REFACTOR: Updated bar and updated keymaps/options

This commit is contained in:
2026-10-05 21:44:48 -04:00
parent 75e4e77dba
commit 5e8d29a82b
10 changed files with 253 additions and 246 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
require('DarthMooMancer.opts') require('DarthMooMancer.opts')
require('DarthMooMancer.plugins') require('DarthMooMancer.plugins')
require('DarthMooMancer.keymaps') require('DarthMooMancer.keymaps')
require('DarthMooMancer.ui') require('DarthMooMancer.statusline')
require('DarthMooMancer.lsp') require('DarthMooMancer.lsp')
@@ -1,7 +1,7 @@
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv") vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv")
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv") vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv")
vim.keymap.set('n', '<leader>ff', function() vim.keymap.set('n', '<leader>ff', function()
require('conform').format({ async = true, lsp_format = 'never' }) require('conform').format({ async = true, lsp_format = 'never' })
end) end)
vim.keymap.set('n', '<leader>vs', ':vsplit<CR>') vim.keymap.set('n', '<leader>vs', ':vsplit<CR>')
vim.keymap.set('n', '<leader>ss', ':split<CR>') vim.keymap.set('n', '<leader>ss', ':split<CR>')
@@ -11,37 +11,25 @@ vim.keymap.set('n', '<C-d>', '<C-d>zz')
vim.keymap.set('n', 'n', 'nzzzv') vim.keymap.set('n', 'n', 'nzzzv')
vim.keymap.set('n', 'N', 'Nzzzv') vim.keymap.set('n', 'N', 'Nzzzv')
vim.keymap.set('x', '<leader>p', [["_dP]]) vim.keymap.set('x', '<leader>p', [["_dP]])
vim.keymap.set( vim.keymap.set('n', '<leader><leader>', function()
'n', Snacks.picker.files()
'<leader><leader>', end)
function() Snacks.picker.files() end vim.keymap.set('n', '<leader>fh', function()
) Snacks.picker.help()
vim.keymap.set( end)
'n', vim.keymap.set('n', '<leader>fg', function()
'<leader>fh', Snacks.picker.grep()
function() Snacks.picker.help() end end)
) vim.keymap.set('n', '<leader>fm', function()
vim.keymap.set( Snacks.picker.man()
'n', end)
'<leader>fg', vim.keymap.set('n', '<leader>xn', function()
function() Snacks.picker.grep() end Snacks.picker.notifications()
) end)
vim.keymap.set(
'n',
'<leader>fm',
function() Snacks.picker.man() end
)
vim.keymap.set(
'n',
'<leader>xn',
function() Snacks.picker.notifications() end
)
vim.keymap.set( vim.keymap.set('n', '<leader>uu', function()
'n', Snacks.picker.undo()
'<leader>uu', end)
function() Snacks.picker.undo() end
)
vim.keymap.set('n', '<leader>fs', vim.lsp.buf.document_symbol) vim.keymap.set('n', '<leader>fs', vim.lsp.buf.document_symbol)
vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition) vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition)
@@ -60,4 +48,7 @@ vim.keymap.set('n', '<C-j>', ':NvimTmuxNavigateDown<CR>', { silent = true })
vim.keymap.set('n', '<C-k>', ':NvimTmuxNavigateUp<CR>', { silent = true }) vim.keymap.set('n', '<C-k>', ':NvimTmuxNavigateUp<CR>', { silent = true })
vim.keymap.set('n', '<C-l>', ':NvimTmuxNavigateRight<CR>', { silent = true }) vim.keymap.set('n', '<C-l>', ':NvimTmuxNavigateRight<CR>', { silent = true })
vim.keymap.set('n', '<leader>xx', ':Trouble diagnostics toggle<cr>') vim.keymap.set('n', '<leader>xx', ':Trouble diagnostics toggle<cr>')
vim.keymap.set('n', '<leader>zz', function() Snacks.zen() end) vim.keymap.set('n', '<leader>zz', function()
Snacks.zen()
end)
vim.keymap.set('n', '<leader>mp', ':Vellum<cr>', { desc = 'Markdown preview' })
@@ -35,17 +35,13 @@ vim.opt.scrolloff = 4
vim.opt.sidescrolloff = 8 vim.opt.sidescrolloff = 8
vim.opt.hlsearch = false vim.opt.hlsearch = false
vim.opt.completeopt = { 'menuone', 'noselect', 'popup' } vim.opt.completeopt = { 'menuone', 'noselect', 'popup' }
vim.g.netrw_browse_split = 0
vim.g.netrw_banner = 0
vim.g.netrw_liststyle = 3
vim.g.netrw_winsize = 25
vim.opt.wrapscan = true -- begin search from top of the file when nothng is found vim.opt.wrapscan = true -- begin search from top of the file when nothng is found
vim.opt.cursorline = true -- enable cursorline vim.opt.cursorline = true -- enable cursorline
vim.opt.cursorlineopt = { 'screenline', 'number' } -- cursorline look vim.opt.cursorlineopt = { 'screenline', 'number' } -- cursorline look
vim.opt.foldmethod = 'indent' vim.opt.foldmethod = 'indent'
vim.opt.foldcolumn = '1' vim.opt.foldcolumn = '1'
vim.opt.foldenable = false vim.opt.foldenable = false
vim.opt.shortmess = 'aF' -- abbreviates messages and prevents file name being echoed when opened vim.opt.shortmess = 'aFI' -- abbreviates messages and prevents file name being echoed when opened
vim.opt.ignorecase = false -- ignore cases when searching vim.opt.ignorecase = false -- ignore cases when searching
vim.opt.smartcase = true -- However if we use a capital in search string we then consider case-sensitivity, ignorecase is disabled vim.opt.smartcase = true -- However if we use a capital in search string we then consider case-sensitivity, ignorecase is disabled
vim.opt.smartindent = false -- smarter indentation vim.opt.smartindent = false -- smarter indentation
@@ -76,3 +72,6 @@ vim.api.nvim_create_autocmd('FileType', {
vim.keymap.set('n', 'k', 'gk', { buffer = true }) vim.keymap.set('n', 'k', 'gk', { buffer = true })
end, end,
}) })
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
@@ -10,3 +10,4 @@ require('DarthMooMancer.plugins.noice')
require('DarthMooMancer.plugins.snacks') require('DarthMooMancer.plugins.snacks')
require('DarthMooMancer.plugins.trouble') require('DarthMooMancer.plugins.trouble')
require('DarthMooMancer.plugins.conform') require('DarthMooMancer.plugins.conform')
require('DarthMooMancer.plugins.vellum')
@@ -1,30 +1,29 @@
vim.pack.add({ vim.pack.add({
{ {
src = 'https://github.com/saghen/blink.cmp', src = 'https://github.com/saghen/blink.cmp',
version = vim.version.range('*'), version = vim.version.range('*'),
} },
}) })
require('blink.cmp').setup({ require('blink.cmp').setup({
completion = { completion = {
documentation = { documentation = {
auto_show = true, auto_show = true,
auto_show_delay_ms = 100, auto_show_delay_ms = 100,
window = { window = {
winhighlight = 'Normal:NormalFloat,FloatBorder:SnacksPickerBorder,CursorLine:Visual,Search:None', winhighlight = 'Normal:NormalFloat,FloatBorder:SnacksPickerBorder,CursorLine:Visual,Search:None',
}, },
}, },
menu = { menu = {
draw = { draw = {
columns = { columns = {
{ "label", "label_description", gap = 1 }, { 'label', 'label_description', gap = 1 },
{ "kind_icon", "kind", gap = 1 }, { 'kind_icon', 'kind', gap = 1 },
{ "source_name", gap = 1 }, { 'source_name', gap = 1 },
}, },
}, },
scrollbar = false, scrollbar = false,
winhighlight = winhighlight = 'Pmenu:NormalFloat,FloatBorder:SnacksPickerBorder,PmenuSel:Visual,CursorLine:Visual,Search:None',
'Pmenu:NormalFloat,FloatBorder:SnacksPickerBorder,PmenuSel:Visual,CursorLine:Visual,Search:None', },
}, },
},
}) })
@@ -1,6 +1,6 @@
vim.pack.add({ vim.pack.add({
{ src = 'https://github.com/b0o/incline.nvim' }, { src = 'https://github.com/b0o/incline.nvim' },
{ src = 'https://github.com/SmiteshP/nvim-navic' }, { src = 'https://github.com/SmiteshP/nvim-navic' },
}) })
local helpers = require('incline.helpers') local helpers = require('incline.helpers')
@@ -8,43 +8,50 @@ local navic = require('nvim-navic')
local devicons = require('nvim-web-devicons') local devicons = require('nvim-web-devicons')
vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserNavicAttach', { clear = true }), group = vim.api.nvim_create_augroup('UserNavicAttach', { clear = true }),
callback = function(args) callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id) local client = vim.lsp.get_client_by_id(args.data.client_id)
if client and client.server_capabilities.documentSymbolProvider then if client and client.server_capabilities.documentSymbolProvider then
navic.attach(client, args.buf) navic.attach(client, args.buf)
end end
end, end,
}) })
require('incline').setup({ require('incline').setup({
window = { window = {
padding = 0, padding = 0,
margin = { horizontal = 0, vertical = 0 }, margin = { horizontal = 0, vertical = 0 },
}, },
render = function(props) render = function(props)
local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ':t') local filename =
if filename == '' then vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ':t')
filename = '[No Name]' if filename == '' then
end filename = '[No Name]'
local ft_icon, ft_color = devicons.get_icon_color(filename) end
local modified = vim.bo[props.buf].modified local ft_icon, ft_color = devicons.get_icon_color(filename)
local res = { local modified = vim.bo[props.buf].modified
ft_icon and { ' ', ft_icon, ' ', guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or '', local res = {
' ', ft_icon and {
{ filename, gui = modified and 'bold,italic' or 'bold' }, ' ',
guibg = "none", ft_icon,
} ' ',
if props.focused then guibg = ft_color,
for _, item in ipairs(navic.get_data(props.buf) or {}) do guifg = helpers.contrast_color(ft_color),
table.insert(res, { } or '',
{ ' > ', group = 'NavicSeparator' }, ' ',
{ item.icon, group = 'NavicIcons' .. item.type }, { filename, gui = modified and 'bold,italic' or 'bold' },
{ item.name, group = 'NavicText' }, guibg = 'none',
}) }
end if props.focused then
end for _, item in ipairs(navic.get_data(props.buf) or {}) do
table.insert(res, ' ') table.insert(res, {
return res { ' > ', group = 'NavicSeparator' },
end, { item.icon, group = 'NavicIcons' .. item.type },
{ item.name, group = 'NavicText' },
})
end
end
table.insert(res, ' ')
return res
end,
}) })
@@ -16,8 +16,12 @@ require('snacks').setup({
}, },
}, },
layout = { sources = {
preview = false, files = {
layout = {
preview = false, -- This now ONLY applies to Snacks.picker.files()
},
},
}, },
}, },
zen = { zen = {
@@ -0,0 +1,16 @@
vim.pack.add({
{
src = 'https://github.com/blackhat-7/vellum.nvim',
},
})
vim.api.nvim_create_autocmd('FileType', {
pattern = 'markdown',
once = true,
callback = function()
local ok, vellum = pcall(require, 'vellum')
if ok then
vellum.setup({})
end
end,
})
@@ -3,31 +3,33 @@ local function derive_hl(name, opts)
or {} or {}
local fg = opts.fg and vim.api.nvim_get_hl(0, { name = opts.fg }) or {} local fg = opts.fg and vim.api.nvim_get_hl(0, { name = opts.fg }) or {}
local bg = opts.bg and vim.api.nvim_get_hl(0, { name = opts.bg }) or {} local bg = opts.bg and vim.api.nvim_get_hl(0, { name = opts.bg }) or {}
vim.api.nvim_set_hl(0, name, { vim.api.nvim_set_hl(
fg = fg.fg or base.fg, 0,
bg = bg.bg or base.bg, name,
bold = opts.bold, { fg = fg.fg or base.fg, bg = bg.bg or base.bg, bold = opts.bold }
}) )
end
local function derive_mode_hl(name, color_group)
local color = vim.api.nvim_get_hl(0, { name = color_group })
local status_bg = vim.api.nvim_get_hl(0, { name = 'StatusLine' })
vim.api.nvim_set_hl(0, name, {
bg = color.fg,
fg = status_bg.bg or '#191724',
bold = true,
})
end end
local function setup_statusline_highlights() local function setup_statusline_highlights()
derive_mode_hl('StatusModeNormal', 'Type') local st = vim.api.nvim_get_hl(0, { name = 'StatusLine' })
derive_mode_hl('StatusModeInsert', 'String') for name, link in pairs({
derive_mode_hl('StatusModeVisual', 'Statement') Normal = 'Type',
derive_mode_hl('StatusModeCommand', 'PreProc') Insert = 'String',
derive_mode_hl('StatusModeReplace', 'WarningMsg') Visual = 'Statement',
derive_mode_hl('StatusModeTerminal', 'Special') Command = 'PreProc',
Replace = 'WarningMsg',
Terminal = 'Special',
}) do
local c = vim.api.nvim_get_hl(0, { name = link })
vim.api.nvim_set_hl(
0,
'StatusMode' .. name,
{ bg = c.fg, fg = st.bg or '#191724', bold = true }
)
end
derive_hl('StatusGit', { base = 'CursorLine', fg = 'Normal' }) derive_hl('StatusGit', { base = 'CursorLine', fg = 'Normal' })
derive_hl('StatusCursor', { base = 'CursorLine', fg = 'Normal' })
derive_hl( derive_hl(
'StatusLspWorking', 'StatusLspWorking',
{ base = 'StatusLine', fg = 'DiagnosticInfo' } { base = 'StatusLine', fg = 'DiagnosticInfo' }
@@ -53,69 +55,64 @@ vim.api.nvim_create_autocmd('ColorScheme', {
}) })
setup_statusline_highlights() setup_statusline_highlights()
local mode_map = { local modes = {
n = ' NORM ', n = { ' NORM ', 'StatusModeNormal' },
i = ' INS ', i = { ' INS ', 'StatusModeInsert' },
v = ' VIS ', v = { ' VIS ', 'StatusModeVisual' },
V = ' V-LINE ', V = { ' V-LINE ', 'StatusModeVisual' },
['\22'] = ' V-BLK ', ['\22'] = { ' V-BLK ', 'StatusModeVisual' },
['\19'] = ' V-BLK ', ['\19'] = { ' V-BLK ', 'StatusModeVisual' },
s = ' VIS ', s = { ' VIS ', 'StatusModeVisual' },
S = ' V-LINE ', S = { ' V-LINE ', 'StatusModeVisual' },
R = ' REPL ', R = { ' REPL ', 'StatusModeReplace' },
c = ' CMD ', c = { ' CMD ', 'StatusModeCommand' },
r = ' PROMPT ', r = { ' PROMPT ', 'StatusModeCommand' },
t = ' TERM ', t = { ' TERM ', 'StatusModeTerminal' },
['!'] = ' SHELL ', ['!'] = { ' SHELL ', 'StatusModeCommand' },
} }
local mode_hl_map = { local mode_statusline =
n = 'StatusModeNormal', { default = { '%#StatusModeNormal# ?? %*', 'StatusModeNormal' } }
i = 'StatusModeInsert', for k, v in pairs(modes) do
v = 'StatusModeVisual', mode_statusline[k] = { '%#' .. v[2] .. '#' .. v[1] .. '%*', v[2] }
V = 'StatusModeVisual', end
['\22'] = 'StatusModeVisual',
s = 'StatusModeVisual',
S = 'StatusModeVisual',
['\19'] = 'StatusModeVisual',
R = 'StatusModeReplace',
c = 'StatusModeCommand',
r = 'StatusModeCommand',
['!'] = 'StatusModeCommand',
t = 'StatusModeTerminal',
}
local mode_statusline = {} local redraw_scheduled = false
for k, v in pairs(mode_map) do local function schedule_redraw()
local hl = mode_hl_map[k] or 'StatusModeNormal' if redraw_scheduled then
mode_statusline[k] = '%#' .. hl .. '#' .. v .. '%*' return
end
redraw_scheduled = true
vim.schedule(function()
redraw_scheduled = false
vim.cmd.redrawstatus()
end)
end end
mode_statusline['default'] = '%#StatusModeNormal# ?? %*'
local function refresh_status(buf) local function refresh_status(buf)
local b = vim.b[buf] local b = vim.b[buf]
local left, right = {}, {} local l, r = '', ''
if b.git_branch and b.git_branch ~= '' then if b.git_branch and b.git_branch ~= '' then
left[#left + 1] = '%#StatusGit# ' .. b.git_branch .. ' %*' l = l .. '%#StatusGit# ' .. b.git_branch .. ' %*'
end end
local diff = b.git_diff if b.git_diff then
if diff then if b.git_diff.added > 0 then
if diff.added > 0 then l = l .. '%#StatusGitAdded# +' .. b.git_diff.added .. '%*'
left[#left + 1] = '%#StatusGitAdded# +' .. diff.added .. '%*'
end end
if diff.removed > 0 then if b.git_diff.removed > 0 then
left[#left + 1] = '%#StatusGitRemoved# -' .. diff.removed .. '%*' l = l .. '%#StatusGitRemoved# -' .. b.git_diff.removed .. '%*'
end end
end end
if b.recording then if b.recording then
right[#right + 1] = '%#StatusRecording# ' .. b.recording .. ' %*' r = r .. '%#StatusRecording# ' .. b.recording .. ' %*'
end end
if b.diag_str then if b.diag_str then
right[#right + 1] = b.diag_str r = r .. b.diag_str
end end
if b.lsp_icon and b.lsp_icon ~= '' then if b.lsp_icon and b.lsp_icon ~= '' then
right[#right + 1] = '%#' r = r
.. '%#'
.. b.lsp_hl .. b.lsp_hl
.. '#' .. '#'
.. b.lsp_icon .. b.lsp_icon
@@ -123,61 +120,42 @@ local function refresh_status(buf)
.. ' %*' .. ' %*'
end end
local l = #left > 0 and table.concat(left) or '' b.status_left, b.status_right = l, r
local r = #right > 0 and table.concat(right) or ''
if b.status_left ~= l then
b.status_left = l
end
if b.status_right ~= r then
b.status_right = r
end
end end
local lsp_icon = { local lsp_states = {
none = '', none = { '', 'StatusLspNone' },
starting = '', starting = { '', 'StatusLspNone' },
working = ' 󰄬 ', working = { ' 󰄬 ', 'StatusLspWorking' },
ready = ' 󰄭 ', ready = { ' 󰄭 ', 'StatusLspReady' },
}
local lsp_hl = {
none = 'StatusLspNone',
starting = 'StatusLspNone',
working = 'StatusLspWorking',
ready = 'StatusLspReady',
} }
local active_progress = {} local active_progress = {}
local function refresh_lsp(buf) local function refresh_lsp(buf)
local state = 'ready' local state, clients = 'ready', vim.lsp.get_clients({ bufnr = buf })
local clients = vim.lsp.get_clients({ bufnr = buf })
if #clients == 0 then if #clients == 0 then
state = 'none' state, vim.b[buf].lsp_name = 'none', ''
vim.b[buf].lsp_name = ''
else else
local names = {} local names = {}
for _, client in ipairs(clients) do for _, c in ipairs(clients) do
names[#names + 1] = client.name names[#names + 1] = c.name
local p = active_progress[client.id] local p = active_progress[c.id]
if p then if p and p.is_starting and state ~= 'working' then
if p.is_starting then state = 'starting'
if state ~= 'working' then elseif p and next(p.tokens) then
state = 'starting' state = 'working'
end
elseif next(p.tokens) then
state = 'working'
end
end end
vim.b[buf].lsp_name = table.concat(names, '/')
end end
vim.b[buf].lsp_name = table.concat(names, '/')
end end
if vim.b[buf].lsp_state == state then if vim.b[buf].lsp_state == state then
return return
end end
vim.b[buf].lsp_state = state vim.b[buf].lsp_state = state
vim.b[buf].lsp_icon = lsp_icon[state] vim.b[buf].lsp_icon, vim.b[buf].lsp_hl =
vim.b[buf].lsp_hl = lsp_hl[state] lsp_states[state][1], lsp_states[state][2]
refresh_status(buf) refresh_status(buf)
vim.cmd.redrawstatus() schedule_redraw()
end end
vim.api.nvim_create_autocmd({ 'LspAttach', 'LspDetach' }, { vim.api.nvim_create_autocmd({ 'LspAttach', 'LspDetach' }, {
@@ -237,8 +215,11 @@ vim.api.nvim_create_autocmd('LspProgress', {
end end
local client = vim.lsp.get_client_by_id(ev.data.client_id) local client = vim.lsp.get_client_by_id(ev.data.client_id)
if client then if client then
for buf in pairs(client.attached_buffers) do for _, win in ipairs(vim.api.nvim_list_wins()) do
refresh_lsp(buf) local buf = vim.api.nvim_win_get_buf(win)
if client.attached_buffers[buf] then
refresh_lsp(buf)
end
end end
end end
end, end,
@@ -282,7 +263,7 @@ local function refresh_branch(buf)
vim.b[buf].git_branch = branch ~= '' and (BRANCH_ICON .. branch) vim.b[buf].git_branch = branch ~= '' and (BRANCH_ICON .. branch)
or '' or ''
refresh_status(buf) refresh_status(buf)
vim.cmd.redrawstatus() schedule_redraw()
end) end)
) )
end end
@@ -329,37 +310,35 @@ local function refresh_diff(buf, force)
end end
end end
refresh_status(buf) refresh_status(buf)
vim.cmd.redrawstatus() schedule_redraw()
end) end)
) )
end end
local function refresh_diag(buf) local function refresh_diag(buf)
local count = vim.diagnostic.count(buf) local c, s = vim.diagnostic.count(buf), vim.diagnostic.severity
local sev = vim.diagnostic.severity local e, w, h = c[s.ERROR] or 0, c[s.WARN] or 0, c[s.HINT] or 0
local parts = {} vim.b[buf].diag_str = (e > 0 and '%#StatusDiagError# E' .. e .. ' %*' or '')
if (count[sev.ERROR] or 0) > 0 then .. (w > 0 and '%#StatusDiagWarn# W' .. w .. ' %*' or '')
parts[#parts + 1] = '%#StatusDiagError# E' .. count[sev.ERROR] .. ' %*' .. (h > 0 and '%#StatusDiagHint# H' .. h .. ' %*' or '')
end
if (count[sev.WARN] or 0) > 0 then
parts[#parts + 1] = '%#StatusDiagWarn# W' .. count[sev.WARN] .. ' %*'
end
if (count[sev.HINT] or 0) > 0 then
parts[#parts + 1] = '%#StatusDiagHint# H' .. count[sev.HINT] .. ' %*'
end
vim.b[buf].diag_str = #parts > 0 and table.concat(parts) or ''
refresh_status(buf) refresh_status(buf)
vim.cmd.redrawstatus() schedule_redraw()
end end
vim.api.nvim_create_autocmd('DiagnosticChanged', { local grp = vim.api.nvim_create_augroup('StatuslineEvents', { clear = true })
callback = function(ev) local current_mode = 'n'
refresh_diag(ev.buf)
vim.cmd.redrawstatus() vim.api.nvim_create_autocmd('ModeChanged', {
group = grp,
pattern = '*:*',
callback = function()
current_mode = vim.api.nvim_get_mode().mode
schedule_redraw()
end, end,
}) })
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufNewFile' }, { vim.api.nvim_create_autocmd({ 'BufEnter', 'BufNewFile' }, {
group = grp,
callback = function(ev) callback = function(ev)
if vim.bo[ev.buf].buftype == '' then if vim.bo[ev.buf].buftype == '' then
refresh_branch(ev.buf) refresh_branch(ev.buf)
@@ -369,7 +348,9 @@ vim.api.nvim_create_autocmd({ 'BufEnter', 'BufNewFile' }, {
refresh_diag(ev.buf) refresh_diag(ev.buf)
end, end,
}) })
vim.api.nvim_create_autocmd('FocusGained', { vim.api.nvim_create_autocmd('FocusGained', {
group = grp,
callback = function() callback = function()
local buf = vim.api.nvim_get_current_buf() local buf = vim.api.nvim_get_current_buf()
if vim.bo[buf].buftype == '' then if vim.bo[buf].buftype == '' then
@@ -377,31 +358,37 @@ vim.api.nvim_create_autocmd('FocusGained', {
end end
end, end,
}) })
vim.api.nvim_create_autocmd('BufWritePost', { vim.api.nvim_create_autocmd('BufWritePost', {
group = grp,
callback = function(ev) callback = function(ev)
refresh_diff(ev.buf, true) refresh_diff(ev.buf, true)
end, end,
}) })
vim.api.nvim_create_autocmd('RecordingEnter', { vim.api.nvim_create_autocmd('DiagnosticChanged', {
pattern = '*', group = grp,
callback = function(ev) callback = function(ev)
vim.b[ev.buf].recording = 'Rec @' .. vim.fn.reg_recording() refresh_diag(ev.buf)
refresh_status(ev.buf)
end, end,
}) })
vim.api.nvim_create_autocmd('RecordingLeave', { vim.api.nvim_create_autocmd({ 'RecordingEnter', 'RecordingLeave' }, {
pattern = '*', group = grp,
callback = function(ev) callback = function(ev)
vim.b[ev.buf].recording = nil if ev.event == 'RecordingEnter' then
vim.b[ev.buf].recording = 'Rec @' .. vim.fn.reg_recording()
else
vim.b[ev.buf].recording = nil
end
refresh_status(ev.buf) refresh_status(ev.buf)
end, end,
}) })
function _G.__statusline() function _G.__statusline()
local win_id = vim.g.statusline_winid or vim.api.nvim_get_current_win() local current_win = vim.api.nvim_get_current_win()
local is_active = win_id == vim.api.nvim_get_current_win() local win_id = vim.g.statusline_winid or current_win
local is_active = win_id == current_win
local buf = vim.api.nvim_win_get_buf(win_id) local buf = vim.api.nvim_win_get_buf(win_id)
local b = vim.b[buf] local b = vim.b[buf]
@@ -413,17 +400,16 @@ function _G.__statusline()
.. ' %#StatusLineNC# %l:%-2c ' .. ' %#StatusLineNC# %l:%-2c '
end end
local m = vim.api.nvim_get_mode().mode local m = current_mode
local key = (m == '\22' or m == '\19') and m or m:sub(1, 1) local key = (m == '\22' or m == '\19') and m or m:sub(1, 1)
local hl = mode_hl_map[key] or 'StatusModeNormal' local md = mode_statusline[key] or mode_statusline.default
return (mode_statusline[key] or mode_statusline['default']) return md[1]
.. (b.status_left or '') .. (b.status_left or '')
.. '%=' .. '%='
.. (b.status_right or '') .. (b.status_right or '')
.. '%#StatusCursor# %l:%-2c ' .. '%#StatusCursor# %l:%-2c %#'
.. '%#' .. md[2]
.. hl
.. '# %p%% %*' .. '# %p%% %*'
end end
+6 -2
View File
@@ -47,7 +47,7 @@
"src": "https://github.com/MunifTanjim/nui.nvim" "src": "https://github.com/MunifTanjim/nui.nvim"
}, },
"nvim-lspconfig": { "nvim-lspconfig": {
"rev": "3e8d598d3b5f8338a41699c436e5fa11d2666cf0", "rev": "910f0c4d46aa186641518395bc7e6fffb4d23baf",
"src": "https://github.com/neovim/nvim-lspconfig" "src": "https://github.com/neovim/nvim-lspconfig"
}, },
"nvim-navic": { "nvim-navic": {
@@ -59,7 +59,7 @@
"src": "https://github.com/alexghergh/nvim-tmux-navigation" "src": "https://github.com/alexghergh/nvim-tmux-navigation"
}, },
"nvim-treesitter": { "nvim-treesitter": {
"rev": "910fdf6f49e9dee7e7257c7d11a76b040fdfb9de", "rev": "e289100ff98969e118c702199d88b764ce9e7fdf",
"src": "https://github.com/nvim-treesitter/nvim-treesitter" "src": "https://github.com/nvim-treesitter/nvim-treesitter"
}, },
"nvim-ts-autotag": { "nvim-ts-autotag": {
@@ -81,6 +81,10 @@
"trouble.nvim": { "trouble.nvim": {
"rev": "bd67efe408d4816e25e8491cc5ad4088e708a69a", "rev": "bd67efe408d4816e25e8491cc5ad4088e708a69a",
"src": "https://github.com/folke/trouble.nvim" "src": "https://github.com/folke/trouble.nvim"
},
"vellum.nvim": {
"rev": "c9a8665c5d306bf56c6df89896fed8bfaf3110b3",
"src": "https://github.com/blackhat-7/vellum.nvim"
} }
} }
} }