summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-08-09 08:12:30 +0200
committerGitHub <[email protected]>2021-08-09 08:12:30 +0200
commit29b532b5e3d048c162087bd0e57a9bd25b8d87f2 (patch)
tree2ceed258d1bd9c2aebe9671e8c21bee5280776fc
parent93b37d6e8697ec07038f31b3d479c5f1c38777d8 (diff)
parent6b98bc137894492ecbe5dfa03bc149e8760a6453 (diff)
Merge pull request #1268 from kylo252/fix_smart_cwd
-rw-r--r--lua/lsp/init.lua13
1 files changed, 9 insertions, 4 deletions
diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua
index 29676214..020c4313 100644
--- a/lua/lsp/init.lua
+++ b/lua/lsp/init.lua
@@ -51,6 +51,14 @@ local function add_lsp_buffer_keybindings(bufnr)
wk.register(keys, { mode = "n", buffer = bufnr })
end
+local function set_smart_cwd(client)
+ local proj_dir = client.config.root_dir
+ if lvim.lsp.smart_cwd and proj_dir ~= "/" then
+ vim.api.nvim_set_current_dir(proj_dir)
+ require("core.nvimtree").change_tree_dir(proj_dir)
+ end
+end
+
function M.common_capabilities()
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
@@ -113,10 +121,7 @@ function M.common_on_attach(client, bufnr)
end
lsp_highlight_document(client)
add_lsp_buffer_keybindings(bufnr)
- if lvim.lsp.smart_cwd then
- vim.api.nvim_set_current_dir(client.config.root_dir)
- require("core.nvimtree").change_tree_dir(client.config.root_dir)
- end
+ set_smart_cwd(client)
require("lsp.null-ls").setup(vim.bo.filetype)
end