fix(plugins): initial plugin configuration fixes

This commit is contained in:
Paul B. Kim 2026-03-06 11:14:30 +09:00
parent 1b65e46834
commit 357dab6e1c
No known key found for this signature in database
5 changed files with 105 additions and 31 deletions

View File

@ -179,6 +179,13 @@ vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- Diagnostic keymaps -- Diagnostic keymaps
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
vim.keymap.set('n', '[d', function()
vim.diagnostic.jump { count = -1, float = true }
end, { desc = 'Go to previous [D]iagnostic' })
vim.keymap.set('n', ']d', function()
vim.diagnostic.jump { count = 1, float = true }
end, { desc = 'Go to next [D]iagnostic' })
vim.keymap.set('n', '<leader>de', vim.diagnostic.open_float, { desc = 'Show [D]iagnostic [E]rror details' })
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which -- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
@ -329,19 +336,6 @@ require('lazy').setup({
-- options to `gitsigns.nvim`. -- options to `gitsigns.nvim`.
-- --
-- See `:help gitsigns` to understand what the configuration keys do -- See `:help gitsigns` to understand what the configuration keys do
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
opts = {
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
},
},
},
-- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- NOTE: Plugins can also be configured to run Lua code when they are loaded.
-- --
-- This is often very useful to both group configuration, as well as handle -- This is often very useful to both group configuration, as well as handle
@ -402,8 +396,14 @@ require('lazy').setup({
-- Document existing key chains -- Document existing key chains
spec = { spec = {
{ '<leader>a', group = 'Harpoon [A]dd' },
{ '<leader>d', group = '[D]iagnostics' },
{ '<leader>g', group = '[G]it' },
{ '<leader>m', group = '[M]arkdown' },
{ '<leader>o', group = '[O]pencode' },
{ '<leader>s', group = '[S]earch' }, { '<leader>s', group = '[S]earch' },
{ '<leader>t', group = '[T]oggle' }, { '<leader>t', group = '[T]oggle' },
{ '<leader>w', group = '[W]indow' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } }, { '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
}, },
}, },
@ -701,14 +701,15 @@ require('lazy').setup({
virtual_text = { virtual_text = {
source = 'if_many', source = 'if_many',
spacing = 2, spacing = 2,
severity = { min = vim.diagnostic.severity.WARN },
format = function(diagnostic) format = function(diagnostic)
local diagnostic_message = { if diagnostic.severity == vim.diagnostic.severity.WARN then
[vim.diagnostic.severity.ERROR] = diagnostic.message, return 'W: ' .. diagnostic.message
[vim.diagnostic.severity.WARN] = diagnostic.message, end
[vim.diagnostic.severity.INFO] = diagnostic.message, if diagnostic.severity == vim.diagnostic.severity.ERROR then
[vim.diagnostic.severity.HINT] = diagnostic.message, return 'E: ' .. diagnostic.message
} end
return diagnostic_message[diagnostic.severity] return nil
end, end,
}, },
} }

View File

