From 7ae5a26fad83b53af6fd6c4c59e9563a6d18ee8a Mon Sep 17 00:00:00 2001 From: Bazaah Date: Mon, 26 Apr 2021 10:44:22 +0000 Subject: [PATCH 1/3] bugfix: . now selects the current word --- vimrc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vimrc b/vimrc index e4cc5f3..741144e 100644 --- a/vimrc +++ b/vimrc @@ -260,8 +260,12 @@ if has_key(plugs, 'coc.nvim') let g:coc_global_extensions+=[ 'coc-markdownlint' ] let g:coc_global_extensions+=[ 'coc-yaml' ] - " Do action on current object - nmap . :CocAction + " Do action on current word + nmap . (coc-codeaction-selected)w + + " Do action on a selection + nmap / (coc-codeaction-selected) + xmap / (coc-codeaction-selected) " Use tab for trigger completion with characters ahead and navigate. " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by From 05e3ef0cc1e23d4c3fc35455da278a608a41fb9b Mon Sep 17 00:00:00 2001 From: psox Date: Thu, 8 Jul 2021 16:42:47 +0100 Subject: [PATCH 2/3] fix problem with xhost --- zshrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zshrc b/zshrc index 15ef60b..39fd880 100755 --- a/zshrc +++ b/zshrc @@ -266,7 +266,7 @@ if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then fi [[ -d /cygdrive/c/qemu/ ]] && path+=( /cygdrive/c/qemu/ ) -[[ ! -z "$DISPLAY" ]] && xhost +LOCAL: +( which xhost &>/dev/null ) && [[ -n "$DISPLAY" ]] && xhost +LOCAL: # Set Time Variables precmd() { @@ -283,7 +283,7 @@ precmd() { # Remove unwanted aliases -( where fd | grep -E '\/s?bin\/fd' ) && alias fd &>/dev/null && unalias fd +( where fd | grep -qE '\/s?bin\/fd' ) && alias fd &>/dev/null && unalias fd # Clean up global aliases source <(alias -g | awk -F= '/^[A-Za-z]+/{print $1}' | xargs -I{} -n1 echo unalias "'{}'") From a45652fd2e4f79417fbe75ab3162ea6065644160 Mon Sep 17 00:00:00 2001 From: Paul Stemmet Date: Sun, 8 Aug 2021 20:22:07 +0100 Subject: [PATCH 3/3] Feature/fzf commands (#4) * vimrc: fix signcolumn, prune quickfix,netrw buffers from list * vimrc: add FZF shortcuts, overrides * vimrc: improvements to coc.nvim, check for node --- vimrc | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 9 deletions(-) diff --git a/vimrc b/vimrc index 741144e..bad40ec 100644 --- a/vimrc +++ b/vimrc @@ -68,16 +68,16 @@ set completeopt+=longest " Lower update time (Default 4000) set updatetime=300 -" Always show the signcolumn, otherwise it would shift the text each time -" diagnostics appear/become resolved. +set number +set relativenumber try - " Vim 8.2 only - set signcolumn=number + set signcolumn=auto catch set signcolumn=yes:1 endtry -set number -set relativenumber + +" Use existing buffers +set switchbuf="useopen,usetab" if exists('+termguicolors') set termguicolors @@ -106,12 +106,12 @@ call plug#begin("$VIMHOME/plugged") Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' } Plug 'scrooloose/nerdcommenter' Plug 'scrooloose/vim-statline' + Plug 'qpkorr/vim-bufkill' Plug 'vim-perl/vim-perl', { 'for': 'perl', 'do': 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny' } Plug 'rust-lang/rust.vim', { 'for': 'rust' } Plug 'pearofducks/ansible-vim', { 'for': ['yaml', 'yml'] } Plug 'luochen1990/rainbow' Plug 'kevinoid/vim-jsonc' - Plug 'jremmen/vim-ripgrep', { 'on': ['Rg', 'RgRoot'] } Plug 'junegunn/fzf', { 'on': ['FZF', 'fzf#run', 'fzf#wrap'] } Plug 'junegunn/fzf.vim' Plug 'sheerun/vim-polyglot' @@ -243,12 +243,33 @@ augroup PsoxFileAutos \| endif if has_key(plugs, 'coc.nvim') + " Highlight the symbol and its references when hovering autocmd CursorHold * silent call CocActionAsync('highlight') + " Update signature help on jump placeholder + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') endif + + " Force non file buffers to not pollute the buffer list + autocmd FileType quickfix,netrw setlocal nobuflisted + + " Actually kill netrw when trying to quit it + autocmd FileType netrw nnoremap :call CloseNetrw() augroup END +function! s:CloseNetrw() abort + for bufn in range(1, bufnr('$')) + if bufexists(bufn) && getbufvar(bufn, '&filetype') ==# 'netrw' + silent! execute 'bwipeout ' . bufn + if getline(2) =~# '^" Netrw ' + silent! bwipeout + endif + return + endif + endfor +endfunction + " Set bindings for coc.nvim -if has_key(plugs, 'coc.nvim') +if has_key(plugs, 'coc.nvim') && executable("node") if !exists("g:coc_global_extensions") let g:coc_global_extensions=[] endif @@ -267,6 +288,12 @@ if has_key(plugs, 'coc.nvim') nmap / (coc-codeaction-selected) xmap / (coc-codeaction-selected) + " rename symbol + nnoremap rn (coc-rename) + " goto definition / references + nnoremap gd (coc-definition) + nnoremap gr (coc-references) + " Use tab for trigger completion with characters ahead and navigate. " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by " other plugin before putting this into your config. @@ -317,6 +344,36 @@ if has_key(plugs, 'coc.nvim') nnoremap :CocList -A --normal yank endif +" FZF overides +if has_key(plugs, 'fzf.vim') + if executable('rg') + " Only search file contents, not file name + " We can use the stock :Files for that + command! -bang -nargs=* Rg call + \ fzf#vim#grep( + \ "rg --column --line-number --no-heading --color=always --smart-case ".shellescape(), + \ 1, + \ fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}), + \ 0 + \ ) + + " Override the default grep implementation in vim + set grepprg=rg\ --vimgrep\ --smart-case\ --follow + + " If the user hasn't set a default FZF command, and has ripgrep installed, + " use it over find, otherwise defer to the user's preferred command + if empty($FZF_DEFAULT_COMMAND) + command! -bang -nargs=? -complete=dir Files call + \ fzf#vim#files(, fzf#vim#with_preview({'source': 'rg --files --hidden --glob "!**/.git/**" ' }), 0) + endif + + nnoremap :Rg + endif + + nnoremap :Files + nnoremap :Buffers +endif + " Vim Tmux unified movement if has_key(plugs, 'vim-tmux-navigator') let g:tmux_navigator_no_mappings = 1 @@ -347,7 +404,7 @@ function! ToggleGutter() abort exec "set nonumber norelativenumber signcolumn=no" else exec "set number relativenumber" - try | set signcolumn=number | catch | set signcolumn=yes:1 | endtry + try | set signcolumn=auto | catch | set signcolumn=yes:1 | endtry endif endfunction