diff --git a/config/bundles/common.nix b/config/bundles/common.nix new file mode 100644 index 0000000..9af4021 --- /dev/null +++ b/config/bundles/common.nix @@ -0,0 +1,51 @@ +{ + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace enabled; + base = "${namespace}.bundles.common"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "common bundle"; + }; + + config = mkIf cfg.enable { + ${namespace} = { + languages = { + cmp = enabled; + conform = enabled; + dap = enabled; + luasnip = enabled; + treesitter = enabled; + }; + + navigation = { + harpoon = enabled; + nvim-tree = enabled; + telescope = enabled; + }; + + ui = { + alpha = enabled; + fidget = enabled; + indent-blankline = enabled; + lualine = enabled; + noice = enabled; + nvim-notify = enabled; + }; + + utils = { + lazygit = enabled; + todo-comments = enabled; + toggleterm = enabled; + undotree = enabled; + which-key = enabled; + zenmode = enabled; + }; + }; + }; +} diff --git a/config/bundles/common/default.nix b/config/bundles/common/default.nix deleted file mode 100644 index e69de29..0000000 diff --git a/config/bundles/default.nix b/config/bundles/default.nix new file mode 100644 index 0000000..ec003d6 --- /dev/null +++ b/config/bundles/default.nix @@ -0,0 +1,5 @@ +{...} @ inputs: { + imports = [ + (import ./common.nix inputs) + ]; +} diff --git a/config/default.nix b/config/default.nix index 393a655..6638757 100755 --- a/config/default.nix +++ b/config/default.nix @@ -1,9 +1,11 @@ -{ +{...} @ inputs: { imports = [ - ./languages - ./navigation - ./ui - ./utils + (import ./bundles inputs) + + (import ./languages inputs) + (import ./navigation inputs) + (import ./ui inputs) + (import ./utils inputs) ./autocmds.nix ./mappings.nix diff --git a/config/languages/cmp.nix b/config/languages/cmp.nix index 90c0d88..7da582b 100755 --- a/config/languages/cmp.nix +++ b/config/languages/cmp.nix @@ -1,55 +1,70 @@ { - plugins = { - cmp = { - enable = true; - autoEnableSources = true; - - settings = { - sources = [ - {name = "nvim_lsp";} - {name = "luasnip";} - {name = "path";} - {name = "buffer";} - ]; - - mapping = { - "" = "cmp.mapping.select_next_item()"; - "" = "cmp.mapping.select_prev_item()"; - "" = "cmp.mapping.select_next_item()"; - "" = "cmp.mapping.select_prev_item()"; - "" = "cmp.mapping.confirm({ select = true })"; - "" = "cmp.mapping.complete()"; - }; - - 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"; - }; - }; - - formatting = { - fields = ["kind" "abbr" "menu"]; - expandable_indicator = true; - }; - }; - }; - - cmp_luasnip.enable = true; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.languages.cmp"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "nvim-cmp"; }; - extraConfigLua = '' - kind_icons = { + config = mkIf cfg.enable { + plugins = { + cmp = { + enable = true; + autoEnableSources = true; + + settings = { + sources = [ + {name = "nvim_lsp";} + {name = "luasnip";} + {name = "path";} + {name = "buffer";} + ]; + + mapping = { + "" = "cmp.mapping.select_next_item()"; + "" = "cmp.mapping.select_prev_item()"; + "" = "cmp.mapping.select_next_item()"; + "" = "cmp.mapping.select_prev_item()"; + "" = "cmp.mapping.confirm({ select = true })"; + "" = "cmp.mapping.complete()"; + }; + + 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"; + }; + }; + + formatting = { + fields = ["kind" "abbr" "menu"]; + expandable_indicator = true; + }; + }; + }; + + cmp_luasnip.enable = true; + }; + + extraConfigLua = '' + kind_icons = { Text = "󰊄", Method = "", Function = "󰡱", @@ -75,33 +90,34 @@ Event = "", Operator = "", TypeParameter = "", - } + } - local cmp = require'cmp' + local cmp = require'cmp' - -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline({'/', "?" }, { + -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({'/', "?" }, { sources = { - { name = 'buffer' } + { name = 'buffer' } } - }) + }) - -- Set configuration for specific filetype. - cmp.setup.filetype('gitcommit', { + -- Set configuration for specific filetype. + cmp.setup.filetype('gitcommit', { sources = cmp.config.sources({ - { name = 'cmp_git' }, + { name = 'cmp_git' }, }, { - { name = 'buffer' }, + { name = 'buffer' }, }) - }) + }) - -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline(':', { + -- 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 = 'path' } }, { - { name = 'cmdline' } + { name = 'cmdline' } }), - }) - ''; + }) + ''; + }; } diff --git a/config/languages/conform.nix b/config/languages/conform.nix index 10cdbd2..dff0c81 100755 --- a/config/languages/conform.nix +++ b/config/languages/conform.nix @@ -1,104 +1,119 @@ -{lib, ...}: let +{ + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; inherit (lib.nixvim.utils) listToUnkeyedAttrs; + base = "${namespace}.languages.conform"; + cfg = getAttrByNamespace config base; in { - keymaps = [ - { - mode = "n"; - key = "ff"; - action = "FormatToggle"; - options = { - silent = true; - desc = "Conform Toggle autoformat"; - }; - } - { - mode = ["n" "v"]; - key = "f"; - action = "lua require('conform').format({ lsp_format = \"fallback\" })"; - options = { - silent = true; - desc = "Conform Format"; - }; - } - ]; + options = mkOptionsWithNamespace base { + enable = mkEnableOption "conform"; + }; - plugins.conform-nvim = { - enable = true; - settings = { - notify_on_error = true; - - default_format_opts = { - lsp_format = "fallback"; - }; - - formatters_by_ft = let - mkFormatList = formatters: - listToUnkeyedAttrs formatters - // { - stop_after_first = true; - }; - in { - astro = mkFormatList ["prettierd" "prettier"]; - cabal = mkFormatList ["ormolu"]; - haskell = mkFormatList ["ormolu"]; - java = mkFormatList ["google-java-format"]; - javascript = mkFormatList ["prettierd" "prettier"]; - javascriptreact = mkFormatList ["prettierd" "prettier"]; - lua = mkFormatList ["stylua"]; - nix = mkFormatList ["alejandra"]; - racket = mkFormatList ["raco_fmt"]; - typescript = mkFormatList ["prettierd" "prettier"]; - typescriptreact = mkFormatList ["prettierd" "prettier"]; - }; - - formatters = { - raco_fmt = { - command = "raco"; - args = ["fmt"]; + config = mkIf cfg.enable { + keymaps = [ + { + mode = "n"; + key = "ff"; + action = "FormatToggle"; + options = { + silent = true; + desc = "Conform Toggle autoformat"; }; - nix_fmt = { - command = "nix"; - args = ["fmt"]; + } + { + mode = ["n" "v"]; + key = "f"; + action = "lua require('conform').format({ lsp_format = \"fallback\" })"; + options = { + silent = true; + desc = "Conform Format"; + }; + } + ]; + + plugins.conform-nvim = { + enable = true; + settings = { + notify_on_error = true; + + default_format_opts = { + lsp_format = "fallback"; + }; + + formatters_by_ft = let + mkFormatList = formatters: + listToUnkeyedAttrs formatters + // { + stop_after_first = true; + }; + in { + astro = mkFormatList ["prettierd" "prettier"]; + cabal = mkFormatList ["ormolu"]; + haskell = mkFormatList ["ormolu"]; + java = mkFormatList ["google-java-format"]; + javascript = mkFormatList ["prettierd" "prettier"]; + javascriptreact = mkFormatList ["prettierd" "prettier"]; + lua = mkFormatList ["stylua"]; + nix = mkFormatList ["alejandra"]; + racket = mkFormatList ["raco_fmt"]; + typescript = mkFormatList ["prettierd" "prettier"]; + typescriptreact = mkFormatList ["prettierd" "prettier"]; + }; + + formatters = { + raco_fmt = { + command = "raco"; + args = ["fmt"]; + }; + nix_fmt = { + command = "nix"; + args = ["fmt"]; + }; }; }; }; - }; - extraConfigLua = '' - local conform = require("conform") - local notify = require("notify") + extraConfigLua = '' + local conform = require("conform") + local notify = require("notify") - conform.setup({ + conform.setup({ 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 { lsp_format = "fallback" } + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + return { lsp_format = "fallback" } end, - }) + }) - local function show_notification(message, level) + local function show_notification(message, level) notify(message, level, { title = "conform.nvim" }) - end + end - vim.api.nvim_create_user_command("FormatToggle", function(args) + vim.api.nvim_create_user_command("FormatToggle", function(args) local is_global = not args.bang 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 + 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 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 + 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 }) - ''; + end, { desc = "Toggle autoformat-on-save", bang = true }) + ''; + }; } diff --git a/config/languages/dap.nix b/config/languages/dap.nix index 75a3420..3cb8c72 100755 --- a/config/languages/dap.nix +++ b/config/languages/dap.nix @@ -1,362 +1,379 @@ -{pkgs, ...}: { - keymaps = [ - { - mode = "n"; - key = "db"; - action.__raw = "function() require('dap').toggle_breakpoint() end"; - options = { - silent = true; - desc = "Toggle Breakpoint"; - }; - } - { - mode = "n"; - key = "dB"; - action.__raw = "function() require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: ')) end"; - options = { - silent = true; - desc = "Toggle Conditional Breakpoint"; - }; - } - { - mode = "n"; - key = "dc"; - action.__raw = "function() require('dap').continue() end"; - options = { - silent = true; - desc = "Continue"; - }; - } - { - mode = "n"; - key = "da"; - action.__raw = "function() require('dap').continue({ before = get_args }) end"; - options = { - silent = true; - desc = "Run with Args"; - }; - } - { - mode = "n"; - key = "dC"; - action.__raw = "function() require('dap').run_to_cursor() end"; - options = { - silent = true; - desc = "Run to cursor"; - }; - } - { - mode = "n"; - key = "dg"; - action.__raw = "function() require('dap').goto_() end"; - options = { - silent = true; - desc = "Go to line (no execute)"; - }; - } - { - mode = "n"; - key = "di"; - action.__raw = "function() require('dap').step_into() end"; - options = { - silent = true; - desc = "Step into"; - }; - } - { - mode = "n"; - key = "dj"; - action.__raw = "function() require('dap').down() end"; - options = { - silent = true; - desc = "Down"; - }; - } - { - mode = "n"; - key = "dk"; - action.__raw = "function() require('dap').up() end"; - options = { - silent = true; - desc = "Up"; - }; - } - { - mode = "n"; - key = "dl"; - action.__raw = "function() require('dap').run_last() end"; - options = { - silent = true; - desc = "Run Last"; - }; - } - { - mode = "n"; - key = "do"; - action.__raw = "function() require('dap').step_out() end"; - options = { - silent = true; - desc = "Step Out"; - }; - } - { - mode = "n"; - key = "dO"; - action.__raw = "function() require('dap').step_over() end"; - options = { - silent = true; - desc = "Step Over"; - }; - } - { - mode = "n"; - key = "dp"; - action.__raw = "function() require('dap').pause() end"; - options = { - silent = true; - desc = "Pause"; - }; - } - { - mode = "n"; - key = "dr"; - action.__raw = "function() require('dap').repl.toggle() end"; - options = { - silent = true; - desc = "Toggle REPL"; - }; - } - { - mode = "n"; - key = "ds"; - action.__raw = "function() require('dap').session() end"; - options = { - silent = true; - desc = "Session"; - }; - } - { - mode = "n"; - key = "dt"; - action.__raw = "function() require('dap').terminate() end"; - options = { - silent = true; - desc = "Terminate"; - }; - } - { - mode = "n"; - key = "du"; - action.__raw = "function() require('dapui').toggle() end"; - options = { - silent = true; - desc = "Dap UI"; - }; - } - { - mode = ["n" "v"]; - key = "de"; - action.__raw = "function() require('dapui').eval() end"; - options = { - silent = true; - desc = "Eval"; - }; - } - ]; +{ + config, + lib, + namespace, + pkgs, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.languages.dap"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "dap"; + }; - plugins = { - dap = { - enable = true; - adapters = { - servers = { - codelldb = { - port = 13000; - executable = { - command = "${pkgs.vscode-extensions.vadimcn.vscode-lldb}/share/vscode/extensions/vadimcn.vscode-lldb/adapter/codelldb"; - args = ["--port" "13000"]; + config = mkIf cfg.enable { + keymaps = [ + { + mode = "n"; + key = "db"; + action.__raw = "function() require('dap').toggle_breakpoint() end"; + options = { + silent = true; + desc = "Toggle Breakpoint"; + }; + } + { + mode = "n"; + key = "dB"; + action.__raw = "function() require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: ')) end"; + options = { + silent = true; + desc = "Toggle Conditional Breakpoint"; + }; + } + { + mode = "n"; + key = "dc"; + action.__raw = "function() require('dap').continue() end"; + options = { + silent = true; + desc = "Continue"; + }; + } + { + mode = "n"; + key = "da"; + action.__raw = "function() require('dap').continue({ before = get_args }) end"; + options = { + silent = true; + desc = "Run with Args"; + }; + } + { + mode = "n"; + key = "dC"; + action.__raw = "function() require('dap').run_to_cursor() end"; + options = { + silent = true; + desc = "Run to cursor"; + }; + } + { + mode = "n"; + key = "dg"; + action.__raw = "function() require('dap').goto_() end"; + options = { + silent = true; + desc = "Go to line (no execute)"; + }; + } + { + mode = "n"; + key = "di"; + action.__raw = "function() require('dap').step_into() end"; + options = { + silent = true; + desc = "Step into"; + }; + } + { + mode = "n"; + key = "dj"; + action.__raw = "function() require('dap').down() end"; + options = { + silent = true; + desc = "Down"; + }; + } + { + mode = "n"; + key = "dk"; + action.__raw = "function() require('dap').up() end"; + options = { + silent = true; + desc = "Up"; + }; + } + { + mode = "n"; + key = "dl"; + action.__raw = "function() require('dap').run_last() end"; + options = { + silent = true; + desc = "Run Last"; + }; + } + { + mode = "n"; + key = "do"; + action.__raw = "function() require('dap').step_out() end"; + options = { + silent = true; + desc = "Step Out"; + }; + } + { + mode = "n"; + key = "dO"; + action.__raw = "function() require('dap').step_over() end"; + options = { + silent = true; + desc = "Step Over"; + }; + } + { + mode = "n"; + key = "dp"; + action.__raw = "function() require('dap').pause() end"; + options = { + silent = true; + desc = "Pause"; + }; + } + { + mode = "n"; + key = "dr"; + action.__raw = "function() require('dap').repl.toggle() end"; + options = { + silent = true; + desc = "Toggle REPL"; + }; + } + { + mode = "n"; + key = "ds"; + action.__raw = "function() require('dap').session() end"; + options = { + silent = true; + desc = "Session"; + }; + } + { + mode = "n"; + key = "dt"; + action.__raw = "function() require('dap').terminate() end"; + options = { + silent = true; + desc = "Terminate"; + }; + } + { + mode = "n"; + key = "du"; + action.__raw = "function() require('dapui').toggle() end"; + options = { + silent = true; + desc = "Dap UI"; + }; + } + { + mode = ["n" "v"]; + key = "de"; + action.__raw = "function() require('dapui').eval() end"; + options = { + silent = true; + desc = "Eval"; + }; + } + ]; + + plugins = { + dap = { + enable = true; + adapters = { + servers = { + codelldb = { + port = 13000; + executable = { + command = "${pkgs.vscode-extensions.vadimcn.vscode-lldb}/share/vscode/extensions/vadimcn.vscode-lldb/adapter/codelldb"; + args = ["--port" "13000"]; + }; }; - }; - go = { - port = 38697; - executable = { - command = "${pkgs.delve}/bin/dlv"; - args = ["dap" "-l" "127.0.0.1:38697"]; + go = { + port = 38697; + executable = { + command = "${pkgs.delve}/bin/dlv"; + args = ["dap" "-l" "127.0.0.1:38697"]; + }; }; - }; - pwa-node = { - port = 9229; - executable = { - command = "${pkgs.vscode-js-debug}/bin/js-debug"; - args = ["9229" "127.0.0.1"]; + pwa-node = { + port = 9229; + executable = { + command = "${pkgs.vscode-js-debug}/bin/js-debug"; + args = ["9229" "127.0.0.1"]; + }; }; }; }; - }; - configurations = let - exeConfigs = [ - { - type = "codelldb"; - request = "launch"; - name = "exe"; - program.__raw = ''function() return vim.fn.input("Executable: ", vim.fn.getcwd() .. "/target/debug/", "file") end''; - cwd.__raw = ''function() return vim.fn.getcwd() end''; - } - { - type = "codelldb"; - request = "launch"; - name = "exe:args"; - program.__raw = ''function() return vim.fn.input("Executable: ", vim.fn.getcwd() .. "/target/debug/", "file") end ''; - cwd.__raw = ''function() return vim.fn.getcwd() end ''; - args.__raw = ''function() return vim.fn.split(vim.fn.input("Arguments: "), " ") end''; - } - { - type = "codelldb"; - request = "attach"; - name = "attach"; - connect.__raw = ''function() return vim.fn.input("Host: ") end''; - cwd.__raw = ''function() return vim.fn.getcwd() end''; - } - ]; + configurations = let + exeConfigs = [ + { + type = "codelldb"; + request = "launch"; + name = "exe"; + program.__raw = ''function() return vim.fn.input("Executable: ", vim.fn.getcwd() .. "/target/debug/", "file") end''; + cwd.__raw = ''function() return vim.fn.getcwd() end''; + } + { + type = "codelldb"; + request = "launch"; + name = "exe:args"; + program.__raw = ''function() return vim.fn.input("Executable: ", vim.fn.getcwd() .. "/target/debug/", "file") end ''; + cwd.__raw = ''function() return vim.fn.getcwd() end ''; + args.__raw = ''function() return vim.fn.split(vim.fn.input("Arguments: "), " ") end''; + } + { + type = "codelldb"; + request = "attach"; + name = "attach"; + connect.__raw = ''function() return vim.fn.input("Host: ") end''; + cwd.__raw = ''function() return vim.fn.getcwd() end''; + } + ]; - webConfigs = [ - { - type = "pwa-node"; - request = "launch"; - name = "current"; - program = "\${file}"; - cwd.__raw = ''function() return vim.fn.getcwd() end''; - } - { - type = "pwa-node"; - request = "launch"; - name = "current:args"; - program = "\${file}"; - cwd.__raw = ''function() return vim.fn.getcwd() end''; - args.__raw = ''function() return vim.fn.split(vim.fn.input("Arguments: "), " ") end''; - } - { - type = "pwa-node"; - request = "launch"; - name = "file"; - program.__raw = ''function() return vim.fn.input("Executable: ", vim.fn.getcwd(), "file") end ''; - cwd.__raw = ''function() return vim.fn.getcwd() end''; - } - { - type = "pwa-node"; - request = "launch"; - name = "file:args"; - program.__raw = ''function() return vim.fn.input("Executable: ", vim.fn.getcwd(), "file") end ''; - cwd.__raw = ''function() return vim.fn.getcwd() end''; - args.__raw = ''function() return vim.fn.split(vim.fn.input("Arguments: "), " ") end''; - } - { - type = "pwa-node"; - request = "attach"; - name = "attach"; - connect.__raw = ''function() return vim.fn.input("Host: ") end''; - cwd.__raw = ''function() return vim.fn.getcwd() end''; - } - ]; - in { - python = let - findPython = '' - function() - local cwd = vim.fn.getcwd() - if vim.fn.executable(cwd .. "/venv/bin/python") == 1 then - return cwd .. "/venv/bin/python" - elseif vim.fn.executable(cwd .. "/.venv/bin/python") == 1 then - return cwd .. "/.venv/bin/python" - else - return "python3" - end - end - ''; - in [ - { - type = "python"; - request = "launch"; - name = "module"; - module.__raw = ''function() return vim.fn.input("Module: ") end ''; - pythonPath.__raw = findPython; - } - { - type = "python"; - request = "launch"; - name = "module:args"; - module.__raw = ''function() return vim.fn.input("Module: ") end ''; - args.__raw = ''function() return vim.fn.split(vim.fn.input("Arguments: "), " ") end''; - pythonPath.__raw = findPython; - } - ]; - c = exeConfigs; - cpp = exeConfigs; - rust = exeConfigs; - zig = exeConfigs; - go = [ - { - type = "go"; - request = "launch"; - name = "file"; - program = "\${file}"; - outputMode = "remote"; - } - { - type = "go"; - request = "launch"; - name = "file:args"; - program = "\${file}"; - args.__raw = ''function() return vim.fn.split(vim.fn.input("Arguments: "), " ") end''; - outputMode = "remote"; - } - { - type = "go"; - mode = "remote"; - request = "attach"; - name = "attach"; - connect.__raw = '' + webConfigs = [ + { + type = "pwa-node"; + request = "launch"; + name = "current"; + program = "\${file}"; + cwd.__raw = ''function() return vim.fn.getcwd() end''; + } + { + type = "pwa-node"; + request = "launch"; + name = "current:args"; + program = "\${file}"; + cwd.__raw = ''function() return vim.fn.getcwd() end''; + args.__raw = ''function() return vim.fn.split(vim.fn.input("Arguments: "), " ") end''; + } + { + type = "pwa-node"; + request = "launch"; + name = "file"; + program.__raw = ''function() return vim.fn.input("Executable: ", vim.fn.getcwd(), "file") end ''; + cwd.__raw = ''function() return vim.fn.getcwd() end''; + } + { + type = "pwa-node"; + request = "launch"; + name = "file:args"; + program.__raw = ''function() return vim.fn.input("Executable: ", vim.fn.getcwd(), "file") end ''; + cwd.__raw = ''function() return vim.fn.getcwd() end''; + args.__raw = ''function() return vim.fn.split(vim.fn.input("Arguments: "), " ") end''; + } + { + type = "pwa-node"; + request = "attach"; + name = "attach"; + connect.__raw = ''function() return vim.fn.input("Host: ") end''; + cwd.__raw = ''function() return vim.fn.getcwd() end''; + } + ]; + in { + python = let + findPython = '' function() - local input = vim.fn.input("Host: ") - local host, port = string.match(input, "([^:]+):(%d+)") - return { host = host, port = tonumber(port) } + local cwd = vim.fn.getcwd() + if vim.fn.executable(cwd .. "/venv/bin/python") == 1 then + return cwd .. "/venv/bin/python" + elseif vim.fn.executable(cwd .. "/.venv/bin/python") == 1 then + return cwd .. "/.venv/bin/python" + else + return "python3" + end end ''; - cwd.__raw = ''function() return vim.fn.getcwd() end''; - } - ]; + in [ + { + type = "python"; + request = "launch"; + name = "module"; + module.__raw = ''function() return vim.fn.input("Module: ") end ''; + pythonPath.__raw = findPython; + } + { + type = "python"; + request = "launch"; + name = "module:args"; + module.__raw = ''function() return vim.fn.input("Module: ") end ''; + args.__raw = ''function() return vim.fn.split(vim.fn.input("Arguments: "), " ") end''; + pythonPath.__raw = findPython; + } + ]; + c = exeConfigs; + cpp = exeConfigs; + rust = exeConfigs; + zig = exeConfigs; + go = [ + { + type = "go"; + request = "launch"; + name = "file"; + program = "\${file}"; + outputMode = "remote"; + } + { + type = "go"; + request = "launch"; + name = "file:args"; + program = "\${file}"; + args.__raw = ''function() return vim.fn.split(vim.fn.input("Arguments: "), " ") end''; + outputMode = "remote"; + } + { + type = "go"; + mode = "remote"; + request = "attach"; + name = "attach"; + connect.__raw = '' + function() + local input = vim.fn.input("Host: ") + local host, port = string.match(input, "([^:]+):(%d+)") + return { host = host, port = tonumber(port) } + end + ''; + cwd.__raw = ''function() return vim.fn.getcwd() end''; + } + ]; - javascript = webConfigs; - javascriptreact = webConfigs; - typescript = webConfigs; - typescriptreact = webConfigs; - }; - signs = { - dapBreakpoint = { - text = "●"; - texthl = "DapBreakpoint"; + javascript = webConfigs; + javascriptreact = webConfigs; + typescript = webConfigs; + typescriptreact = webConfigs; }; - dapBreakpointCondition = { - text = "⏹"; - texthl = "DapBreakpointCondition"; - }; - dapLogPoint = { - text = "◆"; - texthl = "DapLogPoint"; + signs = { + dapBreakpoint = { + text = "●"; + texthl = "DapBreakpoint"; + }; + dapBreakpointCondition = { + text = "⏹"; + texthl = "DapBreakpointCondition"; + }; + dapLogPoint = { + text = "◆"; + texthl = "DapLogPoint"; + }; }; }; - }; - dap-ui = { - enable = true; + dap-ui = { + enable = true; - settings.floating.mappings = { - close = ["" "q"]; + settings.floating.mappings = { + close = ["" "q"]; + }; }; - }; - dap-python.enable = true; - dap-lldb = { - enable = true; - settings.codelldb_path = "${pkgs.vscode-extensions.vadimcn.vscode-lldb}/share/vscode/extensions/vadimcn.vscode-lldb/adapter/codelldb"; + dap-python.enable = true; + dap-lldb = { + enable = true; + settings.codelldb_path = "${pkgs.vscode-extensions.vadimcn.vscode-lldb}/share/vscode/extensions/vadimcn.vscode-lldb/adapter/codelldb"; + }; }; }; } diff --git a/config/languages/default.nix b/config/languages/default.nix index d8daca9..181bb28 100755 --- a/config/languages/default.nix +++ b/config/languages/default.nix @@ -1,13 +1,12 @@ -{ +{...} @ inputs: { imports = [ - ./cmp.nix - ./conform.nix - ./dap.nix - ./lsp.nix - ./lspkind.nix - ./lspsaga.nix - ./luasnip.nix - ./treesitter.nix + (import ./lsp inputs) + + (import ./cmp.nix inputs) + (import ./conform.nix inputs) + (import ./dap.nix inputs) + (import ./luasnip.nix inputs) + (import ./treesitter.nix inputs) ]; plugins = { diff --git a/config/languages/lsp.nix b/config/languages/lsp.nix deleted file mode 100755 index 6ba4d68..0000000 --- a/config/languages/lsp.nix +++ /dev/null @@ -1,64 +0,0 @@ -{pkgs, ...}: { - plugins = { - lsp = { - enable = true; - capabilities = "offsetEncoding = 'utf-16'"; - servers = { - astro.enable = true; - clangd.enable = true; - csharp_ls.enable = true; - gopls.enable = true; - hls = { - enable = true; - installGhc = false; - package = pkgs.haskell-language-server.override {supportedGhcVersions = ["98" "910"];}; - }; - jdtls.enable = true; - lua_ls.enable = true; - nixd.enable = true; - pylsp = { - enable = true; - settings.configurationSources = "pycodestyle"; - settings = { - plugins = { - pyflakes.enabled = true; - mccabe.enabled = true; - pycodestyle.enabled = true; - pydocstyle.enabled = true; - yapf.enabled = true; - }; - }; - }; - sqls.enable = true; - zls.enable = true; - }; - }; - rustaceanvim.enable = true; - typescript-tools.enable = true; - }; - - extraConfigLua = '' - local _border = "rounded" - - 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=_border }; - virtual_text = true; - }; - - require('lspconfig.ui.windows').default_options = { - border = _border; - } - ''; -} diff --git a/config/languages/lsp/default.nix b/config/languages/lsp/default.nix new file mode 100644 index 0000000..fbe6848 --- /dev/null +++ b/config/languages/lsp/default.nix @@ -0,0 +1,86 @@ +{ + config, + lib, + namespace, + pkgs, + ... +} @ inputs: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.languages.lsp"; + cfg = getAttrByNamespace config base; +in { + imports = [ + (import ./lspkind.nix inputs) + (import ./lspsaga.nix inputs) + ]; + + options = mkOptionsWithNamespace base { + enable = mkEnableOption "lsp"; + }; + + config = mkIf cfg.enable { + plugins = { + lsp = { + enable = true; + capabilities = "offsetEncoding = 'utf-16'"; + servers = { + astro.enable = true; + clangd.enable = true; + csharp_ls.enable = true; + gopls.enable = true; + hls = { + enable = true; + installGhc = false; + package = pkgs.haskell-language-server.override {supportedGhcVersions = ["98" "910"];}; + }; + jdtls.enable = true; + lua_ls.enable = true; + nixd.enable = true; + pylsp = { + enable = true; + settings.configurationSources = "pycodestyle"; + settings = { + plugins = { + pyflakes.enabled = true; + mccabe.enabled = true; + pycodestyle.enabled = true; + pydocstyle.enabled = true; + yapf.enabled = true; + }; + }; + }; + sqls.enable = true; + zls.enable = true; + }; + }; + rustaceanvim.enable = true; + typescript-tools.enable = true; + }; + + extraConfigLua = '' + local _border = "rounded" + + 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=_border }; + virtual_text = true; + }; + + require('lspconfig.ui.windows').default_options = { + border = _border; + } + ''; + }; +} diff --git a/config/languages/lsp/lspkind.nix b/config/languages/lsp/lspkind.nix new file mode 100755 index 0000000..cdef21c --- /dev/null +++ b/config/languages/lsp/lspkind.nix @@ -0,0 +1,20 @@ +{ + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf; + inherit (lib.${namespace}) getAttrByNamespace; + cfg = getAttrByNamespace config "${namespace}.languages.lsp"; +in { + config = mkIf cfg.enable { + plugins.lspkind = { + enable = true; + extraOptions = { + maxwidth = 50; + ellipsis_char = "..."; + }; + }; + }; +} diff --git a/config/languages/lsp/lspsaga.nix b/config/languages/lsp/lspsaga.nix new file mode 100755 index 0000000..955e4dd --- /dev/null +++ b/config/languages/lsp/lspsaga.nix @@ -0,0 +1,155 @@ +{ + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf; + inherit (lib.${namespace}) getAttrByNamespace; + cfg = getAttrByNamespace config "${namespace}.languages.lsp"; +in { + config = mkIf cfg.enable { + 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 = "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; + }; + } + ]; + + plugins.lspsaga = { + enable = true; + beacon = { + enable = true; + }; + ui = { + border = "rounded"; + codeAction = "💡"; + }; + hover = { + openCmd = "!floorp"; + openLink = "gx"; + }; + diagnostic = { + borderFollow = true; + diagnosticOnlyCurrent = false; + showCodeAction = true; + }; + symbolInWinbar = { + enable = true; + }; + 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"; + winPosition = "right"; + keys = { + jump = "e"; + quit = "q"; + toggleOrJump = "o"; + }; + }; + scrollPreview = { + scrollDown = ""; + scrollUp = ""; + }; + }; + }; +} diff --git a/config/languages/lspkind.nix b/config/languages/lspkind.nix deleted file mode 100755 index ab4946a..0000000 --- a/config/languages/lspkind.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - plugins.lspkind = { - enable = true; - extraOptions = { - maxwidth = 50; - ellipsis_char = "..."; - }; - }; -} diff --git a/config/languages/lspsaga.nix b/config/languages/lspsaga.nix deleted file mode 100755 index 3e0ba31..0000000 --- a/config/languages/lspsaga.nix +++ /dev/null @@ -1,144 +0,0 @@ -{ - 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 = "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; - }; - } - ]; - - plugins.lspsaga = { - enable = true; - beacon = { - enable = true; - }; - ui = { - border = "rounded"; - codeAction = "💡"; - }; - hover = { - openCmd = "!floorp"; - openLink = "gx"; - }; - diagnostic = { - borderFollow = true; - diagnosticOnlyCurrent = false; - showCodeAction = true; - }; - symbolInWinbar = { - enable = true; - }; - 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"; - winPosition = "right"; - keys = { - jump = "e"; - quit = "q"; - toggleOrJump = "o"; - }; - }; - scrollPreview = { - scrollDown = ""; - scrollUp = ""; - }; - }; -} diff --git a/config/languages/luasnip.nix b/config/languages/luasnip.nix index 95ccf26..40b1e8f 100644 --- a/config/languages/luasnip.nix +++ b/config/languages/luasnip.nix @@ -1,123 +1,137 @@ { - plugins.luasnip = { - enable = true; - - # Basic LuaSnip settings - settings = { - history = true; - updateevents = "TextChanged,TextChangedI"; - enable_autosnippets = true; - }; + config, + lib, + namespace, + ... +}: let + inherit (builtins) readDir; + inherit (lib) mkIf mkEnableOption filter match attrNames concatStringsSep; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.languages.luasnip"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "luasnip"; }; - # Add keymaps for snippet navigation - keymaps = [ - { - mode = "i"; - key = ""; - action = "lua require('luasnip').expand_or_jump()"; - options.desc = "Snippets Expand or jump forward"; - } - { - mode = "i"; - key = ""; - action = "lua require('luasnip').jump(-1)"; - options.desc = "Snippets Jump backward"; - } - { - mode = "i"; - key = ""; - action = "lua require('luasnip').change_choice(1)"; - options.desc = "Snippets Cycle choices"; - } - ]; + config = mkIf cfg.enable { + plugins.luasnip = { + enable = true; - # Core snippet configuration and definitions - # Uses unified snippets config from ../snippets/default.nix for all LuaSnip setup. - # Use the unified snippets config for LuaSnip - extraConfigLua = let - snippetDir = ../languages/snippets; - snippetFiles = - builtins.filter - (name: builtins.match ".*\\.nix$" name != null) - (builtins.attrNames (builtins.readDir snippetDir)); - snippetConfigs = map (file: (import (snippetDir + "/${file}")).extraConfigLua) snippetFiles; - allSnippets = builtins.concatStringsSep "\n" snippetConfigs; - in '' - -- Get comment string for current filetype - local function get_comment_string() - local comment_string = vim.bo.commentstring - if not comment_string or comment_string == "" then - return "-- %s" -- Default to Lua style comments + # Basic LuaSnip settings + settings = { + history = true; + updateevents = "TextChanged,TextChangedI"; + enable_autosnippets = true; + }; + }; + + # Add keymaps for snippet navigation + keymaps = [ + { + mode = "i"; + key = ""; + action = "lua require('luasnip').expand_or_jump()"; + options.desc = "Snippets Expand or jump forward"; + } + { + mode = "i"; + key = ""; + action = "lua require('luasnip').jump(-1)"; + options.desc = "Snippets Jump backward"; + } + { + mode = "i"; + key = ""; + action = "lua require('luasnip').change_choice(1)"; + options.desc = "Snippets Cycle choices"; + } + ]; + + extraConfigLua = let + snippets = + readDir ../languages/snippets + |> attrNames + |> filter (name: match ".*\\.nix$" name != null) + |> map (name: ../languages/snippets + "/${name}") + |> map (file: (import file).extraConfigLua) + |> concatStringsSep "\n"; + in '' + -- Get comment string for current filetype + local function get_comment_string() + local comment_string = vim.bo.commentstring + if not comment_string or comment_string == "" then + return "-- %s" -- Default to Lua style comments + end + return comment_string end - return comment_string - end - -- Get visual selection - local function get_visual_selection() - local visual_modes = { - v = true, - V = true, - ["\22"] = true -- CTRL+V + -- Get visual selection + local function get_visual_selection() + local visual_modes = { + v = true, + V = true, + ["\22"] = true -- CTRL+V + } + + if not visual_modes[vim.api.nvim_get_mode().mode] then + return "" + end + + local _, ls, cs = unpack(vim.fn.getpos("v")) + local _, le, ce = unpack(vim.fn.getpos(".")) + + -- Normalize positions + if ls > le or (ls == le and cs > ce) then + ls, le = le, ls + cs, ce = ce, cs + end + + local lines = vim.api.nvim_buf_get_lines(0, ls - 1, le, false) + if #lines == 0 then + return "" + end + + -- Adjust for partial lines + lines[1] = string.sub(lines[1], cs, -1) + if #lines > 1 then + lines[#lines] = string.sub(lines[#lines], 1, ce) + else + lines[1] = string.sub(lines[1], 1, ce - cs + 1) + end + + return table.concat(lines, "\n") + end + + -- Format date in various ways + local function date_format(format) + return os.date(format) + end + + -- Capture groups from regex matches + local function capture_match(match, group) + if match and #match > group then + return match[group + 1] + end + return "" + end + + -- Check if the current buffer is a test file + local function is_test_file() + local filename = vim.fn.expand("%:t") + return string.match(filename, "[tT]est") ~= nil or string.match(filename, "_test") ~= nil or string.match(filename, "spec") ~= nil + end + + -- Make these functions available to snippets + _G.snippet_utils = { + get_comment_string = get_comment_string, + get_visual_selection = get_visual_selection, + date_format = date_format, + capture_match = capture_match, + is_test_file = is_test_file } - if not visual_modes[vim.api.nvim_get_mode().mode] then - return "" - end - - local _, ls, cs = unpack(vim.fn.getpos("v")) - local _, le, ce = unpack(vim.fn.getpos(".")) - - -- Normalize positions - if ls > le or (ls == le and cs > ce) then - ls, le = le, ls - cs, ce = ce, cs - end - - local lines = vim.api.nvim_buf_get_lines(0, ls - 1, le, false) - if #lines == 0 then - return "" - end - - -- Adjust for partial lines - lines[1] = string.sub(lines[1], cs, -1) - if #lines > 1 then - lines[#lines] = string.sub(lines[#lines], 1, ce) - else - lines[1] = string.sub(lines[1], 1, ce - cs + 1) - end - - return table.concat(lines, "\n") - end - - -- Format date in various ways - local function date_format(format) - return os.date(format) - end - - -- Capture groups from regex matches - local function capture_match(match, group) - if match and #match > group then - return match[group + 1] - end - return "" - end - - -- Check if the current buffer is a test file - local function is_test_file() - local filename = vim.fn.expand("%:t") - return string.match(filename, "[tT]est") ~= nil or string.match(filename, "_test") ~= nil or string.match(filename, "spec") ~= nil - end - - -- Make these functions available to snippets - _G.snippet_utils = { - get_comment_string = get_comment_string, - get_visual_selection = get_visual_selection, - date_format = date_format, - capture_match = capture_match, - is_test_file = is_test_file - } - - ${allSnippets} - ''; + ${snippets} + ''; + }; } diff --git a/config/languages/treesitter.nix b/config/languages/treesitter.nix index 884d88b..de66689 100755 --- a/config/languages/treesitter.nix +++ b/config/languages/treesitter.nix @@ -1,9 +1,25 @@ { - plugins.treesitter = { - enable = true; - folding = true; - settings.highlight = { + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.languages.treesitter"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "treesitter"; + }; + + config = mkIf cfg.enable { + plugins.treesitter = { enable = true; + folding = true; + settings.highlight = { + enable = true; + }; }; }; } diff --git a/config/navigation/default.nix b/config/navigation/default.nix index 0510d2a..79feb3b 100755 --- a/config/navigation/default.nix +++ b/config/navigation/default.nix @@ -1,7 +1,7 @@ -{ +{...} @ inputs: { imports = [ - ./harpoon.nix - ./nvim-tree.nix - ./telescope.nix + (import ./harpoon.nix inputs) + (import ./nvim-tree.nix inputs) + (import ./telescope.nix inputs) ]; } diff --git a/config/navigation/harpoon.nix b/config/navigation/harpoon.nix index 49c17b2..d174950 100755 --- a/config/navigation/harpoon.nix +++ b/config/navigation/harpoon.nix @@ -1,44 +1,60 @@ { - keymaps = [ - { - mode = "n"; - key = "a"; - action.__raw = "function() require'harpoon':list():add() end"; - } - { - mode = "n"; - key = ""; - action.__raw = "function() require'harpoon'.ui:toggle_quick_menu(require'harpoon':list()) end"; - } - { - mode = "n"; - key = ""; - action.__raw = "function() require'harpoon':list():select(1) end"; - } - { - mode = "n"; - key = ""; - action.__raw = "function() require'harpoon':list():select(2) end"; - } - { - mode = "n"; - key = ""; - action.__raw = "function() require'harpoon':list():select(3) end"; - } - { - mode = "n"; - key = ""; - action.__raw = "function() require'harpoon':list():select(4) end"; - } - ]; - - plugins.harpoon = { - enable = true; - enableTelescope = true; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.navigation.harpoon"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "harpoon"; }; - extraConfigLua = '' - local harpoon = require("harpoon") - harpoon:setup({ settings = { save_on_toggle = true }}) - ''; + config = mkIf cfg.enable { + keymaps = [ + { + mode = "n"; + key = "a"; + action.__raw = "function() require'harpoon':list():add() end"; + } + { + mode = "n"; + key = ""; + action.__raw = "function() require'harpoon'.ui:toggle_quick_menu(require'harpoon':list()) end"; + } + { + mode = "n"; + key = ""; + action.__raw = "function() require'harpoon':list():select(1) end"; + } + { + mode = "n"; + key = ""; + action.__raw = "function() require'harpoon':list():select(2) end"; + } + { + mode = "n"; + key = ""; + action.__raw = "function() require'harpoon':list():select(3) end"; + } + { + mode = "n"; + key = ""; + action.__raw = "function() require'harpoon':list():select(4) end"; + } + ]; + + plugins.harpoon = { + enable = true; + enableTelescope = true; + }; + + extraConfigLua = '' + local harpoon = require("harpoon") + harpoon:setup({ settings = { save_on_toggle = true }}) + ''; + }; } diff --git a/config/navigation/nvim-tree.nix b/config/navigation/nvim-tree.nix index 26f1b31..13b1b01 100755 --- a/config/navigation/nvim-tree.nix +++ b/config/navigation/nvim-tree.nix @@ -1,75 +1,91 @@ { - keymaps = [ - { - mode = "n"; - key = "pv"; - action = "NvimTreeToggle"; - options.desc = "Toggle NvimTree"; - } - ]; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.navigation.nvim-tree"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "nvim-tree"; + }; - plugins.web-devicons.enable = true; + config = mkIf cfg.enable { + keymaps = [ + { + mode = "n"; + key = "pv"; + action = "NvimTreeToggle"; + options.desc = "Toggle NvimTree"; + } + ]; - plugins.nvim-tree = { - enable = true; + plugins.web-devicons.enable = true; - disableNetrw = true; - hijackNetrw = true; - hijackCursor = true; - hijackUnnamedBufferWhenOpening = true; - syncRootWithCwd = true; - - updateFocusedFile.enable = true; - - sortBy = "case_sensitive"; - - filters = { - custom = ["__pycache__"]; - exclude = []; - }; - - git = { + plugins.nvim-tree = { enable = true; - ignore = true; - }; - view = { - side = "right"; - width = 60; - number = true; - relativenumber = true; - preserveWindowProportions = true; - }; + disableNetrw = true; + hijackNetrw = true; + hijackCursor = true; + hijackUnnamedBufferWhenOpening = true; + syncRootWithCwd = true; - renderer = { - rootFolderLabel = false; - indentWidth = 2; - highlightGit = true; - indentMarkers.enable = true; + updateFocusedFile.enable = true; - groupEmpty = true; + sortBy = "case_sensitive"; - icons.glyphs = { - default = "󰈚"; - symlink = ""; - folder = { - default = ""; - empty = ""; - emptyOpen = ""; - open = ""; - symlink = ""; - symlinkOpen = ""; - arrowOpen = ""; - arrowClosed = ""; - }; - git = { - unstaged = "✗"; - staged = "✓"; - unmerged = ""; - renamed = "➜"; - untracked = "★"; - deleted = ""; - ignored = "◌"; + filters = { + custom = ["__pycache__"]; + exclude = []; + }; + + git = { + enable = true; + ignore = true; + }; + + view = { + side = "right"; + width = 60; + number = true; + relativenumber = true; + preserveWindowProportions = true; + }; + + renderer = { + rootFolderLabel = false; + indentWidth = 2; + highlightGit = true; + indentMarkers.enable = true; + + groupEmpty = true; + + icons.glyphs = { + default = "󰈚"; + symlink = ""; + folder = { + default = ""; + empty = ""; + emptyOpen = ""; + open = ""; + symlink = ""; + symlinkOpen = ""; + arrowOpen = ""; + arrowClosed = ""; + }; + git = { + unstaged = "✗"; + staged = "✓"; + unmerged = ""; + renamed = "➜"; + untracked = "★"; + deleted = ""; + ignored = "◌"; + }; }; }; }; diff --git a/config/navigation/telescope.nix b/config/navigation/telescope.nix index 3893c44..52edaac 100755 --- a/config/navigation/telescope.nix +++ b/config/navigation/telescope.nix @@ -1,91 +1,107 @@ { - keymaps = [ - { - mode = "n"; - key = "pws"; - action.__raw = '' - function() - local word = vim.fn.expand("") - require('telescope.builtin').grep_string({ search = word }) - end - ''; - options.desc = "Telescope Live grep word under cursor"; - } - { - mode = "n"; - key = "pWs"; - action.__raw = '' - function() - local word = vim.fn.expand("cWORD") - require('telescope.builtin').grep_string({ search = word }) - end - ''; - options.desc = "Telecope Live grep WORD under cursor"; - } - ]; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.navigation.telescope"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "telescope"; + }; - plugins.telescope = { - keymaps = { - "pf" = { - action = "find_files"; - options.desc = "Telescope Find project files"; - }; - "pa" = { - action = "find_files follow=true no_ignore=true hidden=true"; - options.desc = "Telescope Find all files"; - }; - "pz" = { - action = "current_buffer_fuzzy_find"; - options.desc = "Telescope Find in buffer"; - }; - "ps" = { - action = "live_grep"; - options.desc = "Telescope Live grep"; + config = mkIf cfg.enable { + keymaps = [ + { + mode = "n"; + key = "pws"; + action.__raw = '' + function() + local word = vim.fn.expand("") + require('telescope.builtin').grep_string({ search = word }) + end + ''; + options.desc = "Telescope Live grep word under cursor"; + } + { + mode = "n"; + key = "pWs"; + action.__raw = '' + function() + local word = vim.fn.expand("cWORD") + require('telescope.builtin').grep_string({ search = word }) + end + ''; + options.desc = "Telecope Live grep WORD under cursor"; + } + ]; + + plugins.telescope = { + keymaps = { + "pf" = { + action = "find_files"; + options.desc = "Telescope Find project files"; + }; + "pa" = { + action = "find_files follow=true no_ignore=true hidden=true"; + options.desc = "Telescope Find all files"; + }; + "pz" = { + action = "current_buffer_fuzzy_find"; + options.desc = "Telescope Find in buffer"; + }; + "ps" = { + action = "live_grep"; + options.desc = "Telescope Live grep"; + }; + + "ws" = { + action = "lsp_document_symbols ignore_symbols='variable'"; + options.desc = "Telescope LSP Document symbols"; + }; + + "tt" = { + action = "diagnostics"; + options.desc = "Telescope Diagnostics"; + }; + "tf" = { + action = "diagnostics bufnr=0"; + options.desc = "Telescope Diagnostics in buffer"; + }; + + ":" = { + action = "command_history"; + options.desc = "Telescope Command history"; + }; }; - "ws" = { - action = "lsp_document_symbols ignore_symbols='variable'"; - options.desc = "Telescope LSP Document symbols"; + enable = true; + + extensions = { + fzf-native.enable = true; + ui-select.settings.specific_opts.codeactions = true; + undo.enable = true; }; - "tt" = { - action = "diagnostics"; - options.desc = "Telescope Diagnostics"; - }; - "tf" = { - action = "diagnostics bufnr=0"; - options.desc = "Telescope Diagnostics in buffer"; - }; + settings = { + defaults = { + prompt_prefix = "  "; + selection_caret = " "; + entry_prefix = " "; - ":" = { - action = "command_history"; - options.desc = "Telescope Command history"; - }; - }; + sorting_strategy = "ascending"; + layout_config = { + horizontal = { + prompt_position = "top"; + preview_width = 0.65; + }; - enable = true; - - extensions = { - fzf-native.enable = true; - ui-select.settings.specific_opts.codeactions = true; - undo.enable = true; - }; - - settings = { - defaults = { - prompt_prefix = "  "; - selection_caret = " "; - entry_prefix = " "; - - sorting_strategy = "ascending"; - layout_config = { - horizontal = { - prompt_position = "top"; - preview_width = 0.65; + width = 0.75; + height = 0.80; }; - - width = 0.75; - height = 0.80; }; }; }; diff --git a/config/ui/alpha.nix b/config/ui/alpha.nix index 9d8e7ad..6e96013 100755 --- a/config/ui/alpha.nix +++ b/config/ui/alpha.nix @@ -1,74 +1,94 @@ { - plugins.alpha = { - enable = true; - theme = null; - layout = let - mkPadding = val: { - type = "padding"; - inherit val; - }; - mkButton = label: shortcut: command: { - type = "button"; - val = label; - on_press.__raw = '' - function() - local key = vim.api.nvim_replace_termcodes("${shortcut}", true, false, true) - vim.api.nvim_feedkeys(key, "n", false) - end - ''; - opts = { - keymap = [ - "n" - shortcut - command - { - noremap = true; - silent = true; - nowait = true; - } - ]; - shortcut = shortcut; - position = "center"; - cursor = 3; - width = 38; - align_shortcut = "right"; - hl_shortcut = "Keyword"; - }; - }; - in [ - (mkPadding 4) - { - opts = { - hl = "AlphaHeader"; - position = "center"; - }; - type = "text"; - val = [ - "▓██ ██▓ █ ██ ███▄ ▄███▓▓█████ ██▒ █▓ ██▓ ███▄ ▄███▓" - " ▒██ ██▒ ██ ▓██▒▓██▒▀█▀ ██▒▓█ ▀▓██░ █▒▓██▒▓██▒▀█▀ ██▒" - " ▒██ ██░▓██ ▒██░▓██ ▓██░▒███ ▓██ █▒░▒██▒▓██ ▓██░" - " ░ ▐██▓░▓▓█ ░██░▒██ ▒██ ▒▓█ ▄ ▒██ █░░░██░▒██ ▒██ " - " ░ ██▒▓░▒▒█████▓ ▒██▒ ░██▒░▒████▒ ▒▀█░ ░██░▒██▒ ░██▒" - " ██▒▒▒ ░▒▓▒ ▒ ▒ ░ ▒░ ░ ░░░ ▒░ ░ ░ ▐░ ░▓ ░ ▒░ ░ ░" - " ▓██ ░▒░ ░░▒░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░░ ▒ ░░ ░ ░" - " ▒ ▒ ░░ ░░░ ░ ░ ░ ░ ░ ░░ ▒ ░░ ░ " - " ░ ░ ░ ░ ░ ░ ░ ░ ░ " - " " - " git@github.com:c4patino " + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.ui.alpha"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "alpha"; + }; + + config = mkIf cfg.enable { + plugins = { + persistence.enable = true; + + alpha = { + enable = true; + theme = null; + layout = let + mkPadding = val: { + type = "padding"; + inherit val; + }; + mkButton = label: shortcut: command: { + type = "button"; + val = label; + on_press.__raw = '' + function() + local key = vim.api.nvim_replace_termcodes("${shortcut}", true, false, true) + vim.api.nvim_feedkeys(key, "n", false) + end + ''; + opts = { + keymap = [ + "n" + shortcut + command + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = shortcut; + position = "center"; + cursor = 3; + width = 38; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + }; + in [ + (mkPadding 4) + { + opts = { + hl = "AlphaHeader"; + position = "center"; + }; + type = "text"; + val = [ + "▓██ ██▓ █ ██ ███▄ ▄███▓▓█████ ██▒ █▓ ██▓ ███▄ ▄███▓" + " ▒██ ██▒ ██ ▓██▒▓██▒▀█▀ ██▒▓█ ▀▓██░ █▒▓██▒▓██▒▀█▀ ██▒" + " ▒██ ██░▓██ ▒██░▓██ ▓██░▒███ ▓██ █▒░▒██▒▓██ ▓██░" + " ░ ▐██▓░▓▓█ ░██░▒██ ▒██ ▒▓█ ▄ ▒██ █░░░██░▒██ ▒██ " + " ░ ██▒▓░▒▒█████▓ ▒██▒ ░██▒░▒████▒ ▒▀█░ ░██░▒██▒ ░██▒" + " ██▒▒▒ ░▒▓▒ ▒ ▒ ░ ▒░ ░ ░░░ ▒░ ░ ░ ▐░ ░▓ ░ ▒░ ░ ░" + " ▓██ ░▒░ ░░▒░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░░ ▒ ░░ ░ ░" + " ▒ ▒ ░░ ░░░ ░ ░ ░ ░ ░ ░░ ▒ ░░ ░ " + " ░ ░ ░ ░ ░ ░ ░ ░ ░ " + " " + " git@github.com:c4patino " + ]; + } + (mkPadding 2) + (mkButton " Find File" "f" "Telescope find_files") + (mkPadding 1) + (mkButton " New File" "n" "ene startinsert") + (mkPadding 1) + (mkButton "󰈚 Recent Files" "r" "Telescope oldfiles") + (mkPadding 1) + (mkButton "󰈭 Find Word" "g" "Telescope live_grep") + (mkPadding 1) + (mkButton " Restore Session" "s" "lua require('persistence').load()") + (mkPadding 1) + (mkButton " Quit Neovim" "q" "qa") ]; - } - (mkPadding 2) - (mkButton " Find File" "f" "Telescope find_files") - (mkPadding 1) - (mkButton " New File" "n" "ene startinsert") - (mkPadding 1) - (mkButton "󰈚 Recent Files" "r" "Telescope oldfiles") - (mkPadding 1) - (mkButton "󰈭 Find Word" "g" "Telescope live_grep") - (mkPadding 1) - (mkButton " Restore Session" "s" "lua require('persistence').load()") - (mkPadding 1) - (mkButton " Quit Neovim" "q" "qa") - ]; + }; + }; }; } diff --git a/config/ui/default.nix b/config/ui/default.nix index 62c2e65..24ee88e 100755 --- a/config/ui/default.nix +++ b/config/ui/default.nix @@ -1,11 +1,11 @@ -{pkgs, ...}: { +{pkgs, ...} @ inputs: { imports = [ - ./alpha.nix - ./fidget.nix - ./indent-blankline.nix - ./lualine.nix - ./noice.nix - ./nvim-notify.nix + (import ./alpha.nix inputs) + (import ./fidget.nix inputs) + (import ./indent-blankline.nix inputs) + (import ./lualine.nix inputs) + (import ./noice.nix inputs) + (import ./nvim-notify.nix inputs) ]; colorschemes.tokyonight = { diff --git a/config/ui/fidget.nix b/config/ui/fidget.nix index 5fa9899..043951a 100755 --- a/config/ui/fidget.nix +++ b/config/ui/fidget.nix @@ -1,96 +1,112 @@ { - plugins.fidget = { - enable = true; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.ui.fidget"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "fidget"; + }; - settings = { - logger = { - level = "warn"; # “off”, “error”, “warn”, “info”, “debug”, “trace” - float_precision = 0.01; # Limit the number of decimals displayed for floats - }; - progress = { - poll_rate = 0; # How and when to poll for progress messages - suppress_on_insert = true; # Suppress new messages while in insert mode - ignore_done_already = false; # Ignore new tasks that are already complete - ignore_empty_message = false; # Ignore new tasks that don't contain a message - # Clear notification group when LSP server detaches - clear_on_detach = '' - function(client_id) - local client = vim.lsp.get_client_by_id(client_id) - return client and client.name or nil - end - ''; - # How to get a progress message's notification group key - notification_group = '' - function(msg) return msg.lsp_client.name end - ''; - ignore = []; # List of LSP servers to ignore - lsp = { - progress_ringbuf_size = 0; # Configure the nvim's LSP progress ring buffer size - }; - display = { - render_limit = 16; # How many LSP messages to show at once - done_ttl = 3; # How long a message should persist after completion - done_icon = "✔"; # Icon shown when all LSP progress tasks are complete - done_style = "Constant"; # Highlight group for completed LSP tasks - progress_ttl.__raw = "math.huge"; # How long a message should persist when in progress - progress_icon = { - pattern = "dots"; - period = 1; - }; # Icon shown when LSP progress tasks are in progress - progress_style = "WarningMsg"; # Highlight group for in-progress LSP tasks - group_style = "Title"; # Highlight group for group name (LSP server name) - icon_style = "Question"; # Highlight group for group icons - priority = 30; # Ordering priority for LSP notification group - skip_history = true; # Whether progress notifications should be omitted from history - format_message = '' - require ("fidget.progress.display").default_format_message - ''; # How to format a progress message - format_annote = '' - function (msg) return msg.title end - ''; # How to format a progress annotation - format_group_name = '' - function (group) return tostring (group) end - ''; # How to format a progress notification group's name - overrides = { - rust_analyzer = { - name = "rust-analyzer"; - }; - }; # Override options from the default notification config - }; - }; - notification = { - poll_rate = 10; # How frequently to update and render notifications - filter = "info"; # “off”, “error”, “warn”, “info”, “debug”, “trace” - history_size = 128; # Number of removed messages to retain in history - override_vim_notify = true; + config = mkIf cfg.enable { + plugins.fidget = { + enable = true; - redirect.__raw = '' - function(msg, level, opts) - if opts and opts.on_open then - return require("fidget.integration.nvim-notify").delegate(msg, level, opts) + settings = { + logger = { + level = "warn"; # “off”, “error”, “warn”, “info”, “debug”, “trace” + float_precision = 0.01; # Limit the number of decimals displayed for floats + }; + progress = { + poll_rate = 0; # How and when to poll for progress messages + suppress_on_insert = true; # Suppress new messages while in insert mode + ignore_done_already = false; # Ignore new tasks that are already complete + ignore_empty_message = false; # Ignore new tasks that don't contain a message + # Clear notification group when LSP server detaches + clear_on_detach = '' + function(client_id) + local client = vim.lsp.get_client_by_id(client_id) + return client and client.name or nil end - end - ''; - - configs.default.__raw = "require('fidget.notification').default_config"; - - window = { - normal_hl = "Comment"; - winblend = 0; - border = "none"; # none, single, double, rounded, solid, shadow - zindex = 45; - max_width = 0; - max_height = 0; - x_padding = 1; - y_padding = 0; - align = "bottom"; - relative = "editor"; + ''; + # How to get a progress message's notification group key + notification_group = '' + function(msg) return msg.lsp_client.name end + ''; + ignore = []; # List of LSP servers to ignore + lsp = { + progress_ringbuf_size = 0; # Configure the nvim's LSP progress ring buffer size + }; + display = { + render_limit = 16; # How many LSP messages to show at once + done_ttl = 3; # How long a message should persist after completion + done_icon = "✔"; # Icon shown when all LSP progress tasks are complete + done_style = "Constant"; # Highlight group for completed LSP tasks + progress_ttl.__raw = "math.huge"; # How long a message should persist when in progress + progress_icon = { + pattern = "dots"; + period = 1; + }; # Icon shown when LSP progress tasks are in progress + progress_style = "WarningMsg"; # Highlight group for in-progress LSP tasks + group_style = "Title"; # Highlight group for group name (LSP server name) + icon_style = "Question"; # Highlight group for group icons + priority = 30; # Ordering priority for LSP notification group + skip_history = true; # Whether progress notifications should be omitted from history + format_message = '' + require ("fidget.progress.display").default_format_message + ''; # How to format a progress message + format_annote = '' + function (msg) return msg.title end + ''; # How to format a progress annotation + format_group_name = '' + function (group) return tostring (group) end + ''; # How to format a progress notification group's name + overrides = { + rust_analyzer = { + name = "rust-analyzer"; + }; + }; # Override options from the default notification config + }; }; - view = { - stack_upwards = true; # Display notification items from bottom to top - icon_separator = " "; # Separator between group name and icon - group_separator = "---"; # Separator between notification groups - group_separator_hl = "Comment"; # Highlight group used for group separator + notification = { + poll_rate = 10; # How frequently to update and render notifications + filter = "info"; # “off”, “error”, “warn”, “info”, “debug”, “trace” + history_size = 128; # Number of removed messages to retain in history + override_vim_notify = true; + + redirect.__raw = '' + 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.__raw = "require('fidget.notification').default_config"; + + window = { + normal_hl = "Comment"; + winblend = 0; + border = "none"; # none, single, double, rounded, solid, shadow + zindex = 45; + max_width = 0; + max_height = 0; + x_padding = 1; + y_padding = 0; + align = "bottom"; + relative = "editor"; + }; + view = { + stack_upwards = true; # Display notification items from bottom to top + icon_separator = " "; # Separator between group name and icon + group_separator = "---"; # Separator between notification groups + group_separator_hl = "Comment"; # Highlight group used for group separator + }; }; }; }; diff --git a/config/ui/indent-blankline.nix b/config/ui/indent-blankline.nix index 0760362..a7ca3c2 100755 --- a/config/ui/indent-blankline.nix +++ b/config/ui/indent-blankline.nix @@ -1,6 +1,22 @@ { - plugins.indent-blankline = { - enable = true; - settings.scope.enabled = false; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.ui.indent-blankline"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "indent-blankline"; + }; + + config = mkIf cfg.enable { + plugins.indent-blankline = { + enable = true; + settings.scope.enabled = false; + }; }; } diff --git a/config/ui/lualine.nix b/config/ui/lualine.nix index bc37d66..773db26 100755 --- a/config/ui/lualine.nix +++ b/config/ui/lualine.nix @@ -1,50 +1,66 @@ { - plugins.lualine = { - enable = true; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.ui.lualine"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "lualine"; + }; - settings = { - options = { - globalstatus = true; - always_divide_middle = true; - theme = "auto"; - ignore_focus = ["nvim-tree"]; + config = mkIf cfg.enable { + plugins.lualine = { + enable = true; - component_separators = { - left = "|"; - right = "|"; + settings = { + options = { + globalstatus = true; + always_divide_middle = true; + theme = "auto"; + ignore_focus = ["nvim-tree"]; + + component_separators = { + left = "|"; + right = "|"; + }; }; - }; - extensions = ["fzf"]; + extensions = ["fzf"]; - sections = { - lualine_a = ["mode"]; - lualine_b = [ - { - __unkeyed = "branch"; - icon = ""; - icons_enabled = true; - } - "diff" - "diagnostics" - ]; - lualine_c = [ - "filename" - { - __raw = '' - function() - local rec = vim.fn.reg_recording() - if rec ~= "" then - return " @" .. rec - end - return "" - end - ''; - } - ]; - lualine_x = ["filetype"]; - lualine_y = ["location"]; - lualine_z = [''" " .. os.date("%R")'']; + sections = { + lualine_a = ["mode"]; + lualine_b = [ + { + __unkeyed = "branch"; + icon = ""; + icons_enabled = true; + } + "diff" + "diagnostics" + ]; + lualine_c = [ + "filename" + { + __raw = '' + function() + local rec = vim.fn.reg_recording() + if rec ~= "" then + return " @" .. rec + end + return "" + end + ''; + } + ]; + lualine_x = ["filetype"]; + lualine_y = ["location"]; + lualine_z = [''" " .. os.date("%R")'']; + }; }; }; }; diff --git a/config/ui/noice.nix b/config/ui/noice.nix index 5443b93..dc7029e 100755 --- a/config/ui/noice.nix +++ b/config/ui/noice.nix @@ -1,33 +1,49 @@ { - plugins.noice = { - enable = true; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.ui.noice"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "noice"; + }; - settings = { - notify.enabled = false; - messages.enabled = true; + config = mkIf cfg.enable { + plugins.noice = { + enable = true; - lsp = { - message.enabled = true; - progress = { - enabled = false; - view = "mini"; + settings = { + notify.enabled = false; + messages.enabled = true; + + 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"; + popupmenu = { + enabled = true; + backend = "nui"; }; - 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"; + 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/nvim-notify.nix b/config/ui/nvim-notify.nix index 8019ee7..b158289 100755 --- a/config/ui/nvim-notify.nix +++ b/config/ui/nvim-notify.nix @@ -1,47 +1,63 @@ { - keymaps = [ - { - mode = "n"; - key = "un"; - action = '' - lua require("notify").dismiss({ silent = true, pending = true }) - ''; - options = {desc = "Dismiss All Notifications";}; - } - ]; - - plugins.notify = { - enable = true; - - settings = { - background_color = "#000000"; - fps = 60; - render = "default"; - timeout = 500; - top_down = false; - }; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.ui.nvim-notify"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "nvim-notify"; }; - extraConfigLua = '' - local notify = require("notify") - local filtered_message = { "No information available" } + config = mkIf cfg.enable { + keymaps = [ + { + mode = "n"; + key = "un"; + action = '' + lua require("notify").dismiss({ silent = true, pending = true }) + ''; + options = {desc = "Dismiss All Notifications";}; + } + ]; - -- 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 {}) + plugins.notify = { + enable = true; - for _, msg in ipairs(filtered_message) do - if message == msg then - return - end - end - return notify(message, level, merged_opts) - end - ''; + settings = { + background_color = "#000000"; + fps = 60; + render = "default"; + timeout = 500; + top_down = false; + }; + }; + + extraConfigLua = '' + local notify = require("notify") + local filtered_message = { "No information available" } + + -- Override notify function to filter out messages + ---@diagnostic disable-next-line: duplicate-set-field + vim.notify = function(message, level, opts) + local merged_opts = vim.tbl_extend("force", { + on_open = function(win) + local buf = vim.api.nvim_win_get_buf(win) + vim.api.nvim_buf_set_option(buf, "filetype", "markdown") + end, + }, opts or {}) + + for _, msg in ipairs(filtered_message) do + if message == msg then + return + end + end + return notify(message, level, merged_opts) + end + ''; + }; } diff --git a/config/utils/default.nix b/config/utils/default.nix index 7f542f1..a62be74 100755 --- a/config/utils/default.nix +++ b/config/utils/default.nix @@ -1,16 +1,12 @@ -{ +{...} @ inputs: { imports = [ - ./lazygit.nix - ./obsidian.nix - ./todo-comments.nix - ./toggleterm.nix - ./undotree.nix - ./vimtex.nix - ./zenmode.nix + (import ./lazygit.nix inputs) + (import ./obsidian.nix inputs) + (import ./todo-comments.nix inputs) + (import ./toggleterm.nix inputs) + (import ./undotree.nix inputs) + (import ./vimtex.nix inputs) + (import ./which-key.nix inputs) + (import ./zenmode.nix inputs) ]; - - plugins = { - persistence.enable = true; - which-key.enable = true; - }; } diff --git a/config/utils/lazygit.nix b/config/utils/lazygit.nix index 2d072ee..c168824 100755 --- a/config/utils/lazygit.nix +++ b/config/utils/lazygit.nix @@ -1,14 +1,30 @@ { - keymaps = [ - { - mode = "n"; - key = "gg"; - action = "LazyGit"; - options.desc = "LazyGit Toggle window"; - } - ]; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.utils.lazygit"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "lazygit"; + }; - plugins = { - lazygit.enable = true; + config = mkIf cfg.enable { + keymaps = [ + { + mode = "n"; + key = "gg"; + action = "LazyGit"; + options.desc = "LazyGit Toggle window"; + } + ]; + + plugins = { + lazygit.enable = true; + }; }; } diff --git a/config/utils/obsidian.nix b/config/utils/obsidian.nix index 2b72551..2dea408 100644 --- a/config/utils/obsidian.nix +++ b/config/utils/obsidian.nix @@ -1,14 +1,30 @@ { - plugins = { - obsidian = { - enable = true; - settings = { - workspaces = [ - { - name = "obsidian"; - path = "~/Documents/obsidian"; - } - ]; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.utils.obsidian"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "obsidian"; + }; + + config = mkIf cfg.enable { + plugins = { + obsidian = { + enable = true; + settings = { + workspaces = [ + { + name = "obsidian"; + path = "~/Documents/obsidian"; + } + ]; + }; }; }; }; diff --git a/config/utils/todo-comments.nix b/config/utils/todo-comments.nix index 3e526a7..97d139d 100755 --- a/config/utils/todo-comments.nix +++ b/config/utils/todo-comments.nix @@ -1,14 +1,30 @@ { - keymaps = [ - { - mode = "n"; - key = "tc"; - action = "TodoTelescope"; - options.desc = "Telescope Find todo comments"; - } - ]; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.utils.todo-comments"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "todo-comments"; + }; - plugins = { - todo-comments.enable = true; + config = mkIf cfg.enable { + keymaps = [ + { + mode = "n"; + key = "tc"; + action = "TodoTelescope"; + options.desc = "Telescope Find todo comments"; + } + ]; + + plugins = { + todo-comments.enable = true; + }; }; } diff --git a/config/utils/toggleterm.nix b/config/utils/toggleterm.nix index 0f71e8d..54aa39c 100755 --- a/config/utils/toggleterm.nix +++ b/config/utils/toggleterm.nix @@ -1,14 +1,30 @@ { - plugins.toggleterm = { - enable = true; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.utils.toggleterm"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "toggleterm"; + }; - settings = { - open_mapping = "[[]]"; + config = mkIf cfg.enable { + plugins.toggleterm = { + enable = true; - direction = "float"; + settings = { + open_mapping = "[[]]"; - float_opts.border = "curved"; - winbar.enabled = true; + direction = "float"; + + float_opts.border = "curved"; + winbar.enabled = true; + }; }; }; } diff --git a/config/utils/undotree.nix b/config/utils/undotree.nix index c242fae..357596c 100755 --- a/config/utils/undotree.nix +++ b/config/utils/undotree.nix @@ -1,20 +1,36 @@ { - keymaps = [ - { - mode = "n"; - key = "u"; - action = "UndotreeToggle"; - options.desc = "Undotree Toggle window"; - } - ]; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.utils.undotree"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "undotree"; + }; - plugins.undotree = { - enable = true; + config = mkIf cfg.enable { + keymaps = [ + { + mode = "n"; + key = "u"; + action = "UndotreeToggle"; + options.desc = "Undotree Toggle window"; + } + ]; - settings = { - WindowLayout = 4; - DiffpaneHeight = 15; - SplitWidth = 40; + plugins.undotree = { + enable = true; + + settings = { + WindowLayout = 4; + DiffpaneHeight = 15; + SplitWidth = 40; + }; }; }; } diff --git a/config/utils/vimtex.nix b/config/utils/vimtex.nix index 39fcde9..23b5aaa 100755 --- a/config/utils/vimtex.nix +++ b/config/utils/vimtex.nix @@ -1,10 +1,27 @@ -{pkgs, ...}: { - plugins.vimtex = { - enable = true; - texlivePackage = pkgs.texliveFull; +{ + config, + lib, + namespace, + pkgs, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.utils.vimtex"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "vimtex"; + }; - settings = { - view_method = "zathura"; + config = mkIf cfg.enable { + plugins.vimtex = { + enable = true; + texlivePackage = pkgs.texliveFull; + + settings = { + view_method = "zathura"; + }; }; }; } diff --git a/config/utils/which-key.nix b/config/utils/which-key.nix new file mode 100644 index 0000000..6e8c342 --- /dev/null +++ b/config/utils/which-key.nix @@ -0,0 +1,21 @@ +{ + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.utils.which-key"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "which-key"; + }; + + config = mkIf cfg.enable { + plugins = { + which-key.enable = true; + }; + }; +} diff --git a/config/utils/zenmode.nix b/config/utils/zenmode.nix index aa9618c..6d30b91 100755 --- a/config/utils/zenmode.nix +++ b/config/utils/zenmode.nix @@ -1,14 +1,30 @@ { - keymaps = [ - { - mode = "n"; - key = "zz"; - action = "ZenMode"; - } - ]; + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace; + base = "${namespace}.utils.zenmode"; + cfg = getAttrByNamespace config base; +in { + options = mkOptionsWithNamespace base { + enable = mkEnableOption "zenmode"; + }; - plugins.zen-mode = { - enable = true; - settings.window.width = 150; + config = mkIf cfg.enable { + keymaps = [ + { + mode = "n"; + key = "zz"; + action = "ZenMode"; + } + ]; + + plugins.zen-mode = { + enable = true; + settings.window.width = 150; + }; }; } diff --git a/flake.nix b/flake.nix index b7793e0..499f361 100755 --- a/flake.nix +++ b/flake.nix @@ -19,22 +19,6 @@ system: let namespace = "yumevim"; - pkgs = import nixpkgs {inherit system;}; - mergedLib = pkgs.lib.extend (final: prev: {${namespace} = import ./lib {lib = pkgs.lib;};}); - - nixvimLib = nixvim.lib.${system}; - nixvim' = nixvim.legacyPackages.${system}; - nixvimModule = { - inherit pkgs; - module = import ./config; - extraSpecialArgs = { - lib = mergedLib.extend nixvim.lib.overlay; - namespace = namespace; - }; - }; - - nvim = nixvim'.makeNixvimWithModule nixvimModule; - treefmtConfig = {...}: { projectRootFile = "flake.nix"; programs = { @@ -42,13 +26,50 @@ }; }; treefmtEval = treefmt-nix.lib.evalModule pkgs (treefmtConfig {inherit pkgs;}); - in { - checks = { - default = nixvimLib.check.mkTestDerivationFromNixvimModule nixvimModule; - treefmt = treefmtEval.config.build.check self; + + pkgs = import nixpkgs {inherit system;}; + mergedLib = pkgs.lib.extend (final: prev: {${namespace} = import ./lib {lib = pkgs.lib;};}); + + nixvimLib = nixvim.lib.${system}; + nixvim' = nixvim.legacyPackages.${system}; + mkNixvimProfile = custom: { + module = { + imports = [./config]; + + ${namespace} = pkgs.lib.mkMerge [ + { + bundles.common.enable = true; + } + custom + ]; + }; + + extraSpecialArgs = { + inherit namespace pkgs; + lib = mergedLib.extend nixvim.lib.overlay; + }; }; - packages.default = nvim; + minimal = mkNixvimProfile {}; + + full = mkNixvimProfile { + languages = { + lsp.enable = true; + }; + utils = { + obsidian.enable = true; + }; + }; + in { + checks = { + treefmt = treefmtEval.config.build.check self; + minimal = nixvimLib.check.mkTestDerivationFromNixvimModule minimal; + }; + + packages = { + default = nixvim'.makeNixvimWithModule minimal; + full = nixvim'.makeNixvimWithModule full; + }; } ); }