diff options
| Commit | c9ca8a09dc3a5e421c50dc3cfa16c573a3e87135 (patch) | |
|---|---|---|
| Author | 2026-11-01 22:51:04 +0200 | |
| Committer | 2026-11-01 22:51:18 +0200 | |
| Files | ec3e06cdc9099838406b918f5b9347eee46adf88 /nvim | |
| .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.
12 files changed, 883 insertions, 0 deletions
| l--------- | nvim/.config/nvim | 1 | ||||
| -rw-r--r-- | nvim/.nvim/after/queries/awk/injections.scm | 7 | ||||
| -rw-r--r-- | nvim/.nvim/init.lua | 12 | ||||
| -rw-r--r-- | nvim/.nvim/lazy-lock.json | 36 | ||||
| -rw-r--r-- | nvim/.nvim/lua/config/lazy.lua | 36 | ||||
| -rw-r--r-- | nvim/.nvim/lua/mappings.lua | 127 | ||||
| -rw-r--r-- | nvim/.nvim/lua/onfiletype.lua | 6 | ||||
| -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 | ||||
| -rw-r--r-- | nvim/.nvim/lua/text.lua | 27 | ||||
| -rw-r--r-- | nvim/.nvim/lua/ux.lua | 69 |
diff --git a/nvim/.config/nvim b/nvim/.config/nvim new file mode 120000 index 0000000..7038074 --- /dev/null +++ b/nvim/.config/nvim @@ -0,0 +1 @@ +../.nvim
\ No newline at end of file diff --git a/nvim/.nvim/after/queries/awk/injections.scm b/nvim/.nvim/after/queries/awk/injections.scm new file mode 100644 index 0000000..8de95c4 --- /dev/null +++ b/nvim/.nvim/after/queries/awk/injections.scm @@ -0,0 +1,7 @@ +;; extends +( + (regex + pattern: + (regex_pattern) @injection.content) + (#set! injection.language "regex") +) diff --git a/nvim/.nvim/init.lua b/nvim/.nvim/init.lua new file mode 100644 index 0000000..edce259 --- /dev/null +++ b/nvim/.nvim/init.lua @@ -0,0 +1,12 @@ +function rawgetrec(table, key, ...) + if key == nil then + return table + end + return get(rawget(table, key), ...) +end + +require("config.lazy") +require("onfiletype") +require("mappings") +require("text") +require("ux") diff --git a/nvim/.nvim/lazy-lock.json b/nvim/.nvim/lazy-lock.json new file mode 100644 index 0000000..670fb0f --- /dev/null +++ b/nvim/.nvim/lazy-lock.json @@ -0,0 +1,36 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "changes.nvim": { "branch": "master", "commit": "563771d50ca90602d94a6eca84f11706f1bdc508" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, + "dunbar": { "branch": "main", "commit": "0fc9f9e2d9ac5481541b7c49ce6cc9050fb4bd34" }, + "git-blame.vim": { "branch": "master", "commit": "9d144b7bed5d8f1c9259551768b7f3b3d1294917" }, + "gruvbox": { "branch": "master", "commit": "697c00291db857ca0af00ec154e5bd514a79191f" }, + "gruvbox-highlight.nvim": { "branch": "main", "commit": "165c11bb131fc73f0b6c7b39d861290f2c4ed402" }, + "heirline.nvim": { "branch": "master", "commit": "fae936abb5e0345b85c3a03ecf38525b0828b992" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lsp-zero.nvim": { "branch": "v3.x", "commit": "77550f2f6cbf0959ef1583d845661af075f3442b" }, + "lua-utils.nvim": { "branch": "main", "commit": "e565749421f4bbb5d2e85e37c3cef9d56553d8bd" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "25f609e7fca78af7cede4f9fa3af8a94b1c4950b" }, + "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, + "neorg": { "branch": "main", "commit": "ace80b05771b65d6633f3c64b8d930b5787f20d0" }, + "nnn.nvim": { "branch": "master", "commit": "efe690293eee87558f034a83ed96157e52639cdb" }, + "noir-nvim": { "branch": "master", "commit": "974085422a6dab055821803a0c2177ced673510d" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" }, + "nvim-lspconfig": { "branch": "master", "commit": "5492a24edd68f78d8a778edcb8905d0a28993abc" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-surround": { "branch": "main", "commit": "61319d4bd1c5e336e197defa15bd104c51f0fb29" }, + "nvim-treesitter": { "branch": "master", "commit": "cf12346a3414fa1b06af75c79faebe7f76df080a" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "5ca4aaa6efdcc59be46b95a3e876300cfead05ef" }, + "nvim-ts-autotag": { "branch": "main", "commit": "8e1c0a389f20bf7f5b0dd0e00306c1247bda2595" }, + "nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" }, + "pathlib.nvim": { "branch": "main", "commit": "57e5598af6fe253761c1b48e0b59b7cd6699e2c1" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "tabular": { "branch": "master", "commit": "12437cd1b53488e24936ec4b091c9324cafee311" }, + "telescope.nvim": { "branch": "master", "commit": "cfb85dcf7f822b79224e9e6aef9e8c794211b20b" }, + "undotree": { "branch": "master", "commit": "6fa6b57cda8459e1e4b2ca34df702f55242f4e4d" }, + "vim-better-whitespace": { "branch": "master", "commit": "de99b55a6fe8c96a69f9376f16b1d5d627a56e81" }, + "vim-eunuch": { "branch": "master", "commit": "e86bb794a1c10a2edac130feb0ea590a00d03f1e" }, + "vim-vsnip": { "branch": "master", "commit": "9bcfabea653abdcdac584283b5097c3f8760abaa" }, + "vim-wakatime": { "branch": "master", "commit": "d7973b157a632d1edeff01818f18d67e584eeaff" } +} diff --git a/nvim/.nvim/lua/config/lazy.lua b/nvim/.nvim/lua/config/lazy.lua new file mode 100644 index 0000000..dd7ef42 --- /dev/null +++ b/nvim/.nvim/lua/config/lazy.lua @@ -0,0 +1,36 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = true, notify = false }, + change_detection = { notify = false }, +}) diff --git a/nvim/.nvim/lua/mappings.lua b/nvim/.nvim/lua/mappings.lua new file mode 100644 index 0000000..4257e06 --- /dev/null +++ b/nvim/.nvim/lua/mappings.lua @@ -0,0 +1,127 @@ +--[=[ Helpers ]=]-- + +keys = {} +setmetatable(keys, +{ + __index = function (table, index) + local mod, key = index:match("^(.*)_"), index:match("[^_]*$") + if mod == nil then + if #key > 1 then key = "<" .. key .. ">" end + return key + end + mod = mod:upper() + + if mod == "SHIFT" then key = "<S-" .. key .. ">" + elseif mod == "CONTROL" then key = "<C-" .. key .. ">" + elseif mod == "ALT" then key = "<M-" .. key .. ">" + elseif mod == "SUPER" then key = "<D-" .. key .. ">" + elseif mod ~= nil then error("Unknown key modifier \"" .. mod .. "\"!") + end + + return key + end +}) +map = { keys = { lhs = {}, rhs = "" } } +setmetatable(map, +{ + __index = function (table, index) + table.keys.lhs = {} + table.keys.rhs = "" + for i = 1, index:len() do + table.keys.lhs[i] = index:sub(i, i) + end + return table.keys + end +}) +setmetatable(map.keys, +{ + __index = function (table, index) + table.rhs = table.rhs .. keys[index] + return table + end, + __call = function (table, ...) + return vim.keymap.set(table.lhs, table.rhs, ...) + end +}) + +local function icommand(command) + return keys.Control_o .. command .. keys.Return +end + +--[=[ Mappings ]=]-- + +-- Quality of life +map.t["Esc><Esc"]("<C-\\><C-N>") +map.n.Control_t(":topl sp | ter" .. keys.Enter) +map.n.Control_c("<C-I>") + +-- Tab navigation +map.n.Alt_p("gt") +map.n.Alt_o("gT") + +map.i.Alt_p(keys.Control_o .. "gt") +map.i.Alt_o(keys.Control_o .. "gT") + +map.t.Alt_p("<C-\\><C-N>gt") +map.t.Alt_o("<C-\\><C-N>gT") + +-- Split navigation +local function windownav(letter) return keys.Control_w .. letter end +map.n.Control_l(windownav("l")) +map.n.Control_h(windownav("h")) +map.n.Control_j(windownav("j")) +map.n.Control_k(windownav("k")) +map.t.Control_l("<C-\\><C-o>" .. windownav("l") .. "<Esc>") +map.t.Control_h("<C-\\><C-o>" .. windownav("h") .. "<Esc>") +map.t.Control_j("<C-\\><C-o>" .. windownav("j") .. "<Esc>") +map.t.Control_k("<C-\\><C-o>" .. windownav("k") .. "<Esc>") + +-- Ctrl-S, Ctrl-A, Ctrl-C, Ctrol-X +map.i.Control_s(icommand(":w")) +-- map.i.Control_a(keys.Escape .. "ggVG") + +map.n.Control_s(":w" .. keys.Enter) +-- map.n.Control_a("ggVG") + +map.x.Control_c('"+y') +-- map.x.Control_x('"+d') + +-- Undo/redo +map.i.Control_r(keys.Control_o .. keys.Control_r) +map.i.Control_u(keys.Control_o .. "u") + +-- Backspace +map.ic.Control_h(keys.Control_w) +map.ic.Control_BS(keys.Control_w) + +-- Move lines +map.n.Alt_j(":m+1" .. keys.Enter) +map.n.Alt_k(":m-2" .. keys.Enter) +map.x.Alt_j(":m '>+1<CR>gv=gv") +map.x.Alt_k(":m '<-2<CR>gv=gv") + +-- Special +map.n["|"](":tabnew | ter lazygit<CR>", { silent = true }) +map.n.F6(function() + vim.cmd("set spell!") +end) + +local telescope = require('telescope.builtin') +vim.keymap.set('n', 'ff', telescope.find_files) +vim.keymap.set('n', 'fg', telescope.live_grep) +vim.keymap.set('n', 'fb', telescope.buffers) +vim.keymap.set('n', 'fc', telescope.git_commits) + +--[=[ Abbreviations ]=]-- +vim.cmd("cnoreabbrev x wa \\| qa!") + +--[=[ Language mappings ]=]-- +vim.opt.langmap = { + -- Lowercase mappings + "аa", "бb", "вw", "гg", "дd", "еe", "жv", "зz", "иi", "йj", "кk", "лl", "мm", "нn", + "оo", "пp", "рr", "сs", "тt", "уu", "фf", "хh", "цc", "ч`", "ш[", "щ]", "ъy", "ьx", "ю\\", "яq", + + --, Uppercase, mappings + "АA", "БB", "ВW", "ГG", "ДD", "ЕE", "ЖV", "ЗZ", "ИI", "ЙJ", "КK", "ЛL", "МM", "НN", + "ОO", "ПP", "РR", "СS", "ТT", "УU", "ФF", "ХH", "ЦC", "Ч~", "Ш[", "Щ]", "ЪY", "ЬX", "Ю|", "ЯQ", +} diff --git a/nvim/.nvim/lua/onfiletype.lua b/nvim/.nvim/lua/onfiletype.lua new file mode 100644 index 0000000..efa69ac --- /dev/null +++ b/nvim/.nvim/lua/onfiletype.lua @@ -0,0 +1,6 @@ +--[=[ Terminal buffers ]=]-- + +vim.api.nvim_create_autocmd({ "TermOpen", "BufEnter" }, { + pattern = "term://*", + command = "setlocal nonu | startinsert", +}) 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", + }, + }, +} diff --git a/nvim/.nvim/lua/text.lua b/nvim/.nvim/lua/text.lua new file mode 100644 index 0000000..898bfa3 --- /dev/null +++ b/nvim/.nvim/lua/text.lua @@ -0,0 +1,27 @@ +vim.cmd.highlight({ "Pmenu", "ctermfg=223", "ctermbg=238" }) + +vim.api.nvim_create_user_command( + "FIND", + "vim /\\v(<args>)/ % | set nowrap | copen", + { nargs = 1 } +) + +--[=[ Treesitter ]=]-- + +vim.cmd.highlight({ "link", "@variable", "GruvboxFg1" }) +vim.cmd.highlight({ "link", "@operator", "GruvboxOrange" }) + +--[=[ Characters ]=]-- + +vim.o.list = true +vim.opt.listchars = { tab = "│ ", extends = ">", precedes = "<" } + +vim.o.tabstop = 4 -- Show tab as 4 spaces +vim.o.shiftwidth = 4 -- Indent with 4 spaces + +--[=[ Folding ]=]-- +vim.o.foldlevel = 99 +vim.cmd.highlight({ "Folded", "ctermfg=NONE" }) + +--[=[ ToHTML ]=]-- +vim.g.html_dynamic_folds = true diff --git a/nvim/.nvim/lua/ux.lua b/nvim/.nvim/lua/ux.lua new file mode 100644 index 0000000..8ff01fc --- /dev/null +++ b/nvim/.nvim/lua/ux.lua @@ -0,0 +1,69 @@ +--[=[ Search ]=]-- + +vim.o.hlsearch = false -- No highlighting when searching + +vim.api.nvim_create_autocmd({ "Filetype" }, { + pattern = "qf", + command = "wincmd J" +}) + +--[=[ Cursor and mouse ]=]-- + +vim.o.scrolloff = 5 -- Lines above and below cursor +vim.o.showmatch = true -- Jump to opening brace when having typed closing one + +vim.o.cursorline = true +vim.api.nvim_create_autocmd({ "InsertLeave", "BufEnter" }, { + command = "set cul" +}) +vim.api.nvim_create_autocmd({ "InsertEnter", "BufLeave" }, { + command = "set nocul" +}) + +vim.o.mouse = "a" + +--[=[ Windows ]=]-- + +vim.o.splitbelow = true +vim.o.splitright = true + +vim.o.number = true +vim.o.signcolumn = "number" + +vim.o.showmode = false +vim.o.timeoutlen = 350 + +--[=[ History ]=]-- + +vim.o.undofile = true +vim.o.undodir = vim.fn.expand("~/nvim/undo") + +--[=[ Quickfix ]=]-- + +vim.cmd [[ + function QuickFixFormat(info) + let qfl = [] + + let maxfnlen = 0 + let maxlilen = 0 + for d in getqflist() + let maxfnlen = max([maxfnlen, strdisplaywidth(fnamemodify(bufname(d.bufnr), ":t"))]) + let maxlilen = max([maxlilen, strdisplaywidth(string(d.lnum))]) + endfor + let strfmt = "%-" . maxfnlen . "s |%". maxlilen ."d|%s" + + let lastfile = "" + for d in getqflist() + let fn = fnamemodify(bufname(d.bufnr), ":t") + if d.lnum != 0 + call add(qfl, printf(strfmt, fn == lastfile ? '' : fn, d.lnum, d.text)) + let lastfile = fn + else + call add(qfl, ' ') + endif + endfor + return qfl + endfunction +]] + +vim.o.quickfixtextfunc = "QuickFixFormat" |
