Skip to content

Commit a2f7627

Browse files
author
Joel Nimety
committed
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
1 parent 799aa53 commit a2f7627

7 files changed

Lines changed: 195 additions & 0 deletions

File tree

.gitmodules

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
[submodule "home/.vim/pack/dotfiles/start/vim-terraform"]
131131
path = home/.vim/pack/dotfiles/start/vim-terraform
132132
url = https://github.com/hashivim/vim-terraform.git
133+
[submodule "home/home/.vim/pack/dotfiles/start/coc.nvim"]
134+
path = home/home/.vim/pack/dotfiles/start/coc.nvim
135+
url = git@github.com:neoclide/coc.nvim.git
136+
branch = release
137+
[submodule "home/.vim/pack/dotfiles/start/coc.nvim"]
138+
path = home/.vim/pack/dotfiles/start/coc.nvim
139+
url = git@github.com:neoclide/coc.nvim.git
140+
branch = release
141+
[submodule "home/.vim/pack/dotfiles/start/vim-snippets"]
142+
path = home/.vim/pack/dotfiles/start/vim-snippets
143+
url = git@github.com:honza/vim-snippets.git

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ gem 'thyme'
77
gem 'git'
88
gem 'sqlint'
99
gem 'thor'
10+
gem 'solargraph'
1011

1112
# stuff for pivotal
1213
gem 'activesupport'

Gemfile.lock

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ GEM
1010
tzinfo (~> 1.1)
1111
addressable (2.6.0)
1212
public_suffix (>= 2.0.2, < 4.0)
13+
ast (2.4.0)
1314
axiom-types (0.1.1)
1415
descendants_tracker (~> 0.0.4)
1516
ice_nine (~> 0.11.0)
1617
thread_safe (~> 0.3, >= 0.3.1)
18+
backport (1.1.2)
1719
coercible (1.0.0)
1820
descendants_tracker (~> 0.0.1)
1921
concurrent-ruby (1.1.4)
@@ -35,14 +37,32 @@ GEM
3537
i18n (1.5.3)
3638
concurrent-ruby (~> 1.0)
3739
ice_nine (0.11.2)
40+
jaro_winkler (1.5.4)
41+
maruku (0.7.3)
42+
mini_portile2 (2.4.0)
3843
minitest (5.11.3)
3944
multipart-post (2.0.0)
45+
nokogiri (1.10.7)
46+
mini_portile2 (~> 2.4.0)
47+
parallel (1.19.1)
48+
parser (2.7.0.2)
49+
ast (~> 2.4.0)
4050
pg_query (1.1.0)
4151
public_suffix (3.0.3)
52+
rainbow (3.0.0)
4253
rake (12.3.2)
4354
rb-fsevent (0.10.3)
4455
rb-inotify (0.10.0)
4556
ffi (~> 1.0)
57+
reverse_markdown (1.4.0)
58+
nokogiri
59+
rubocop (0.79.0)
60+
jaro_winkler (~> 1.5.1)
61+
parallel (~> 1.10)
62+
parser (>= 2.7.0.1)
63+
rainbow (>= 2.2.2, < 4.0)
64+
ruby-progressbar (~> 1.7)
65+
unicode-display_width (>= 1.4.0, < 1.7)
4666
ruby-progressbar (1.10.0)
4767
sass (3.7.3)
4868
sass-listen (~> 4.0.0)
@@ -52,12 +72,25 @@ GEM
5272
scss_lint (0.57.1)
5373
rake (>= 0.9, < 13)
5474
sass (~> 3.5, >= 3.5.5)
75+
solargraph (0.38.0)
76+
backport (~> 1.1)
77+
bundler (>= 1.17.2)
78+
jaro_winkler (~> 1.5)
79+
maruku (~> 0.7, >= 0.7.3)
80+
nokogiri (~> 1.9, >= 1.9.1)
81+
parser (~> 2.3)
82+
reverse_markdown (~> 1.0, >= 1.0.5)
83+
rubocop (~> 0.52)
84+
thor (~> 0.19, >= 0.19.4)
85+
tilt (~> 2.0)
86+
yard (~> 0.9)
5587
sqlint (0.1.9)
5688
pg_query (~> 1)
5789
thor (0.20.3)
5890
thread_safe (0.3.6)
5991
thyme (0.0.15)
6092
ruby-progressbar (~> 1.0)
93+
tilt (2.0.10)
6194
tracker_api (0.2.9)
6295
activemodel
6396
activesupport
@@ -68,11 +101,13 @@ GEM
68101
virtus
69102
tzinfo (1.2.5)
70103
thread_safe (~> 0.1)
104+
unicode-display_width (1.6.1)
71105
virtus (1.0.5)
72106
axiom-types (~> 0.1)
73107
coercible (~> 1.0)
74108
descendants_tracker (~> 0.0, >= 0.0.3)
75109
equalizer (~> 0.0, >= 0.0.9)
110+
yard (0.9.24)
76111

77112
PLATFORMS
78113
ruby
@@ -84,6 +119,7 @@ DEPENDENCIES
84119
hitch
85120
homesick
86121
scss_lint
122+
solargraph
87123
sqlint
88124
thor
89125
thyme

home/.vim/coc-settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"solargraph.checkGemVersion": false,
3+
"solargraph.diagnostics": false,
4+
"solargraph.promptDownload": false,
5+
"suggest.maxCompleteItemCount": 20
6+
}

