Skip to content

Commit a755b0e

Browse files
committed
Vim: support coc.nvim
1 parent 1e0d46d commit a755b0e

File tree

5 files changed

+85
-2
lines changed

5 files changed

+85
-2
lines changed

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Beta release.
3131
* The macOS and Windows executables now include embedded code signatures. These
3232
signatures are made with a self-signed certificate.
3333
* The Linux executables are now signed with a GPG signature (`.asc` files).
34+
* Vim: [coc.nvim][] is now supported.
3435

3536
### Fixed
3637

@@ -202,6 +203,7 @@ Beta release.
202203
[Lee Wannacott]: https://github.com/LeeWannacott
203204
[Matheus Sousa]: https://github.com/keyehzy
204205
[Shivam Mehta]: https://github.com/maniac-en
206+
[coc.nvim]: https://github.com/neoclide/coc.nvim
205207
[config-global-groups]: https://quick-lint-js.com/config/#global-groups
206208
[tiagovla]: https://github.com/tiagovla
207209
[wagner riffel]: https://github.com/wgrr

plugin/vim/quick-lint-js.vim/doc/quick-lint-js.txt

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ newer version might or might not work.
1414
2. Installing the plugin |quick-lint-js-vim-install|
1515
3. Configuring |quick-lint-js-configure|
1616
3.1. ALE |quick-lint-js-configure-ale|
17-
3.2. nvim-lspconfig |quick-lint-js-configure-nvim-lspconfig|
17+
3.2. coc.nvim |quick-lint-js-configure-coc-nvim|
18+
3.3. nvim-lspconfig |quick-lint-js-configure-nvim-lspconfig|
1819

1920
==============================================================================
2021
1. Installing quick-lint-js *quick-lint-js-app-install*
@@ -112,7 +113,41 @@ could run arbitrary code on your computer through `node_modules` if you open a
112113
JavaScript file.
113114

114115
==============================================================================
115-
3.2. Configuring for nvim-lspconfig *quick-lint-js-configure-nvim-lspconfig*
116+
3.2. Configuring for coc.nvim *quick-lint-js-configure-coc-nvim*
117+
118+
The quick-lint-js Vim plugin comes with a plugin for coc.nvim (Conquer of
119+
Completion). https://github.com/neoclide/coc.nvim
120+
121+
Supported coc.nvim versions: v0.0.80 or newer
122+
123+
quick-lint-js is fast. To feel the speed, you should configure
124+
`diagnostic.messageDelay` and `diagnostic.refreshOnInsertMode`. Add the
125+
following code to your |coc-configuration| (run `:CocConfig`) to make
126+
JavaScript linting as fast as possible:
127+
128+
"diagnostic.messageDelay": 0,
129+
"diagnostic.refreshOnInsertMode": true,
130+
131+
Unfortunately, there is an unconfigurable 400 millisecond delay hard-coded
132+
into coc.nvim:
133+
https://github.com/neoclide/coc.nvim/blob/9f6e29b6f9661ebba10ff3df84de11d96c8a9e56/src/model/document.ts#L75,L78
134+
If you want linting to feel faster, try ALE or nvim-lspconfig instead of
135+
coc.nvim.
136+
137+
You can customize this plugin's configuration by copy-pasting the following
138+
snippet into your |coc-configuration| then tweaking it according to
139+
|coc-config-languageserver|:
140+
141+
"languageserver": {
142+
"quick-lint-js": {
143+
"args": ["--lsp-server"],
144+
"command": "quick-lint-js",
145+
"filetypes": ["javascript", "json"]
146+
}
147+
}
148+
149+
==============================================================================
150+
3.3. Configuring for nvim-lspconfig *quick-lint-js-configure-nvim-lspconfig*
116151

117152
The quick-lint-js Vim plugin comes with a plugin for nvim-lspconfig.
118153
https://github.com/neovim/nvim-lspconfig
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
" Copyright (C) 2020 Matthew "strager" Glazar
2+
" See end of file for extended copyright information.
3+
4+
" Register quick-lint-js with coc.nvim (Conquer of Completion).
5+
" https://github.com/neoclide/coc.nvim
6+
try
7+
call coc#config('languageserver', {
8+
\ 'quick-lint-js': {
9+
\ 'args': ['--lsp-server'],
10+
\ 'command': 'quick-lint-js',
11+
\ 'filetypes': ['javascript', 'json'],
12+
\ }
13+
\ })
14+
catch /E117/
15+
" coc#config does not exist; coc.nvim is not installed. Ignore.
16+
endtry
17+
18+
" quick-lint-js finds bugs in JavaScript programs.
19+
" Copyright (C) 2020 Matthew "strager" Glazar
20+
"
21+
" This file is part of quick-lint-js.
22+
"
23+
" quick-lint-js is free software: you can redistribute it and/or modify
24+
" it under the terms of the GNU General Public License as published by
25+
" the Free Software Foundation, either version 3 of the License, or
26+
" (at your option) any later version.
27+
"
28+
" quick-lint-js is distributed in the hope that it will be useful,
29+
" but WITHOUT ANY WARRANTY; without even the implied warranty of
30+
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31+
" GNU General Public License for more details.
32+
"
33+
" You should have received a copy of the GNU General Public License
34+
" along with quick-lint-js. If not, see <https://www.gnu.org/licenses/>.

website/public/install/neovim/common-prerequisites.ejs.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
>
1212
v2.1.1 or newer, or version v3.0.0 or newer
1313
</li>
14+
<li>
15+
<a href="https://github.com/neoclide/coc.nvim"
16+
>coc.nvim - Conquer of Completion</a
17+
>
18+
v0.0.80 or newer
19+
</li>
1420
<li>
1521
<a href="https://github.com/neovim/nvim-lspconfig">nvim-lspconfig</a>
1622
(requires Neovim 0.5.0 or newer)

website/public/install/vim/common-prerequisites.ejs.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
>
1212
v2.1.1 or newer, or version v3.0.0 or newer
1313
</li>
14+
<li>
15+
<a href="https://github.com/neoclide/coc.nvim"
16+
>coc.nvim - Conquer of Completion</a
17+
>
18+
v0.0.80 or newer
19+
</li>
1420
</ul>
1521

1622
<%#

0 commit comments

Comments
 (0)