diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2022-05-12 01:37:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-12 01:37:45 +0200 |
| commit | 4f8d9de3e62aebe4154f8119db6e9ef42cf00a18 (patch) | |
| tree | 9b28d77f2018e7168b547ab1ee222f28923956c0 | |
| parent | feat: glint-language-server #1890 (diff) | |
| parent | fix(glint): add more files to root_dir pattern (diff) | |
| download | nvim-lspconfig-4f8d9de3e62aebe4154f8119db6e9ef42cf00a18.tar nvim-lspconfig-4f8d9de3e62aebe4154f8119db6e9ef42cf00a18.tar.gz nvim-lspconfig-4f8d9de3e62aebe4154f8119db6e9ef42cf00a18.tar.bz2 nvim-lspconfig-4f8d9de3e62aebe4154f8119db6e9ef42cf00a18.tar.lz nvim-lspconfig-4f8d9de3e62aebe4154f8119db6e9ef42cf00a18.tar.xz nvim-lspconfig-4f8d9de3e62aebe4154f8119db6e9ef42cf00a18.tar.zst nvim-lspconfig-4f8d9de3e62aebe4154f8119db6e9ef42cf00a18.zip | |
Merge pull request #1893 from williamboman/fix/glint-project-root
fix(glint): detect project dir inside `on_new_config` hook rather than at module import
| -rw-r--r-- | lua/lspconfig/server_configurations/glint.lua | 28 | ||||
| -rw-r--r-- | lua/lspconfig/util.lua | 3 |
2 files changed, 26 insertions, 5 deletions
diff --git a/lua/lspconfig/server_configurations/glint.lua b/lua/lspconfig/server_configurations/glint.lua index e915af67..9c131d2f 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', @@ -18,7 +29,14 @@ return { 'javascript', 'javascript.glimmer', }, - root_dir = util.root_pattern '.glintrc.yml', + root_dir = util.root_pattern( + '.glintrc.yml', + '.glintrc', + '.glintrc.json', + '.glintrc.js', + 'glint.config.js', + 'package.json' + ), }, docs = { description = [[ 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)() |
