From 14a5399cdc3ade18042843e47709cbe8e283aba2 Mon Sep 17 00:00:00 2001 From: Mark Riedesel Date: Tue, 26 Jan 2021 10:07:43 -0500 Subject: [PATCH] update my nvim since apparently I'm gonna use that again --- _config/nvim/coc-settings.json | 29 ++++++ _config/nvim/init.vim | 184 ++++++++++++++++++++------------- 2 files changed, 144 insertions(+), 69 deletions(-) create mode 100644 _config/nvim/coc-settings.json diff --git a/_config/nvim/coc-settings.json b/_config/nvim/coc-settings.json new file mode 100644 index 0000000..da5a158 --- /dev/null +++ b/_config/nvim/coc-settings.json @@ -0,0 +1,29 @@ +{ + "languageserver": { + "ccls": { + "command": "ccls", + "filetypes": [ + "c", + "cpp" + ], + "rootPatterns": [ + ".ccls", + ".git/", + ".hg/", + ".vim/", + "compile_commands.json" + ], + "initializationOptions":{ + "cache": { + "directory": "/tmp/ccls" + } + } + }, + "godot": { + "host": "127.0.0.1", + "filetypes": ["gdscript"], + "port": 6008 + } + }, + "tsserver.log": "off" +} diff --git a/_config/nvim/init.vim b/_config/nvim/init.vim index bc51ac3..26eb37f 100644 --- a/_config/nvim/init.vim +++ b/_config/nvim/init.vim @@ -26,8 +26,9 @@ set ignorecase set incsearch " search as you type set hidden " sometimes I don't want to save a buffer before switching away from it set cmdheight=2 -set updatetime=300 +set updatetime=750 set signcolumn=yes +set shortmess+=c set completeopt-=preview set matchtime=1 @@ -50,6 +51,7 @@ call plug#begin('~/.local/share/nvim/plugged') " color schemes Plug 'dylanaraps/wal.vim' +Plug 'sickill/vim-monokai' " syntax Plug 'cakebaker/scss-syntax.vim' @@ -57,8 +59,10 @@ Plug 'calviken/vim-gdscript3' Plug 'ianks/vim-tsx' Plug 'leafgarland/typescript-vim' Plug 'lepture/vim-jinja' -Plug 'posva/vim-vue' Plug 'nikvdp/ejs-syntax' +Plug 'noahfrederick/vim-noctu' +Plug 'posva/vim-vue' +Plug 'numirias/semshi', {'do': ':UpdateRemotePlugins'} " functionality Plug 'tpope/vim-sensible' @@ -72,25 +76,60 @@ Plug 'tpope/vim-commentary', "{{{ xmap c Commentary omap c Commentary nmap cc CommentaryLine + autocmd FileType vue setlocal commentstring=//\ %s "}}} + Plug 'tpope/vim-fugitive', "{{{ map \b :Gblame map \l :Glog map \gs :Gstatus "}}} -Plug 'carlitux/deoplete-ternjs', {'do': 'npm install -g tern'} -"Plug 'w0rp/ale', "{{{ -" let g:ale_linters = { -" \ 'c': ['clang'], -" \ 'cpp': ['clangx'], -" \ 'php': ['phpcs'], -" \ 'javascript': ['eslint'], -" \} -" let g:ale_python_pylint_options = '--load-plugins pylint_django' -" let g:ale_sign_error = '⬤' -""}}} -" Use release branch (Recommend) -Plug 'neoclide/coc.nvim', {'branch': 'release'} + +Plug 'neoclide/coc.nvim', {'branch': 'release'}, "{{{ + inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() + + inoremap pumvisible() ? "\" : "\" + + function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' + endfunction + " Remap keys for gotos + nmap gd (coc-definition) + nmap gy (coc-type-definition) + nmap gi (coc-implementation) + nmap gr (coc-references) + + nmap ]p :CocPrev + nmap [p :CocNext + + nmap f (coc-fix-current) + + " Use to trigger completion. + inoremap coc#refresh() + + " Highlight symbol under cursor on CursorHold + autocmd CursorHold * silent call CocActionAsync('highlight') + + " Use K to show documentation in preview window + nnoremap K :call show_documentation() + + function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) + execute 'h '.expand('') + else + call CocAction('doHover') + endif + endfunction + + " Use to confirm completion, `u` means break undo chain at current position. + " Coc only does snippet and additional edit on confirm. + inoremap pumvisible() ? "\" : "\u\" +"}}} + Plug 'vim-airline/vim-airline-themes' Plug 'vim-airline/vim-airline', "{{{ let g:airline_symbols = {} @@ -102,48 +141,32 @@ Plug 'vim-airline/vim-airline', "{{{ "}}} Plug 'mattn/webapi-vim' Plug 'mattn/gist-vim' +Plug 'airblade/vim-gitgutter' Plug 'easymotion/vim-easymotion', "{{{ map (easymotion-prefix) "}}} -"Plug 'mhartington/nvim-typescript', {'do': './install.sh'} -" if has('nvim') -" Plug 'Shougo/deoplete.nvim', {'do': ':UpdateRemotePlugins'} -" else -" Plug 'Shougo/deoplete.nvim' -" Plug 'roxma/nvim-yarp' -" Plug 'roxma/vim-hug-neovim-rpc' -" endif -" let g:deoplete#enable_at_startup = 1 -" let g:deoplete#enable_smart_case = 1 -" let g:deoplete#sources#syntax#min_keyword_length = 2 -" Plug 'Shougo/denite.nvim' -"Plug 'Shougo/neosnippet-snippets' -"Plug 'Shougo/neosnippet.vim', "{{{ -" let g:neosnippet#snippets_directory = '~/.vim/bundle/'.expand(fnamemodify($MYVIMRC, ':p:h').'/snippets/') -" let g:neosnippet#enable_snipmate_compatibility = 1 -""}}} Plug 'junegunn/fzf', {'dir': '~/.fzf', 'do': './install --all'} Plug 'junegunn/fzf.vim', "{{{ function! s:buflist() - redir => ls - silent ls - redir END - return split(ls,'\n') + redir => ls + silent ls + redir END + return split(ls,'\n') endfunction function! s:bufopen(e) - execute 'buffer' matchstr(a:e, '^[ 0-9]*') + execute 'buffer' matchstr(a:e, '^[ 0-9]*') endfunction nnoremap :call fzf#run({ - \ 'source': reverse(buflist()), - \ 'sink': function('bufopen'), - \ 'options': '+m', - \ 'down': len(buflist()) + 2 - \}) + \ 'source': reverse(buflist()), + \ 'sink': function('bufopen'), + \ 'options': '+m', + \ 'down': len(buflist()) + 2 + \}) + - function! s:FuzzyFiles() let gitparent=system('git rev-parse --show-toplevel')[:-2] let rootdir='.' @@ -176,39 +199,62 @@ Plug 'junegunn/fzf.vim', "{{{ "}}} call plug#end() -" key bindings -map :bnext -map :bprev -nmap j " faster window movement -nmap k -nmap h -nmap l -vmap :sort " sort lines in visual mode with ctrl-o -map mzgg=G`z " autoformat document -nmap n :set invnumber " toggle line numbers -vnoremap < >gv -nnoremap pu :PlugUpdate " vim-plug actions -nnoremap pi :PlugInstall -nnoremap pc :PlugClean -nnoremap o :jumps " show jumps list -nnoremap zn ]s " next misspelling -nnoremap zp [s " prev misspelling -nnoremap zf 1z= " replace misspelling with first suggestion -nnoremap z! :set local spell! " toggle spellcheck -nnoremap ve :e $MYVIMRC " quick open this (literally this) file -if executable('rg') - set grepprg='rg\ --vimgrep' " use ripgrep if available -endif - " theme / visual try - colorscheme wal + " colorscheme wal + colorscheme monokai catch endtry hi clear SpellBad " italicize misspellings hi SpellBad gui=underline cterm=italic +highlight ExtraWhitespace ctermbg=20 ctermfg=1 +match ExtraWhitespace /\s\+$/ +autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ +autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@ :bnext " next buffer +map :bprev " prev buffer + +nmap j " focus window down +nmap k " focus window up +nmap h " focus window left +nmap l " focus window right + +vnoremap :sort " visual select and sort +noremap mzgg=G`z " auto-format entire document + +nnoremap pu :PlugUpdate " update plugins managed by vim-plugged +nnoremap pi :PlugInstall " install new plugins +nnoremap pc :PlugClean " clean removed plugins + +nnoremap zn ]s " next misspelling +nnoremap zp [s " prev misspelling +nnoremap zf 1z= " replace misspelling with first suggestion + +nnoremap n :set number! " toggle numbering + +nnoremap ve :e $MYVIMRC " quick open (literally) this file + +nmap w :w! " fast save + +" clear trailing white space +nnoremap :let _s=@/ :%s/\s\+$//e :let @/=_s :nohl :unlet _s + +" prefer ripgrep if available +if executable('rg') + set grepprg="rg --vimgrep" +endif + +" save with sudo +command! W execute 'w !sudo tee %> /dev/null' edit! + " netrw nnoremap \e :Lexplore! let g:netrw_banner = 0