From f491cba67223affa6fcbdf701d62c50afd994459 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 10 May 2020 13:29:31 -0400 Subject: which key basics --- coc-settings.json | 27 ++++++++++++ general/settings.vim | 2 + init.vim | 8 +++- keys/which-key.vim | 97 +++++++++++++++++++++++++++++++++++++++++--- plug-config/coc.vim | 49 ++++++++++------------ plug-config/fzf.vim | 10 ++--- plug-config/sneak.vim | 2 +- plug-config/start-screen.vim | 6 +++ vim-plug/plugins.vim | 1 - 9 files changed, 160 insertions(+), 42 deletions(-) diff --git a/coc-settings.json b/coc-settings.json index 8599d4ca..edb93d0c 100644 --- a/coc-settings.json +++ b/coc-settings.json @@ -1,10 +1,31 @@ { + + // suggestions + // "suggest.echodocSupport": true, + + // diagnostics + "diagnostic.errorSign": "✗", + "diagnostic.warningSign": "⚠", + "diagnostic.infoSign": "", + "diagnostic.hintSign": " ", + // "diagnostic.displayByAle": true, + + // codelens TODO what does this get me? + // "codeLens.enable": true, + + // list + "list.indicator": ">", + "list.selectedSignText": " ", + + // autoformat "coc.preferences.formatOnSaveFiletypes": ["css", "markdown", "javascript", "graphql", "html", "yaml", "json", "python"], + "coc.preferences.hoverTarget": "float", // python config "python.linting.enabled": true, "python.linting.pylintEnabled": true, + // snippets "snippets.ultisnips.directories": [ "UltiSnips", @@ -15,8 +36,14 @@ "explorer.width": 30, "explorer.icon.enableNerdfont": true, "explorer.previewAction.onHover": false, + "explorer.icon.enableVimDevicons": true, "explorer.keyMappings": { "": ["expandable?", "expand", "open"], "v": "open:vsplit" } + + // TODO language servers + // TODO g:coc_global_extensions + // TODO b:coc_suggest_disable=1 GOYO + // TODO add to paths.vim g:coc_node_path } diff --git a/general/settings.vim b/general/settings.vim index c2f89897..be7e9acf 100644 --- a/general/settings.vim +++ b/general/settings.vim @@ -38,6 +38,8 @@ if !exists('g:vscode') set formatoptions-=cro " Stop newline continution of comments set clipboard=unnamedplus " Copy paste between vim and everything else set incsearch + set guifont=Hack\ Nerd\ Font + " let $NVIM_TUI_ENABLE_TRUE_COLOR=1 " set mmp=1300 " set autochdir " Your working directory will always be the same as your working directory " set foldcolumn=2 " Folding abilities diff --git a/init.vim b/init.vim index 74ceb135..c1deabc1 100644 --- a/init.vim +++ b/init.vim @@ -22,7 +22,6 @@ else source $HOME/.config/nvim/themes/syntax.vim source $HOME/.config/nvim/themes/onedark.vim source $HOME/.config/nvim/themes/airline.vim - " source $HOME/.config/nvim/themes/eleline.vim source $HOME/.config/nvim/plug-config/rnvimr.vim source $HOME/.config/nvim/plug-config/fzf.vim source $HOME/.config/nvim/plug-config/commentary.vim @@ -37,3 +36,10 @@ else source $HOME/.config/nvim/plug-config/signify.vim luafile $HOME/.config/nvim/lua/plug-colorizer.lua endif + +let g:floaterm_wintype='normal' +let g:floaterm_height=6 +let g:floaterm_keymap_new = '' +let g:floaterm_keymap_prev = '' +let g:floaterm_keymap_next = '' +let g:floaterm_keymap_toggle = '' diff --git a/keys/which-key.vim b/keys/which-key.vim index 2cf2e48e..d37592e4 100644 --- a/keys/which-key.vim +++ b/keys/which-key.vim @@ -2,15 +2,16 @@ " call which_key#register('', "g:which_key_map") nnoremap :silent WhichKey ' ' +vnoremap :silent WhichKeyVisual ' ' + +let g:which_key_map = {} +let g:which_key_sep = '→' +" set timeoutlen=100 " Not a fan of floating windows for this let g:which_key_use_floating_win = 0 -" highlight default link WhichKey Function -" highlight default link WhichKeySeperator DiffAdded -" highlight default link WhichKeyGroup Keyword -" highlight default link WhichKeyDesc Identifier - +" Change the colors if you want highlight default link WhichKey Operator highlight default link WhichKeySeperator DiffAdded highlight default link WhichKeyGroup Identifier @@ -19,5 +20,89 @@ highlight default link WhichKeyDesc Function " Hide status line autocmd! FileType which_key autocmd FileType which_key set laststatus=0 noshowmode noruler - \| autocmd BufLeave set laststatus=2 noshowmode ruler + \| autocmd BufLeave set laststatus=2 noshowmode ruler + +" f is for find +let g:which_key_map.f = { + \ 'name' : '+find' , + \ '/' : [':History/' , 'history'], + \ ';' : [':Commands' , 'commands'], + \ 'a' : [':Ag' , 'text Ag'], + \ 'b' : [':BLines' , 'current buffer'], + \ 'B' : [':Buffers' , 'open buffers'], + \ 'c' : [':Commits' , 'commits'], + \ 'C' : [':BCommits' , 'buffer commits'], + \ 'f' : [':Files' , 'files'], + \ 'g' : [':GFiles' , 'git files'], + \ 'G' : [':GFiles?' , 'modified git files'], + \ 'h' : [':History' , 'file history'], + \ 'H' : [':History:' , 'command history'], + \ 'l' : [':Lines' , 'lines'] , + \ 'm' : [':Marks' , 'marks'] , + \ 'M' : [':Maps' , 'normal maps'] , + \ 'p' : [':Helptags' , 'help tags'] , + \ 'r' : [':Rg' , 'text Rg'], + \ 's' : [':Snippets' , 'snippets'], + \ 'S' : [':Colors' , 'color schemes'], + \ 't' : [':Tags' , 'project tags'], + \ 'T' : [':BTags' , 'buffer tags'], + \ 'w' : [':Windows' , 'search windows'], + \ 'y' : [':Filetypes' , 'file types'], + \ 'z' : [':FZF' , 'FZF'], + \ } +let g:fzf_buffers_jump = 1 + +" l is for language server protocol +let g:which_key_map.l = { + \ 'name' : '+lsp' , + \ '.' : [':CocConfig' , 'config'], + \ ';' : ['(coc-refactor)' , 'refactor'], + \ 'a' : ['(coc-codeaction)' , 'line action'], + \ 'A' : ['(coc-codeaction-selected)' , 'selected action'], + \ 'b' : [':CocNext' , 'next action'], + \ 'B' : [':CocPrev' , 'prev action'], + \ 'c' : [':CocList commands' , 'commands'], + \ 'd' : ['(coc-definition)' , 'definition'], + \ 'D' : ['(coc-declaration)' , 'declaration'], + \ 'e' : [':CocList extensions' , 'extensions'], + \ 'f' : ['(coc-format-selected)' , 'format selected'], + \ 'F' : ['(coc-format)' , 'format'], + \ 'h' : ['(coc-float-hide)' , 'hide'], + \ 'i' : ['(coc-implementation)' , 'implementation'], + \ 'I' : [':CocList diagnostics' , 'diagnostics'], + \ 'j' : ['(coc-float-jump)' , 'float jump'], + \ 'l' : ['(coc-codelens-action)' , 'code lens'], + \ 'n' : ['(coc-diagnostic-next)' , 'next diagnostic'], + \ 'N' : ['(coc-diagnostic-next-error)' , 'next error'], + \ 'o' : ['(coc-openlink)' , 'open link'], + \ 'O' : [':CocList outline' , 'outline'], + \ 'p' : ['(coc-diagnostic-prev)' , 'prev diagnostic'], + \ 'P' : ['(coc-diagnostic-prev-error)' , 'prev error'], + \ 'q' : ['(coc-fix-current)' , 'quickfix'], + \ 'r' : ['(coc-rename)' , 'rename'], + \ 'R' : ['(coc-references)' , 'references'], + \ 's' : [':CocList -I symbols' , 'references'], + \ 't' : ['(coc-type-definition)' , 'type definition'], + \ 'u' : [':CocListResume' , 'resume list'], + \ 'U' : [':CocUpdate' , 'update CoC'], + \ 'z' : [':CocDisable' , 'disable CoC'], + \ 'Z' : [':CocEnable' , 'enable CoC'], + \ } + + +" t is for toggle +let g:which_key_map.t = { + \ 'name' : '+toggle' , + \ 'e' : [':CocCommand explorer' , 'explorer'], + \ 'n' : [':set nonumber!' , 'line-numbers'], + \ 'r' : [':set norelativenumber!' , 'rel-line-numbers'], + \ 's' : [':let @/ = ""' , 'remove-search-highlight'], + \ 'c' : [':ColorizerToggle' , 'colorizer'], + \ 't' : [':FloatermToggle' , 'terminal'], + \ } + + + + +call which_key#register('', "g:which_key_map") diff --git a/plug-config/coc.vim b/plug-config/coc.vim index babae7ed..428230d1 100644 --- a/plug-config/coc.vim +++ b/plug-config/coc.vim @@ -22,10 +22,6 @@ else imap pumvisible() ? "\" : "\u\" endif -" Use `[g` and `]g` to navigate diagnostics -nmap [g (coc-diagnostic-prev) -nmap ]g (coc-diagnostic-next) - " GoTo code navigation. nmap gd (coc-definition) nmap gy (coc-type-definition) @@ -49,10 +45,6 @@ autocmd CursorHold * silent call CocActionAsync('highlight') " Symbol renaming. nmap rn (coc-rename) -" Formatting selected code. -xmap f (coc-format-selected) -nmap f (coc-format-selected) - augroup mygroup autocmd! " Setup formatexpr specified filetype(s). @@ -63,13 +55,13 @@ augroup end " Applying codeAction to the selected region. " Example: `aap` for current paragraph -xmap a (coc-codeaction-selected) -nmap a (coc-codeaction-selected) +" xmap a (coc-codeaction-selected) +" nmap a (coc-codeaction-selected) " Remap keys for applying codeAction to the current line. -nmap ac (coc-codeaction) +" nmap ac (coc-codeaction) " Apply AutoFix to problem on the current line. -nmap qf (coc-fix-current) +" nmap qf (coc-fix-current) " Introduce function text object " NOTE: Requires 'textDocument.documentSymbol' support from the language server. @@ -100,21 +92,22 @@ set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} " Mappings using CoCList: " Show all diagnostics. -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 +" 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 = { @@ -137,5 +130,5 @@ let g:coc_explorer_global_presets = { \ } "nmap e :CocCommand explorer nnoremap e :CocCommand explorer -nmap f :CocCommand explorer --preset floatingRightside +" nmap f :CocCommand explorer --preset floatingRightside autocmd BufEnter * if (winnr("$") == 1 && &filetype == 'coc-explorer') | q | endif diff --git a/plug-config/fzf.vim b/plug-config/fzf.vim index 0e95a46f..c7ad00a2 100644 --- a/plug-config/fzf.vim +++ b/plug-config/fzf.vim @@ -10,11 +10,11 @@ let g:fzf_action = { " explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS. let g:fzf_history_dir = '~/.local/share/fzf-history' -map :Files -map b :Buffers -nnoremap g :Rg -nnoremap t :Tags -nnoremap m :Marks +" map :Files +" map b :Buffers +" nnoremap g :Rg +" nnoremap t :Tags +" nnoremap m :Marks let g:fzf_tags_command = 'ctags -R' diff --git a/plug-config/sneak.vim b/plug-config/sneak.vim index 29b57834..a879c6eb 100644 --- a/plug-config/sneak.vim +++ b/plug-config/sneak.vim @@ -15,7 +15,7 @@ highlight Sneak guifg=black guibg=#00C7DF ctermfg=black ctermbg=cyan highlight SneakScope guifg=red guibg=yellow ctermfg=red ctermbg=yellow " Cool prompt -let g:sneak#prompt = '🔎' +let g:sneak#prompt = '🔎 ' " I like quickscope better for this since it keeps me in the scope of a single line " map f Sneak_f diff --git a/plug-config/start-screen.vim b/plug-config/start-screen.vim index 8024fa16..2e926721 100644 --- a/plug-config/start-screen.vim +++ b/plug-config/start-screen.vim @@ -23,6 +23,12 @@ let g:startify_change_to_vcs_root = 1 let g:startify_fortune_use_unicode = 1 let g:startify_session_persistence = 1 +let g:webdevicons_enable_startify = 1 + +function! StartifyEntryFormat() + return 'WebDevIconsGetFileTypeSymbol(absolute_path) ." ". entry_path' + endfunction + let g:startify_bookmarks = [ \ { 'c': '~/.config/i3/config' }, \ { 'i': '~/.config/nvim/init.vim' }, diff --git a/vim-plug/plugins.vim b/vim-plug/plugins.vim index f545c3d3..4dc00292 100644 --- a/vim-plug/plugins.vim +++ b/vim-plug/plugins.vim @@ -47,7 +47,6 @@ call plug#begin('~/.config/nvim/autoload/plugged') " Intellisense Plug 'neoclide/coc.nvim', {'branch': 'release'} " Status Line - " Plug 'ChristianChiarulli/eleline.vim' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' " Ranger -- cgit v1.2.3