aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorElvis Claros Castro <elvis@claros.ar>2025-09-03 20:56:00 -0300
committerElvis Claros Castro <elvis@claros.ar>2025-09-03 20:56:00 -0300
commit9d6f4942b982bf3c42af96ce69fc28cd3b9a9374 (patch)
treea3faa17f77056f91b492bc7306ea62542bf53e77 /lua
parentec64a4c396b25183496cd83591c42088dc89acfb (diff)
downloadnvim-conf-9d6f4942b982bf3c42af96ce69fc28cd3b9a9374.tar.gz
nvim-conf-9d6f4942b982bf3c42af96ce69fc28cd3b9a9374.zip
feat(statusline): mejora la barra de estado nativa con iconos y visualización LSP mejorada
- Añade iconos nerdfont/devicon para modos, rama git, diferencias git, diagnósticos y clientes LSP para mayor claridad visual. - Mejora la visualización de clientes LSP mostrando iconos y evitando duplicados. - Refactoriza el diseño de la barra de estado para secciones izquierda/derecha más informativas. - Actualiza la configuración de resaltado para mayor consistencia. fix(lsp): actualiza el mapeo de teclas para ir a la definición - Cambia el mapeo de teclas de definición LSP a <C-S-[> para mayor coherencia. feat(autocmds): autoformatea archivos C/C++ con clang-format al guardar - Añade autocmd para formatear archivos C/C++ usando LSP antes de guardar. refactor(null-ls): actualiza la sintaxis de require y la configuración de clang-format - Usa el estilo require de Lua para las fuentes de none-ls. - Habilita clang-format por defecto, comenta argumentos personalizados. feat(floaterm): añade opciones personalizadas para el plugin floaterm - Añade borde, tamaño, posición, visibilidad de la barra lateral/barra y terminales predefinidos. fix(noice): desactiva noice cuando se inicia con firenvim - Evita que Noice se cargue en sesiones de Firenvim. chore(lazy-lock): actualiza el archivo de bloqueo de plugins a los últimos commits - Sincroniza las versiones de los plugins con los últimos cambios upstream.
Diffstat (limited to 'lua')
-rw-r--r--lua/config/autocmds.lua8
-rw-r--r--lua/config/native-statusline.lua185
-rw-r--r--lua/pi/lsp/attach.lua2
-rw-r--r--lua/pi/lsp/null-ls.lua26
-rw-r--r--lua/plugins/foatterm.lua18
-rw-r--r--lua/plugins/noice.lua1
6 files changed, 157 insertions, 83 deletions
diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua
index 50e8cae..a18bc1a 100644
--- a/lua/config/autocmds.lua
+++ b/lua/config/autocmds.lua
@@ -38,6 +38,14 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, {
end,
})
+-- Auto-format C/C++ files with clang-format on save
+vim.api.nvim_create_autocmd("BufWritePre", {
+ pattern = { "*.c", "*.h", "*.cpp", "*.hpp", "*.cc", "*.cxx" },
+ callback = function()
+ vim.lsp.buf.format({ async = false })
+ end,
+})
+
-- Función para alternar el ajuste de línea
function ToggleWrap()
local wrap = vim.wo.wrap
diff --git a/lua/config/native-statusline.lua b/lua/config/native-statusline.lua
index c7dea6e..61ac97a 100644
--- a/lua/config/native-statusline.lua
+++ b/lua/config/native-statusline.lua
@@ -38,8 +38,12 @@ local colors = get_colors()
local function create_highlight(name, fg, bg, style)
local hl = { fg = fg, bg = bg }
if style then
- if style:find("bold") then hl.bold = true end
- if style:find("italic") then hl.italic = true end
+ if style:find "bold" then
+ hl.bold = true
+ end
+ if style:find "italic" then
+ hl.italic = true
+ end
end
vim.api.nvim_set_hl(0, name, hl)
return "%#" .. name .. "#"
@@ -53,93 +57,103 @@ local function setup_highlights()
create_highlight("StatuslineModeReplace", colors.red100, colors.base03, "bold")
create_highlight("StatuslineModeCommand", colors.yellow100, colors.base03, "bold")
create_highlight("StatuslineModeTerminal", colors.orange100, colors.base03, "bold")
-
+
create_highlight("StatuslineBranch", colors.orange100, colors.base03, "bold")
create_highlight("StatuslineFilename", colors.yellow100, colors.base03, "bold")
create_highlight("StatuslineLSP", colors.base4, colors.base03, "bold")
create_highlight("StatuslineFiletype", colors.magenta100, colors.base03, "bold")
create_highlight("StatuslineProgress", colors.cyan100, colors.base03, "bold")
-
+
create_highlight("StatuslineGitAdd", colors.green300, colors.base03, "bold")
create_highlight("StatuslineGitChange", colors.yellow300, colors.base03, "bold")
create_highlight("StatuslineGitDelete", colors.red300, colors.base03, "bold")
-
+
create_highlight("StatuslineDiagError", colors.red300, colors.base03, "bold")
create_highlight("StatuslineDiagWarn", colors.yellow300, colors.base03, "bold")
create_highlight("StatuslineDiagInfo", colors.blue300, colors.base03, "bold")
create_highlight("StatuslineDiagHint", colors.cyan300, colors.base03, "bold")
-
+
create_highlight("StatuslineSeparator", colors.base03, colors.base03, "")
end
-- Get current mode
local function get_mode()
local mode_map = {
- n = { "NORMAL", "StatuslineModeNormal", " " },
- i = { "INSERT", "StatuslineModeInsert", " " },
+ n = { "NORMAL", "StatuslineModeNormal", " " },
+ i = { "INSERT", "StatuslineModeInsert", " " },
v = { "VISUAL", "StatuslineModeVisual", "󰈈 " },
- V = { "V-LINE", "StatuslineModeVisual", " " },
- [""] = { "V-BLOCK", "StatuslineModeVisual", "󰩭 " },
- c = { "COMMAND", "StatuslineModeCommand", " " },
+ V = { "V-LINE", "StatuslineModeVisual", "󰕞 " },
+ ["\22"] = { "V-BLOCK", "StatuslineModeVisual", "󰩭 " }, -- Ctrl+v visual block mode
+ c = { "COMMAND", "StatuslineModeCommand", " " },
R = { "REPLACE", "StatuslineModeReplace", "󰛔 " },
- t = { "TERMINAL", "StatuslineModeTerminal", " " },
+ t = { "TERMINAL", "StatuslineModeTerminal", " " },
}
-
+
local current_mode = vim.fn.mode()
local mode_info = mode_map[current_mode] or { "UNKNOWN", "StatuslineModeNormal", " " }
-
+
return "%#" .. mode_info[2] .. "#" .. mode_info[3] .. mode_info[1] .. " "
end
-- Get git branch
local function get_git_branch()
- local handle = io.popen("git branch --show-current 2>/dev/null")
- if not handle then return "" end
-
- local branch = handle:read("*l")
+ local handle = io.popen "git branch --show-current 2>/dev/null"
+ if not handle then
+ return ""
+ end
+
+ local branch = handle:read "*l"
handle:close()
-
+
if not branch or branch == "" then
return ""
end
- return "%#StatuslineBranch# " .. branch .. " "
+ return "%#StatuslineBranch# " .. "  " .. branch .. " "
end
-- Get git diff stats
local function get_git_diff()
-- Check if we're in a git repository
- local handle = io.popen("git rev-parse --is-inside-work-tree 2>/dev/null")
- if not handle then return "" end
-
- local is_git = handle:read("*l")
+ local handle = io.popen "git rev-parse --is-inside-work-tree 2>/dev/null"
+ if not handle then
+ return ""
+ end
+
+ local is_git = handle:read "*l"
handle:close()
-
- if is_git ~= "true" then return "" end
-
+
+ if is_git ~= "true" then
+ return ""
+ end
+
-- Get staged changes
- local staged_handle = io.popen("git diff --cached --numstat 2>/dev/null | wc -l")
- local added = staged_handle and staged_handle:read("*l") or "0"
- if staged_handle then staged_handle:close() end
-
+ local staged_handle = io.popen "git diff --cached --numstat 2>/dev/null | wc -l"
+ local added = staged_handle and staged_handle:read "*l" or "0"
+ if staged_handle then
+ staged_handle:close()
+ end
+
-- Get unstaged changes
- local unstaged_handle = io.popen("git diff --numstat 2>/dev/null | wc -l")
- local modified = unstaged_handle and unstaged_handle:read("*l") or "0"
- if unstaged_handle then unstaged_handle:close() end
-
+ local unstaged_handle = io.popen "git diff --numstat 2>/dev/null | wc -l"
+ local modified = unstaged_handle and unstaged_handle:read "*l" or "0"
+ if unstaged_handle then
+ unstaged_handle:close()
+ end
+
local result = ""
if tonumber(added) and tonumber(added) > 0 then
- result = result .. "%#StatuslineGitAdd# +" .. added .. " "
+ result = result .. "%#StatuslineGitAdd#  +" .. added .. " "
end
if tonumber(modified) and tonumber(modified) > 0 then
- result = result .. "%#StatuslineGitChange# ~" .. modified .. " "
+ result = result .. "%#StatuslineGitChange#  ~" .. modified .. " "
end
-
+
return result
end
-- Get filename with path
local function get_filename()
- local filename = vim.fn.expand("%:t")
+ local filename = vim.fn.expand "%:t"
if filename == "" then
filename = "[No Name]"
end
@@ -148,24 +162,52 @@ end
-- Get LSP clients
local function get_lsp_clients()
- local clients = vim.lsp.get_clients({ bufnr = 0 })
+ local clients = vim.lsp.get_clients { bufnr = 0 }
if #clients == 0 then
return "%#StatuslineLSP#No LSP "
end
-
+
+ -- Map common LSP names to icons (nerdfonts / devicons style). Add or adjust as you like.
+ local lsp_icons = {
+ lua_ls = "",
+ sumneko_lua = "",
+ pyright = "",
+ pylsp = "",
+ tsserver = "",
+ denols = "",
+ rust_analyzer = "",
+ gopls = "",
+ clangd = "",
+ html = "󰜫",
+ cssls = "",
+ bashls = "",
+ jsonls = "ﬥ",
+ tailwindcss = "",
+ angularls = "",
+ emmet_ls = "",
+ ["null-ls"] = "ﳠ",
+ copilot = "",
+ }
+
+ local seen = {}
local client_names = {}
for _, client in ipairs(clients) do
- table.insert(client_names, client.name)
+ local name = client.name or "unknown"
+ if not seen[name] then
+ seen[name] = true
+ local icon = lsp_icons[name] or ""
+ table.insert(client_names, icon .. " " .. name)
+ end
end
-
- return "%#StatuslineLSP#" .. table.concat(client_names, ",") .. " "
+
+ return "%#StatuslineLSP#" .. "LSP: " .. table.concat(client_names, ", ") .. " "
end
-- Get diagnostics
local function get_diagnostics()
local diagnostics = vim.diagnostic.get(0)
local counts = { error = 0, warn = 0, info = 0, hint = 0 }
-
+
for _, diagnostic in ipairs(diagnostics) do
if diagnostic.severity == vim.diagnostic.severity.ERROR then
counts.error = counts.error + 1
@@ -177,21 +219,23 @@ local function get_diagnostics()
counts.hint = counts.hint + 1
end
end
-
+
local result = ""
+
+ -- Add icons for each diagnostic type (uses nerdfonts/devicons where available)
if counts.error > 0 then
- result = result .. "%#StatuslineDiagError# " .. counts.error .. " "
+ result = result .. "%#StatuslineDiagError#  " .. counts.error .. " "
end
if counts.warn > 0 then
- result = result .. "%#StatuslineDiagWarn# " .. counts.warn .. " "
+ result = result .. "%#StatuslineDiagWarn#  " .. counts.warn .. " "
end
if counts.info > 0 then
- result = result .. "%#StatuslineDiagInfo# " .. counts.info .. " "
+ result = result .. "%#StatuslineDiagInfo#  " .. counts.info .. " "
end
if counts.hint > 0 then
- result = result .. "%#StatuslineDiagHint#󰠠 " .. counts.hint .. " "
+ result = result .. "%#StatuslineDiagHint# 󰠠 " .. counts.hint .. " "
end
-
+
return result
end
@@ -206,8 +250,8 @@ end
-- Get progress (line/total)
local function get_progress()
- local current = vim.fn.line(".")
- local total = vim.fn.line("$")
+ local current = vim.fn.line "."
+ local total = vim.fn.line "$"
local percentage = math.floor((current / total) * 100)
return "%#StatuslineProgress#" .. percentage .. "%% "
end
@@ -219,39 +263,44 @@ end
-- Build the statusline
function M.build_statusline()
- local left = get_mode() .. separator() ..
- get_git_branch() .. separator() ..
- get_git_diff() .. separator() ..
- get_filename()
-
- local right = get_diagnostics() .. separator() ..
- get_lsp_clients() .. separator() ..
- get_filetype() .. separator() ..
- get_progress()
-
+ local left = get_mode()
+ .. separator()
+ .. get_git_branch()
+ .. separator()
+ .. get_git_diff()
+ .. separator()
+ .. get_filetype()
+ .. get_filename()
+
+ local right = get_diagnostics() .. separator() .. get_lsp_clients() .. separator() .. get_progress()
+
return left .. "%=" .. right
end
-- Setup function
function M.setup()
setup_highlights()
-
+
-- Set up autocommands to refresh statusline
vim.api.nvim_create_augroup("NativeStatusline", { clear = true })
-
+
-- Update statusline on various events
vim.api.nvim_create_autocmd({
- "VimEnter", "WinEnter", "BufEnter", "ModeChanged", "DiagnosticChanged"
+ "VimEnter",
+ "WinEnter",
+ "BufEnter",
+ "ModeChanged",
+ "DiagnosticChanged",
}, {
group = "NativeStatusline",
callback = function()
vim.opt.statusline = M.build_statusline()
end,
})
-
+
-- Set initial statusline
vim.opt.statusline = M.build_statusline()
-
+
-- Always show statusline
vim.opt.laststatus = 2
end
diff --git a/lua/pi/lsp/attach.lua b/lua/pi/lsp/attach.lua
index 24842fe..c61f5a1 100644
--- a/lua/pi/lsp/attach.lua
+++ b/lua/pi/lsp/attach.lua
@@ -26,7 +26,7 @@ return function(client, bufnr)
telescope_mapper("gr", "lsp_references", { buffer = true, desc = "LSP References of symbol on cursor" })
telescope_mapper("<leader>pv", "find_symbol", { buffer = true, desc = "LSP find symbol on the project" })
telescope_mapper("<leader>pd", "lsp_document_symbols", { buffer = true, desc = "LSP document symbols" })
- telescope_mapper("gd", "lsp_definitions", { buffer = true, desc = "LSP go to definition" })
+ telescope_mapper("<C-S-[>", "lsp_definitions", { buffer = true, desc = "LSP go to definition" })
vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
diff --git a/lua/pi/lsp/null-ls.lua b/lua/pi/lsp/null-ls.lua
index a9c4412..7e7888d 100644
--- a/lua/pi/lsp/null-ls.lua
+++ b/lua/pi/lsp/null-ls.lua
@@ -5,19 +5,19 @@ local null_ls = require "null-ls"
null_ls.setup {
sources = {
-- null_ls.builtins.code_actions.gitsigns,
- require("none-ls.formatting.jq"),
- require("none-ls.diagnostics.cpplint"),
- require("none-ls.code_actions.eslint"),
+ require "none-ls.formatting.jq",
+ -- require("none-ls.diagnostics.cpplint"),
+ require "none-ls.code_actions.eslint",
null_ls.builtins.code_actions.refactoring,
null_ls.builtins.formatting.alejandra,
- require("none-ls-luacheck.diagnostics.luacheck"),
+ require "none-ls-luacheck.diagnostics.luacheck",
null_ls.builtins.formatting.stylua,
- require("none-ls.diagnostics.yamllint"),
+ require "none-ls.diagnostics.yamllint",
-- require("none-ls.diagnostics.ruff"),
-- require("none-ls.diagnostics.flake8"),
- require("none-ls-shellcheck.diagnostics"),
- require("none-ls-shellcheck.code_actions"),
+ require "none-ls-shellcheck.diagnostics",
+ require "none-ls-shellcheck.code_actions",
-- null_ls.builtins.diagnostics.yamllint,
-- php_actions.getter_setter,
@@ -38,17 +38,17 @@ null_ls.setup {
end,
},
null_ls.builtins.formatting.pint,
- -- null_ls.builtins.formatting.clang_format,
- null_ls.builtins.formatting.clang_format.with {
- extra_args = { "--style={IndentWidth: 4}" },
- },
+ null_ls.builtins.formatting.clang_format,
+ -- null_ls.builtins.formatting.clang_format.with {
+ -- extra_args = { "--style={IndentWidth: 4}" },
+ -- },
},
}
-vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, {desc = "LSP (null ls) Code actions"})
+vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, { desc = "LSP (null ls) Code actions" })
vim.keymap.set("n", "<leader>vf", function()
return vim.lsp.buf.format { async = true }
-end, {desc = "LSP (null ls) Format file"})
+end, { desc = "LSP (null ls) Format file" })
-- function to toogle and possible restart it
vim.api.nvim_create_user_command("NullLsToggle", function()
diff --git a/lua/plugins/foatterm.lua b/lua/plugins/foatterm.lua
index 708241a..a6c64b5 100644
--- a/lua/plugins/foatterm.lua
+++ b/lua/plugins/foatterm.lua
@@ -1,6 +1,22 @@
return {
"nvzone/floaterm",
dependencies = "nvzone/volt",
- opts = {},
+ opts = {
+ border = false,
+ size = { h = 40, w = 70 },
+ -- to use, make this func(buf)
+ position = { row = 50, col = 35 },
+ show_sidebar = false, -- oculta el sidebar
+ show_bar = false, -- oculta la barra
+ mappings = { sidebar = nil, term = nil },
+
+ -- Default sets of terminals you'd like to open
+ terminals = {
+ { name = "Terminal" },
+ -- cmd can be function too
+ -- { name = "Terminal", cmd = "neofetch" },
+ -- More terminals
+ },
+ },
cmd = "FloatermToggle",
}
diff --git a/lua/plugins/noice.lua b/lua/plugins/noice.lua
index 314db31..033db3c 100644
--- a/lua/plugins/noice.lua
+++ b/lua/plugins/noice.lua
@@ -4,6 +4,7 @@ return {
"MunifTanjim/nui.nvim",
},
event = "VeryLazy",
+ enabled = not vim.g.started_by_firenvim,
opts = {
cmdline = {
enabled = true, -- enables the Noice cmdline UI