diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 2112376..a6d44e7 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -1,5 +1,5 @@ require('DarthMooMancer.opts') require('DarthMooMancer.plugins') require('DarthMooMancer.keymaps') -require('DarthMooMancer.ui') +require('DarthMooMancer.statusline') require('DarthMooMancer.lsp') diff --git a/nvim/.config/nvim/lua/DarthMooMancer/keymaps.lua b/nvim/.config/nvim/lua/DarthMooMancer/keymaps.lua index 8b084f1..8d99c39 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/keymaps.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/keymaps.lua @@ -1,7 +1,7 @@ vim.keymap.set('v', 'J', ":m '>+1gv=gv") vim.keymap.set('v', 'K', ":m '<-2gv=gv") vim.keymap.set('n', 'ff', function() - require('conform').format({ async = true, lsp_format = 'never' }) + require('conform').format({ async = true, lsp_format = 'never' }) end) vim.keymap.set('n', 'vs', ':vsplit') vim.keymap.set('n', 'ss', ':split') @@ -11,37 +11,25 @@ vim.keymap.set('n', '', 'zz') vim.keymap.set('n', 'n', 'nzzzv') vim.keymap.set('n', 'N', 'Nzzzv') vim.keymap.set('x', 'p', [["_dP]]) -vim.keymap.set( - 'n', - '', - function() Snacks.picker.files() end -) -vim.keymap.set( - 'n', - 'fh', - function() Snacks.picker.help() end -) -vim.keymap.set( - 'n', - 'fg', - function() Snacks.picker.grep() end -) -vim.keymap.set( - 'n', - 'fm', - function() Snacks.picker.man() end -) -vim.keymap.set( - 'n', - 'xn', - function() Snacks.picker.notifications() end -) +vim.keymap.set('n', '', function() + Snacks.picker.files() +end) +vim.keymap.set('n', 'fh', function() + Snacks.picker.help() +end) +vim.keymap.set('n', 'fg', function() + Snacks.picker.grep() +end) +vim.keymap.set('n', 'fm', function() + Snacks.picker.man() +end) +vim.keymap.set('n', 'xn', function() + Snacks.picker.notifications() +end) -vim.keymap.set( - 'n', - 'uu', - function() Snacks.picker.undo() end -) +vim.keymap.set('n', 'uu', function() + Snacks.picker.undo() +end) vim.keymap.set('n', 'fs', vim.lsp.buf.document_symbol) vim.keymap.set('n', 'gd', vim.lsp.buf.definition) @@ -60,4 +48,7 @@ vim.keymap.set('n', '', ':NvimTmuxNavigateDown', { silent = true }) vim.keymap.set('n', '', ':NvimTmuxNavigateUp', { silent = true }) vim.keymap.set('n', '', ':NvimTmuxNavigateRight', { silent = true }) vim.keymap.set('n', 'xx', ':Trouble diagnostics toggle') -vim.keymap.set('n', 'zz', function() Snacks.zen() end) +vim.keymap.set('n', 'zz', function() + Snacks.zen() +end) +vim.keymap.set('n', 'mp', ':Vellum', { desc = 'Markdown preview' }) diff --git a/nvim/.config/nvim/lua/DarthMooMancer/opts.lua b/nvim/.config/nvim/lua/DarthMooMancer/opts.lua index d361334..44ed10b 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/opts.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/opts.lua @@ -35,17 +35,13 @@ vim.opt.scrolloff = 4 vim.opt.sidescrolloff = 8 vim.opt.hlsearch = false 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.cursorline = true -- enable cursorline vim.opt.cursorlineopt = { 'screenline', 'number' } -- cursorline look vim.opt.foldmethod = 'indent' vim.opt.foldcolumn = '1' 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.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 @@ -76,3 +72,6 @@ vim.api.nvim_create_autocmd('FileType', { vim.keymap.set('n', 'k', 'gk', { buffer = true }) end, }) + +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins.lua index de85cbc..603c700 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/plugins.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins.lua @@ -10,3 +10,4 @@ require('DarthMooMancer.plugins.noice') require('DarthMooMancer.plugins.snacks') require('DarthMooMancer.plugins.trouble') require('DarthMooMancer.plugins.conform') +require('DarthMooMancer.plugins.vellum') diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/blink-cmp.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/blink-cmp.lua index 008a975..0b7b784 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/plugins/blink-cmp.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/blink-cmp.lua @@ -1,30 +1,29 @@ vim.pack.add({ - { - src = 'https://github.com/saghen/blink.cmp', - version = vim.version.range('*'), - } + { + src = 'https://github.com/saghen/blink.cmp', + version = vim.version.range('*'), + }, }) require('blink.cmp').setup({ - completion = { - documentation = { - auto_show = true, - auto_show_delay_ms = 100, - window = { - winhighlight = 'Normal:NormalFloat,FloatBorder:SnacksPickerBorder,CursorLine:Visual,Search:None', - }, - }, - menu = { - draw = { - columns = { - { "label", "label_description", gap = 1 }, - { "kind_icon", "kind", gap = 1 }, - { "source_name", gap = 1 }, - }, - }, - scrollbar = false, - winhighlight = - 'Pmenu:NormalFloat,FloatBorder:SnacksPickerBorder,PmenuSel:Visual,CursorLine:Visual,Search:None', - }, - }, + completion = { + documentation = { + auto_show = true, + auto_show_delay_ms = 100, + window = { + winhighlight = 'Normal:NormalFloat,FloatBorder:SnacksPickerBorder,CursorLine:Visual,Search:None', + }, + }, + menu = { + draw = { + columns = { + { 'label', 'label_description', gap = 1 }, + { 'kind_icon', 'kind', gap = 1 }, + { 'source_name', gap = 1 }, + }, + }, + scrollbar = false, + winhighlight = 'Pmenu:NormalFloat,FloatBorder:SnacksPickerBorder,PmenuSel:Visual,CursorLine:Visual,Search:None', + }, + }, }) diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/incline.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/incline.lua index 04fa131..eca1e16 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/plugins/incline.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/incline.lua @@ -1,6 +1,6 @@ vim.pack.add({ - { src = 'https://github.com/b0o/incline.nvim' }, - { src = 'https://github.com/SmiteshP/nvim-navic' }, + { src = 'https://github.com/b0o/incline.nvim' }, + { src = 'https://github.com/SmiteshP/nvim-navic' }, }) local helpers = require('incline.helpers') @@ -8,43 +8,50 @@ local navic = require('nvim-navic') local devicons = require('nvim-web-devicons') vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('UserNavicAttach', { clear = true }), - callback = function(args) - local client = vim.lsp.get_client_by_id(args.data.client_id) - if client and client.server_capabilities.documentSymbolProvider then - navic.attach(client, args.buf) - end - end, + group = vim.api.nvim_create_augroup('UserNavicAttach', { clear = true }), + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client and client.server_capabilities.documentSymbolProvider then + navic.attach(client, args.buf) + end + end, }) require('incline').setup({ - window = { - padding = 0, - margin = { horizontal = 0, vertical = 0 }, - }, - render = function(props) - local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ':t') - if filename == '' then - filename = '[No Name]' - end - local ft_icon, ft_color = devicons.get_icon_color(filename) - local modified = vim.bo[props.buf].modified - local res = { - ft_icon and { ' ', ft_icon, ' ', guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or '', - ' ', - { filename, gui = modified and 'bold,italic' or 'bold' }, - guibg = "none", - } - if props.focused then - for _, item in ipairs(navic.get_data(props.buf) or {}) do - table.insert(res, { - { ' > ', group = 'NavicSeparator' }, - { item.icon, group = 'NavicIcons' .. item.type }, - { item.name, group = 'NavicText' }, - }) - end - end - table.insert(res, ' ') - return res - end, + window = { + padding = 0, + margin = { horizontal = 0, vertical = 0 }, + }, + render = function(props) + local filename = + vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ':t') + if filename == '' then + filename = '[No Name]' + end + local ft_icon, ft_color = devicons.get_icon_color(filename) + local modified = vim.bo[props.buf].modified + local res = { + ft_icon and { + ' ', + ft_icon, + ' ', + guibg = ft_color, + guifg = helpers.contrast_color(ft_color), + } or '', + ' ', + { filename, gui = modified and 'bold,italic' or 'bold' }, + guibg = 'none', + } + if props.focused then + for _, item in ipairs(navic.get_data(props.buf) or {}) do + table.insert(res, { + { ' > ', group = 'NavicSeparator' }, + { item.icon, group = 'NavicIcons' .. item.type }, + { item.name, group = 'NavicText' }, + }) + end + end + table.insert(res, ' ') + return res + end, }) diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/snacks.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/snacks.lua index 223429c..7c83238 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/plugins/snacks.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/snacks.lua @@ -16,8 +16,12 @@ require('snacks').setup({ }, }, - layout = { - preview = false, + sources = { + files = { + layout = { + preview = false, -- This now ONLY applies to Snacks.picker.files() + }, + }, }, }, zen = { diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/vellum.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/vellum.lua new file mode 100644 index 0000000..50ef3fb --- /dev/null +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/vellum.lua @@ -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, +}) diff --git a/nvim/.config/nvim/lua/DarthMooMancer/ui.lua b/nvim/.config/nvim/lua/DarthMooMancer/statusline.lua similarity index 62% rename from nvim/.config/nvim/lua/DarthMooMancer/ui.lua rename to nvim/.config/nvim/lua/DarthMooMancer/statusline.lua index fd0c5dc..3dbb3c0 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/ui.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/statusline.lua @@ -3,31 +3,33 @@ local function derive_hl(name, opts) 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 {} - vim.api.nvim_set_hl(0, name, { - 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, - }) + vim.api.nvim_set_hl( + 0, + name, + { fg = fg.fg or base.fg, bg = bg.bg or base.bg, bold = opts.bold } + ) end local function setup_statusline_highlights() - derive_mode_hl('StatusModeNormal', 'Type') - derive_mode_hl('StatusModeInsert', 'String') - derive_mode_hl('StatusModeVisual', 'Statement') - derive_mode_hl('StatusModeCommand', 'PreProc') - derive_mode_hl('StatusModeReplace', 'WarningMsg') - derive_mode_hl('StatusModeTerminal', 'Special') + local st = vim.api.nvim_get_hl(0, { name = 'StatusLine' }) + for name, link in pairs({ + Normal = 'Type', + Insert = 'String', + Visual = 'Statement', + 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('StatusCursor', { base = 'CursorLine', fg = 'Normal' }) derive_hl( 'StatusLspWorking', { base = 'StatusLine', fg = 'DiagnosticInfo' } @@ -53,69 +55,64 @@ vim.api.nvim_create_autocmd('ColorScheme', { }) setup_statusline_highlights() -local mode_map = { - n = ' NORM ', - i = ' INS ', - v = ' VIS ', - V = ' V-LINE ', - ['\22'] = ' V-BLK ', - ['\19'] = ' V-BLK ', - s = ' VIS ', - S = ' V-LINE ', - R = ' REPL ', - c = ' CMD ', - r = ' PROMPT ', - t = ' TERM ', - ['!'] = ' SHELL ', +local modes = { + n = { ' NORM ', 'StatusModeNormal' }, + i = { ' INS ', 'StatusModeInsert' }, + v = { ' VIS ', 'StatusModeVisual' }, + V = { ' V-LINE ', 'StatusModeVisual' }, + ['\22'] = { ' V-BLK ', 'StatusModeVisual' }, + ['\19'] = { ' V-BLK ', 'StatusModeVisual' }, + s = { ' VIS ', 'StatusModeVisual' }, + S = { ' V-LINE ', 'StatusModeVisual' }, + R = { ' REPL ', 'StatusModeReplace' }, + c = { ' CMD ', 'StatusModeCommand' }, + r = { ' PROMPT ', 'StatusModeCommand' }, + t = { ' TERM ', 'StatusModeTerminal' }, + ['!'] = { ' SHELL ', 'StatusModeCommand' }, } -local mode_hl_map = { - n = 'StatusModeNormal', - i = 'StatusModeInsert', - v = 'StatusModeVisual', - V = 'StatusModeVisual', - ['\22'] = 'StatusModeVisual', - s = 'StatusModeVisual', - S = 'StatusModeVisual', - ['\19'] = 'StatusModeVisual', - R = 'StatusModeReplace', - c = 'StatusModeCommand', - r = 'StatusModeCommand', - ['!'] = 'StatusModeCommand', - t = 'StatusModeTerminal', -} +local mode_statusline = + { default = { '%#StatusModeNormal# ?? %*', 'StatusModeNormal' } } +for k, v in pairs(modes) do + mode_statusline[k] = { '%#' .. v[2] .. '#' .. v[1] .. '%*', v[2] } +end -local mode_statusline = {} -for k, v in pairs(mode_map) do - local hl = mode_hl_map[k] or 'StatusModeNormal' - mode_statusline[k] = '%#' .. hl .. '#' .. v .. '%*' +local redraw_scheduled = false +local function schedule_redraw() + if redraw_scheduled then + return + end + redraw_scheduled = true + vim.schedule(function() + redraw_scheduled = false + vim.cmd.redrawstatus() + end) end -mode_statusline['default'] = '%#StatusModeNormal# ?? %*' local function refresh_status(buf) local b = vim.b[buf] - local left, right = {}, {} + local l, r = '', '' if b.git_branch and b.git_branch ~= '' then - left[#left + 1] = '%#StatusGit# ' .. b.git_branch .. ' %*' + l = l .. '%#StatusGit# ' .. b.git_branch .. ' %*' end - local diff = b.git_diff - if diff then - if diff.added > 0 then - left[#left + 1] = '%#StatusGitAdded# +' .. diff.added .. '%*' + if b.git_diff then + if b.git_diff.added > 0 then + l = l .. '%#StatusGitAdded# +' .. b.git_diff.added .. '%*' end - if diff.removed > 0 then - left[#left + 1] = '%#StatusGitRemoved# -' .. diff.removed .. '%*' + if b.git_diff.removed > 0 then + l = l .. '%#StatusGitRemoved# -' .. b.git_diff.removed .. '%*' end end if b.recording then - right[#right + 1] = '%#StatusRecording# ' .. b.recording .. ' %*' + r = r .. '%#StatusRecording# ' .. b.recording .. ' %*' end if b.diag_str then - right[#right + 1] = b.diag_str + r = r .. b.diag_str end if b.lsp_icon and b.lsp_icon ~= '' then - right[#right + 1] = '%#' + r = r + .. '%#' .. b.lsp_hl .. '#' .. b.lsp_icon @@ -123,61 +120,42 @@ local function refresh_status(buf) .. ' %*' end - local l = #left > 0 and table.concat(left) or '' - 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 + b.status_left, b.status_right = l, r end -local lsp_icon = { - none = '', - starting = '', - working = ' 󰄬 ', - ready = ' 󰄭 ', -} -local lsp_hl = { - none = 'StatusLspNone', - starting = 'StatusLspNone', - working = 'StatusLspWorking', - ready = 'StatusLspReady', +local lsp_states = { + none = { '', 'StatusLspNone' }, + starting = { '', 'StatusLspNone' }, + working = { ' 󰄬 ', 'StatusLspWorking' }, + ready = { ' 󰄭 ', 'StatusLspReady' }, } local active_progress = {} local function refresh_lsp(buf) - local state = 'ready' - local clients = vim.lsp.get_clients({ bufnr = buf }) + local state, clients = 'ready', vim.lsp.get_clients({ bufnr = buf }) if #clients == 0 then - state = 'none' - vim.b[buf].lsp_name = '' + state, vim.b[buf].lsp_name = 'none', '' else local names = {} - for _, client in ipairs(clients) do - names[#names + 1] = client.name - local p = active_progress[client.id] - if p then - if p.is_starting then - if state ~= 'working' then - state = 'starting' - end - elseif next(p.tokens) then - state = 'working' - end + for _, c in ipairs(clients) do + names[#names + 1] = c.name + local p = active_progress[c.id] + if p and p.is_starting and state ~= 'working' then + state = 'starting' + elseif p and next(p.tokens) then + state = 'working' end - vim.b[buf].lsp_name = table.concat(names, '/') end + vim.b[buf].lsp_name = table.concat(names, '/') end if vim.b[buf].lsp_state == state then return end vim.b[buf].lsp_state = state - vim.b[buf].lsp_icon = lsp_icon[state] - vim.b[buf].lsp_hl = lsp_hl[state] + vim.b[buf].lsp_icon, vim.b[buf].lsp_hl = + lsp_states[state][1], lsp_states[state][2] refresh_status(buf) - vim.cmd.redrawstatus() + schedule_redraw() end vim.api.nvim_create_autocmd({ 'LspAttach', 'LspDetach' }, { @@ -237,8 +215,11 @@ vim.api.nvim_create_autocmd('LspProgress', { end local client = vim.lsp.get_client_by_id(ev.data.client_id) if client then - for buf in pairs(client.attached_buffers) do - refresh_lsp(buf) + for _, win in ipairs(vim.api.nvim_list_wins()) do + local buf = vim.api.nvim_win_get_buf(win) + if client.attached_buffers[buf] then + refresh_lsp(buf) + end end end end, @@ -282,7 +263,7 @@ local function refresh_branch(buf) vim.b[buf].git_branch = branch ~= '' and (BRANCH_ICON .. branch) or '' refresh_status(buf) - vim.cmd.redrawstatus() + schedule_redraw() end) ) end @@ -329,37 +310,35 @@ local function refresh_diff(buf, force) end end refresh_status(buf) - vim.cmd.redrawstatus() + schedule_redraw() end) ) end local function refresh_diag(buf) - local count = vim.diagnostic.count(buf) - local sev = vim.diagnostic.severity - local parts = {} - if (count[sev.ERROR] or 0) > 0 then - parts[#parts + 1] = '%#StatusDiagError# E' .. count[sev.ERROR] .. ' %*' - 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 '' + local c, s = vim.diagnostic.count(buf), vim.diagnostic.severity + local e, w, h = c[s.ERROR] or 0, c[s.WARN] or 0, c[s.HINT] or 0 + vim.b[buf].diag_str = (e > 0 and '%#StatusDiagError# E' .. e .. ' %*' or '') + .. (w > 0 and '%#StatusDiagWarn# W' .. w .. ' %*' or '') + .. (h > 0 and '%#StatusDiagHint# H' .. h .. ' %*' or '') refresh_status(buf) - vim.cmd.redrawstatus() + schedule_redraw() end -vim.api.nvim_create_autocmd('DiagnosticChanged', { - callback = function(ev) - refresh_diag(ev.buf) - vim.cmd.redrawstatus() +local grp = vim.api.nvim_create_augroup('StatuslineEvents', { clear = true }) +local current_mode = 'n' + +vim.api.nvim_create_autocmd('ModeChanged', { + group = grp, + pattern = '*:*', + callback = function() + current_mode = vim.api.nvim_get_mode().mode + schedule_redraw() end, }) vim.api.nvim_create_autocmd({ 'BufEnter', 'BufNewFile' }, { + group = grp, callback = function(ev) if vim.bo[ev.buf].buftype == '' then refresh_branch(ev.buf) @@ -369,7 +348,9 @@ vim.api.nvim_create_autocmd({ 'BufEnter', 'BufNewFile' }, { refresh_diag(ev.buf) end, }) + vim.api.nvim_create_autocmd('FocusGained', { + group = grp, callback = function() local buf = vim.api.nvim_get_current_buf() if vim.bo[buf].buftype == '' then @@ -377,31 +358,37 @@ vim.api.nvim_create_autocmd('FocusGained', { end end, }) + vim.api.nvim_create_autocmd('BufWritePost', { + group = grp, callback = function(ev) refresh_diff(ev.buf, true) end, }) -vim.api.nvim_create_autocmd('RecordingEnter', { - pattern = '*', +vim.api.nvim_create_autocmd('DiagnosticChanged', { + group = grp, callback = function(ev) - vim.b[ev.buf].recording = 'Rec @' .. vim.fn.reg_recording() - refresh_status(ev.buf) + refresh_diag(ev.buf) end, }) -vim.api.nvim_create_autocmd('RecordingLeave', { - pattern = '*', +vim.api.nvim_create_autocmd({ 'RecordingEnter', 'RecordingLeave' }, { + group = grp, 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) end, }) function _G.__statusline() - local win_id = vim.g.statusline_winid or vim.api.nvim_get_current_win() - local is_active = win_id == vim.api.nvim_get_current_win() + local current_win = 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 b = vim.b[buf] @@ -413,17 +400,16 @@ function _G.__statusline() .. ' %#StatusLineNC# %l:%-2c ' 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 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_right or '') - .. '%#StatusCursor# %l:%-2c ' - .. '%#' - .. hl + .. '%#StatusCursor# %l:%-2c %#' + .. md[2] .. '# %p%% %*' end diff --git a/nvim/.config/nvim/nvim-pack-lock.json b/nvim/.config/nvim/nvim-pack-lock.json index ff05451..2ce23c5 100644 --- a/nvim/.config/nvim/nvim-pack-lock.json +++ b/nvim/.config/nvim/nvim-pack-lock.json @@ -47,7 +47,7 @@ "src": "https://github.com/MunifTanjim/nui.nvim" }, "nvim-lspconfig": { - "rev": "3e8d598d3b5f8338a41699c436e5fa11d2666cf0", + "rev": "910f0c4d46aa186641518395bc7e6fffb4d23baf", "src": "https://github.com/neovim/nvim-lspconfig" }, "nvim-navic": { @@ -59,7 +59,7 @@ "src": "https://github.com/alexghergh/nvim-tmux-navigation" }, "nvim-treesitter": { - "rev": "910fdf6f49e9dee7e7257c7d11a76b040fdfb9de", + "rev": "e289100ff98969e118c702199d88b764ce9e7fdf", "src": "https://github.com/nvim-treesitter/nvim-treesitter" }, "nvim-ts-autotag": { @@ -81,6 +81,10 @@ "trouble.nvim": { "rev": "bd67efe408d4816e25e8491cc5ad4088e708a69a", "src": "https://github.com/folke/trouble.nvim" + }, + "vellum.nvim": { + "rev": "c9a8665c5d306bf56c6df89896fed8bfaf3110b3", + "src": "https://github.com/blackhat-7/vellum.nvim" } } }