Skip to content

feat: use allow changing the Copilot model used #2 #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ require('copilot').setup({
["."] = false,
},
copilot_node_command = 'node', -- Node.js version must be > 18.x
copilot_model = "", -- Current LSP default is gpt-35-turbo, supports gpt-4o-copilot
server_opts_overrides = {},
})
```
Expand Down
3 changes: 3 additions & 0 deletions lua/copilot/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ local function prepare_client_config(overrides)
end
end,
handlers = handlers,
init_options = {
copilotIntegrationId = "vscode-chat",
},
}, overrides)
end

Expand Down
2 changes: 2 additions & 0 deletions lua/copilot/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ local default_config = {
auth_provider_url = nil,
copilot_node_command = "node",
server_opts_overrides = {},
---@type string|nil
copilot_model = nil,
}

local mod = {
Expand Down
7 changes: 7 additions & 0 deletions lua/copilot/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,20 @@ function M.get_editor_configuration()
filetypes = vim.tbl_deep_extend("keep", filetypes, internal_filetypes)
end

local copilot_model = conf.copilot_model ~= "" and conf.copilot_model or ""

---@type string[]
local disabled_filetypes = vim.tbl_filter(function(ft)
return filetypes[ft] == false
end, vim.tbl_keys(filetypes))
table.sort(disabled_filetypes)

return {
github = {
copilot = {
selectedCompletionModel = copilot_model,
},
},
enableAutoCompletions = not not (conf.panel.enabled or conf.suggestion.enabled),
disabledLanguages = vim.tbl_map(function(ft)
return { languageId = ft }
Expand Down