diff --git a/flake.lock b/flake.lock index ea5a48a..1ce5b85 100644 --- a/flake.lock +++ b/flake.lock @@ -76,11 +76,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1757789833, - "narHash": "sha256-cpYiHtQ9ROyutuFEkqDNkc3sOVayEeNHAtCVQI5reoc=", + "lastModified": 1758033778, + "narHash": "sha256-oQH2wLOWLFHXT3NE+gcsFOX+Pq40bKjlOH1xw0wcmT8=", "owner": "chaotic-cx", "repo": "nyx", - "rev": "5a088eb3f84aeea80b2d240e25c4f72a0fbdea4e", + "rev": "b3efa297b9c6a9e55a44f3b6905d55f80738704f", "type": "github" }, "original": { @@ -116,11 +116,11 @@ ] }, "locked": { - "lastModified": 1757508292, - "narHash": "sha256-7lVWL5bC6xBIMWWDal41LlGAG+9u2zUorqo3QCUL4p4=", + "lastModified": 1758287904, + "narHash": "sha256-IGmaEf3Do8o5Cwp1kXBN1wQmZwQN3NLfq5t4nHtVtcU=", "owner": "nix-community", "repo": "disko", - "rev": "146f45bee02b8bd88812cfce6ffc0f933788875a", + "rev": "67ff9807dd148e704baadbd4fd783b54282ca627", "type": "github" }, "original": { @@ -278,11 +278,11 @@ ] }, "locked": { - "lastModified": 1757698511, - "narHash": "sha256-UqHHGydF/q3jfYXCpvYLA0TWtvByOp1NwOKCUjhYmPs=", + "lastModified": 1757920978, + "narHash": "sha256-Mv16aegXLulgyDunijP6SPFJNm8lSXb2w3Q0X+vZ9TY=", "owner": "nix-community", "repo": "home-manager", - "rev": "a3fcc92180c7462082cd849498369591dfb20855", + "rev": "11cc5449c50e0e5b785be3dfcb88245232633eb8", "type": "github" }, "original": { @@ -298,11 +298,11 @@ ] }, "locked": { - "lastModified": 1757997814, - "narHash": "sha256-F+1aoG+3NH4jDDEmhnDUReISyq6kQBBuktTUqCUWSiw=", + "lastModified": 1758375677, + "narHash": "sha256-BLtD+6qWz7fQjPk2wpwyXQLGI0E30Ikgf2ppn2nVadI=", "owner": "nix-community", "repo": "home-manager", - "rev": "5820376beb804de9acf07debaaff1ac84728b708", + "rev": "edc7468e12be92e926847cb02418e649b02b59dd", "type": "github" }, "original": { @@ -386,11 +386,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1757598577, - "narHash": "sha256-+PccWxBVh1cFy2sDWHlpSBG+OP0b6o/DE2EzCxsB0ns=", + "lastModified": 1758029758, + "narHash": "sha256-fKqsvznISxVSBo6aaiGGXMRiBG4IIuV3sSySxx80pcQ=", "owner": "PedroHLC", "repo": "nixpkgs", - "rev": "7bbfafff0e9f1c9a0d10ca4d4c26aaa49a13d893", + "rev": "4eb5897225c3d7e78a0b9d1542197ee7c8d270a5", "type": "github" }, "original": { @@ -430,11 +430,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1757745802, - "narHash": "sha256-hLEO2TPj55KcUFUU1vgtHE9UEIOjRcH/4QbmfHNF820=", + "lastModified": 1758277210, + "narHash": "sha256-iCGWf/LTy+aY0zFu8q12lK8KuZp7yvdhStehhyX1v8w=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c23193b943c6c689d70ee98ce3128239ed9e32d1", + "rev": "8eaee110344796db060382e15d3af0a9fc396e0e", "type": "github" }, "original": { @@ -470,11 +470,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1757864383, - "narHash": "sha256-oMoFAEC8A8BGBHIYiUNsgsVhEyNwTbn066J68LtbelY=", + "lastModified": 1758405527, + "narHash": "sha256-3OMGX/chlzLpL7OMjXUfcI+xGu5GMeldCnBQ5kM9lZE=", "owner": "nix-community", "repo": "nixvim", - "rev": "db1a991f33fb43cf0e2a4aff54a8c53b4dc12128", + "rev": "fd0c42355026185678e93bca152cbdb3b1a67563", "type": "github" }, "original": { @@ -518,11 +518,11 @@ ] }, "locked": { - "lastModified": 1757624466, - "narHash": "sha256-25ExS2AkQD05Jf0Y2Wnn5KHpucN2d3ObEQOVaDh7ubg=", + "lastModified": 1758272005, + "narHash": "sha256-1u3xTH+3kaHhztPmWtLAD8LF5pTYLR2CpsPFWTFnVtQ=", "owner": "NuschtOS", "repo": "search", - "rev": "da8bcb74407e41d334fc79081fdd8948b795bd6f", + "rev": "aa975a3757f28ce862812466c5848787b868e116", "type": "github" }, "original": { @@ -550,11 +550,11 @@ ] }, "locked": { - "lastModified": 1757730403, - "narHash": "sha256-Jxl4OZRVsXs8JxEHUVQn3oPu6zcqFyGGKaFrlNgbzp0=", + "lastModified": 1757930296, + "narHash": "sha256-Z9u5VszKs8rfEvg2AsFucWEjl7wMtAln9l1b78cfBh4=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "3232f7f8bd07849fc6f4ae77fe695e0abb2eba2c", + "rev": "09442765a05c2ca617c20ed68d9613da92a2d96b", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 287d3c3..fa63ac3 100644 --- a/flake.nix +++ b/flake.nix @@ -13,14 +13,28 @@ nixvim.url = "github:nix-community/nixvim"; stylix.url = "github:danth/stylix"; }; + outputs = inputs: let hostname = "dos"; username = "dich"; in { nixosConfigurations = { "${hostname}" = inputs.nixpkgs.lib.nixosSystem { - modules = [./hosts]; - specialArgs = {inherit hostname inputs username;}; + specialArgs = { inherit hostname inputs username; }; + modules = [ + ./hosts + inputs.home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.${username} = { + imports = [ + ./home + inputs.nixvim.homeModules.nixvim + ]; + }; + } + ]; }; }; }; diff --git a/home/default.nix b/home/default.nix index c1b8ca0..43ab129 100644 --- a/home/default.nix +++ b/home/default.nix @@ -11,7 +11,8 @@ in { ls ./cli ++ ls ./gui ++ ls ./tui - ++ ls ./wayland; + ++ ls ./wayland + ++ [ ./nixvim ]; home = { file = { diff --git a/home/nixvim/autocmd.nix b/home/nixvim/autocmd.nix new file mode 100644 index 0000000..c70bde7 --- /dev/null +++ b/home/nixvim/autocmd.nix @@ -0,0 +1,64 @@ +{ + autoGroups = { + highlight_yank = {}; + vim_enter = {}; + indentscope = {}; + restore_cursor = {}; + }; + + autoCmd = [ + # highlight Text on Yank + { + group = "highlight_yank"; + event = "TextYankPost"; + pattern = "*"; + callback = { + __raw = " + function() + vim.highlight.on_yank() + end + "; + }; + } + { + group = "indentscope"; + event = ["FileType"]; + pattern = [ + "help" + "Startup" + "startup" + "neo-tree" + "Trouble" + "trouble" + "notify" + ]; + callback = { + __raw = '' + function() + vim.b.miniindentscope_disable = true + end + ''; + }; + } + ## from NVChad https://nvchad.com/docs/recipes (this autocmd will restore the cursor position when opening a file) + { + group = "restore_cursor"; + event = ["BufReadPost"]; + pattern = "*"; + callback = { + __raw = '' + function() + if + vim.fn.line "'\"" > 1 + and vim.fn.line "'\"" <= vim.fn.line "$" + and vim.bo.filetype ~= "commit" + and vim.fn.index({ "xxd", "gitrebase" }, vim.bo.filetype) == -1 + then + vim.cmd "normal! g`\"" + end + end + ''; + }; + } + ]; +} diff --git a/home/nixvim/default.nix b/home/nixvim/default.nix new file mode 100644 index 0000000..b3dafc8 --- /dev/null +++ b/home/nixvim/default.nix @@ -0,0 +1,16 @@ +{pkgs, ...}: { + programs.nixvim = { + enable = true; + enableMan = false; + imports = [ + ./autocmd.nix + ./keymaps.nix + ./settings.nix + ./lazy.nix + ./plugins + ]; + extraPackages = with pkgs; [ + wakatime-cli + ]; + }; +} diff --git a/home/nixvim/keymaps.nix b/home/nixvim/keymaps.nix new file mode 100644 index 0000000..7ac5e5f --- /dev/null +++ b/home/nixvim/keymaps.nix @@ -0,0 +1,273 @@ +{ + globals.mapleader = " "; + + keymaps = [ + # Windows + { + mode = "n"; + key = ""; + action = "k"; + options.desc = "Move To Window Up"; + } + + { + mode = "n"; + key = ""; + action = "j"; + options.desc = "Move To Window Down"; + } + + { + mode = "n"; + key = ""; + action = "h"; + options.desc = "Move To Window Left"; + } + + { + mode = "n"; + key = ""; + action = "l"; + options.desc = "Move To Window Right"; + } + + { + mode = "n"; + key = "wd"; + action = "c"; + options = { + silent = true; + desc = "Delete window"; + }; + } + + { + mode = "n"; + key = "-"; + action = "s"; + options = { + silent = true; + desc = "Split window below"; + }; + } + + { + mode = "n"; + key = "|"; + action = "v"; + options = { + silent = true; + desc = "Split window right"; + }; + } + + { + mode = "n"; + key = ""; + action = "w"; + options = { + silent = true; + desc = "Save file"; + }; + } + + # Quit/Session + { + mode = "n"; + key = "qq"; + action = "quitall"; + options = { + silent = true; + desc = "Quit all"; + }; + } + + # Toggle options + { + mode = "n"; + key = "ul"; + action = ":lua ToggleLineNumber()"; + options = { + silent = true; + desc = "Toggle Line Numbers"; + }; + } + + { + mode = "n"; + key = "uL"; + action = ":lua ToggleRelativeLineNumber()"; + options = { + silent = true; + desc = "Toggle Relative Line Numbers"; + }; + } + + { + mode = "n"; + key = "uw"; + action = ":lua ToggleWrap()"; + options = { + silent = true; + desc = "Toggle Line Wrap"; + }; + } + + # Move Lines + { + mode = "n"; + key = ""; + action = "m .-2=="; + options.desc = "Move line up"; + } + + { + mode = "v"; + key = ""; + action = ":m '<-2gv=gv"; + options.desc = "Move line up"; + } + + { + mode = "n"; + key = ""; + action = "m .+1=="; + options.desc = "Move line down"; + } + + { + mode = "v"; + key = ""; + action = ":m '>+1gv=gv"; + options.desc = "Move line Down"; + } + + # Better indenting + { + mode = "v"; + key = "<"; + action = " + y or just y to have it just in vim + { + mode = [ + "n" + "v" + ]; + key = "y"; + action = "\"+y"; + options.desc = "Copy to system clipboard"; + } + + # Delete to void register + { + mode = [ + "n" + "v" + ]; + key = "D"; + action = "\"_d"; + options.desc = "Delete to void register"; + } + ]; + extraConfigLua = '' + function ToggleLineNumber() + if vim.wo.number then + vim.wo.number = false + else + vim.wo.number = true + vim.wo.relativenumber = false + end + end + + function ToggleRelativeLineNumber() + if vim.wo.relativenumber then + vim.wo.relativenumber = false + else + vim.wo.relativenumber = true + vim.wo.number = false + end + end + + function ToggleWrap() + vim.wo.wrap = not vim.wo.wrap + end + + if vim.lsp.inlay_hint then + vim.keymap.set('n', 'uh', function() + vim.lsp.inlay_hint(0, nil) + end, { desc = 'Toggle Inlay Hints' }) + end + ''; +} diff --git a/home/nixvim/lazy.nix b/home/nixvim/lazy.nix new file mode 100644 index 0000000..7bb02aa --- /dev/null +++ b/home/nixvim/lazy.nix @@ -0,0 +1,5 @@ +{ + plugins.lazy = { + enable = true; + }; +} diff --git a/home/nixvim/plugins/ai/codeium.nix b/home/nixvim/plugins/ai/codeium.nix new file mode 100644 index 0000000..68f446c --- /dev/null +++ b/home/nixvim/plugins/ai/codeium.nix @@ -0,0 +1,33 @@ +{ + lib, + pkgs, + ... +}: { + plugins = { + codeium-nvim = { + enable = true; + + settings = { + enable_chat = true; + + tools = { + curl = lib.getExe pkgs.curl; + gzip = lib.getExe pkgs.gzip; + uname = lib.getExe' pkgs.coreutils "uname"; + uuidgen = lib.getExe' pkgs.util-linux "uuidgen"; + }; + }; + }; + }; + + keymaps = [ + { + mode = "n"; + key = "ac"; + action = "Codeium Chat"; + options = { + desc = "Codeium Chat"; + }; + } + ]; +} diff --git a/home/nixvim/plugins/ai/copilot.nix b/home/nixvim/plugins/ai/copilot.nix new file mode 100644 index 0000000..13e75d9 --- /dev/null +++ b/home/nixvim/plugins/ai/copilot.nix @@ -0,0 +1,32 @@ +{ + plugins = { + copilot-chat.enable = true; + copilot-lua = { + enable = true; + suggestion = { + enabled = false; + autoTrigger = true; + keymap.accept = ""; + }; + panel.enabled = false; + }; + + which-key.settings.spec = [ + { + __unkeyed-1 = "a"; + mode = "n"; + icon = "󰚩"; + group = "+ai"; + } + ]; + }; + + keymaps = [ + { + action = "CopilotChatToggle"; + key = "ac"; + options.desc = "Toggle Coilot chat"; + mode = "n"; + } + ]; +} diff --git a/home/nixvim/plugins/completion/cmp.nix b/home/nixvim/plugins/completion/cmp.nix new file mode 100644 index 0000000..c3b2c0d --- /dev/null +++ b/home/nixvim/plugins/completion/cmp.nix @@ -0,0 +1,166 @@ +{lib, ...}: { + plugins = { + cmp = { + enable = true; + autoEnableSources = true; + + cmdline = { + "/" = { + mapping.__raw = "cmp.mapping.preset.cmdline()"; + sources = [{name = "buffer";}]; + }; + ":" = { + mapping.__raw = "cmp.mapping.preset.cmdline()"; + sources = [ + {name = "path";} + { + name = "cmdline"; + option.ignore_cmds = [ + "Man" + "!" + ]; + } + ]; + }; + }; + + filetype = { + sql.sources = [ + {name = "buffer";} + {name = "vim-dadbod-completion";} + ]; + }; + + settings = { + # Preselect first entry + completion.completeopt = "menu,menuone,noinsert"; + sources = [ + { + name = "nvim_lsp"; + priority = 100; + } + { + name = "nvim_lsp_signature_help"; + priority = 100; + } + { + name = "nvim_lsp_document_symbol"; + priority = 100; + } + { + name = "treesitter"; + priority = 80; + } + { + name = "luasnip"; + priority = 70; + } + # { + # name = "codeium"; + # priority = 60; + # } + { + name = "buffer"; + priority = 50; + # Words from other open buffers can also be suggested. + option.get_bufnrs.__raw = "vim.api.nvim_list_bufs"; + keywordLength = 3; + } + { + name = "path"; + priority = 30; + } + { + name = "git"; + priority = 20; + } + { + name = "npm"; + priority = 20; + } + # { + # name = "zsh"; + # priority = 20; + # } + { + name = "calc"; + priority = 10; + } + { + name = "emoji"; + priority = 5; + } + + # Disable this if running tests with nix flake check + (lib.mkIf lib.nixvim.enableExceptInTests {name = "nixpkgs_maintainers";}) + ]; + + window = { + completion.border = "rounded"; + documentation.border = "rounded"; + }; + experimental.ghost_text = true; + + mapping = { + "".__raw = '' + cmp.mapping(function(fallback) + local luasnip = require("luasnip") + if luasnip.locally_jumpable(1) then + luasnip.jump(1) + else + fallback() + end + end, { "i", "s" }) + ''; + + "".__raw = '' + cmp.mapping(function(fallback) + local luasnip = require("luasnip") + if luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }) + ''; + + "" = + # lua + "cmp.mapping(cmp.mapping.select_next_item())"; + "" = + # lua + "cmp.mapping(cmp.mapping.select_prev_item())"; + "" = + # lua + "cmp.mapping.abort()"; + "" = + # lua + "cmp.mapping.scroll_docs(-4)"; + "" = + # lua + "cmp.mapping.scroll_docs(4)"; + "" = + # lua + "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})"; + "" = + # lua + "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; + "" = + # lua + "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true })"; + "" = + # lua + "cmp.mapping.complete()"; + }; + + snippet.expand = + # lua + '' + function(args) + require('luasnip').lsp_expand(args.body) + end + ''; + }; + }; + }; +} diff --git a/home/nixvim/plugins/completion/lspkind.nix b/home/nixvim/plugins/completion/lspkind.nix new file mode 100644 index 0000000..f62c12b --- /dev/null +++ b/home/nixvim/plugins/completion/lspkind.nix @@ -0,0 +1,67 @@ +{ + plugins.lspkind = { + enable = true; + + settings = { + cmp.menu = { + nvim_lsp = ""; + nvim_lua = ""; + neorg = "[neorg]"; + buffer = ""; + calc = ""; + git = ""; + luasnip = "󰩫"; + codeium = "󱜙"; + copilot = ""; + emoji = "󰞅"; + path = ""; + spell = ""; + }; + + symbol_map = { + Namespace = "󰌗"; + Text = "󰊄"; + Method = "󰆧"; + Function = "󰡱"; + Constructor = ""; + Field = "󰜢"; + Variable = "󰀫"; + Class = "󰠱"; + Interface = ""; + Module = "󰕳"; + Property = ""; + Unit = "󰑭"; + Value = "󰎠"; + Enum = ""; + Keyword = "󰌋"; + Snippet = ""; + Color = "󰏘"; + File = "󰈚"; + Reference = "󰈇"; + Folder = "󰉋"; + EnumMember = ""; + Constant = "󰏿"; + Struct = "󰙅"; + Event = ""; + Operator = "󰆕"; + TypeParameter = ""; + Table = ""; + Object = "󰅩"; + Tag = ""; + Array = "[]"; + Boolean = ""; + Number = ""; + Null = "󰟢"; + String = "󰉿"; + Calendar = ""; + Watch = "󰥔"; + Package = ""; + Copilot = ""; + Codeium = ""; + TabNine = ""; + }; + maxwidth = 50; + ellipsis_char = "..."; + }; + }; +} diff --git a/home/nixvim/plugins/debug/dap.nix b/home/nixvim/plugins/debug/dap.nix new file mode 100644 index 0000000..31c27b9 --- /dev/null +++ b/home/nixvim/plugins/debug/dap.nix @@ -0,0 +1,198 @@ +{ + plugins = { + dap = { + enable = true; + signs = { + dapBreakpoint = { + text = " "; + texthl = "DiagnosticInfo"; + }; + dapBreakpointCondition = { + text = " "; + texthl = "DiagnosticInfo"; + }; + dapBreakpointRejected = { + text = " "; + texthl = "DiagnosticError"; + }; + dapLogPoint = { + text = " "; + texthl = "DiagnosticInfo"; + }; + dapStopped = { + text = "󰁕 "; + texthl = "DiagnosticWarn"; + linehl = "DapStoppedLine"; + numhl = "DapStoppedLine"; + }; + }; + }; + dap-ui = { + enable = true; + settings.layouts = [ + { + elements = [ + { + id = "scopes"; + size = 0.25; + } + { + id = "breakpoints"; + size = 0.25; + } + { + id = "stacks"; + size = 0.25; + } + { + id = "watches"; + size = 0.25; + } + ]; + position = "left"; + size = 40; + } + { + elements = [ + { + id = "repl"; + size = 0.5; + } + { + id = "console"; + size = 0; + } + ]; + position = "bottom"; + size = 10; + } + ]; + }; + dap-virtual-text.enable = true; + which-key.settings.spec = [ + { + __unkeyed-1 = "d"; + mode = [ + "n" + "v" + ]; + group = "+debug"; + } + ]; + }; + + keymaps = [ + { + mode = ["n"]; + action = ":DapContinue"; + key = "dc"; + options = { + desc = "Continue"; + }; + } + { + mode = ["n"]; + action = ":DapStepOver"; + key = "dO"; + options = { + desc = "Step over"; + }; + } + { + mode = ["n"]; + action = ":DapStepInto"; + key = "di"; + options = { + desc = "Step Into"; + }; + } + { + mode = ["n"]; + action = ":DapStepOut"; + key = "do"; + options = { + desc = "Step Out"; + }; + } + { + mode = ["n"]; + action = "lua require('dap').pause()"; + key = "dp"; + options = { + desc = "Pause"; + }; + } + { + mode = ["n"]; + action = ":DapToggleBreakpoint"; + key = "db"; + options = { + desc = "Toggle Breakpoint"; + }; + } + { + mode = ["n"]; + action = "lua require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))"; + key = "dB"; + options = { + desc = "Breakpoint (conditional)"; + }; + } + { + mode = ["n"]; + action = ":DapToggleRepl"; + key = "dR"; + options = { + desc = "Toggle REPL"; + }; + } + { + mode = ["n"]; + action = "lua require('dap').run_last()"; + key = "dr"; + options = { + desc = "Run Last"; + }; + } + { + mode = ["n"]; + action = "lua require('dap').session()"; + key = "ds"; + options = { + desc = "Session"; + }; + } + { + mode = ["n"]; + action = ":DapTerminate"; + key = "dt"; + options = { + desc = "Terminate"; + }; + } + { + mode = ["n"]; + action = "lua require('dap.ui.widgets').hover()"; + key = "dw"; + options = { + desc = "Hover Widget"; + }; + } + { + mode = ["n"]; + action = "lua require('dapui').toggle()"; + key = "du"; + options = { + desc = "Toggle UI"; + }; + } + { + mode = ["n"]; + action = "lua require('dapui').eval()"; + key = "de"; + options = { + desc = "Eval"; + }; + } + ]; +} diff --git a/home/nixvim/plugins/default.nix b/home/nixvim/plugins/default.nix new file mode 100644 index 0000000..a724170 --- /dev/null +++ b/home/nixvim/plugins/default.nix @@ -0,0 +1,69 @@ +{ + imports = [ + # ./ai/codeium.nix + + # ./completion/blink.nix + ./completion/cmp.nix + ./completion/lspkind.nix + + ./debug/dap.nix + + ./editor/neotree.nix + ./editor/undotree.nix + ./editor/whichkey.nix + ./editor/yazi.nix + + ./theme + ./luasnip + ./telescope + + ./git/gitsigns.nix + + ./lsp/conform.nix + ./lsp/fidget.nix + ./lsp/lsp.nix + ./lsp/lspsaga.nix + ./lsp/trouble.nix + + ./lang/cpp.nix + ./lang/css.nix + ./lang/docker.nix + ./lang/html.nix + ./lang/json.nix + ./lang/lua.nix + ./lang/markdown.nix + ./lang/nix.nix + # ./lang/python.nix + ./lang/shell.nix + ./lang/typescript.nix + ./lang/yaml.nix + + ./treesitter/treesitter.nix + ./treesitter/treesitter-textobjects.nix + + ./ui/alpha.nix + ./ui/bufferline.nix + ./ui/general.nix + ./ui/flash.nix + ./ui/indent-blankline.nix + ./ui/lualine.nix + ./ui/noice.nix + ./ui/notify.nix + ./ui/precognition.nix + ./ui/toggleterm.nix + ./ui/ufo.nix + + ./util/colorizer.nix + ./util/debugprint.nix + ./util/harpoon.nix + ./util/kulala.nix + ./util/mini.nix + ./util/nvim-autopairs.nix + ./util/nvim-surround.nix + ./util/plenary.nix + ./util/persistence.nix + ./util/project-nvim.nix + ./util/snacks.nix + ./util/wakatime.nix + ]; +} diff --git a/home/nixvim/plugins/editor/neotree.nix b/home/nixvim/plugins/editor/neotree.nix new file mode 100644 index 0000000..a1dea82 --- /dev/null +++ b/home/nixvim/plugins/editor/neotree.nix @@ -0,0 +1,51 @@ +{ + plugins.neo-tree = { + enable = true; + closeIfLastWindow = true; + sources = [ + "filesystem" + "buffers" + "git_status" + "document_symbols" + ]; + popupBorderStyle = "rounded"; # “NC”, “double”, “none”, “rounded”, “shadow”, “single”, “solid” or raw lua code + + filesystem = { + bindToCwd = false; + useLibuvFileWatcher = true; + followCurrentFile.enabled = true; + }; + + defaultComponentConfigs = { + gitStatus = { + symbols = { + added = " "; + conflict = "󰩌 "; + deleted = "󱂥 "; + ignored = " "; + modified = " "; + renamed = " "; + staged = "✓ "; + unstaged = " "; + untracked = " "; + }; + }; + }; + + window.mappings = { + "" = "none"; + }; + }; + + keymaps = [ + { + mode = "n"; + key = "e"; + action = "Neotree toggle"; + options = { + silent = true; + desc = "Explorer NeoTree (root dir)"; + }; + } + ]; +} diff --git a/home/nixvim/plugins/editor/undotree.nix b/home/nixvim/plugins/editor/undotree.nix new file mode 100644 index 0000000..3a2b787 --- /dev/null +++ b/home/nixvim/plugins/editor/undotree.nix @@ -0,0 +1,34 @@ +{ + plugins.undotree = { + enable = true; + settings = { + autoOpenDiff = true; + focusOnToggle = true; + CursorLine = true; + DiffAutoOpen = true; + DiffCommand = "diff"; + DiffpanelHeight = 10; + HelpLine = true; + HighlightChangedText = true; + HighlightChangedWithSign = true; + HighlightSyntaxAdd = "DiffAdd"; + HighlightSyntaxChange = "DiffChange"; + HighlightSyntaxDel = "DiffDelete"; + RelativeTimestamp = true; + SetFocusWhenToggle = true; + ShortIndicators = false; + }; + }; + + keymaps = [ + { + mode = "n"; + key = "ut"; + action = "UndotreeToggle"; + options = { + silent = true; + desc = "Undotree"; + }; + } + ]; +} diff --git a/home/nixvim/plugins/editor/whichkey.nix b/home/nixvim/plugins/editor/whichkey.nix new file mode 100644 index 0000000..50f7b0b --- /dev/null +++ b/home/nixvim/plugins/editor/whichkey.nix @@ -0,0 +1,68 @@ +{ + plugins.which-key = { + enable = true; + settings = { + icons = { + breadcrumb = "»"; + group = "+"; + separator = ""; # ➜ + }; + win = { + border = "rounded"; + padding = [ + 1 + 1 + ]; + }; + spec = [ + # General Mappings + { + __unkeyed-1 = "c"; + mode = [ + "n" + "v" + ]; + group = "+code"; + } + { + __unkeyed-1 = "f"; + mode = "n"; + group = "+find/file"; + } + + { + __unkeyed-1 = "g"; + mode = [ + "n" + "v" + ]; + group = "+git"; + } + + { + __unkeyed-1 = "q"; + mode = "n"; + group = "+quit/session"; + } + + { + __unkeyed-1 = "s"; + mode = "n"; + group = "+search"; + } + + { + __unkeyed-1 = "u"; + mode = "n"; + group = "+ui"; + } + + { + __unkeyed-1 = "w"; + mode = "n"; + group = "+windows"; + } + ]; + }; + }; +} diff --git a/home/nixvim/plugins/editor/yazi.nix b/home/nixvim/plugins/editor/yazi.nix new file mode 100644 index 0000000..95d718b --- /dev/null +++ b/home/nixvim/plugins/editor/yazi.nix @@ -0,0 +1,19 @@ +{ + plugins.yazi.enable = true; + + keymaps = [ + { + mode = "n"; + key = "E"; + action.__raw = '' + function() + require('yazi').yazi() + end + ''; + options = { + desc = "Yazi toggle"; + silent = true; + }; + } + ]; +} diff --git a/home/nixvim/plugins/git/gitsigns.nix b/home/nixvim/plugins/git/gitsigns.nix new file mode 100644 index 0000000..85b09aa --- /dev/null +++ b/home/nixvim/plugins/git/gitsigns.nix @@ -0,0 +1,102 @@ +{ + plugins.gitsigns = { + enable = true; + settings = { + trouble = true; + current_line_blame = false; + }; + }; + + keymaps = [ + { + mode = [ + "n" + "v" + ]; + key = "gh"; + action = "gitsigns"; + options = { + silent = true; + desc = "+hunks"; + }; + } + { + mode = "n"; + key = "ghb"; + action = ":Gitsigns blame_line"; + options = { + silent = true; + desc = "Blame line"; + }; + } + { + mode = "n"; + key = "ghd"; + action = ":Gitsigns diffthis"; + options = { + silent = true; + desc = "Diff This"; + }; + } + { + mode = "n"; + key = "ghp"; + action = ":Gitsigns preview_hunk"; + options = { + silent = true; + desc = "Preview hunk"; + }; + } + { + mode = "n"; + key = "ghR"; + action = ":Gitsigns reset_buffer"; + options = { + silent = true; + desc = "Reset Buffer"; + }; + } + { + mode = [ + "n" + "v" + ]; + key = "ghr"; + action = ":Gitsigns reset_hunk"; + options = { + silent = true; + desc = "Reset Hunk"; + }; + } + { + mode = [ + "n" + "v" + ]; + key = "ghs"; + action = ":Gitsigns stage_hunk"; + options = { + silent = true; + desc = "Stage Hunk"; + }; + } + { + mode = "n"; + key = "ghS"; + action = ":Gitsigns stage_buffer"; + options = { + silent = true; + desc = "Stage Buffer"; + }; + } + { + mode = "n"; + key = "ghu"; + action = ":Gitsigns undo_stage_hunk"; + options = { + silent = true; + desc = "Undo Stage Hunk"; + }; + } + ]; +} diff --git a/home/nixvim/plugins/lang/cpp.nix b/home/nixvim/plugins/lang/cpp.nix new file mode 100644 index 0000000..db917e0 --- /dev/null +++ b/home/nixvim/plugins/lang/cpp.nix @@ -0,0 +1,92 @@ +{pkgs, ...}: { + plugins = { + conform-nvim.settings = { + formatters_by_ft = { + cpp = ["clang-format"]; + }; + + formatters = { + clang-format = { + command = "${pkgs.clang-tools}/bin/clang-format"; + }; + }; + }; + + lsp.servers = { + cmake.enable = true; + clangd = { + enable = true; + cmd = [ + "clangd" + "--offset-encoding=utf-16" + "--header-insertion=iwyu" + "--background-index" + "--clang-tidy" + "--all-scopes-completion" + "--completion-style=detailed" + "--function-arg-placeholders" + "--fallback-style=llvm" + "-j=6" + ]; + onAttach.function = '' + vim.keymap.set('n', 'gh', "ClangdSwitchSourceHeader", { desc = "Switch Source/Header (C/C++)", buffer = bufnr }) + + require("clangd_extensions.inlay_hints").setup_autocmd() + require("clangd_extensions.inlay_hints").set_inlay_hints() + ''; + extraOptions = { + init_options = { + usePlaceholders = true; + completeUnimported = true; + clangdFileStatus = true; + }; + }; + }; + }; + + clangd-extensions = { + enable = true; + settings = { + inlay_hints.inline = false; + codelens.enable = true; + ast = { + role_icons = { + type = ""; + declaration = ""; + expression = ""; + specifier = ""; + statement = ""; + templateArgument = ""; + }; + kind_icons = { + compound = ""; + recovery = ""; + translationUnit = ""; + packExpansion = ""; + templateTypeParm = ""; + templateTemplateParm = ""; + templateParamObject = ""; + }; + }; + }; + }; + + dap = { + adapters.executables.lldb.command = "${pkgs.lldb}/bin/lldb-vscode"; + + configurations.cpp = [ + { + name = "C++"; + type = "lldb"; + request = "launch"; + cwd = "\${workspaceFolder}"; + program.__raw = '' + function() + return vim.fn.input('Executable path: ', vim.fn.getcwd() .. '/', 'file') + end + ''; + } + ]; + }; + }; +} diff --git a/home/nixvim/plugins/lang/css.nix b/home/nixvim/plugins/lang/css.nix new file mode 100644 index 0000000..408cb1a --- /dev/null +++ b/home/nixvim/plugins/lang/css.nix @@ -0,0 +1,37 @@ +{ + pkgs, + lib, + ... +}: { + plugins = { + conform-nvim.settings = { + formatters_by_ft.css = [ + "prettierd" + "prettier" + ]; + + formatters = { + prettierd.command = "${pkgs.prettierd}/bin/prettierd"; + prettier.command = "${pkgs.nodePackages.prettier}/bin/prettier"; + }; + }; + + lsp.servers = { + cssls = { + enable = true; + cmd = [ + "${pkgs.vscode-langservers-extracted}/bin/vscode-css-language-server" + "--stdio" + ]; + }; + + tailwindcss = { + enable = true; + cmd = [ + (lib.getExe pkgs.tailwindcss-language-server) + "--stdio" + ]; + }; + }; + }; +} diff --git a/home/nixvim/plugins/lang/docker.nix b/home/nixvim/plugins/lang/docker.nix new file mode 100644 index 0000000..d354cb3 --- /dev/null +++ b/home/nixvim/plugins/lang/docker.nix @@ -0,0 +1,20 @@ +{pkgs, ...}: { + plugins = { + lsp.servers = { + dockerls.enable = true; + docker_compose_language_service.enable = true; + }; + + lint = { + lintersByFt = { + docker = ["hadolint"]; + }; + + linters = { + hadolint = { + cmd = "${pkgs.hadolint}/bin/hadolint"; + }; + }; + }; + }; +} diff --git a/home/nixvim/plugins/lang/html.nix b/home/nixvim/plugins/lang/html.nix new file mode 100644 index 0000000..f7b32da --- /dev/null +++ b/home/nixvim/plugins/lang/html.nix @@ -0,0 +1,44 @@ +{ + pkgs, + lib, + ... +}: { + plugins = { + conform-nvim.settings = { + formatters_by_ft.html = [ + "prettierd" + "prettier" + ]; + + formatters = { + prettierd.command = "${pkgs.prettierd}/bin/prettierd"; + prettier.command = "${pkgs.nodePackages.prettier}/bin/prettier"; + }; + }; + + lsp = { + servers = { + html = { + enable = true; + cmd = [ + "${pkgs.vscode-langservers-extracted}/bin/vscode-html-language-server" + "--stdio" + ]; + }; + }; + + enabledServers = [ + { + name = "emmet_language_server"; + extraOptions = { + cmd = [ + (lib.getExe pkgs.emmet-language-server) + "--stdio" + ]; + filetypes = ["html"]; + }; + } + ]; + }; + }; +} diff --git a/home/nixvim/plugins/lang/json.nix b/home/nixvim/plugins/lang/json.nix new file mode 100644 index 0000000..8ad6fda --- /dev/null +++ b/home/nixvim/plugins/lang/json.nix @@ -0,0 +1,31 @@ +{pkgs, ...}: { + plugins = { + conform-nvim.settings = { + formatters_by_ft = { + json = ["jq"]; + }; + + formatters = { + jq = { + command = "${pkgs.jq}/bin/jq"; + }; + }; + }; + + lint = { + lintersByFt = { + json = ["jsonlint"]; + }; + + linters = { + jsonlint = { + cmd = "${pkgs.nodePackages_latest.jsonlint}/bin/jsonlint"; + }; + }; + }; + + lsp.servers.jsonls = { + enable = true; + }; + }; +} diff --git a/home/nixvim/plugins/lang/lua.nix b/home/nixvim/plugins/lang/lua.nix new file mode 100644 index 0000000..bc9895c --- /dev/null +++ b/home/nixvim/plugins/lang/lua.nix @@ -0,0 +1,22 @@ +{pkgs, ...}: { + plugins = { + lsp.servers.lua_ls.enable = true; + + conform-nvim.settings = { + formatters_by_ft = { + lua = ["stylua"]; + }; + + formatters = { + stylua = { + command = "${pkgs.stylua}/bin/stylua"; + }; + }; + }; + + lint = { + lintersByFt.lua = ["luacheck"]; + linters.luacheck.cmd = "${pkgs.lua54Packages.luacheck}/bin/luacheck"; + }; + }; +} diff --git a/home/nixvim/plugins/lang/markdown.nix b/home/nixvim/plugins/lang/markdown.nix new file mode 100644 index 0000000..459a48a --- /dev/null +++ b/home/nixvim/plugins/lang/markdown.nix @@ -0,0 +1,69 @@ +{ + lib, + pkgs, + ... +}: { + extraPackages = with pkgs; [ + marksman + ]; + + plugins = { + clipboard-image = { + enable = true; + clipboardPackage = pkgs.wl-clipboard; + }; + + image = { + enable = lib.nixvim.enableExceptInTests; + settings.integrations.markdown = { + clearInInsertMode = true; + onlyRenderImageAtCursor = true; + }; + }; + + markdown-preview = { + enable = true; + }; + + render-markdown = { + enable = true; + }; + + lsp.servers = { + marksman.enable = true; + + ltex = { + enable = true; + filetypes = [ + "markdown" + "text" + ]; + + settings.completionEnabled = true; + + extraOptions = { + checkFrequency = "save"; + language = "en-GB"; + }; + }; + }; + # markdownlint-cli2 have problems in build. + # need to try a newer version in future, + # lint = { + # lintersByFt.md = [ "markdownlint-cli2" ]; + # linters.markdownlint-cli2.cmd = "${pkgs.markdownlint-cli2}/bin/markdownlint-cli2"; + # }; + }; + + keymaps = [ + { + mode = "n"; + key = "m"; + action = "MarkdownPreviewToggle"; + options = { + silent = true; + desc = "Toggle markdown preview"; + }; + } + ]; +} diff --git a/home/nixvim/plugins/lang/nix.nix b/home/nixvim/plugins/lang/nix.nix new file mode 100644 index 0000000..fd7aee0 --- /dev/null +++ b/home/nixvim/plugins/lang/nix.nix @@ -0,0 +1,49 @@ +{pkgs, ...}: let + flake = "/home/atp/System/atpos/"; +in { + plugins = { + nix.enable = true; + hmts.enable = true; + nix-develop.enable = true; + + conform-nvim.settings = { + formatters_by_ft = { + nix = ["alejandra"]; + }; + + formatters = { + alejandra = { + command = "${pkgs.alejandra}/bin/alejandra"; + }; + }; + }; + + lint = { + lintersByFt = { + nix = ["statix"]; + }; + + linters = { + statix = { + cmd = "${pkgs.statix}/bin/statix"; + }; + }; + }; + + lsp.servers.nixd = { + enable = true; + settings = { + nixpkgs.expr = ''import (builtins.getFlake "${flake}").inputs.nixpkgs { }''; + options = { + nixos.expr = ''(builtins.getFlake "${flake}").nixosConfigurations.alfhiem.options''; + home_manager.expr = ''(builtins.getFlake "${flake}").nixosConfigurations.alfhiem.options''; + }; + flake_parts.expr = ''let flake = builtins.getFlake ("${flake}"); in flake.debug.options // flake.currentSystem.options''; + }; + }; + }; + + extraConfigVim = '' + au BufRead,BufNewFile flake.lock setf json + ''; +} diff --git a/home/nixvim/plugins/lang/python.nix b/home/nixvim/plugins/lang/python.nix new file mode 100644 index 0000000..96c02d4 --- /dev/null +++ b/home/nixvim/plugins/lang/python.nix @@ -0,0 +1,44 @@ +{pkgs, ...}: { + plugins = { + dap.extensions.dap-python.enable = true; + + conform-nvim.settings = { + formatters_by_ft.python = [ + "ruff_format" + "ruff_organize_imports" + ]; + }; + + lint = { + lintersByFt.python = ["mypy"]; + linters.mypy = { + cmd = "${pkgs.mypy}/bin/mypy"; + args = ["--ignore-missing-imports"]; + }; + }; + + lsp.servers = { + pyright = { + enable = true; + extraOptions.settings = { + # Using Ruff's import organizer + pyright.disableOrganizeImports = true; + python.analysis = { + # Ignore all files for analysis to exclusively use Ruff for linting + ignore.__raw = ''{ '*' }''; + }; + }; + }; + + ruff = { + enable = true; + onAttach.function = '' + if client.name == 'ruff' then + -- Disable hover in favor of Pyright + client.server_capabilities.hoverProvider = false + end + ''; + }; + }; + }; +} diff --git a/home/nixvim/plugins/lang/shell.nix b/home/nixvim/plugins/lang/shell.nix new file mode 100644 index 0000000..6ee8a35 --- /dev/null +++ b/home/nixvim/plugins/lang/shell.nix @@ -0,0 +1,16 @@ +{pkgs, ...}: { + plugins = { + conform-nvim.settings = { + formatters_by_ft = { + sh = ["shfmt"]; + }; + formatters = { + shfmt = { + command = "${pkgs.shfmt}/bin/shfmt"; + }; + }; + }; + + lsp.servers.bashls.enable = true; + }; +} diff --git a/home/nixvim/plugins/lang/typescript.nix b/home/nixvim/plugins/lang/typescript.nix new file mode 100644 index 0000000..607fa84 --- /dev/null +++ b/home/nixvim/plugins/lang/typescript.nix @@ -0,0 +1,90 @@ +{pkgs, ...}: { + plugins = { + conform-nvim.settings = { + formatters_by_ft = { + javascript = ["eslint_d"]; + javascriptreact = ["eslint_d"]; + typescript = ["eslint_d"]; + typescriptreact = ["eslint_d"]; + svelte = ["eslint_d"]; + }; + + formatters.eslint_d = { + command = "${pkgs.eslint_d}/bin/eslint_d"; + }; + }; + + lsp.servers = { + svelte.enable = true; + + eslint = { + enable = true; + filetypes = [ + "javascript" + "javascriptreact" + "javascript.jsx" + "typescript" + "typescriptreact" + "typescript.tsx" + "vue" + "html" + "markdown" + "json" + "jsonc" + "yaml" + "toml" + "xml" + "gql" + "graphql" + "svelte" + "css" + "less" + "scss" + "pcss" + "postcss" + ]; + }; + + ts_ls = { + enable = true; + filetypes = [ + "javascript" + "javascriptreact" + "typescript" + "typescriptreact" + "svelte" + ]; + + settings = { + complete_function_calls = true; + vtsls = { + autoUseWorkspaceTsdk = true; + experimental = { + completion = { + enableServerSideFuzzyMatch = true; + }; + }; + }; + + typescript = { + updateImportsOnFileMove.enabled = "always"; + suggest = { + completeFunctionCalls = true; + }; + + inlayHints = { + enumMemberValues.enabled = true; + functionLikeReturnTypes.enabled = true; + parameterNames.enabled = "literals"; + parameterTypes.enabled = true; + propertyDeclarationTypes.enabled = true; + variableType.enabled = false; + }; + }; + }; + }; + }; + + ts-autotag.enable = true; + }; +} diff --git a/home/nixvim/plugins/lang/yaml.nix b/home/nixvim/plugins/lang/yaml.nix new file mode 100644 index 0000000..9485eee --- /dev/null +++ b/home/nixvim/plugins/lang/yaml.nix @@ -0,0 +1,15 @@ +{ + plugins.lsp.servers.yamlls = { + enable = true; + extraOptions = { + capabilities = { + textDocument = { + foldingRange = { + dynamicRegistration = false; + lineFoldingOnly = true; + }; + }; + }; + }; + }; +} diff --git a/home/nixvim/plugins/lsp/conform.nix b/home/nixvim/plugins/lsp/conform.nix new file mode 100644 index 0000000..cd8d387 --- /dev/null +++ b/home/nixvim/plugins/lsp/conform.nix @@ -0,0 +1,46 @@ +{ + pkgs, + lib, + ... +}: { + plugins.conform-nvim = { + enable = true; + settings = { + format_on_save = { + lspFallback = true; + timeoutMs = 500; + }; + formatters_by_ft = { + # Use the "_" filetype to run formatters on filetypes that don't have other formatters configured. + "_" = [ + "squeeze_blanks" + "trim_whitespace" + "trim_newlines" + ]; + }; + formatters = { + _ = { + command = "${pkgs.gawk}/bin/gawk"; + }; + squeeze_blanks = { + command = lib.getExe' pkgs.coreutils "cat"; + }; + }; + }; + }; + + keymaps = [ + { + mode = [ + "n" + "v" + ]; + key = "cf"; + action = "lua require('conform').format()"; + options = { + silent = true; + desc = "Format"; + }; + } + ]; +} diff --git a/home/nixvim/plugins/lsp/fidget.nix b/home/nixvim/plugins/lsp/fidget.nix new file mode 100644 index 0000000..e04dcd4 --- /dev/null +++ b/home/nixvim/plugins/lsp/fidget.nix @@ -0,0 +1,91 @@ +{lib, ...}: { + plugins.fidget = { + enable = true; + settings = { + logger = { + level = "warn"; # “off”, “error”, “warn”, “info”, “debug”, “trace” + float_precision = 0.01; # Limit the number of decimals displayed for floats + }; + notification = { + poll_rate = 10; # How frequently to update and render notifications + filter = "info"; # “off”, “error”, “warn”, “info”, “debug”, “trace” + history_size = 128; # Number of removed messages to retain in history + override_vim_notify = true; + + window = { + normal_hl = "Comment"; + winblend = 0; + border = "none"; # none, single, double, rounded, solid, shadow + zindex = 45; + max_width = 0; + max_height = 0; + x_padding = 1; + y_padding = 0; + align = "bottom"; + relative = "editor"; + }; + view = { + stack_upwards = true; # Display notification items from bottom to top + icon_separator = " "; # Separator between group name and icon + group_separator = "---"; # Separator between notification groups + group_separator_hl = + # Highlight group used for group separator + "Comment"; + }; + }; + progress = { + poll_rate = 0; # How and when to poll for progress messages + suppress_on_insert = true; # Suppress new messages while in insert mode + ignore_done_already = false; # Ignore new tasks that are already complete + ignore_empty_message = false; # Ignore new tasks that don't contain a message + clear_on_detach = + # Clear notification group when LSP server detaches + '' + function(client_id) + local client = vim.lsp.get_client_by_id(client_id) + return client and client.name or nil + end + ''; + notification_group = + # How to get a progress message's notification group key + '' + function(msg) return msg.lsp_client.name end + ''; + ignore = []; # List of LSP servers to ignore + lsp = { + progress_ringbuf_size = 0; # Configure the nvim's LSP progress ring buffer size + }; + display = { + render_limit = 16; # How many LSP messages to show at once + done_ttl = 3; # How long a message should persist after completion + done_icon = "✔"; # Icon shown when all LSP progress tasks are complete + done_style = "Constant"; # Highlight group for completed LSP tasks + progress_ttl = lib.nixvim.mkRaw "math.huge"; # How long a message should persist when in progress + progress_icon = { + pattern = "dots"; + period = 1; + }; # Icon shown when LSP progress tasks are in progress + progress_style = "WarningMsg"; # Highlight group for in-progress LSP tasks + group_style = "Title"; # Highlight group for group name (LSP server name) + icon_style = "Question"; # Highlight group for group icons + priority = 30; # Ordering priority for LSP notification group + skip_history = true; # Whether progress notifications should be omitted from history + format_message = '' + require ("fidget.progress.display").default_format_message + ''; # How to format a progress message + format_annote = '' + function (msg) return msg.title end + ''; # How to format a progress annotation + format_group_name = '' + function (group) return tostring (group) end + ''; # How to format a progress notification group's name + overrides = { + rust_analyzer = { + name = "rust-analyzer"; + }; + }; # Override options from the default notification config + }; + }; + }; + }; +} diff --git a/home/nixvim/plugins/lsp/lsp.nix b/home/nixvim/plugins/lsp/lsp.nix new file mode 100644 index 0000000..dc3355e --- /dev/null +++ b/home/nixvim/plugins/lsp/lsp.nix @@ -0,0 +1,24 @@ +{ + plugins = { + lsp-signature.enable = true; + + lsp = { + enable = true; + servers.typos_lsp.enable = true; + keymaps.lspBuf = { + "" = "signature_help"; + "gi" = "implementation"; + }; + }; + lint.enable = true; + }; + + keymaps = [ + { + mode = "n"; + key = "cl"; + action = "LspInfo"; + options.desc = "Lsp Info"; + } + ]; +} diff --git a/home/nixvim/plugins/lsp/lspsaga.nix b/home/nixvim/plugins/lsp/lspsaga.nix new file mode 100644 index 0000000..8c79b2b --- /dev/null +++ b/home/nixvim/plugins/lsp/lspsaga.nix @@ -0,0 +1,184 @@ +{ + plugins = { + lspsaga = { + enable = true; + settings = { + beacon.enable = true; + outline = { + close_after_jump = true; + layout = "normal"; # normal or float + win_position = "right"; # left or right + keys = { + jump = "e"; + quit = "q"; + toggle_or_jump = "o"; + }; + }; + symbol_in_winbar = { + enable = true; # Breadcrumbs + show_file = false; + }; + rename.keys = { + exec = ""; + quit = [ + "" + "" + ]; + select = "x"; + }; + scroll_preview = { + scroll_up = ""; + scroll_down = ""; + }; + lightbulb = { + enable = true; + sign = true; + }; + code_action = { + show_server_name = true; + num_shortcut = false; + only_in_cursor = false; + keys = { + exec = ""; + quit = [ + "" + "q" + ]; + }; + }; + ui.border = "rounded"; # One of none, single, double, rounded, solid, shadow + hover = { + openCmd = "!firfox"; + openLink = "gx"; + }; + }; + }; + + which-key.settings.spec = [ + { + __unkeyed-1 = "gp"; + mode = "n"; + group = "+peek"; + } + ]; + }; + + keymaps = [ + { + mode = "n"; + key = "K"; + # action = "Lspsaga hover_doc"; + action.__raw = '' + function() + local winid = require("ufo").peekFoldedLinesUnderCursor() + if not winid then + vim.cmd("Lspsaga hover_doc") + end + end + ''; + options = { + desc = "Hover"; + silent = true; + }; + } + { + mode = "n"; + key = "lo"; + action = "Lspsaga outline"; + options = { + desc = "Outline"; + silent = true; + }; + } + { + mode = "n"; + key = "lr"; + action = "Lspsaga rename"; + options = { + desc = "Rename"; + silent = true; + }; + } + { + mode = "n"; + key = "ca"; + action = "Lspsaga code_action"; + options = { + desc = "Code Action"; + silent = true; + }; + } + { + mode = "n"; + key = "cd"; + action = "Lspsaga show_buf_diagnostics"; + options = { + desc = "Line Diagnostics"; + silent = true; + }; + } + { + mode = "n"; + key = "gd"; + action = "Lspsaga goto_definition"; + options = { + desc = "Goto Definition"; + silent = true; + }; + } + { + mode = "n"; + key = "gt"; + action = "Lspsaga goto_type_definition"; + options = { + desc = "Type Definitions"; + silent = true; + }; + } + { + mode = "n"; + key = "gpd"; + action = "Lspsaga peek_definition"; + options = { + desc = "Peek Definitions"; + silent = true; + }; + } + { + mode = "n"; + key = "gpt"; + action = "Lspsaga peek_type_definition"; + options = { + desc = "Peek Type Definitions"; + silent = true; + }; + } + { + mode = "n"; + key = "gl"; + action = "Lspsaga show_line_diagnostics"; + options = { + desc = "Line Diagnostics"; + silent = true; + }; + } + { + mode = "n"; + key = "[d"; + action = "Lspsaga diagnostic_jump_next"; + options = { + desc = "Next Diagnostic"; + silent = true; + }; + } + { + mode = "n"; + key = "]d"; + action = "Lspsaga diagnostic_jump_prev"; + options = { + desc = "Previous Diagnostic"; + silent = true; + }; + } + ]; +} diff --git a/home/nixvim/plugins/lsp/trouble.nix b/home/nixvim/plugins/lsp/trouble.nix new file mode 100644 index 0000000..888ac18 --- /dev/null +++ b/home/nixvim/plugins/lsp/trouble.nix @@ -0,0 +1,50 @@ +{ + plugins.trouble = { + enable = true; + settings.auto_close = true; + }; + + keymaps = [ + { + mode = "n"; + key = "x"; + action = "+diagnostics/quickfix"; + } + { + mode = "n"; + key = "xx"; + action = "TroubleToggle"; + options = { + silent = true; + desc = "Document Diagnostics (Trouble)"; + }; + } + { + mode = "n"; + key = "xX"; + action = "TroubleToggle workspace_diagnostics"; + options = { + silent = true; + desc = "Workspace Diagnostics (Trouble)"; + }; + } + { + mode = "n"; + key = "xt"; + action = "TroubleToggle todo"; + options = { + silent = true; + desc = "Todo (Trouble)"; + }; + } + { + mode = "n"; + key = "xq"; + action = "TodoQuickFix"; + options = { + silent = true; + desc = "Quickfix List (Trouble)"; + }; + } + ]; +} diff --git a/home/nixvim/plugins/luasnip/default.nix b/home/nixvim/plugins/luasnip/default.nix new file mode 100644 index 0000000..2efb62d --- /dev/null +++ b/home/nixvim/plugins/luasnip/default.nix @@ -0,0 +1,15 @@ +{pkgs, ...}: { + plugins.luasnip = { + enable = true; + settings = { + enable_autosnippets = true; + store_selection_keys = ""; + }; + fromVscode = [ + { + lazyLoad = true; + paths = "${pkgs.vimPlugins.friendly-snippets}"; + } + ]; + }; +} diff --git a/home/nixvim/plugins/telescope/default.nix b/home/nixvim/plugins/telescope/default.nix new file mode 100644 index 0000000..fe99f39 --- /dev/null +++ b/home/nixvim/plugins/telescope/default.nix @@ -0,0 +1,144 @@ +{pkgs, ...}: { + plugins = { + project-nvim.enableTelescope = true; + telescope = { + enable = true; + extensions = { + fzf-native.enable = true; + undo.enable = true; + ui-select = { + settings = { + specific_opts = { + codeactions = true; + }; + }; + }; + }; + + settings.defaults = { + prompt_prefix = "  "; + color_devicons = true; + set_env.COLORTERM = "truecolor"; + + mappings = { + i = { + # Have Telescope not to enter a normal-like mode when hitting escape (and instead exiting), you can map to do so via: + "".__raw = '' + function(...) + return require("telescope.actions").close(...) + end''; + "".__raw = '' + function(...) + require('trouble.providers.telescope').open_with_trouble(...); + end + ''; + }; + n = { + "".__raw = '' + function(...) + require('trouble.providers.telescope').open_with_trouble(...); + end + ''; + }; + }; + # trim leading whitespace from grep + vimgrep_arguments = [ + "${pkgs.ripgrep}/bin/rg" + "--color=never" + "--no-heading" + "--with-filename" + "--line-number" + "--column" + "--smart-case" + "--trim" + ]; + }; + keymaps = { + "fp" = { + action = "projects"; + options.desc = "Search Todo"; + }; + "st" = { + action = "todo-comments"; + options.desc = "Search Todo"; + }; + "sn" = { + action = "notify"; + options.desc = "Search Notifications"; + }; + "su" = { + action = "undo"; + options.desc = "Search Undo"; + }; + "" = { + action = "find_files"; + options.desc = "Find project files"; + }; + "ff" = { + action = "find_files hidden=true"; + options.desc = "Find project files"; + }; + "/" = { + action = "live_grep"; + options.desc = "Grep (root dir)"; + }; + ":" = { + action = "command_history"; + options.desc = "Command History"; + }; + "fr" = { + action = "oldfiles"; + options.desc = "Recent"; + }; + "" = { + mode = [ + "n" + "i" + ]; + action = "registers"; + options.desc = "Select register to paste"; + }; + "gc" = { + action = "git_commits"; + options.desc = "commits"; + }; + "sa" = { + action = "autocommands"; + options.desc = "Auto Commands"; + }; + "sc" = { + action = "commands"; + options.desc = "Commands"; + }; + "sd" = { + action = "diagnostics bufnr=0"; + options.desc = "Workspace diagnostics"; + }; + "sh" = { + action = "help_tags"; + options.desc = "Help pages"; + }; + "sk" = { + action = "keymaps"; + options.desc = "Key maps"; + }; + "sM" = { + action = "man_pages"; + options.desc = "Man pages"; + }; + "sm" = { + action = "marks"; + options.desc = "Jump to Mark"; + }; + "so" = { + action = "vim_options"; + options.desc = "Options"; + }; + "uC" = { + action = "colorscheme"; + options.desc = "Colorscheme preview"; + }; + }; + }; + }; +} diff --git a/home/nixvim/plugins/theme/default.nix b/home/nixvim/plugins/theme/default.nix new file mode 100644 index 0000000..a386f9f --- /dev/null +++ b/home/nixvim/plugins/theme/default.nix @@ -0,0 +1,50 @@ +{ + colorschemes = { + catppuccin = { + enable = true; + settings = { + background = { + light = "macchiato"; + dark = "mocha"; + }; + flavour = "macchiato"; # “latte”, “mocha”, “frappe”, “macchiato”, “auto” + transparent_background = true; + integrations = { + cmp = true; + flash = true; + fidget = true; + gitsigns = true; + indent_blankline.enabled = true; + lsp_trouble = true; + mini.enabled = true; + neotree = true; + noice = true; + notify = true; + telescope.enabled = true; + treesitter = true; + treesitter_context = true; + which_key = true; + native_lsp = { + enabled = true; + inlay_hints = { + background = true; + }; + virtual_text = { + errors = ["italic"]; + hints = ["italic"]; + information = ["italic"]; + warnings = ["italic"]; + ok = ["italic"]; + }; + underlines = { + errors = ["underline"]; + hints = ["underline"]; + information = ["underline"]; + warnings = ["underline"]; + }; + }; + }; + }; + }; + }; +} diff --git a/home/nixvim/plugins/treesitter/treesitter-textobjects.nix b/home/nixvim/plugins/treesitter/treesitter-textobjects.nix new file mode 100644 index 0000000..d550e9e --- /dev/null +++ b/home/nixvim/plugins/treesitter/treesitter-textobjects.nix @@ -0,0 +1,50 @@ +{ + plugins.treesitter-textobjects = { + enable = true; + select = { + enable = true; + lookahead = true; + keymaps = { + "aa" = "@parameter.outer"; + "ia" = "@parameter.inner"; + "af" = "@function.outer"; + "if" = "@function.inner"; + "ac" = "@class.outer"; + "ic" = "@class.inner"; + "ii" = "@conditional.inner"; + "ai" = "@conditional.outer"; + "il" = "@loop.inner"; + "al" = "@loop.outer"; + "at" = "@comment.outer"; + }; + }; + move = { + enable = true; + gotoNextStart = { + "]m" = "@function.outer"; + "]]" = "@class.outer"; + }; + gotoNextEnd = { + "]M" = "@function.outer"; + "][" = "@class.outer"; + }; + gotoPreviousStart = { + "[m" = "@function.outer"; + "[[" = "@class.outer"; + }; + gotoPreviousEnd = { + "[M" = "@function.outer"; + "[]" = "@class.outer"; + }; + }; + swap = { + enable = true; + swapNext = { + "a" = "@parameters.inner"; + }; + swapPrevious = { + "A" = "@parameter.outer"; + }; + }; + }; +} diff --git a/home/nixvim/plugins/treesitter/treesitter.nix b/home/nixvim/plugins/treesitter/treesitter.nix new file mode 100644 index 0000000..408db1d --- /dev/null +++ b/home/nixvim/plugins/treesitter/treesitter.nix @@ -0,0 +1,14 @@ +{ + plugins = { + treesitter = { + enable = true; + settings = { + highlight.enable = true; + incremental_selection.enable = true; + indent.enable = true; + }; + nixvimInjections = true; + }; + treesitter-context.enable = true; + }; +} diff --git a/home/nixvim/plugins/ui/alpha.nix b/home/nixvim/plugins/ui/alpha.nix new file mode 100644 index 0000000..cdbd6db --- /dev/null +++ b/home/nixvim/plugins/ui/alpha.nix @@ -0,0 +1,178 @@ +{ + plugins.alpha = { + enable = true; + layout = let + padding = val: { + type = "padding"; + inherit val; + }; + in [ + (padding 4) + { + opts = { + hl = "AlphaHeader"; + position = "center"; + }; + type = "text"; + val = [ + "███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗" + "████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║" + "██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║" + "██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║" + "██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║" + "╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝" + ]; + } + (padding 6) + { + type = "button"; + val = " Find File"; + on_press.raw = "require('telescope.builtin').find_files"; + opts = { + keymap = [ + "n" + "f" + ":Telescope find_files " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "f"; + + position = "center"; + cursor = 3; + width = 40; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = " New File"; + on_press.__raw = "function() vim.cmd[[ene]] end"; + opts = { + keymap = [ + "n" + "n" + ":ene startinsert " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "n"; + + position = "center"; + cursor = 3; + width = 40; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = "󰈚 Recent Files"; + on_press.raw = "require('telescope.builtin').oldfiles"; + opts = { + keymap = [ + "n" + "r" + ":Telescope oldfiles " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "r"; + + position = "center"; + cursor = 3; + width = 40; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = "󰈭 Find Word"; + on_press.raw = "require('telescope.builtin').live_grep"; + opts = { + keymap = [ + "n" + "g" + ":Telescope live_grep " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "g"; + + position = "center"; + cursor = 3; + width = 40; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = " Restore Session"; + on_press.raw = "require('persistence').load()"; + opts = { + keymap = [ + "n" + "s" + ":lua require('persistence').load()" + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "s"; + + position = "center"; + cursor = 3; + width = 40; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = " Quit Neovim"; + on_press.__raw = "function() vim.cmd[[qa]] end"; + opts = { + keymap = [ + "n" + "q" + ":qa" + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "q"; + + position = "center"; + cursor = 3; + width = 40; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + ]; + }; +} diff --git a/home/nixvim/plugins/ui/bufferline.nix b/home/nixvim/plugins/ui/bufferline.nix new file mode 100644 index 0000000..99f1529 --- /dev/null +++ b/home/nixvim/plugins/ui/bufferline.nix @@ -0,0 +1,172 @@ +{ + plugins = { + bufferline = { + enable = true; + settings = { + highlights = { + background = { + bg = "#252434"; + fg = "#605f6f"; + }; + + buffer_selected = { + bg = "#1E1D2D"; + fg = "#D9E0EE"; + }; + buffer_visible = { + fg = "#605f6f"; + bg = "#252434"; + }; + + error = { + fg = "#605f6f"; + bg = "#252434"; + }; + error_diagnostic = { + fg = "#605f6f"; + bg = "#252434"; + }; + + close_button = { + fg = "#605f6f"; + bg = "#252434"; + }; + close_button_visible = { + fg = "#605f6f"; + bg = "#252434"; + }; + fill = { + bg = "#1E1D2D"; + fg = "#605f6f"; + }; + indicator_selected = { + bg = "#1E1D2D"; + fg = "#1E1D2D"; + }; + + modified = { + fg = "#F38BA8"; + bg = "#252434"; + }; + modified_visible = { + fg = "#F38BA8"; + bg = "#252434"; + }; + modified_selected = { + fg = "#ABE9B3"; + bg = "#1E1D2D"; + }; + + separator = { + bg = "#252434"; + fg = "#252434"; + }; + separator_visible = { + bg = "#252434"; + fg = "#252434"; + }; + separator_selected = { + bg = "#252434"; + fg = "#252434"; + }; + + duplicate = { + fg = "NONE"; + bg = "#252434"; + }; + duplicate_selected = { + fg = "#F38BA8"; + bg = "#1E1D2D"; + }; + duplicate_visible = { + fg = "#89B4FA"; + bg = "#252434"; + }; + }; + + options.offsets = [ + { + filetype = "neo-tree"; + text = "Neo-tree"; + highlight = "Directory"; + text_align = "left"; + } + ]; + }; + }; + }; + + keymaps = [ + { + mode = "n"; + key = ""; + action = "BufferLineCycleNext"; + options = { + desc = "Cycle to next buffer"; + }; + } + + { + mode = "n"; + key = ""; + action = "BufferLineCyclePrev"; + options = { + desc = "Cycle to previous buffer"; + }; + } + + { + mode = "n"; + key = ""; + action = ":bp | bd #"; + options = { + desc = "Delete buffer"; + }; + } + + { + mode = "n"; + key = "br"; + action = "BufferLineCloseRight"; + options = { + desc = "Delete buffers to the right"; + }; + } + + { + mode = "n"; + key = "bl"; + action = "BufferLineCloseLeft"; + options = { + desc = "Delete buffers to the left"; + }; + } + + { + mode = "n"; + key = "bo"; + action = "BufferLineCloseOthers"; + options = { + desc = "Delete other buffers"; + }; + } + + { + mode = "n"; + key = "bp"; + action = "BufferLineTogglePin"; + options = { + desc = "Toggle pin"; + }; + } + + { + mode = "n"; + key = "bP"; + action = "BufferLineGroupClose ungrouped"; + options = { + desc = "Delete non-pinned buffers"; + }; + } + ]; +} diff --git a/home/nixvim/plugins/ui/flash.nix b/home/nixvim/plugins/ui/flash.nix new file mode 100644 index 0000000..6039f5e --- /dev/null +++ b/home/nixvim/plugins/ui/flash.nix @@ -0,0 +1,40 @@ +{ + plugins.flash = { + enable = true; + settings.label.uppercase = false; + }; + + keymaps = [ + { + mode = [ + "n" + "x" + "o" + ]; + key = "s"; + action = "lua require('flash').jump()"; + options = { + desc = "Flash"; + }; + } + # { + # mode = [ "n" "x" "o" ]; + # key = "S"; + # action = "lua require('flash').treesitter()"; + # options = { + # desc = "Flash Treesitter"; + # }; + # } + { + mode = [ + "x" + "o" + ]; + key = "R"; + action = "lua require('flash').treesitter_search()"; + options = { + desc = "Treesitter Search"; + }; + } + ]; +} diff --git a/home/nixvim/plugins/ui/general.nix b/home/nixvim/plugins/ui/general.nix new file mode 100644 index 0000000..1db9e45 --- /dev/null +++ b/home/nixvim/plugins/ui/general.nix @@ -0,0 +1,10 @@ +{ + plugins = { + trim.enable = true; + neoscroll.enable = true; + dressing.enable = true; + todo-comments.enable = true; + web-devicons.enable = true; + nui.enable = true; + }; +} diff --git a/home/nixvim/plugins/ui/indent-blankline.nix b/home/nixvim/plugins/ui/indent-blankline.nix new file mode 100644 index 0000000..4b22a60 --- /dev/null +++ b/home/nixvim/plugins/ui/indent-blankline.nix @@ -0,0 +1,30 @@ +{ + plugins = { + indent-blankline = { + enable = true; + settings = { + indent = { + char = "│"; # "│" or "▎" + tab_char = "│"; + }; + scope.enabled = false; + exclude = { + buftypes = ["terminal" "nofile"]; + filetypes = [ + "help" + "alpha" + "dashboard" + "neo-tree" + "Trouble" + "trouble" + "lazy" + "mason" + "notify" + "toggleterm" + "lazyterm" + ]; + }; + }; + }; + }; +} diff --git a/home/nixvim/plugins/ui/lualine.nix b/home/nixvim/plugins/ui/lualine.nix new file mode 100644 index 0000000..3c31f7f --- /dev/null +++ b/home/nixvim/plugins/ui/lualine.nix @@ -0,0 +1,129 @@ +{ + plugins.lualine = { + enable = true; + settings = { + options = { + always_divide_middle = true; + ignore_focus = ["neo-tree"]; + globalstatus = true; # have a single statusline at bottom of neovim instead of one for every window + disabled_filetypes.statusline = [ + "dashboard" + "alpha" + ]; + section_separators = { + left = ""; + right = ""; + }; + }; + extensions = ["fzf"]; + sections = { + lualine_a = ["mode"]; + lualine_b = ["branch"]; + lualine_y = [ + "progress" + { + separator = ""; + } + "location" + { + padding = { + left = 0; + right = 1; + }; + } + ]; + lualine_z = [''" " .. os.date("%R")'']; + }; + }; + }; + extraConfigLua = '' + local ui = {} + + function ui.fg(name) + local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) or vim.api.nvim_get_hl_by_name(name, true) + local fg = hl and (hl.fg or hl.foreground) + return fg and { fg = string.format("#%06x", fg) } or nil + end + + ---@param opts? {relative: "cwd"|"root", modified_hl: string?} + function ui.pretty_path(opts) + opts = vim.tbl_extend("force", { + relative = "cwd", + modified_hl = "Constant", + }, opts or {}) + + return function(self) + local path = vim.fn.expand("%:p") --[[@as string]] + + if path == "" then + return "" + end + + local bufname = vim.fn.bufname(vim.fn.bufnr()) + local sep = package.config:sub(1, 1) + + local root = (opts.relative == "root") and vim.fn.getcwd() or vim.fn.fnamemodify(bufname, ":h") + local cwd = vim.fn.getcwd() + + path = (opts.relative == "cwd" and path:find(cwd, 1, true) == 1) and path:sub(#cwd + 2) or path:sub(#root + 2) + + local parts = vim.split(path, "[\\/]") + if #parts > 3 then + parts = { parts[1], "…", parts[#parts - 1], parts[#parts] } + end + + if opts.modified_hl and vim.bo.modified then + local modified_hl_fg = ui.fg(opts.modified_hl) + if modified_hl_fg then + parts[#parts] = string.format("%%#%s#%s%%*", opts.modified_hl, parts[#parts]) + end + end + + return table.concat(parts, sep) + end + end + + require("lualine").setup({ + sections = { + lualine_c = { + { + "diagnostics", + symbols = { + error = " ", + warn = " ", + hint = " ", + info = " ", + }, + }, + { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, + { ui.pretty_path() }, + }, + lualine_x = { + { + function() return require("noice").api.status.command.get() end, + cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end, + color = ui.fg("Statement"), + }, + { + function() return require("noice").api.status.mode.get() end, + cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end, + color = ui.fg("Constant"), + }, + { + function() return " " .. require("dap").status() end, + cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end, + color = ui.fg("Debug"), + }, + { + "diff", + symbols = { + added = " ", + modified = " ", + removed= " ", + }, + }, + } + } + }) + ''; +} diff --git a/home/nixvim/plugins/ui/noice.nix b/home/nixvim/plugins/ui/noice.nix new file mode 100644 index 0000000..6747f9a --- /dev/null +++ b/home/nixvim/plugins/ui/noice.nix @@ -0,0 +1,38 @@ +{ + plugins.noice = { + enable = true; + settings = { + lsp = { + override = { + "vim.lsp.util.convert_input_to_markdown_lines" = true; + "vim.lsp.util.stylize_markdown" = true; + "cmp.entry.get_documentation" = true; + }; + progress.enabled = true; + }; + + presets = { + bottom_search = true; + command_palette = true; + long_message_to_split = true; + inc_rename = true; + lsp_doc_border = true; + }; + notify.enabled = true; + + routes = [ + { + filter = { + event = "msg_show"; + any = [ + {find = "%d+L, %d+B";} + {find = "; after #%d+";} + {find = "; before #%d+";} + ]; + }; + view = "mini"; + } + ]; + }; + }; +} diff --git a/home/nixvim/plugins/ui/notify.nix b/home/nixvim/plugins/ui/notify.nix new file mode 100644 index 0000000..119ac09 --- /dev/null +++ b/home/nixvim/plugins/ui/notify.nix @@ -0,0 +1,47 @@ +{ + plugins.notify = { + enable = true; + # remove animations for preformance + settings = { + stages = "static"; + timeout = 4000; + }; + }; + + keymaps = [ + { + mode = "n"; + key = "un"; + action = '' + lua require("notify").dismiss({ silent = true, pending = true }) + ''; + options = { + desc = "Dismiss All Notifications"; + }; + } + ]; + + extraConfigLua = '' + local notify = require("notify") + + local filtered_message = { "No information available" } + + -- Override notify function to filter out messages + ---@diagnostic disable-next-line: duplicate-set-field + vim.notify = function(message, level, opts) + local merged_opts = vim.tbl_extend("force", { + on_open = function(win) + local buf = vim.api.nvim_win_get_buf(win) + vim.api.nvim_buf_set_option(buf, "filetype", "markdown") + end, + }, opts or {}) + + for _, msg in ipairs(filtered_message) do + if message == msg then + return + end + end + return notify(message, level, merged_opts) + end + ''; +} diff --git a/home/nixvim/plugins/ui/precognition.nix b/home/nixvim/plugins/ui/precognition.nix new file mode 100644 index 0000000..9070646 --- /dev/null +++ b/home/nixvim/plugins/ui/precognition.nix @@ -0,0 +1,29 @@ +{ + plugins.precognition = { + enable = true; + settings = { + startVisible = false; + }; + }; + + keymaps = [ + { + mode = "n"; + key = "up"; + action.__raw = '' + function() + if require("precognition").toggle() then + vim.notify("Precognition on") + else + vim.notify("Precognition off") + end + end + ''; + + options = { + desc = "Precognition Toggle"; + silent = true; + }; + } + ]; +} diff --git a/home/nixvim/plugins/ui/toggleterm.nix b/home/nixvim/plugins/ui/toggleterm.nix new file mode 100644 index 0000000..4fef9d7 --- /dev/null +++ b/home/nixvim/plugins/ui/toggleterm.nix @@ -0,0 +1,65 @@ +{ + plugins.toggleterm = { + enable = true; + settings = { + size = '' + function(term) + if term.direction == "horizontal" then + return 30 + elseif term.direction == "vertical" then + return vim.o.columns * 0.4 + end + end + ''; + open_mapping = "[[]]"; + hide_numbers = true; + shade_terminals = true; + start_in_insert = true; + terminal_mappings = true; + persist_mode = true; + insert_mappings = true; + close_on_exit = true; + shell = "nu"; + direction = "horizontal"; # 'vertical' | 'horizontal' | 'tab' | 'float' + float_opts = { + border = "single"; # 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open + width = 80; + height = 20; + winblend = 0; + }; + }; + }; + + keymaps = [ + { + mode = "t"; + key = ""; + action = "2ToggleTerm"; + options.desc = "Open/Close Terminal 2"; + } + { + mode = "t"; + key = ""; + action = "wincmd h"; + options.desc = "Go to Left window"; + } + { + mode = "t"; + key = ""; + action = "wincmd l"; + options.desc = "Go to Right window"; + } + { + mode = "t"; + key = ""; + action = "wincmd k"; + options.desc = "Go to Up window"; + } + { + mode = "t"; + key = ""; + action = "wincmd j"; + options.desc = "Go to Down window"; + } + ]; +} diff --git a/home/nixvim/plugins/ui/ufo.nix b/home/nixvim/plugins/ui/ufo.nix new file mode 100644 index 0000000..b5a07ae --- /dev/null +++ b/home/nixvim/plugins/ui/ufo.nix @@ -0,0 +1,95 @@ +{lib, ...}: { + autoCmd = [ + { + event = [ + "BufEnter" + "BufNew" + ]; + desc = "disable statuscolumn for neo-tree and dashboard"; + callback = lib.nixvim.mkRaw '' + function() + local ft_ignore = { "dashboard", "neo-tree" } + if vim.tbl_contains(ft_ignore, vim.bo.filetype) then + vim.cmd("setlocal foldcolumn=0") + end + end + ''; + } + ]; + + plugins = { + statuscol = { + enable = true; + settings = { + relculright = true; + ft_ignore = [ + "dashboard" + "neo-tree" + ]; + segments = [ + { + click = "v:lua.ScFa"; + text = [(lib.nixvim.mkRaw "require('statuscol.builtin').foldfunc")]; + } + { + click = "v:lua.ScSa"; + text = [" %s"]; + } + { + click = "v:lua.ScLa"; + text = [ + (lib.nixvim.mkRaw "require('statuscol.builtin').lnumfunc") + " " + ]; + } + ]; + }; + }; + + nvim-ufo = { + enable = true; + settings = { + provider_selector = + # lua + '' + function() + return { "lsp", "indent" } + end + ''; + preview.mappings = { + close = "q"; + switch = "K"; + }; + }; + }; + }; + + opts = { + foldcolumn = "1"; + foldlevel = 99; + foldlevelstart = 99; + foldenable = true; + fillchars = lib.nixvim.mkRaw "[[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]"; + }; + + keymaps = [ + { + mode = "n"; + key = "zR"; + action = lib.nixvim.mkRaw "function() require('ufo').openAllFolds() end"; + options.desc = "open all folds"; + } + { + mode = "n"; + key = "zM"; + action = lib.nixvim.mkRaw "function() require('ufo').closeAllFolds() end"; + options.desc = "close all folds"; + } + { + mode = "n"; + key = "zK"; + action = lib.nixvim.mkRaw "function() local winid = require('ufo').peekFoldedLinesUnderCursor() if not winid then vim.lsp.buf.hover() end end"; + options.desc = "Peek Folded Lines"; + } + ]; +} diff --git a/home/nixvim/plugins/util/colorizer.nix b/home/nixvim/plugins/util/colorizer.nix new file mode 100644 index 0000000..54e88fe --- /dev/null +++ b/home/nixvim/plugins/util/colorizer.nix @@ -0,0 +1,5 @@ +{ + plugins.colorizer = { + enable = true; + }; +} diff --git a/home/nixvim/plugins/util/debugprint.nix b/home/nixvim/plugins/util/debugprint.nix new file mode 100644 index 0000000..ab3ebd0 --- /dev/null +++ b/home/nixvim/plugins/util/debugprint.nix @@ -0,0 +1,34 @@ +{ + plugins.debugprint = { + enable = true; + + settings = { + commands = { + toggle_comment_debug_prints = "ToggleCommentDebugPrints"; + delete_debug_prints = "DeleteDebugPrints"; + }; + + display_counter = true; + display_snippet = true; + + keymaps = { + normal = { + plain_below = "pb"; + plain_above = "pB"; + variable_below = "pv"; + variable_above = "pV"; + variable_below_alwaysprompt.__raw = "nil"; + variable_above_alwaysprompt.__raw = "nil"; + textobj_below = "po"; + textobj_above = "pO"; + toggle_comment_debug_prints.__raw = "nil"; + delete_debug_prints.__raw = "nil"; + }; + visual = { + variable_below = "pv"; + variable_above = "pV"; + }; + }; + }; + }; +} diff --git a/home/nixvim/plugins/util/harpoon.nix b/home/nixvim/plugins/util/harpoon.nix new file mode 100644 index 0000000..1374899 --- /dev/null +++ b/home/nixvim/plugins/util/harpoon.nix @@ -0,0 +1,17 @@ +{ + plugins.harpoon = { + enable = true; + enableTelescope = true; + # keymapsSilent = true; + # keymaps = { + # addFile = "ha"; + # toggleQuickMenu = ""; + # navFile = { + # "1" = "hj"; + # "2" = "hk"; + # "3" = "hl"; + # "4" = "hm"; + # }; + # }; + }; +} diff --git a/home/nixvim/plugins/util/kulala.nix b/home/nixvim/plugins/util/kulala.nix new file mode 100644 index 0000000..d74a158 --- /dev/null +++ b/home/nixvim/plugins/util/kulala.nix @@ -0,0 +1,5 @@ +{ + plugins.kulala = { + enable = false; + }; +} diff --git a/home/nixvim/plugins/util/mini.nix b/home/nixvim/plugins/util/mini.nix new file mode 100644 index 0000000..bf3bfb7 --- /dev/null +++ b/home/nixvim/plugins/util/mini.nix @@ -0,0 +1,28 @@ +{ + plugins = { + mini = { + enable = true; + modules = { + comment = { + options = { + customCommentString = '' + lua require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring + ''; + }; + }; + # Highlight word under cursor + cursorword = { + delay = 0; + }; + + # Show indent lines + indentscope = { + symbol = "│"; + draw.delay = 0; + }; + }; + }; + + ts-context-commentstring.enable = true; + }; +} diff --git a/home/nixvim/plugins/util/nvim-autopairs.nix b/home/nixvim/plugins/util/nvim-autopairs.nix new file mode 100644 index 0000000..b748672 --- /dev/null +++ b/home/nixvim/plugins/util/nvim-autopairs.nix @@ -0,0 +1,5 @@ +{ + plugins.nvim-autopairs = { + enable = true; + }; +} diff --git a/home/nixvim/plugins/util/nvim-surround.nix b/home/nixvim/plugins/util/nvim-surround.nix new file mode 100644 index 0000000..b240582 --- /dev/null +++ b/home/nixvim/plugins/util/nvim-surround.nix @@ -0,0 +1,5 @@ +{ + plugins.nvim-surround = { + enable = true; + }; +} diff --git a/home/nixvim/plugins/util/persistence.nix b/home/nixvim/plugins/util/persistence.nix new file mode 100644 index 0000000..eb7cde3 --- /dev/null +++ b/home/nixvim/plugins/util/persistence.nix @@ -0,0 +1,5 @@ +{ + plugins.persistence = { + enable = true; + }; +} diff --git a/home/nixvim/plugins/util/plenary.nix b/home/nixvim/plugins/util/plenary.nix new file mode 100644 index 0000000..133b26f --- /dev/null +++ b/home/nixvim/plugins/util/plenary.nix @@ -0,0 +1,5 @@ +{pkgs, ...}: { + extraPlugins = with pkgs.vimPlugins; [ + plenary-nvim + ]; +} diff --git a/home/nixvim/plugins/util/project-nvim.nix b/home/nixvim/plugins/util/project-nvim.nix new file mode 100644 index 0000000..b411ec7 --- /dev/null +++ b/home/nixvim/plugins/util/project-nvim.nix @@ -0,0 +1,6 @@ +{ + plugins.project-nvim = { + enable = true; + enableTelescope = true; + }; +} diff --git a/home/nixvim/plugins/util/snacks.nix b/home/nixvim/plugins/util/snacks.nix new file mode 100644 index 0000000..c312f8a --- /dev/null +++ b/home/nixvim/plugins/util/snacks.nix @@ -0,0 +1,103 @@ +{ + config, + lib, + pkgs, + ... +}: { + extraConfigLuaPre = lib.mkOrder 1 ( + lib.optionalString + (config.plugins.snacks.enable && config.plugins.snacks.settings.profiler.enabled) # Lua + + '' + if vim.env.PROF then + local snacks = "${pkgs.vimPlugins.snacks-nvim}" + vim.opt.rtp:append(snacks) + require("snacks.profiler").startup({ + startup = { + -- event = "VimEnter", -- stop profiler on this event. Defaults to `VimEnter` + event = "UIEnter", + -- event = "VeryLazy", + }, + }) + end + '' + ); + + plugins = { + snacks = { + enable = true; + + settings = { + bigfile = { + enabled = true; + size = 1024 * 1024; # 1MB + setup.__raw = '' + function(ctx) + ${lib.optionalString config.plugins.indent-blankline.enable ''require("ibl").setup_buffer(0, { enabled = false })''} + ${lib.optionalString (lib.hasAttr "indentscope" config.plugins.mini.modules) ''vim.b.miniindentscope_disable = true''} + ${lib.optionalString config.plugins.illuminate.enable ''require("illuminate").pause_buf()''} + + -- Disable line numbers and relative line numbers + vim.cmd("setlocal nonumber norelativenumber") + + -- Syntax highlighting + vim.schedule(function() + vim.bo[ctx.buf].syntax = ctx.ft + end) + + -- Disable matchparen + vim.cmd("let g:loaded_matchparen = 1") + + -- Disable cursor line and column + vim.cmd("setlocal nocursorline nocursorcolumn") + + -- Disable folding + vim.cmd("setlocal nofoldenable") + + -- Disable sign column + vim.cmd("setlocal signcolumn=no") + + -- Disable swap file and undo file + vim.cmd("setlocal noswapfile noundofile") + + -- Disable mini animate + vim.b.minianimate_disable = true + end + ''; + }; + + gitbrowse.enabled = true; + gitui.enabled = true; + lazygit.enabled = true; + profiler.enabled = true; + }; + }; + }; + + keymaps = [ + { + mode = "n"; + key = "go"; + action = "lua Snacks.gitbrowse()"; + options = { + desc = "Open file in browser"; + }; + } + { + mode = "n"; + key = "gg"; + action = "lua Snacks.lazygit()"; + options = { + desc = "Open lazygit"; + }; + } + { + mode = "n"; + key = "gG"; + action = "lua Snacks.terminal({'gitui'})"; + options = { + desc = "Open Gitui"; + }; + } + ]; +} diff --git a/home/nixvim/plugins/util/wakatime.nix b/home/nixvim/plugins/util/wakatime.nix new file mode 100644 index 0000000..2ee4576 --- /dev/null +++ b/home/nixvim/plugins/util/wakatime.nix @@ -0,0 +1,5 @@ +{ + plugins.wakatime = { + enable = true; + }; +} diff --git a/home/nixvim/settings.nix b/home/nixvim/settings.nix new file mode 100644 index 0000000..2387e63 --- /dev/null +++ b/home/nixvim/settings.nix @@ -0,0 +1,113 @@ +{pkgs, ...}: { + config = { + extraConfigLuaPre = '' + vim.fn.sign_define("diagnosticsignerror", { text = " ", texthl = "diagnosticerror", linehl = "", numhl = "" }) + vim.fn.sign_define("diagnosticsignwarn", { text = " ", texthl = "diagnosticwarn", linehl = "", numhl = "" }) + vim.fn.sign_define("diagnosticsignhint", { text = "󰌵", texthl = "diagnostichint", linehl = "", numhl = "" }) + vim.fn.sign_define("diagnosticsigninfo", { text = " ", texthl = "diagnosticinfo", linehl = "", numhl = "" }) + ''; + + # feature that enhances the way Neovim loads and executes Lua modules, + # offering improved performance and flexibility. + luaLoader.enable = true; + clipboard = { + register = "unnamedplus"; + providers.wl-copy = { + enable = true; + package = pkgs.wl-clipboard-rs; + }; + }; + opts = { + virtualedit = "block"; # Allow cursor to move where there is no text in visual block mode + cursorline = true; # Highlight the line where the cursor is located + cmdheight = 2; # more space in the neovim command line for displaying messages + showmode = false; # Dont show the editor mode in status line + + # Enable relative line numbers + number = true; + relativenumber = true; + + # Tab spacing 2 spaces + tabstop = 2; + softtabstop = 2; + shiftwidth = 2; + expandtab = true; + + smartindent = true; + wrap = true; + + # Smart indent on word wrap + breakindent = true; + + # Undo stuff from days ago + swapfile = false; + backup = false; + undofile = true; + + # Incremental search + hlsearch = true; + incsearch = true; + + # Better splitting + splitbelow = true; + splitright = true; + + # Enable ignorecase + smartcase for better searching + ignorecase = true; + smartcase = true; # Don't ignore case with capitals + grepprg = "rg --vimgrep"; + grepformat = "%f:%l:%c:%m"; + + # Better colors + termguicolors = true; + + # Decrease updatetime + updatetime = 50; # faster completion (4000ms default) + + # Enable the sign column to prevent the screen from jumping + signcolumn = "yes"; + + # Reduce which-key timeout to 250s + timeoutlen = 250; + + scrolloff = 8; # Will never have less than 8 characters as you scroll down + mouse = "a"; # Mouse + + # Set encoding type + encoding = "utf-8"; + fileencoding = "utf-8"; + + # Maximum number of items to show in the popup menu (0 means "use available screen space") + pumheight = 0; + }; + + extraConfigLua = '' + local opt = vim.opt + local g = vim.g + local o = vim.o + -- Neovide + if g.neovide then + -- Neovide options + g.neovide_fullscreen = false + g.neovide_hide_mouse_when_typing = false + g.neovide_refresh_rate = 165 + g.neovide_cursor_vfx_mode = "ripple" + g.neovide_cursor_animate_command_line = true + g.neovide_cursor_animate_in_insert_mode = true + g.neovide_cursor_vfx_particle_lifetime = 5.0 + g.neovide_cursor_vfx_particle_density = 14.0 + g.neovide_cursor_vfx_particle_speed = 12.0 + g.neovide_transparency = 0.8 + + -- Neovide Fonts + o.guifont = "MonoLisa Trial:Medium:h15" + -- o.guifont = "CommitMono:Medium:h15" + -- o.guifont = "JetBrainsMono Nerd Font:h14:Medium:i" + -- o.guifont = "FiraMono Nerd Font:Medium:h14" + -- o.guifont = "CaskaydiaCove Nerd Font:h14:b:i" + -- o.guifont = "BlexMono Nerd Font Mono:h14:Medium:i" + -- o.guifont = "Liga SFMono Nerd Font:b:h15" + end + ''; + }; +}