From 389833df640279be2f50a21fc16654866f10b5be Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sun, 17 Aug 2025 14:02:27 +0200 Subject: [PATCH] Updated scripts --- config/nvim/init.lua | 79 +++++++++++++++++++++++++++++++------------- 1 file changed, 56 insertions(+), 23 deletions(-) diff --git a/config/nvim/init.lua b/config/nvim/init.lua index fbc4e5b..494d6c4 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -21,7 +21,7 @@ vim.g.netrw_liststyle = 3 -- tree style view in netrw ------------------------------------------------------------------- -- Autocommands ------------------------------------------------------------------- --- show cursor line only in active window +-- show cursor line only in active window (TMUX) local cursorLineGrp = vim.api.nvim_create_augroup("CursorLine", { clear = true }) vim.api.nvim_create_autocmd( { "InsertLeave", "WinEnter" }, @@ -40,6 +40,47 @@ vim.api.nvim_create_autocmd( { pattern = "*", command = "set nocursorline", group = cursorLineGrp } ) +------------------------------------------------------------------- +-- Functions +------------------------------------------------------------------- +local center_window = function() + local height = math.floor(0.618 * vim.o.lines) + local width = math.floor(0.618 * vim.o.columns) + return { + anchor = "NW", + height = height, + width = width, + row = math.floor(0.5 * (vim.o.lines - height)), + col = math.floor(0.5 * (vim.o.columns - width)), + } +end + +local active_statusline = function() + local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 }) + local diff = MiniStatusline.section_diff({ trunc_width = 75 }) + local git = MiniStatusline.section_git({ trunc_width = 40 }) + local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 }) + local lsp = MiniStatusline.section_lsp({ trunc_width = 75 }) + local filename = MiniStatusline.section_filename({ trunc_width = 140 }) + local fileinfo = string.match(MiniStatusline.section_fileinfo({ trunc_width = 120 }), "%S+") + local location = MiniStatusline.section_location({ trunc_width = 75 }) + + return MiniStatusline.combine_groups({ + { hl = mode_hl, strings = { mode } }, + { hl = "MiniStatuslineDevinfo", strings = { git, diff, diagnostics } }, + "%<", -- Mark general truncate point + { hl = "MiniStatuslineFilename", strings = { filename } }, + "%=", -- End left alignment + { hl = "MiniStatuslineFileinfo", strings = { lsp, fileinfo } }, + { hl = mode_hl, strings = { location } }, + }) +end +local inactive_statusline = function() + return MiniStatusline.combine_groups({ + { hl = "MiniStatuslineDevinfo", strings = {} }, + }) +end + ------------------------------------------------------------------- -- Plugin installation ------------------------------------------------------------------- @@ -97,21 +138,9 @@ require("conform").setup({ lsp_format = "fallback", }, }) - -local win_config = function() - local height = math.floor(0.618 * vim.o.lines) - local width = math.floor(0.618 * vim.o.columns) - return { - anchor = "NW", - height = height, - width = width, - row = math.floor(0.5 * (vim.o.lines - height)), - col = math.floor(0.5 * (vim.o.columns - width)), - } -end -require("mini.pick").setup({ window = { config = win_config } }) +require("mini.pick").setup({ window = { config = center_window } }) require("mini.extra").setup() -require("mini.statusline").setup() +require("mini.statusline").setup({ content = { active = active_statusline, inactive = inactive_statusline } }) require("gitsigns").setup({ signs = { add = { text = "▎" }, @@ -130,9 +159,6 @@ require("gitsigns").setup({ col = 1, }, }) -------------------------------------------------------------------- --- Autocomplete -------------------------------------------------------------------- require("luasnip.loaders.from_vscode").lazy_load() require("blink.cmp").setup({ signature = { enabled = true }, @@ -170,13 +196,16 @@ vim.cmd.colorscheme("nightly_cm") vim.diagnostic.config({ severity_sort = true, float = { border = "rounded", source = "if_many" }, - underline = { severity = vim.diagnostic.severity.ERROR }, + underline = { severity = vim.diagnostic.severity.WARN }, signs = { + numhl = { + [vim.diagnostic.severity.ERROR] = "DiagnosticSignError", + }, text = { - [vim.diagnostic.severity.ERROR] = "󰅚 ", - [vim.diagnostic.severity.WARN] = "󰀪 ", - [vim.diagnostic.severity.INFO] = "󰋽 ", - [vim.diagnostic.severity.HINT] = "󰌶 ", + [vim.diagnostic.severity.ERROR] = "", + [vim.diagnostic.severity.WARN] = "", + [vim.diagnostic.severity.INFO] = "", + [vim.diagnostic.severity.HINT] = "", }, } or {}, virtual_text = { @@ -205,6 +234,10 @@ map("n", "u", ":update :source", { noremap = true, silent = true map("n", "w", ":write", { noremap = true, silent = true }) map("n", "q", ":quit", { noremap = true, silent = true }) map("n", "v", ":vsplit", { noremap = true, silent = true }) +map("n", "", "zz", { noremap = true, silent = true }) +map("n", "", "zz", { noremap = true, silent = true }) +map("n", "n", "nzzzv", { noremap = true, silent = true }) +map("n", "N", "Nzzzv", { noremap = true, silent = true }) -- Git map("n", "g", ":LazyGitCurrentFile", { noremap = true, silent = true })