commit a3f3abb4601d72edb8e85331bddc761f67b1db46 Author: unexplrd Date: Thu Feb 6 17:45:39 2025 +0200 initial diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e0993bc --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Mateus Alves + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..93a1b02 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +

+ +
+
+
+ + + + + + + + + + + + +
+ +
+

+ +

❄️ Neve ❄️

+

+ +

+ +# What is this? +This is a config based on [Neve](https://github.com/redyf/Neve) with minimal changes, as I mainly use [Helix](https://helix-editor.com/), but that might change in the future. diff --git a/config/bufferlines/bufferline.nix b/config/bufferlines/bufferline.nix new file mode 100644 index 0000000..eaf0991 --- /dev/null +++ b/config/bufferlines/bufferline.nix @@ -0,0 +1,167 @@ +{ + lib, + config, + ... +}: { + options = { + bufferline = { + enable = lib.mkEnableOption "Enable bufferline module"; + + keymaps = { + enable = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enable default keymaps"; + }; + + enableHL = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enable keymaps for switching buffers with h and l"; + }; + + enableTab = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enable keymaps for switching buffers with Tab and S-Tab"; + }; + }; + }; + }; + config = let + cfg = config.bufferline; + in + lib.mkIf cfg.enable { + plugins = { + bufferline = { + enable = true; + settings = { + options = { + separatorStyle = "thick"; # “slant”, “padded_slant”, “slope”, “padded_slope”, “thick”, “thin“ + offsets = [ + { + filetype = "neo-tree"; + text = "Neo-tree"; + highlight = "Directory"; + text_align = "left"; + } + ]; + }; + }; + }; + }; + keymaps = + lib.mkIf cfg.keymaps.enable + ([ + { + mode = "n"; + key = "bd"; + action = "bdelete"; + options = { + desc = "Delete buffer"; + }; + } + + { + mode = "n"; + key = "bb"; + action = "e #"; + options = { + desc = "Switch to Other Buffer"; + }; + } + + # { + # mode = "n"; + # key = "`"; + # action = "e #"; + # options = { + # desc = "Switch to Other 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"; + }; + } + ] + ++ (lib.optionals cfg.keymaps.enableTab [ + { + mode = "n"; + key = ""; + action = "BufferLineCycleNext"; + options = { + desc = "Cycle to next buffer"; + }; + } + + { + mode = "n"; + key = ""; + action = "BufferLineCyclePrev"; + options = { + desc = "Cycle to previous buffer"; + }; + } + ]) + ++ (lib.optionals cfg.keymaps.enableHL [ + { + mode = "n"; + key = ""; + action = "BufferLineCycleNext"; + options = { + desc = "Cycle to next buffer"; + }; + } + + { + mode = "n"; + key = ""; + action = "BufferLineCyclePrev"; + options = { + desc = "Cycle to previous buffer"; + }; + } + ])); + }; +} diff --git a/config/bufferlines/default.nix b/config/bufferlines/default.nix new file mode 100644 index 0000000..7bfd1c0 --- /dev/null +++ b/config/bufferlines/default.nix @@ -0,0 +1,16 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./bufferline.nix + ]; + + options = { + bufferlines.enable = lib.mkEnableOption "Enable bufferlines module"; + }; + config = lib.mkIf config.bufferlines.enable { + bufferline.enable = lib.mkDefault true; + }; +} diff --git a/config/colorschemes/ayu.nix b/config/colorschemes/ayu.nix new file mode 100644 index 0000000..303691f --- /dev/null +++ b/config/colorschemes/ayu.nix @@ -0,0 +1,19 @@ +{ + lib, + config, + ... +}: { + options = { + ayu.enable = lib.mkEnableOption "Enable ayu module"; + }; + config = lib.mkIf config.ayu.enable { + colorschemes = { + ayu = { + enable = true; + settings = { + mirage = true; + }; + }; + }; + }; +} diff --git a/config/colorschemes/base16.nix b/config/colorschemes/base16.nix new file mode 100644 index 0000000..9fa693a --- /dev/null +++ b/config/colorschemes/base16.nix @@ -0,0 +1,17 @@ +{ + lib, + config, + ... +}: { + options = { + base16.enable = lib.mkEnableOption "Enable base16 module"; + }; + config = lib.mkIf config.base16.enable { + colorschemes = { + base16 = { + enable = true; + colorscheme = "ayu-mirage"; + }; + }; + }; +} diff --git a/config/colorschemes/catppuccin.nix b/config/colorschemes/catppuccin.nix new file mode 100644 index 0000000..3545a89 --- /dev/null +++ b/config/colorschemes/catppuccin.nix @@ -0,0 +1,57 @@ +{ + lib, + config, + ... +}: { + options = { + catppuccin.enable = lib.mkEnableOption "Enable catppuccin module"; + }; + config = lib.mkIf config.catppuccin.enable { + colorschemes = { + catppuccin = { + enable = true; + settings = { + background = { + light = "macchiato"; + dark = "mocha"; + }; + flavour = "mocha"; # "latte", "mocha", "frappe", "macchiato" or raw lua code + disable_bold = false; + disable_italic = false; + disable_underline = false; + transparent_background = true; + term_colors = true; + integrations = { + cmp = true; + noice = true; + notify = true; + neotree = true; + harpoon = true; + gitsigns = true; + which_key = true; + illuminate = { + enabled = true; + }; + treesitter = true; + treesitter_context = true; + telescope.enabled = true; + indent_blankline.enabled = true; + mini.enabled = true; + native_lsp = { + enabled = true; + inlay_hints = { + background = true; + }; + underlines = { + errors = ["underline"]; + hints = ["underline"]; + information = ["underline"]; + warnings = ["underline"]; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/config/colorschemes/default.nix b/config/colorschemes/default.nix new file mode 100644 index 0000000..57cb985 --- /dev/null +++ b/config/colorschemes/default.nix @@ -0,0 +1,22 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./ayu.nix + ./base16.nix + ./catppuccin.nix + ./rose-pine.nix + ]; + + options = { + colorschemes.enable = lib.mkEnableOption "Enable colorschemes module"; + }; + config = lib.mkIf config.colorschemes.enable { + ayu.enable = lib.mkDefault true; + base16.enable = lib.mkDefault false; + catppuccin.enable = lib.mkDefault false; + rose-pine.enable = lib.mkDefault false; + }; +} diff --git a/config/colorschemes/rose-pine.nix b/config/colorschemes/rose-pine.nix new file mode 100644 index 0000000..6aa8a1e --- /dev/null +++ b/config/colorschemes/rose-pine.nix @@ -0,0 +1,23 @@ +{ + lib, + config, + ... +}: { + options = { + rose-pine.enable = lib.mkEnableOption "Enable rose-pine module"; + }; + config = lib.mkIf config.rose-pine.enable { + colorschemes = { + rose-pine = { + enable = true; + settings = { + styles = { + italic = true; + bold = true; + transparency = false; + }; + }; + }; + }; + }; +} diff --git a/config/completion/cmp.nix b/config/completion/cmp.nix new file mode 100644 index 0000000..acbdd8f --- /dev/null +++ b/config/completion/cmp.nix @@ -0,0 +1,174 @@ +{ + lib, + config, + ... +}: { + options = { + cmp.enable = lib.mkEnableOption "Enable cmp module"; + }; + config = lib.mkIf config.cmp.enable { + plugins = { + cmp-nvim-lsp = { + enable = true; + }; # lsp + cmp-buffer = { + enable = true; + }; + cmp-path = { + enable = true; + }; # file system paths + cmp-cmdline = { + enable = true; + }; # autocomplete for cmdline + cmp_luasnip = { + enable = true; + }; # snippets + copilot-cmp = { + enable = true; + }; # copilot suggestions + cmp = { + enable = true; + autoEnableSources = false; + settings = { + experimental = { + ghost_text = true; + }; + mapping = { + "" = "cmp.mapping.select_next_item()"; + "" = "cmp.mapping.select_prev_item()"; + + "" = '' + cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }) + ''; + + "" = '' + cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }) + ''; + + "" = "cmp.mapping.abort()"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.confirm({ select = false })"; # Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + "" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })"; + }; + sources = [ + { + name = "nvim_lsp"; + } + { + name = "buffer"; + keyword_length = 5; + } + {name = "copilot";} + { + name = "path"; + keyword_length = 3; + } + { + name = "luasnip"; + keyword_length = 3; + } + ]; + + # Enable pictogram icons for lsp/autocompletion + formatting = { + fields = [ + "kind" + "abbr" + "menu" + ]; + expandable_indicator = true; + }; + performance = { + debounce = 60; + fetching_timeout = 200; + max_view_entries = 30; + }; + window = { + completion = { + border = "rounded"; + winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None"; + }; + documentation = { + border = "rounded"; + }; + }; + }; + }; + }; + extraConfigLua = '' + luasnip = require("luasnip") + kind_icons = { + 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 = "", + } + + local cmp = require'cmp' + + -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({'/', "?" }, { + sources = { + { name = 'buffer' } + } + }) + + -- Set configuration for specific filetype. + cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. + }, { + { name = 'buffer' }, + }) + }) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }), + }) + ''; + }; +} diff --git a/config/completion/codeium.nix b/config/completion/codeium.nix new file mode 100644 index 0000000..8ad2927 --- /dev/null +++ b/config/completion/codeium.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + ... +}: { + options = { + codeium.enable = lib.mkEnableOption "Enable codeium module"; + }; + config = lib.mkIf config.codeium.enable { + plugins.codeium-vim = { + enable = true; + }; + }; +} diff --git a/config/completion/copilot.nix b/config/completion/copilot.nix new file mode 100644 index 0000000..9a07519 --- /dev/null +++ b/config/completion/copilot.nix @@ -0,0 +1,55 @@ +{ + lib, + config, + ... +}: { + options = { + copilot.enable = lib.mkEnableOption "Enable copilot module"; + }; + config = lib.mkIf config.copilot.enable { + plugins.copilot-lua = { + enable = true; + panel = { + enabled = false; + autoRefresh = true; + keymap = { + jumpPrev = "[["; + jumpNext = "]]"; + accept = ""; + refresh = "gr"; + open = ""; + }; + layout = { + position = "bottom"; # | top | left | right + ratio = 0.4; + }; + }; + suggestion = { + enabled = false; + autoTrigger = true; + debounce = 75; + keymap = { + accept = ""; + acceptWord = false; + acceptLine = false; + next = ""; + prev = ""; + dismiss = ""; + }; + }; + filetypes = { + yaml = false; + markdown = false; + help = false; + gitcommit = false; + gitrebase = false; + hgcommit = false; + svn = false; + cvs = false; + "." = false; + }; + copilotNodeCommand = "node"; # Node.js version must be > 18.x + serverOptsOverrides = {}; + }; + }; +} diff --git a/config/completion/default.nix b/config/completion/default.nix new file mode 100644 index 0000000..e9145cc --- /dev/null +++ b/config/completion/default.nix @@ -0,0 +1,22 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./cmp.nix + ./codeium.nix + ./copilot.nix + ./lspkind.nix + ]; + + options = { + completion.enable = lib.mkEnableOption "Enable completion module"; + }; + config = lib.mkIf config.completion.enable { + cmp.enable = lib.mkDefault true; + codeium.enable = lib.mkDefault false; + copilot.enable = lib.mkDefault false; + lspkind.enable = lib.mkDefault true; + }; +} diff --git a/config/completion/lspkind.nix b/config/completion/lspkind.nix new file mode 100644 index 0000000..71cda83 --- /dev/null +++ b/config/completion/lspkind.nix @@ -0,0 +1,21 @@ +{ + lib, + config, + ... +}: { + options = { + lspkind.enable = lib.mkEnableOption "Enable lspkind module"; + }; + config = lib.mkIf config.lspkind.enable { + plugins.lspkind = { + enable = true; + symbolMap = { + Copilot = ""; + }; + extraOptions = { + maxwidth = 50; + ellipsis_char = "..."; + }; + }; + }; +} diff --git a/config/dap/default.nix b/config/dap/default.nix new file mode 100644 index 0000000..08d09db --- /dev/null +++ b/config/dap/default.nix @@ -0,0 +1,16 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./nvim-dap.nix + ]; + + options = { + dap.enable = lib.mkEnableOption "Enable dap module"; + }; + config = lib.mkIf config.dap.enable { + nvim-dap.enable = lib.mkDefault true; + }; +} diff --git a/config/dap/nvim-dap.nix b/config/dap/nvim-dap.nix new file mode 100644 index 0000000..94c0210 --- /dev/null +++ b/config/dap/nvim-dap.nix @@ -0,0 +1,237 @@ +{ + lib, + config, + ... +}: { + options = { + nvim-dap.enable = lib.mkEnableOption "Enable Debug Adapter Protocol module"; + }; + config = lib.mkIf config.nvim-dap.enable { + plugins.dap = { + enable = true; + signs = { + dapBreakpoint = { + text = "●"; + texthl = "DapBreakpoint"; + }; + dapBreakpointCondition = { + text = "●"; + texthl = "DapBreakpointCondition"; + }; + dapLogPoint = { + text = "◆"; + texthl = "DapLogPoint"; + }; + }; + extensions = { + dap-python = { + enable = true; + }; + dap-ui = { + enable = true; + floating.mappings = { + close = [ + "" + "q" + ]; + }; + }; + dap-virtual-text = { + enable = true; + }; + }; + configurations = { + java = [ + { + type = "java"; + request = "launch"; + name = "Debug (Attach) - Remote"; + hostName = "127.0.0.1"; + port = 5005; + } + ]; + }; + }; + + keymaps = [ + { + mode = "n"; + key = "dB"; + action = " + lua require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: ')) + "; + options = { + silent = true; + desc = "Breakpoint Condition"; + }; + } + { + mode = "n"; + key = "db"; + action = ":DapToggleBreakpoint"; + options = { + silent = true; + desc = "Toggle Breakpoint"; + }; + } + { + mode = "n"; + key = "dc"; + action = ":DapContinue"; + options = { + silent = true; + desc = "Continue"; + }; + } + { + mode = "n"; + key = "da"; + action = "lua require('dap').continue({ before = get_args })"; + options = { + silent = true; + desc = "Run with Args"; + }; + } + { + mode = "n"; + key = "dC"; + action = "lua require('dap').run_to_cursor()"; + options = { + silent = true; + desc = "Run to cursor"; + }; + } + { + mode = "n"; + key = "dg"; + action = "lua require('dap').goto_()"; + options = { + silent = true; + desc = "Go to line (no execute)"; + }; + } + { + mode = "n"; + key = "di"; + action = ":DapStepInto"; + options = { + silent = true; + desc = "Step into"; + }; + } + { + mode = "n"; + key = "dj"; + action = " + lua require('dap').down() + "; + options = { + silent = true; + desc = "Down"; + }; + } + { + mode = "n"; + key = "dk"; + action = "lua require('dap').up()"; + options = { + silent = true; + desc = "Up"; + }; + } + { + mode = "n"; + key = "dl"; + action = "lua require('dap').run_last()"; + options = { + silent = true; + desc = "Run Last"; + }; + } + { + mode = "n"; + key = "do"; + action = ":DapStepOut"; + options = { + silent = true; + desc = "Step Out"; + }; + } + { + mode = "n"; + key = "dO"; + action = ":DapStepOver"; + options = { + silent = true; + desc = "Step Over"; + }; + } + { + mode = "n"; + key = "dp"; + action = "lua require('dap').pause()"; + options = { + silent = true; + desc = "Pause"; + }; + } + { + mode = "n"; + key = "dr"; + action = ":DapToggleRepl"; + options = { + silent = true; + desc = "Toggle REPL"; + }; + } + { + mode = "n"; + key = "ds"; + action = "lua require('dap').session()"; + options = { + silent = true; + desc = "Session"; + }; + } + { + mode = "n"; + key = "dt"; + action = ":DapTerminate"; + options = { + silent = true; + desc = "Terminate"; + }; + } + { + mode = "n"; + key = "du"; + action = "lua require('dapui').toggle()"; + options = { + silent = true; + desc = "Dap UI"; + }; + } + { + mode = "n"; + key = "dw"; + action = "lua require('dap.ui.widgets').hover()"; + options = { + silent = true; + desc = "Widgets"; + }; + } + { + mode = [ + "n" + "v" + ]; + key = "de"; + action = "lua require('dapui').eval()"; + options = { + silent = true; + desc = "Eval"; + }; + } + ]; + }; +} diff --git a/config/default.nix b/config/default.nix new file mode 100644 index 0000000..8963047 --- /dev/null +++ b/config/default.nix @@ -0,0 +1,44 @@ +{ + lib, + config, + ... +}: { + # Import all your configuration modules here + imports = [ + ./bufferlines + ./colorschemes + ./completion + ./dap + ./filetrees + ./git + ./keys.nix + ./languages + ./lsp + ./none-ls + ./pluginmanagers + ./sets + ./snippets + ./statusline + ./telescope + ./ui + ./utils + ]; + + bufferlines.enable = lib.mkDefault true; + colorschemes.enable = lib.mkDefault false; + completion.enable = lib.mkDefault true; + dap.enable = lib.mkDefault true; + filetrees.enable = lib.mkDefault false; + git.enable = lib.mkDefault true; + keys.enable = true; + languages.enable = true; + lsp.enable = lib.mkDefault true; + none-ls.enable = lib.mkDefault false; + sets.enable = lib.mkDefault true; + pluginmanagers.enable = lib.mkDefault true; + snippets.enable = lib.mkDefault true; + statusline.enable = lib.mkDefault true; + telescope.enable = lib.mkDefault true; + ui.enable = lib.mkDefault true; + utils.enable = lib.mkDefault true; +} diff --git a/config/filetrees/default.nix b/config/filetrees/default.nix new file mode 100644 index 0000000..06c7104 --- /dev/null +++ b/config/filetrees/default.nix @@ -0,0 +1,16 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./neo-tree.nix + ]; + + options = { + filetrees.enable = lib.mkEnableOption "Enable filetrees module"; + }; + config = lib.mkIf config.filetrees.enable { + neo-tree.enable = lib.mkDefault true; + }; +} diff --git a/config/filetrees/neo-tree.nix b/config/filetrees/neo-tree.nix new file mode 100644 index 0000000..4dada48 --- /dev/null +++ b/config/filetrees/neo-tree.nix @@ -0,0 +1,73 @@ +{ + lib, + config, + ... +}: { + options = { + neo-tree.enable = lib.mkEnableOption "Enable neo-tree module"; + }; + config = lib.mkIf config.neo-tree.enable { + plugins.neo-tree = { + enable = true; + enableDiagnostics = true; + enableGitStatus = true; + enableModifiedMarkers = true; + enableRefreshOnWrite = true; + closeIfLastWindow = true; + popupBorderStyle = "rounded"; # Type: null or one of “NC”, “double”, “none”, “rounded”, “shadow”, “single”, “solid” or raw lua code + buffers = { + bindToCwd = false; + followCurrentFile = { + enabled = true; + }; + }; + window = { + width = 40; + height = 15; + autoExpandWidth = false; + mappings = { + "" = "none"; + }; + }; + }; + + # keymaps = [ + # { + # mode = "n"; + # key = "e"; + # action = ":Neotree toggle reveal_force_cwd"; + # options = { + # silent = true; + # desc = "Explorer NeoTree (root dir)"; + # }; + # } + # { + # mode = "n"; + # key = "E"; + # action = "Neotree toggle"; + # options = { + # silent = true; + # desc = "Explorer NeoTree (cwd)"; + # }; + # } + # { + # mode = "n"; + # key = "be"; + # action = ":Neotree buffers"; + # options = { + # silent = true; + # desc = "Buffer explorer"; + # }; + # } + # { + # mode = "n"; + # key = "ge"; + # action = ":Neotree git_status"; + # options = { + # silent = true; + # desc = "Git explorer"; + # }; + # } + # ]; + }; +} diff --git a/config/git/default.nix b/config/git/default.nix new file mode 100644 index 0000000..ea307eb --- /dev/null +++ b/config/git/default.nix @@ -0,0 +1,22 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./diffview.nix + ./gitsigns.nix + ./lazygit.nix + ./neogit.nix + ]; + + options = { + git.enable = lib.mkEnableOption "Enable git module"; + }; + config = lib.mkIf config.git.enable { + diffview.enable = lib.mkDefault true; + gitsigns.enable = lib.mkDefault true; + lazygit.enable = lib.mkDefault true; + neogit.enable = lib.mkDefault false; + }; +} diff --git a/config/git/diffview.nix b/config/git/diffview.nix new file mode 100644 index 0000000..b72e1d7 --- /dev/null +++ b/config/git/diffview.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + ... +}: { + options = { + diffview.enable = lib.mkEnableOption "Enable diffview module"; + }; + config = lib.mkIf config.diffview.enable { + plugins.diffview = { + enable = true; + }; + }; +} diff --git a/config/git/gitsigns.nix b/config/git/gitsigns.nix new file mode 100644 index 0000000..e6c86c9 --- /dev/null +++ b/config/git/gitsigns.nix @@ -0,0 +1,110 @@ +{ + lib, + config, + ... +}: { + options = { + gitsigns.enable = lib.mkEnableOption "Enable gitsigns module"; + }; + config = lib.mkIf config.gitsigns.enable { + 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/config/git/lazygit.nix b/config/git/lazygit.nix new file mode 100644 index 0000000..1564b86 --- /dev/null +++ b/config/git/lazygit.nix @@ -0,0 +1,29 @@ +{ + lib, + config, + ... +}: { + options = { + lazygit.enable = lib.mkEnableOption "Enable lazygit module"; + }; + config = lib.mkIf config.lazygit.enable { + plugins.lazygit = { + enable = true; + }; + + extraConfigLua = '' + require("telescope").load_extension("lazygit") + ''; + + keymaps = [ + { + mode = "n"; + key = "gg"; + action = "LazyGit"; + options = { + desc = "LazyGit (root dir)"; + }; + } + ]; + }; +} diff --git a/config/git/neogit.nix b/config/git/neogit.nix new file mode 100644 index 0000000..1ae6902 --- /dev/null +++ b/config/git/neogit.nix @@ -0,0 +1,21 @@ +{ + lib, + config, + ... +}: { + options = { + neogit.enable = lib.mkEnableOption "Enable neogit module"; + }; + config = lib.mkIf config.neogit.enable { + plugins.neogit = { + enable = false; + }; + keymaps = [ + { + mode = "n"; + key = "gg"; + action = "Neogit"; + } + ]; + }; +} diff --git a/config/keys.nix b/config/keys.nix new file mode 100644 index 0000000..ffd62e8 --- /dev/null +++ b/config/keys.nix @@ -0,0 +1,494 @@ +# Thanks for the keybinds primeagen and folke! +{ + lib, + config, + ... +}: { + options = { + keys.enable = lib.mkEnableOption "Enable keys module"; + }; + config = lib.mkIf config.keys.enable { + globals.mapleader = " "; + keymaps = [ + # Disable arrow keys + # { + # mode = [ + # "n" + # "i" + # ]; + # key = ""; + # action = ""; + # options = { + # silent = true; + # noremap = true; + # desc = "Disable Up arrow key"; + # }; + # } + # { + # mode = [ + # "n" + # "i" + # ]; + # key = ""; + # action = ""; + # options = { + # silent = true; + # noremap = true; + # desc = "Disable Down arrow key"; + # }; + # } + # { + # mode = [ + # "n" + # "i" + # ]; + # key = ""; + # action = ""; + # options = { + # silent = true; + # noremap = true; + # desc = "Disable Right arrow key"; + # }; + # } + # { + # mode = [ + # "n" + # "i" + # ]; + # key = ""; + # action = ""; + # options = { + # silent = true; + # noremap = true; + # desc = "Disable Left arrow key"; + # }; + # } + { + mode = ["n" "i"]; + key = ""; + action = "g"; + } + { + mode = ["n" "i"]; + key = ""; + action = "g"; + } + # Tabs + { + mode = "n"; + key = "l"; + action = "tablast"; + options = { + silent = true; + desc = "Last tab"; + }; + } + + { + mode = "n"; + key = "f"; + action = "tabfirst"; + options = { + silent = true; + desc = "First Tab"; + }; + } + + { + mode = "n"; + key = ""; + action = "tabnew"; + options = { + silent = true; + desc = "New Tab"; + }; + } + + { + mode = "n"; + key = "]"; + action = "tabnext"; + options = { + silent = true; + desc = "Next Tab"; + }; + } + + { + mode = "n"; + key = "d"; + action = "tabclose"; + options = { + silent = true; + desc = "Close tab"; + }; + } + + { + mode = "n"; + key = "["; + action = "tabprevious"; + options = { + silent = true; + desc = "Previous Tab"; + }; + } + + # Windows + { + mode = "n"; + key = "ww"; + action = "p"; + options = { + silent = true; + desc = "Other window"; + }; + } + + { + mode = "n"; + key = "wd"; + action = "c"; + options = { + silent = true; + desc = "Delete window"; + }; + } + + { + mode = "n"; + key = "w-"; + action = "s"; + options = { + silent = true; + desc = "Split window below"; + }; + } + + { + mode = "n"; + key = "w|"; + action = "v"; + options = { + silent = true; + desc = "Split window right"; + }; + } + + # { + # 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"; + }; + } + + { + mode = "n"; + key = "qs"; + action = ":lua require('persistence').load()"; + options = { + silent = true; + desc = "Restore session"; + }; + } + + { + mode = "n"; + key = "ql"; + action = "lua require('persistence').load({ last = true })"; + options = { + silent = true; + desc = "Restore last session"; + }; + } + + { + mode = "n"; + key = "qd"; + action = "lua require('persistence').stop()"; + options = { + silent = true; + desc = "Don't save current session"; + }; + } + + # Toggle + { + 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"; + }; + } + + # Inlay Hints + { + mode = "n"; + key = "uh"; + action = ":lua ToggleInlayHints()"; + options = { + silent = true; + desc = "Toggle Inlay Hints"; + }; + } + + { + mode = "v"; + key = "J"; + action = ":m '>+1gv=gv"; + options = { + silent = true; + desc = "Move up when line is highlighted"; + }; + } + + { + mode = "v"; + key = "K"; + action = ":m '<-2gv=gv"; + options = { + silent = true; + desc = "Move down when line is highlighted"; + }; + } + + { + mode = "n"; + key = "J"; + action = "mzJ`z"; + options = { + silent = true; + desc = "Allow cursor to stay in the same place after appeding to current line"; + }; + } + + { + 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"; + }; + } + + { + 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"; + }; + } + + # instead of pressing esc just because + { + mode = "i"; + key = ""; + action = ""; + } + { + mode = "n"; + key = ""; + action = "zz"; + } + { + mode = "n"; + key = ""; + action = "zz"; + } + { + mode = "n"; + key = "n"; + action = "nzzzv"; + } + { + mode = "n"; + key = "N"; + action = "Nzzzv"; + } + { + mode = "n"; + key = ""; + action = "!tmux new tmux-sessionizer"; + options = { + desc = "Switch between projects"; + }; + } + + # Set highlight on search, but clear on pressing in normal mode + { + mode = "n"; + key = ""; + action = "nohlsearch"; + } + ]; + }; +} diff --git a/config/languages/default.nix b/config/languages/default.nix new file mode 100644 index 0000000..b3ad421 --- /dev/null +++ b/config/languages/default.nix @@ -0,0 +1,22 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./treesitter-nvim.nix + ./nvim-jdtls.nix + ./nvim-lint.nix + ./rainbow-delimeters.nix + ]; + + options = { + languages.enable = lib.mkEnableOption "Enable languages module"; + }; + config = lib.mkIf config.languages.enable { + treesitter-nvim.enable = lib.mkDefault true; + nvim-jdtls.enable = lib.mkDefault false; + nvim-lint.enable = lib.mkDefault true; + rainbow-delimeters.enable = lib.mkDefault true; + }; +} diff --git a/config/languages/nvim-jdtls.nix b/config/languages/nvim-jdtls.nix new file mode 100644 index 0000000..6f5e4db --- /dev/null +++ b/config/languages/nvim-jdtls.nix @@ -0,0 +1,90 @@ +{ + lib, + config, + ... +}: let + javaTestPath = "/nix/store/j3nvmhvj2pmnykw5pbm51dn0bz4cv6j3-vscode-extension-vscjava-vscode-java-test-0.38.2023032402/share/vscode/extensions/vscjava.vscode-java-test/server/com.microsoft.java.test.plugin-0.38.2.jar + "; +in { + options = { + nvim-jdtls.enable = lib.mkEnableOption "Enable nvim-jdtls module"; + }; + config = lib.mkIf config.nvim-jdtls.enable { + plugins.nvim-jdtls = { + enable = true; + cmd = [ + "/nix/store/20h2hjjm94gbskqhbwikbgxbblv1xpf2-jdt-language-server-1.31.0/bin/jdtls" + ]; + # configuration = "/path/to/configuration"; + data = "~/.cache/jdtls/workspace"; + settings = { + java = { + signatureHelp = true; + completion = true; + }; + }; + initOptions = { + bundles = [ + "/nix/store/b9ib40q36wxjl4xs5lng263lflz1fsi7-vscode-extension-vscjava-vscode-java-debug-0.49.2023032407/share/vscode/extensions/vscjava.vscode-java-debug/server/com.microsoft.java.debug.plugin-0.44.0.jar" + "${javaTestPath}" + ]; + }; + }; + }; +} +# +# extraConfigLua = '' +# local jdtls = require("jdtls") +# local cmp_nvim_lsp = require("cmp_nvim_lsp") +# +# local root_dir = require("jdtls.setup").find_root({ "packageInfo" }, "Config") +# local home = os.getenv("HOME") +# local eclipse_workspace = home .. "/.local/share/eclipse/" .. vim.fn.fnamemodify(root_dir, ":p:h:t") +# +# local ws_folders_jdtls = {} +# if root_dir then +# local file = io.open(root_dir .. "/.bemol/ws_root_folders") +# if file then +# for line in file:lines() do +# table.insert(ws_folders_jdtls, "file://" .. line) +# end +# file:close() +# end +# end +# +# -- for completions +# local client_capabilities = vim.lsp.protocol.make_client_capabilities() +# local capabilities = cmp_nvim_lsp.default_capabilities(client_capabilities) +# +# local config = { +# capabilities = capabilities, +# cmd = { +# "${pkgs.jdt-language-server}/bin/jdt-language-server", +# "--jvm-arg=-javaagent:" .. home .. "/Developer/lombok.jar", +# "-data", +# eclipse_workspace, +# "--add-modules=ALL-SYSTEM", +# }, +# root_dir = root_dir, +# init_options = { +# workspaceFolders = ws_folders_jdtls, +# }, +# settings = { +# java = { +# signatureHelp = { enabled = true}, +# completion = { enabled = true }, +# }, +# }, +# on_attach = function(client, bufnr) +# local opts = { silent = true, buffer = bufnr } +# vim.keymap.set('n', "lo", jdtls.organize_imports, { desc = 'Organize imports', buffer = bufnr }) +# vim.keymap.set('n', "df", jdtls.test_class, opts) +# vim.keymap.set('n', "dn", jdtls.test_nearest_method, opts) +# vim.keymap.set('n', 'rv', jdtls.extract_variable_all, { desc = 'Extract variable', buffer = bufnr }) +# vim.keymap.set('n', 'rc', jdtls.extract_constant, { desc = 'Extract constant', buffer = bufnr }) +# end +# } +# +# jdtls.start_or_attach(config) +# ''; + diff --git a/config/languages/nvim-lint.nix b/config/languages/nvim-lint.nix new file mode 100644 index 0000000..90465df --- /dev/null +++ b/config/languages/nvim-lint.nix @@ -0,0 +1,30 @@ +{ + lib, + config, + ... +}: { + options = { + nvim-lint.enable = lib.mkEnableOption "Enable nvim-lint module"; + }; + config = lib.mkIf config.nvim-lint.enable { + plugins.lint = { + enable = true; + lintersByFt = { + c = ["cpplint"]; + cpp = ["cpplint"]; + go = ["golangci-lint"]; + nix = ["statix"]; + lua = ["selene"]; + python = ["flake8"]; + javascript = ["eslint_d"]; + javascriptreact = ["eslint_d"]; + typescript = ["eslint_d"]; + typescriptreact = ["eslint_d"]; + json = ["jsonlint"]; + java = ["checkstyle"]; + haskell = ["hlint"]; + bash = ["shellcheck"]; + }; + }; + }; +} diff --git a/config/languages/rainbow-delimeters.nix b/config/languages/rainbow-delimeters.nix new file mode 100644 index 0000000..e9d8610 --- /dev/null +++ b/config/languages/rainbow-delimeters.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + ... +}: { + options = { + rainbow-delimeters.enable = lib.mkEnableOption "Enable rainbow-delimeters module"; + }; + config = lib.mkIf config.rainbow-delimeters.enable { + plugins.rainbow-delimiters = { + enable = true; + }; + }; +} diff --git a/config/languages/treesitter-nvim.nix b/config/languages/treesitter-nvim.nix new file mode 100644 index 0000000..b42f6a0 --- /dev/null +++ b/config/languages/treesitter-nvim.nix @@ -0,0 +1,128 @@ +{ + lib, + config, + ... +}: { + options = { + treesitter-nvim.enable = lib.mkEnableOption "Enable treesitter-nvim module"; + }; + config = lib.mkIf config.treesitter-nvim.enable { + plugins.treesitter = { + enable = true; + settings = { + highlight = { + enable = true; + }; + indent = { + enable = true; + }; + autopairs = { + enable = true; + }; + folding = { + enable = true; + }; + ensure_installed = [ + "bash" + "c" + # "html" + # "css" + # "javascript" + # "jsdoc" + "json" + "lua" + "luadoc" + # "luap" + "nix" + "rust" + # "java" + "markdown" + # "markdown_inline" + "python" + # "query" + # "regex" + # "tsx" + # "typescript" + "typst" + "vim" + "vimdoc" + "toml" + "yaml" + ]; + auto_install = true; + incremental_selection = { + enable = true; + keymaps = { + init_selection = ""; + node_incremental = ""; + scope_incremental = false; + node_decremental = ""; + }; + }; + }; + nixvimInjections = true; + }; + + 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"; + }; + }; + }; + + plugins.ts-autotag = { + enable = true; + }; + + plugins.treesitter-context = { + enable = true; + }; + + plugins.ts-context-commentstring = { + enable = true; + disableAutoInitialization = false; + }; + }; +} diff --git a/config/lsp/conform.nix b/config/lsp/conform.nix new file mode 100644 index 0000000..90459d3 --- /dev/null +++ b/config/lsp/conform.nix @@ -0,0 +1,115 @@ +{ + lib, + config, + ... +}: { + options = { + conform.enable = lib.mkEnableOption "Enable conform module"; + }; + config = lib.mkIf config.conform.enable { + plugins.conform-nvim = { + enable = true; + settings = { + notify_on_error = true; + # default_format_opts = { + # lsp_format = "fallback"; + # }; + # format_after_save = { + # lsp_format = "fallback"; + # }; + format_on_save = '' + function(bufnr) + -- Disable with a global or buffer-local variable + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + return { timeout_ms = 500, lsp_format = 'fallback' } + end + ''; + formatters_by_ft = { + html = { + __unkeyed-1 = "prettierd"; + __unkeyed-2 = "prettier"; + stop_after_first = true; + }; + css = { + __unkeyed-1 = "prettierd"; + __unkeyed-2 = "prettier"; + stop_after_first = true; + }; + javascript = { + __unkeyed-1 = "prettierd"; + __unkeyed-2 = "prettier"; + stop_after_first = true; + }; + javascriptreact = { + __unkeyed-1 = "prettierd"; + __unkeyed-2 = "prettier"; + stop_after_first = true; + }; + typescript = { + __unkeyed-1 = "prettierd"; + __unkeyed-2 = "prettier"; + stop_after_first = true; + }; + typescriptreact = { + __unkeyed-1 = "prettierd"; + __unkeyed-2 = "prettier"; + stop_after_first = true; + }; + java = ["google-java-format"]; + python = ["black"]; + lua = ["stylua"]; + nix = ["alejandra"]; + typst = ["typstfmt"]; + markdown = { + __unkeyed-1 = "prettierd"; + __unkeyed-2 = "prettier"; + stop_after_first = true; + }; + rust = ["rustfmt"]; + }; + }; + }; + + keymaps = [ + { + mode = "n"; + key = "uf"; + action = ":FormatToggle"; + options = { + desc = "Toggle Format Globally"; + silent = true; + }; + } + { + mode = "n"; + key = "uF"; + action = ":FormatToggle!"; + options = { + desc = "Toggle Format Locally"; + silent = true; + }; + } + { + mode = "n"; + key = "cf"; + action = "lua require('conform').format()"; + options = { + silent = true; + desc = "Format Buffer"; + }; + } + + { + mode = "v"; + key = "cF"; + action = "lua require('conform').format()"; + options = { + silent = true; + desc = "Format Lines"; + }; + } + ]; + }; +} diff --git a/config/lsp/default.nix b/config/lsp/default.nix new file mode 100644 index 0000000..4ec8c54 --- /dev/null +++ b/config/lsp/default.nix @@ -0,0 +1,24 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./conform.nix + ./fidget.nix + ./lsp-nvim.nix + ./lspsaga.nix + ./trouble.nix + ]; + + options = { + lsp.enable = lib.mkEnableOption "Enable lsp module"; + }; + config = lib.mkIf config.dap.enable { + conform.enable = lib.mkDefault true; + fidget.enable = lib.mkDefault true; + lsp-nvim.enable = lib.mkDefault true; + lspsaga.enable = lib.mkDefault false; + trouble.enable = lib.mkDefault true; + }; +} diff --git a/config/lsp/fidget.nix b/config/lsp/fidget.nix new file mode 100644 index 0000000..e7e59e9 --- /dev/null +++ b/config/lsp/fidget.nix @@ -0,0 +1,108 @@ +{ + lib, + config, + ... +}: { + options = { + fidget.enable = lib.mkEnableOption "Enable fidget module"; + }; + config = lib.mkIf config.fidget.enable { + plugins.fidget = { + enable = true; + logger = { + level = "warn"; # “off”, “error”, “warn”, “info”, “debug”, “trace” + floatPrecision = 1.0e-2; # Limit the number of decimals displayed for floats + }; + progress = { + pollRate = 0; # How and when to poll for progress messages + suppressOnInsert = true; # Suppress new messages while in insert mode + ignoreDoneAlready = false; # Ignore new tasks that are already complete + ignoreEmptyMessage = false; # Ignore new tasks that don't contain a message + clearOnDetach = + # 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 + ''; + notificationGroup = + # 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 = { + progressRingbufSize = 0; # Configure the nvim's LSP progress ring buffer size + }; + display = { + renderLimit = 16; # How many LSP messages to show at once + doneTtl = 3; # How long a message should persist after completion + doneIcon = "✔"; # Icon shown when all LSP progress tasks are complete + doneStyle = "Constant"; # Highlight group for completed LSP tasks + progressTtl = lib.nixvim.mkRaw "math.huge"; # How long a message should persist when in progress + progressIcon = { + pattern = "dots"; + period = 1; + }; # Icon shown when LSP progress tasks are in progress + progressStyle = "WarningMsg"; # Highlight group for in-progress LSP tasks + groupStyle = "Title"; # Highlight group for group name (LSP server name) + iconStyle = "Question"; # Highlight group for group icons + priority = 30; # Ordering priority for LSP notification group + skipHistory = true; # Whether progress notifications should be omitted from history + formatMessage = '' + require ("fidget.progress.display").default_format_message + ''; # How to format a progress message + formatAnnote = '' + function (msg) return msg.title end + ''; # How to format a progress annotation + formatGroupName = '' + 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 + }; + }; + notification = { + pollRate = 10; # How frequently to update and render notifications + filter = "info"; # “off”, “error”, “warn”, “info”, “debug”, “trace” + historySize = 128; # Number of removed messages to retain in history + overrideVimNotify = true; + redirect = lib.nixvim.mkRaw '' + function(msg, level, opts) + if opts and opts.on_open then + return require("fidget.integration.nvim-notify").delegate(msg, level, opts) + end + end + ''; + configs = { + default = lib.nixvim.mkRaw "require('fidget.notification').default_config"; + }; + + window = { + normalHl = "Comment"; + winblend = 0; + border = "none"; # none, single, double, rounded, solid, shadow + zindex = 45; + maxWidth = 0; + maxHeight = 0; + xPadding = 1; + yPadding = 0; + align = "bottom"; + relative = "editor"; + }; + view = { + stackUpwards = true; # Display notification items from bottom to top + iconSeparator = " "; # Separator between group name and icon + groupSeparator = "---"; # Separator between notification groups + groupSeparatorHl = + # Highlight group used for group separator + "Comment"; + }; + }; + }; + }; +} diff --git a/config/lsp/lsp-nvim.nix b/config/lsp/lsp-nvim.nix new file mode 100644 index 0000000..4d28a42 --- /dev/null +++ b/config/lsp/lsp-nvim.nix @@ -0,0 +1,214 @@ +{ + lib, + config, + ... +}: { + options = { + lsp-nvim.enable = lib.mkEnableOption "Enable lsp-nvim module"; + }; + config = lib.mkIf config.lsp-nvim.enable { + plugins = { + lsp-format = { + enable = false; # Enable it if you want lsp-format integration for none-ls + }; + lsp = { + enable = true; + capabilities = "offsetEncoding = 'utf-16'"; + servers = { + clangd = { + enable = true; + }; + lua_ls = { + enable = true; + extraOptions = { + settings = { + Lua = { + completion = { + callSnippet = "Replace"; + }; + diagnostics = { + globals = ["vim"]; + }; + telemetry = { + enabled = false; + }; + hint = { + enable = true; + }; + }; + }; + }; + }; + nil_ls = { + enable = false; + }; + nixd = { + enable = true; + }; + tinymist = { + enable = true; + }; + eslint = { + enable = false; + }; + pyright = { + enable = false; + }; + ruff = { + enable = false; + }; + + rust_analyzer = { + enable = true; + installCargo = true; + installRustc = true; + settings = { + checkOnSave = true; + check = { + command = "clippy"; + }; + # inlayHints = { + # enable = true; + # showParameterNames = true; + # parameterHintsPrefix = "<- "; + # otherHintsPrefix = "=> "; + # }; + procMacro = { + enable = true; + }; + }; + }; + }; + keymaps = { + silent = true; + lspBuf = { + gd = { + action = "definition"; + desc = "Goto Definition"; + }; + gr = { + action = "references"; + desc = "Goto References"; + }; + gD = { + action = "declaration"; + desc = "Goto Declaration"; + }; + gI = { + action = "implementation"; + desc = "Goto Implementation"; + }; + gT = { + action = "type_definition"; + desc = "Type Definition"; + }; + K = { + action = "hover"; + desc = "Hover"; + }; + "cw" = { + action = "workspace_symbol"; + desc = "Workspace Symbol"; + }; + "cr" = { + action = "rename"; + desc = "Rename"; + }; + "ca" = { + action = "code_action"; + desc = "Code Action"; + }; + "" = { + action = "signature_help"; + desc = "Signature Help"; + }; + }; + diagnostic = { + "cd" = { + action = "open_float"; + desc = "Line Diagnostics"; + }; + "[d" = { + action = "goto_next"; + desc = "Next Diagnostic"; + }; + "]d" = { + action = "goto_prev"; + desc = "Previous Diagnostic"; + }; + }; + }; + onAttach = '' + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint.enable(false) + end + vim.bo[args.buf].omnifunc = "v:lua.vim.lsp.omnifunc" + end, + }) + ''; + }; + }; + extraConfigLua = '' + local _border = "rounded" + + require('lspconfig.ui.windows').default_options = { + border = _border + } + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with( + vim.lsp.handlers.hover, { + border = _border + } + ) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with( + vim.lsp.handlers.signature_help, { + border = _border + } + ) + + vim.diagnostic.config({ + float = { border = "rounded" }, + virtual_text = { + prefix = "", + }, + signs = true, + underline = true, + update_in_insert = true, + }) + + -- vim.api.nvim_create_autocmd("LspAttach", { + -- group = vim.api.nvim_create_augroup("UserLspConfig", {}), + -- callback = function(args) + -- local client = vim.lsp.get_client_by_id(args.data.client_id) + -- if client.server_capabilities.inlayHintProvider then + -- vim.lsp.inlay_hint.enable(false) + -- end + -- vim.bo[args.buf].omnifunc = "v:lua.vim.lsp.omnifunc" + -- + -- local opts = { buffer = args.buf } + -- vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + -- vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) + -- vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + -- vim.keymap.set("n", "gI", vim.lsp.buf.implementation, opts) + -- vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, opts) + -- vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + -- vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) + -- vim.keymap.set("n", "cw", vim.lsp.buf.workspace_symbol, opts) + -- vim.keymap.set("n", "cr", vim.lsp.buf.rename, opts) + -- vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) + -- vim.keymap.set("n", "cf", function() + -- vim.lsp.buf.format({ async = true }) + -- end, opts) + -- vim.keymap.set("n", "cd", vim.diagnostic.open_float, opts) + -- vim.keymap.set("n", "[d", vim.diagnostic.goto_next, opts) + -- vim.keymap.set("n", "]d", vim.diagnostic.goto_prev, opts) + -- end, + -- }) + ''; + }; +} diff --git a/config/lsp/lspsaga.nix b/config/lsp/lspsaga.nix new file mode 100644 index 0000000..cef7e43 --- /dev/null +++ b/config/lsp/lspsaga.nix @@ -0,0 +1,201 @@ +{ + lib, + config, + ... +}: { + options = { + lspsaga.enable = lib.mkEnableOption "Enable lspsaga module"; + }; + config = lib.mkIf config.lspsaga.enable { + plugins.lspsaga = { + enable = true; + beacon = { + enable = true; + }; + ui = { + border = "rounded"; # One of none, single, double, rounded, solid, shadow + codeAction = "💡"; # Can be any symbol you want 💡 + }; + hover = { + openCmd = "!floorp"; # Choose your browser + openLink = "gx"; + }; + diagnostic = { + borderFollow = true; + diagnosticOnlyCurrent = false; + showCodeAction = true; + }; + symbolInWinbar = { + enable = true; # Breadcrumbs + }; + codeAction = { + extendGitSigns = false; + showServerName = true; + onlyInCursor = true; + numShortcut = true; + keys = { + exec = ""; + quit = [ + "" + "q" + ]; + }; + }; + lightbulb = { + enable = false; + sign = false; + virtualText = true; + }; + implement = { + enable = false; + }; + rename = { + autoSave = false; + keys = { + exec = ""; + quit = [ + "" + "" + ]; + select = "x"; + }; + }; + outline = { + autoClose = true; + autoPreview = true; + closeAfterJump = true; + layout = "normal"; # normal or float + winPosition = "right"; # left or right + keys = { + jump = "e"; + quit = "q"; + toggleOrJump = "o"; + }; + }; + scrollPreview = { + scrollDown = ""; + scrollUp = ""; + }; + }; + # keymaps = [ + # { + # mode = "n"; + # key = "gd"; + # action = "Lspsaga finder def"; + # options = { + # desc = "Goto Definition"; + # silent = true; + # }; + # } + # { + # mode = "n"; + # key = "gr"; + # action = "Lspsaga finder ref"; + # options = { + # desc = "Goto References"; + # silent = true; + # }; + # } + # + # # { + # # mode = "n"; + # # key = "gD"; + # # action = "Lspsaga show_line_diagnostics"; + # # options = { + # # desc = "Goto Declaration"; + # # silent = true; + # # }; + # # } + # + # { + # mode = "n"; + # key = "gI"; + # action = "Lspsaga finder imp"; + # options = { + # desc = "Goto Implementation"; + # silent = true; + # }; + # } + # + # { + # mode = "n"; + # key = "gT"; + # action = "Lspsaga peek_type_definition"; + # options = { + # desc = "Type Definition"; + # silent = true; + # }; + # } + # + # { + # mode = "n"; + # key = "K"; + # action = "Lspsaga hover_doc"; + # options = { + # desc = "Hover"; + # silent = true; + # }; + # } + # + # { + # mode = "n"; + # key = "cw"; + # action = "Lspsaga outline"; + # options = { + # desc = "Outline"; + # silent = true; + # }; + # } + # + # { + # mode = "n"; + # key = "cr"; + # 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_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/config/lsp/trouble.nix b/config/lsp/trouble.nix new file mode 100644 index 0000000..48ea8a7 --- /dev/null +++ b/config/lsp/trouble.nix @@ -0,0 +1,61 @@ +{ + lib, + config, + ... +}: { + options = { + trouble.enable = lib.mkEnableOption "Enable trouble module"; + }; + config = lib.mkIf config.trouble.enable { + plugins.trouble = { + enable = true; + settings = { + auto_close = true; + }; + }; + # TODO: Add keybinds to close trouble (q would be nice), rn I need to use :x to close it... + keymaps = [ + { + mode = "n"; + key = "x"; + action = "+diagnostics/quickfix"; + } + { + mode = "n"; + key = "xx"; + action = "Trouble diagnostics toggle"; + options = { + silent = true; + desc = "Diagnostics (Trouble)"; + }; + } + { + mode = "n"; + key = "xX"; + action = "Trouble diagnostics toggle filter.buf=0"; + options = { + silent = true; + desc = "Buffer Diagnostics (Trouble)"; + }; + } + { + mode = "n"; + key = "xt"; + action = "Trouble todo"; + options = { + silent = true; + desc = "Todo (Trouble)"; + }; + } + { + mode = "n"; + key = "xQ"; + action = "Trouble qflist toggle"; + options = { + silent = true; + desc = "Quickfix List (Trouble)"; + }; + } + ]; + }; +} diff --git a/config/none-ls/default.nix b/config/none-ls/default.nix new file mode 100644 index 0000000..f9d038d --- /dev/null +++ b/config/none-ls/default.nix @@ -0,0 +1,16 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./none-ls-nvim.nix + ]; + + options = { + none-ls.enable = lib.mkEnableOption "Enable none-ls module"; + }; + config = lib.mkIf config.none-ls.enable { + none-ls-nvim.enable = lib.mkDefault true; + }; +} diff --git a/config/none-ls/none-ls-nvim.nix b/config/none-ls/none-ls-nvim.nix new file mode 100644 index 0000000..d591f2e --- /dev/null +++ b/config/none-ls/none-ls-nvim.nix @@ -0,0 +1,87 @@ +{ + lib, + config, + ... +}: { + options = { + none-ls-nvim.enable = lib.mkEnableOption "Enable none-ls-nvim module"; + }; + config = lib.mkIf config.none-ls-nvim.enable { + plugins.none-ls = { + enable = true; + settings = { + enableLspFormat = false; + updateInInsert = false; + onAttach = '' + function(client, bufnr) + if client.supports_method "textDocument/formatting" then + vim.api.nvim_clear_autocmds { group = augroup, buffer = bufnr } + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format { bufnr = bufnr } + end, + }) + end + end + ''; + }; + sources = { + code_actions = { + gitsigns.enable = true; + statix.enable = true; + }; + diagnostics = { + checkstyle = { + enable = true; + }; + statix = { + enable = true; + }; + }; + formatting = { + alejandra = { + enable = false; + }; + nixfmt = { + enable = true; + }; + prettier = { + enable = true; + settings = '' + { + extra_args = { "--no-semi", "--single-quote" }, + } + ''; + }; + google_java_format = { + enable = true; + }; + stylua = { + enable = true; + }; + black = { + enable = true; + settings = '' + { + extra_args = { "--fast" }, + } + ''; + }; + }; + }; + }; + # keymaps = [ + # { + # mode = [ "n" "v" ]; + # key = "cf"; + # action = "lua vim.lsp.buf.format()"; + # options = { + # silent = true; + # desc = "Format"; + # }; + # } + # ]; + }; +} diff --git a/config/pluginmanagers/default.nix b/config/pluginmanagers/default.nix new file mode 100644 index 0000000..95e29dc --- /dev/null +++ b/config/pluginmanagers/default.nix @@ -0,0 +1,16 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./lazy-nvim.nix + ]; + + options = { + pluginmanagers.enable = lib.mkEnableOption "Enable pluginmanagers module"; + }; + config = lib.mkIf config.pluginmanagers.enable { + lazy-nvim.enable = lib.mkDefault true; + }; +} diff --git a/config/pluginmanagers/lazy-nvim.nix b/config/pluginmanagers/lazy-nvim.nix new file mode 100644 index 0000000..69792c3 --- /dev/null +++ b/config/pluginmanagers/lazy-nvim.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + ... +}: { + options = { + lazy-nvim.enable = lib.mkEnableOption "Enable lazy-nvim module"; + }; + config = lib.mkIf config.lazy-nvim.enable { + plugins.lazy = { + enable = true; + }; + }; +} diff --git a/config/sets/default.nix b/config/sets/default.nix new file mode 100644 index 0000000..6af7cda --- /dev/null +++ b/config/sets/default.nix @@ -0,0 +1,16 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./set.nix + ]; + + options = { + sets.enable = lib.mkEnableOption "Enable sets module"; + }; + config = lib.mkIf config.utils.enable { + set.enable = lib.mkDefault true; + }; +} diff --git a/config/sets/set.nix b/config/sets/set.nix new file mode 100644 index 0000000..54e2f77 --- /dev/null +++ b/config/sets/set.nix @@ -0,0 +1,148 @@ +{ + lib, + config, + ... +}: { + options = { + set.enable = lib.mkEnableOption "Enable set module"; + }; + config = lib.mkIf config.set.enable { + opts = { + # Enable relative line numbers + number = true; + relativenumber = true; + + # Set tabs to 2 spaces + tabstop = 2; + softtabstop = 2; + showtabline = 2; + expandtab = true; + + # Enable auto indenting and set it to spaces + smartindent = true; + shiftwidth = 2; + + # Enable smart indenting (see https://stackoverflow.com/questions/1204149/smart-wrap-in-vim) + breakindent = true; + + # Enable incremental searching + hlsearch = true; + incsearch = true; + + # Enable text wrap + wrap = true; + + # Better splitting + splitbelow = true; + splitright = true; + + # Enable mouse mode + mouse = "a"; # Mouse + + # Enable ignorecase + smartcase for better searching + ignorecase = true; + smartcase = true; # Don't ignore case with capitals + grepprg = "rg --vimgrep"; + grepformat = "%f:%l:%c:%m"; + + # Decrease updatetime + updatetime = 50; # faster completion (4000ms default) + + # Set completeopt to have a better completion experience + completeopt = [ + "menuone" + "noselect" + "noinsert" + ]; # mostly just for cmp + + # Enable persistent undo history + swapfile = false; + backup = false; + undofile = true; + + # Enable 24-bit colors + termguicolors = true; + + # Enable the sign column to prevent the screen from jumping + signcolumn = "yes"; + + # Enable cursor line highlight + cursorline = false; # Highlight the line where the cursor is located + + # Set fold settings + # These options were reccommended by nvim-ufo + # See: https://github.com/kevinhwang91/nvim-ufo#minimal-configuration + foldcolumn = "0"; + foldlevel = 99; + foldlevelstart = 99; + foldenable = true; + foldmethod = "expr"; + foldexpr = "v:lua.vim.treesitter.foldexpr()"; + + # Always keep 8 lines above/below cursor unless at start/end of file + scrolloff = 8; + + # Place a column line + colorcolumn = "80"; + + # Reduce which-key timeout + timeoutlen = 200; + + # Set encoding type + encoding = "utf-8"; + fileencoding = "utf-8"; + + # Change cursor options + guicursor = [ + "n-v-c:block" # Normal, visual, command-line: block cursor + "i-ci-ve:block" # Insert, command-line insert, visual-exclude: vertical bar cursor with block cursor, use "ver25" for 25% width + "r-cr:hor20" # Replace, command-line replace: horizontal bar cursor with 20% height + "o:hor50" # Operator-pending: horizontal bar cursor with 50% height + "a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor" # All modes: blinking settings + "sm:block-blinkwait175-blinkoff150-blinkon175" # Showmatch: block cursor with specific blinking settings + ]; + + # Enable chars list + list = false; # Show invisible characters (tabs, eol, ...) + listchars = "eol:↲,tab:|->,lead:·,space: ,trail:•,extends:→,precedes:←,nbsp:␣"; + + # More space in the neovim command line for displaying messages + cmdheight = 2; + + # We don't need to see things like INSERT anymore + showmode = false; + + # Maximum number of items to show in the popup menu (0 means "use available screen space") + pumheight = 0; + + # Use conform-nvim for gq formatting. ('formatexpr' is set to vim.lsp.formatexpr(), so you can format lines via gq if the language server supports it) + formatexpr = "v:lua.require'conform'.formatexpr()"; + + laststatus = 3; # (https://neovim.io/doc/user/options.html#'laststatus') + + inccommand = "split"; # (https://neovim.io/doc/user/options.html#'inccommand') + }; + + extraConfigLua = '' + local opt = vim.opt + local g = vim.g + local o = vim.o + -- Neovide + if g.neovide then + 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 = "Iosevka Nerd Font:h14:Medium:i" + end + ''; + }; +} diff --git a/config/snippets/default.nix b/config/snippets/default.nix new file mode 100644 index 0000000..1a069c8 --- /dev/null +++ b/config/snippets/default.nix @@ -0,0 +1,16 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./luasnip.nix + ]; + + options = { + snippets.enable = lib.mkEnableOption "Enable snippets module"; + }; + config = lib.mkIf config.snippets.enable { + luasnip.enable = lib.mkDefault true; + }; +} diff --git a/config/snippets/luasnip.nix b/config/snippets/luasnip.nix new file mode 100644 index 0000000..66c4b1d --- /dev/null +++ b/config/snippets/luasnip.nix @@ -0,0 +1,25 @@ +{ + lib, + config, + pkgs, + ... +}: { + options = { + luasnip.enable = lib.mkEnableOption "Enable luasnip module"; + }; + config = lib.mkIf config.luasnip.enable { + plugins.luasnip = { + enable = true; + settings = { + enable_autosnippets = true; + store_selection_keys = ""; + }; + fromVscode = [ + { + lazyLoad = true; + paths = "${pkgs.vimPlugins.friendly-snippets}"; + } + ]; + }; + }; +} diff --git a/config/statusline/default.nix b/config/statusline/default.nix new file mode 100644 index 0000000..ecc3a63 --- /dev/null +++ b/config/statusline/default.nix @@ -0,0 +1,18 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./lualine.nix + ./staline.nix + ]; + + options = { + statusline.enable = lib.mkEnableOption "Enable statusline module"; + }; + config = lib.mkIf config.dap.enable { + lualine.enable = lib.mkDefault true; + staline.enable = lib.mkDefault false; + }; +} diff --git a/config/statusline/lualine.nix b/config/statusline/lualine.nix new file mode 100644 index 0000000..925479b --- /dev/null +++ b/config/statusline/lualine.nix @@ -0,0 +1,115 @@ +{ + lib, + config, + ... +}: { + options = { + lualine.enable = lib.mkEnableOption "Enable lualine module"; + }; + config = lib.mkIf config.lualine.enable { + plugins.lualine = { + enable = true; + settings = { + alwaysDivideMiddle = true; + globalstatus = true; + ignoreFocus = ["neo-tree"]; + extensions = ["fzf"]; + theme = "auto"; + componentSeparators = { + left = "|"; + right = "|"; + }; + sectionSeparators = { + left = "█"; #  + right = "█"; #  + }; + sections = { + lualine_a = ["mode"]; + lualine_b = [ + "branch" + "" + "diff" + "diagnostics" + ]; + lualine_c = ["filename"]; + lualine_x = ["filetype"]; + lualine_y = ["progress"]; + lualine_z = [''" " .. os.date("%R")'']; + }; + }; + }; + extraConfigLua = '' + config = function() + local harpoon = require("harpoon.mark") + + local function truncate_branch_name(branch) + if not branch or branch == "" then + return "" + end + + -- Match the branch name to the specified format + local user, team, ticket_number = string.find(branch, "(%w+)%/(%w+)%-(%d+)%-") + + -- If the branch name matches the format, display sko-{ticket_number}, otherwise display the full branch name + if ticket_number then + return user .. "/" .. team .. "-" .. ticket_number + else + return branch + end + end + + local function harpoon_component() + local total_marks = harpoon.get_length() + + if total_marks == 0 then + return "" + end + + local current_mark = "—" + + local mark_idx = harpoon.get_current_index() + if mark_idx ~= nil then + current_mark = tostring(mark_idx) + end + + return string.format("󱡅 %s/%d", current_mark, total_marks) + end + + local function get_lsp_client(_) + ---@type any?{} + local client_names = {} + local msg = "No Active Lsp" + local clients = vim.lsp.get_clients({ bufnr = 0 }) + if next(clients) == nil then + return msg + end + for _, client in ipairs(clients) do + table.insert(client_names, client.name) + end + return #client_names == 0 and msg or table.concat(client_names, " | ") + end + local function wordcount() + return tostring(vim.fn.wordcount().words) .. " words" + end + local function readingtime() + return tostring(math.ceil(vim.fn.wordcount().words / 200.0)) .. " min" + end + local function is_markdown() + return vim.bo.filetype == "markdown" or vim.bo.filetype == "asciidoc" + end + local function navic() + return require("nvim-navic").get_location() + end + local function navic_is_available() + return package.loaded["nvim-navic"] and require("nvim-navic").is_available() + end + local cmd_mode = function() + return require("noice").api.status.mode.get() + end + local show_mode = function() + return package.loaded["noice"] and require("noice").api.status.mode.has() or "" + end + end + ''; + }; +} diff --git a/config/statusline/staline.nix b/config/statusline/staline.nix new file mode 100644 index 0000000..7eff647 --- /dev/null +++ b/config/statusline/staline.nix @@ -0,0 +1,75 @@ +{ + lib, + config, + pkgs, + ... +}: { + options = { + staline.enable = lib.mkEnableOption "Enable staline module"; + }; + config = lib.mkIf config.staline.enable { + extraPlugins = with pkgs.vimUtils; [ + (buildVimPlugin { + pname = "staline.nvim"; + version = "2024-02-05"; + src = pkgs.fetchFromGitHub { + owner = "tamton-aquib"; + repo = "staline.nvim"; + rev = "a53f869278b8b186a5afd6f21680cd103c381599"; + hash = "sha256-GDMKzxFDtQk5LL+rMsxTGTyLv69w5NUd+u19noeO5ws="; + }; + }) + ]; + extraConfigLua = '' + require("staline").setup({ + sections = { + left = { "-mode", " ", "branch" }, + mid = { "lsp_name" }, + right = { "file_name", "line_column" }, + }, + inactive_sections = { + left = { "-mode", " ", "branch" }, + mid = { "lsp_name" }, + right = { "file_name", "line_column" }, + }, + defaults = { + left_separator = " ", + right_separator = " ", + branch_symbol = " ", + mod_symbol = "", + line_column = "[%l/%L]", + inactive_color = "#80a6f2", --#303030 is the default + inactive_bgcolor = "none", + }, + special_table = { + lazy = { "Plugins", "💤 " }, + TelescopePrompt = { "Telescope", " " }, + oil = { "Oil", "󰏇 " }, + lazygit = { "LazyGit", " " }, + }, + mode_icons = { + ["n"] = "NORMAL", + ["no"] = "NORMAL", + ["nov"] = "NORMAL", + ["noV"] = "NORMAL", + ["niI"] = "NORMAL", + ["niR"] = "NORMAL", + ["niV"] = "NORMAL", + ["i"] = "INSERT", + ["ic"] = "INSERT", + ["ix"] = "INSERT", + ["s"] = "INSERT", + ["S"] = "INSERT", + ["v"] = "VISUAL", + ["V"] = "VISUAL", + [""] = "VISUAL", + ["r"] = "REPLACE", + ["r?"] = "REPLACE", + ["R"] = "REPLACE", + ["c"] = "COMMAND", + ["t"] = "TERMINAL", + }, + }) + ''; + }; +} diff --git a/config/telescope/default.nix b/config/telescope/default.nix new file mode 100644 index 0000000..d726772 --- /dev/null +++ b/config/telescope/default.nix @@ -0,0 +1,16 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./telescope-nvim.nix + ]; + + options = { + telescope.enable = lib.mkEnableOption "Enable telescope module"; + }; + config = lib.mkIf config.telescope.enable { + telescope-nvim.enable = lib.mkDefault true; + }; +} diff --git a/config/telescope/telescope-nvim.nix b/config/telescope/telescope-nvim.nix new file mode 100644 index 0000000..15301eb --- /dev/null +++ b/config/telescope/telescope-nvim.nix @@ -0,0 +1,162 @@ +{ + lib, + config, + ... +}: { + options = { + telescope-nvim.enable = lib.mkEnableOption "Enable telescope-nvim module"; + }; + config = lib.mkIf config.telescope-nvim.enable { + plugins.telescope = { + enable = true; + extensions = { + fzf-native = { + enable = true; + settings = { + fuzzy = true; + override_generic_sorter = true; + override_file_sorter = true; + case_mode = "smart_case"; + }; + }; + ui-select = { + enable = true; + settings = { + specific_opts = { + codeactions = true; + }; + }; + }; + }; + # If you'd prefer Telescope not to enter a normal-like mode when hitting escape (and instead exiting), you can map to do so via: + settings = { + defaults = { + mappings = { + i = { + "" = { + __raw = '' + function(...) + return require("telescope.actions").close(...) + end''; + }; + }; + }; + }; + pickers = { + colorscheme = { + enable_preview = true; + }; + # find_files = { + # theme = "ivy"; + # }; + }; + }; + keymaps = { + "" = { + action = "find_files"; + options.desc = "Find project files"; + }; + "/" = { + action = "live_grep"; + options.desc = "Grep (root dir)"; + }; + ":" = { + action = "command_history"; + options.desc = "Command History"; + }; + "b" = { + action = "buffers"; + options.desc = "+buffer"; + }; + "ff" = { + action = "find_files"; + options.desc = "Find project files"; + }; + "fr" = { + action = "oldfiles"; + options.desc = "Recent"; + }; + "fb" = { + action = "buffers"; + options.desc = "Buffers"; + }; + "" = { + action = "git_files"; + options.desc = "Search git files"; + }; + "gc" = { + action = "git_commits"; + options.desc = "Commits"; + }; + "gs" = { + action = "git_status"; + options.desc = "Status"; + }; + "sa" = { + action = "autocommands"; + options.desc = "Auto Commands"; + }; + "sb" = { + action = "current_buffer_fuzzy_find"; + options.desc = "Buffer"; + }; + "sc" = { + action = "command_history"; + options.desc = "Command History"; + }; + "sC" = { + action = "commands"; + options.desc = "Commands"; + }; + "sD" = { + action = "diagnostics"; + options.desc = "Workspace diagnostics"; + }; + "sh" = { + action = "help_tags"; + options.desc = "Help pages"; + }; + "sH" = { + action = "highlights"; + options.desc = "Search Highlight Groups"; + }; + "sk" = { + action = "keymaps"; + options.desc = "Keymaps"; + }; + "sM" = { + action = "man_pages"; + options.desc = "Man pages"; + }; + "sm" = { + action = "marks"; + options.desc = "Jump to Mark"; + }; + "so" = { + action = "vim_options"; + options.desc = "Options"; + }; + "sR" = { + action = "resume"; + options.desc = "Resume"; + }; + "uC" = { + action = "colorscheme"; + options.desc = "Colorscheme preview"; + }; + "fp" = { + action = "projects"; + options.desc = "Projects"; + }; + "sd" = { + action = "diagnostics bufnr=0"; + options.desc = "Document Diagnostics"; + }; + "st" = { + action = "todo-comments"; + options.desc = "Todo (Telescope)"; + }; + }; + }; + }; +} diff --git a/config/ui/alpha.nix b/config/ui/alpha.nix new file mode 100644 index 0000000..9d2cea7 --- /dev/null +++ b/config/ui/alpha.nix @@ -0,0 +1,207 @@ +{ + lib, + config, + ... +}: { + options = { + alpha.enable = lib.mkEnableOption "Enable alpha module"; + }; + config = lib.mkIf config.alpha.enable { + plugins.alpha = { + enable = true; + theme = null; + layout = let + padding = val: { + type = "padding"; + inherit val; + }; + in [ + (padding 4) + { + opts = { + hl = "AlphaHeader"; + position = "center"; + }; + type = "text"; + val = [ + " :::::: :::: ::: :::::::::: ::::::::: ::: ::: ::: ::: :::::::::: :::::: " + " :+: :+:+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: " + " +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ " + " +#+ +#+ +:+ +#+ +#++:++# +#++:++#+ +#+ +:+ +#+ +#++:++#++: +#++:++# +#+ " + " +#+ +#+ +#+#+# +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ " + " #+# #+# #+#+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# " + " ###### ### #### ########## ######### ######## ########## ### ### ########## ###### " + ]; + } + (padding 2) + { + type = "button"; + val = " Find File"; + on_press = { + __raw = "function() require('telescope.builtin').find_files() end"; + }; + opts = { + # hl = "comment"; + keymap = [ + "n" + "f" + ":Telescope find_files " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "f"; + + position = "center"; + cursor = 3; + width = 38; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = " New File"; + on_press = { + __raw = "function() vim.cmd[[ene]] end"; + }; + opts = { + # hl = "comment"; + keymap = [ + "n" + "n" + ":ene startinsert " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "n"; + + position = "center"; + cursor = 3; + width = 38; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = "󰈚 Recent Files"; + on_press = { + __raw = "function() require('telescope.builtin').oldfiles() end"; + }; + opts = { + # hl = "comment"; + keymap = [ + "n" + "r" + ":Telescope oldfiles " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "r"; + + position = "center"; + cursor = 3; + width = 38; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = "󰈭 Find Word"; + on_press = { + __raw = "function() require('telescope.builtin').live_grep() end"; + }; + opts = { + # hl = "comment"; + keymap = [ + "n" + "g" + ":Telescope live_grep " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "g"; + + position = "center"; + cursor = 3; + width = 38; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = " Restore Session"; + on_press = { + __raw = "function() require('persistence').load() end"; + }; + opts = { + # hl = "comment"; + keymap = [ + "n" + "s" + ":lua require('persistence').load()" + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "s"; + + position = "center"; + cursor = 3; + width = 38; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + (padding 1) + { + type = "button"; + val = " Quit Neovim"; + on_press = { + __raw = "function() vim.cmd[[qa]] end"; + }; + opts = { + # hl = "comment"; + keymap = [ + "n" + "q" + ":qa" + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "q"; + + position = "center"; + cursor = 3; + width = 38; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + } + ]; + }; + }; +} diff --git a/config/ui/barbecue.nix b/config/ui/barbecue.nix new file mode 100644 index 0000000..198a402 --- /dev/null +++ b/config/ui/barbecue.nix @@ -0,0 +1,34 @@ +{ + lib, + config, + ... +}: { + options = { + barbecue.enable = lib.mkEnableOption "Enable barbecue module"; + }; + config = lib.mkIf config.barbecue.enable { + plugins.barbecue = { + enable = true; + settings = { + create_autocmd = false; + theme = "auto"; + }; + }; + extraConfigLua = '' + vim.api.nvim_create_autocmd({ + "WinScrolled", -- or WinResized on NVIM-v0.9 and higher + "BufWinEnter", + "CursorHold", + "InsertLeave", + + -- include this if you have set `show_modified` to `true` + "BufModifiedSet", + }, { + group = vim.api.nvim_create_augroup("barbecue.updater", {}), + callback = function() + require("barbecue.ui").update() + end, + }) + ''; + }; +} diff --git a/config/ui/default.nix b/config/ui/default.nix new file mode 100644 index 0000000..cde1971 --- /dev/null +++ b/config/ui/default.nix @@ -0,0 +1,30 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./alpha.nix + ./barbecue.nix + ./dressing-nvim.nix + ./indent-blankline.nix + ./noice.nix + ./nui.nix + ./notify.nix + ./web-devicons.nix + ]; + + options = { + ui.enable = lib.mkEnableOption "Enable ui module"; + }; + config = lib.mkIf config.ui.enable { + alpha.enable = lib.mkDefault true; + barbecue.enable = lib.mkDefault true; + dressing-nvim.enable = lib.mkDefault true; + indent-blankline.enable = lib.mkDefault true; + noice.enable = lib.mkDefault false; + notify.enable = lib.mkDefault true; + nui.enable = lib.mkDefault true; + web-devicons.enable = lib.mkDefault true; + }; +} diff --git a/config/ui/dressing-nvim.nix b/config/ui/dressing-nvim.nix new file mode 100644 index 0000000..c529d0c --- /dev/null +++ b/config/ui/dressing-nvim.nix @@ -0,0 +1,181 @@ +{ + lib, + config, + pkgs, + ... +}: { + options = { + dressing-nvim.enable = lib.mkEnableOption "Enable dressing-nvim module"; + }; + config = lib.mkIf config.dressing-nvim.enable { + extraPlugins = with pkgs.vimPlugins; [ + dressing-nvim + ]; + extraConfigLua = '' + require("dressing").setup({ + input = { + -- Set to false to disable the vim.ui.input implementation + enabled = true, + + -- Default prompt string + default_prompt = "Input", + + -- Trim trailing `:` from prompt + trim_prompt = true, + + -- Can be 'left', 'right', or 'center' + title_pos = "left", + + -- When true, will close the modal + insert_only = true, + + -- When true, input will start in insert mode. + start_in_insert = true, + + -- These are passed to nvim_open_win + border = "rounded", + -- 'editor' and 'win' will default to being centered + relative = "cursor", + + -- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) + prefer_width = 40, + width = nil, + -- min_width and max_width can be a list of mixed types. + -- min_width = {20, 0.2} means "the greater of 20 columns or 20% of total" + max_width = { 140, 0.9 }, + min_width = { 20, 0.2 }, + + buf_options = {}, + win_options = { + -- Disable line wrapping + wrap = false, + -- Indicator for when text exceeds window + list = true, + listchars = "precedes:…,extends:…", + -- Increase this for more context when text scrolls off the window + sidescrolloff = 0, + }, + + -- Set to `false` to disable + mappings = { + n = { + [""] = "Close", + [""] = "Confirm", + }, + i = { + [""] = "Close", + [""] = "Confirm", + [""] = "HistoryPrev", + [""] = "HistoryNext", + }, + }, + + override = function(conf) + -- This is the config that will be passed to nvim_open_win. + -- Change values here to customize the layout + return conf + end, + + -- see :help dressing_get_config + get_config = nil, + }, + select = { + -- Set to false to disable the vim.ui.select implementation + enabled = true, + + -- Priority list of preferred vim.select implementations + backend = { "telescope", "fzf_lua", "fzf", "builtin", "nui" }, + + -- Trim trailing `:` from prompt + trim_prompt = true, + + -- Options for telescope selector + -- These are passed into the telescope picker directly. Can be used like: + -- telescope = require('telescope.themes').get_ivy({...}) + telescope = nil, + + -- Options for fzf selector + fzf = { + window = { + width = 0.5, + height = 0.4, + }, + }, + + -- Options for fzf-lua + fzf_lua = { + -- winopts = { + -- height = 0.5, + -- width = 0.5, + -- }, + }, + + -- Options for nui Menu + nui = { + position = "50%", + size = nil, + relative = "editor", + border = { + style = "rounded", + }, + buf_options = { + swapfile = false, + filetype = "DressingSelect", + }, + win_options = { + winblend = 0, + }, + max_width = 80, + max_height = 40, + min_width = 40, + min_height = 10, + }, + + -- Options for built-in selector + builtin = { + -- Display numbers for options and set up keymaps + show_numbers = true, + -- These are passed to nvim_open_win + border = "rounded", + -- 'editor' and 'win' will default to being centered + relative = "editor", + + buf_options = {}, + win_options = { + cursorline = true, + cursorlineopt = "both", + }, + + -- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) + -- the min_ and max_ options can be a list of mixed types. + -- max_width = {140, 0.8} means "the lesser of 140 columns or 80% of total" + width = nil, + max_width = { 140, 0.8 }, + min_width = { 40, 0.2 }, + height = nil, + max_height = 0.9, + min_height = { 10, 0.2 }, + + -- Set to `false` to disable + mappings = { + [""] = "Close", + [""] = "Close", + [""] = "Confirm", + }, + + override = function(conf) + -- This is the config that will be passed to nvim_open_win. + -- Change values here to customize the layout + return conf + end, + }, + + -- Used to override format_item. See :help dressing-format + format_item_override = {}, + + -- see :help dressing_get_config + get_config = nil, + }, + }) ''; + }; +} diff --git a/config/ui/indent-blankline.nix b/config/ui/indent-blankline.nix new file mode 100644 index 0000000..bbdc8a6 --- /dev/null +++ b/config/ui/indent-blankline.nix @@ -0,0 +1,45 @@ +{ + lib, + config, + ... +}: { + options = { + indent-blankline.enable = lib.mkEnableOption "Enable indent-blankline module"; + }; + config = lib.mkIf config.indent-blankline.enable { + plugins = { + indent-blankline = { + enable = true; + settings = { + indent = { + char = "│"; # "│" or "▎" + }; + scope = { + enabled = true; + show_start = true; + }; + exclude = { + buftypes = [ + "terminal" + "nofile" + ]; + filetypes = [ + "help" + "alpha" + "dashboard" + "neo-tree" + "Trouble" + "trouble" + "lazy" + "mason" + "notify" + "toggleterm" + "lazyterm" + "nvterm" + ]; + }; + }; + }; + }; + }; +} diff --git a/config/ui/noice.nix b/config/ui/noice.nix new file mode 100644 index 0000000..7479d03 --- /dev/null +++ b/config/ui/noice.nix @@ -0,0 +1,59 @@ +{ + lib, + config, + ... +}: { + options = { + noice.enable = lib.mkEnableOption "Enable noice module"; + }; + config = lib.mkIf config.noice.enable { + plugins.noice = { + enable = true; + notify = { + enabled = false; + }; + messages = { + enabled = true; # Adds a padding-bottom to neovim statusline when set to false for some reason + }; + lsp = { + message = { + enabled = true; + }; + progress = { + enabled = false; + view = "mini"; + }; + }; + popupmenu = { + enabled = true; + backend = "nui"; + }; + format = { + filter = { + pattern = [ + ":%s*%%s*s:%s*" + ":%s*%%s*s!%s*" + ":%s*%%s*s/%s*" + "%s*s:%s*" + ":%s*s!%s*" + ":%s*s/%s*" + ]; + icon = ""; + lang = "regex"; + }; + replace = { + pattern = [ + ":%s*%%s*s:%w*:%s*" + ":%s*%%s*s!%w*!%s*" + ":%s*%%s*s/%w*/%s*" + "%s*s:%w*:%s*" + ":%s*s!%w*!%s*" + ":%s*s/%w*/%s*" + ]; + icon = "󱞪"; + lang = "regex"; + }; + }; + }; + }; +} diff --git a/config/ui/notify.nix b/config/ui/notify.nix new file mode 100644 index 0000000..7c0ac29 --- /dev/null +++ b/config/ui/notify.nix @@ -0,0 +1,146 @@ +{ + lib, + config, + ... +}: { + options = { + notify.enable = lib.mkEnableOption "Enable notify module"; + }; + config = lib.mkIf config.notify.enable { + plugins.notify = { + enable = true; + backgroundColour = "#000000"; + fps = 60; + render = "default"; + timeout = 500; + topDown = true; + }; + 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 function show_notification(message, level) + notify(message, level, { title = "conform.nvim" }) + end + + function ToggleLineNumber() + if vim.wo.number then + vim.wo.number = false + show_notification("Line numbers disabled", "info") + else + vim.wo.number = true + vim.wo.relativenumber = false + show_notification("Line numbers enabled", "info") + end + end + + function ToggleRelativeLineNumber() + if vim.wo.relativenumber then + vim.wo.relativenumber = false + show_notification("Relative line numbers disabled", "info") + else + vim.wo.relativenumber = true + vim.wo.number = false + show_notification("Relative line numbers enabled", "info") + end + end + + function ToggleWrap() + if vim.wo.wrap then + vim.wo.wrap = false + show_notification("Wrap disabled", "info") + else + vim.wo.wrap = true + vim.wo.number = false + show_notification("Wrap enabled", "info") + end + end + + function ToggleInlayHints() + local is_enabled = vim.lsp.inlay_hint.is_enabled() + vim.lsp.inlay_hint.enable(not is_enabled) + if is_enabled then + show_notification("Inlay Hints disabled", "info") + else + show_notification("Inlay Hints enabled", "info") + end + end + + vim.api.nvim_create_autocmd("BufReadPost", { + callback = function() + local current_dir = vim.fn.getcwd() + local is_nixpkgs = current_dir:match("nixpkgs$") + if is_nixpkgs then + vim.b.disable_autoformat = true + show_notification("Autoformat-on-save disabled for nixpkgs", "info") + else + vim.b.disable_autoformat = false + end + end, + }) + + vim.api.nvim_create_user_command("FormatToggle", function(args) + local is_global = not args.bang + local current_dir = vim.fn.getcwd() + local is_nixpkgs = current_dir:match("nixpkgs$") + + if is_global then + vim.g.disable_autoformat = not vim.g.disable_autoformat + if vim.g.disable_autoformat then + show_notification("Autoformat-on-save disabled globally", "info") + else + show_notification("Autoformat-on-save enabled globally", "info") + end + elseif is_nixpkgs then + vim.b.disable_autoformat = not vim.b.disable_autoformat + if vim.b.disable_autoformat then + show_notification("Autoformat-on-save disabled for nixpkgs", "info") + else + show_notification("Autoformat-on-save enabled for nixpkgs", "info") + end + else + vim.b.disable_autoformat = not vim.b.disable_autoformat + if vim.b.disable_autoformat then + show_notification("Autoformat-on-save disabled for this buffer", "info") + else + show_notification("Autoformat-on-save enabled for this buffer", "info") + end + end + end, { + desc = "Toggle autoformat-on-save", + bang = true, + }) + + 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/config/ui/nui.nix b/config/ui/nui.nix new file mode 100644 index 0000000..7aa1cd1 --- /dev/null +++ b/config/ui/nui.nix @@ -0,0 +1,13 @@ +{ + lib, + config, + pkgs, + ... +}: { + options = { + nui.enable = lib.mkEnableOption "Enable nui module"; + }; + config = lib.mkIf config.nui.enable { + extraPlugins = with pkgs.vimPlugins; [nui-nvim]; + }; +} diff --git a/config/ui/web-devicons.nix b/config/ui/web-devicons.nix new file mode 100644 index 0000000..80421af --- /dev/null +++ b/config/ui/web-devicons.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + ... +}: { + options = { + web-devicons.enable = lib.mkEnableOption "Enable web-devicons module"; + }; + config = lib.mkIf config.web-devicons.enable { + plugins.web-devicons = { + enable = true; + }; + }; +} diff --git a/config/utils/better-escape.nix b/config/utils/better-escape.nix new file mode 100644 index 0000000..08e4fb8 --- /dev/null +++ b/config/utils/better-escape.nix @@ -0,0 +1,42 @@ +{ + lib, + config, + ... +}: { + options = { + better-escape.enable = lib.mkEnableOption "Enable better-escape module"; + }; + config = lib.mkIf config.better-escape.enable { + plugins.better-escape = { + enable = true; + settings = { + timeout = 200; + default_mappings = false; + mappings = { + i = { + j = { + k = ""; + j = ""; + }; + }; + c = { + j = { + k = ""; + j = ""; + }; + }; + v = { + j = { + k = ""; + }; + }; + s = { + j = { + k = ""; + }; + }; + }; + }; + }; + }; +} diff --git a/config/utils/cloak.nix b/config/utils/cloak.nix new file mode 100644 index 0000000..daad172 --- /dev/null +++ b/config/utils/cloak.nix @@ -0,0 +1,28 @@ +{ + lib, + config, + ... +}: { + options = { + cloak.enable = lib.mkEnableOption "Enable cloak module"; + }; + config = lib.mkIf config.cloak.enable { + plugins.cloak = { + enable = true; + settings = { + cloak_character = "*"; + highlight_group = "Comment"; + patterns = [ + { + file_pattern = [ + ".env*" + "wrangler.toml" + ".dev.vars" + ]; + cloak_pattern = "=.+"; + } + ]; + }; + }; + }; +} diff --git a/config/utils/colorizer.nix b/config/utils/colorizer.nix new file mode 100644 index 0000000..e39c57d --- /dev/null +++ b/config/utils/colorizer.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + ... +}: { + options = { + colorizer.enable = lib.mkEnableOption "Enable nvim-colorizer module"; + }; + config = lib.mkIf config.colorizer.enable { + plugins.colorizer = { + enable = true; + }; + }; +} diff --git a/config/utils/default.nix b/config/utils/default.nix new file mode 100644 index 0000000..1313bb8 --- /dev/null +++ b/config/utils/default.nix @@ -0,0 +1,60 @@ +{ + lib, + config, + ... +}: { + imports = [ + ./better-escape.nix + ./cloak.nix + ./colorizer.nix + ./harpoon.nix + ./markdown-preview.nix + ./mini.nix + ./neocord.nix + ./neotest.nix + ./nvim-autopairs.nix + ./nvim-surround.nix + ./nvterm.nix + ./oil.nix + ./persistence.nix + ./plenary.nix + ./project-nvim.nix + ./sidebar.nix + ./tmux-navigator.nix + ./todo-comments.nix + ./ultimate-autopair.nix + ./undotree.nix + ./wakatime.nix + ./which-key.nix + ./wilder.nix + ]; + + options = { + utils.enable = lib.mkEnableOption "Enable utils module"; + }; + config = lib.mkIf config.utils.enable { + better-escape.enable = lib.mkDefault true; + cloak.enable = lib.mkDefault true; + harpoon.enable = lib.mkDefault false; + markdown-preview.enable = lib.mkDefault false; + mini.enable = lib.mkDefault true; + neocord.enable = lib.mkDefault false; + neotest.enable = lib.mkDefault true; + nvim-autopairs.enable = lib.mkDefault true; + colorizer.enable = lib.mkDefault true; + nvim-surround.enable = lib.mkDefault true; + nvterm.enable = lib.mkDefault true; + oil.enable = lib.mkDefault true; + persistence.enable = lib.mkDefault true; + plenary.enable = lib.mkDefault true; + project-nvim.enable = lib.mkDefault true; + sidebar.enable = lib.mkDefault false; + tmux-navigator.enable = lib.mkDefault true; + todo-comments.enable = lib.mkDefault true; + ultimate-autopair.enable = lib.mkDefault true; + undotree.enable = lib.mkDefault true; + wakatime.enable = lib.mkDefault false; + which-key.enable = lib.mkDefault true; + wilder.enable = lib.mkDefault false; + }; +} diff --git a/config/utils/harpoon.nix b/config/utils/harpoon.nix new file mode 100644 index 0000000..462c22c --- /dev/null +++ b/config/utils/harpoon.nix @@ -0,0 +1,26 @@ +{ + lib, + config, + ... +}: { + options = { + harpoon.enable = lib.mkEnableOption "Enable harpoon module"; + }; + config = lib.mkIf config.harpoon.enable { + plugins.harpoon = { + enable = true; + enableTelescope = true; + keymapsSilent = true; + keymaps = { + addFile = "ha"; + toggleQuickMenu = ""; + navFile = { + "1" = "hj"; + "2" = "hk"; + "3" = "hl"; + "4" = "hm"; + }; + }; + }; + }; +} diff --git a/config/utils/markdown-preview.nix b/config/utils/markdown-preview.nix new file mode 100644 index 0000000..4537c7e --- /dev/null +++ b/config/utils/markdown-preview.nix @@ -0,0 +1,29 @@ +{ + lib, + config, + ... +}: { + # TODO: Switch to peek.nvim + options = { + markdown-preview.enable = lib.mkEnableOption "Enable markdown-preview module"; + }; + config = lib.mkIf config.markdown-preview.enable { + plugins.markdown-preview = { + enable = true; + settings = { + browser = "firefox"; + theme = "dark"; + }; + }; + keymaps = [ + { + mode = "n"; + key = "cp"; + action = "MarkdownPreview"; + options = { + desc = "Markdown Preview"; + }; + } + ]; + }; +} diff --git a/config/utils/mini.nix b/config/utils/mini.nix new file mode 100644 index 0000000..4ca296e --- /dev/null +++ b/config/utils/mini.nix @@ -0,0 +1,28 @@ +{ + lib, + config, + ... +}: { + options = { + mini.enable = lib.mkEnableOption "Enable mini module"; + }; + config = lib.mkIf config.mini.enable { + plugins.mini = { + enable = true; + modules = { + comment = { + options = { + customCommentString = '' + lua require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring + ''; + }; + }; + cursorword = { + opts = { + delay = 100; + }; + }; + }; + }; + }; +} diff --git a/config/utils/neocord.nix b/config/utils/neocord.nix new file mode 100644 index 0000000..d9e8d45 --- /dev/null +++ b/config/utils/neocord.nix @@ -0,0 +1,36 @@ +{ + lib, + config, + ... +}: { + options = { + neocord.enable = lib.mkEnableOption "Enable neocord module"; + }; + config = lib.mkIf config.neocord.enable { + plugins.neocord = { + enable = true; + settings = { + auto_update = true; + blacklist = []; + client_id = "1157438221865717891"; + debounce_timeout = 10; + editing_text = "Editing..."; + enable_line_number = true; + logo = "https://repository-images.githubusercontent.com/325421844/ecb73f47-cb89-4ee0-a0fd-9743c2f3569a"; + logo_tooltip = "NixVim"; + file_assets = null; + file_explorer_text = "Browsing..."; + git_commit_text = "Committing changes..."; + global_timer = true; + line_number_text = "Line %s out of %s"; + log_level = null; + main_image = "logo"; + plugin_manager_text = "Managing plugins..."; + reading_text = "Reading..."; + show_time = true; + terminal_text = "Using Terminal..."; + workspace_text = "Working on %s"; + }; + }; + }; +} diff --git a/config/utils/neotest.nix b/config/utils/neotest.nix new file mode 100644 index 0000000..a56e1bb --- /dev/null +++ b/config/utils/neotest.nix @@ -0,0 +1,144 @@ +{ + lib, + config, + pkgs, + ... +}: { + # TODO: Refactor this as neotest is supported on nixvim now + options = { + neotest.enable = lib.mkEnableOption "Enable neotest module"; + }; + config = lib.mkIf config.neotest.enable { + extraPlugins = with pkgs.vimPlugins; [ + # (pkgs.vimUtils.buildVimPlugin { + # pname = "neotest-java"; + # version = "v0.17.6"; + # src = pkgs.fetchFromGitHub { + # owner = "rcasia"; + # repo = "neotest-java"; + # rev = "43b4cf9ee0d3d05f56a9a43c89c4268157cfbc79"; + # sha256 = "0653fx7bcr8mn38dfza4qywia1i862zc42frwf18s51zp5jjrfqy"; + # }; + # }) + (pkgs.vimUtils.buildVimPlugin { + pname = "neotest-vim-test"; + version = "2023-04-17"; + src = pkgs.fetchFromGitHub { + owner = "nvim-neotest"; + repo = "neotest-vim-test"; + rev = "75c4228882ae4883b11bfce9b8383e637eb44192"; + sha256 = "12ix1lzmqlk3iyngaafby9c02fcl9d5iva965miwxfljvmibjnbw"; + }; + }) + neotest + FixCursorHold-nvim + neotest-plenary + vim-test + neotest-python + neotest-vitest + ]; + extraConfigLua = '' + require("neotest").setup({ + adapters = { + -- require("neotest-java")({ + -- ignore_wrapper = false, + -- -- function to determine which runner to use based on project path + -- determine_runner = function(project_root_path) + -- -- return should be "maven" or "gradle" + -- return "maven" + -- end, + -- -- override the builtin runner discovery behaviour to always use given + -- -- tool. Default is "nil", so no override + -- force_runner = nil, + -- -- if the automatic runner discovery can't uniquely determine whether + -- -- to use Gradle or Maven, fallback to using this runner. Default is + -- -- "maven" + -- fallback_runner = "gradle" + -- }), + require("neotest-python")({ + dap = { justMyCode = false }, + }), + require "neotest-vim-test" { + ignore_file_types = { "python", "java", "vim", "lua", "javascript", "typescript" }, + }, + }, + output = { enabled = true, open_on_run = true }, + summary = { enabled = true, }, + }) + ''; + keymaps = [ + { + mode = "n"; + key = "tt"; + action = "lua require('neotest').run.run(vim.fn.expand '%')"; + options = { + desc = "Run File"; + silent = true; + }; + } + { + mode = "n"; + key = "tT"; + action = "lua require('neotest').run.run(vim.loop.cwd())"; + options = { + desc = "Run All Test Files"; + silent = true; + }; + } + { + mode = "n"; + key = "tr"; + action = "lua require('neotest').run.run()"; + options = { + desc = "Run Nearest"; + silent = true; + }; + } + { + mode = "n"; + key = "td"; + action = "lua require('neotest').run.run({strategy = 'dap'})"; + options = { + desc = "Run Nearest with debugger"; + silent = true; + }; + } + { + mode = "n"; + key = "ts"; + action = "lua require('neotest').summary.toggle()"; + options = { + desc = "Toggle Summary"; + silent = true; + }; + } + { + mode = "n"; + key = "to"; + action = "lua require('neotest').output.open{ enter = true, auto_close = true }"; + options = { + desc = "Show Output"; + silent = true; + }; + } + { + mode = "n"; + key = "tO"; + action = "lua require('neotest').output_panel.toggle()"; + options = { + desc = "Toggle Output Panel"; + silent = true; + }; + } + { + mode = "n"; + key = "tS"; + action = "lua require('neotest').run.stop()"; + options = { + desc = "Stop"; + silent = true; + }; + } + ]; + }; +} diff --git a/config/utils/nvim-autopairs.nix b/config/utils/nvim-autopairs.nix new file mode 100644 index 0000000..b90425e --- /dev/null +++ b/config/utils/nvim-autopairs.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + ... +}: { + options = { + nvim-autopairs.enable = lib.mkEnableOption "Enable nvim-autopairs module"; + }; + config = lib.mkIf config.nvim-autopairs.enable { + plugins.nvim-autopairs = { + enable = true; + }; + }; +} diff --git a/config/utils/nvim-surround.nix b/config/utils/nvim-surround.nix new file mode 100644 index 0000000..d265385 --- /dev/null +++ b/config/utils/nvim-surround.nix @@ -0,0 +1,15 @@ +{ + lib, + config, + pkgs, + ... +}: { + options = { + nvim-surround.enable = lib.mkEnableOption "Enable nvim-surround module"; + }; + config = lib.mkIf config.nvim-surround.enable { + plugins.nvim-surround = { + enable = true; + }; + }; +} diff --git a/config/utils/nvterm.nix b/config/utils/nvterm.nix new file mode 100644 index 0000000..9c54b26 --- /dev/null +++ b/config/utils/nvterm.nix @@ -0,0 +1,73 @@ +{ + lib, + config, + pkgs, + ... +}: { + options = { + nvterm.enable = lib.mkEnableOption "Enable nvterm module"; + }; + config = lib.mkIf config.nvterm.enable { + extraPlugins = [ + pkgs.vimPlugins.nvterm + ]; + extraConfigLua = '' + require("nvterm").setup({ + terminals = { + shell = vim.o.shell, + list = {}, + type_opts = { + float = { + relative = "editor", + row = 0.3, + col = 0.25, + width = 0.5, + height = 0.4, + border = "single", + }, + horizontal = { location = "rightbelow", split_ratio = 0.5 }, + vertical = { location = "rightbelow", split_ratio = 0.5 }, + }, + }, + behavior = { + autoclose_on_quit = { + enabled = false, + confirm = true, + }, + close_on_exit = true, + auto_insert = true, + }, + }) + local terminal = require("nvterm.terminal") + + local toggle_modes = { "n", "t" } + local mappings = { + { + toggle_modes, + "", + function() + terminal.toggle("horizontal") + end, + }, + { + toggle_modes, + "", + function() + terminal.toggle("vertical") + end, + }, + { + toggle_modes, + "", + function() + terminal.toggle("float") + end, + }, + } + local opts = { noremap = true, silent = true } + for _, mapping in ipairs(mappings) do + vim.keymap.set(mapping[1], mapping[2], mapping[3], opts) + end + ''; + }; +} diff --git a/config/utils/oil.nix b/config/utils/oil.nix new file mode 100644 index 0000000..77163a9 --- /dev/null +++ b/config/utils/oil.nix @@ -0,0 +1,66 @@ +{ + lib, + config, + ... +}: { + options = { + oil.enable = lib.mkEnableOption "Enable oil module"; + }; + config = lib.mkIf config.oil.enable { + plugins.oil = { + enable = true; + settings = { + deleteToTrash = true; + useDefaultKeymaps = true; + viewOptions = { + showHidden = true; + }; + preview = { + border = "rounded"; + win_options = { + winblend = 0; + }; + }; + + float = { + padding = 2; + maxWidth = 0; # ''math.ceil(vim.o.lines * 0.8 - 4)''; + maxHeight = 0; # ''math.ceil(vim.o.columns * 0.8)''; + border = "rounded"; # 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open + winOptions = { + winblend = 0; + }; + }; + keymaps = { + "g?" = "actions.show_help"; + "" = "actions.select"; + "" = "actions.select_vsplit"; + "" = "actions.select_split"; # this is used to navigate left + "" = "actions.select_tab"; + "" = "actions.preview"; + "" = "actions.close"; + "" = "actions.refresh"; + "-" = "actions.parent"; + "_" = "actions.open_cwd"; + "`" = "actions.cd"; + "~" = "actions.tcd"; + "gs" = "actions.change_sort"; + "gx" = "actions.open_external"; + "g." = "actions.toggle_hidden"; + "q" = "actions.close"; + }; + }; + }; + keymaps = [ + { + mode = "n"; + key = "o"; + action = ":Oil --float"; + options = { + desc = "Open parent directory"; + silent = true; + }; + } + ]; + }; +} diff --git a/config/utils/persistence.nix b/config/utils/persistence.nix new file mode 100644 index 0000000..4ea5497 --- /dev/null +++ b/config/utils/persistence.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + ... +}: { + options = { + persistence.enable = lib.mkEnableOption "Enable persistence module"; + }; + config = lib.mkIf config.persistence.enable { + plugins.persistence = { + enable = true; + }; + }; +} diff --git a/config/utils/plenary.nix b/config/utils/plenary.nix new file mode 100644 index 0000000..a131265 --- /dev/null +++ b/config/utils/plenary.nix @@ -0,0 +1,15 @@ +{ + lib, + config, + pkgs, + ... +}: { + options = { + plenary.enable = lib.mkEnableOption "Enable plenary module"; + }; + config = lib.mkIf config.plenary.enable { + extraPlugins = with pkgs.vimPlugins; [ + plenary-nvim + ]; + }; +} diff --git a/config/utils/project-nvim.nix b/config/utils/project-nvim.nix new file mode 100644 index 0000000..9f05562 --- /dev/null +++ b/config/utils/project-nvim.nix @@ -0,0 +1,15 @@ +{ + lib, + config, + ... +}: { + options = { + project-nvim.enable = lib.mkEnableOption "Enable project-nvim module"; + }; + config = lib.mkIf config.project-nvim.enable { + plugins.project-nvim = { + enable = true; + enableTelescope = true; + }; + }; +} diff --git a/config/utils/sidebar.nix b/config/utils/sidebar.nix new file mode 100644 index 0000000..ace1333 --- /dev/null +++ b/config/utils/sidebar.nix @@ -0,0 +1,65 @@ +{ + lib, + config, + pkgs, + ... +}: { + options = { + sidebar.enable = lib.mkEnableOption "Enable sidebar module"; + }; + config = lib.mkIf config.sidebar.enable { + extraPlugins = with pkgs.vimUtils; [ + (buildVimPlugin { + pname = "sidebar.nvim"; + version = "2024-02-07"; + src = pkgs.fetchFromGitHub { + owner = "sidebar-nvim"; + repo = "sidebar.nvim"; + rev = "5695712eef6288fff667343c4ae77c54911bdb1b"; + sha256 = "1p12189367x0x26cys9wxipzwr3i0bmz4lb0s79ki0a49d6zja2c"; + }; + }) + ]; + extraConfigLua = '' + local sidebar = require("sidebar-nvim") + sidebar.setup({ + disable_default_keybindings = 0, + bindings = nil, + open = false, + side = "left", + initial_width = 32, + hide_statusline = false, + update_interval = 1000, + sections = { "git", "containers" }, + section_separator = {"", "-----", ""}, + section_title_separator = {""}, + containers = { + attach_shell = "/bin/sh", show_all = true, interval = 5000, + }, + datetime = { format = "%a %b %d, %H:%M", clocks = { { name = "local" } } }, + todos = { ignored_paths = {} }, + ["git"] = { + icon = "", --  + }, + }) + cmd = { + "SidebarNvimToggle", + "SidebarNvimOpen", + "SidebarNvimFocus", + "SidebarNvimUpdate", + }, + ''; + + keymaps = [ + { + mode = "n"; + key = "e"; + action = ":SidebarNvimToggle"; + options = { + desc = "Toggle Explorer"; + silent = true; + }; + } + ]; + }; +} diff --git a/config/utils/tmux-navigator.nix b/config/utils/tmux-navigator.nix new file mode 100644 index 0000000..86d6566 --- /dev/null +++ b/config/utils/tmux-navigator.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + ... +}: { + options = { + tmux-navigator.enable = lib.mkEnableOption "Enable tmux-navigator module"; + }; + config = lib.mkIf config.tmux-navigator.enable { + plugins.tmux-navigator = { + enable = true; + }; + }; +} diff --git a/config/utils/todo-comments.nix b/config/utils/todo-comments.nix new file mode 100644 index 0000000..5b29846 --- /dev/null +++ b/config/utils/todo-comments.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + ... +}: { + options = { + todo-comments.enable = lib.mkEnableOption "Enable todo-comments module"; + }; + config = lib.mkIf config.todo-comments.enable { + plugins.todo-comments = { + enable = true; + }; + }; +} diff --git a/config/utils/ultimate-autopair.nix b/config/utils/ultimate-autopair.nix new file mode 100644 index 0000000..37c6a73 --- /dev/null +++ b/config/utils/ultimate-autopair.nix @@ -0,0 +1,27 @@ +{ + lib, + config, + pkgs, + ... +}: { + options = { + ultimate-autopair.enable = lib.mkEnableOption "Enable ultimate-autopair module"; + }; + config = lib.mkIf config.ultimate-autopair.enable { + extraPlugins = with pkgs.vimUtils; [ + (buildVimPlugin { + pname = "ultimate-autopair.nvim"; + version = "2024-02-05"; + src = pkgs.fetchFromGitHub { + owner = "altermo"; + repo = "ultimate-autopair.nvim"; + rev = "25c13e0ce167db0255456cac10158b27d2be30c0"; + sha256 = "0bsxfj6g8fii9nn92vl15hdhafx3fikgiz4srr7y10pxz01c5s4c"; + }; + }) + ]; + extraConfigLua = '' + require('ultimate-autopair').setup() + ''; + }; +} diff --git a/config/utils/undotree.nix b/config/utils/undotree.nix new file mode 100644 index 0000000..78699e6 --- /dev/null +++ b/config/utils/undotree.nix @@ -0,0 +1,29 @@ +{ + lib, + config, + ... +}: { + options = { + undotree.enable = lib.mkEnableOption "Enable undotree module"; + }; + config = lib.mkIf config.undotree.enable { + plugins.undotree = { + enable = true; + settings = { + autoOpenDiff = true; + focusOnToggle = true; + }; + }; + keymaps = [ + { + mode = "n"; + key = "ut"; + action = "UndotreeToggle"; + options = { + silent = true; + desc = "Undotree"; + }; + } + ]; + }; +} diff --git a/config/utils/wakatime.nix b/config/utils/wakatime.nix new file mode 100644 index 0000000..6a79cf2 --- /dev/null +++ b/config/utils/wakatime.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + ... +}: { + options = { + wakatime.enable = lib.mkEnableOption "Enable wakatime module"; + }; + config = lib.mkIf config.wakatime.enable { + plugins.wakatime = { + enable = true; + }; + }; +} diff --git a/config/utils/which-key.nix b/config/utils/which-key.nix new file mode 100644 index 0000000..ea82616 --- /dev/null +++ b/config/utils/which-key.nix @@ -0,0 +1,126 @@ +{ + lib, + config, + ... +}: { + options = { + which-key.enable = lib.mkEnableOption "Enable which-key module"; + }; + config = lib.mkIf config.which-key.enable { + plugins.which-key = { + enable = true; + settings = { + icons = { + breadcrumb = "»"; + group = "+"; + separator = ""; # ➜ + }; + spec = [ + # Harpoon Configs + { + __unkeyed-1 = "h"; + mode = "n"; + group = "+harpoon"; + icon = "󱡁"; + } + { + __unkeyed-1 = "ha"; + mode = "n"; + group = "Add file to Harpoon"; + } + { + __unkeyed-1 = "hj"; + mode = "n"; + group = "Harpoon File 1"; + } + { + __unkeyed-1 = "hk"; + mode = "n"; + group = "Harpoon File 2"; + } + { + __unkeyed-1 = "hl"; + mode = "n"; + group = "Harpoon File 3"; + } + { + __unkeyed-1 = "hm"; + mode = "n"; + group = "Harpoon File 4"; + } + + # General Mappings + { + __unkeyed-1 = "c"; + mode = [ + "n" + "v" + ]; + group = "+code"; + } + { + __unkeyed-1 = "d"; + mode = [ + "n" + "v" + ]; + group = "+debug"; + } + { + __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 = ""; + mode = "n"; + group = "+tab"; + } + + { + __unkeyed-1 = "t"; + mode = "n"; + group = "+test"; + } + + { + __unkeyed-1 = "u"; + mode = "n"; + group = "+ui"; + } + + { + __unkeyed-1 = "w"; + mode = "n"; + group = "+windows"; + } + ]; + win = { + border = "none"; + wo.winblend = 0; + }; + }; + }; + }; +} diff --git a/config/utils/wilder.nix b/config/utils/wilder.nix new file mode 100644 index 0000000..401aa98 --- /dev/null +++ b/config/utils/wilder.nix @@ -0,0 +1,57 @@ +{ + lib, + config, + ... +}: { + options = { + wilder.enable = lib.mkEnableOption "Enable wilder module"; + }; + config = lib.mkIf config.wilder.enable { + plugins.wilder = { + enable = true; + modes = [ + ":" + "/" + "?" + ]; + pipeline = [ + '' + wilder.branch( + wilder.python_file_finder_pipeline({ + file_command = function(ctx, arg) + if string.find(arg, '.') ~= nil then + return {'fd', '-tf', '-H'} + else + return {'fd', '-tf'} + end + end, + dir_command = {'fd', '-td'}, + filters = {'cpsm_filter'}, + }), + wilder.substitute_pipeline({ + pipeline = wilder.python_search_pipeline({ + skip_cmdtype_check = 1, + pattern = wilder.python_fuzzy_pattern({ + start_at_boundary = 0, + }), + }), + }), + wilder.cmdline_pipeline({ + language = 'python', + fuzzy = 1, + }), + { + wilder.check(function(ctx, x) return x == "" end), + wilder.history(), + }, + wilder.python_search_pipeline({ + pattern = wilder.python_fuzzy_pattern({ + start_at_boundary = 0, + }), + }) + ) + '' + ]; + }; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d4270bc --- /dev/null +++ b/flake.lock @@ -0,0 +1,351 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1735644329, + "narHash": "sha256-tO3HrHriyLvipc4xr+Ewtdlo7wM1OjXNjlWRgmM7peY=", + "owner": "numtide", + "repo": "devshell", + "rev": "f7795ede5b02664b57035b3b757876703e2c3eac", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-compat": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1736143030, + "narHash": "sha256-+hu54pAoLDEZT9pjHlqL9DNzWz0NbUn8NEAHP7PQPzU=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "b905f6fc23a9051a6e1b741e1438dbfc0634c6de", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": [ + "nixvim", + "flake-compat" + ], + "gitignore": "gitignore", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737043064, + "narHash": "sha256-I/OuxGwXwRi5gnFPsyCvVR+IfFstA+QXEpHu1hvsgD8=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "94ee657f6032d913fe0ef49adaa743804635b0bb", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixvim", + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737075266, + "narHash": "sha256-u1gk5I1an975FOAMMdS6oBKnSIsZza5ZKhaeBZAskVo=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "12851ae7467bad8ef422b20806ab4d6d81e12d29", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "ixx": { + "inputs": { + "flake-utils": [ + "nixvim", + "nuschtosSearch", + "flake-utils" + ], + "nixpkgs": [ + "nixvim", + "nuschtosSearch", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1729958008, + "narHash": "sha256-EiOq8jF4Z/zQe0QYVc3+qSKxRK//CFHMB84aYrYGwEs=", + "owner": "NuschtOS", + "repo": "ixx", + "rev": "9fd01aad037f345350eab2cd45e1946cc66da4eb", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "ref": "v0.0.6", + "repo": "ixx", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1736819234, + "narHash": "sha256-deQVtIH4UJueELJqluAICUtX7OosD9paTP+5FgbiSwI=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "bd921223ba7cdac346477d7ea5204d6f4736fcc6", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 0, + "narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=", + "path": "/nix/store/8vz84mqgnm1gz5yk7hgnnb5gir5hjxas-source", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1736883708, + "narHash": "sha256-uQ+NQ0/xYU0N1CnXsa2zghgNaOPxWpMJXSUJJ9W7140=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "eb62e6aa39ea67e0b8018ba8ea077efe65807dc8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixvim": { + "inputs": { + "devshell": "devshell", + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "git-hooks": "git-hooks", + "home-manager": "home-manager", + "nix-darwin": "nix-darwin", + "nixpkgs": "nixpkgs_2", + "nuschtosSearch": "nuschtosSearch", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1737461429, + "narHash": "sha256-XOHKAdOk++rgbOJZzZxsyTctcVYvTAHG1I519FcVsk0=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "53bfadc2c2a6cdc12b8f8cf5b4e24701e213cb34", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "nuschtosSearch": { + "inputs": { + "flake-utils": "flake-utils_2", + "ixx": "ixx", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1735854821, + "narHash": "sha256-Iv59gMDZajNfezTO0Fw6LHE7uKAShxbvMidmZREit7c=", + "owner": "NuschtOS", + "repo": "search", + "rev": "836908e3bddd837ae0f13e215dd48767aee355f0", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "repo": "search", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "nixvim": "nixvim" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737054102, + "narHash": "sha256-saLiCRQ5RtdTnznT/fja7GxcYRAzeY3k8S+IF/2s/2A=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "97871d416166803134ba64597a1006f3f670fbde", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d73b43e --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + description = "Neve is a Neovim configuration built with Nixvim, which allows you to use Nix language to manage Neovim plugins/options"; + + inputs = { + nixvim.url = "github:nix-community/nixvim"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { + self, + nixpkgs, + nixvim, + flake-utils, + ... + } @ inputs: let + config = import ./config; # import the module directly + # Enable unfree packages + nixpkgsConfig = { + allowUnfree = true; + }; + in + { + nixvimModule = config; + } + // flake-utils.lib.eachDefaultSystem ( + system: let + nixvimLib = nixvim.lib.${system}; + pkgs = import nixpkgs { + inherit system; + config = nixpkgsConfig; + }; + nixvim' = nixvim.legacyPackages.${system}; + nvim = nixvim'.makeNixvimWithModule { + inherit pkgs; + module = config; + # You can use `extraSpecialArgs` to pass additional arguments to your module files + extraSpecialArgs = { + inherit self; + }; + }; + in { + checks = { + # Run `nix flake check .` to verify that your config is not broken + default = nixvimLib.check.mkTestDerivationFromNvim { + inherit nvim; + name = "Neve"; + }; + }; + + packages = { + # Lets you run `nix run .` to start nixvim + default = nvim; + }; + + formatter = pkgs.nixfmt-rfc-style; + } + ); +}