Updated scripts

This commit is contained in:
Christoffer Martinsson 2025-08-17 14:02:27 +02:00
parent 292759db4e
commit 389833df64

View File

@ -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", "<leader>u", ":update<CR> :source<CR>", { noremap = true, silent = true
map("n", "<leader>w", ":write<CR>", { noremap = true, silent = true })
map("n", "<leader>q", ":quit<CR>", { noremap = true, silent = true })
map("n", "<leader>v", ":vsplit<CR>", { noremap = true, silent = true })
map("n", "<C-d>", "<C-d>zz", { noremap = true, silent = true })
map("n", "<C-u>", "<C-u>zz", { noremap = true, silent = true })
map("n", "n", "nzzzv", { noremap = true, silent = true })
map("n", "N", "Nzzzv", { noremap = true, silent = true })
-- Git
map("n", "<leader>g", ":LazyGitCurrentFile<CR>", { noremap = true, silent = true })