diff options
author | kylo252 <[email protected]> | 2021-08-03 18:10:54 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2021-08-03 12:10:54 -0400 |
commit | 4c3c3f388557a182794bffdbf923129c66af885a (patch) | |
tree | 4138b428ccfbee42ffecdbc88bc7d2d42fa67195 /lua/lsp/null-ls.lua | |
parent | b608b08ff3a5f28e7c57bc7bd7a30cfe2ab5c111 (diff) |
feat: add lvim.lsp.smart_cwd (#1218)
- Enable querying the language-server for the `root_dir`
- Use `root_dir` to set the current working-directory (CWD)
- Make vim-rooter configurable and add an option to disable it
Inspired by "ahmedkhalf/lsp-rooter.nvim"
Diffstat (limited to 'lua/lsp/null-ls.lua')
-rw-r--r-- | lua/lsp/null-ls.lua | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index 51fab00b..d3f7931b 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -24,10 +24,14 @@ function M.get_registered_providers_by_filetype(ft) end local function validate_nodejs_provider(requests, provider) - vim.cmd "let root_dir = FindRootDirectory()" - local root_dir = vim.api.nvim_get_var "root_dir" + local ts_client = require("utils").get_active_client_by_ft "typescript" + if ts_client == nil then + u.lvim_log "Unable to determine root directory since tsserver didn't start correctly" + return + end + local root_dir = ts_client.config.root_dir local local_nodejs_command = root_dir .. "/node_modules/.bin/" .. provider._opts.command - u.lvim_log(string.format("checking for local node module: [%s]", vim.inspect(provider))) + u.lvim_log(string.format("checking [%s] for local node module: [%s]", local_nodejs_command, vim.inspect(provider))) if vim.fn.executable(local_nodejs_command) == 1 then provider._opts.command = local_nodejs_command table.insert(requests, provider) |