aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-05-06 12:06:51 +0200
committerWilliam Boman <william@redwill.se>2022-05-06 12:21:12 +0200
commitd42b86ac71063c54c53402e0c7e2ed667cc2f495 (patch)
tree7761aa6b5cd5644db78414ef50107ad651b762b6 /lua
parentfeat: glint-language-server #1890 (diff)
downloadnvim-lspconfig-d42b86ac71063c54c53402e0c7e2ed667cc2f495.tar
nvim-lspconfig-d42b86ac71063c54c53402e0c7e2ed667cc2f495.tar.gz
nvim-lspconfig-d42b86ac71063c54c53402e0c7e2ed667cc2f495.tar.bz2
nvim-lspconfig-d42b86ac71063c54c53402e0c7e2ed667cc2f495.tar.lz
nvim-lspconfig-d42b86ac71063c54c53402e0c7e2ed667cc2f495.tar.xz
nvim-lspconfig-d42b86ac71063c54c53402e0c7e2ed667cc2f495.tar.zst
nvim-lspconfig-d42b86ac71063c54c53402e0c7e2ed667cc2f495.zip
fix(glint): detect project dir inside `on_new_config` hook rather than at module import
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/server_configurations/glint.lua19
-rw-r--r--lua/lspconfig/util.lua3
2 files changed, 18 insertions, 4 deletions
diff --git a/lua/lspconfig/server_configurations/glint.lua b/lua/lspconfig/server_configurations/glint.lua
index e915af67..1d60f244 100644
--- a/lua/lspconfig/server_configurations/glint.lua
+++ b/lua/lspconfig/server_configurations/glint.lua
@@ -1,15 +1,26 @@
local util = require 'lspconfig.util'
local bin_name = 'glint-language-server'
+local cmd = { bin_name }
--- Glint should not be installed globally.
-local path_to_node_modules = util.find_node_modules_ancestor(vim.fn.getcwd())
-
-local cmd = { path_to_node_modules .. '/node_modules/.bin/' .. bin_name }
+if vim.fn.has 'win32' == 1 then
+ cmd = { 'cmd.exe', '/C', bin_name }
+end
return {
default_config = {
cmd = cmd,
+ on_new_config = function(config, new_root_dir)
+ local project_root = util.find_node_modules_ancestor(new_root_dir)
+ -- Glint should not be installed globally.
+ local node_bin_path = util.path.join(project_root, 'node_modules', '.bin')
+ local path = node_bin_path .. util.path.path_separator .. vim.env.PATH
+ if config.cmd_env then
+ config.cmd_env.PATH = path
+ else
+ config.cmd_env = { PATH = path }
+ end
+ end,
filetypes = {
'html.handlebars',
'handlebars',
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index dec80d95..a1eb75ba 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -207,6 +207,8 @@ M.path = (function()
return dir == root
end
+ local path_separator = is_windows and ';' or ':'
+
return {
is_dir = is_dir,
is_file = is_file,
@@ -218,6 +220,7 @@ M.path = (function()
traverse_parents = traverse_parents,
iterate_parents = iterate_parents,
is_descendant = is_descendant,
+ path_separator = path_separator,
}
end)()