From 78fb2c072fef3a08d9bdc9788bbd9b89311b933c Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 3 Nov 2020 18:50:33 -0500 Subject: all kinds of stuff --- README.md | 10 +-- coc-settings.json | 7 ++ init.vim | 3 +- keys/which-key.vim | 77 ++++++++-------- lua/nvcodeline.lua | 13 +++ plug-config/coc.vim | 180 ------------------------------------- plug-config/coc/coc-extensions.vim | 33 +++++++ plug-config/coc/coc.vim | 143 +++++++++++++++++++++++++++++ utils/images/nvim.png | Bin 1380470 -> 858621 bytes 9 files changed, 237 insertions(+), 229 deletions(-) delete mode 100644 plug-config/coc.vim create mode 100644 plug-config/coc/coc-extensions.vim create mode 100644 plug-config/coc/coc.vim mode change 100644 => 100755 utils/images/nvim.png diff --git a/README.md b/README.md index cf3bcddc..09c5e1c8 100644 --- a/README.md +++ b/README.md @@ -185,15 +185,12 @@ Along with some of my config files you can find in `utils/vscode_config` ## TODO - Better Documentation -- Improve VSCode which-key config ## CoC extensions to check out -- coc-fzf -- coc-stylelintplus +- coc-fzf-preview + - https://github.com/yuki-ycino/fzf-preview.vim/ - coc-floaterm -- coc-actions -- coc-bookmark ## 0.5 @@ -207,12 +204,13 @@ If anyone reading this has any suggestions about implementing any of the followi - ale - multiple cursors - markdown table -- spaceline (add colorscheme for mach2) +- galaxyline automatically grab colors from colorscheme - tpope/vim-dadbod - neovide - People asked about vimwiki I kinda hate it but maybe I'll add it - vimspector this is included but I don't plan on using it much - can be used with jdb, pdb, gdb, etc... +- nvim-dap and nvim-dap-virtual-text (ALL DEBUGGING IN NEOVIM IS CONFUSING AND HARD TO GET WORKING OR I'M JUST DUMB) - later manually link pylance - resize with arrows in addition to meta - how to support meta key on for macOS? diff --git a/coc-settings.json b/coc-settings.json index b6be78fc..335dd0d7 100644 --- a/coc-settings.json +++ b/coc-settings.json @@ -58,6 +58,12 @@ "javascript": "javascriptreact" }, + // CSS (disable since I'm also using stylelintplus) + "css.validate": false, + "less.validate": false, + "scss.validate": false, + "wxss.validate": false, + // explorer "explorer.width": 30, "explorer.icon.enableNerdfont": true, @@ -68,6 +74,7 @@ "": ["expandable?", "expand", "open"], "v": "open:vsplit" }, + "bookmark.sign": "", //coc-emoji "coc.source.emoji.filetypes": ["markdown"] diff --git a/init.vim b/init.vim index 768f519c..21fddc43 100644 --- a/init.vim +++ b/init.vim @@ -35,7 +35,8 @@ else source $HOME/.config/nvim/plug-config/vim-wiki.vim luafile $HOME/.config/nvim/lua/nvcodeline.lua luafile $HOME/.config/nvim/lua/treesitter.lua - source $HOME/.config/nvim/plug-config/coc.vim + source $HOME/.config/nvim/plug-config/coc/coc.vim + source $HOME/.config/nvim/plug-config/coc/coc-extensions.vim source $HOME/.config/nvim/plug-config/easymotion.vim source $HOME/.config/nvim/plug-config/goyo.vim source $HOME/.config/nvim/plug-config/vim-rooter.vim diff --git a/keys/which-key.vim b/keys/which-key.vim index 412517a9..ba3cc1da 100644 --- a/keys/which-key.vim +++ b/keys/which-key.vim @@ -35,15 +35,14 @@ let g:which_key_map['='] = [ '=' , 'balance win let g:which_key_map['d'] = [ ':Bdelete' , 'delete buffer'] let g:which_key_map['e'] = [ ':CocCommand explorer' , 'explorer' ] let g:which_key_map['h'] = [ 's' , 'split below'] -let g:which_key_map['m'] = [ ':call WindowSwap#EasyWindowSwap()' , 'move window' ] let g:which_key_map['n'] = [ ':let @/ = ""' , 'no highlight' ] +let g:which_key_map['o'] = [ ':RnvimrToggle' , 'open' ] let g:which_key_map['p'] = [ ':Files' , 'search files' ] let g:which_key_map['q'] = [ 'q' , 'quit' ] -let g:which_key_map['r'] = [ ':RnvimrToggle' , 'ranger' ] let g:which_key_map['T'] = [ ':TSHighlightCapturesUnderCursor' , 'treesitter highlight' ] let g:which_key_map['u'] = [ ':UndotreeToggle' , 'undo tree'] let g:which_key_map['v'] = [ 'v' , 'split right'] -let g:which_key_map['W'] = [ 'w' , 'write' ] +let g:which_key_map['W'] = [ ':call WindowSwap#EasyWindowSwap()' , 'move window' ] let g:which_key_map['z'] = [ 'Goyo' , 'zen' ] " Group mappings @@ -96,7 +95,7 @@ let g:which_key_map.b = { " f is for find and replace let g:which_key_map.f = { \ 'name' : '+find & replace' , - \ 'b' : [':Farr --source=vimgrep' , 'buffer'], + \ 'f' : [':Farr --source=vimgrep' , 'file'], \ 'p' : [':Farr --source=rgnvim' , 'project'], \ } @@ -118,6 +117,18 @@ let g:which_key_map.k = { \ } " \ 'l' : [':AsyncTaskList' , 'list tasks'], +" m is for mark +let g:which_key_map.m = { + \ 'name' : '+mark' , + \ 'c' : [':CocCommand bookmark.clearForCurrentFile', 'clear file'], + \ 'C' : [':CocCommand bookmark.clearForAllFiles', 'clear project'], + \ 'j' : [':CocCommand bookmark.next', 'next bookmark'], + \ 'k' : [':CocCommand bookmark.prev', 'prev bookmark'], + \ 't' : [':CocCommand bookmark.toggle', 'toggle bookmark'], + \ } + " CoC throws an error + " \ 'a' : [':CocCommand bookmark.annotate', 'annotate bookmark'], + " s is for search let g:which_key_map.s = { \ 'name' : '+search' , @@ -223,7 +234,7 @@ let g:which_key_map.l = { \ 'n' : ['(coc-diagnostic-next)' , 'next diagnostic'], \ 'N' : ['(coc-diagnostic-next-error)' , 'next error'], \ 'o' : [':Vista!!' , 'outline'], - \ 'O' : [':CocList outline' , 'outline'], + \ 'O' : [':CocList outline' , 'search outline'], \ 'p' : ['(coc-diagnostic-prev)' , 'prev diagnostic'], \ 'P' : ['(coc-diagnostic-prev-error)' , 'prev error'], \ 'q' : ['(coc-fix-current)' , 'quickfix'], @@ -256,44 +267,26 @@ let g:which_key_map.t = { \ 's' : [':FloatermNew ncdu' , 'ncdu'], \ } -" " T is for terminal -" let g:which_key_map.T = { -" \ 'name' : '+tabline' , -" \ 'b' : [':XTabListBuffers' , 'list buffers'], -" \ 'd' : [':XTabCloseBuffer' , 'close buffer'], -" \ 'D' : [':XTabDeleteTab' , 'close tab'], -" \ 'h' : [':XTabHideBuffer' , 'hide buffer'], -" \ 'i' : [':XTabInfo' , 'info'], -" \ 'l' : [':XTabLock' , 'lock tab'], -" \ 'm' : [':XTabMode' , 'toggle mode'], -" \ 'n' : [':tabNext' , 'next tab'], -" \ 'N' : [':XTabMoveBufferNext' , 'buffer->'], -" \ 't' : [':tabnew' , 'new tab'], -" \ 'p' : [':tabprevious' , 'prev tab'], -" \ 'P' : [':XTabMoveBufferPrev' , '<-buffer'], -" \ 'x' : [':XTabPinBuffer' , 'pin buffer'], -" \ } - " w is for wiki -let g:which_key_map.w = { - \ 'name' : '+wiki' , - \ 'w' : ['VimwikiIndex' , 'ncdu'], - \ 'n' : ['(wiki-open)' , 'ncdu'], - \ 'j' : ['(wiki-journal)' , 'ncdu'], - \ 'R' : ['(wiki-reload)' , 'ncdu'], - \ 'c' : ['(wiki-code-run)' , 'ncdu'], - \ 'b' : ['(wiki-graph-find-backlinks)' , 'ncdu'], - \ 'g' : ['(wiki-graph-in)' , 'ncdu'], - \ 'G' : ['(wiki-graph-out)' , 'ncdu'], - \ 'l' : ['(wiki-link-toggle)' , 'ncdu'], - \ 'd' : ['(wiki-page-delete)' , 'ncdu'], - \ 'r' : ['(wiki-page-rename)' , 'ncdu'], - \ 't' : ['(wiki-page-toc)' , 'ncdu'], - \ 'T' : ['(wiki-page-toc-local)' , 'ncdu'], - \ 'e' : ['(wiki-export)' , 'ncdu'], - \ 'u' : ['(wiki-list-uniq)' , 'ncdu'], - \ 'U' : ['(wiki-list-uniq-local)' , 'ncdu'], - \ } +" let g:which_key_map.w = { +" \ 'name' : '+wiki' , +" \ 'w' : ['VimwikiIndex' , 'ncdu'], +" \ 'n' : ['(wiki-open)' , 'ncdu'], +" \ 'j' : ['(wiki-journal)' , 'ncdu'], +" \ 'R' : ['(wiki-reload)' , 'ncdu'], +" \ 'c' : ['(wiki-code-run)' , 'ncdu'], +" \ 'b' : ['(wiki-graph-find-backlinks)' , 'ncdu'], +" \ 'g' : ['(wiki-graph-in)' , 'ncdu'], +" \ 'G' : ['(wiki-graph-out)' , 'ncdu'], +" \ 'l' : ['(wiki-link-toggle)' , 'ncdu'], +" \ 'd' : ['(wiki-page-delete)' , 'ncdu'], +" \ 'r' : ['(wiki-page-rename)' , 'ncdu'], +" \ 't' : ['(wiki-page-toc)' , 'ncdu'], +" \ 'T' : ['(wiki-page-toc-local)' , 'ncdu'], +" \ 'e' : ['(wiki-export)' , 'ncdu'], +" \ 'u' : ['(wiki-list-uniq)' , 'ncdu'], +" \ 'U' : ['(wiki-list-uniq-local)' , 'ncdu'], +" \ } " Global " VimwikiIndex diff --git a/lua/nvcodeline.lua b/lua/nvcodeline.lua index f66c2e9a..e416b2c3 100644 --- a/lua/nvcodeline.lua +++ b/lua/nvcodeline.lua @@ -256,3 +256,16 @@ gls.short_line_left[1] = { -- highlight = {colors.grey,colors.purple} -- } -- } +-- function! s:my_bookmark_color() abort +-- let s:scl_guibg = matchstr(execute('hi SignColumn'), 'guibg=\zs\S*') +-- if empty(s:scl_guibg) +-- let s:scl_guibg = 'NONE' +-- endif +-- exe 'hi MyBookmarkSign guifg=' . s:scl_guibg +-- endfunction +-- call s:my_bookmark_color() " don't remove this line! + +-- augroup UserGitSignColumnColor +-- autocmd! +-- autocmd ColorScheme * call s:my_bookmark_color() +-- augroup END diff --git a/plug-config/coc.vim b/plug-config/coc.vim deleted file mode 100644 index 82f9723b..00000000 --- a/plug-config/coc.vim +++ /dev/null @@ -1,180 +0,0 @@ - let g:coc_global_extensions = [ - \ 'coc-snippets', - \ 'coc-actions', - \ 'coc-sh', - \ 'coc-java-debug', - \ 'coc-java', - \ 'coc-lists', - \ 'coc-emmet', - \ 'coc-tasks', - \ 'coc-pairs', - \ 'coc-tsserver', - \ 'coc-floaterm', - \ 'coc-html', - \ 'coc-css', - \ 'coc-emoji', - \ 'coc-cssmodules', - \ 'coc-yaml', - \ 'coc-python', - \ 'coc-pyright', - \ 'coc-explorer', - \ 'coc-svg', - \ 'coc-prettier', - \ 'coc-vimlsp', - \ 'coc-xml', - \ 'coc-yank', - \ 'coc-json', - \ 'coc-marketplace', - \ ] - " \ 'coc-tabnine', - " \ 'coc-highlight', - -" Use tab for trigger completion with characters ahead and navigate. -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 - -" Use to trigger completion. -inoremap coc#refresh() - -" Use to confirm completion, `u` means break undo chain at current -" position. Coc only does snippet and additional edit on confirm. -if exists('*complete_info') - inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" -else - imap pumvisible() ? "\" : "\u\" -endif - -" GoTo code navigation. -nmap gd (coc-definition) -nmap gy (coc-type-definition) -nmap gi (coc-implementation) -nmap gr (coc-references) - -" 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 - -" Highlight the symbol and its references when holding the cursor. -autocmd CursorHold * silent call CocActionAsync('highlight') - -" Symbol renaming. -" nmap rn (coc-rename) - -augroup mygroup - autocmd! - " Setup formatexpr specified filetype(s). - autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') - " Update signature help on jump placeholder. - autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') -augroup end - -" Applying codeAction to the selected region. -" Example: `aap` for current paragraph -" xmap a (coc-codeaction-selected) -" nmap a (coc-codeaction-selected) - -" Remap keys for applying codeAction to the current line. -" nmap ac (coc-codeaction) -" Apply AutoFix to problem on the current line. -" nmap qf (coc-fix-current) - -" Introduce function text object -" NOTE: Requires 'textDocument.documentSymbol' support from the language server. -xmap if (coc-funcobj-i) -xmap af (coc-funcobj-a) -omap if (coc-funcobj-i) -omap af (coc-funcobj-a) - -" Use for selections ranges. -" NOTE: Requires 'textDocument/selectionRange' support from the language server. -" coc-tsserver, coc-python are the examples of servers that support it. -" nmap (coc-range-select) -" xmap (coc-range-select) - -" Add `:Format` command to format current buffer. -command! -nargs=0 Format :call CocAction('format') - -" Add `:Fold` command to fold current buffer. -command! -nargs=? Fold :call CocAction('fold', ) - -" Add `:OR` command for organize imports of the current buffer. -command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') - -" Add (Neo)Vim's native statusline support. -" NOTE: Please see `:h coc-status` for integrations with external plugins that -" provide custom statusline: lightline.vim, vim-airline. -set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} - -" Mappings using CoCList: -" Show all diagnostics. -" TODO add these to which key -" nnoremap a :CocList diagnostics -" " Manage extensions. -" nnoremap e :CocList extensions -" " Show commands. -" nnoremap c :CocList commands -" " Find symbol of current document. -" nnoremap o :CocList outline -" " Search workspace symbols. -" nnoremap s :CocList -I symbols -" " Do default action for next item. -" nnoremap j :CocNext -" " Do default action for previous item. -" nnoremap k :CocPrev -" " Resume latest coc list. -" nnoremap p :CocListResume - -" Explorer -let g:coc_explorer_global_presets = { -\ 'floating': { -\ 'position': 'floating', -\ }, -\ 'floatingLeftside': { -\ 'position': 'floating', -\ 'floating-position': 'left-center', -\ 'floating-width': 30, -\ }, -\ 'floatingRightside': { -\ 'position': 'floating', -\ 'floating-position': 'right-center', -\ 'floating-width': 30, -\ }, -\ 'simplify': { -\ 'file.child.template': '[selection | clip | 1] [indent][icon | 1] [filename omitCenter 1]' -\ } -\ } -"nmap e :CocCommand explorer -" nnoremap e :CocCommand explorer -" nmap f :CocCommand explorer --preset floatingRightside -autocmd BufEnter * if (winnr("$") == 1 && &filetype == 'coc-explorer') | q | endif - -" Snippets -" Use for trigger snippet expand. -imap (coc-snippets-expand) - -" Use for select text for visual placeholder of snippet. -vmap (coc-snippets-select) - -" Use for jump to next placeholder, it's default of coc.nvim -let g:coc_snippet_next = '' - -" Use for jump to previous placeholder, it's default of coc.nvim -let g:coc_snippet_prev = '' - -" Use for both expand and jump (make expand higher priority.) -imap (coc-snippets-expand-jump) diff --git a/plug-config/coc/coc-extensions.vim b/plug-config/coc/coc-extensions.vim new file mode 100644 index 00000000..1466aafc --- /dev/null +++ b/plug-config/coc/coc-extensions.vim @@ -0,0 +1,33 @@ +let g:coc_global_extensions = [ + \ 'coc-snippets', + \ 'coc-actions', + \ 'coc-sh', + \ 'coc-java-debug', + \ 'coc-java', + \ 'coc-lists', + \ 'coc-emmet', + \ 'coc-tasks', + \ 'coc-pairs', + \ 'coc-tsserver', + \ 'coc-floaterm', + \ 'coc-html', + \ 'coc-css', + \ 'coc-cssmodules', + \ 'coc-stylelintplus', + \ 'coc-emoji', + \ 'coc-bookmark', + \ 'coc-yaml', + \ 'coc-python', + \ 'coc-pyright', + \ 'coc-explorer', + \ 'coc-svg', + \ 'coc-prettier', + \ 'coc-vimlsp', + \ 'coc-xml', + \ 'coc-yank', + \ 'coc-json', + \ 'coc-marketplace', + \ ] + " \ 'coc-tabnine', + " \ 'coc-highlight', + diff --git a/plug-config/coc/coc.vim b/plug-config/coc/coc.vim new file mode 100644 index 00000000..597d39d9 --- /dev/null +++ b/plug-config/coc/coc.vim @@ -0,0 +1,143 @@ +" Use tab for trigger completion with characters ahead and navigate. +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 + +" Use to trigger completion. +inoremap coc#refresh() + +" Use to confirm completion, `u` means break undo chain at current +" position. Coc only does snippet and additional edit on confirm. +if exists('*complete_info') + inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" +else + imap pumvisible() ? "\" : "\u\" +endif + +" GoTo code navigation. +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +" 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 + +" Highlight the symbol and its references when holding the cursor. +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Symbol renaming. +" nmap rn (coc-rename) + +augroup mygroup + autocmd! + " Setup formatexpr specified filetype(s). + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') + " Update signature help on jump placeholder. + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') +augroup end + +" Applying codeAction to the selected region. +" Example: `aap` for current paragraph +" xmap a (coc-codeaction-selected) +" nmap a (coc-codeaction-selected) + +" Remap keys for applying codeAction to the current line. +" nmap ac (coc-codeaction) +" Apply AutoFix to problem on the current line. +" nmap qf (coc-fix-current) + +" Introduce function text object +" NOTE: Requires 'textDocument.documentSymbol' support from the language server. +xmap if (coc-funcobj-i) +xmap af (coc-funcobj-a) +omap if (coc-funcobj-i) +omap af (coc-funcobj-a) + +" Add `:Format` command to format current buffer. +command! -nargs=0 Format :call CocAction('format') + +" Add `:Fold` command to fold current buffer. +command! -nargs=? Fold :call CocAction('fold', ) + +" Add `:OR` command for organize imports of the current buffer. +command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') + +" Add (Neo)Vim's native statusline support. +" NOTE: Please see `:h coc-status` for integrations with external plugins that +" provide custom statusline: lightline.vim, vim-airline. +set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} + +" Mappings using CoCList: +" Show all diagnostics. +" TODO add these to which key +" nnoremap a :CocList diagnostics +" " Manage extensions. +" nnoremap e :CocList extensions +" " Show commands. +" nnoremap c :CocList commands +" " Find symbol of current document. +" nnoremap o :CocList outline +" " Search workspace symbols. +" nnoremap s :CocList -I symbols +" " Do default action for next item. +" nnoremap j :CocNext +" " Do default action for previous item. +" nnoremap k :CocPrev +" " Resume latest coc list. +" nnoremap p :CocListResume + +" Explorer +let g:coc_explorer_global_presets = { +\ 'floating': { +\ 'position': 'floating', +\ }, +\ 'floatingLeftside': { +\ 'position': 'floating', +\ 'floating-position': 'left-center', +\ 'floating-width': 30, +\ }, +\ 'floatingRightside': { +\ 'position': 'floating', +\ 'floating-position': 'right-center', +\ 'floating-width': 30, +\ }, +\ 'simplify': { +\ 'file.child.template': '[selection | clip | 1] [indent][icon | 1] [filename omitCenter 1]' +\ } +\ } +"nmap e :CocCommand explorer +" nnoremap e :CocCommand explorer +" nmap f :CocCommand explorer --preset floatingRightside +autocmd BufEnter * if (winnr("$") == 1 && &filetype == 'coc-explorer') | q | endif + +" Snippets +" Use for trigger snippet expand. +imap (coc-snippets-expand) + +" Use for select text for visual placeholder of snippet. +vmap (coc-snippets-select) + +" Use for jump to next placeholder, it's default of coc.nvim +let g:coc_snippet_next = '' + +" Use for jump to previous placeholder, it's default of coc.nvim +let g:coc_snippet_prev = '' + +" Use for both expand and jump (make expand higher priority.) +imap (coc-snippets-expand-jump) diff --git a/utils/images/nvim.png b/utils/images/nvim.png old mode 100644 new mode 100755 index f1530d87..bbb72c42 Binary files a/utils/images/nvim.png and b/utils/images/nvim.png differ -- cgit v1.2.3