REFACTOR: Updated bar and updated keymaps/options
This commit is contained in:
@@ -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')
|
||||||
|
|||||||
@@ -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')
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ 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({
|
||||||
@@ -17,14 +17,13 @@ require('blink.cmp').setup({
|
|||||||
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',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -23,17 +23,24 @@ require('incline').setup({
|
|||||||
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 =
|
||||||
|
vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ':t')
|
||||||
if filename == '' then
|
if filename == '' then
|
||||||
filename = '[No Name]'
|
filename = '[No Name]'
|
||||||
end
|
end
|
||||||
local ft_icon, ft_color = devicons.get_icon_color(filename)
|
local ft_icon, ft_color = devicons.get_icon_color(filename)
|
||||||
local modified = vim.bo[props.buf].modified
|
local modified = vim.bo[props.buf].modified
|
||||||
local res = {
|
local res = {
|
||||||
ft_icon and { ' ', ft_icon, ' ', guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or '',
|
ft_icon and {
|
||||||
|
' ',
|
||||||
|
ft_icon,
|
||||||
|
' ',
|
||||||
|
guibg = ft_color,
|
||||||
|
guifg = helpers.contrast_color(ft_color),
|
||||||
|
} or '',
|
||||||
' ',
|
' ',
|
||||||
{ filename, gui = modified and 'bold,italic' or 'bold' },
|
{ filename, gui = modified and 'bold,italic' or 'bold' },
|
||||||
guibg = "none",
|
guibg = 'none',
|
||||||
}
|
}
|
||||||
if props.focused then
|
if props.focused then
|
||||||
for _, item in ipairs(navic.get_data(props.buf) or {}) do
|
for _, item in ipairs(navic.get_data(props.buf) or {}) do
|
||||||
|
|||||||
@@ -16,8 +16,12 @@ require('snacks').setup({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
sources = {
|
||||||
|
files = {
|
||||||
layout = {
|
layout = {
|
||||||
preview = false,
|
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,
|
||||||
|
})
|
||||||
+122
-136
@@ -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
|
|
||||||
if state ~= 'working' then
|
|
||||||
state = 'starting'
|
state = 'starting'
|
||||||
end
|
elseif p and next(p.tokens) then
|
||||||
elseif next(p.tokens) then
|
|
||||||
state = 'working'
|
state = 'working'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
vim.b[buf].lsp_name = table.concat(names, '/')
|
vim.b[buf].lsp_name = table.concat(names, '/')
|
||||||
end
|
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,10 +215,13 @@ 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
|
||||||
|
local buf = vim.api.nvim_win_get_buf(win)
|
||||||
|
if client.attached_buffers[buf] then
|
||||||
refresh_lsp(buf)
|
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)
|
||||||
|
if ev.event == 'RecordingEnter' then
|
||||||
|
vim.b[ev.buf].recording = 'Rec @' .. vim.fn.reg_recording()
|
||||||
|
else
|
||||||
vim.b[ev.buf].recording = nil
|
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
|
||||||
|
|
||||||
@@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user