diff --git a/nvim/init.vim b/nvim/init.vim index 87ccb46..275da13 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -8,19 +8,23 @@ if ! filereadable(expand('~/.config/nvim/autoload/plug.vim')) silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim endif let g:coc_global_extensions=[ - \ 'coc-fzf-preview', \ 'coc-python', \ 'coc-git', \ 'coc-tsserver', \ 'coc-diagnostic', - \ 'coc-yaml' + \ 'coc-yaml', + \ 'coc-explorer' \ ] call plug#begin('~/.config/nvim/plugged') " tools Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'junegunn/fzf', {'dir': '~/.fzf', 'do': './install --all'} +Plug 'junegunn/fzf.vim' +Plug 'antoinemadec/coc-fzf', {'branch': 'release'} +Plug 'liuchengxu/vista.vim' " tags explorer Plug 'sheerun/vim-polyglot' " language syntax +" git Plug 'tpope/vim-fugitive' Plug 'junegunn/gv.vim' " markdown @@ -34,14 +38,10 @@ Plug 'farmergreg/vim-lastplace' " When reopen a buffer, puts the cursor wh Plug 'christoomey/vim-tmux-navigator' " integrate movement in tmux and vim Plug 'haya14busa/vim-asterisk' " better asterisk motions Plug 'bfredl/nvim-miniyank' " nvim bugfix block copy -Plug 'qpkorr/vim-bufkill' " delete buffer without closing window " aesthetics Plug 'chriskempson/base16-vim' " base16 themes Plug 'chrisbra/Colorizer' " show color codes Plug 'junegunn/rainbow_parentheses.vim' " colorize parentheses -" file mgmt -Plug 'jeetsukumaran/vim-buffergator' -Plug 'scrooloose/nerdtree' " themes Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' @@ -158,15 +158,19 @@ let maplocalleader="," nnoremap q: nnoremap Q vnoremap v -nnoremap . : -nnoremap , . +nnoremap ø : nmap :noh -nmap :BD nnoremap R :so ~/.config/nvim/init.vim nnoremap E :tabe ~/.config/nvim/init.vim " nerdcommenter: 'c ', 'cl' aligned and 'cu>' remove " vim-surround: visual 'SA' to wrap in A. Surround 'csAB' to change from A to B, 'dsA' to remove A. Word 'ysiwA' to wrap with A +" ***************************** +" EDITING +nmap cr (coc-rename) +xmap cf (coc-format-selected) +nmap cf (coc-format-selected) + " ***************************** " CLIPBOARD (incl bugfix paste unnamedplus) set clipboard+=unnamedplus @@ -202,17 +206,15 @@ let g:asterisk#keeppos=1 " ***************************** " CURSOR " vertical movement remapping ala US -map å ( -map ¨ ) +map å [ +map ¨ ] map Å { map ^ } -map + [ -map \ ] " Treat long lines as break lines (useful when moving around in them) -nmap j gj -nmap k gk -vmap j gj -vmap k gk +"nmap j gj +"nmap k gk +"vmap j gj +"vmap k gk " indenting nnoremap >>_ nnoremap <<_ @@ -243,39 +245,23 @@ nnoremap :vsplit nnoremap :vnew nnoremap :split nnoremap :new -nnoremap T -nnoremap :tabnew -" buffergator & nerdtree +nnoremap T +nnoremap :tabnew +" buffergator nmap :bprev nmap :bnext -nmap :tabprev -nmap :tabnext +nmap :tabprev +nmap :tabnext " resize windows with hjkl nnoremap < nnoremap - nnoremap + nnoremap > -" buffergator & nerdtree -map :NERDTreeToggle -map :BuffergatorToggle -map :BuffergatorTabsToggle -let g:buffergator_mru_cycle_loop=0 -let g:buffergator_suppress_keymaps=1 -let g:buffergator_autoupdate=1 -let g:buffergator_sort_regime='bufnum' -let g:buffergator_display_regime='basename' -let g:buffergator_autodismiss_on_select=0 -let g:buffergator_show_full_directory_path=0 -let g:buffergator_tab_statusline=0 -let g:buffergator_window_statusline=0 -" other C-w commands to remember -" = equalize sizes -" T move buffer to new tab -" move windows with +HJKL -" H -" J -" K -" L +" quickfix window +nmap :cn +nmap :cp +" close buffer +nmap :bd " ***************************** " MARKDOWN @@ -317,23 +303,23 @@ nmap gs :CocCommand git.chunkStage vmap gs :CocCommand git.chunkStage nmap gX :CocCommand git.chunkUndo vmap gX :CocCommand git.chunkUndo -" coc fzf -nmap :CocCommand fzf-preview.GitStatus -nmap :CocCommand fzf-preview.GitActions " ***************************** -" COC FZF -nmap :CocCommand fzf-preview.ProjectGrep -xmap "sy:CocCommand fzf-preview.ProjectGrep-F"=substitute(substitute(@s, '\n', '', 'g'), '/', '\\/', 'g')" -nmap :CocCommand fzf-preview.ProjectGrep -nmap :CocCommand fzf-preview.Lines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'" -nmap :CocCommand fzf-preview.Lines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'=expand('')" -nmap :CocCommand fzf-preview.MruFiles -nmap :CocCommand fzf-preview.ProjectMruFiles -nmap :CocCommand fzf-preview.DirectoryFiles -nmap :CocCommand fzf-preview.ProjectFiles -nmap :CocCommand fzf-preview.Buffers -nmap :CocCommand fzf-preview.AllBuffers +" EXPLORERS +" vista and coc-explorer +map :Vista!! +map :CocCommand explorer +let g:vista_default_executive = 'ctags' +let g:vista_fzf_preview = ['right:50%'] + +" ***************************** +" POPUPS +" TODO coclist fzf +nmap :Ag +nmap :CocFzfList symbols +nmap :History +nmap :History/ +nmap :GFiles let g:fzf_preview_command='bat --color=always --plain {-1}' " Installed bat let g:fzf_preview_grep_cmd='rg --smart-case --line-number --no-heading --color=never' @@ -359,15 +345,6 @@ nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) nmap gR (coc-refactor) -" show coc documentation in preview window -function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - else - call CocAction('doHover') - endif -endfunction -nmap K :call show_documentation() " ***************************** " autocmd @@ -375,10 +352,26 @@ augroup myAu " A unique name for the group. DO NOT use the same name twice! autocmd! autocmd FileType python set tabstop=4 softtabstop=4 shiftwidth=4 autocmd FileType markdown,yaml set tabstop=2 softtabstop=2 shiftwidth=2 - autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o " Disables automatic commenting on newline + autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o " Disables automatic commenting on newline autocmd FileType * RainbowParentheses() autocmd BufEnter * if &filetype == "" | setlocal ft=markdown | endif " default new file is markdown autocmd BufWritePre * %s/\s\+$//e " Automatically deletes all trailing whitespace on save. autocmd BufReadPost quickfix nmap " quickfix autocmd CompleteDone * if pumvisible() == 0 | pclose | endif " bugfix augroup end + +" CTRL-A CTRL-Q to select all and build quickfix list + +function! s:build_quickfix_list(lines) + call setqflist(map(copy(a:lines), '{ "filename": v:val }')) + copen + cc +endfunction + +let g:fzf_action = { +\ 'ctrl-q': function('s:build_quickfix_list'), +\ 'ctrl-t': 'tab split', +\ 'ctrl-s': 'split', +\ 'ctrl-v': 'vsplit' } + +let $FZF_DEFAULT_OPTS = '--bind ctrl-a:select-all'