-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc.plugins
207 lines (172 loc) · 6.86 KB
/
.vimrc.plugins
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
let mapleader=","
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Tabularize
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <Leader>f= :Tabularize /=<CR>
vmap <Leader>f= :Tabularize /=<CR>
nmap <Leader>f :Tabularize /:\zs<CR>
vmap <Leader>f :Tabularize /:\zs<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Surround
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Leader>y <Plug>Yssurround=<cr>
map <Leader>i <Plug>Yssurround-<cr>
map <leader># ysiw#
imap <C-c> <CR><Esc>O
autocmd FileType ruby let b:surround_35 = "#{\r}"
autocmd FileType eruby let b:surround_35 = "#{\r}"
" Toggler
nmap <script> <silent> <leader>w :call ToggleQuickfixList()<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Git
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <Leader>gs :Gstatus<CR>
nnoremap <Leader>gd :Gdiff<CR>
nnoremap <Leader>gc :Gcommit<CR>
nnoremap <Leader>gb :Gblame<CR>
nnoremap <Leader>gl :Glog<CR>
nnoremap <Leader>gp :Git push<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Nerdtree
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" autocmd VimEnter * NERDTree
" autocmd BufWinEnter * NERDTreeMirror
let NERDTreeMapOpenInTab='<ENTER>'
nnoremap <F6> :UndotreeToggle<CR>
map <leader>r :NERDTree<cr> :NERDTreeMirror<cr>
map <leader>c :NERDTreeClose<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ultisnips
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:UltiSnipsSnippetDirectories=["~/.vim/my-snippets"]
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ElixirLS
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ElixirLS = {}
let ElixirLS.path = stdpath('config').'/plugged/elixir-ls'
let ElixirLS.lsp = ElixirLS.path.'/release/language_server.sh'
" let ElixirLS.cmd = join([
" \ 'cp .release-tool-versions .tool-versions &&',
" \ 'asdf install &&',
" \ 'mix do',
" \ 'local.hex --force --if-missing,',
" \ 'local.rebar --force,',
" \ 'deps.get,',
" \ 'compile,',
" \ 'elixir_ls.release &&',
" \ 'rm .tool-versions'
" \ ], ' ')
function ElixirLS.on_stdout(_job_id, data, _event)
let self.output[-1] .= a:data[0]
call extend(self.output, a:data[1:])
endfunction
let ElixirLS.on_stderr = function(ElixirLS.on_stdout)
function ElixirLS.on_exit(_job_id, exitcode, _event)
if a:exitcode[0] == 0
echom '>>> ElixirLS compiled'
else
echoerr join(self.output, ' ')
echoerr '>>> ElixirLS compilation failed'
endif
endfunction
function ElixirLS.compile()
let me = copy(g:ElixirLS)
let me.output = ['']
echom '>>> compiling ElixirLS'
let me.id = jobstart('cd ' . me.path . ' && git pull && ' . me.cmd, me)
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Coc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:coc_global_extensions = [
\ 'coc-diagnostic',
\ 'coc-json',
\ 'coc-html',
\ 'coc-css',
\ 'coc-elixir',
\ 'coc-docker',
\ 'coc-diagnostic',
\ 'coc-tsserver',
\ 'coc-eslint',
\ 'coc-snippets',
\ 'coc-tabnine',
\ 'coc-ultisnips',
\ 'coc-rust-analyzer',
\ 'coc-solidity',
\ 'coc-yaml',
\ ]
" \ 'coc-prettier',
" "\ 'coc-rls',
call coc#config('elixir', {
\ 'command': g:ElixirLS.lsp,
\ 'filetypes': ['elixir', 'eelixir']
\})
call coc#config('elixir.pathToElixirLS', g:ElixirLS.lsp)
nnoremap <silent> K :call CocAction('doHover')<CR>
function! ShowDocIfNoDiagnostic(timer_id)
if (coc#float#has_float() == 0 && CocHasProvider('hover') == 1)
silent call CocActionAsync('doHover')
endif
endfunction
function! s:show_hover_doc()
call timer_start(500, 'ShowDocIfNoDiagnostic')
endfunction
autocmd CursorHoldI * :call <SID>show_hover_doc()
autocmd CursorHold * :call <SID>show_hover_doc()
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gr <Plug>(coc-references)
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
nnoremap <silent> <space>d :<C-u>CocList diagnostics<cr>
nmap <leader>do <Plug>(coc-codeaction)
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
let g:prettier#autoformat = 1
" Autoformat
augroup autoformat
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json,rust,javascript,html,css,solidity setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.svelte,*.yaml,*.html,*.sol Prettier
autocmd BufRead silent! * Format
autocmd Filetype * setlocal sw=2 sts=2 ts=2 tw=0 et
autocmd BufRead * retab
augroup end
" Scrolling
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocActionAsync('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport')
" Prettier format
command! -nargs=0 Prettier :CocCommand prettier.forceFormatDocument