home/.vim/coc.vimrc

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
" if hidden is not set, TextEdit might fail.
2+
set hidden
3+
4+
" Some servers have issues with backup files, see #649
5+
set nobackup
6+
set nowritebackup
7+
8+
" Better display for messages
9+
set cmdheight=2
10+
11+
" You will have bad experience for diagnostic messages when it's default 4000.
12+
set updatetime=300
13+
14+
" don't give |ins-completion-menu| messages.
15+
set shortmess+=c
16+
17+
" always show signcolumns
18+
set signcolumn=yes
19+
20+
" Use tab for trigger completion with characters ahead and navigate.
21+
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
22+
inoremap <silent><expr> <TAB>
23+
\ pumvisible() ? "\<C-n>" :
24+
\ <SID>check_back_space() ? "\<TAB>" :
25+
\ coc#refresh()
26+
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
27+
28+
function! s:check_back_space() abort
29+
let col = col('.') - 1
30+
return !col || getline('.')[col - 1] =~# '\s'
31+
endfunction
32+
33+
let g:coc_snippet_next = '<tab>'
34+
35+
" Use <c-space> to trigger completion.
36+
inoremap <silent><expr> <c-space> coc#refresh()
37+
38+
" Endwise / coc.nvim compatibility
39+
let g:endwise_no_mappings = 1
40+
41+
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
42+
" Coc only does snippet and additional edit on confirm.
43+
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
44+
" Or use `complete_info` if your vim support it, like:
45+
" inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
46+
47+
augroup vimrc-ruby-settings
48+
autocmd!
49+
autocmd FileType ruby imap <expr> <CR> pumvisible() ? "\<C-y>\<Plug>DiscretionaryEnd" : "\<CR>\<Plug>DiscretionaryEnd"
50+
augroup END
51+
52+
" Use `[g` and `]g` to navigate diagnostics
53+
nmap <silent> [g <Plug>(coc-diagnostic-prev)
54+
nmap <silent> ]g <Plug>(coc-diagnostic-next)
55+
56+
" Remap keys for gotos
57+
nmap <silent> gd <Plug>(coc-definition)
58+
nmap <silent> gy <Plug>(coc-type-definition)
59+
nmap <silent> gi <Plug>(coc-implementation)
60+
nmap <silent> gr <Plug>(coc-references)
61+
62+
" Use K to show documentation in preview window
63+
nnoremap <silent> K :call <SID>show_documentation()<CR>
64+
65+
function! s:show_documentation()
66+
if (index(['vim','help'], &filetype) >= 0)
67+
execute 'h '.expand('<cword>')
68+
else
69+
call CocAction('doHover')
70+
endif
71+
endfunction
72+
73+
" Highlight symbol under cursor on CursorHold
74+
autocmd CursorHold * silent call CocActionAsync('highlight')
75+
76+
" Remap for rename current word
77+
nmap <leader>rn <Plug>(coc-rename)
78+
79+
" Remap for format selected region
80+
xmap <leader>f <Plug>(coc-format-selected)
81+
nmap <leader>f <Plug>(coc-format-selected)
82+
83+
augroup mygroup
84+
autocmd!
85+
" Setup formatexpr specified filetype(s).
86+
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
87+
" Update signature help on jump placeholder
88+
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
89+
augroup end
90+
91+
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
92+
xmap <leader>a <Plug>(coc-codeaction-selected)
93+
nmap <leader>a <Plug>(coc-codeaction-selected)
94+
95+
" Remap for do codeAction of current line
96+
nmap <leader>ac <Plug>(coc-codeaction)
97+
" Fix autofix problem of current line
98+
nmap <leader>qf <Plug>(coc-fix-current)
99+
100+
" Create mappings for function text object, requires document symbols feature of languageserver.
101+
xmap if <Plug>(coc-funcobj-i)
102+
xmap af <Plug>(coc-funcobj-a)
103+
omap if <Plug>(coc-funcobj-i)
104+
omap af <Plug>(coc-funcobj-a)
105+
106+
" Use <TAB> for select selections ranges, needs server support, like: coc-tsserver, coc-python
107+
nmap <silent> <TAB> <Plug>(coc-range-select)
108+
xmap <silent> <TAB> <Plug>(coc-range-select)
109+
110+
" Use `:Format` to format current buffer
111+
command! -nargs=0 Format :call CocAction('format')
112+
113+
" Use `:Fold` to fold current buffer
114+
command! -nargs=? Fold :call CocAction('fold', <f-args>)
115+
116+
" use `:OR` for organize import of current buffer
117+
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
118+
119+
" Add status line support, for integration with other plugin, checkout `:h coc-status`
120+
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
121+
122+
" Using CocList
123+
" Show all diagnostics
124+
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
125+
" Manage extensions
126+
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
127+
" Show commands
128+
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
129+
" Find symbol of current document
130+
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
131+
" Search workspace symbols
132+
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
133+
" Do default action for next item.
134+
nnoremap <silent> <space>j :<C-u>CocNext<CR>
135+
" Do default action for previous item.
136+
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
137+
" Resume latest coc list
138+
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
139+
"" END COC Config
Submodule coc.nvim added at 9bb31f9
Submodule vim-snippets added at 867f5cc

0 commit comments

Comments
 (0)