chore(nvim): tweaks and fixes

This commit is contained in:
2024-12-09 13:00:45 +02:00
parent f3f7ecc522
commit 0964253be5
3 changed files with 38 additions and 18 deletions

View File

@@ -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',
})

View File

@@ -89,7 +89,9 @@ n('<down>', ':echo "Use j to move!!"<CR>')
n('<C-s>', ':w!<cr>', { desc = 'Save', noremap = true })
n('<esc><esc>', ':nohlsearch<cr>', { 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()<CR>', 'Delete')
nld('bh', ':bprev<cr>', 'Prev')
nld('bj', ':bfirst<cr>', 'First')
@@ -120,7 +122,9 @@ ld('cu', 'n', ':Lspsaga preview_definition<cr>', 'Preview Definition')
ld('cv', 'n', ':Lspsaga diagnostic_jump_prev<cr>', 'Diagnostic Jump Prev')
ld('cw', 'n', ':Lspsaga diagnostic_jump_next<cr>', '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', '<Cmd>CBccbox<CR>', 'CB: Box Title')
nld('cbd', '<Cmd>CBd<CR>', 'CB: Remove a box')
nld('cbl', '<Cmd>CBline<CR>', 'CB: Simple Line')
@@ -175,13 +179,13 @@ d('<C-j>', { 'n', 'v' }, ":m '>+1<CR>gv=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<cr>', 'Cloak: Toggle')
nld('te', ':Neotree toggle<cr>', 'Toggle Neotree')
nld(
'tl',
':lua vim.o.bg = vim.o.bg:get() == "light" and "dark" or "light"<cr>',
'Toggle Light/Dark Mode'
)
nld('tl', toggle_background, 'Toggle Light/Dark Mode')
nld('tn', ':Noice dismiss<cr>', 'Noice: Dismiss Notification')
-- Splits
@@ -201,6 +205,14 @@ n('j',
-- Quit
nld('qf', ':q<CR>', 'Quicker close split')
nld('qq', ':wq!<CR>', '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<CR>', 'Write and quit')
nld('qQ', ':q!<CR>', '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')

View File

@@ -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,