Updated statusbar

This commit is contained in:
2026-10-27 12:28:04 -04:00
parent d750bb2da1
commit 1f58fc6411
7 changed files with 52 additions and 77 deletions
+1
View File
@@ -1,3 +1,4 @@
vim.loader.enable()
require('DarthMooMancer.opts') require('DarthMooMancer.opts')
vim.cmd.colorscheme('min-kanso') vim.cmd.colorscheme('min-kanso')
@@ -4,8 +4,6 @@ require('lazydev').setup({
}, },
}) })
-- local capabilities = require('blink.cmp').get_lsp_capabilities()
vim.lsp.config('*', { capabilities = require('blink.cmp').get_lsp_capabilities() }) vim.lsp.config('*', { capabilities = require('blink.cmp').get_lsp_capabilities() })
vim.lsp.config('lua_ls', { vim.lsp.config('lua_ls', {
settings = { settings = {
@@ -23,9 +21,6 @@ vim.lsp.config('lua_ls', {
workspace = { workspace = {
checkThirdParty = false, checkThirdParty = false,
}, },
-- library = {
-- vim.fn.stdpath('data') .. '/site/pack/dev/opt/vern.nvim',
-- },
didChangeWatchedFiles = { didChangeWatchedFiles = {
dynamicRegistration = false, dynamicRegistration = false,
}, },
@@ -40,15 +40,4 @@ vim.opt.showmode = false
vim.opt.smoothscroll = true vim.opt.smoothscroll = true
vim.diagnostic.config({ severity_sort = true }) vim.diagnostic.config({ severity_sort = true })
vim.o.winborder = 'rounded' vim.o.winborder = 'rounded'
vim.api.nvim_create_autocmd('FileType', {
pattern = { 'text', 'plaintex' },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.linebreak = true
vim.opt_local.breakindent = true
vim.keymap.set('n', 'j', 'gj', { buffer = true })
vim.keymap.set('n', 'k', 'gk', { buffer = true })
end,
})
vim.opt.updatetime = 250 vim.opt.updatetime = 250
@@ -1,6 +1,5 @@
require('conform').setup({ require('conform').setup({
formatters_by_ft = { formatters_by_ft = {
-- rust = { 'rustfmt', lsp_format = 'fallback' },
lua = { 'stylua', lsp_format = 'fallback' }, lua = { 'stylua', lsp_format = 'fallback' },
javascript = { 'prettier', stop_after_first = true }, javascript = { 'prettier', stop_after_first = true },
typescript = { 'prettier', stop_after_first = true }, typescript = { 'prettier', stop_after_first = true },
@@ -8,8 +7,7 @@ require('conform').setup({
html = { 'prettier' }, html = { 'prettier' },
c = { 'clang-format' }, c = { 'clang-format' },
cpp = { 'clang-format' }, cpp = { 'clang-format' },
-- css = { 'csskit' }, python = { 'ruff_fix', 'ruff_format' },
python = { 'autopep8' },
['_'] = { 'trim_whitespace' }, ['_'] = { 'trim_whitespace' },
}, },
format_on_save = { format_on_save = {
@@ -1,4 +1,4 @@
require('nvim-treesitter').install({ local parsers = {
'json', 'json',
'rust', 'rust',
'c', 'c',
@@ -6,11 +6,13 @@ require('nvim-treesitter').install({
'lua', 'lua',
'javascript', 'javascript',
'typescript', 'typescript',
'tsx',
'css', 'css',
'html', 'html',
'python', 'python',
'yaml', 'yaml',
}) }
require('nvim-treesitter').install(parsers)
require('nvim-ts-autotag').setup({ require('nvim-ts-autotag').setup({
opts = { opts = {
@@ -20,22 +22,16 @@ require('nvim-ts-autotag').setup({
}, },
}) })
local group = vim.api.nvim_create_augroup('UserTreesitter', { clear = true })
vim.api.nvim_create_autocmd('FileType', { vim.api.nvim_create_autocmd('FileType', {
pattern = { group = group,
'json', desc = 'Start treesitter highlighting when a parser is installed',
'c', callback = function(ev)
'cpp', local lang = vim.treesitter.language.get_lang(ev.match) or ev.match
'rust', if not vim.treesitter.language.add(lang) then
'lua', return
'typescript', end
'javascript', vim.treesitter.start(ev.buf, lang)
'css',
'html',
'python',
'yaml',
},
callback = function()
vim.treesitter.start()
-- vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end, end,
}) })
@@ -1,5 +1,11 @@
local icon_cache = {} local icon_cache = {}
local diagnostic_configs = {
{ sev = vim.diagnostic.severity.ERROR, label = 'E', hl = 'DiagnosticError' },
{ sev = vim.diagnostic.severity.WARN, label = 'W', hl = 'DiagnosticWarn' },
{ sev = vim.diagnostic.severity.HINT, label = 'H', hl = 'DiagnosticHint' },
}
function _G.Status() function _G.Status()
local win = tonumber(vim.g.statusline_winid) local win = tonumber(vim.g.statusline_winid)
local buf = (win and vim.api.nvim_win_is_valid(win)) and vim.api.nvim_win_get_buf(win) local buf = (win and vim.api.nvim_win_is_valid(win)) and vim.api.nvim_win_get_buf(win)
@@ -10,35 +16,38 @@ function _G.Status()
display_path = '[No Name]' display_path = '[No Name]'
end end
local icon, hl = icon_cache[display_path] local ext = vim.fn.fnamemodify(bufname, ':e')
if ext == '' then
ext = display_path
end
local icon, hl = icon_cache[ext]
if not icon then if not icon then
icon, hl = MiniIcons.get('file', display_path) icon, hl = MiniIcons.get('file', display_path)
icon_cache[display_path] = { icon, hl } icon_cache[ext] = { icon, hl }
else else
icon, hl = icon[1], icon[2] icon, hl = icon[1], icon[2]
end end
local nm = (icon ~= '' and hl ~= '') and ('%#' .. hl .. '#' .. icon .. '%* ' .. display_path) or (' ' .. display_path) local nm = (icon ~= '' and hl ~= '') and ('%#' .. hl .. '#' .. icon .. '%* ' .. display_path)
or (' ' .. display_path)
local dg_parts = {} local counts = vim.diagnostic.count(buf)
if (vim.diagnostic.count(buf)[vim.diagnostic.severity.ERROR] or 0) > 0 then local parts = {}
table.insert(dg_parts, '%#DiagnosticError#E' .. vim.diagnostic.count(buf)[vim.diagnostic.severity.ERROR] .. '%*')
for _, cfg in ipairs(diagnostic_configs) do
local n = counts[cfg.sev]
if n and n > 0 then
parts[#parts + 1] = ('%%#%s#%s%d%%*'):format(cfg.hl, cfg.label, n)
end
end end
if (vim.diagnostic.count(buf)[vim.diagnostic.severity.WARN] or 0) > 0 then local dg = #parts > 0 and (table.concat(parts, ' ') .. ' ') or ''
table.insert(dg_parts, '%#DiagnosticWarn#W' .. vim.diagnostic.count(buf)[vim.diagnostic.severity.WARN] .. '%*')
end
if (vim.diagnostic.count(buf)[vim.diagnostic.severity.HINT] or 0) > 0 then
table.insert(dg_parts, '%#DiagnosticHint#H' .. vim.diagnostic.count(buf)[vim.diagnostic.severity.HINT] .. '%*')
end
local dg = #dg_parts > 0 and (table.concat(dg_parts, ' ') .. ' ') or ''
local clients = vim.lsp.get_clients({ bufnr = buf }) local clients = vim.lsp.get_clients({ bufnr = buf })
local lsp_clients = '' local lsp_clients = ''
if #clients > 0 then if #clients > 0 then
local names = {} local names = vim.tbl_map(function(c)
for i = 1, #clients do return c.name
names[i] = clients[i].name end, clients)
end
lsp_clients = '󰄭 ' .. table.concat(names, '/') .. ' ' lsp_clients = '󰄭 ' .. table.concat(names, '/') .. ' '
end end
@@ -51,25 +60,12 @@ end
vim.opt.statusline = '%!v:lua.Status()' vim.opt.statusline = '%!v:lua.Status()'
local augroup = vim.api.nvim_create_augroup('CustomStatusline', { clear = true }) local augroup = vim.api.nvim_create_augroup('CustomStatusline', { clear = true })
vim.api.nvim_create_autocmd({ vim.api.nvim_create_autocmd(
'DiagnosticChanged', { 'DiagnosticChanged', 'LspAttach', 'LspDetach', 'BufEnter', 'LspProgress' },
'LspAttach', {
'LspDetach', group = augroup,
'BufEnter', callback = function()
'LspProgress', vim.cmd.redrawstatus()
'TextChanged', end,
'TextChangedI', }
}, { )
group = augroup,
callback = function()
vim.cmd.redrawstatus()
end,
})
vim.api.nvim_create_autocmd('BufWipeout', {
group = augroup,
callback = function(args)
local name = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(args.buf), ':.')
icon_cache[name] = nil
end,
})
+1 -1
View File
@@ -1,4 +1,4 @@
column_width = 120 column_width = 100
line_endings = "Unix" line_endings = "Unix"
indent_type = "Tabs" indent_type = "Tabs"
indent_width = 2 indent_width = 2