From d61d97f1215df98d686dd6f8f108c363a18a5e62 Mon Sep 17 00:00:00 2001 From: Henrik Bakken Date: Mon, 10 Feb 2025 23:40:22 +0100 Subject: [PATCH] nvim refactoring --- nvim/init.lua | 1751 ++++++++++++++++++++++++------------------------- 1 file changed, 868 insertions(+), 883 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index b8df66c..7ebace0 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -2,870 +2,6 @@ vim.opt.termguicolors = true vim.g.mapleader = " " vim.g.maplocalleader = " " -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not (vim.uv or vim.loop).fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "--branch=stable", - "https://github.com/folke/lazy.nvim.git", - lazypath, - }) -end -vim.opt.rtp:prepend(lazypath) -require("lazy").setup({ - -- mini - { - "echasnovski/mini.basics", - config = function() - require("mini.basics").setup({ - options = { - basic = true, - extra_ui = true, - }, - mappings = { - move_with_alt = true, - }, - }) - end, - }, - { - "echasnovski/mini.base16", - config = function() - require("mini.base16").setup({ - palette = { - base00 = "#112641", - base01 = "#3a475e", - base02 = "#606b81", - base03 = "#8691a7", - base04 = "#d5dc81", - base05 = "#e2e98f", - base06 = "#eff69c", - base07 = "#fcffaa", - base08 = "#ffcfa0", - base09 = "#cc7e46", - base0A = "#46a436", - base0B = "#9ff895", - base0C = "#ca6ecf", - base0D = "#42f7ff", - base0E = "#ffc4ff", - base0F = "#00a5c5", - }, - use_cterm = true, - plugins = { - default = false, - ["echasnovski/mini.nvim"] = true, - }, - }) - end, - }, - { - "phaazon/hop.nvim", - config = function() - require("hop").setup({ - require("hop.highlight").insert_highlights(), - }) - local map = vim.keymap.set - local opts = { silent = true, noremap = true } - map({ "n", "v" }, "", "HopWord", opts) - map({ "n", "v" }, "", "HopWord", opts) - end, - }, - { - "echasnovski/mini.icons", - config = function() - require("mini.icons").setup() - end, - }, - { - "echasnovski/mini.files", - dependencies = { - "echasnovski/mini.icons", - }, - config = function() - local minifiles = require("mini.files") - vim.keymap.set("n", "", minifiles.open, { noremap = true }) - end, - }, - { - "echasnovski/mini.surround", - version = false, - config = function() - require("mini.surround").setup() - end, - }, - { - "echasnovski/mini.bufremove", - config = function() - local bufremove = require("mini.bufremove") - bufremove.setup() - local map = vim.keymap.set - -- remove buffer - map("n", "", function() - bufremove.wipeout() - end, { noremap = true }) - map("n", "", function() - bufremove.wipeout(nil, true) - end, { noremap = true }) - end, - }, - -- snacks - { - "folke/snacks.nvim", - priority = 1000, - lazy = false, - ---@type snacks.Config - opts = { - bigfile = { - enabled = true, - notify = true, -- show notification when big file detected - size = 1.5 * 1024 * 1024, -- 1.5MB - line_length = 1000, -- average line length (useful for minified files) - -- Enable or disable features when big file detected - ---@param ctx {buf: number, ft:string} - setup = function(ctx) - if vim.fn.exists(":NoMatchParen") ~= 0 then - vim.cmd([[NoMatchParen]]) - end - Snacks.util.wo(0, { foldmethod = "manual", statuscolumn = "", conceallevel = 0 }) - vim.schedule(function() - if vim.api.nvim_buf_is_valid(ctx.buf) then - vim.bo[ctx.buf].syntax = ctx.ft - end - end) - end, - }, - notifier = { enabled = true }, - }, - }, - -- div utils - "tpope/vim-eunuch", -- Move, Rename etc - "dhruvasagar/vim-table-mode", -- tables - "itchyny/vim-qfedit", -- editable quickfix list - "mbbill/undotree", - { - -- keep location upon reopening - "ethanholz/nvim-lastplace", - config = function() - require("nvim-lastplace").setup() - end, - }, - { - -- tmux / vim interop - "christoomey/vim-tmux-navigator", - config = function() - vim.g.tmux_navigator_no_mappings = 1 - vim.g.tmux_navigator_disable_when_zoomed = 1 - local map = vim.keymap.set - local opts = { silent = true, noremap = true } - map("n", "", "TmuxNavigateLeft", opts) - map("n", "", "TmuxNavigateDown", opts) - map("n", "", "TmuxNavigateUp", opts) - map("n", "", "TmuxNavigateRight", opts) - end, - }, - { - "cameron-wags/rainbow_csv.nvim", - config = true, - ft = { - "csv", - "tsv", - "csv_semicolon", - "csv_whitespace", - "csv_pipe", - "rfc_csv", - "rfc_semicolon", - }, - cmd = { - "RainbowDelim", - "RainbowDelimSimple", - "RainbowDelimQuoted", - "RainbowMultiDelim", - }, - }, - { - -- live preview of markdown files - "iamcco/markdown-preview.nvim", -- requires yarn - cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, - ft = { "markdown" }, - build = function() - vim.fn["mkdp#util#install"]() - end, - init = function() - vim.g.mkdp_auto_start = 0 -- auto start on moving into - vim.g.mkdp_auto_close = 0 -- auto close on moving away - vim.g.mkdp_open_to_the_world = 1 -- available to others - vim.g.mkdp_port = 10010 - vim.g.mkdp_echo_preview_url = 1 - vim.g.mkdp_preview_options = { disable_sync_scroll = 1 } - end, - }, - { - -- search count > 99 - "kevinhwang91/nvim-hlslens", - dependencies = { - "haya14busa/vim-asterisk", - }, - config = function() - require("hlslens").setup({ nearest_only = true }) - local kopts = { noremap = true, silent = true } - local map = vim.keymap.set - vim.g["asterisk#keeppos"] = 1 - map({ "n", "x" }, "*", [[(asterisk-z*)lua require('hlslens').start()]], {}) - map({ "n", "x" }, "#", [[(asterisk-z#)lua require('hlslens').start()]], {}) - map({ "n", "x" }, "g*", [[(asterisk-gz*)lua require('hlslens').start()]], {}) - map({ "n", "x" }, "g#", [[(asterisk-gz#)lua require('hlslens').start()]], {}) - map({ "n", "x" }, "n", [[nlua require('hlslens').start()]], kopts) - map({ "n", "x" }, "N", [[Nlua require('hlslens').start()]], kopts) - end, - }, -- theme dark and light - "NLKNguyen/papercolor-theme", - "junegunn/seoul256.vim", - "mhartington/oceanic-next", - "morhetz/gruvbox", - "sonph/onehalf", - { "catppuccin/nvim", lazy = false, name = "catppuccin", priority = 1000 }, - { - "Shatur/neovim-ayu", - config = function() - vim.g.ayu_extended_palette = 1 - end, - }, -- theme dark only - "tomasr/molokai", - "jnurmine/Zenburn", - { - -- coloring of colornames - "rrethy/vim-hexokinase", - build = "cd /home/hjalmarlucius/.local/share/nvim/lazy/vim-hexokinase && make hexokinase", - config = function() - vim.g.Hexokinase_highlighters = { "virtual" } - end, - }, -- status + buffer lines - { - "nvim-lualine/lualine.nvim", - dependencies = { "echasnovski/mini.icons" }, - config = function() - local noice_status = require("noice").api.status - require("lualine").setup({ - options = { theme = "auto", globalstatus = false }, - extensions = { "fugitive" }, - sections = { - lualine_a = { { "mode", color = { bg = "goldenrod" } } }, - lualine_b = { "branch" }, - lualine_c = { - { - "filename", - file_status = true, - path = 1, - shorting_target = 0, - }, - { "diff", colored = true }, - }, - lualine_x = { - { - noice_status.command.get, - cond = noice_status.command.has, - }, - { - noice_status.mode.get, - cond = noice_status.mode.has, - }, - }, - lualine_y = { "filetype", "progress" }, - lualine_z = { "location" }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { - { - "filename", - file_status = true, - path = 1, - shorting_target = 0, - }, - { "diff", colored = true }, - }, - lualine_x = {}, - lualine_y = { "filetype", "progress" }, - lualine_z = { "location" }, - }, - tabline = { - lualine_a = { - { - "buffers", - symbols = { alternate_file = "" }, - buffers_color = { - active = { bg = "goldenrod" }, - }, - }, - }, - lualine_b = {}, - lualine_c = {}, - lualine_x = {}, - lualine_y = {}, - lualine_z = { - { - "tabs", - mode = 2, - tabs_color = { - active = { bg = "goldenrod" }, - }, - }, - }, - }, - }) - end, - }, -- git related plugins - { - "tpope/vim-fugitive", - config = function() - local map = vim.keymap.set - map("", "", "vertical Git", {}) - map("", "gB", "Git blame", {}) - map("", "gp", "Git! push", {}) - map("", "gP", "Git! push -f", {}) - vim.api.nvim_create_autocmd("User", { - pattern = { "FugitiveCommit", "BufReadPost" }, - callback = function() - vim.opt.foldmethod = "syntax" - vim.opt.foldlevel = 0 - end, - }) - end, - }, - { - "rbong/vim-flog", - config = function() - local map = vim.keymap.set - map("", "gl", "vertical Flogsplit -path=%", {}) - map("", "gL", "vertical Flogsplit", {}) - vim.g.flog_permanent_default_opts = { - -- format = "%ad [%h] {%an}%d %s", - format = "%ad [%h]%d %s", - date = "short", - } - end, - }, - { - "lewis6991/gitsigns.nvim", - config = function() - require("gitsigns").setup({ - signcolumn = true, - numhl = true, - linehl = false, - word_diff = false, - signs_staged_enable = false, - on_attach = function(bufnr) - local gs = package.loaded.gitsigns - - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end - - -- Navigation - map("n", "", function() - if vim.wo.diff then - return "]c" - end - vim.schedule(function() - gs.next_hunk() - end) - return "" - end, { expr = true }) - - map("n", "", function() - if vim.wo.diff then - return "[c" - end - vim.schedule(function() - gs.prev_hunk() - end) - return "" - end, { expr = true }) - - -- Actions - map({ "n", "v" }, "gs", ":Gitsigns stage_hunk") - map({ "n", "v" }, "gx", ":Gitsigns reset_hunk") - map("n", "gu", gs.undo_stage_hunk) - map("n", "gi", gs.preview_hunk) - map("n", "gb", function() - gs.blame_line({ full = true }) - end) - map("n", "gd", gs.diffthis) - map("n", "gS", gs.stage_buffer) - map("n", "gX", gs.reset_buffer) - map("n", "td", gs.toggle_deleted) - map("n", "tl", gs.toggle_linehl) - map("n", "tb", gs.toggle_current_line_blame) - map("n", "th", gs.toggle_word_diff) - map("n", "tn", gs.toggle_numhl) - - -- Text object - map({ "o", "x" }, "ih", "Gitsigns select_hunk") - end, - }) - end, - }, - { -- helplists - "folke/todo-comments.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - require("todo-comments").setup({ - signs = true, -- show icons in the signs column - sign_priority = 8, -- sign priority - -- keywords recognized as todo comments - keywords = { - ERROR = { icon = " ", color = "error" }, - WIP = { icon = " ", color = "warning" }, - TODO = { icon = " ", color = "warning" }, - PERF = { icon = " ", color = "info" }, - TEST = { icon = " ", color = "info" }, - MAYBE = { icon = " ", color = "default" }, - IDEA = { icon = " ", color = "hint" }, - }, - merge_keywords = false, -- when true, custom keywords will be merged with the defaults - highlight = { keyword = "bg", pattern = [[<(KEYWORDS)\s*]] }, - search = { pattern = [[\b(KEYWORDS)\b]] }, - colors = { - error = { "#ba1a1a" }, - warning = { "#FFC107" }, - info = { "#91BED0" }, - hint = { "#10B981" }, - default = { "#91D0C1" }, - }, - }) - end, - }, -- Fuzzy Finder (files, lsp, etc) - { - "nvim-telescope/telescope.nvim", - version = "*", - dependencies = { - "sharkdp/fd", - "nvim-lua/plenary.nvim", - "nvim-telescope/telescope-live-grep-args.nvim", - }, - config = function() - -- TODO grep with regex - local map = vim.keymap.set - local opts = { noremap = true } - local actions = require("telescope.actions") - map("n", "", "Telescope find_files layout_config={width=0.99}", opts) - map("n", "", "Telescope git_files layout_config={width=0.99}", opts) - map( - "n", - "", - "Telescope diagnostics layout_strategy=vertical layout_config={width=0.99}", - opts - ) - map("n", "", "Telescope live_grep layout_strategy=vertical layout_config={width=0.99}", opts) - map("n", "", ':lua require("telescope").extensions.live_grep_args.live_grep_args()', opts) - map("n", "", "Telescope filetypes", opts) - map("n", "", "Telescope search_history", opts) - map("n", "", "Telescope colorscheme layout_config={width=0.5} enable_preview=1", opts) - require("telescope").setup({ - defaults = { - layout_config = { horizontal = { width = 0.99 } }, - mappings = { - i = { - [""] = actions.close, - [""] = actions.select_default, - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - [""] = actions.preview_scrolling_up, - [""] = actions.preview_scrolling_down, - [""] = actions.select_horizontal, - [""] = actions.select_vertical, - [""] = actions.select_tab, - [""] = actions.toggle_selection + actions.move_selection_worse, - [""] = actions.toggle_selection + actions.move_selection_better, - [""] = actions.send_to_loclist + actions.open_loclist, - [""] = actions.send_selected_to_loclist + actions.open_loclist, - [""] = actions.results_scrolling_up, - [""] = actions.results_scrolling_down, - }, - }, - file_ignore_patterns = {}, - set_env = { ["COLORTERM"] = "truecolor" }, - }, - }) - end, - }, - { - "kevinhwang91/nvim-ufo", - dependencies = { "kevinhwang91/promise-async" }, - config = function() - vim.o.foldcolumn = "0" - vim.o.foldlevel = 99 - vim.o.foldlevelstart = 99 - vim.o.foldenable = true - - local ufo = require("ufo") - -- zm/M zr/R increase/increase foldlevel (max) - -- zo/O zc/C open / close fold (max) - -- za zA switch fold (small/full) - -- zi toggle folds - -- zi zj move to next / prev fold - - local map = vim.keymap.set - map("n", "zR", ufo.openAllFolds) - map("n", "zM", ufo.closeAllFolds) - map("n", "zm", ufo.closeFoldsWith) - map("n", "zr", ufo.openFoldsExceptKinds) - - local closecounthandler = function(virtText, lnum, endLnum, width, truncate) - local newVirtText = {} - local suffix = (" 󰁂 %d "):format(endLnum - lnum) - local sufWidth = vim.fn.strdisplaywidth(suffix) - local targetWidth = width - sufWidth - local curWidth = 0 - for _, chunk in ipairs(virtText) do - local chunkText = chunk[1] - local chunkWidth = vim.fn.strdisplaywidth(chunkText) - if targetWidth > curWidth + chunkWidth then - table.insert(newVirtText, chunk) - else - chunkText = truncate(chunkText, targetWidth - curWidth) - local hlGroup = chunk[2] - table.insert(newVirtText, { chunkText, hlGroup }) - chunkWidth = vim.fn.strdisplaywidth(chunkText) - -- str width returned from truncate() may less than 2nd argument, need padding - if curWidth + chunkWidth < targetWidth then - suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth) - end - break - end - curWidth = curWidth + chunkWidth - end - table.insert(newVirtText, { suffix, "MoreMsg" }) - return newVirtText - end - ufo.setup({ - preview = { - mappings = { - scrollU = "", - scrollD = "", - jumpTop = "[", - jumpBot = "]", - }, - }, - fold_virt_text_handler = closecounthandler, - }) - end, - }, - { - -- Highlight, edit, and navigate code - "nvim-treesitter/nvim-treesitter", - config = function() - pcall(require("nvim-treesitter.install").update()) - require("nvim-treesitter.configs").setup({ - ensure_installed = { "c", "cpp", "lua", "vimdoc", "gitcommit", "git_rebase", "bash", "python" }, - auto_install = true, - highlight = { enable = true }, - indent = { disable = { "python" }, additional_vim_regex_highlighting = { "python" } }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "gnn", - node_decremental = "", - node_incremental = "", - scope_incremental = "", - }, - }, - }) - vim.opt.foldexpr = "nvim_treesitter#foldexpr()" - end, - }, - { - "windwp/nvim-ts-autotag", - dependencies = { - "nvim-treesitter/nvim-treesitter", - }, - config = function() - require("nvim-ts-autotag").setup({ - filetypes = { "html", "xml" }, - }) - end, - }, -- package manager + lsp stuff - { - "williamboman/mason.nvim", - config = function() - require("mason").setup() - end, - }, - { - "mfussenegger/nvim-lint", - config = function() - require("lint").linters_by_ft = { - javascript = { "eslint_d" }, - typescript = { "eslint_d" }, - html = { "tidy", "eslint_d" }, - } - vim.api.nvim_create_autocmd({ "BufWritePost", "TextChanged" }, { - callback = function() - require("lint").try_lint() - end, - }) - end, - }, - { - "mhartington/formatter.nvim", -- TODO move to conform - -- Utilities for creating configurations - config = function() - local util = require("formatter.util") - local map = vim.keymap.set - local opts = { silent = true, noremap = true } - map("n", "f", ":Format", opts) - map("n", "F", ":FormatWrite", opts) - local eslint_d = function() - return { - exe = "eslint_d", - args = { - "--stdin", - "--debug", - "--stdin-filename", - util.escape_path(util.get_current_buffer_file_path()), - "--fix-to-stdout", - }, - stdin = true, - try_node_modules = true, - ignore_exitcode = true, - } - end - -- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands - require("formatter").setup({ - logging = true, - log_level = vim.log.levels.DEBUG, - filetype = { - python = { - function() - return { - exe = "ruff", - args = { "check", "--select I,F,UP", "--fix-only", "-" }, - stdin = true, - } - end, - function() - return { - exe = "ruff", - args = { "format", "-" }, - stdin = true, - } - end, - }, - go = { require("formatter.filetypes.go").gofumpt, require("formatter.filetypes.go").golines }, - lua = { - function() - return { - exe = "stylua", - args = { - "--search-parent-directories", - "--indent-type Spaces", - "--stdin-filepath", - util.escape_path(util.get_current_buffer_file_path()), - "--", - "-", - }, - stdin = true, - } - end, - }, - yaml = { - function() - return { - exe = "yamlfmt", - args = { - "-formatter indentless_arrays=true,retain_line_breaks=true,line_ending=lf,max_line_length=100,pad_line_comments=2", - "-in", - }, - stdin = true, - } - end, - }, - sh = { require("formatter.filetypes.sh").shfmt }, - javascript = { - require("formatter.filetypes.javascript").prettierd, - }, - html = { - require("formatter.filetypes.html").prettierd, - }, - css = { - require("formatter.filetypes.css").prettierd, - }, - markdown = { require("formatter.filetypes.markdown").prettierd }, - json = { require("formatter.filetypes.json").jq }, - ["*"] = { require("formatter.filetypes.any").remove_trailing_whitespace }, - }, - }) - end, - }, - { - "neovim/nvim-lspconfig", - dependencies = { - "williamboman/mason.nvim", - "williamboman/mason-lspconfig.nvim", - "kevinhwang91/nvim-ufo", - }, - config = function() - local on_attach = function(client, bufnr) - local bmap = function(mode, keys, func) - vim.keymap.set(mode, keys, func, { buffer = bufnr, noremap = true }) - end - -- workspaces - bmap("n", "wa", vim.lsp.buf.add_workspace_folder) - bmap("n", "wr", vim.lsp.buf.remove_workspace_folder) - bmap("n", "wl", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end) - -- jump - bmap("n", "", function() - vim.diagnostic.open_float({ source = true }) - end) - bmap("n", "", function() - vim.diagnostic.jump({ severity = { min = vim.diagnostic.severity.HINT }, float = true, count = 1 }) - end) - bmap("n", "", function() - vim.diagnostic.jump({ severity = { min = vim.diagnostic.severity.HINT }, float = true, count = -1 }) - end) - bmap("n", "gd", vim.lsp.buf.definition) - bmap("n", "gD", vim.lsp.buf.type_definition) - bmap("n", "gi", vim.lsp.buf.declaration) - bmap("n", "gI", vim.lsp.buf.implementation) - -- quickfix - bmap("n", "gl", vim.diagnostic.setloclist) - bmap("n", "gr", vim.lsp.buf.references) - -- popups - bmap({ "n", "i" }, "", vim.lsp.buf.signature_help) - -- other - bmap("n", "K", function() - local winid = require("ufo").peekFoldedLinesUnderCursor() - if not winid then - vim.lsp.buf.hover() - end - end) - bmap("n", "", vim.lsp.buf.rename) - bmap("n", "ca", vim.lsp.buf.code_action) - end - - local server_configs = { - pyright = { - python = { - analysis = { autoImportCompletions = false, diagnosticMode = "openFilesOnly" }, - }, - }, - lua_ls = { - Lua = { - workspace = { - checkThirdParty = false, - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - }, - telemetry = { enable = false }, - diagnostics = { - -- Get the language server to recognize the `vim` global in init.lua - globals = { "vim", "core" }, - }, - format = { enable = false }, - }, - }, - html = { - html = { - format = { - templating = true, - wrapLineLength = 120, - wrapAttributes = "auto", - }, - hover = { - documentation = true, - references = true, - }, - }, - }, - yamlls = { - yaml = { - schemas = { kubernetes = "/home/hjalmarlucius/src/hjarl/system/manifests/*.yaml" }, - -- schemaStore = { enable = false, url = "" }, - }, - }, - } - - local capabilities = vim.lsp.protocol.make_client_capabilities() - - local ufo = require("ufo") - if ufo then - capabilities.textDocument.foldingRange = { - dynamicRegistration = false, - lineFoldingOnly = true, - } - end - - local mason_lspconfig = require("mason-lspconfig") - mason_lspconfig.setup({ - ensure_installed = { - "cssls", - "html", - "jsonls", - "yamlls", - "bashls", - "pyright", - "lua_ls", - }, - }) - mason_lspconfig.setup_handlers({ - function(server_name) - require("lspconfig")[server_name].setup({ - capabilities = capabilities, - on_attach = on_attach, - settings = server_configs[server_name], - }) - end, - }) - end, - }, - { - "folke/noice.nvim", - dependencies = { "MunifTanjim/nui.nvim" }, - config = function() - require("noice").setup({ - cmdline = { enabled = true, view = "cmdline_popup" }, - messages = { - enabled = true, -- enables the Noice messages UI - view = "mini", -- default view for messages - view_error = "notify", -- view for errors - view_warn = "mini", -- view for warnings - view_history = "popup", -- view for :messages - view_search = false, - }, - popupmenu = { enabled = true }, - notify = { enabled = true, view = "mini" }, - lsp = { - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - }, - progress = { enabled = false }, - hover = { enabled = true }, - signature = { enabled = true, auto_open = { enabled = true, throttle = 0 } }, - message = { enabled = true, view = "notify" }, - documentation = { view = "hover" }, - }, - -- you can enable a preset for easier configuration - presets = { - command_palette = true, -- position the cmdline and popupmenu together - long_message_to_split = true, -- long messages will be sent to a split - }, - routes = { - { filter = { event = "msg_show", kind = "search_count" }, opts = { skip = true } }, - { filter = { kind = "", min_height = 2 }, view = "split" }, - }, - }) - end, - }, -}) - -- ---------------------------------------- -- SETTINGS -- ---------------------------------------- @@ -923,9 +59,7 @@ vim.opt.iskeyword = vim.opt.iskeyword - { "." } vim.api.nvim_create_autocmd({ "BufReadPost" }, { pattern = { "quickfix" }, - callback = function() - vim.keymap.set("n", "", "", { buffer = true }) - end, + callback = function() vim.keymap.set("n", "", "", { buffer = true }) end, }) -- ---------------------------------------- @@ -980,10 +114,7 @@ map("n", "", "lprev", { noremap = true }) map("n", "", "lnext", { noremap = true }) --- F keys map("n", "", "Lazy", { noremap = true }) -map("n", "", "Mason", { noremap = true }) -map("n", "", "LspInfo", { noremap = true }) map("n", "", "checkt", { noremap = true }) -map("n", "", "TodoQuickFix", { noremap = true }) -- VISUALS vim.o.guicursor = "n-v-c:block-CustomCursor,i:ver100-CustomICursor,n-v-c:blinkon0,i:blinkwait10" @@ -996,17 +127,871 @@ vim.api.nvim_create_autocmd("ColorScheme", { vim.api.nvim_set_hl(0, "ColorColumn", { bg = "salmon4" }) end, }) -local customthemegroup = vim.api.nvim_create_augroup("customthemegroup", {}) -vim.api.nvim_create_autocmd("ColorScheme", { - pattern = { "OceanicNext" }, - group = customthemegroup, - callback = function() - vim.api.nvim_set_hl(0, "DiffAdded", { default = false, link = "DiffAdd" }) - vim.api.nvim_set_hl(0, "DiffRemoved", { default = false, link = "DiffDelete" }) - vim.api.nvim_set_hl(0, "Normal", {}) - vim.api.nvim_set_hl(0, "LineNr", {}) - vim.api.nvim_set_hl(0, "SignColumn", {}) - vim.api.nvim_set_hl(0, "EndOfBuffer", {}) - end, + +-- ---------------------------------------- +-- PLUGINS +-- ---------------------------------------- + +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "--branch=stable", + "https://github.com/folke/lazy.nvim.git", + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) +require("lazy").setup({ + spec = { + -- mini + { + "echasnovski/mini.basics", + opts = { + options = { basic = true, extra_ui = true }, + mappings = { move_with_alt = true }, + }, + }, + { + "smoka7/hop.nvim", + opts = {}, + keys = { + { "", "HopWord", mode = { "n", "v" }, silent = true, noremap = true }, + { "", "HopAnywhere", mode = { "n", "v" }, silent = true, noremap = true }, + }, + }, + { + "echasnovski/mini.icons", + opts = {}, + }, + { + -- folder tree + "nvim-neo-tree/neo-tree.nvim", + version = "*", + lazy = false, + dependencies = { "nvim-lua/plenary.nvim", "mini.icons", "MunifTanjim/nui.nvim" }, + opts = {}, + keys = { { "", "Neotree", noremap = true } }, + }, + { + "echasnovski/mini.surround", + version = "*", + opts = {}, + }, + { + "echasnovski/mini.bufremove", + opts = {}, + keys = { + { "", function() require("mini.bufremove").wipeout() end, noremap = true }, + { "", function() require("mini.bufremove").wipeout(nil, true) end, noremap = true }, + }, + }, + -- snacks + { + "folke/snacks.nvim", + priority = 1000, + lazy = false, + ---@type snacks.Config + opts = { + bigfile = { + enabled = true, + notify = true, -- show notification when big file detected + size = 1.5 * 1024 * 1024, -- 1.5MB + line_length = 1000, -- average line length (useful for minified files) + -- Enable or disable features when big file detected + ---@param ctx {buf: number, ft:string} + setup = function(ctx) + if vim.fn.exists(":NoMatchParen") ~= 0 then vim.cmd([[NoMatchParen]]) end + Snacks.util.wo(0, { foldmethod = "manual", statuscolumn = "", conceallevel = 0 }) + vim.schedule(function() + if vim.api.nvim_buf_is_valid(ctx.buf) then vim.bo[ctx.buf].syntax = ctx.ft end + end) + end, + }, + notifier = { enabled = true }, + indent = { enabled = true }, + quickfile = { enabled = true }, + }, + }, + -- div utils + "tpope/vim-eunuch", -- Move, Rename etc + "dhruvasagar/vim-table-mode", -- tables + "itchyny/vim-qfedit", -- editable quickfix list + "mbbill/undotree", + { + -- keep location upon reopening + "ethanholz/nvim-lastplace", + opts = {}, + }, + { + -- tmux / vim interop + "christoomey/vim-tmux-navigator", + cmd = { + "TmuxNavigateLeft", + "TmuxNavigateDown", + "TmuxNavigateUp", + "TmuxNavigateRight", + "TmuxNavigatePrevious", + "TmuxNavigatorProcessList", + }, + keys = { + { "", "TmuxNavigateLeft" }, + { "", "TmuxNavigateDown" }, + { "", "TmuxNavigateUp" }, + { "", "TmuxNavigateRight" }, + { "", "TmuxNavigatePrevious" }, + }, + init = function() + vim.g.tmux_navigator_no_mappings = 1 + vim.g.tmux_navigator_disable_when_zoomed = 1 + end, + }, + { + -- live preview of markdown files + "iamcco/markdown-preview.nvim", -- requires yarn + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + ft = { "markdown" }, + build = function() vim.fn["mkdp#util#install"]() end, + init = function() + vim.g.mkdp_auto_start = 0 -- auto start on moving into + vim.g.mkdp_auto_close = 0 -- auto close on moving away + vim.g.mkdp_open_to_the_world = 1 -- available to others + vim.g.mkdp_port = 10010 + vim.g.mkdp_echo_preview_url = 1 + vim.g.mkdp_preview_options = { disable_sync_scroll = 1 } + end, + }, + { + -- search count > 99 + "kevinhwang91/nvim-hlslens", + dependencies = { "haya14busa/vim-asterisk" }, + opts = { nearest_only = true }, + keys = { + { "*", [[(asterisk-z*)lua require('hlslens').start()]], mode = { "n", "x" }, {} }, + { "#", [[(asterisk-z#)lua require('hlslens').start()]], mode = { "n", "x" }, {} }, + { "g*", [[(asterisk-gz*)lua require('hlslens').start()]], mode = { "n", "x" }, {} }, + { "g#", [[(asterisk-gz#)lua require('hlslens').start()]], mode = { "n", "x" }, {} }, + { + "n", + [[nlua require('hlslens').start()]], + mode = { "n", "x" }, + noremap = true, + silent = true, + }, + { + "N", + [[Nlua require('hlslens').start()]], + mode = { "n", "x" }, + noremap = true, + silent = true, + }, + }, + init = function() vim.g["asterisk#keeppos"] = 1 end, + }, + { + "catgoose/nvim-colorizer.lua", + event = "BufReadPre", + opts = { user_default_options = { mode = "virtualtext" } }, + }, + -- theme dark and light + "NLKNguyen/papercolor-theme", + "junegunn/seoul256.vim", + { + "mhartington/oceanic-next", + config = function() + local customthemegroup = vim.api.nvim_create_augroup("customthemegroup", {}) + vim.api.nvim_create_autocmd("ColorScheme", { + pattern = { "OceanicNext" }, + group = customthemegroup, + callback = function() + vim.api.nvim_set_hl(0, "DiffAdded", { default = false, link = "DiffAdd" }) + vim.api.nvim_set_hl(0, "DiffRemoved", { default = false, link = "DiffDelete" }) + vim.api.nvim_set_hl(0, "Normal", {}) + vim.api.nvim_set_hl(0, "LineNr", {}) + vim.api.nvim_set_hl(0, "SignColumn", {}) + vim.api.nvim_set_hl(0, "EndOfBuffer", {}) + end, + }) + end, + }, + "morhetz/gruvbox", + { + "sonph/onehalf", + lazy = false, + config = function(plugin) vim.opt.rtp:append(plugin.dir .. "/vim") end, + }, + { + "catppuccin/nvim", + lazy = false, + name = "catppuccin", + priority = 1000, + config = function() vim.cmd([[colorscheme catppuccin-mocha]]) end, + }, + { + "Shatur/neovim-ayu", + init = function() vim.g.ayu_extended_palette = 1 end, + }, + -- theme dark only + "tomasr/molokai", + "jnurmine/Zenburn", + -- status + buffer lines + { + "nvim-lualine/lualine.nvim", + dependencies = { "echasnovski/mini.icons", "folke/noice.nvim" }, + opts = { + options = { theme = "auto", globalstatus = false }, + extensions = { "fugitive" }, + sections = { + lualine_a = { { "mode", color = { bg = "goldenrod" } } }, + lualine_b = { "branch" }, + lualine_c = { + { + "filename", + file_status = true, + path = 1, + shorting_target = 0, + }, + { "diff", colored = true }, + }, + lualine_x = { + { + function() require("noice").api.status.command.get() end, + cond = function() require("noice").api.status.command.has() end, + }, + { + function() require("noice").api.status.mode.get() end, + cond = function() require("noice").api.status.mode.has() end, + }, + }, + lualine_y = { "filetype", "progress" }, + lualine_z = { "location" }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { + { + "filename", + file_status = true, + path = 1, + shorting_target = 0, + }, + { "diff", colored = true }, + }, + lualine_x = {}, + lualine_y = { "filetype", "progress" }, + lualine_z = { "location" }, + }, + tabline = { + lualine_a = { + { + "buffers", + symbols = { alternate_file = "" }, + buffers_color = { + active = { bg = "goldenrod" }, + }, + }, + }, + lualine_b = {}, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = { + { + "tabs", + mode = 2, + tabs_color = { + active = { bg = "goldenrod" }, + }, + }, + }, + }, + }, + }, + -- git related plugins + { + "tpope/vim-fugitive", + config = function() + vim.api.nvim_create_autocmd("User", { + pattern = { "FugitiveCommit", "BufReadPost" }, + callback = function() + vim.opt.foldmethod = "syntax" + vim.opt.foldlevel = 0 + end, + }) + end, + keys = { + { "", "vertical Git" }, + { "gB", "Git blame" }, + { "gp", "Git! push" }, + { "gP", "Git! push -f" }, + }, + }, + { + "rbong/vim-flog", + dependencies = { "tpope/vim-fugitive" }, + cmd = { "Flog", "Flogsplit", "Floggit" }, + config = function() + vim.g.flog_permanent_default_opts = { + -- format = "%ad [%h] {%an}%d %s", + format = "%ad [%h]%d %s", + date = "short", + } + end, + keys = { + { "gl", "vertical Flogsplit -path=%" }, + { "gL", "vertical Flogsplit" }, + }, + }, + { + "lewis6991/gitsigns.nvim", + opts = { + signcolumn = true, + numhl = true, + linehl = false, + word_diff = false, + signs_staged_enable = false, + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map("n", "", function() + if vim.wo.diff then return "]c" end + vim.schedule(function() gs.next_hunk() end) + return "" + end, { expr = true }) + + map("n", "", function() + if vim.wo.diff then return "[c" end + vim.schedule(function() gs.prev_hunk() end) + return "" + end, { expr = true }) + + -- Actions + map({ "n", "v" }, "gs", ":Gitsigns stage_hunk") + map({ "n", "v" }, "gx", ":Gitsigns reset_hunk") + map("n", "gu", gs.undo_stage_hunk) + map("n", "gi", gs.preview_hunk) + map("n", "gb", function() gs.blame_line({ full = true }) end) + map("n", "gd", gs.diffthis) + map("n", "gS", gs.stage_buffer) + map("n", "gX", gs.reset_buffer) + map("n", "td", gs.toggle_deleted) + map("n", "tl", gs.toggle_linehl) + map("n", "tb", gs.toggle_current_line_blame) + map("n", "th", gs.toggle_word_diff) + map("n", "tn", gs.toggle_numhl) + + -- Text object + map({ "o", "x" }, "ih", "Gitsigns select_hunk") + end, + }, + }, + { -- helplists + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = { + signs = true, -- show icons in the signs column + sign_priority = 8, -- sign priority + -- keywords recognized as todo comments + keywords = { + ERROR = { icon = " ", color = "error" }, + WIP = { icon = " ", color = "warning" }, + TODO = { icon = " ", color = "warning" }, + PERF = { icon = " ", color = "info" }, + TEST = { icon = " ", color = "info" }, + MAYBE = { icon = " ", color = "default" }, + IDEA = { icon = " ", color = "hint" }, + }, + merge_keywords = false, -- when true, custom keywords will be merged with the defaults + highlight = { keyword = "bg", pattern = [[<(KEYWORDS)\s*]] }, + search = { pattern = [[\b(KEYWORDS)\b]] }, + colors = { + error = { "#ba1a1a" }, + warning = { "#FFC107" }, + info = { "#91BED0" }, + hint = { "#10B981" }, + default = { "#91D0C1" }, + }, + }, + keys = { { "", "TodoQuickFix", noremap = true } }, + }, + { + -- Fuzzy Finder (files, lsp, etc) + "nvim-telescope/telescope.nvim", + version = "*", + dependencies = { + "sharkdp/fd", + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope-live-grep-args.nvim", + }, + keys = { + { + "", + function() require("telescope.builtin").find_files({ layout_config = { width = 0.99 } }) end, + noremap = true, + }, + { + "", + function() require("telescope.builtin").git_files({ layout_config = { width = 0.99 } }) end, + noremap = true, + }, + { + "", + function() + require("telescope.builtin").diagnostics({ + layout_strategy = "vertical", + layout_config = { width = 0.99 }, + }) + end, + noremap = true, + }, + { + "", + "Telescope live_grep ", + function() + require("telescope.builtin").live_grep({ + layout_strategy = "vertical", + layout_config = { width = 0.99 }, + }) + end, + noremap = true, + }, + { + "", + function() require("telescope").extensions.live_grep_args.live_grep_args() end, + noremap = true, + }, + { "", function() require("telescope.builtin").filetypes() end, noremap = true }, + { "", function() require("telescope.builtin").search_history() end, noremap = true }, + { + "", + function() + require("telescope.builtin").colorscheme({ + layout_config = { width = 0.5 }, + enable_preview = true, + ignore_builtins = true, + }) + end, + noremap = true, + }, + }, + config = function() + -- TODO grep with regex + local actions = require("telescope.actions") + require("telescope").setup({ + defaults = { + layout_config = { horizontal = { width = 0.99 } }, + mappings = { + i = { + [""] = "close", + [""] = "select_default", + [""] = "move_selection_next", + [""] = "move_selection_previous", + [""] = "preview_scrolling_up", + [""] = "preview_scrolling_down", + [""] = "select_horizontal", + [""] = "select_vertical", + [""] = "select_tab", + [""] = actions.toggle_selection + actions.move_selection_worse, + [""] = actions.toggle_selection + actions.move_selection_better, + [""] = actions.send_to_loclist + actions.open_loclist, + [""] = actions.send_selected_to_loclist + actions.open_loclist, + [""] = "results_scrolling_up", + [""] = "results_scrolling_down", + }, + }, + file_ignore_patterns = {}, + set_env = { ["COLORTERM"] = "truecolor" }, + }, + }) + end, + }, + { + "kevinhwang91/nvim-ufo", + dependencies = { "kevinhwang91/promise-async" }, + opts = { + preview = { + mappings = { + scrollU = "", + scrollD = "", + jumpTop = "[", + jumpBot = "]", + }, + }, + fold_virt_text_handler = function(virtText, lnum, endLnum, width, truncate) + local newVirtText = {} + local suffix = (" 󰁂 %d "):format(endLnum - lnum) + local sufWidth = vim.fn.strdisplaywidth(suffix) + local targetWidth = width - sufWidth + local curWidth = 0 + for _, chunk in ipairs(virtText) do + local chunkText = chunk[1] + local chunkWidth = vim.fn.strdisplaywidth(chunkText) + if targetWidth > curWidth + chunkWidth then + table.insert(newVirtText, chunk) + else + chunkText = truncate(chunkText, targetWidth - curWidth) + local hlGroup = chunk[2] + table.insert(newVirtText, { chunkText, hlGroup }) + chunkWidth = vim.fn.strdisplaywidth(chunkText) + -- str width returned from truncate() may less than 2nd argument, need padding + if curWidth + chunkWidth < targetWidth then + suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth) + end + break + end + curWidth = curWidth + chunkWidth + end + table.insert(newVirtText, { suffix, "MoreMsg" }) + return newVirtText + end, + }, + keys = { + -- zm/M zr/R increase/increase foldlevel (max) + -- zo/O zc/C open / close fold (max) + -- za zA switch fold (small/full) + -- zi toggle folds + -- zi zj move to next / prev fold + { + "zR", + function() require("ufo").openAllFolds() end, + }, + { + "zM", + function() require("ufo").closeAllFolds() end, + }, + { + "zm", + function() require("ufo").closeFoldsWith() end, + }, + { + "zr", + function() require("ufo").openFoldsExceptKinds() end, + }, + }, + init = function() + vim.o.foldcolumn = "0" + vim.o.foldlevel = 99 + vim.o.foldlevelstart = 99 + vim.o.foldenable = true + end, + }, + { + -- Highlight, edit, and navigate code + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + opts = { + { + ensure_installed = { "c", "cpp", "lua", "vimdoc", "gitcommit", "git_rebase", "bash", "python" }, + auto_install = true, + highlight = { enable = true }, + indent = { enable = true, disable = { "python" }, additional_vim_regex_highlighting = { "python" } }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_decremental = "", + node_incremental = "", + scope_incremental = "", + }, + }, + }, + }, + config = function() vim.opt.foldexpr = "nvim_treesitter#foldexpr()" end, + }, + { + "windwp/nvim-ts-autotag", + dependencies = { "nvim-treesitter/nvim-treesitter" }, + opts = { filetypes = { "html", "xml" } }, + }, + -- package manager + lsp stuff + { + "williamboman/mason.nvim", + opts = {}, + keys = { { "", "Mason", noremap = true } }, + }, + { + "mfussenegger/nvim-lint", + config = function() + require("lint").linters_by_ft = { + javascript = { "eslint_d" }, + typescript = { "eslint_d" }, + html = { "tidy", "eslint_d" }, + } + vim.api.nvim_create_autocmd({ "BufWritePost", "TextChanged" }, { + callback = function() require("lint").try_lint() end, + }) + end, + }, + { + "mhartington/formatter.nvim", -- TODO move to conform + -- Utilities for creating configurations, + keys = { + { "f", ":Format", silent = true, noremap = true }, + { "F", ":FormatWrite", silent = true, noremap = true }, + }, + config = function() + local util = require("formatter.util") + require("formatter").setup({ + logging = true, + log_level = vim.log.levels.DEBUG, + filetype = { + python = { + function() + return { + exe = "ruff", + args = { "check", "--select I,F,UP", "--fix-only", "-" }, + stdin = true, + } + end, + function() + return { + exe = "ruff", + args = { "format", "-" }, + stdin = true, + } + end, + }, + lua = { + function() + return { + exe = "stylua", + args = { + "--search-parent-directories", + "--indent-type Spaces", + "--collapse-simple-statement Always", + "--stdin-filepath", + util.escape_path(util.get_current_buffer_file_path()), + "--", + "-", + }, + stdin = true, + } + end, + }, + yaml = { + function() + return { + exe = "yamlfmt", + args = { + "-formatter indentless_arrays=true,retain_line_breaks=true,line_ending=lf,max_line_length=100,pad_line_comments=2", + "-in", + }, + stdin = true, + } + end, + }, + typescript = { + function() + local util = require("formatter.util") + return { + exe = "eslint_d", + args = { + "--stdin", + "--debug", + "--stdin-filename", + util.escape_path(util.get_current_buffer_file_path()), + "--fix-to-stdout", + }, + stdin = true, + try_node_modules = true, + ignore_exitcode = true, + } + end, + }, + go = { require("formatter.filetypes.go").gofumpt, require("formatter.filetypes.go").golines }, + sh = { require("formatter.filetypes.sh").shfmt }, + javascript = { require("formatter.filetypes.javascript").prettierd }, + html = { require("formatter.filetypes.html").prettierd }, + css = { require("formatter.filetypes.css").prettierd }, + markdown = { require("formatter.filetypes.markdown").prettierd }, + json = { require("formatter.filetypes.json").jq }, + ["*"] = { require("formatter.filetypes.any").remove_trailing_whitespace }, + }, + }) + end, + }, + { + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "kevinhwang91/nvim-ufo", + }, + keys = { { "", "LspInfo", noremap = true } }, + config = function() + local on_attach = function(client, bufnr) + local bmap = function(mode, keys, func) + vim.keymap.set(mode, keys, func, { buffer = bufnr, noremap = true }) + end + -- workspaces + bmap("n", "wa", vim.lsp.buf.add_workspace_folder) + bmap("n", "wr", vim.lsp.buf.remove_workspace_folder) + bmap("n", "wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end) + -- jump + bmap("n", "", function() vim.diagnostic.open_float({ source = true }) end) + bmap( + "n", + "", + function() + vim.diagnostic.jump({ + severity = { min = vim.diagnostic.severity.HINT }, + float = true, + count = 1, + }) + end + ) + bmap( + "n", + "", + function() + vim.diagnostic.jump({ + severity = { min = vim.diagnostic.severity.HINT }, + float = true, + count = -1, + }) + end + ) + bmap("n", "gd", vim.lsp.buf.definition) + bmap("n", "gD", vim.lsp.buf.type_definition) + bmap("n", "gi", vim.lsp.buf.declaration) + bmap("n", "gI", vim.lsp.buf.implementation) + -- quickfix + bmap("n", "gl", vim.diagnostic.setloclist) + bmap("n", "gr", vim.lsp.buf.references) + -- popups + bmap({ "n", "i" }, "", vim.lsp.buf.signature_help) + -- other + bmap("n", "K", function() + local winid = require("ufo").peekFoldedLinesUnderCursor() + if not winid then vim.lsp.buf.hover() end + end) + bmap("n", "", vim.lsp.buf.rename) + bmap("n", "ca", vim.lsp.buf.code_action) + end + + local server_configs = { + pyright = { + python = { + analysis = { autoImportCompletions = false, diagnosticMode = "openFilesOnly" }, + }, + }, + lua_ls = { + Lua = { + workspace = { + checkThirdParty = false, + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + }, + telemetry = { enable = false }, + diagnostics = { + -- Get the language server to recognize the `vim` global in init.lua + globals = { "vim", "core" }, + }, + format = { enable = false }, + }, + }, + html = { + html = { + format = { + templating = true, + wrapLineLength = 120, + wrapAttributes = "auto", + }, + hover = { + documentation = true, + references = true, + }, + }, + }, + yamlls = { + yaml = { + schemas = { kubernetes = "/home/hjalmarlucius/src/hjarl/system/manifests/*.yaml" }, + -- schemaStore = { enable = false, url = "" }, + }, + }, + } + + local capabilities = vim.lsp.protocol.make_client_capabilities() + + local ufo = require("ufo") + if ufo then + capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, + } + end + + local mason_lspconfig = require("mason-lspconfig") + mason_lspconfig.setup({ + ensure_installed = { + "cssls", + "html", + "jsonls", + "yamlls", + "bashls", + "pyright", + "lua_ls", + }, + }) + mason_lspconfig.setup_handlers({ + function(server_name) + require("lspconfig")[server_name].setup({ + capabilities = capabilities, + on_attach = on_attach, + settings = server_configs[server_name], + }) + end, + }) + end, + }, + { + "folke/noice.nvim", + dependencies = { "MunifTanjim/nui.nvim" }, + opts = { + cmdline = { enabled = true, view = "cmdline_popup" }, + messages = { + enabled = true, -- enables the Noice messages UI + view = "mini", -- default view for messages + view_error = "notify", -- view for errors + view_warn = "mini", -- view for warnings + view_history = "popup", -- view for :messages + view_search = false, + }, + popupmenu = { enabled = true }, + notify = { enabled = true, view = "mini" }, + lsp = { + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + }, + progress = { enabled = false }, + hover = { enabled = true }, + signature = { enabled = true, auto_open = { enabled = true, throttle = 0 } }, + message = { enabled = true, view = "notify" }, + documentation = { view = "hover" }, + }, + -- you can enable a preset for easier configuration + presets = { + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + }, + routes = { + { filter = { event = "msg_show", kind = "search_count" }, opts = { skip = true } }, + { filter = { kind = "", min_height = 2 }, view = "split" }, + }, + }, + }, + }, + install = { colorscheme = { "habamax" } }, + checker = { enabled = true }, }) -vim.cmd("colorscheme catppuccin-mocha")