Files
nvim-kickstart/lua/custom/keymaps.lua
T
mathiasandClaude Sonnet 5 2646541406 Clean up config: fix broken plugin specs, dedupe options/keymaps, drop dead code
- lspsaga: custom keys lived outside config(), so setup({}) ran empty and
  they never worked; moved into setup() and updated to the plugin's current
  option schema (finder_action_keys/definition_action_keys/move_in_saga
  are stale names in the installed version)
- catppuccin: fixed a stray `as = "catppuccin"` key left outside the plugin
  table; wrapped as { "catppuccin/nvim", name = "catppuccin" }
- options: consolidated the three competing sources (vimrc, init.lua,
  custom/options.lua) into custom/options.lua alone; hlsearch/wrap were
  silently landing opposite to what init.lua's own comments said, purely
  from require-order. custom/options.lua now loads first in the require
  chain since colorizer.lua and others need termguicolors set before their
  own setup() runs
- removed duplicate keymaps that were dead on arrival due to load order
  (<leader>rn, <leader>sf/sg/sh, jj, <leader>y, mapleader x3, manual
  C-h/j/k/l vs vim-tmux-navigator)
- removed dead code: smart_format, root_dir/fallback_root_dir, toggleterm's
  unused _LAZYGIT_TOGGLE/_NODE_TOGGLE/_PYTHON_TOGGLE globals, unused local
  cmp, stale commented blocks, lua/custom/startup.lua
- removed unused plugins: mini.icons, telescope-dap.nvim,
  startup-nvim/startup.nvim (malformed spec, never actually required),
  plus leftover ALE globals with no ALE plugin installed
- vim.loop.* -> vim.uv.*, vim.diagnostic.goto_prev/next ->
  vim.diagnostic.jump({count=...}) for 0.12.5
- guard vim.treesitter.start() at the top of init.lua: the system's
  bundled Lua highlight query is currently ahead of the available
  tree-sitter-lua grammar (a packaging skew, confirmed nvim-treesitter is
  fully up to date), which was throwing on every Lua buffer and taking
  omnifunc/foldexpr down with it; now falls back to regex highlighting
  with a single notify instead

Verified end-to-end against a real Neovim 0.12.5 headless instance with a
fresh plugin install: no load errors, lspsaga's custom keys now actually
apply, and the treesitter guard was confirmed against the real environment.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jVh2Lhn386JAvjSFCHUhn
2026-08-27 22:27:37 +02:00

100 lines
4.3 KiB
Lua

local keymap = vim.keymap
keymap.set('i', 'jj', '<ESC>')
keymap.set('n', '<leader>nh', ':nohl<CR>', { silent = true })
keymap.set('n', '<leader>to', ':tabnew<CR>', { silent = true }) -- open new tab
keymap.set('n', '<leader>tx', ':tabclose<CR>', { silent = true }) -- close current tab
keymap.set('n', '<leader>tn', ':tabn<CR>', { silent = true }) -- go to next tab
keymap.set('n', '<leader>tp', ':tabp<CR>', { silent = true }) -- go to previous tab
-- buffers
keymap.set('n', 'gn', ':bn<CR>', { silent = true })
keymap.set('n', 'gp', ':bp<CR>', { silent = true })
keymap.set('n', 'g[', ':b#<CR>', { silent = true })
-- copy filename in buffer
keymap.set('n', '<leader>cf', ':let @+ = expand("%:t")<CR>', { silent = true })
-- keymap.set('n', '<C-s>', ':w<CR>')
keymap.set('n', '<leader>x', ':bd<CR>', { silent = true })
-- primeagen
keymap.set('v', 'J', ":m '>+1<CR>gv=gv", { silent = true })
keymap.set('v', 'K', ":m '<-2<CR>gv=gv", { silent = true })
-- [search]
keymap.set('n', 'n', 'nzzzh', { silent = true })
keymap.set('n', 'N', 'Nzzzh', { silent = true })
-- [copy/paste]
keymap.set('x', '<leader>p', '"_dP')
keymap.set('n', '<leader>y', '"+yiw')
----------------------
-- Plugin Keybinds
----------------------
-- neo-tree
keymap.set('n', '<leader>e', ':Neotree toggle current position=float<CR>', { noremap = true, silent = true }) -- toggle file explorer
keymap.set('n', '<leader>gt', ':Neotree toggle current reveal_force_cwd position=float<CR>', { silent = true }) -- toggle file explorer
-- telescope
keymap.set('n', '<leader>sf', '<cmd>Telescope find_files<cr>', { silent = true }) -- find files within current working directory, respects .gitignore
keymap.set('n', '<leader>sg', '<cmd>Telescope live_grep<cr>', { silent = true }) -- find string in current working directory as you type
keymap.set('n', '<leader>sc', '<cmd>Telescope grep_string<cr>', { silent = true }) -- find string under cursor in current working directory
keymap.set('n', '<leader>sb', '<cmd>Telescope buffers<cr>', { silent = true }) -- list open buffers in current neovim instance
keymap.set('n', '<leader>sh', '<cmd>Telescope help_tags<cr>', { silent = true }) -- list available help tags
keymap.set('n', '<leader>sk', '<cmd>Telescope keymaps<cr>', { silent = true }) -- list available help tags
-- git merge
keymap.set('n', '<leader>1', ':diffget LOCAL<CR>')
keymap.set('n', '<leader>2', ':diffget REMOTE<CR>')
-- git diff
keymap.set('n', '<leader>gh', ':DiffviewFileHistory %<CR>', { silent = true })
-- toggleterm
keymap.set('n', '<M-1>', '<cmd>ToggleTerm direction=horizontal<cr>', { silent = true })
-- easymotion
keymap.set('n', '<leader>f', '<Plug>(easymotion-prefix)', { silent = true })
keymap.set('n', '<leader>fs', '<Plug>(easymotion-sn)', { silent = true })
keymap.set('n', '<leader>w', '<Plug>(easymotion-overwin-f2)', { silent = true })
keymap.set('n', 'gl', '<Plug>(easymotion-sl)', { silent = true })
vim.g.EasyMotion_smartcase = 1
-- Telescope history
keymap.set('n', '<leader>fh', '<cmd>Telescope file_history history<CR>', { silent = true })
-- Define a custom function to move the current buffer to a vertical split with the previous buffer
function move_to_vertical_split()
local current_buffer = vim.fn.bufnr('%') -- Get the current buffer number
local last_buffer = vim.fn.bufnr('#') -- Get the previous buffer number
-- Check if last_buffer is set; if not, duplicate the current buffer
if last_buffer == -1 then
vim.cmd('vsplit')
vim.cmd('b ' .. current_buffer)
else
vim.cmd('vsplit')
vim.cmd('b ' .. last_buffer)
vim.cmd('wincmd w') -- Switch focus to the original (current) buffer
end
end
-- Map <leader>v to the custom function
keymap.set('n', '<leader>v', [[:lua move_to_vertical_split()<CR>]], { noremap = true, silent = true })
-- select a session to load
keymap.set("n", "<F2>", '<cmd>Telescope persisted<CR>', { silent = true })
keymap.set("n", "<leader>m", function()
local winid = vim.api.nvim_get_current_win()
local wininfo = vim.fn.getwininfo(winid)[1]
if wininfo and wininfo.wincol > vim.o.columns / 2 then
vim.cmd("wincmd H") -- Move to the left if currently on the right
else
vim.cmd("wincmd L") -- Move to the right if currently on the left
end
end, { desc = "Move buffer between left/right split" })