Repository navigation
Expand file tree
/
Copy pathlsp.vim
More file actions
142 lines (130 loc) · 4.6 KB
/
Copy pathlsp.vim
File metadata and controls
142 lines (130 loc) · 4.6 KB
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
let lspOpts = #{
\ aleSupport: v:false,
\ autoComplete: v:true,
\ autoHighlight: v:true,
\ autoHighlightDiags: v:true,
\ autoPopulateDiags: v:true,
\ codeActionPopupStyle: 'full',
\ completionMatcher: 'case',
\ completionMatcherValue: 1,
\ definitionFallback: v:true,
\ diagSignErrorText: '❗',
\ diagSignHintText: '💡',
\ diagSignInfoText: '💡',
\ diagSignWarningText: '💡',
\ diagSignPriority: {
\ 'Error': 100,
\ 'Warning': 99,
\ 'Information': 98,
\ 'Hint': 97
\ },
\ echoSignature: v:false,
\ hideDisabledCodeActions: v:false,
\ highlightDiagInline: v:true,
\ hoverInPreview: v:false,
\ hoverFallback: v:true,
\ ignoreMissingServer: v:true,
\ incrementalSync: v:true,
\ keepFocusInDiags: v:true,
\ keepFocusInReferences: v:true,
\ completionTextEdit: v:true,
\ diagVirtualTextAlign: 'above',
\ noNewlineInCompletion: v:true,
\ popupBorder: v:true,
\ popupBorderSignatureHelp: v:true,
\ omniComplete: v:null,
\ outlineOnRight: v:true,
\ outlineWinSize: 50,
\ semanticHighlight: v:true,
\ showDiagInBalloon: v:false,
\ showDiagInPopup: v:true,
\ showDiagOnStatusLine: v:false,
\ showDiagWithSign: v:true,
\ showDiagWithVirtualText: v:false,
\ showInlayHints: v:false,
\ showSignature: v:true,
\ snippetSupport: v:true,
\ ultisnipsSupport: v:true,
\ useBufferCompletion: v:false,
\ usePopupInCodeAction: v:true,
\ vsnipSupport: v:false,
\ useQuickfixForLocations: v:false,
\ bufferCompletionTimeout: 100,
\ customCompletionKinds: v:false,
\ completionKinds: {},
\ filterCompletionDuplicates: v:true,
\ }
augroup LspConfig
autocmd!
autocmd User LspSetup call LspOptionsSet(lspOpts)
augroup END
" Source all language servers
for file in split(glob('$VIMHOME/lsp/*.vim'), '\n')
execute 'source' fnameescape(file)
endfor
" Enable language servers
let lspServers = []
call add(lspServers, bash)
call add(lspServers, clangd)
call add(lspServers, codebook)
" call add(lspServers, cmake_language_server)
" call add(lspServers, cspell_lsp)
call add(lspServers, docker_ls)
call add(lspServers, devicetree_ls)
call add(lspServers, efm)
call add(lspServers, gopls)
call add(lspServers, json)
call add(lspServers, jetls)
call add(lspServers, language_server_bitbake)
call add(lspServers, make_ls)
call add(lspServers, marksman)
call add(lspServers, neocmakelsp)
call add(lspServers, perlnavigator)
call add(lspServers, pkl)
call add(lspServers, pyright)
call add(lspServers, qml_ls)
call add(lspServers, rustanalyzer)
call add(lspServers, superhtml)
call add(lspServers, systemd_lsp)
call add(lspServers, tombi)
call add(lspServers, typescript_ls)
call add(lspServers, sonarlint)
call add(lspServers, vhdl)
call add(lspServers, vimls)
call add(lspServers, yaml_ls)
autocmd LspConfig User LspSetup call LspAddServer(lspServers)
inoremap <expr> <C-j> pumvisible() ? "\<C-n>" : "\<C-j>"
inoremap <expr> <C-k> pumvisible() ? "\<C-p>" : "\<C-k>"
nnoremap <leader>ac :LspCodeAction<CR>
nnoremap <silent> <leader>pe :LspDiagPrev<CR>
nnoremap <silent> <leader>ne :LspDiagNext<CR>
nnoremap <silent> <leader>pd :LspPeekDefinition<CR>
nnoremap <silent> <leader>pdc :LspPeekDeclaration<CR>
nnoremap <silent> <leader>pr :LspPeekReferences<CR>
nnoremap <silent> <leader>ol :LspOutline<CR>
nnoremap <silent> <leader>rn :LspRename<CR>
nnoremap <silent> <leader>di :LspDiagShow<CR>
nnoremap <leader>cl :LspCodeLens<CR>
" Map add to dictionary differently for different cspell clients
if index(lspServers, cspell_lsp) >= 0
nnoremap <silent> <leader>ad m0$:LspCodeAction Add<CR>`0
elseif index(lspServers, codebook) >= 0
nnoremap <silent> <leader>ad :LspCodeAction /global dictionary<CR>
endif
function! s:SmartHover() abort
let result = execute('LspHover')
if result =~ 'Error'
call feedkeys('K', 'n')
endif
endfunction
nnoremap <silent> K :call <SID>SmartHover()<CR>
nnoremap <silent> <RightMouse> :call <SID>SmartHover()<CR>
nnoremap <silent> <MiddleMouse> :LspPeekDefinition<CR>
nnoremap <silent> <C-.> :LspGotoDefinition<CR>
nnoremap <silent> gd :LspGotoDefinition<CR>
nnoremap <silent> gy :LspGotoTypeDef<CR>
nnoremap <silent> gi :LspGotoImpl<CR>
nnoremap <silent> gdc :LspGotoDeclaration<CR>
xnoremap <silent> <leader>f :LspFormat<CR>
nnoremap <silent> <leader>f :LspFormat<CR>
set formatexpr=lsp#lsp#FormatExpr() " Map LspFormat to the gq command