-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlsp.vim
More file actions
124 lines (114 loc) · 3.81 KB
/
lsp.vim
File metadata and controls
124 lines (114 loc) · 3.81 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
let lspOpts = #{
\ aleSupport: v:false,
\ autoComplete: v:true,
\ autoHighlight: v:true,
\ autoHighlightDiags: v:true,
\ autoPopulateDiags: v:true,
\ 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,
\ 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,
\ }
autocmd User LspSetup call LspOptionsSet(lspOpts)
" 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)
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, marksman)
call add(lspServers, neocmakelsp)
call add(lspServers, perlnavigator)
call add(lspServers, pkl)
call add(lspServers, pyright)
call add(lspServers, rustanalyzer)
call add(lspServers, systemd_lsp)
call add(lspServers, typescript_ls)
" call add(lspServers, sonarlint)
call add(lspServers, vhdl)
call add(lspServers, vimls)
call add(lspServers, yaml_ls)
autocmd 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>ad m0$:LspCodeAction Add<CR>`0
nnoremap <leader>cl :LspCodeLens<CR>
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>
command! -nargs=0 -bar -range=% Format <line1>,<line2>LspFormat
set formatexpr=lsp#lsp#FormatExpr() " Map LspFormat to the gq command