From 87a4c6b8ee41615f6ac30e7cb42705ebb2977588 Mon Sep 17 00:00:00 2001 From: Joel Nimety Date: Fri, 24 Jan 2020 20:21:44 +0000 Subject: [PATCH] add coc.nvim for "intellisense" code completion (useable with neovim and vim 8+), snippets, and the default coc.nvim config. added solargraph to our Gemfile for ruby code completion support. for more coc information see https://github.com/neoclide/coc.nvim --- .gitmodules | 7 ++ Gemfile | 1 + Gemfile.lock | 36 ++++++ home/.vim/coc-settings.json | 6 + home/.vim/coc.vimrc | 139 +++++++++++++++++++++ home/.vim/pack/dotfiles/start/coc.nvim | 1 + home/.vim/pack/dotfiles/start/vim-snippets | 1 + 7 files changed, 191 insertions(+) create mode 100644 home/.vim/coc-settings.json create mode 100644 home/.vim/coc.vimrc create mode 160000 home/.vim/pack/dotfiles/start/coc.nvim create mode 160000 home/.vim/pack/dotfiles/start/vim-snippets diff --git a/.gitmodules b/.gitmodules index 9c678c7..3194672 100644 --- a/.gitmodules +++ b/.gitmodules @@ -130,3 +130,10 @@ [submodule "home/.vim/pack/dotfiles/start/vim-terraform"] path = home/.vim/pack/dotfiles/start/vim-terraform url = https://github.com/hashivim/vim-terraform.git +[submodule "home/.vim/pack/dotfiles/start/coc.nvim"] + path = home/.vim/pack/dotfiles/start/coc.nvim + url = git@github.com:neoclide/coc.nvim.git + branch = release +[submodule "home/.vim/pack/dotfiles/start/vim-snippets"] + path = home/.vim/pack/dotfiles/start/vim-snippets + url = git@github.com:honza/vim-snippets.git diff --git a/Gemfile b/Gemfile index 676c96a..a115835 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,7 @@ gem 'thyme' gem 'git' gem 'sqlint' gem 'thor' +gem 'solargraph' # stuff for pivotal gem 'activesupport' diff --git a/Gemfile.lock b/Gemfile.lock index 182230f..ded0bfa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,10 +10,12 @@ GEM tzinfo (~> 1.1) addressable (2.6.0) public_suffix (>= 2.0.2, < 4.0) + ast (2.4.0) axiom-types (0.1.1) descendants_tracker (~> 0.0.4) ice_nine (~> 0.11.0) thread_safe (~> 0.3, >= 0.3.1) + backport (1.1.2) coercible (1.0.0) descendants_tracker (~> 0.0.1) concurrent-ruby (1.1.4) @@ -35,14 +37,32 @@ GEM i18n (1.5.3) concurrent-ruby (~> 1.0) ice_nine (0.11.2) + jaro_winkler (1.5.4) + maruku (0.7.3) + mini_portile2 (2.4.0) minitest (5.11.3) multipart-post (2.0.0) + nokogiri (1.10.7) + mini_portile2 (~> 2.4.0) + parallel (1.19.1) + parser (2.7.0.2) + ast (~> 2.4.0) pg_query (1.1.0) public_suffix (3.0.3) + rainbow (3.0.0) rake (12.3.2) rb-fsevent (0.10.3) rb-inotify (0.10.0) ffi (~> 1.0) + reverse_markdown (1.4.0) + nokogiri + rubocop (0.79.0) + jaro_winkler (~> 1.5.1) + parallel (~> 1.10) + parser (>= 2.7.0.1) + rainbow (>= 2.2.2, < 4.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 1.7) ruby-progressbar (1.10.0) sass (3.7.3) sass-listen (~> 4.0.0) @@ -52,12 +72,25 @@ GEM scss_lint (0.57.1) rake (>= 0.9, < 13) sass (~> 3.5, >= 3.5.5) + solargraph (0.38.0) + backport (~> 1.1) + bundler (>= 1.17.2) + jaro_winkler (~> 1.5) + maruku (~> 0.7, >= 0.7.3) + nokogiri (~> 1.9, >= 1.9.1) + parser (~> 2.3) + reverse_markdown (~> 1.0, >= 1.0.5) + rubocop (~> 0.52) + thor (~> 0.19, >= 0.19.4) + tilt (~> 2.0) + yard (~> 0.9) sqlint (0.1.9) pg_query (~> 1) thor (0.20.3) thread_safe (0.3.6) thyme (0.0.15) ruby-progressbar (~> 1.0) + tilt (2.0.10) tracker_api (0.2.9) activemodel activesupport @@ -68,11 +101,13 @@ GEM virtus tzinfo (1.2.5) thread_safe (~> 0.1) + unicode-display_width (1.6.1) virtus (1.0.5) axiom-types (~> 0.1) coercible (~> 1.0) descendants_tracker (~> 0.0, >= 0.0.3) equalizer (~> 0.0, >= 0.0.9) + yard (0.9.24) PLATFORMS ruby @@ -84,6 +119,7 @@ DEPENDENCIES hitch homesick scss_lint + solargraph sqlint thor thyme diff --git a/home/.vim/coc-settings.json b/home/.vim/coc-settings.json new file mode 100644 index 0000000..5ff32ad --- /dev/null +++ b/home/.vim/coc-settings.json @@ -0,0 +1,6 @@ +{ + "solargraph.checkGemVersion": false, + "solargraph.diagnostics": false, + "solargraph.promptDownload": false, + "suggest.maxCompleteItemCount": 20 +} diff --git a/home/.vim/coc.vimrc b/home/.vim/coc.vimrc new file mode 100644 index 0000000..0bc85d6 --- /dev/null +++ b/home/.vim/coc.vimrc @@ -0,0 +1,139 @@ +" if hidden is not set, TextEdit might fail. +set hidden + +" Some servers have issues with backup files, see #649 +set nobackup +set nowritebackup + +" Better display for messages +set cmdheight=2 + +" You will have bad experience for diagnostic messages when it's default 4000. +set updatetime=300 + +" don't give |ins-completion-menu| messages. +set shortmess+=c + +" always show signcolumns +set signcolumn=yes + +" Use tab for trigger completion with characters ahead and navigate. +" Use command ':verbose imap ' to make sure tab is not mapped by other plugin. +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 + +let g:coc_snippet_next = '' + +" Use to trigger completion. +inoremap coc#refresh() + +" Endwise / coc.nvim compatibility +let g:endwise_no_mappings = 1 + +" Use to confirm completion, `u` means break undo chain at current position. +" Coc only does snippet and additional edit on confirm. +inoremap pumvisible() ? "\" : "\u\" +" Or use `complete_info` if your vim support it, like: +" inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" + +augroup vimrc-ruby-settings + autocmd! + autocmd FileType ruby imap pumvisible() ? "\\DiscretionaryEnd" : "\\DiscretionaryEnd" +augroup END + +" Use `[g` and `]g` to navigate diagnostics +nmap [g (coc-diagnostic-prev) +nmap ]g (coc-diagnostic-next) + +" Remap keys for gotos +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 symbol under cursor on CursorHold +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Remap for rename current word +nmap rn (coc-rename) + +" Remap for format selected region +xmap f (coc-format-selected) +nmap f (coc-format-selected) + +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 + +" Remap for do codeAction of selected region, ex: `aap` for current paragraph +xmap a (coc-codeaction-selected) +nmap a (coc-codeaction-selected) + +" Remap for do codeAction of current line +nmap ac (coc-codeaction) +" Fix autofix problem of current line +nmap qf (coc-fix-current) + +" Create mappings for function text object, requires document symbols feature of languageserver. +xmap if (coc-funcobj-i) +xmap af (coc-funcobj-a) +omap if (coc-funcobj-i) +omap af (coc-funcobj-a) + +" Use for select selections ranges, needs server support, like: coc-tsserver, coc-python +nmap (coc-range-select) +xmap (coc-range-select) + +" Use `:Format` to format current buffer +command! -nargs=0 Format :call CocAction('format') + +" Use `:Fold` to fold current buffer +command! -nargs=? Fold :call CocAction('fold', ) + +" use `:OR` for organize import of current buffer +command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') + +" Add status line support, for integration with other plugin, checkout `:h coc-status` +set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} + +" 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 +"" END COC Config diff --git a/home/.vim/pack/dotfiles/start/coc.nvim b/home/.vim/pack/dotfiles/start/coc.nvim new file mode 160000 index 0000000..9bb31f9 --- /dev/null +++ b/home/.vim/pack/dotfiles/start/coc.nvim @@ -0,0 +1 @@ +Subproject commit 9bb31f9d03af2fc52f98ec65020b34efdc496883 diff --git a/home/.vim/pack/dotfiles/start/vim-snippets b/home/.vim/pack/dotfiles/start/vim-snippets new file mode 160000 index 0000000..867f5cc --- /dev/null +++ b/home/.vim/pack/dotfiles/start/vim-snippets @@ -0,0 +1 @@ +Subproject commit 867f5cc995aec6c6f065d0ad76f5f0c914df4493