Skip to content

Commit c5f32f4

Browse files
committed
use nvim-lspconfig
1 parent dd0dc50 commit c5f32f4

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

README.md

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,29 @@ See if your editor supports language servers or if there is a plugin to add supp
2424

2525
### Neovim
2626

27-
Example uses [`nvim-lspconfig`](https://github.com/neovim/lspconfig)
27+
Example uses [`nvim-lspconfig`](https://github.com/neovim/nvim-lspconfig)
2828

2929
```lua
30-
local configs = require'lspconfig/configs'
31-
32-
if not configs.cssmodules then
33-
configs.cssmodules = {
34-
default_config = {
35-
cmd = {'cssmodules-language-server'},
36-
filetypes = {'javascript', 'javascriptreact', 'typescript', 'typescriptreact'},
37-
init_options = {
38-
camelCase = 'dashes',
39-
},
40-
root_dir = require('lspconfig.util').root_pattern('package.json')
41-
},
42-
docs = {
43-
description = 'TODO description',
44-
default_config = {
45-
root_dir = '[[root_pattern("package.json")]]'
46-
}
47-
}
48-
}
49-
end
50-
51-
configs.cssmodules.setup {}
52-
-- or
53-
-- configs.cssmodules.setup {on_attach = custom_on_attach}
30+
require'lspconfig'.cssmodules_ls.setup {
31+
-- provide your on_attach to bind keymappings
32+
on_attach = custom_on_attach,
33+
-- optionally
34+
init_options = {
35+
camelCase = 'dashes',
36+
},
37+
}
38+
```
39+
40+
**Known issue**: if you have multiple LSP that provide hover and go-to-definition support, there can be races(example typescript and cssmodules-language-server work simultaneously). As a workaround you can disable **definition** in favor of **implementation** to avoid conflicting with typescript's go-to-definition.
41+
42+
```lua
43+
require'lspconfig'.cssmodules_ls.setup {
44+
on_attach = function (client)
45+
-- avoid accepting `go-to-definition` responses from this LSP
46+
client.resolved_capabilities.goto_definition = false
47+
custom_on_attach(client)
48+
end,
49+
}
5450
```
5551

5652
### [coc.nvim](https://github.com/neoclide/coc.nvim)

0 commit comments

Comments
 (0)