Skip to content

Commit c65288b

Browse files
authored
feat: more sophisticated method to get copilot path (zbirenbaum#78)
* feat: more sophisticated method to get copilot path * fix: use `nvim_get_runtime_file` to find copilot
1 parent f9c4bf7 commit c65288b

File tree

4 files changed

+7
-21
lines changed

4 files changed

+7
-21
lines changed

README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ require('copilot').setup({
109109
["."] = false,
110110
},
111111
copilot_node_command = 'node', -- Node version must be < 18
112-
plugin_manager_path = vim.fn.stdpath("data") .. "/site/pack/packer",
113112
server_opts_overrides = {},
114113
})
115114
```
@@ -201,18 +200,6 @@ Example:
201200
copilot_node_command = vim.fn.expand("$HOME") .. "/.config/nvm/versions/node/v16.14.2/bin/node", -- Node version must be < 18
202201
```
203202

204-
### plugin_manager_path
205-
206-
This is installation path of Packer, change this to the plugin manager installation path of your choice.
207-
208-
Example:
209-
210-
```lua
211-
require("copilot").setup {
212-
plugin_manager_path = vim.fn.stdpath("data") .. "/site/pack/packer",
213-
}
214-
```
215-
216203
### server_opts_overrides
217204

218205
Override copilot lsp client settings. The `settings` field is where you can set the values of the options defined in [SettingsOpts.md](./SettingsOpts.md).

lua/copilot/client.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ M.merge_server_opts = function(params)
4747
return vim.tbl_deep_extend("force", {
4848
cmd = {
4949
params.copilot_node_command,
50-
require("copilot.util").get_copilot_path(params.plugin_manager_path),
50+
require("copilot.util").get_copilot_path(),
5151
},
5252
cmd_cwd = vim.fn.expand("~"),
5353
root_dir = vim.loop.cwd(),

lua/copilot/init.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ local defaults = {
2929
ft_disable = nil,
3030
filetypes = {},
3131
copilot_node_command = "node",
32-
plugin_manager_path = vim.fn.stdpath("data") .. "/site/pack/packer",
3332
server_opts_overrides = {},
3433
}
3534

lua/copilot/util.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ function M.get_editor_configuration()
229229
}
230230
end
231231

232-
M.get_copilot_path = function(plugin_path)
233-
for _, loc in ipairs({ "/opt", "/start", "" }) do
234-
local copilot_path = plugin_path .. loc .. "/copilot.lua/copilot/index.js"
235-
if vim.fn.filereadable(copilot_path) ~= 0 then
236-
return copilot_path
237-
end
232+
M.get_copilot_path = function()
233+
local copilot_path = vim.api.nvim_get_runtime_file('copilot/index.js', false)[1]
234+
if vim.fn.filereadable(copilot_path) ~= 0 then
235+
return copilot_path
236+
else
237+
print("[Copilot] could not read" .. copilot_path)
238238
end
239239
end
240240

0 commit comments

Comments
 (0)