Skip to content

Commit 7593549

Browse files
authored
fix: make root directory detection dynamic (zbirenbaum#213)
* fix: set root_dir using find_git_ancestor from lspconfig.util * fix: call root_dir instead, since it's now a function * Revert "fix: call root_dir instead, since it's now a function" This reverts commit 587fbeb. * fix: only use client.name in reuse client logic * fix: add get_rootdir and modify root_dir instead * fix: conf -> config
1 parent e601a39 commit 7593549

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lua/copilot/client.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ function M.buf_attach(force)
9797
return
9898
end
9999

100+
local bufnr = vim.api.nvim_get_current_buf()
101+
local bufname = vim.api.nvim_buf_get_name(bufnr)
102+
103+
M.config.root_dir = M.config.get_root_dir(require("lspconfig.util").path.sanitize(bufname), bufnr)
104+
100105
local client_id = lsp_start(M.config)
101106
store_client_id(client_id)
102107
end
@@ -192,6 +197,7 @@ local function prepare_client_config(overrides)
192197
agent_path,
193198
},
194199
root_dir = vim.loop.cwd(),
200+
get_root_dir = require("lspconfig.util").find_git_ancestor,
195201
name = "copilot",
196202
capabilities = capabilities,
197203
get_language_id = function(_, filetype)

0 commit comments

Comments
 (0)