diff --git a/configuration.nix b/configuration.nix index 832bf95c..797edba3 100644 --- a/configuration.nix +++ b/configuration.nix @@ -51,11 +51,9 @@ isMaximal: { css.enable = isMaximal; sql.enable = isMaximal; java.enable = isMaximal; - kotlin.enable = isMaximal; ts.enable = isMaximal; svelte.enable = isMaximal; go.enable = isMaximal; - lua.enable = isMaximal; elixir.enable = isMaximal; zig.enable = isMaximal; ocaml.enable = isMaximal; @@ -70,7 +68,6 @@ isMaximal: { lsp.server = "clangd"; }; - scala.enable = isMaximal; rust = { enable = isMaximal; crates.enable = isMaximal; @@ -174,7 +171,6 @@ isMaximal: { notes = { obsidian.enable = false; # FIXME: neovim fails to build if obsidian is enabled - neorg.enable = false; orgmode.enable = false; mind-nvim.enable = isMaximal; todo-comments.enable = true; diff --git a/docs/manual/hacking/additional-plugins.md b/docs/manual/hacking/additional-plugins.md index f0e8d1c5..6294d6f6 100644 --- a/docs/manual/hacking/additional-plugins.md +++ b/docs/manual/hacking/additional-plugins.md @@ -136,29 +136,30 @@ plugins are managed by `lz.n`. let cfg = config.vim.your-plugin; in { - vim.lazy.plugins.your-plugin = { - # instead of vim.startPlugins, use this: - package = "your-plugin"; + vim.lazy.plugins = [ + { + # instead of vim.startPlugins, use this: + package = "your-plugin"; - # if your plugin uses the `require('your-plugin').setup{...}` pattern - setupModule = "your-plugin"; - inherit (cfg) setupOpts; + # if your plugin uses the `require('your-plugin').setup{...}` pattern + setupModule = "your-plugin"; + inherit (cfg) setupOpts; - # events that trigger this plugin to be loaded - events = ["DirChanged"]; - cmd = ["YourPluginCommand"]; + # events that trigger this plugin to be loaded + events = ["DirChanged"]; + cmd = ["YourPluginCommand"]; - # keymaps - keys = [ - # we'll cover this in detail in the keymaps section - { - key = "d"; - mode = "n"; - action = ":YourPluginCommand"; - } - ]; - }; -; + # keymaps + keys = [ + # we'll cover this in detail in the keymaps section + { + key = "d"; + mode = "n"; + action = ":YourPluginCommand"; + } + ] + } + ]; } ``` diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index c23d7b24..61f382bd 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -63,14 +63,6 @@ Note that we are looking to add more alternatives in the future like dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for everyone. -### `type` based modules removed {#sec-type-based-modules-removed} - -As part of the autocompletion rewrite, modules that used to use a `type` option -have been replaced by per-plugin modules instead. Since both modules only had -one type, you can simply change -- `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*` -- `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable` - ## Changelog {#sec-release-0.7-changelog} [ItsSorae](https://github.com/ItsSorae): @@ -101,9 +93,6 @@ one type, you can simply change - Add dap-go for better dap configurations - Make noice.nvim customizable - Standardize border style options and add custom borders -- Remove `vim.disableDefaultRuntimePaths` in wrapper options. - - As nvf uses `$NVIM_APP_NAME` as of recent changes, we can safely assume any - configuration in `$XDG_CONFIG_HOME/nvf` is intentional. [rust-tools.nvim]: https://github.com/simrat39/rust-tools.nvim [rustaceanvim]: https://github.com/mrcjkb/rustaceanvim @@ -274,19 +263,9 @@ one type, you can simply change - Add LSP and Treesitter support for R under `vim.languages.R`. - Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with ccc -- Add Neorg support under `vim.notes.neorg` -- Add LSP, diagnostics, formatter and Treesitter support for Kotlin under - `vim.languages.kotlin` -- changed default keybinds for leap.nvim to avoid altering expected behavior [Bloxx12](https://github.com/Bloxx12) - Add support for [base16 theming](https://github.com/RRethy/base16-nvim) under `vim.theme` - Fix internal breakage in `elixir-tools` setup. - -[ksonj](https://github.com/ksonj): - -- Add LSP support for Scala via - [nvim-metals](https://github.com/scalameta/nvim-metals) - diff --git a/flake.lock b/flake.lock index 59e8e02a..cd091c56 100644 --- a/flake.lock +++ b/flake.lock @@ -828,22 +828,6 @@ "type": "github" } }, - "plugin-lua-utils-nvim": { - "flake": false, - "locked": { - "lastModified": 1708177208, - "narHash": "sha256-9ildzQEMkXKZ3LHq+khGFgRQFxlIXQclQ7QU3fcU1C4=", - "owner": "nvim-neorg", - "repo": "lua-utils.nvim", - "rev": "e565749421f4bbb5d2e85e37c3cef9d56553d8bd", - "type": "github" - }, - "original": { - "owner": "nvim-neorg", - "repo": "lua-utils.nvim", - "type": "github" - } - }, "plugin-lualine": { "flake": false, "locked": { @@ -1005,38 +989,6 @@ "type": "github" } }, - "plugin-neorg": { - "flake": false, - "locked": { - "lastModified": 1727821831, - "narHash": "sha256-yfWQ6yKytu1jkWUtRZTVICslUWej6jVYv7frmSB7/6Q=", - "owner": "nvim-neorg", - "repo": "neorg", - "rev": "afc9a37bf021acb0853e95714c4c6436e1588286", - "type": "github" - }, - "original": { - "owner": "nvim-neorg", - "repo": "neorg", - "type": "github" - } - }, - "plugin-neorg-telescope": { - "flake": false, - "locked": { - "lastModified": 1722358034, - "narHash": "sha256-ei4uUqpIQjGKzu5ryu0Hlmis9TS9FJsYnjt4J4QdWlw=", - "owner": "nvim-neorg", - "repo": "neorg-telescope", - "rev": "ddb2556644cae922699a239bbb0fe16e25b084b7", - "type": "github" - }, - "original": { - "owner": "nvim-neorg", - "repo": "neorg-telescope", - "type": "github" - } - }, "plugin-new-file-template-nvim": { "flake": false, "locked": { @@ -1278,22 +1230,6 @@ "type": "github" } }, - "plugin-nvim-metals": { - "flake": false, - "locked": { - "lastModified": 1728295172, - "narHash": "sha256-ja/+MNxZ3H9io9jDwm5rhE6iKNi86a22eCOY75g19O8=", - "owner": "scalameta", - "repo": "nvim-metals", - "rev": "f861db9fda55939797ac1b05238c49b0dcdc3bdb", - "type": "github" - }, - "original": { - "owner": "scalameta", - "repo": "nvim-metals", - "type": "github" - } - }, "plugin-nvim-navbuddy": { "flake": false, "locked": { @@ -1550,22 +1486,6 @@ "type": "github" } }, - "plugin-pathlib-nvim": { - "flake": false, - "locked": { - "lastModified": 1724943804, - "narHash": "sha256-YhCJeNKlcjgg3q51UWFhuIEPzNueC8YTpeuPPJDndvw=", - "owner": "pysan3", - "repo": "pathlib.nvim", - "rev": "57e5598af6fe253761c1b48e0b59b7cd6699e2c1", - "type": "github" - }, - "original": { - "owner": "pysan3", - "repo": "pathlib.nvim", - "type": "github" - } - }, "plugin-plenary-nvim": { "flake": false, "locked": { @@ -1988,7 +1908,6 @@ "plugin-lsp-signature": "plugin-lsp-signature", "plugin-lspkind": "plugin-lspkind", "plugin-lspsaga": "plugin-lspsaga", - "plugin-lua-utils-nvim": "plugin-lua-utils-nvim", "plugin-lualine": "plugin-lualine", "plugin-luasnip": "plugin-luasnip", "plugin-lz-n": "plugin-lz-n", @@ -1999,8 +1918,6 @@ "plugin-neo-tree-nvim": "plugin-neo-tree-nvim", "plugin-neocord": "plugin-neocord", "plugin-neodev-nvim": "plugin-neodev-nvim", - "plugin-neorg": "plugin-neorg", - "plugin-neorg-telescope": "plugin-neorg-telescope", "plugin-new-file-template-nvim": "plugin-new-file-template-nvim", "plugin-noice-nvim": "plugin-noice-nvim", "plugin-none-ls": "plugin-none-ls", @@ -2016,7 +1933,6 @@ "plugin-nvim-docs-view": "plugin-nvim-docs-view", "plugin-nvim-lightbulb": "plugin-nvim-lightbulb", "plugin-nvim-lspconfig": "plugin-nvim-lspconfig", - "plugin-nvim-metals": "plugin-nvim-metals", "plugin-nvim-navbuddy": "plugin-nvim-navbuddy", "plugin-nvim-navic": "plugin-nvim-navic", "plugin-nvim-neoclip": "plugin-nvim-neoclip", @@ -2033,7 +1949,6 @@ "plugin-orgmode-nvim": "plugin-orgmode-nvim", "plugin-otter-nvim": "plugin-otter-nvim", "plugin-oxocarbon": "plugin-oxocarbon", - "plugin-pathlib-nvim": "plugin-pathlib-nvim", "plugin-plenary-nvim": "plugin-plenary-nvim", "plugin-project-nvim": "plugin-project-nvim", "plugin-registers": "plugin-registers", diff --git a/flake.nix b/flake.nix index 40043588..dbd2dfc5 100644 --- a/flake.nix +++ b/flake.nix @@ -217,11 +217,6 @@ flake = false; }; - plugin-nvim-metals = { - url = "github:scalameta/nvim-metals"; - flake = false; - }; - # Copying/Registers plugin-registers = { url = "github:tversteeg/registers.nvim"; @@ -657,26 +652,6 @@ flake = false; }; - plugin-lua-utils-nvim = { - url = "github:nvim-neorg/lua-utils.nvim"; - flake = false; - }; - - plugin-pathlib-nvim = { - url = "github:pysan3/pathlib.nvim"; - flake = false; - }; - - plugin-neorg = { - url = "github:nvim-neorg/neorg"; - flake = false; - }; - - plugin-neorg-telescope = { - url = "github:nvim-neorg/neorg-telescope"; - flake = false; - }; - plugin-nui-nvim = { # (required by noice.nvim) url = "github:MunifTanjim/nui.nvim"; diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index 5a30ef5e..c4ff4d30 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -31,28 +31,9 @@ in { vim.autocomplete.type has been removed in favor of per-plugin modules. You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead. '') - (mkRemovedOptionModule ["vim" "autocomplete" "sources"] '' - vim.autocomplete.sources has been removed in favor of per-plugin modules. - You can add nvim-cmp sources with vim.autocomplete.nvim-cmp.sources - instead. - '') (mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] '' vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip. '') (mkRenamedOptionModule ["vim" "lsp" "lspkind" "mode"] ["vim" "lsp" "lspkind" "setupOpts" "mode"]) - - # 2024-10-14 - (mkRemovedOptionModule ["vim" "configRC"] '' - Please migrate your configRC sections to Neovim's Lua format, and - add them to `vim.luaConfigRC`. - - See the v0.7 release notes for more information on why and how to - migrate your existing configurations to the new format. - '') - - (mkRemovedOptionModule ["vim" "disableDefaultRuntimePaths"] '' - Nvf now uses $NVIM_APP_NAME so there is no longer the problem of - (accidental) leaking of user configuration. - '') ]; } diff --git a/modules/plugins/comments/comment-nvim/config.nix b/modules/plugins/comments/comment-nvim/config.nix index 0fde7885..4c3a955c 100644 --- a/modules/plugins/comments/comment-nvim/config.nix +++ b/modules/plugins/comments/comment-nvim/config.nix @@ -11,32 +11,37 @@ inherit (self.options.vim.comments.comment-nvim) mappings; in { config = mkIf cfg.enable { - vim.startPlugins = ["comment-nvim"]; + vim.startPlugins = [ + "comment-nvim" + ]; - vim.lazy.plugins.comment-nvim = { - package = "comment-nvim"; - setupModule = "Comment"; - inherit (cfg) setupOpts; - keys = [ - (mkLznBinding ["n"] cfg.mappings.toggleOpLeaderLine "(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description) - (mkLznBinding ["n"] cfg.mappings.toggleOpLeaderBlock "(comment_toggle_blockwise)" mappings.toggleOpLeaderBlock.description) - (mkLznExprBinding ["n"] cfg.mappings.toggleCurrentLine '' - function() - return vim.api.nvim_get_vvar('count') == 0 and '(comment_toggle_linewise_current)' - or '(comment_toggle_linewise_count)' - end - '' - mappings.toggleCurrentLine.description) - (mkLznExprBinding ["n"] cfg.mappings.toggleCurrentBlock '' - function() - return vim.api.nvim_get_vvar('count') == 0 and '(comment_toggle_blockwise_current)' - or '(comment_toggle_blockwise_count)' - end - '' - mappings.toggleCurrentBlock.description) - (mkLznBinding ["x"] cfg.mappings.toggleSelectedLine "(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description) - (mkLznBinding ["x"] cfg.mappings.toggleSelectedBlock "(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description) - ]; - }; + vim.lazy.plugins = [ + { + package = "comment-nvim"; + setupModule = "Comment"; + inherit (cfg) setupOpts; + keys = [ + (mkLznBinding ["n"] cfg.mappings.toggleOpLeaderLine "(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description) + (mkLznBinding ["n"] cfg.mappings.toggleOpLeaderBlock "(comment_toggle_blockwise)" mappings.toggleOpLeaderBlock.description) + + (mkLznExprBinding ["n"] cfg.mappings.toggleCurrentLine '' + function() + return vim.api.nvim_get_vvar('count') == 0 and '(comment_toggle_linewise_current)' + or '(comment_toggle_linewise_count)' + end + '' + mappings.toggleCurrentLine.description) + (mkLznExprBinding ["n"] cfg.mappings.toggleCurrentBlock '' + function() + return vim.api.nvim_get_vvar('count') == 0 and '(comment_toggle_blockwise_current)' + or '(comment_toggle_blockwise_count)' + end + '' + mappings.toggleCurrentBlock.description) + (mkLznBinding ["x"] cfg.mappings.toggleSelectedLine "(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description) + (mkLznBinding ["x"] cfg.mappings.toggleSelectedBlock "(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description) + ]; + } + ]; }; } diff --git a/modules/plugins/completion/nvim-cmp/config.nix b/modules/plugins/completion/nvim-cmp/config.nix index 5d20242d..ffd15fe4 100644 --- a/modules/plugins/completion/nvim-cmp/config.nix +++ b/modules/plugins/completion/nvim-cmp/config.nix @@ -6,13 +6,17 @@ inherit (lib.modules) mkIf; inherit (lib.strings) optionalString; inherit (lib.generators) mkLuaInline; + inherit (lib.nvim.binds) addDescriptionsToMappings; inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.lua) toLuaObject; inherit (builtins) attrNames; cfg = config.vim.autocomplete.nvim-cmp; luasnipEnable = config.vim.snippets.luasnip.enable; - inherit (cfg) mappings; + + self = import ./nvim-cmp.nix {inherit lib config;}; + mappingDefinitions = self.options.vim.autocomplete.nvim-cmp.mappings; + mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; in { config = mkIf cfg.enable { vim = { @@ -41,20 +45,39 @@ in { }; pluginRC.nvim-cmp = mkIf cfg.enable (entryAfter ["autopairs" "luasnip"] '' - ${optionalString luasnipEnable "local luasnip = require('luasnip')"} + local luasnip = require("luasnip") local cmp = require("cmp") cmp.setup(${toLuaObject cfg.setupOpts}) ''); # `cmp` and `luasnip` are defined above, in the `nvim-cmp` section autocomplete.nvim-cmp.setupOpts.mapping = { - ${mappings.complete} = mkLuaInline "cmp.mapping.complete()"; - ${mappings.close} = mkLuaInline "cmp.mapping.abort()"; - ${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)"; - ${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)"; - ${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })"; + ${mappings.complete.value} = mkLuaInline "cmp.mapping.complete()"; + ${mappings.close.value} = mkLuaInline "cmp.mapping.abort()"; + ${mappings.scrollDocsUp.value} = mkLuaInline "cmp.mapping.scroll_docs(-4)"; + ${mappings.scrollDocsDown.value} = mkLuaInline "cmp.mapping.scroll_docs(4)"; - ${mappings.next} = mkLuaInline '' + ${mappings.confirm.value} = mkLuaInline '' + cmp.mapping(function(fallback) + if cmp.visible() then + ${ + if luasnipEnable + then '' + if luasnip.expandable() then + luasnip.expand() + else + cmp.confirm({ select = true }) + end + '' + else "cmp.confirm({ select = true })" + } + else + fallback() + end + end) + ''; + + ${mappings.next.value} = mkLuaInline '' cmp.mapping(function(fallback) local has_words_before = function() local line, col = unpack(vim.api.nvim_win_get_cursor(0)) @@ -75,7 +98,7 @@ in { end) ''; - ${mappings.previous} = mkLuaInline '' + ${mappings.previous.value} = mkLuaInline '' cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() diff --git a/modules/plugins/debugger/nvim-dap/config.nix b/modules/plugins/debugger/nvim-dap/config.nix index 78e86a8c..a6689591 100644 --- a/modules/plugins/debugger/nvim-dap/config.nix +++ b/modules/plugins/debugger/nvim-dap/config.nix @@ -54,15 +54,17 @@ in { vim = { startPlugins = ["nvim-nio"]; - lazy.plugins.nvim-dap-ui = { - package = "nvim-dap-ui"; - setupModule = "dapui"; - setupOpts = {}; + lazy.plugins = [ + { + package = "nvim-dap-ui"; + setupModule = "dapui"; + setupOpts = {}; - keys = [ - (mkSetLuaLznBinding mappings.toggleDapUI "function() require('dapui').toggle() end") - ]; - }; + keys = [ + (mkSetLuaLznBinding mappings.toggleDapUI "function() require('dapui').toggle() end") + ]; + } + ]; pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] ( optionalString cfg.ui.autoStart '' diff --git a/modules/plugins/filetree/neo-tree/config.nix b/modules/plugins/filetree/neo-tree/config.nix index 13da0354..c2d6ea66 100644 --- a/modules/plugins/filetree/neo-tree/config.nix +++ b/modules/plugins/filetree/neo-tree/config.nix @@ -16,13 +16,15 @@ in { "nui-nvim" # ui library ]; - lazy.plugins.neo-tree-nvim = { - package = "neo-tree-nvim"; - setupModule = "neo-tree"; - inherit (cfg) setupOpts; + lazy.plugins = [ + { + package = "neo-tree-nvim"; + setupModule = "neo-tree"; + inherit (cfg) setupOpts; - cmd = ["Neotree"]; - }; + cmd = ["Neotree"]; + } + ]; visuals.nvimWebDevicons.enable = true; }; diff --git a/modules/plugins/filetree/nvimtree/config.nix b/modules/plugins/filetree/nvimtree/config.nix index 30cc680b..66a901b5 100644 --- a/modules/plugins/filetree/nvimtree/config.nix +++ b/modules/plugins/filetree/nvimtree/config.nix @@ -15,12 +15,12 @@ inherit (self.options.vim.filetree.nvimTree) mappings; in { config = mkIf cfg.enable { - vim = { - binds.whichKey.register = pushDownDefault { - "t" = "+NvimTree"; - }; + vim.binds.whichKey.register = pushDownDefault { + "t" = "+NvimTree"; + }; - lazy.plugins.nvim-tree-lua = { + vim.lazy.plugins = [ + { package = "nvim-tree-lua"; setupModule = "nvim-tree"; inherit (cfg) setupOpts; @@ -31,58 +31,58 @@ in { (mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile" mappings.findFile.description) (mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus" mappings.focus.description) ]; - }; + } + ]; - pluginRC.nvimtreelua = entryAnywhere '' - ${ - optionalString cfg.setupOpts.disable_netrw '' - -- disable netrew completely - vim.g.loaded_netrw = 1 - vim.g.loaded_netrwPlugin = 1 - '' - } + vim.pluginRC.nvimtreelua = entryAnywhere '' + ${ + optionalString cfg.setupOpts.disable_netrw '' + -- disable netrew completely + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + '' + } - ${ - optionalString cfg.openOnSetup '' - ${optionalString config.vim.lazy.enable ''require('lz.n').trigger_load("nvim-tree-lua")''} - -- autostart behaviour - -- Open on startup has been deprecated - -- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup + ${ + optionalString cfg.openOnSetup '' + ${optionalString config.vim.lazy.enable ''require('lz.n').trigger_load("nvim-tree-lua")''} + -- autostart behaviour + -- Open on startup has been deprecated + -- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup - -- use a nix eval to dynamically insert the open on startup function - local function open_nvim_tree(data) - local IGNORED_FT = { - "markdown", - } + -- use a nix eval to dynamically insert the open on startup function + local function open_nvim_tree(data) + local IGNORED_FT = { + "markdown", + } - -- buffer is a real file on the disk - local real_file = vim.fn.filereadable(data.file) == 1 + -- buffer is a real file on the disk + local real_file = vim.fn.filereadable(data.file) == 1 - -- buffer is a [No Name] - local no_name = data.file == "" and vim.bo[data.buf].buftype == "" + -- buffer is a [No Name] + local no_name = data.file == "" and vim.bo[data.buf].buftype == "" - -- &ft - local filetype = vim.bo[data.buf].ft + -- &ft + local filetype = vim.bo[data.buf].ft - -- only files please - if not real_file and not no_name then - return - end - - -- skip ignored filetypes - if vim.tbl_contains(IGNORED_FT, filetype) then - return - end - - -- open the tree but don't focus it - require("nvim-tree.api").tree.toggle({ focus = false }) + -- only files please + if not real_file and not no_name then + return end - -- function to automatically open the tree on VimEnter - vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) - '' - } - ''; - }; + -- skip ignored filetypes + if vim.tbl_contains(IGNORED_FT, filetype) then + return + end + + -- open the tree but don't focus it + require("nvim-tree.api").tree.toggle({ focus = false }) + end + + -- function to automatically open the tree on VimEnter + vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) + '' + } + ''; }; } diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 54a9e1c4..28c1fd8f 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -8,7 +8,6 @@ in { ./css.nix ./elixir.nix ./go.nix - ./kotlin.nix ./html.nix ./java.nix ./lua.nix @@ -20,7 +19,6 @@ in { ./python.nix ./r.nix ./rust.nix - ./scala.nix ./sql.nix ./svelte.nix ./tailwind.nix diff --git a/modules/plugins/languages/kotlin.nix b/modules/plugins/languages/kotlin.nix deleted file mode 100644 index 5637b4f4..00000000 --- a/modules/plugins/languages/kotlin.nix +++ /dev/null @@ -1,107 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: let - inherit (lib.options) mkEnableOption mkOption literalExpression; - inherit (lib.modules) mkIf mkMerge; - inherit (lib.meta) getExe; - inherit (lib.nvim.languages) diagnosticsToLua; - inherit (lib.types) package; - inherit (lib.nvim.types) mkGrammarOption diagnostics; - inherit (lib.lists) isList; - inherit (lib.nvim.lua) expToLua; - - cfg = config.vim.languages.kotlin; - - defaultDiagnosticsProvider = ["ktlint"]; - diagnosticsProviders = { - ktlint = { - package = pkgs.ktlint; - nullConfig = pkg: '' - table.insert( - ls_sources, - null_ls.builtins.diagnostics.ktlint.with({ - command = "${getExe pkg}", - }) - ) - ''; - }; - }; -in { - options.vim.languages.kotlin = { - enable = mkEnableOption "Kotlin/HCL support"; - - treesitter = { - enable = mkEnableOption "Kotlin treesitter" // {default = config.vim.languages.enableTreesitter;}; - package = mkGrammarOption pkgs "kotlin"; - }; - - lsp = { - enable = mkEnableOption "Kotlin LSP support" // {default = config.vim.languages.enableLSP;}; - - package = mkOption { - description = "kotlin_language_server package with Kotlin runtime"; - type = package; - example = literalExpression '' - pkgs.symlinkJoin { - name = "kotlin-language-server-wrapped"; - paths = [pkgs.kotlin-language-server]; - nativeBuildInputs = [pkgs.makeWrapper]; - postBuild = ''' - wrapProgram $out/bin/kotlin-language-server \ - --prefix PATH : ''${pkgs.kotlin}/bin - '''; - }; - ''; - default = pkgs.kotlin-language-server; - }; - }; - - extraDiagnostics = { - enable = mkEnableOption "extra Kotlin diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; - - types = diagnostics { - langDesc = "Kotlin"; - inherit diagnosticsProviders; - inherit defaultDiagnosticsProvider; - }; - }; - }; - config = mkIf cfg.enable (mkMerge [ - (mkIf cfg.treesitter.enable { - vim.treesitter.enable = true; - vim.treesitter.grammars = [cfg.treesitter.package]; - }) - - (mkIf cfg.extraDiagnostics.enable { - vim.lsp.null-ls.enable = true; - vim.lsp.null-ls.sources = diagnosticsToLua { - lang = "kotlin"; - config = cfg.extraDiagnostics.types; - inherit diagnosticsProviders; - }; - }) - - (mkIf cfg.lsp.enable { - vim.lsp.lspconfig.enable = true; - vim.lsp.lspconfig.sources.kotlin_language_server = '' - lspconfig.kotlin_language_server.setup { - capabilities = capabilities, - root_dir = lspconfig.util.root_pattern("main.kt", ".git"), - on_attach=default_on_attach, - init_options = { - -- speeds up the startup time for the LSP - storagePath = vim.fn.stdpath('state') .. '/kotlin', - }, - cmd = ${ - if isList cfg.lsp.package - then expToLua cfg.lsp.package - else ''{"${cfg.lsp.package}/bin/kotlin-language-server"}'' - }, - } - ''; - }) - ]); -} diff --git a/modules/plugins/languages/scala.nix b/modules/plugins/languages/scala.nix deleted file mode 100644 index f769d092..00000000 --- a/modules/plugins/languages/scala.nix +++ /dev/null @@ -1,149 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: let - inherit (lib.generators) mkLuaInline; - inherit (lib.modules) mkIf mkMerge; - inherit (lib.nvim.binds) mkMappingOption; - inherit (lib.nvim.dag) entryAfter; - inherit (lib.nvim.lua) toLuaObject; - inherit (lib.nvim.types) mkGrammarOption luaInline; - inherit (lib.options) mkOption mkEnableOption mkPackageOption; - inherit (lib.strings) optionalString; - inherit (lib.types) attrsOf anything bool; - - listCommandsAction = - if config.vim.telescope.enable - then ''require("telescope").extensions.metals.commands()'' - else ''require("metals").commands()''; - - cfg = config.vim.languages.scala; - - usingDap = config.vim.debugger.nvim-dap.enable && cfg.dap.enable; - usingLualine = config.vim.statusline.lualine.enable; -in { - options.vim.languages.scala = { - enable = mkEnableOption "Scala language support"; - - treesitter = { - enable = mkEnableOption "Scala treesitter" // {default = config.vim.languages.enableTreesitter;}; - package = mkGrammarOption pkgs "scala"; - }; - - lsp = { - enable = mkEnableOption "Scala LSP support (metals)" // {default = config.vim.languages.enableLSP;}; - package = mkPackageOption pkgs "metals" { - default = ["metals"]; - }; - - extraMappings = { - listCommands = mkMappingOption "List Metals commands" "lc"; - }; - - extraSettings = mkOption { - type = attrsOf anything; - description = "Extra settings passed to the metals config. Check nvim-metals docs for available options"; - default = { - showImplicitArguments = true; - showImplicitConversionsAndClasses = true; - showInferredType = true; - excludedPackages = [ - "akka.actor.typed.javadsl" - "com.github.swagger.akka.javadsl" - ]; - }; - }; - }; - - dap = { - enable = mkEnableOption "Scala Debug Adapter support (metals)" // {default = config.vim.languages.enableDAP;}; - config = mkOption { - description = "Lua configuration for dap"; - type = luaInline; - default = mkLuaInline '' - dap.configurations.scala = { - { - type = "scala", - request = "launch", - name = "RunOrTest", - metals = { - runType = "runOrTestFile", - --args = { "firstArg", "secondArg", "thirdArg" }, -- here just as an example - }, - }, - { - type = "scala", - request = "launch", - name = "Test Target", - metals = { - runType = "testTarget", - }, - }, - } - ''; - }; - }; - - fixShortmess = mkOption { - type = bool; - description = "Remove the 'F' flag from shortmess to allow messages to be shown. Without doing this, autocommands that deal with filetypes prohibit messages from being shown"; - default = true; - }; - }; - - config = mkIf cfg.enable ( - mkMerge [ - (mkIf cfg.treesitter.enable { - vim.treesitter.enable = true; - vim.treesitter.grammars = [cfg.treesitter.package]; - }) - (mkIf (cfg.lsp.enable || cfg.dap.enable) { - vim = { - startPlugins = ["nvim-metals"]; - pluginRC.nvim-metals = entryAfter ["lsp-setup"] '' - local metals_caps = capabilities -- from lsp-setup - - local attach_metals_keymaps = function(client, bufnr) - attach_keymaps(client, bufnr) -- from lsp-setup - vim.api.nvim_buf_set_keymap(bufnr, 'n', '${cfg.lsp.extraMappings.listCommands}', 'lua ${listCommandsAction}', {noremap=true, silent=true, desc='Show all Metals commands'}) - end - - metals_config = require('metals').bare_config() - ${optionalString usingLualine "metals_config.init_options.statusBarProvider = 'on'"} - - metals_config.capabilities = metals_caps - metals_config.on_attach = function(client, bufnr) - ${optionalString usingDap "require('metals').setup_dap()"} - attach_metals_keymaps(client, bufnr) - end - - metals_config.settings = ${toLuaObject cfg.lsp.extraSettings} - metals_config.settings.metalsBinaryPath = "${cfg.lsp.package}/bin/metals" - - metals_config.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = { - prefix = '⚠', - } - } - ) - - ${optionalString cfg.fixShortmess ''vim.opt_global.shortmess:remove("F")''} - - local lsp_group = vim.api.nvim_create_augroup('lsp', { clear = true }) - - vim.api.nvim_create_autocmd('FileType', { - group = lsp_group, - pattern = {'java', 'scala', 'sbt'}, - callback = function() - require('metals').initialize_or_attach(metals_config) - end, - }) - ''; - }; - }) - ] - ); -} diff --git a/modules/plugins/lsp/trouble/config.nix b/modules/plugins/lsp/trouble/config.nix index e4b966a4..1a7eb468 100644 --- a/modules/plugins/lsp/trouble/config.nix +++ b/modules/plugins/lsp/trouble/config.nix @@ -14,21 +14,23 @@ in { config = mkIf (cfg.enable && cfg.trouble.enable) { vim = { - lazy.plugins.trouble = { - package = "trouble"; - setupModule = "trouble"; - inherit (cfg.trouble) setupOpts; + lazy.plugins = [ + { + package = "trouble"; + setupModule = "trouble"; + inherit (cfg.trouble) setupOpts; - cmd = "Trouble"; - keys = [ - (mkSetLznBinding mappings.toggle "TroubleToggle") - (mkSetLznBinding mappings.workspaceDiagnostics "TroubleToggle workspace_diagnostics") - (mkSetLznBinding mappings.documentDiagnostics "TroubleToggle document_diagnostics") - (mkSetLznBinding mappings.lspReferences "TroubleToggle lsp_references") - (mkSetLznBinding mappings.quickfix "TroubleToggle quickfix") - (mkSetLznBinding mappings.locList "TroubleToggle loclist") - ]; - }; + cmd = "Trouble"; + keys = [ + (mkSetLznBinding mappings.toggle "TroubleToggle") + (mkSetLznBinding mappings.workspaceDiagnostics "TroubleToggle workspace_diagnostics") + (mkSetLznBinding mappings.documentDiagnostics "TroubleToggle document_diagnostics") + (mkSetLznBinding mappings.lspReferences "TroubleToggle lsp_references") + (mkSetLznBinding mappings.quickfix "TroubleToggle quickfix") + (mkSetLznBinding mappings.locList "TroubleToggle loclist") + ]; + } + ]; binds.whichKey.register = pushDownDefault { "l" = "Trouble"; diff --git a/modules/plugins/notes/default.nix b/modules/plugins/notes/default.nix index 6c342728..88a70924 100644 --- a/modules/plugins/notes/default.nix +++ b/modules/plugins/notes/default.nix @@ -2,7 +2,6 @@ imports = [ ./obsidian ./orgmode - ./neorg ./mind-nvim ./todo-comments ]; diff --git a/modules/plugins/notes/neorg/config.nix b/modules/plugins/notes/neorg/config.nix deleted file mode 100644 index fab5079d..00000000 --- a/modules/plugins/notes/neorg/config.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ - config, - lib, - ... -}: let - inherit (lib.modules) mkIf mkMerge; - inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.nvim.binds) pushDownDefault; - inherit (lib.nvim.lua) toLuaObject; - - cfg = config.vim.notes.neorg; -in { - config = mkIf cfg.enable (mkMerge [ - { - vim = { - startPlugins = [ - "lua-utils-nvim" - "nui-nvim" - "nvim-nio" - "pathlib-nvim" - "plenary-nvim" - "neorg" - "neorg-telescope" - ]; - - binds.whichKey.register = pushDownDefault { - "o" = "+Notes"; - }; - - pluginRC.neorg = entryAnywhere '' - require('neorg').setup(${toLuaObject cfg.setupOpts}) - ''; - }; - } - - (mkIf cfg.treesitter.enable { - vim.treesitter.enable = true; - vim.treesitter.grammars = [cfg.treesitter.norgPackage]; - }) - ]); -} diff --git a/modules/plugins/notes/neorg/default.nix b/modules/plugins/notes/neorg/default.nix deleted file mode 100644 index 409cee31..00000000 --- a/modules/plugins/notes/neorg/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - imports = [ - ./neorg.nix - ./config.nix - ]; -} diff --git a/modules/plugins/notes/neorg/neorg.nix b/modules/plugins/notes/neorg/neorg.nix deleted file mode 100644 index 6b5cf18e..00000000 --- a/modules/plugins/notes/neorg/neorg.nix +++ /dev/null @@ -1,50 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) submodule listOf str; - inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption; -in { - options.vim.notes.neorg = { - enable = mkEnableOption '' - Neorg: An intuitive note-taking and organization tool with a structured nested syntax. - ''; - - setupOpts = mkPluginSetupOption "Neorg" { - load = { - "core.defaults" = mkOption { - default = {}; - description = '' - all of the most important modules that any user would want to have a "just works" experience - ''; - - type = submodule { - options = { - enable = mkEnableOption '' - all of the most important modules that any user would want to have a "just works" experience - ''; - config = { - disable = mkOption { - description = '' - list of modules from to be disabled from core.defaults - ''; - type = listOf str; - default = []; - example = ["core.autocommands" "core.itero"]; - }; - }; - }; - }; - }; - }; - }; - - treesitter = { - enable = mkEnableOption "Neorg treesitter" // {default = config.vim.languages.enableTreesitter;}; - norgPackage = mkGrammarOption pkgs "norg"; - }; - }; -} diff --git a/modules/plugins/terminal/toggleterm/config.nix b/modules/plugins/terminal/toggleterm/config.nix index d96e4801..b4167489 100644 --- a/modules/plugins/terminal/toggleterm/config.nix +++ b/modules/plugins/terminal/toggleterm/config.nix @@ -14,37 +14,39 @@ in { config = mkIf cfg.enable { vim = { - lazy.plugins.toggleterm-nvim = { - package = "toggleterm-nvim"; - cmd = ["ToggleTerm" "ToggleTermSendCurrentLine" "ToggleTermSendVisualLines" "ToggleTermSendVisualSelection" "ToggleTermSetName" "ToggleTermToggleAll"]; - keys = [ - (mkLznBinding ["n"] cfg.mappings.open "execute v:count . \"ToggleTerm\"" "Toggle terminal") - { - key = cfg.lazygit.mappings.open; - desc = lazygitMapDesc; - } - ]; + lazy.plugins = [ + { + package = "toggleterm-nvim"; + cmd = ["ToggleTerm" "ToggleTermSendCurrentLine" "ToggleTermSendVisualLines" "ToggleTermSendVisualSelection" "ToggleTermSetName" "ToggleTermToggleAll"]; + keys = [ + (mkLznBinding ["n"] cfg.mappings.open "execute v:count . \"ToggleTerm\"" "Toggle terminal") + { + key = cfg.lazygit.mappings.open; + desc = lazygitMapDesc; + } + ]; - setupModule = "toggleterm"; - inherit (cfg) setupOpts; - after = optionalString cfg.lazygit.enable '' - local terminal = require 'toggleterm.terminal' - local lazygit = terminal.Terminal:new({ - cmd = '${ - if (cfg.lazygit.package != null) - then getExe cfg.lazygit.package - else "lazygit" - }', - direction = '${cfg.lazygit.direction}', - hidden = true, - on_open = function(term) - vim.cmd("startinsert!") - end - }) + setupModule = "toggleterm"; + inherit (cfg) setupOpts; + after = optionalString cfg.lazygit.enable '' + local terminal = require 'toggleterm.terminal' + local lazygit = terminal.Terminal:new({ + cmd = '${ + if (cfg.lazygit.package != null) + then getExe cfg.lazygit.package + else "lazygit" + }', + direction = '${cfg.lazygit.direction}', + hidden = true, + on_open = function(term) + vim.cmd("startinsert!") + end + }) - vim.keymap.set('n', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = '${lazygitMapDesc}'}) - ''; - }; + vim.keymap.set('n', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = '${lazygitMapDesc}'}) + ''; + } + ]; }; }; } diff --git a/modules/plugins/utility/binds/cheatsheet/config.nix b/modules/plugins/utility/binds/cheatsheet/config.nix index 2fb3e25b..f7bfa44d 100644 --- a/modules/plugins/utility/binds/cheatsheet/config.nix +++ b/modules/plugins/utility/binds/cheatsheet/config.nix @@ -9,13 +9,15 @@ cfg = config.vim.binds.cheatsheet; in { config = mkIf cfg.enable { - vim.lazy.plugins.cheatsheet-nvim = { - package = "cheatsheet-nvim"; - setupModule = "cheatsheet"; - setupOpts = {}; - cmd = ["Cheatsheet" "CheatsheetEdit"]; + vim.lazy.plugins = [ + { + package = "cheatsheet-nvim"; + setupModule = "cheatsheet"; + setupOpts = {}; + cmd = ["Cheatsheet" "CheatsheetEdit"]; - before = optionalString config.vim.lazy.enable "require('lz.n').trigger_load('telescope')"; - }; + before = optionalString config.vim.lazy.enable "require('lz.n').trigger_load('telescope')"; + } + ]; }; } diff --git a/modules/plugins/utility/diffview/config.nix b/modules/plugins/utility/diffview/config.nix index a6458ed5..5ea51d78 100644 --- a/modules/plugins/utility/diffview/config.nix +++ b/modules/plugins/utility/diffview/config.nix @@ -10,12 +10,14 @@ in { config = mkIf cfg.enable { vim = { startPlugins = ["plenary-nvim"]; - lazy.plugins.diffview-nvim = { - package = "diffview-nvim"; - cmd = ["DiffviewClose" "DiffviewFileHistory" "DiffviewFocusFiles" "DiffviewLog" "DiffviewOpen" "DiffviewRefresh" "DiffviewToggleFiles"]; - setupModule = "diffview"; - inherit (cfg) setupOpts; - }; + lazy.plugins = [ + { + package = "diffview-nvim"; + cmd = ["DiffviewClose" "DiffviewFileHistory" "DiffviewFocusFiles" "DiffviewLog" "DiffviewOpen" "DiffviewRefresh" "DiffviewToggleFiles"]; + setupModule = "diffview"; + inherit (cfg) setupOpts; + } + ]; }; }; } diff --git a/modules/plugins/utility/icon-picker/config.nix b/modules/plugins/utility/icon-picker/config.nix index 99e43044..13fa45e6 100644 --- a/modules/plugins/utility/icon-picker/config.nix +++ b/modules/plugins/utility/icon-picker/config.nix @@ -10,14 +10,16 @@ in { config = mkIf cfg.enable { vim.startPlugins = ["dressing-nvim"]; - vim.lazy.plugins.icon-picker-nvim = { - package = "icon-picker-nvim"; - setupModule = "icon-picker"; - setupOpts = { - disable_legacy_commands = true; - }; + vim.lazy.plugins = [ + { + package = "icon-picker-nvim"; + setupModule = "icon-picker"; + setupOpts = { + disable_legacy_commands = true; + }; - cmd = ["IconPickerInsert" "IconPickerNormal" "IconPickerYank"]; - }; + cmd = ["IconPickerInsert" "IconPickerNormal" "IconPickerYank"]; + } + ]; }; } diff --git a/modules/plugins/utility/motion/leap/config.nix b/modules/plugins/utility/motion/leap/config.nix index 94a00c99..9e9cf40e 100644 --- a/modules/plugins/utility/motion/leap/config.nix +++ b/modules/plugins/utility/motion/leap/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib.modules) mkIf mkDefault; + inherit (lib.modules) mkIf; inherit (lib.nvim.binds) mkLznBinding; cfg = config.vim.utility.motion.leap; @@ -11,51 +11,51 @@ in { config = mkIf cfg.enable { vim = { startPlugins = ["vim-repeat"]; - lazy.plugins.leap-nvim = { - package = "leap-nvim"; - keys = [ - (mkLznBinding ["n" "o" "x"] cfg.mappings.leapForwardTo "(leap-forward-to)" "Leap forward to") - (mkLznBinding ["n" "o" "x"] cfg.mappings.leapBackwardTo "(leap-backward-to)" "Leap backward to") - (mkLznBinding ["n" "o" "x"] cfg.mappings.leapForwardTill "(leap-forward-till)" "Leap forward till") - (mkLznBinding ["n" "o" "x"] cfg.mappings.leapBackwardTill "(leap-backward-till)" "Leap backward till") - (mkLznBinding ["n" "o" "x"] cfg.mappings.leapFromWindow "(leap-from-window)" "Leap from window") - ]; + lazy.plugins = [ + { + package = "leap-nvim"; + keys = [ + (mkLznBinding ["n" "o" "x"] cfg.mappings.leapForwardTo "(leap-forward-to)" "Leap forward to") + (mkLznBinding ["n" "o" "x"] cfg.mappings.leapBackwardTo "(leap-backward-to)" "Leap backward to") + (mkLznBinding ["n" "o" "x"] cfg.mappings.leapForwardTill "(leap-forward-till)" "Leap forward till") + (mkLznBinding ["n" "o" "x"] cfg.mappings.leapBackwardTill "(leap-backward-till)" "Leap backward till") + (mkLznBinding ["n" "o" "x"] cfg.mappings.leapFromWindow "(leap-from-window)" "Leap from window") + ]; - after = '' - require('leap').opts = { - max_phase_one_targets = nil, - highlight_unlabeled_phase_one_targets = false, - max_highlighted_traversal_targets = 10, - case_sensitive = false, - equivalence_classes = { ' \t\r\n', }, - substitute_chars = {}, - safe_labels = { - "s", "f", "n", "u", "t", "/", - "S", "F", "N", "L", "H", "M", "U", "G", "T", "?", "Z" - }, - labels = { - "s", "f", "n", - "j", "k", "l", "h", "o", "d", "w", "e", "m", "b", - "u", "y", "v", "r", "g", "t", "c", "x", "/", "z", - "S", "F", "N", - "J", "K", "L", "H", "O", "D", "W", "E", "M", "B", - "U", "Y", "V", "R", "G", "T", "C", "X", "?", "Z" - }, - special_keys = { - repeat_search = '', - next_phase_one_target = '', - next_target = {'', ';'}, - prev_target = {'', ','}, - next_group = '', - prev_group = '', - multi_accept = '', - multi_revert = '', - }, - } - ''; - }; - - binds.whichKey.register."s" = mkDefault "+Leap"; + after = '' + require('leap').opts = { + max_phase_one_targets = nil, + highlight_unlabeled_phase_one_targets = false, + max_highlighted_traversal_targets = 10, + case_sensitive = false, + equivalence_classes = { ' \t\r\n', }, + substitute_chars = {}, + safe_labels = { + "s", "f", "n", "u", "t", "/", + "S", "F", "N", "L", "H", "M", "U", "G", "T", "?", "Z" + }, + labels = { + "s", "f", "n", + "j", "k", "l", "h", "o", "d", "w", "e", "m", "b", + "u", "y", "v", "r", "g", "t", "c", "x", "/", "z", + "S", "F", "N", + "J", "K", "L", "H", "O", "D", "W", "E", "M", "B", + "U", "Y", "V", "R", "G", "T", "C", "X", "?", "Z" + }, + special_keys = { + repeat_search = '', + next_phase_one_target = '', + next_target = {'', ';'}, + prev_target = {'', ','}, + next_group = '', + prev_group = '', + multi_accept = '', + multi_revert = '', + }, + } + ''; + } + ]; }; }; } diff --git a/modules/plugins/utility/motion/leap/leap.nix b/modules/plugins/utility/motion/leap/leap.nix index 4e98f208..a5d72432 100644 --- a/modules/plugins/utility/motion/leap/leap.nix +++ b/modules/plugins/utility/motion/leap/leap.nix @@ -9,22 +9,22 @@ in { leapForwardTo = mkOption { type = nullOr str; description = "Leap forward to"; - default = "ss"; + default = "s"; }; leapBackwardTo = mkOption { type = nullOr str; description = "Leap backward to"; - default = "sS"; + default = "S"; }; leapForwardTill = mkOption { type = nullOr str; description = "Leap forward till"; - default = "sx"; + default = "x"; }; leapBackwardTill = mkOption { type = nullOr str; description = "Leap backward till"; - default = "sX"; + default = "X"; }; leapFromWindow = mkOption { type = nullOr str; diff --git a/modules/plugins/utility/surround/config.nix b/modules/plugins/utility/surround/config.nix index 4ce15cae..57520850 100644 --- a/modules/plugins/utility/surround/config.nix +++ b/modules/plugins/utility/surround/config.nix @@ -30,24 +30,26 @@ in { startPlugins = ["nvim-surround"]; pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})"; - lazy.plugins.nvim-surround = { - package = "nvim-surround"; - setupModule = "nvim-surround"; - inherit (cfg) setupOpts; + lazy.plugins = [ + { + package = "nvim-surround"; + setupModule = "nvim-surround"; + inherit (cfg) setupOpts; - keys = - map (mkLznKey ["i"]) (with vendoredKeybinds; [insert insert_line]) - ++ map (mkLznKey ["x"]) (with vendoredKeybinds; [visual visual_line]) - ++ map (mkLznKey ["n"]) (with vendoredKeybinds; [ - normal - normal_cur - normal_line - normal_cur_line - delete - change - change_line - ]); - }; + keys = + map (mkLznKey ["i"]) (with vendoredKeybinds; [insert insert_line]) + ++ map (mkLznKey ["x"]) (with vendoredKeybinds; [visual visual_line]) + ++ map (mkLznKey ["n"]) (with vendoredKeybinds; [ + normal + normal_cur + normal_line + normal_cur_line + delete + change + change_line + ]); + } + ]; utility.surround.setupOpts.keymaps = mkIf cfg.useVendoredKeybindings vendoredKeybinds; }; diff --git a/modules/plugins/utility/telescope/config.nix b/modules/plugins/utility/telescope/config.nix index 37bdc0f9..f50e955e 100644 --- a/modules/plugins/utility/telescope/config.nix +++ b/modules/plugins/utility/telescope/config.nix @@ -20,55 +20,57 @@ in { vim = { startPlugins = ["plenary-nvim"]; - lazy.plugins.telescope = { - package = "telescope"; - setupModule = "telescope"; - inherit (cfg) setupOpts; - # FIXME: how do I deal with extensions? set all as deps? - after = '' - local telescope = require("telescope") - ${optionalString config.vim.ui.noice.enable "telescope.load_extension('noice')"} - ${optionalString config.vim.notify.nvim-notify.enable "telescope.load_extension('notify')"} - ${optionalString config.vim.projects.project-nvim.enable "telescope.load_extension('projects')"} - ''; + lazy.plugins = [ + { + package = "telescope"; + setupModule = "telescope"; + inherit (cfg) setupOpts; + # FIXME: how do I deal with extensions? set all as deps? + after = '' + local telescope = require("telescope") + ${optionalString config.vim.ui.noice.enable "telescope.load_extension('noice')"} + ${optionalString config.vim.notify.nvim-notify.enable "telescope.load_extension('notify')"} + ${optionalString config.vim.projects.project-nvim.enable "telescope.load_extension('projects')"} + ''; - cmd = ["Telescope"]; + cmd = ["Telescope"]; - keys = - [ - (mkSetLznBinding mappings.findFiles " Telescope find_files") - (mkSetLznBinding mappings.liveGrep " Telescope live_grep") - (mkSetLznBinding mappings.buffers " Telescope buffers") - (mkSetLznBinding mappings.helpTags " Telescope help_tags") - (mkSetLznBinding mappings.open " Telescope") + keys = + [ + (mkSetLznBinding mappings.findFiles " Telescope find_files") + (mkSetLznBinding mappings.liveGrep " Telescope live_grep") + (mkSetLznBinding mappings.buffers " Telescope buffers") + (mkSetLznBinding mappings.helpTags " Telescope help_tags") + (mkSetLznBinding mappings.open " Telescope") - (mkSetLznBinding mappings.gitCommits " Telescope git_commits") - (mkSetLznBinding mappings.gitBufferCommits " Telescope git_bcommits") - (mkSetLznBinding mappings.gitBranches " Telescope git_branches") - (mkSetLznBinding mappings.gitStatus " Telescope git_status") - (mkSetLznBinding mappings.gitStash " Telescope git_stash") - ] - ++ (optionals config.vim.lsp.enable [ - (mkSetLznBinding mappings.lspDocumentSymbols " Telescope lsp_document_symbols") - (mkSetLznBinding mappings.lspWorkspaceSymbols " Telescope lsp_workspace_symbols") - - (mkSetLznBinding mappings.lspReferences " Telescope lsp_references") - (mkSetLznBinding mappings.lspImplementations " Telescope lsp_implementations") - (mkSetLznBinding mappings.lspDefinitions " Telescope lsp_definitions") - (mkSetLznBinding mappings.lspTypeDefinitions " Telescope lsp_type_definitions") - (mkSetLznBinding mappings.diagnostics " Telescope diagnostics") - ]) - ++ ( - optionals config.vim.treesitter.enable [ - (mkSetLznBinding mappings.treesitter " Telescope treesitter") + (mkSetLznBinding mappings.gitCommits " Telescope git_commits") + (mkSetLznBinding mappings.gitBufferCommits " Telescope git_bcommits") + (mkSetLznBinding mappings.gitBranches " Telescope git_branches") + (mkSetLznBinding mappings.gitStatus " Telescope git_status") + (mkSetLznBinding mappings.gitStash " Telescope git_stash") ] - ) - ++ ( - optionals config.vim.projects.project-nvim.enable [ - (mkSetLznBinding mappings.findProjects "") - ] - ); - }; + ++ (optionals config.vim.lsp.enable [ + (mkSetLznBinding mappings.lspDocumentSymbols " Telescope lsp_document_symbols") + (mkSetLznBinding mappings.lspWorkspaceSymbols " Telescope lsp_workspace_symbols") + + (mkSetLznBinding mappings.lspReferences " Telescope lsp_references") + (mkSetLznBinding mappings.lspImplementations " Telescope lsp_implementations") + (mkSetLznBinding mappings.lspDefinitions " Telescope lsp_definitions") + (mkSetLznBinding mappings.lspTypeDefinitions " Telescope lsp_type_definitions") + (mkSetLznBinding mappings.diagnostics " Telescope diagnostics") + ]) + ++ ( + optionals config.vim.treesitter.enable [ + (mkSetLznBinding mappings.treesitter " Telescope treesitter") + ] + ) + ++ ( + optionals config.vim.projects.project-nvim.enable [ + (mkSetLznBinding mappings.findProjects "") + ] + ); + } + ]; binds.whichKey.register = pushDownDefault { "f" = "+Telescope"; diff --git a/modules/plugins/visuals/fidget/config.nix b/modules/plugins/visuals/fidget/config.nix index 7c83cd96..6e81e9d6 100644 --- a/modules/plugins/visuals/fidget/config.nix +++ b/modules/plugins/visuals/fidget/config.nix @@ -8,11 +8,13 @@ cfg = config.vim.visuals.fidget-nvim; in { config = mkIf cfg.enable { - vim.lazy.plugins.fidget-nvim = { - package = "fidget-nvim"; - setupModule = "fidget"; - event = "LspAttach"; - inherit (cfg) setupOpts; - }; + vim.lazy.plugins = [ + { + package = "fidget-nvim"; + setupModule = "fidget"; + event = "LspAttach"; + inherit (cfg) setupOpts; + } + ]; }; } diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix index 100ee375..d575e644 100644 --- a/modules/wrapper/lazy/config.nix +++ b/modules/wrapper/lazy/config.nix @@ -3,8 +3,7 @@ config, ... }: let - inherit (builtins) toJSON typeOf head length filter concatLists concatStringsSep; - inherit (lib.attrsets) mapAttrsToList; + inherit (builtins) toJSON typeOf head length tryEval filter concatLists concatStringsSep; inherit (lib.modules) mkIf mkMerge; inherit (lib.generators) mkLuaInline; inherit (lib.strings) optionalString; @@ -22,7 +21,14 @@ else keySpec.action; }; - toLuaLznSpec = name: spec: + toLuaLznSpec = spec: let + name = + if typeOf spec.package == "string" + then spec.package + else if (spec.package ? pname && (tryEval spec.package.pname).success) + then spec.package.pname + else spec.package.name; + in (removeAttrs spec ["package" "setupModule" "setupOpts" "keys"]) // { "@1" = name; @@ -56,9 +62,9 @@ # empty list or str or (listOf str) else spec.keys; }; - lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins; + lznSpecs = map toLuaLznSpec cfg.plugins; - specToNotLazyConfig = _: spec: '' + specToNotLazyConfig = spec: '' do ${optionalString (spec.before != null) spec.before} ${optionalString (spec.setupModule != null) @@ -67,32 +73,34 @@ end ''; - specToKeymaps = _: spec: + specToKeymaps = spec: if typeOf spec.keys == "list" then map (x: removeAttrs x ["ft"]) (filter (lznKey: lznKey.action != null && lznKey.ft == null) spec.keys) else if spec.keys == null || typeOf spec.keys == "string" then [] else [spec.keys]; - notLazyConfig = concatStringsSep "\n" (mapAttrsToList specToNotLazyConfig cfg.plugins); + notLazyConfig = concatStringsSep "\n" (map specToNotLazyConfig cfg.plugins); in { config.vim = mkMerge [ (mkIf cfg.enable { startPlugins = ["lz-n" "lzn-auto-require"]; - optPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins; + optPlugins = map (plugin: plugin.package) cfg.plugins; luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] '' require('lz.n').load(${toLuaObject lznSpecs}) ''; }) - (mkIf (!cfg.enable) { - startPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins; - luaConfigPre = - concatStringsSep "\n" - (filter (x: x != null) (mapAttrsToList (_: spec: spec.beforeAll) cfg.plugins)); - luaConfigRC.unlazy = entryAfter ["pluginConfigs"] notLazyConfig; - keymaps = concatLists (mapAttrsToList specToKeymaps cfg.plugins); - }) + ( + mkIf (!cfg.enable) { + startPlugins = map (plugin: plugin.package) cfg.plugins; + luaConfigPre = + concatStringsSep "\n" + (filter (x: x != null) (map (spec: spec.beforeAll) cfg.plugins)); + luaConfigRC.unlazy = entryAfter ["pluginConfigs"] notLazyConfig; + keymaps = concatLists (map specToKeymaps cfg.plugins); + } + ) ]; } diff --git a/modules/wrapper/lazy/lazy.nix b/modules/wrapper/lazy/lazy.nix index 622d07f8..9b97bb8a 100644 --- a/modules/wrapper/lazy/lazy.nix +++ b/modules/wrapper/lazy/lazy.nix @@ -188,29 +188,19 @@ in { plugins = mkOption { default = []; - type = attrsOf lznPluginType; - description = '' - Plugins to lazy load. - - The attribute key is used as the plugin name: for the default `vim.g.lz_n.load` - function this should be either the `package.pname` or `package.name`. - ''; + type = listOf lznPluginType; + description = "list of plugins to lazy load"; example = '' - { - toggleterm-nvim = { + [ + { package = "toggleterm-nvim"; setupModule = "toggleterm"; setupOpts = cfg.setupOpts; after = "require('toggleterm').do_something()"; cmd = ["ToggleTerm"]; - }; - - $${pkgs.vimPlugins.vim-bbye.pname} = { - package = pkgs.vimPlugins.vim-bbye; - cmd = ["Bdelete" "Bwipeout"]; - }; - } + } + ] ''; }; }; diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index 1159b9fe..70ab2a8a 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -3,18 +3,27 @@ lib, ... }: let + inherit (lib.modules) mkRemovedOptionModule; inherit (lib.options) mkOption mkEnableOption literalMD literalExpression; inherit (lib.strings) optionalString; - inherit (lib.types) str attrs lines listOf either path; + inherit (lib.types) str attrs lines listOf either path bool; inherit (lib.nvim.types) dagOf; inherit (lib.nvim.lua) listToLuaTable; cfg = config.vim; in { + imports = [ + (mkRemovedOptionModule ["vim" "configRC"] '' + Please migrate your configRC sections to Neovim's Lua format, and + add them to luaConfigRC. + + See the v0.7 release notes for more information on how to migrate + your existing configurations. + '') + ]; + options.vim = { enableLuaLoader = mkEnableOption '' - [{option}`official documentation`]: https://neovim.io/doc/user/lua.html#vim.loader.enable() - the experimental Lua module loader to speed up the start up process If `true`, this will enable the experimental Lua module loader which: @@ -23,12 +32,30 @@ in { - adds the libs loader - removes the default Neovim loader - ::: {.note} This is disabled by default. Before setting this option, please - take a look at the [{option}`official documentation`]. - ::: + take a look at the [{option}`official documentation`](https://neovim.io/doc/user/lua.html#vim.loader.enable()). ''; + disableDefaultRuntimePaths = mkOption { + type = bool; + default = true; + example = false; + description = '' + Disables the default runtime paths that are set by Neovim + when it starts up. This is useful when you want to have + full control over the runtime paths that are set by Neovim. + + ::: {.note} + To avoid leaking imperative user configuration into your + configuration, this is enabled by default. If you wish + to load configuration from user configuration directories + (e.g. {file}`$HOME/.config/nvim`, {file}`$HOME/.config/nvim/after` + and {file}`$HOME/.local/share/nvim/site`) you may set this + option to true. + ::: + ''; + }; + additionalRuntimePaths = mkOption { type = listOf (either path str); default = []; @@ -153,6 +180,21 @@ in { vim.opt.runtimepath:append(${listToLuaTable cfg.additionalRuntimePaths}) ''} + ${optionalString cfg.disableDefaultRuntimePaths '' + -- Remove default user runtime paths from the + -- `runtimepath` option to avoid leaking user configuration + -- into the final neovim wrapper + local defaultRuntimePaths = { + vim.fn.stdpath('config'), -- $HOME/.config/nvim + vim.fn.stdpath('config') .. "/after", -- $HOME/.config/nvim/after + vim.fn.stdpath('data') .. "/site", -- $HOME/.local/share/nvim/site + } + + for _, path in ipairs(defaultRuntimePaths) do + vim.opt.runtimepath:remove(path) + end + ''} + ${optionalString cfg.enableLuaLoader "vim.loader.enable()"} '';