diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-08-25 23:27:45 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-08-25 23:27:45 +0200 |
commit | f93bad12f1b4feeeee007ceab4a350eb1aa26c1e (patch) | |
tree | 15b9edf259fc93da70a599dec47de3cfea551a95 /.config/nvim/lua/lsp/null-ls/services.lua | |
parent | f52dce93777c41671217ced2894c28d6da9114a0 (diff) |
Updates from lvim, remove legacy
Diffstat (limited to '.config/nvim/lua/lsp/null-ls/services.lua')
-rw-r--r-- | .config/nvim/lua/lsp/null-ls/services.lua | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/.config/nvim/lua/lsp/null-ls/services.lua b/.config/nvim/lua/lsp/null-ls/services.lua index 80bf66e..a1e3a06 100644 --- a/.config/nvim/lua/lsp/null-ls/services.lua +++ b/.config/nvim/lua/lsp/null-ls/services.lua @@ -1,28 +1,20 @@ local M = {} -local logger = require("core.log"):get_default() - local function find_root_dir() - if options.builtin.rooter.active then - --- use vim-rooter to set root_dir - vim.cmd "let root_dir = FindRootDirectory()" - return vim.api.nvim_get_var "root_dir" - end - - -- TODO: Rework this to not make it javascript specific - --- use LSP to set root_dir + local util = require "lspconfig/util" local lsp_utils = require "lsp.utils" - local ts_client = lsp_utils.get_active_client_by_ft "typescript" - if ts_client == nil then - logger.error "Unable to determine root directory since tsserver didn't start correctly" - return nil - end - return ts_client.config.root_dir + local status_ok, ts_client = lsp_utils.is_client_active "typescript" + if status_ok then + return ts_client.config.root_dir + end + local dirname = vim.fn.expand "%:p:h" + return util.root_pattern "package.json"(dirname) end local function from_node_modules(command) local root_dir = find_root_dir() + if not root_dir then return nil end |