diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 7365bd9..9412279 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -1,3 +1,4 @@ +vim.loader.enable() require('DarthMooMancer.opts') vim.cmd.colorscheme('min-kanso') diff --git a/nvim/.config/nvim/lua/DarthMooMancer/lsp.lua b/nvim/.config/nvim/lua/DarthMooMancer/lsp.lua index ae18c94..5d2ee8a 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/lsp.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/lsp.lua @@ -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('lua_ls', { settings = { @@ -23,9 +21,6 @@ vim.lsp.config('lua_ls', { workspace = { checkThirdParty = false, }, - -- library = { - -- vim.fn.stdpath('data') .. '/site/pack/dev/opt/vern.nvim', - -- }, didChangeWatchedFiles = { dynamicRegistration = false, }, diff --git a/nvim/.config/nvim/lua/DarthMooMancer/opts.lua b/nvim/.config/nvim/lua/DarthMooMancer/opts.lua index ac69fda..288f57f 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/opts.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/opts.lua @@ -40,15 +40,4 @@ vim.opt.showmode = false vim.opt.smoothscroll = true vim.diagnostic.config({ severity_sort = true }) 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 diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/conform.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/conform.lua index 805ef23..bbc2796 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/plugins/conform.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/conform.lua @@ -1,6 +1,5 @@ require('conform').setup({ formatters_by_ft = { - -- rust = { 'rustfmt', lsp_format = 'fallback' }, lua = { 'stylua', lsp_format = 'fallback' }, javascript = { 'prettier', stop_after_first = true }, typescript = { 'prettier', stop_after_first = true }, @@ -8,8 +7,7 @@ require('conform').setup({ html = { 'prettier' }, c = { 'clang-format' }, cpp = { 'clang-format' }, - -- css = { 'csskit' }, - python = { 'autopep8' }, + python = { 'ruff_fix', 'ruff_format' }, ['_'] = { 'trim_whitespace' }, }, format_on_save = { diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/treesitter.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/treesitter.lua index ddc98e3..6f96551 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/plugins/treesitter.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/treesitter.lua @@ -1,4 +1,4 @@ -require('nvim-treesitter').install({ +local parsers = { 'json', 'rust', 'c', @@ -6,11 +6,13 @@ require('nvim-treesitter').install({ 'lua', 'javascript', 'typescript', + 'tsx', 'css', 'html', 'python', 'yaml', -}) +} +require('nvim-treesitter').install(parsers) require('nvim-ts-autotag').setup({ 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', { - pattern = { - 'json', - 'c', - 'cpp', - 'rust', - 'lua', - 'typescript', - 'javascript', - 'css', - 'html', - 'python', - 'yaml', - }, - callback = function() - vim.treesitter.start() - -- vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + group = group, + desc = 'Start treesitter highlighting when a parser is installed', + callback = function(ev) + local lang = vim.treesitter.language.get_lang(ev.match) or ev.match + if not vim.treesitter.language.add(lang) then + return + end + vim.treesitter.start(ev.buf, lang) end, }) diff --git a/nvim/.config/nvim/lua/DarthMooMancer/statusline.lua b/nvim/.config/nvim/lua/DarthMooMancer/statusline.lua index bee87a9..a14ea27 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/statusline.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/statusline.lua @@ -1,5 +1,11 @@ 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() 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) @@ -10,35 +16,38 @@ function _G.Status() display_path = '[No Name]' 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 icon, hl = MiniIcons.get('file', display_path) - icon_cache[display_path] = { icon, hl } + icon_cache[ext] = { icon, hl } else icon, hl = icon[1], icon[2] 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 = {} - if (vim.diagnostic.count(buf)[vim.diagnostic.severity.ERROR] or 0) > 0 then - table.insert(dg_parts, '%#DiagnosticError#E' .. vim.diagnostic.count(buf)[vim.diagnostic.severity.ERROR] .. '%*') + local counts = vim.diagnostic.count(buf) + local parts = {} + + 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 - if (vim.diagnostic.count(buf)[vim.diagnostic.severity.WARN] or 0) > 0 then - 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 dg = #parts > 0 and (table.concat(parts, ' ') .. ' ') or '' local clients = vim.lsp.get_clients({ bufnr = buf }) local lsp_clients = '' if #clients > 0 then - local names = {} - for i = 1, #clients do - names[i] = clients[i].name - end + local names = vim.tbl_map(function(c) + return c.name + end, clients) lsp_clients = '󰄭 ' .. table.concat(names, '/') .. ' ' end @@ -51,25 +60,12 @@ end vim.opt.statusline = '%!v:lua.Status()' local augroup = vim.api.nvim_create_augroup('CustomStatusline', { clear = true }) -vim.api.nvim_create_autocmd({ - 'DiagnosticChanged', - 'LspAttach', - 'LspDetach', - 'BufEnter', - 'LspProgress', - 'TextChanged', - '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, -}) +vim.api.nvim_create_autocmd( + { 'DiagnosticChanged', 'LspAttach', 'LspDetach', 'BufEnter', 'LspProgress' }, + { + group = augroup, + callback = function() + vim.cmd.redrawstatus() + end, + } +) diff --git a/nvim/.config/nvim/stylua.toml b/nvim/.config/nvim/stylua.toml index 4178ea5..0e7dca0 100644 --- a/nvim/.config/nvim/stylua.toml +++ b/nvim/.config/nvim/stylua.toml @@ -1,4 +1,4 @@ -column_width = 120 +column_width = 100 line_endings = "Unix" indent_type = "Tabs" indent_width = 2