Update files

This commit is contained in:
Chris
2026-07-03 16:05:57 +01:00
parent fbcdd3af0c
commit 7198cb031a
6 changed files with 78 additions and 440 deletions
+54 -2
View File
@@ -121,6 +121,11 @@ vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right win
vim.keymap.set('n', '<C-j>', (win_or_treesj)('j', 'Move focus to the lower window or treesj.toggle()'))
vim.keymap.set('n', '<C-k>', (win_or_treesj)('k', 'Move focus to the upper window or treesj.toggle()'))
vim.keymap.set('t', '<C-h>', '<C-\\><C-n><C-w>h', { desc = 'Move focus to the left window' })
vim.keymap.set('t', '<C-l>', '<C-\\><C-n><C-w>l', { desc = 'Move focus to the right window' })
vim.keymap.set('t', '<C-j>', '<C-\\><C-n><C-w>j', { desc = 'Move focus to the lower window' })
vim.keymap.set('t', '<C-k>', '<C-\\><C-n><C-w>k', { desc = 'Move focus to the upper window' })
vim.keymap.set({ 'i' }, '<C-J>', function()
local ls = require 'luasnip'
if ls.choice_active() then
@@ -177,8 +182,54 @@ vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-f>', function()
end, { desc = 'Search within the whole project' })
vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-Y>', '<CMD>Telescope quickfix<CR>', { desc = 'Show quickfix list' })
vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-S-Y>', '<CMD>Telescope quickfixhistory<CR>', { desc = 'Show quickfix history' })
vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-A>', '<CMD>CodeCompanionChat Toggle<CR>', { desc = 'Open AI Actions' })
vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-S-A>', '<CMD>CodeCompanionActions<CR>', { desc = 'Open AI Actions' })
vim.keymap.set({ 'n', 'v', 'c', 'i', 't' }, '<C-A>', function()
local ai_tools = { 'codex', 'agy', 'opencode' }
local ai_win_opts = {
width = math.floor(vim.o.columns / 3),
vertical = true,
split = 'right',
}
local term_bufnr = -1
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
if vim.bo[bufnr].buftype == 'terminal' then
local name = vim.api.nvim_buf_get_name(bufnr)
for _, tool in ipairs(ai_tools) do
if name:match(':' .. tool .. '$') or name:match('/' .. tool .. '$') then
term_bufnr = bufnr
end
end
end
end
if term_bufnr ~= -1 then
local term_winid = vim.fn.bufwinid(term_bufnr)
if term_winid ~= -1 then
vim.api.nvim_win_hide(term_winid)
return
end
vim.api.nvim_open_win(term_bufnr, true, ai_win_opts)
vim.cmd.startinsert()
return
end
for _, tool in ipairs(ai_tools) do
if vim.fn.executable(tool) == 1 then
helpers.open_term {
cmd = tool,
win_opts = ai_win_opts,
buf_opts = {
bufhidden = 'hide',
modifiable = false,
},
}
return
end
end
vim.api.nvim_echo({ { 'No AI tool found. Please install one of the following: codex, agy, opencode', 'WarningMsg' } }, false, {})
end, { desc = 'Toggle AI tool' })
-- vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-A>', '<CMD>vsplit term://codex<CR>i', { desc = 'Open AI tool' })
vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-S>', function()
require('snacks').scratch()
end, { desc = 'Open scratchpad' })
@@ -398,3 +449,4 @@ vim.keymap.set('n', '<Leader>cr', function()
end, { desc = 'Open RegExp cheat sheet' })
require('helpers').edit_cf('k', '/lua/keymap.lua')