Skip to content
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

feat: configure copilot #82

Merged
merged 1 commit into from
Nov 21, 2023
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 flakes/nvim/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
vim-vsnip

copilot-lua
copilot-cmp

fzf-lua

Expand Down
46 changes: 15 additions & 31 deletions flakes/nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ local function configure_auto_completion()
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' }, -- For vsnip users.
{ name = 'vsnip' },
{ name = 'copilot', group_index = 2 },
-- { name = 'luasnip' }, -- For luasnip users.
-- { name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
Expand Down Expand Up @@ -863,44 +864,26 @@ local function configure_copilot()
print('copilot is not installed.')
return
end
if not pcall(require, 'copilot_cmp') then
print('copilot_cmp is not installed.')
return
end

if os.getenv('NVIM_ENABLE_COPILOT') ~= 'true' then
return
end

-- You still need to call :Copilot auth to authenticated the device for
-- You will need to call `:Copilot auth` to authenticate the device for
-- the first time.

-- Default settings, as defined
-- here https://github.com/zbirenbaum/copilot.lua#setup-and-configuration
-- Settings are defined at https://github.com/zbirenbaum/copilot.lua#setup-and-configuration
require('copilot').setup({
panel = {
enabled = true,
auto_refresh = false,
keymap = {
jump_prev = '[[',
jump_next = ']]',
accept = '<CR>',
refresh = 'gr',
open = '<M-CR>',
},
layout = {
position = 'bottom', -- | top | left | right
ratio = 0.4,
},
enabled = false,
auto_refresh = true,
},
suggestion = {
enabled = true,
auto_trigger = false,
debounce = 75,
keymap = {
accept = '<M-l>',
accept_word = false,
accept_line = false,
next = '<M-]>',
prev = '<M-[>',
dismiss = '<C-]>',
},
enabled = false,
},
filetypes = {
-- filetypes here can be boolean values or functions that return a boolean value.
Expand All @@ -915,14 +898,15 @@ local function configure_copilot()
cvs = false,
['.'] = false,
},
copilot_node_command = 'node', -- Node.js version must be > 16.x
copilot_node_command = 'node', -- Node.js version must be > 18.x
server_opts_overrides = {},
})
require('copilot_cmp').setup({})

-- vim.keymap.set('n', '<c-c>', '<cmd>Copilot panel<CR>', { silent = true })

local buffer_number = vim.api.nvim_get_current_buf()
vim.api.nvim_buf_set_var(buffer_number, COPILOT_ENABLED_VAR_NAME, true)

-- TODO also enable copilot-cmp
end

local function configure_git_blame()
Expand Down