Skip to content

Commit 76667ec

Browse files
committed
✨ add some css lsp
1 parent 95446ed commit 76667ec

File tree

2 files changed

+39
-15
lines changed

2 files changed

+39
-15
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ you can read a little bit more about the above utils in [this article](https://m
162162

163163
- For installing `tsserver` LSP just run: `npm install -g typescript typescript-language-server`. You can read the rest of its doc [here](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#tsserver)
164164

165+
- For installing `cssls` LSP just run: `npm i -g vscode-langservers-extracted`. You can read the rest of its doc [here](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#cssls)
166+
165167
- For installing `emmet-ls` LSP just run: `npm install -g emmet-ls`. You can read the rest of its doc [here](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#emmet_ls)
166168

167169
- For installing `sumneko_lua` LSP read [this doc](https://github.com/sumneko/lua-language-server/wiki/Build-and-Run) and [this doc](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sumneko_lua)

lua/lsp/config/css.lua

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,48 @@ local configs = require("lspconfig/configs")
66

77
-- Setup lspconfig.
88

9-
lspconfig.cssls.setup({
10-
capabilities = setup.capabilities,
11-
filetypes = { "css", "scss", "less", "jsx", "tsx", "javascriptreact", "typescriptreact" },
9+
--Enable (broadcasting) snippet capability for completion
10+
local capabilities = vim.lsp.protocol.make_client_capabilities()
11+
capabilities.textDocument.completion.completionItem.snippetSupport = true
12+
13+
require("lspconfig").cssls.setup({
14+
capabilities = capabilities,
15+
filetypes = {
16+
"css",
17+
"scss",
18+
"less",
19+
"jsx",
20+
"js",
21+
"ts",
22+
"tsx",
23+
"javascriptreact",
24+
"typescriptreact",
25+
"javascript",
26+
"typescript",
27+
},
28+
on_attach = require("lsp.lsp-attach").on_attach,
1229
})
1330

31+
-- lspconfig.cssls.setup({
32+
-- capabilities = setup.capabilities,
33+
-- filetypes = { "css", "scss", "less", "jsx", "tsx", "javascriptreact", "typescriptreact" },
34+
-- })
35+
1436
lspconfig.html.setup({
15-
capabilities = setup.capabilities,
16-
on_attach = require("lsp.lsp-attach").on_attach,
37+
capabilities = setup.capabilities,
38+
on_attach = require("lsp.lsp-attach").on_attach,
1739
})
1840

1941
if not lspconfig.emmet_ls then
20-
configs.emmet_ls = {
21-
default_config = {
22-
cmd = { "emmet-ls", "--stdio" },
23-
filetypes = { "html", "css", "blade", "jsx", "tsx", "javascriptreact", "typescriptreact" },
24-
root_dir = function(fname)
25-
return vim.loop.cwd()
26-
end,
27-
settings = {},
28-
},
29-
}
42+
configs.emmet_ls = {
43+
default_config = {
44+
cmd = { "emmet-ls", "--stdio" },
45+
filetypes = { "html", "css", "blade", "jsx", "tsx", "javascriptreact", "typescriptreact" },
46+
root_dir = function(fname)
47+
return vim.loop.cwd()
48+
end,
49+
settings = {},
50+
},
51+
}
3052
end
3153
lspconfig.emmet_ls.setup({ capabilities = setup.capabilities })

0 commit comments

Comments
 (0)