1
1
# Vim / Neovim
2
2
3
- ## vim-go
3
+ * [ vim-go] ( #vimgo )
4
+ * [ LanguageClient-neovim] ( #lcneovim )
5
+ * [ Ale] ( #ale )
6
+ * [ vim-lsp] ( #vimlsp )
7
+ * [ vim-lsc] ( #vimlsc )
8
+ * [ coc.nvim] ( #cocnvim )
9
+ * [ govim] ( #govim )
10
+ * [ Neovim v0.5.0+] ( #neovim )
11
+ * [ Installation] ( #neovim-install )
12
+ * [ Custom Configuration] ( #neovim-config )
13
+ * [ Imports] ( #neovim-imports )
14
+ * [ Omnifunc] ( #neovim-omnifunc )
15
+ * [ Additional Links] ( #neovim-links )
16
+
17
+ ## <a href =" #vimgo " id =" vimgo " >vim-go</a >
4
18
5
19
Use [ vim-go] ver 1.20+, with the following configuration:
6
20
@@ -9,7 +23,7 @@ let g:go_def_mode='gopls'
9
23
let g:go_info_mode='gopls'
10
24
```
11
25
12
- ## LanguageClient-neovim
26
+ ## < a href = " #lcneovim " id = " lcneovim " > LanguageClient-neovim</ a >
13
27
14
28
Use [ LanguageClient-neovim] , with the following configuration:
15
29
@@ -22,7 +36,7 @@ let g:LanguageClient_serverCommands = {
22
36
autocmd BufWritePre *.go :call LanguageClient#textDocument_formatting_sync()
23
37
```
24
38
25
- ## Ale
39
+ ## < a href = " #ale " id = " ale " > Ale</ a >
26
40
27
41
Use [ ale] :
28
42
@@ -34,7 +48,7 @@ let g:ale_linters = {
34
48
35
49
see [ this issue] [ ale-issue-2179 ]
36
50
37
- ## vim-lsp
51
+ ## < a href = " #vimlsp " id = " vimlsp " > vim-lsp</ a >
38
52
39
53
Use [ prabirshrestha/vim-lsp] , with the following configuration:
40
54
@@ -53,7 +67,7 @@ augroup LspGo
53
67
augroup END
54
68
```
55
69
56
- ## vim-lsc
70
+ ## < a href = " #vimlsc " id = " vimlsc " > vim-lsc</ a >
57
71
58
72
Use [ natebosch/vim-lsc] , with the following configuration:
59
73
@@ -71,7 +85,7 @@ The `log_level` and `suppress_stderr` parts are needed to prevent breakage from
71
85
issues [ #180 ] ( https://github.com/natebosch/vim-lsc/issues/180 ) and
72
86
[ #213 ] ( https://github.com/natebosch/vim-lsc/issues/213 ) .
73
87
74
- ## coc.nvim
88
+ ## < a href = " #cocnvim " id = " cocnvim " > coc.nvim</ a >
75
89
76
90
Use [ coc.nvim] , with the following ` coc-settings.json ` configuration:
77
91
@@ -96,26 +110,38 @@ The `editor.action.organizeImport` code action will auto-format code and add mis
96
110
autocmd BufWritePre *.go :call CocAction('runCommand', 'editor.action.organizeImport')
97
111
```
98
112
99
- ## govim
113
+ ## < a href = " # govim" id = " govim " >govim</ a >
100
114
101
115
In vim classic only, use the experimental [ ` govim ` ] , simply follow the [ install steps] [ govim-install ] .
102
116
103
- ## Neovim v0.5.0+
117
+ ## < a href = " #neovim " id = " neovim " > Neovim v0.5.0+</ a >
104
118
105
119
To use the new (still experimental) native LSP client in Neovim, make sure you
106
120
[ install] [ nvim-install ] the prerelease v0.5.0 version of Neovim (aka “nightly”),
107
121
the ` nvim-lspconfig ` configuration helper plugin, and check the
108
122
[ ` gopls ` configuration section] [ nvim-lspconfig ] there.
109
123
110
- ### Custom configuration
124
+ ### <a href =" #neovim-install " id =" neovim-install " >Installation</a >
125
+
126
+ You can use Neovim's native plugin system. On a Unix system, you can do that by
127
+ cloning the ` nvim-lspconfig ` repository into the correct directory:
128
+
129
+ ``` sh
130
+ dir=" ${HOME} /.local/share/nvim/site/pack/nvim-lspconfig/opt/nvim-lspconfig/"
131
+ mkdir -p " $dir "
132
+ cd " $dir "
133
+ git clone ' https://github.com/neovim/nvim-lspconfig.git' .
134
+ ```
135
+
136
+ ### <a href =" #neovim-config " id =" neovim-config " >Custom Configuration</a >
111
137
112
138
You can add custom configuration using Lua. Here is an example of enabling the
113
139
` unusedparams ` check as well as ` staticcheck ` :
114
140
115
141
``` vim
116
142
lua <<EOF
117
- nvim_lsp = require "lspconfig"
118
- nvim_lsp .gopls.setup {
143
+ lspconfig = require "lspconfig"
144
+ lspconfig .gopls.setup {
119
145
cmd = {"gopls", "serve"},
120
146
settings = {
121
147
gopls = {
@@ -129,7 +155,7 @@ lua <<EOF
129
155
EOF
130
156
```
131
157
132
- ### Imports
158
+ ### < a href = " #neovim-imports " id = " neovim-imports " > Imports</ a >
133
159
134
160
To get your imports ordered on save, like ` goimports ` does, you can define
135
161
a helper function in Lua:
@@ -164,7 +190,7 @@ autocmd BufWritePre *.go lua goimports(1000)
164
190
165
191
(Taken from the [ discussion] [ nvim-lspconfig-imports ] on Neovim issue tracker.)
166
192
167
- ### Omnifunc
193
+ ### < a href = " #neovim-omnifunc " id = " neovim-omnifunc " > Omnifunc</ a >
168
194
169
195
To make your <kbd >Ctrl</kbd >+<kbd >x</kbd >,<kbd >Ctrl</kbd >+<kbd >o</kbd > work, add
170
196
this to your ` init.vim ` :
@@ -173,7 +199,7 @@ this to your `init.vim`:
173
199
autocmd FileType go setlocal omnifunc=v:lua.vim.lsp.omnifunc
174
200
```
175
201
176
- ### Additional Links
202
+ ### < a href = " #neovim-links " id = " neovim-links " > Additional Links</ a >
177
203
178
204
* [ Neovim's official LSP documentation] [ nvim-docs ] .
179
205
0 commit comments