aboutsummaryrefslogtreecommitdiffstats
path: root/lsp/jsonls.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lsp/jsonls.lua')
-rw-r--r--lsp/jsonls.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/lsp/jsonls.lua b/lsp/jsonls.lua
index 93ae1db3..b86289e7 100644
--- a/lsp/jsonls.lua
+++ b/lsp/jsonls.lua
@@ -23,7 +23,16 @@
---@type vim.lsp.Config
return {
- cmd = { 'vscode-json-language-server', '--stdio' },
+ cmd = function(dispatchers, config)
+ local cmd = 'vscode-json-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 = { 'json', 'jsonc' },
init_options = {
provideFormatter = true,