feat: add copilot and update harpoon to v2
This commit is contained in:
parent
d580ce71e9
commit
9502eb0f10
|
|
@ -0,0 +1,99 @@
|
||||||
|
return {
|
||||||
|
'zbirenbaum/copilot.lua',
|
||||||
|
cmd = 'Copilot',
|
||||||
|
event = 'InsertEnter',
|
||||||
|
config = function()
|
||||||
|
require('copilot').setup {
|
||||||
|
panel = {
|
||||||
|
enabled = true,
|
||||||
|
auto_refresh = false,
|
||||||
|
keymap = {
|
||||||
|
jump_prev = '[[',
|
||||||
|
jump_next = ']]',
|
||||||
|
accept = '<CR>',
|
||||||
|
refresh = 'gr',
|
||||||
|
open = '<C-CR>', -- Ctrl+Enter (better for Mac)
|
||||||
|
},
|
||||||
|
layout = {
|
||||||
|
position = 'bottom',
|
||||||
|
ratio = 0.4,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
suggestion = {
|
||||||
|
enabled = true,
|
||||||
|
auto_trigger = true,
|
||||||
|
debounce = 75,
|
||||||
|
keymap = {
|
||||||
|
accept = '<Tab>', -- Tab to accept (most common)
|
||||||
|
accept_word = '<C-Right>', -- Ctrl+Right Arrow
|
||||||
|
accept_line = '<C-l>', -- Ctrl+l
|
||||||
|
next = '<A-]>', -- Ctrl+] for next
|
||||||
|
prev = '<A-[>', -- Ctrl+[ for previous
|
||||||
|
dismiss = '<C-\\>', -- Ctrl+\ to dismiss
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filetypes = {
|
||||||
|
yaml = false,
|
||||||
|
markdown = false,
|
||||||
|
help = false,
|
||||||
|
gitcommit = false,
|
||||||
|
gitrebase = false,
|
||||||
|
hgcommit = false,
|
||||||
|
svn = false,
|
||||||
|
cvs = false,
|
||||||
|
['.'] = false,
|
||||||
|
},
|
||||||
|
copilot_node_command = 'node', -- Make sure you have Node.js installed
|
||||||
|
server_opts_overrides = {},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Mac-friendly custom keymaps
|
||||||
|
local opts = { silent = true, noremap = true }
|
||||||
|
|
||||||
|
-- Panel controls (using Cmd instead of Alt when possible)
|
||||||
|
vim.keymap.set('n', '<leader>co', function()
|
||||||
|
require('copilot.panel').open { position = 'bottom', ratio = 0.4 }
|
||||||
|
end, { desc = 'Open Copilot panel' })
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<leader>cr', function()
|
||||||
|
require('copilot.panel').refresh()
|
||||||
|
end, { desc = 'Refresh Copilot suggestions' })
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<leader>cc', function()
|
||||||
|
require('copilot.panel').close()
|
||||||
|
end, { desc = 'Close Copilot panel' })
|
||||||
|
|
||||||
|
-- Alternative panel opening in insert mode
|
||||||
|
vim.keymap.set('i', '<C-g>', function()
|
||||||
|
require('copilot.panel').open { position = 'right', ratio = 0.3 }
|
||||||
|
end, { desc = 'Open Copilot panel (insert mode)' })
|
||||||
|
|
||||||
|
-- Suggestion controls that work well on Mac
|
||||||
|
vim.keymap.set('i', '<C-j>', function()
|
||||||
|
require('copilot.suggestion').next()
|
||||||
|
end, { desc = 'Next Copilot suggestion' })
|
||||||
|
|
||||||
|
vim.keymap.set('i', '<C-k>', function()
|
||||||
|
require('copilot.suggestion').prev()
|
||||||
|
end, { desc = 'Previous Copilot suggestion' })
|
||||||
|
|
||||||
|
-- Toggle auto trigger
|
||||||
|
vim.keymap.set('i', '<C-o>', function()
|
||||||
|
require('copilot.suggestion').toggle_auto_trigger()
|
||||||
|
end, { desc = 'Toggle Copilot auto trigger' })
|
||||||
|
|
||||||
|
-- Manual suggestion trigger
|
||||||
|
vim.keymap.set('i', '<C-Space>', function()
|
||||||
|
require('copilot.suggestion').next()
|
||||||
|
end, { desc = 'Trigger Copilot suggestion' })
|
||||||
|
|
||||||
|
-- Accept with different granularities
|
||||||
|
vim.keymap.set('i', '<S-Tab>', function()
|
||||||
|
require('copilot.suggestion').accept_word()
|
||||||
|
end, { desc = 'Accept word' })
|
||||||
|
|
||||||
|
vim.keymap.set('i', '<C-Tab>', function()
|
||||||
|
require('copilot.suggestion').accept_line()
|
||||||
|
end, { desc = 'Accept line' })
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
@ -1,21 +1,82 @@
|
||||||
-- NOTE: Harpoon setup
|
-- NOTE: Harpoon2 setup
|
||||||
return {
|
return {
|
||||||
'theprimeagen/harpoon',
|
'ThePrimeagen/harpoon',
|
||||||
|
branch = 'harpoon2',
|
||||||
|
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||||
config = function()
|
config = function()
|
||||||
local mark = require 'harpoon.mark'
|
local harpoon = require 'harpoon'
|
||||||
local ui = require 'harpoon.ui'
|
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>a', mark.add_file)
|
-- REQUIRED
|
||||||
vim.keymap.set('n', '<C-e>', ui.toggle_quick_menu)
|
harpoon:setup()
|
||||||
|
-- OPTIONAL - you can customize settings here
|
||||||
|
-- harpoon:setup({
|
||||||
|
-- settings = {
|
||||||
|
-- save_on_toggle = true,
|
||||||
|
-- sync_on_ui_close = true,
|
||||||
|
-- key = function()
|
||||||
|
-- return vim.loop.cwd()
|
||||||
|
-- end,
|
||||||
|
-- },
|
||||||
|
-- })
|
||||||
|
|
||||||
|
-- Basic keymaps
|
||||||
|
vim.keymap.set('n', '<leader>a', function()
|
||||||
|
harpoon:list():add()
|
||||||
|
end, { desc = 'Harpoon add file' })
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<C-e>', function()
|
||||||
|
harpoon.ui:toggle_quick_menu(harpoon:list())
|
||||||
|
end, { desc = 'Harpoon toggle menu' })
|
||||||
|
|
||||||
|
-- Navigation keymaps
|
||||||
vim.keymap.set('n', '<C-r>', function()
|
vim.keymap.set('n', '<C-r>', function()
|
||||||
ui.nav_file(1)
|
harpoon:list():select(1)
|
||||||
end)
|
end, { desc = 'Harpoon to file 1' })
|
||||||
|
|
||||||
vim.keymap.set('n', '<C-t>', function()
|
vim.keymap.set('n', '<C-t>', function()
|
||||||
ui.nav_file(2)
|
harpoon:list():select(2)
|
||||||
end)
|
end, { desc = 'Harpoon to file 2' })
|
||||||
|
|
||||||
vim.keymap.set('n', '<C-y>', function()
|
vim.keymap.set('n', '<C-y>', function()
|
||||||
ui.nav_file(3)
|
harpoon:list():select(3)
|
||||||
end)
|
end, { desc = 'Harpoon to file 3' })
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<C-u>', function()
|
||||||
|
harpoon:list():select(4)
|
||||||
|
end, { desc = 'Harpoon to file 4' })
|
||||||
|
|
||||||
|
-- Toggle previous & next buffers stored within Harpoon list
|
||||||
|
vim.keymap.set('n', '<C-S-P>', function()
|
||||||
|
harpoon:list():prev()
|
||||||
|
end, { desc = 'Harpoon previous buffer' })
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<C-S-N>', function()
|
||||||
|
harpoon:list():next()
|
||||||
|
end, { desc = 'Harpoon next buffer' })
|
||||||
|
|
||||||
|
-- Optional: Telescope integration
|
||||||
|
-- If you have telescope installed, you can add this for a better UI
|
||||||
|
local conf = require('telescope.config').values
|
||||||
|
local function toggle_telescope(harpoon_files)
|
||||||
|
local file_paths = {}
|
||||||
|
for _, item in ipairs(harpoon_files.items) do
|
||||||
|
table.insert(file_paths, item.value)
|
||||||
|
end
|
||||||
|
|
||||||
|
require('telescope.pickers')
|
||||||
|
.new({}, {
|
||||||
|
prompt_title = 'Harpoon',
|
||||||
|
finder = require('telescope.finders').new_table {
|
||||||
|
results = file_paths,
|
||||||
|
},
|
||||||
|
previewer = conf.file_previewer {},
|
||||||
|
sorter = conf.generic_sorter {},
|
||||||
|
})
|
||||||
|
:find()
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<C-e>', function()
|
||||||
|
toggle_telescope(harpoon:list())
|
||||||
|
end, { desc = 'Open harpoon window' })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ require('lazy').setup({
|
||||||
require 'newbim/plugins/mini',
|
require 'newbim/plugins/mini',
|
||||||
require 'newbim/plugins/comment',
|
require 'newbim/plugins/comment',
|
||||||
require 'newbim/plugins/markdown',
|
require 'newbim/plugins/markdown',
|
||||||
|
require 'newbim/plugins/copilot',
|
||||||
}, {
|
}, {
|
||||||
ui = {
|
ui = {
|
||||||
-- If you are using a Nerd Font: set icons to an empty table which will use the
|
-- If you are using a Nerd Font: set icons to an empty table which will use the
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue