-- Spellchecker vim.o.spelllang = 'en,es' vim.o.spellsuggest = 'best,10' vim.o.spellfile = vim.fn.expand('~/.local/share/nvim/site/spell/words.utf-8.add') -- Commands ----------------------------------------------------------------- vim.api.nvim_create_user_command('ReloadInit', 'source $MYVIMRC', {}) vim.api.nvim_create_user_command('Mswq', 'wa | mkses! | qa', { desc = [[Saves all files, saves this session and quits.]] }) -- Keybinds ----------------------------------------------------------------- -- More ergonomic terminal mode escape keybind vim.keymap.set('t', '', [[]], { silent = true }) -- Delete buffer without closing the window vim.keymap.set('n', 'q', ':bp|bd#', { silent = true }) -- ditto but forceful vim.keymap.set('n', 'Q', ':bp|bd!#', { silent = true }) -- Toggle spell checker vim.keymap.set('n', '', ':setlocal spell!', { silent = true, desc = [[Toggle spell checker]] }) vim.keymap.set('i', '', ':setlocal spell!', { silent = true, desc = [[Toggle spell checker]] }) -- Aliases for "yank/delete current line" vim.keymap.set('n', 'Y', 'y_', { silent = true }) vim.keymap.set('n', 'D', 'd_', { silent = true }) -- System clipboard interaction keybinds vim.keymap.set({'n', 'v'}, 'gy', '"+y', { desc = [[Yank to system's selection clipboard]] }) vim.keymap.set({'n', 'v'}, 'gp', '"+p', { desc = [[Paste from system's selection clipboard]] }) -- This one is cool; it allows to delete the line contents without the trailling newline -- (and without any preceding whitespace too). Can accept a optional register. vim.keymap.set('n', 'dil', function() vim.cmd(('norm! ^v$h"%sd"_dd'):format(vim.v.register)) end, { silent = true }) -- Previous buffer jump keybind vim.keymap.set('n', '', ':b#', { silent = true }) -- Opens nvdired in a bottom split vim.keymap.set('n', 'd', ':bo split | resize 13 | Dired', { silent = true }) -- Opens nvdired in the current window vim.keymap.set('n', '', ':Dired', { silent = true }) vim.keymap.set('n', 'xb', function() local st = { light = 'dark', dark = 'light' } vim.o.background = st[vim.o.background] end, { silent = true, desc = [[Toggle colorscheme background preference (light/dark)]] }) vim.g.qf_win_open = false vim.keymap.set('n', 'xd', function() if not vim.g.qf_win_open then vim.diagnostic.setqflist { open = false } vim.cmd 'bo copen' else vim.cmd 'cclose' end vim.g.qf_win_open = not vim.g.qf_win_open end, { desc = [[Toggles a quickfix window populated with diagnostics]] }) vim.keymap.set('n', '', function() if vim.b.current_compiler then vim.cmd [[wa | make %]] end end, { silent = true, desc = [[Compile this project (only if b:current_compiler is set)]] }) vim.keymap.set('n', '', function() if vim.b.current_compiler then vim.cmd 'copen' end end, { silent = true, desc = 'Open quickfix window (only if b:current_compiler is set)' }) vim.keymap.set('n', '', 'w', { silent = true, desc = 'CUA binding for :w', }) -- vim: set ts=2 sw=2 et: