diff options
| Commit | c9ca8a09dc3a5e421c50dc3cfa16c573a3e87135 (patch) | |
|---|---|---|
| Author | 2026-11-01 22:51:04 +0200 | |
| Committer | 2026-11-01 22:51:18 +0200 | |
| Files | ec3e06cdc9099838406b918f5b9347eee46adf88 /nvim/.nvim/lua/plugins | |
| .files-main.tar .files-main.tar.gz .files-main.zip | ||
| Parent | 72d71324e1063d4d7402180e846aeff3056ba177 (diff) | |
Latest version from https://git.syndamia.com/conf/anderson (and formerly
https://gitlab.com/Syndamia/anderson).
Not edited in 7 months.
3 files changed, 562 insertions, 0 deletions
| -rw-r--r-- | nvim/.nvim/lua/plugins/default.lua | 162 | ||||
| -rw-r--r-- | nvim/.nvim/lua/plugins/heirline.lua | 262 | ||||
| -rw-r--r-- | nvim/.nvim/lua/plugins/lsp.lua | 138 |
diff --git a/nvim/.nvim/lua/plugins/default.lua b/nvim/.nvim/lua/plugins/default.lua new file mode 100644 index 0000000..fb70f8d --- /dev/null +++ b/nvim/.nvim/lua/plugins/default.lua @@ -0,0 +1,162 @@ +local _, builtin = pcall(require, 'telescope.builtin') +return { + --[=[ Visuals ]=]-- + { + "morhetz/gruvbox", -- Color theme + lazy = false, + priority = 1000, + init = function() + vim.o.background = "dark" + vim.g.gruvbox_contrast_dark = "hard" + vim.opt.termguicolors = false; + end, + config = function(_, opts) + vim.cmd("colorscheme gruvbox") + end, + }, + { + "https://gitlab.com/Syndamia/gruvbox-highlight.nvim", + dependencies = { "morhetz/gruvbox" }, + lazy = false, + priority = 1, + opts = { + text = false, + markup = { + underline = false, + }, + }, + }, + + --[=[ Quality of life ]=]-- + + --[==[ + { + "preservim/nerdtree", -- Browse directories + dependencies = { + "ryanoasis/vim-devicons", + }, + keys = {{ "<Tab>", ":NERDTreeToggle<CR>" }}, + init = function() + vim.g.NERDTreeShowHidden = 1 + vim.g.NERDTreeWinPos = "right" + vim.g.NERDTreeIgnore = { "\\.swp$", "\\~$" } -- Ignore file, ending with .swp and ~ + end, + }, + --]==] + { + "nvim-tree/nvim-web-devicons", -- NERDFont icons + }, + { + "luukvbaal/nnn.nvim", + keys = { + { "<Tab>", ":NnnExplorer<CR>", mode = "n", }, + }, + config = true, + opts = { + explorer = { + cmd = "nnn -dHoJ", + width = 31; + side = "botright", + fullscreen = false, + }, + }, + }, + { + "numToStr/Comment.nvim", -- Toggle comments + opts = {}, + }, + { + "mbbill/undotree", -- Easily interact with undo history + keys = {{ "<F5>", ":UndotreeToggle<CR>" }}, + init = function() + vim.g.undotree_WindowLayout = 2 + vim.g.undotree_ShortIndicators = 1 -- e.g. using 'd' instead of 'days' to save some space. + vim.g.undotree_SetFocusWhenToggle = 1 -- if set, let undotree window get focus after being opened, otherwise focus will stay in current window. + vim.g.undotree_TreeNodeShape = '*' + vim.g.undotree_DiffCommand = "diff" + end, + }, + { + "godlygeek/tabular", -- Line up text to a given character + }, + { + "tpope/vim-eunuch", -- UNIX commands in vim + }, + { + "kylechui/nvim-surround", -- Surround text + version = "*", + event = "VeryLazy", + dependencies = { + "nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter-textobjects" + }, + opts = {}, + }, + { + "windwp/nvim-ts-autotag", -- Auto-add and edit HTML tags + }, + { + "ntpeters/vim-better-whitespace", -- Highlight in red trailing whitespaces + }, + { + "https://gitlab.com/Syndamia/dunbar", + }, + + --[=[ Development-specific ]=]-- + { + "zivyangll/git-blame.vim", -- Show last commit on line + keys = {{ "<F8>", ":<C-u>call gitblame#echo()<CR>" }}, + }, + { + "wakatime/vim-wakatime", -- WakaTime tracking + lazy = false, + }, + { + "nvim-neorg/neorg", + lazy = true, + ft = "norg", + version = "8.9.0", -- Last version to support versions <nvim-0.9 + config = true, + opts = { + load = { + ["core.defaults"] = {}, + ["core.concealer"] = { config = { -- Display markup as icons + icon_preset = "varied", + }}, + ["core.export"] = {}, + ["core.export.markdown"] = {}, + -- ["core.presenter"] = {}, -- Requires zen mode + -- ["core.text-objects"] = {}, -- Requires >=nvim-0.10 + ["core.esupports.metagen"] = {}, -- Autoplace metadata + }, + }, + }, + { "noir-lang/noir-nvim", lazy = false }, + { + "nvim-telescope/telescope.nvim", + config = true, + opts = { + layout_strategy = 'horizontal', + defaults = { + layout_config = { + prompt_position = 'top', + } + }, + }, + }, + { + 'FahimAnayet/changes.nvim', + config = function() + require('changes').setup({ + autocmd = true, + vcs_check = true, + vcs_system = '', -- 'git', 'hg', or '' for auto-detect + sign_text_utf8 = false, + use_icons = true, + linehi_diff = false, + }) + require('changes').enable() + vim.keymap.set('n', ';', '<cmd>ChangesToggle<cr>') + end, + event = { 'BufReadPost', 'BufNewFile' }, + }, +} diff --git a/nvim/.nvim/lua/plugins/heirline.lua b/nvim/.nvim/lua/plugins/heirline.lua new file mode 100644 index 0000000..cd7fbd2 --- /dev/null +++ b/nvim/.nvim/lua/plugins/heirline.lua @@ -0,0 +1,262 @@ +return { + "rebelot/heirline.nvim", + lazy = false, + event = "UiEnter", + opts = function() + local utils = require("heirline.utils") + local conditions = require("heirline.conditions") + + --[=[ Helpers ]=]-- + + function inverseColors(highlight) + if highlight == nil then return nil end + + if type(highlight) == "string" then + highlight = utils.get_highlight(highlight) + end + + highlight.cterm = { reverse = true } + return highlight + end + + local delimiters = { + FilledCircle = { "", "" }, + Circle = { "", "" }, + } + local StatusLineColor = utils.get_highlight("StatusLine") + + function surround(delimiters, component, additional_update) + return { + init = function(self) + local highlight + if component.hl ~= nil and type(component.hl) == "function" then + if component.init ~= nil then + component:init() + end + highlight = component:hl() + else + highlight = component.hl + end + + self.inverse = inverseColors(highlight) + self.inverse.ctermfg = StatusLineColor.ctermfg -- Actually sets bg, but both are reversed + end, + + { + condition = function() return conditions.is_active() end, + provider = delimiters[1], + hl = function(self) return self.inverse end, + }, + component, + { + condition = function() return conditions.is_active() end, + provider = delimiters[2], + hl = function(self) return self.inverse end, + }, + + update = { "BufEnter", "BufLeave", additional_update }, + } + end + + function set_hl(name, val) + val.nocombine = true + vim.api.nvim_set_hl(0, name, val) + return val + end + + --[=[ Common elements ]=]-- + + local FileStat = { + { + condition = function() + return vim.bo.readonly + end, + provider = "", + }, + { + condition = function() + return vim.bo.modified or not vim.bo.modifiable + end, + provider = function(self) + local prepend = vim.bo.readonly and " " or "" + if vim.bo.modified then return prepend.."" end + if not vim.bo.modifiable then return prepend.."" end + end, + }, + } + + local FileType = { + static = { + get_icon = require("nvim-web-devicons").get_icon_by_filetype, + }, + provider = function(self) + local icon = self.get_icon(vim.bo.filetype) + if icon ~= nil then icon = icon.." " + else icon = "" + end + return icon..vim.bo.filetype + end, + update = "FileType", + } + + local Filename = { provider = "%f", } + local Space = { provider = " ", } + + --[=[ Statusline ]=]-- + + set_hl("ModeNormal", { ctermfg = 236, ctermbg = 117 }) + set_hl("ModeInsert", { ctermfg = 236, ctermbg = 119 }) + set_hl("ModeReplace", { ctermfg = 236, ctermbg = 203 }) + set_hl("ModeVisual", { ctermfg = 236, ctermbg = 216 }) + + local Mode = surround(delimiters.FilledCircle, { + init = function(self) + self.modestr = vim.fn.mode(1) + if self.modestr == "\22" then self.modestr = "V^" + elseif self.modestr == "\22s" then self.modestr = "V^s" + end + end, + + provider = function(self) + if not conditions.is_active() then return " " end + return self.modestr + end, + hl = function(self) + if not conditions.is_active() then return "StatusLineNC" end + + local modeletter = self.modestr:sub(1,1):lower() + + if modeletter == "i" then return "ModeInsert" + elseif modeletter == "r" then return "ModeReplace" + elseif modeletter == "v" then return "ModeVisual" + end + + return "ModeNormal" + end, + }, "ModeChanged") + + + set_hl("RowAndColumn", { ctermfg = 238, ctermbg = 244 }) + + local LineAndColumn = surround(delimiters.FilledCircle, { + provider = function(self) + if not conditions.is_active() then + local row,col = unpack(vim.api.nvim_win_get_cursor(0)) + return string.rep(" ", 1 + tostring(row):len() + tostring(col):len()) + end + return "%l:%c" + end, + hl = function(self) + if not conditions.is_active() then return "StatusLineNC" end + return "RowAndColumn" + end, + }) + + local LeftShrink = { provider = "%<", } + local LeftSep = { provider = " "..delimiters.Circle[2].." " } + local RightSep = { provider = " "..delimiters.Circle[1].." " } + local ExpandMiddle = { provider = "%=", } + local CursorChar = { provider = "%b", } + + local StatusLine = { + Mode, LeftShrink, Space, Filename, LeftSep, FileStat, + ExpandMiddle, + CursorChar, RightSep, FileType, Space, LineAndColumn + } + + --[=[ Tabline ]=]-- + local hl_TabLine = set_hl("TabLine", { ctermfg = 252, ctermbg = 242 }) + local hl_TabLineSel = set_hl("TabLineSel", { ctermfg = 252, ctermbg = 235 }) + local hl_TabLineFill = set_hl("TabLineFill", { ctermfg = 248, ctermbg = 238 }) + set_hl("TabLineRFR", { ctermfg = hl_TabLine.ctermbg, ctermbg = hl_TabLineFill.ctermbg }) -- nonactive Right Full, Rightmost + set_hl("TabLineSelRF", { ctermfg = hl_TabLineSel.ctermbg, ctermbg = hl_TabLine.ctermbg }) -- active Right Full + set_hl("TabLineSelRFR", { ctermfg = hl_TabLineSel.ctermbg, ctermbg = hl_TabLineFill.ctermbg }) -- active Right Full, Rightmost + set_hl("TabLineSelLF", { ctermfg = hl_TabLine.ctermbg, ctermbg = hl_TabLineSel.ctermbg }) -- active Left Full (left one's Right Full) + + local TabPage = { + init = function(self) + self.pages = vim.api.nvim_list_tabpages() + end, + { + static = { + get_icon = require("nvim-web-devicons").get_icon, + ft_icon = require("nvim-web-devicons").get_icon_by_filetype, + none_icon = "", + }, + init = function(self) + self.bufnr = vim.api.nvim_win_get_buf(vim.api.nvim_tabpage_get_win(self.tabpage)) + end, + provider = function(self) + --[==[ Filename ]==]-- + local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(self.bufnr), ":t") + if #filename == 0 then filename = "[No Name]" end + + local max_name_len = vim.o.columns / (5 + #self.pages) + filename = (self.get_icon(filename, vim.fn.fnamemodify(filename, ":e")) or self.ft_icon(vim.bo[self.bufnr].filetype) or self.none_icon) .. + " " .. string.sub(filename, 1, max_name_len) + + --[==[ Readonly ]==]-- + local readonly = vim.bo[self.bufnr].readonly and " " or "" + + --[==[ Modification ]==]-- + local mod = vim.bo[self.bufnr].modified and " " + or (vim.bo[self.bufnr].modifiable and "" or " ") + + --[==[ Tab ]==]-- + return + "%" .. self.tabnr .. "T" .. + " " .. + filename .. readonly .. mod .. + " " + end, + hl = function(self) + if not self.is_active then + return "TabLine" + else + return "TabLineSel" + end + end, + }, + { + init = function(self) + local activenr = vim.api.nvim_tabpage_get_number(vim.api.nvim_get_current_tabpage()) + + self.dist = self.tabnr - activenr + self.last = self.tabnr == #self.pages + end, + provider = function(self) + return (self.last or self.dist == -1 or self.dist == 0) + and delimiters.FilledCircle[2] or delimiters.Circle[2] + end, + hl = function(self) + if not self.is_active then + return self.last and "TabLineRFR" or (self.dist == -1 and "TabLineSelLF" or "TabLine") + else + return self.last and "TabLineSelRFR" or "TabLineSelRF" + end + end, + }, + { + provider = "%T" + } + } + + local TabPages = { + -- only show this component if there's 2 or more tabpages + condition = function() + return #vim.api.nvim_list_tabpages() >= 2 + end, + utils.make_tablist(TabPage), + } + + local TabLine = { + TabPages, + } + + --[=[ Setup ]=]-- + return { + statusline = StatusLine, + tabline = TabLine, + } + end, +} diff --git a/nvim/.nvim/lua/plugins/lsp.lua b/nvim/.nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..176bd84 --- /dev/null +++ b/nvim/.nvim/lua/plugins/lsp.lua @@ -0,0 +1,138 @@ +-- Thanks https://stackoverflow.com/a/70760302/12036073 +vim.o.updatetime = 600 +vim.diagnostic.config({ + virtual_text = false, + float = { focus = false }, +}) +vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { callback = function(ev) + vim.diagnostic.open_float(nil) +end}) + +return { + -- Syntax parsing (for highlighting) + { + "nvim-treesitter/nvim-treesitter", + branch = "master", + lazy = false, + build = ":TSUpdate", + opts = { + ensure_installed = "all", + ignore_install = { "liquidsoap", "tlaplus", "yaml", "ipkg" }, -- Can't compile + highlight = { enable = true }, + incremental_selection = { enable = true }, + textobjects = { enable = true }, + }, + config = function(_, opts) + require("nvim-treesitter.configs").setup(opts) + end, + }, + -- LSP server utilisation + { + "neovim/nvim-lspconfig", + dependencies = { 'VonHeikemen/lsp-zero.nvim', 'williamboman/mason-lspconfig.nvim' }, + lazy = false, + opts = { -- :h lspconfig-all + -- awk_ls = { }, + bashls = { }, + lua_ls = { }, + rust_analyzer = { }, + }, + config = function(_, opts) + for k,v in pairs(opts) do + vim.lsp.config(k, v) + end + end, + }, + -- Auto-completion + { + 'hrsh7th/cmp-nvim-lsp', + config = true, + lazy = true + }, + { + 'hrsh7th/nvim-cmp', + dependencies = { 'hrsh7th/vim-vsnip' }, + lazy = false, + opts = { + sources = { { name = 'nvim_lsp' } }, + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + }, + config = function(_, opts) + local cmp = require('cmp') + opts.mapping = cmp.mapping.preset.insert({ + -- -- `Enter` key to confirm completion + ['<Tab>'] = cmp.mapping.confirm({select = false}), + -- + -- -- Ctrl+Space to trigger completion menu + ['<C-Space>'] = cmp.mapping.complete(), + -- + -- -- Navigate between snippet placeholder + -- ['<C-f>'] = cmp_action.vim_snippet_jump_forward(), + -- ['<C-b>'] = cmp_action.vim_snippet_jump_backward(), + -- + -- -- Scroll up and down in the completion documentation + -- ['<C-u>'] = cmp.mapping.scroll_docs(-4), + -- ['<C-d>'] = cmp.mapping.scroll_docs(4), + }) + cmp.setup(opts) + end, + }, + -- Helper functions + { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v3.x', + lazy = true, + dependencies = { 'hrsh7th/cmp-nvim-lsp' }, + opts = { + sign_text = true, + capabailities = "", + lsp_attach = function(event) + local opts = { silent = true, buffer = event.buf } + + vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts) + vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts) + vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts) + vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts) + vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts) + vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts) + vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts) + vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts) + vim.keymap.set({'n', 'x'}, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts) + vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts) + end, + }, + config = function(_, opts) + opts.capabilities = require('cmp_nvim_lsp').default_capabilities() + vim.api.nvim_create_autocmd('LspAttach', { + desc = 'Lsp Actions', + callback = opts.lsp_attach, + }) + require("lsp-zero").extend_lspconfig(opts) + end, + }, + -- Download plugins automatically + { + 'williamboman/mason-lspconfig.nvim', + dependencies = { 'neovim/nvim-lspconfig' }, + lazy = true, + opts = { + automatic_installation = true, + handlers = { + function(server_name) + vim.lsp.config(server_name, {}) + end, + }, + }, + }, + { + 'williamboman/mason.nvim', + lazy = false, + opts = { + PATH = "append", + }, + }, +} |
