{ osConfig, config, pkgs, lib, inputs, ... }: let inherit (lib.generators) mkLuaInline; inherit (lib) concatStringsSep optionalString; suda-nvim = pkgs.vimUtils.buildVimPlugin { name = "vim-suda"; src = pkgs.fetchFromGitHub { owner = "lambdalisue"; repo = "vim-suda"; rev = "9adda7d195222d4e2854efb2a88005a120296c47"; hash = "sha256-46sy3rAdOCULVt1RkIoGdweoV3MqQaB33Et9MrxI6Lk="; }; }; marks-nvim = pkgs.vimUtils.buildVimPlugin { name = "marks-nvim"; src = inputs.marks-nvim; }; yaziOpenDir = config.programs.nvf.settings.vim.utility.yazi-nvim.setupOpts.open_for_directories; in { imports = [ ./plugins/snacks-nvim ./plugins/lualine ./plugins/leetcode ./extra-lsp.nix ]; home.packages = with pkgs; [ (rust-bin.stable.latest.default.override { extensions = [ "rust-src" ]; }) ]; programs.nvf = { enable = true; settings = { vim = { enableLuaLoader = true; vimAlias = true; luaConfigPre = '' ${optionalString yaziOpenDir "vim.g.loaded_netrwPlugin = 1"} ''; extraPackages = with pkgs; [ nixfmt ]; clipboard = { enable = true; providers = { wl-copy.enable = true; }; registers = "unnamedplus"; }; extraPlugins = with pkgs.vimPlugins; { transparent = { package = transparent-nvim; setup = let clearFg = map (x: ''vim.api.nvim_set_hl(0, "${x}", { fg = "NONE", bg = "NONE"})'') [ "TabLineFill" ]; in # lua '' require("transparent").setup({ extra_groups = { "NormalFloat", "NvimTreeNormal", "TreesitterContext", "FloatBorder", "FoldColumn", "Folded", "BlinkCmpMenu", "BlinkCmpBorder", "BlinkCmpKind", "WarningMsg", "ColorColumn", "ErrorMsg", "BlinkCmpMenuBorder", "FzfLuaBackdrop", "VertSplit", "Pmenu", "PmenuSbar", "DiffText", "DiffViewNormal", "CursorColumn", "QuickFixLine", "Error", "NoiceScrollbar" }, }) require("transparent").clear_prefix("NeoTree") require("transparent").clear_prefix("GitGutter") require("transparent").clear_prefix("BufferLine") ${concatStringsSep "\n" clearFg} ''; }; suda = { package = suda-nvim; }; marks = { package = marks-nvim; setup = '' require("marks").setup {} ''; }; }; keymaps = [ # === Buffer === # { key = "bo"; mode = [ "n" ]; action = ":BufferLineCloseOther"; desc = "Close other buffer"; } { key = "bS"; mode = [ "n" ]; action = ":SudaWrite"; desc = "Save file as root"; } # === General Control === # # Save file { key = ""; mode = [ "n" "i" "v" ]; action = ":w"; desc = "Save file"; } { key = ""; mode = [ "i" ]; action = ""; desc = "Shift left"; } { key = "n"; mode = [ "n" ]; action = ":NoiceAll"; nowait = true; desc = "Notifications"; } { key = ""; mode = [ "n" ]; action = ":noh"; desc = "Clear highlight"; } # === Tab === # { key = ">"; mode = [ "v" ]; action = ">gv"; silent = true; desc = "Shift right"; } { key = "<"; mode = [ "v" ]; action = " 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 ''; provider_selector = mkLuaInline # lua '' function(bufnr, filetype, buftype) return {'treesitter', 'indent'} end ''; }; }; borders = { enable = true; plugins = { lspsaga.enable = true; fastaction.enable = true; lsp-signature.enable = true; which-key.enable = true; }; }; }; mini.surround = { enable = true; setupOpts = { mappings = { add = "gsa"; delete = "gsd"; find = "gsf"; find_left = "gsF"; highlight = "gsh"; replace = "gsr"; suffix_last = ""; suffix_next = ""; }; silent = true; }; }; }; }; }; }