@ -6,6 +6,13 @@ return {
{ {
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
opts = { opts = {
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
},
on_attach = function(bufnr) on_attach = function(bufnr)
local gitsigns = require 'gitsigns' local gitsigns = require 'gitsigns'
@ -44,7 +51,7 @@ return {
map('n', '<leader>hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) map('n', '<leader>hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' })
map('n', '<leader>hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) map('n', '<leader>hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' })
map('n', '<leader>hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) map('n', '<leader>hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' })
map('n', '<leader>hu', gitsigns.stage_hunk, { desc = 'git [u]ndo stage hunk' }) map('n', '<leader>hu', gitsigns.undo_stage_hunk, { desc = 'git [u]ndo stage hunk' })
map('n', '<leader>hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) map('n', '<leader>hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' })
map('n', '<leader>hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) map('n', '<leader>hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' })
map('n', '<leader>hb', gitsigns.blame_line, { desc = 'git [b]lame line' }) map('n', '<leader>hb', gitsigns.blame_line, { desc = 'git [b]lame line' })
@ -54,7 +61,7 @@ return {
end, { desc = 'git [D]iff against last commit' }) end, { desc = 'git [D]iff against last commit' })
-- Toggles -- Toggles
map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' })
map('n', '<leader>tD', gitsigns.preview_hunk_inline, { desc = '[T]oggle git show [D]eleted' }) map('n', '<leader>tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' })
end, end,
}, },
}, },

View File

@ -0,0 +1,48 @@
return {
'folke/persistence.nvim',
event = 'BufReadPre',
opts = {
options = { 'buffers', 'curdir', 'tabpages', 'winsize', 'help', 'globals' },
},
keys = {
{
'<leader>wr',
function()
require('persistence').load()
end,
desc = '[W]orkspace [R]estore session',
},
{
'<leader>wl',
function()
require('persistence').load { last = true }
end,
desc = '[W]orkspace [L]ast session',
},
{
'<leader>wd',
function()
require('persistence').stop()
end,
desc = '[W]orkspace [D]isable session save',
},
},
init = function()
vim.api.nvim_create_autocmd('VimEnter', {
group = vim.api.nvim_create_augroup('persistence-auto-restore', { clear = true }),
callback = function()
if vim.fn.argc(-1) > 0 then
return
end
local ignored = { gitcommit = true, gitrebase = true }
if ignored[vim.bo.filetype] then
return
end
require('persistence').load()
end,
nested = true,
})
end,
}

View File

@ -1,5 +1,6 @@
return { return {
'supermaven-inc/supermaven-nvim', 'supermaven-inc/supermaven-nvim',
event = 'InsertEnter',
config = function() config = function()
require('supermaven-nvim').setup { require('supermaven-nvim').setup {
keymaps = { keymaps = {
@ -12,7 +13,7 @@ return {
suggestion_color = '#ffffff', suggestion_color = '#ffffff',
cterm = 244, cterm = 244,
}, },
log_level = 'info', -- set to "off" to disable logging completely log_level = 'off',
disable_inline_completion = false, -- disables inline completion for use with cmp disable_inline_completion = false, -- disables inline completion for use with cmp
disable_keymaps = false, -- disables built in keymaps for more manual control disable_keymaps = false, -- disables built in keymaps for more manual control
condition = function() return false end, -- condition to check for stopping supermaven, `true` means to stop supermaven when the condition is true. condition = function() return false end, -- condition to check for stopping supermaven, `true` means to stop supermaven when the condition is true.

View File

@ -3,6 +3,8 @@ local M = {}
local defaults = { local defaults = {
width = 100, width = 100,
patterns = { '*.md', '*.markdown' }, patterns = { '*.md', '*.markdown' },
max_lines = 5000,
max_bytes = 1024 * 1024,
} }
local function apply_wrap_options(local_opts, width) local function apply_wrap_options(local_opts, width)
@ -16,12 +18,28 @@ local function apply_wrap_options(local_opts, width)
local_opts.formatoptions:remove 'l' local_opts.formatoptions:remove 'l'
end end
local function can_reflow(bufnr) local function can_reflow(bufnr, opts)
return vim.api.nvim_buf_is_valid(bufnr) and vim.bo[bufnr].modifiable and vim.bo[bufnr].buftype == '' if not vim.api.nvim_buf_is_valid(bufnr) or not vim.bo[bufnr].modifiable or vim.bo[bufnr].buftype ~= '' then
return false
end
if opts.max_lines and vim.api.nvim_buf_line_count(bufnr) > opts.max_lines then
return false
end
local name = vim.api.nvim_buf_get_name(bufnr)
if name ~= '' and opts.max_bytes then
local stat = (vim.uv or vim.loop).fs_stat(name)
if stat and stat.size and stat.size > opts.max_bytes then
return false
end
end
return true
end end
local function reflow_whole_buffer(bufnr, preserve_view) local function reflow_whole_buffer(bufnr, preserve_view, opts)
if not can_reflow(bufnr) then if not can_reflow(bufnr, opts) then
return return
end end
@ -37,12 +55,11 @@ end
function M.setup(opts) function M.setup(opts)
opts = vim.tbl_deep_extend('force', defaults, opts or {}) opts = vim.tbl_deep_extend('force', defaults, opts or {})
apply_wrap_options(vim.opt, opts.width)
local group = vim.api.nvim_create_augroup('custom_wrapping_rules', { clear = true }) local group = vim.api.nvim_create_augroup('custom_wrapping_rules', { clear = true })
vim.api.nvim_create_autocmd('FileType', { vim.api.nvim_create_autocmd('FileType', {
group = group, group = group,
pattern = 'markdown',
callback = function() callback = function()
-- Apply after ftplugins so local overrides don't drop wrap options. -- Apply after ftplugins so local overrides don't drop wrap options.
vim.schedule(function() vim.schedule(function()
@ -61,7 +78,7 @@ function M.setup(opts)
end end
vim.b[args.buf].did_initial_wrap = true vim.b[args.buf].did_initial_wrap = true
vim.schedule(function() vim.schedule(function()
reflow_whole_buffer(args.buf, false) reflow_whole_buffer(args.buf, false, opts)
end) end)
end, end,
}) })
@ -73,7 +90,7 @@ function M.setup(opts)
if not vim.bo[args.buf].modified then if not vim.bo[args.buf].modified then
return return
end end
reflow_whole_buffer(args.buf, true) reflow_whole_buffer(args.buf, true, opts)
end, end,
}) })
end end