diff --git a/README.md b/README.md index 5a214fda..1e991425 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,6 @@ require('copilot').setup({ ["."] = false, }, copilot_node_command = 'node', -- Node version must be < 18 - plugin_manager_path = vim.fn.stdpath("data") .. "/site/pack/packer", server_opts_overrides = {}, }) ``` @@ -201,18 +200,6 @@ Example: copilot_node_command = vim.fn.expand("$HOME") .. "/.config/nvm/versions/node/v16.14.2/bin/node", -- Node version must be < 18 ``` -### plugin_manager_path - -This is installation path of Packer, change this to the plugin manager installation path of your choice. - -Example: - -```lua -require("copilot").setup { - plugin_manager_path = vim.fn.stdpath("data") .. "/site/pack/packer", -} -``` - ### server_opts_overrides Override copilot lsp client settings. The `settings` field is where you can set the values of the options defined in [SettingsOpts.md](./SettingsOpts.md). diff --git a/lua/copilot/client.lua b/lua/copilot/client.lua index 0873649d..3723803d 100644 --- a/lua/copilot/client.lua +++ b/lua/copilot/client.lua @@ -47,7 +47,7 @@ M.merge_server_opts = function(params) return vim.tbl_deep_extend("force", { cmd = { params.copilot_node_command, - require("copilot.util").get_copilot_path(params.plugin_manager_path), + require("copilot.util").get_copilot_path(), }, cmd_cwd = vim.fn.expand("~"), root_dir = vim.loop.cwd(), diff --git a/lua/copilot/init.lua b/lua/copilot/init.lua index 2f146ff8..962c31ec 100644 --- a/lua/copilot/init.lua +++ b/lua/copilot/init.lua @@ -29,7 +29,6 @@ local defaults = { ft_disable = nil, filetypes = {}, copilot_node_command = "node", - plugin_manager_path = vim.fn.stdpath("data") .. "/site/pack/packer", server_opts_overrides = {}, } diff --git a/lua/copilot/util.lua b/lua/copilot/util.lua index 422d8604..7b3e511e 100644 --- a/lua/copilot/util.lua +++ b/lua/copilot/util.lua @@ -229,12 +229,12 @@ function M.get_editor_configuration() } end -M.get_copilot_path = function(plugin_path) - for _, loc in ipairs({ "/opt", "/start", "" }) do - local copilot_path = plugin_path .. loc .. "/copilot.lua/copilot/index.js" - if vim.fn.filereadable(copilot_path) ~= 0 then - return copilot_path - end +M.get_copilot_path = function() + local copilot_path = vim.api.nvim_get_runtime_file('copilot/index.js', false)[1] + if vim.fn.filereadable(copilot_path) ~= 0 then + return copilot_path + else + print("[Copilot] could not read" .. copilot_path) end end