aboutsummaryrefslogtreecommitdiffstats
path: root/lsp/cssls.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lsp/cssls.lua')
-rw-r--r--lsp/cssls.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/lsp/cssls.lua b/lsp/cssls.lua
index 5f825b4a..8333628e 100644
--- a/lsp/cssls.lua
+++ b/lsp/cssls.lua
@@ -22,10 +22,20 @@
---@type vim.lsp.Config
return {
- cmd = { 'vscode-css-language-server', '--stdio' },
+ cmd = function(dispatchers, config)
+ local cmd = 'vscode-css-language-server'
+ if (config or {}).root_dir then
+ local local_cmd = vim.fs.joinpath(config.root_dir, 'node_modules/.bin', cmd)
+ if vim.fn.executable(local_cmd) == 1 then
+ cmd = local_cmd
+ end
+ end
+ return vim.lsp.rpc.start({ cmd, '--stdio' }, dispatchers)
+ end,
filetypes = { 'css', 'scss', 'less' },
init_options = { provideFormatter = true }, -- needed to enable formatting capabilities
root_markers = { 'package.json', '.git' },
+ ---@type lspconfig.settings.cssls
settings = {
css = { validate = true },
scss = { validate = true },