Adding some snippets and keymaps

This commit is contained in:
Chris
2025-04-29 17:22:28 +01:00
parent 767d2595cd
commit 17e642dcd3
6 changed files with 67 additions and 13 deletions

View File

@@ -73,7 +73,10 @@ vim.api.nvim_create_autocmd('BufEnter', {
for _, window in ipairs(windows) do
local bufnr = vim.api.nvim_win_get_buf(window)
if vim.api.nvim_get_option_value('buflisted', { buf = bufnr }) or vim.api.nvim_get_option_value('filetype', { buf = bufnr }) == 'oil' then
local ft = vim.api.nvim_get_option_value('filetype', { buf = bufnr })
if vim.api.nvim_get_option_value('buflisted', { buf = bufnr })
or ft == 'oil'
or ft == 'snacks_dashboard' then
return
end
end

View File

@@ -34,6 +34,9 @@ vim.keymap.set('n', '<C-S-l>', '<C-w>L', { desc = 'Move window to the right' })
vim.keymap.set('n', '<C-S-j>', '<C-w>J', { desc = 'Move window to the lower' })
vim.keymap.set('n', '<C-S-k>', '<C-w>K', { desc = 'Move window to the upper' })
vim.keymap.set('c', 'tn', 'tabnext<CR>', { desc = 'Next tab' })
vim.keymap.set('c', 'tp', 'tabprevious<CR>', { desc = 'Previous tab' })
-- Overriding CTRL mappings because some of them are stupid
vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-S-B>', '<CMD>Git blame<CR>', { desc = 'Git blame' })
vim.keymap.set({ 'n', 'v', 'c', 'i' }, '<C-Q>', '<CMD>Telescope lsp_document_symbols<CR>', { desc = 'Show symbols in current document' })
@@ -104,9 +107,38 @@ vim.keymap.set('n', '<Leader>gsta', '<CMD>Git stash push<CR>', { desc = 'Git sta
vim.keymap.set('n', '<Leader>gstA', '<CMD>Git stash apply<CR>', { desc = 'Git stash apply' })
vim.keymap.set('n', '<Leader>gstp', '<CMD>Git stash pop<CR>', { desc = 'Git stash pop' })
-- Add keymaps for diff mode
vim.api.nvim_create_autocmd('BufEnter', {
callback = function()
if vim.wo.diff then
-- Keymaps for navigating hunks
vim.api.nvim_buf_set_keymap(0, 'n', '<Tab>', ']c', { noremap = true, silent = true, desc = 'Next hunk in diff mode' })
vim.api.nvim_buf_set_keymap(0, 'n', '<S-Tab>', '[c', { noremap = true, silent = true, desc = 'Previous hunk in diff mode' })
-- Keymaps for resolving conflicts
vim.api.nvim_buf_set_keymap(0, 'n', '<leader>dl', ':diffget LOCAL<CR>', { noremap = true, silent = true, desc = 'Get LOCAL changes' })
vim.api.nvim_buf_set_keymap(0, 'n', '<leader>dr', ':diffget REMOTE<CR>', { noremap = true, silent = true, desc = 'Get REMOTE changes' })
end
end,
})
-- AI mappings
vim.keymap.set('v', '<Leader>ae', '<CMD>CodeCompanion<CR>', { desc = 'Edit selection with AI' })
vim.keymap.set('n', '<Leader>ac', '<CMD>CodeCompanionCmd<CR>', { desc = 'Run Neovim commands with AI' })
vim.api.nvim_create_autocmd('FileType', {
pattern = 'codecompanion',
callback = function()
vim.keymap.set('i', '<S-Enter>', '<CR>', { desc = 'Use shift enter to start a new line' })
vim.keymap.set('n', '<Enter>', 'G', { desc = 'Use enter in normal mode to go to the end of the chat' })
local models = { 'gpt-4o', 'gemini-2.5-pro', 'gemini-2.0-flash', 'claude-3.7-sonnet-thinking', 'o3-mini' }
-- Loop through models and create keymaps for each
for i, model in ipairs(models) do
vim.keymap.set('n', '<C-' .. i .. '>', 'mzggj0WC' .. model .. '<Esc>`z', { desc = 'Switch to ' .. model })
vim.keymap.set('i', '<C-' .. i .. '>', '<Esc>mzggj0WC' .. model .. '<Esc>`zi', { desc = 'Switch to ' .. model })
end
end,
})
-- Search mappings
vim.keymap.set('n', '<Leader>sGb', '<CMD>Telescope git_branches<CR>', { desc = 'Search git branches' })

View File

@@ -50,7 +50,7 @@ return {
completion = {
-- By default, you may press `<c-space>` to show the documentation.
-- Optionally, set `auto_show = true` to show the documentation after a delay.
documentation = { auto_show = true, auto_show_delay_ms = 500 },
documentation = { auto_show = true, auto_show_delay_ms = 200 },
},
sources = {

View File

@@ -1,5 +1,7 @@
require('helpers').edit_cf('pa', '/lua/plugins/codecompanion.lua')
vim.cmd [[cab cc CodeCompanion]]
return {
'olimorris/codecompanion.nvim',
opts = function(_, opts)
@@ -62,7 +64,7 @@ return {
opts.strategies = {
chat = {
adapter = 'gemini',
adapter = 'gpt',
slash_commands = {
codebase = require('vectorcode.integrations').codecompanion.chat.make_slash_command(),
},
@@ -72,6 +74,11 @@ return {
callback = require('vectorcode.integrations').codecompanion.chat.make_tool(),
},
},
keymaps = {
send = {
modes = { i = '<Enter>' },
},
},
},
inline = {
adapter = 'flash',

View File

@@ -1,21 +1,26 @@
return {
"nvim-neotest/neotest",
'nvim-neotest/neotest',
lazy = true,
dependencies = {
"nvim-neotest/nvim-nio",
"nvim-lua/plenary.nvim",
"antoinemadec/FixCursorHold.nvim",
"nvim-treesitter/nvim-treesitter",
'nvim-neotest/nvim-nio',
'nvim-lua/plenary.nvim',
'antoinemadec/FixCursorHold.nvim',
'nvim-treesitter/nvim-treesitter',
-- Adapters
'V13Axel/neotest-pest',
-- "olimorris/neotest-phpunit",
},
config = function()
require('neotest').setup({
require('neotest').setup {
adapters = {
require('neotest-pest'),
require 'neotest-pest' {
sail_enabled = function()
return false
end,
parallel = 10,
},
-- require('neotest-phpunit'),
}
})
end
},
}
end,
}

View File

@@ -13,5 +13,12 @@
"dump($0);"
],
"description": "Dump variable"
},
"Type dump function": {
"prefix": "dt",
"body": [
"\\PhpStan\\dumpType($0);"
],
"description": "Dump PHPStan type"
}
}