-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimlsp.vim
236 lines (217 loc) · 7.57 KB
/
.vimlsp.vim
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
if &diff
finish
endif
let g:lsp_max_buffer_size = -1
let g:lsp_use_native_client = 1
let g:lsp_diagnostics_highlights_delay = 200
let g:lsp_diagnostics_highlights_enabled = 0
let g:lsp_diagnostics_highlights_insert_mode_enabled = 0
let g:lsp_diagnostics_signs_delay = 200
let g:lsp_diagnostics_signs_insert_mode_enabled = 0
let g:lsp_diagnostics_signs_priority = 11
let g:lsp_diagnostics_virtual_text_align = "after"
let g:lsp_diagnostics_virtual_text_delay = 200
let g:lsp_diagnostics_virtual_text_insert_mode_enabled = 1
let g:lsp_diagnostics_virtual_text_prefix = "💥 "
let g:lsp_document_code_action_signs_enabled = 0
let g:lsp_document_highlight_delay = 200
let g:lsp_inlay_hints_delay = 200
let g:lsp_inlay_hints_enabled = 1
if executable('bash-language-server')
" https://github.com/bash-lsp/bash-language-server#vim
autocmd User lsp_setup call lsp#register_server(#{
\ name: 'Bash Language Server',
\ cmd: {server_info->[&shell, &shellcmdflag, 'bash-language-server start']},
\ allowlist: ['sh', 'bash'],
\ })
endif
if executable('clangd')
" https://jonasdevlieghere.com/vim-lsp-clangd/#configurevimtouseclangd
autocmd User lsp_setup call lsp#register_server(#{
\ name: 'C/C++ Language Server',
\ cmd: {server_info->['clangd']},
\ allowlist: ['c', 'cpp', 'objc', 'objcpp'],
\ })
endif
if executable('docker-langserver')
" https://github.com/rcjsuen/dockerfile-language-server-nodejs#installation-instructions
autocmd User lsp_setup call lsp#register_server(#{
\ name: 'Docker Language Server',
\ cmd: {server_info->[&shell, &shellcmdflag, 'docker-langserver --stdio']},
\ allowlist: ['dockerfile'],
\ })
endif
if executable('gopls')
" https://github.com/golang/tools/blob/master/gopls/doc/vim.md#vimlsp
autocmd User lsp_setup call lsp#register_server(#{
\ name: 'Go Language Server',
\ cmd: {server_info->['gopls', '-remote=auto']},
\ allowlist: ['go', 'gomod', 'gohtmltmpl', 'gotexttmpl'],
\ })
endif
if executable('lua-language-server')
" https://github.com/LuaLS/lua-language-server#install
autocmd User lsp_setup call lsp#register_server(#{
\ name: 'Lua Language Server',
\ cmd: {server_info->['lua-language-server']},
\ allowlist: ['lua'],
\ })
endif
if executable('protobuf-language-server')
" https://github.com/lasorda/protobuf-language-server#installation
autocmd User lsp_setup call lsp#register_server(#{
\ name: 'Protobuf Language Server',
\ cmd: {server_info->[&shell, &shellcmdflag, 'protobuf-language-server -stdio -logs ""']},
\ allowlist: ['proto'],
\ })
endif
if executable('pylsp')
" https://github.com/python-lsp/python-lsp-server#configuration
autocmd User lsp_setup call lsp#register_server(#{
\ name: 'Python Language Server',
\ cmd: {server_info->['pylsp']},
\ allowlist: ['python'],
\ workspace_config: #{
\ pylsp: #{
\ configurationSources: ['flake8'],
\ plugins: #{
\ autopep8: #{
\ enabled: v:false,
\ },
\ black: #{
\ enabled: v:false,
\ },
\ flake8: #{
\ enabled: v:true,
\ },
\ isort: #{
\ enabled: v:true,
\ },
\ mccabe: #{
\ enabled: v:false,
\ },
\ pylsp_mypy: #{
\ enabled: v:true,
\ follow-imports: 'normal',
\ },
\ pycodestyle: #{
\ enabled: v:false,
\ },
\ pydocstyle: #{
\ enabled: v:true,
\ },
\ pyflakes: #{
\ enabled: v:false,
\ },
\ pylint: #{
\ enabled: v:false,
\ },
\ yapf: #{
\ enabled: v:false,
\ },
\ },
\ },
\ },
\ })
endif
if executable('rust-analyzer')
" https://rust-analyzer.github.io/manual.html#configuration
autocmd User lsp_setup call lsp#register_server(#{
\ name: 'Rust Language Server',
\ cmd: {server_info->['rust-analyzer']},
\ allowlist: ['rust'],
\ initialization_options: #{
\ cargo: #{
\ buildScripts: #{
\ enable: v:false,
\ },
\ },
\ checkOnSave: #{
\ command: "clippy",
\ },
\ inlayHints: #{
\ chainingHints: #{
\ enable: v:false,
\ },
\ closingBraceHints: #{
\ minLines: 0,
\ },
\ maxLength: v:null,
\ },
\ procMacro: #{
\ enable: v:false,
\ },
\ rust: #{
\ analyzerTargetDir: v:true,
\ },
\ },
\ })
endif
if executable('taplo')
" https://taplo.tamasfe.dev/cli/usage/language-server.html
autocmd User lsp_setup call lsp#register_server(#{
\ name: 'TOML Language Server',
\ cmd: {server_info->['taplo', 'lsp', 'stdio']},
\ allowlist: ['toml'],
\ workspace_config: {},
\ })
endif
if executable('terraform-ls')
" https://github.com/hashicorp/terraform-ls/blob/main/docs/USAGE.md#vim-lsp
autocmd User lsp_setup call lsp#register_server(#{
\ name: 'Terraform Language Server',
\ cmd: {server_info->[&shell, &shellcmdflag, 'terraform-ls serve']},
\ allowlist: ['terraform'],
\ })
endif
if executable('typescript-language-server')
" https://github.com/typescript-language-server/typescript-language-server#running-the-language-server
autocmd User lsp_setup call lsp#register_server(#{
\ name: 'TypeScript Language Server',
\ cmd: {server_info->[&shell, &shellcmdflag, 'typescript-language-server --stdio']},
\ allowlist: ['javascript', 'typescript'],
\ })
endif
if executable('vim-language-server')
" https://github.com/iamcco/vim-language-server#config
autocmd User lsp_setup call lsp#register_server(#{
\ name: 'VimScript Language Server',
\ cmd: {server_info->[&shell, &shellcmdflag, 'vim-language-server --stdio']},
\ allowlist: ['vim'],
\ })
endif
"if executable('yaml-language-server')
" " https://github.com/redhat-developer/yaml-language-server#connecting-to-the-language-server-via-stdio
" autocmd User lsp_setup call lsp#register_server(#{
" \ name: 'YAML Language Server',
" \ cmd: {server_info->[&shell, &shellcmdflag, 'yaml-language-server --stdio']},
" \ allowlist: ['yaml'],
" \ })
"endif
function! s:on_lsp_buffer_enabled() abort
setlocal nowrap
setlocal signcolumn=yes
setlocal omnifunc=lsp#complete
setlocal tagfunc=lsp#tagfunc
nmap <buffer> ga <plug>(lsp-code-action-float)
nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> gD <plug>(lsp-document-diagnostics)
nmap <buffer> gs <plug>(lsp-document-symbol-search)
nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
nmap <buffer> gr <plug>(lsp-references)
nmap <buffer> gi <plug>(lsp-implementation)
nmap <buffer> td <plug>(lsp-type-definition)
nmap <buffer> th <plug>(lsp-type-hierarchy)
nmap <buffer> <F2> <plug>(lsp-rename)
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover-float)
nmap <buffer> tt <plug>(lsp-definition)
nnoremap <buffer> <expr><c-k> lsp#scroll(-3)
nnoremap <buffer> <expr><c-j> lsp#scroll(+3)
autocmd! BufWritePre *.py,*.rs,*.go call execute('LspDocumentFormatSync')
endfunction
augroup lsp_install
autocmd!
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END