mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-20 06:55:23 +00:00
chore(nvim): tweaks and fixes
This commit is contained in:
@@ -20,7 +20,10 @@ autocmd('TextYankPost', {
|
|||||||
autocmd({ "BufEnter", "BufWinEnter", "TabEnter" }, {
|
autocmd({ "BufEnter", "BufWinEnter", "TabEnter" }, {
|
||||||
callback = function()
|
callback = function()
|
||||||
local max_line_count = vim.fn.line("$")
|
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,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -65,7 +68,7 @@ autocmd('FileType', {
|
|||||||
-- wrap and check for spell in text filetypes
|
-- wrap and check for spell in text filetypes
|
||||||
autocmd('FileType', {
|
autocmd('FileType', {
|
||||||
group = augroup('wrap_spell', { clear = true }),
|
group = augroup('wrap_spell', { clear = true }),
|
||||||
pattern = { 'text', 'plaintex', 'typst', 'gitcommit', 'markdown' },
|
pattern = { 'text', 'plaintex', 'typst', 'gitcommit', 'markdown', 'asciidoc', 'rst', 'tex' },
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.opt_local.wrap = true
|
vim.opt_local.wrap = true
|
||||||
vim.opt_local.spell = true
|
vim.opt_local.spell = true
|
||||||
@@ -82,7 +85,7 @@ autocmd({ 'FileType' }, {
|
|||||||
-- Set filetype for SSH config directory
|
-- Set filetype for SSH config directory
|
||||||
autocmd({ 'BufRead', 'BufNewFile' }, {
|
autocmd({ 'BufRead', 'BufNewFile' }, {
|
||||||
desc = 'Set filetype for SSH config directory',
|
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',
|
command = 'set filetype=sshconfig',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,9 @@ n('<down>', ':echo "Use j to move!!"<CR>')
|
|||||||
n('<C-s>', ':w!<cr>', { desc = 'Save', noremap = true })
|
n('<C-s>', ':w!<cr>', { desc = 'Save', noremap = true })
|
||||||
n('<esc><esc>', ':nohlsearch<cr>', { desc = 'Clear Search Highlighting' })
|
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('bd', ':lua MiniBufremove.delete()<CR>', 'Delete')
|
||||||
nld('bh', ':bprev<cr>', 'Prev')
|
nld('bh', ':bprev<cr>', 'Prev')
|
||||||
nld('bj', ':bfirst<cr>', 'First')
|
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('cv', 'n', ':Lspsaga diagnostic_jump_prev<cr>', 'Diagnostic Jump Prev')
|
||||||
ld('cw', 'n', ':Lspsaga diagnostic_jump_next<cr>', 'Diagnostic Jump Next')
|
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('cbb', '<Cmd>CBccbox<CR>', 'CB: Box Title')
|
||||||
nld('cbd', '<Cmd>CBd<CR>', 'CB: Remove a box')
|
nld('cbd', '<Cmd>CBd<CR>', 'CB: Remove a box')
|
||||||
nld('cbl', '<Cmd>CBline<CR>', 'CB: Simple Line')
|
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')
|
nld('o', function() require('snacks').gitbrowse() end, 'Open repo in browser')
|
||||||
|
|
||||||
-- Toggle settings
|
-- 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('tc', ':CloakToggle<cr>', 'Cloak: Toggle')
|
||||||
nld('te', ':Neotree toggle<cr>', 'Toggle Neotree')
|
nld('te', ':Neotree toggle<cr>', 'Toggle Neotree')
|
||||||
nld(
|
nld('tl', toggle_background, 'Toggle Light/Dark Mode')
|
||||||
'tl',
|
|
||||||
':lua vim.o.bg = vim.o.bg:get() == "light" and "dark" or "light"<cr>',
|
|
||||||
'Toggle Light/Dark Mode'
|
|
||||||
)
|
|
||||||
nld('tn', ':Noice dismiss<cr>', 'Noice: Dismiss Notification')
|
nld('tn', ':Noice dismiss<cr>', 'Noice: Dismiss Notification')
|
||||||
|
|
||||||
-- Splits
|
-- Splits
|
||||||
@@ -201,6 +205,14 @@ n('j',
|
|||||||
|
|
||||||
-- Quit
|
-- Quit
|
||||||
nld('qf', ':q<CR>', 'Quicker close split')
|
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('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')
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ return {
|
|||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
'nvim-tree/nvim-web-devicons',
|
'nvim-tree/nvim-web-devicons',
|
||||||
},
|
},
|
||||||
|
---@type LspsagaConfig
|
||||||
opts = {
|
opts = {
|
||||||
code_action = {
|
code_action = {
|
||||||
show_server_name = true,
|
show_server_name = true,
|
||||||
@@ -29,12 +30,16 @@ return {
|
|||||||
{
|
{
|
||||||
'junnplus/lsp-setup.nvim',
|
'junnplus/lsp-setup.nvim',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
'neovim/nvim-lspconfig',
|
{ 'neovim/nvim-lspconfig' },
|
||||||
{ 'williamboman/mason.nvim', cmd = 'Mason', run = ':MasonUpdate' },
|
{
|
||||||
'williamboman/mason-lspconfig.nvim',
|
'williamboman/mason.nvim',
|
||||||
'folke/neodev.nvim',
|
cmd = 'Mason',
|
||||||
'b0o/schemastore.nvim',
|
run = ':MasonUpdate'
|
||||||
'saghen/blink.cmp',
|
},
|
||||||
|
{ 'williamboman/mason-lspconfig.nvim' },
|
||||||
|
{ 'folke/neodev.nvim' },
|
||||||
|
{ 'b0o/schemastore.nvim' },
|
||||||
|
{ 'saghen/blink.cmp' },
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
default_mappings = false,
|
default_mappings = false,
|
||||||
|
|||||||
Reference in New Issue
Block a user