diff --git a/config/nvim/lua/autogroups.lua b/config/nvim/lua/autogroups.lua index 3dbade9..97697b7 100644 --- a/config/nvim/lua/autogroups.lua +++ b/config/nvim/lua/autogroups.lua @@ -20,7 +20,10 @@ autocmd('TextYankPost', { autocmd({ "BufEnter", "BufWinEnter", "TabEnter" }, { callback = function() local max_line_count = vim.fn.line("$") - vim.opt.numberwidth = #tostring(max_line_count) + 1 + -- Only adjust if the file is large enough to matter + if max_line_count > 99 then + vim.opt.numberwidth = #tostring(max_line_count) + 1 + end end, }) @@ -65,7 +68,7 @@ autocmd('FileType', { -- wrap and check for spell in text filetypes autocmd('FileType', { group = augroup('wrap_spell', { clear = true }), - pattern = { 'text', 'plaintex', 'typst', 'gitcommit', 'markdown' }, + pattern = { 'text', 'plaintex', 'typst', 'gitcommit', 'markdown', 'asciidoc', 'rst', 'tex' }, callback = function() vim.opt_local.wrap = true vim.opt_local.spell = true @@ -82,7 +85,7 @@ autocmd({ 'FileType' }, { -- Set filetype for SSH config directory autocmd({ 'BufRead', 'BufNewFile' }, { desc = 'Set filetype for SSH config directory', - pattern = '*/?.ssh/{config|shared}.d/*', + pattern = { '*/?.ssh/{config|shared}.d/*', '*/?.ssh/config.local', '*/?.ssh/config.work' }, command = 'set filetype=sshconfig', }) diff --git a/config/nvim/lua/keymaps.lua b/config/nvim/lua/keymaps.lua index 33e25f2..f838846 100644 --- a/config/nvim/lua/keymaps.lua +++ b/config/nvim/lua/keymaps.lua @@ -89,7 +89,9 @@ n('', ':echo "Use j to move!!"') n('', ':w!', { desc = 'Save', noremap = true }) n('', ':nohlsearch', { desc = 'Clear Search Highlighting' }) --- Buffer +-- Buffer operations +-- Mappings for buffer management operations like switching, deleting, etc. +-- Convention: All mappings start with 'b' followed by the operation nld('bd', ':lua MiniBufremove.delete()', 'Delete') nld('bh', ':bprev', 'Prev') nld('bj', ':bfirst', 'First') @@ -120,7 +122,9 @@ ld('cu', 'n', ':Lspsaga preview_definition', 'Preview Definition') ld('cv', 'n', ':Lspsaga diagnostic_jump_prev', 'Diagnostic Jump Prev') ld('cw', 'n', ':Lspsaga diagnostic_jump_next', 'Diagnostic Jump Next') --- CommentBox keymaps +-- CommentBox operations +-- Mappings for creating and managing comment boxes +-- Convention: All mappings start with 'cb' followed by the box type nld('cbb', 'CBccbox', 'CB: Box Title') nld('cbd', 'CBd', 'CB: Remove a box') nld('cbl', 'CBline', 'CB: Simple Line') @@ -175,13 +179,13 @@ d('', { 'n', 'v' }, ":m '>+1gv=gv", 'Move Block Down') nld('o', function() require('snacks').gitbrowse() end, 'Open repo in browser') -- Toggle settings +local function toggle_background() + vim.o.bg = vim.o.bg == "light" and "dark" or "light" +end + nld('tc', ':CloakToggle', 'Cloak: Toggle') nld('te', ':Neotree toggle', 'Toggle Neotree') -nld( - 'tl', - ':lua vim.o.bg = vim.o.bg:get() == "light" and "dark" or "light"', - 'Toggle Light/Dark Mode' -) +nld('tl', toggle_background, 'Toggle Light/Dark Mode') nld('tn', ':Noice dismiss', 'Noice: Dismiss Notification') -- Splits @@ -201,6 +205,14 @@ n('j', -- Quit nld('qf', ':q', 'Quicker close split') -nld('qq', ':wq!', 'Quit with force saving') +nld('qq', function() + if vim.fn.confirm("Force save and quit?", "&Yes\n&No", 2) == 1 then + vim.cmd('wq!') + end +end, 'Quit with force saving') nld('qw', ':wq', 'Write and quit') -nld('qQ', ':q!', 'Force quit without saving') +nld('qQ', function() + if vim.fn.confirm("Force quit without saving?", "&Yes\n&No", 2) == 1 then + vim.cmd('q!') + end +end, 'Force quit without saving') diff --git a/config/nvim/lua/plugins/lsp.lua b/config/nvim/lua/plugins/lsp.lua index 67ba541..386dafb 100644 --- a/config/nvim/lua/plugins/lsp.lua +++ b/config/nvim/lua/plugins/lsp.lua @@ -9,6 +9,7 @@ return { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons', }, + ---@type LspsagaConfig opts = { code_action = { show_server_name = true, @@ -29,12 +30,16 @@ return { { 'junnplus/lsp-setup.nvim', dependencies = { - 'neovim/nvim-lspconfig', - { 'williamboman/mason.nvim', cmd = 'Mason', run = ':MasonUpdate' }, - 'williamboman/mason-lspconfig.nvim', - 'folke/neodev.nvim', - 'b0o/schemastore.nvim', - 'saghen/blink.cmp', + { 'neovim/nvim-lspconfig' }, + { + 'williamboman/mason.nvim', + cmd = 'Mason', + run = ':MasonUpdate' + }, + { 'williamboman/mason-lspconfig.nvim' }, + { 'folke/neodev.nvim' }, + { 'b0o/schemastore.nvim' }, + { 'saghen/blink.cmp' }, }, opts = { default_mappings = false,