diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 167fb09f..39d92e36 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,43 +29,7 @@ Most of nixvim is dedicated to wrapping neovim plugin such that we can configure To add a new plugin you need to do the following. 1. Add a file in the correct sub-directory of [plugins](plugins). This depends on your exact plugin. - You will most certainly need the `helpers`, they can be added by doing something like: - - ```nix - { - lib, - pkgs, - ... - } @ args: - - let - helpers = import ../helpers.nix args; - in { - } - ``` - -2. Create the minimal options for a new plugin (in `options.plugins.`: - - - `enable = mkEnableOption ...` to toggle the plugin. - - `package = helpers.mkPackageOption ...` to change the package options. - -3. Add the plugin package to the installed plugins if it is enabled. This can be done with the following: - - ```nix - { - config = - let - cfg = config.plugins.""; - - in lib.mkIf cfg.enable { - extraPlugins = [cfg.package]; - - extraConfigLua = '' - - ''; - }; - } - ``` +2. Write the code for the corresponding nixvim module. You can start from the [template](plugins/TEMPLATE.nix). You will then need to add Nix options for all (or most) of the upstream plugin options. These options should be in `camelCase` (whereas most plugins define their options in `snake_case`), and their names should match exactly (except the case) to the upstream names. diff --git a/plugins/completion/nvim-cmp/cmp-helpers.nix b/plugins/completion/nvim-cmp/cmp-helpers.nix index d98c9288..c90ec569 100644 --- a/plugins/completion/nvim-cmp/cmp-helpers.nix +++ b/plugins/completion/nvim-cmp/cmp-helpers.nix @@ -1,66 +1,65 @@ { lib, + helpers, config, pkgs, ... -}: let - helpers = import ../../helpers.nix {inherit lib;}; -in - with helpers.vim-plugin; - with lib; { - mkCmpSourcePlugin = { - name, - extraPlugins ? [], - useDefaultPackage ? true, - ... - }: - mkVimPlugin config { - inherit name; - extraPlugins = extraPlugins ++ (lists.optional useDefaultPackage pkgs.vimPlugins.${name}); - }; - - pluginAndSourceNames = { - "buffer" = "cmp-buffer"; - "calc" = "cmp-calc"; - "dap" = "cmp-dap"; - "cmdline" = "cmp-cmdline"; - "cmp-clippy" = "cmp-clippy"; - "cmp-cmdline-history" = "cmp-cmdline-history"; - "cmp_pandoc" = "cmp-pandoc-nvim"; - "cmp_tabby" = "cmp-tabby"; - "cmp_tabnine" = "cmp-tabnine"; - "codeium" = "codeium-nvim"; - "conventionalcommits" = "cmp-conventionalcommits"; - "copilot" = "copilot-cmp"; - "crates" = "crates-nvim"; - "dictionary" = "cmp-dictionary"; - "digraphs" = "cmp-digraphs"; - "emoji" = "cmp-emoji"; - "fish" = "cmp-fish"; - "fuzzy_buffer" = "cmp-fuzzy-buffer"; - "fuzzy_path" = "cmp-fuzzy-path"; - "git" = "cmp-git"; - "greek" = "cmp-greek"; - "latex_symbols" = "cmp-latex-symbols"; - "look" = "cmp-look"; - "luasnip" = "cmp_luasnip"; - "nvim_lsp" = "cmp-nvim-lsp"; - "nvim_lsp_document_symbol" = "cmp-nvim-lsp-document-symbol"; - "nvim_lsp_signature_help" = "cmp-nvim-lsp-signature-help"; - "nvim_lua" = "cmp-nvim-lua"; - "npm" = "cmp-npm"; - "omni" = "cmp-omni"; - "pandoc_references" = "cmp-pandoc-references"; - "path" = "cmp-path"; - "rg" = "cmp-rg"; - "snippy" = "cmp-snippy"; - "spell" = "cmp-spell"; - "tmux" = "cmp-tmux"; - "treesitter" = "cmp-treesitter"; - "ultisnips" = "cmp-nvim-ultisnips"; - "vim_lsp" = "cmp-vim-lsp"; - "vimwiki-tags" = "cmp-vimwiki-tags"; - "vsnip" = "cmp-vsnip"; - "zsh" = "cmp-zsh"; +}: +with helpers.vim-plugin; +with lib; { + mkCmpSourcePlugin = { + name, + extraPlugins ? [], + useDefaultPackage ? true, + ... + }: + mkVimPlugin config { + inherit name; + extraPlugins = extraPlugins ++ (lists.optional useDefaultPackage pkgs.vimPlugins.${name}); }; - } + + pluginAndSourceNames = { + "buffer" = "cmp-buffer"; + "calc" = "cmp-calc"; + "dap" = "cmp-dap"; + "cmdline" = "cmp-cmdline"; + "cmp-clippy" = "cmp-clippy"; + "cmp-cmdline-history" = "cmp-cmdline-history"; + "cmp_pandoc" = "cmp-pandoc-nvim"; + "cmp_tabby" = "cmp-tabby"; + "cmp_tabnine" = "cmp-tabnine"; + "codeium" = "codeium-nvim"; + "conventionalcommits" = "cmp-conventionalcommits"; + "copilot" = "copilot-cmp"; + "crates" = "crates-nvim"; + "dictionary" = "cmp-dictionary"; + "digraphs" = "cmp-digraphs"; + "emoji" = "cmp-emoji"; + "fish" = "cmp-fish"; + "fuzzy_buffer" = "cmp-fuzzy-buffer"; + "fuzzy_path" = "cmp-fuzzy-path"; + "git" = "cmp-git"; + "greek" = "cmp-greek"; + "latex_symbols" = "cmp-latex-symbols"; + "look" = "cmp-look"; + "luasnip" = "cmp_luasnip"; + "nvim_lsp" = "cmp-nvim-lsp"; + "nvim_lsp_document_symbol" = "cmp-nvim-lsp-document-symbol"; + "nvim_lsp_signature_help" = "cmp-nvim-lsp-signature-help"; + "nvim_lua" = "cmp-nvim-lua"; + "npm" = "cmp-npm"; + "omni" = "cmp-omni"; + "pandoc_references" = "cmp-pandoc-references"; + "path" = "cmp-path"; + "rg" = "cmp-rg"; + "snippy" = "cmp-snippy"; + "spell" = "cmp-spell"; + "tmux" = "cmp-tmux"; + "treesitter" = "cmp-treesitter"; + "ultisnips" = "cmp-nvim-ultisnips"; + "vim_lsp" = "cmp-vim-lsp"; + "vimwiki-tags" = "cmp-vimwiki-tags"; + "vsnip" = "cmp-vsnip"; + "zsh" = "cmp-zsh"; + }; +} diff --git a/plugins/completion/nvim-cmp/sources/default.nix b/plugins/completion/nvim-cmp/sources/default.nix index a0c6c01a..54927b09 100644 --- a/plugins/completion/nvim-cmp/sources/default.nix +++ b/plugins/completion/nvim-cmp/sources/default.nix @@ -1,11 +1,12 @@ { lib, config, + helpers, pkgs, ... }: with lib; let - cmpLib = import ../cmp-helpers.nix {inherit lib config pkgs;}; + cmpLib = import ../cmp-helpers.nix {inherit lib config helpers pkgs;}; cmpSourcesPluginNames = attrValues cmpLib.pluginAndSourceNames; pluginModules = lists.map (name: cmpLib.mkCmpSourcePlugin {inherit name;}) cmpSourcesPluginNames; in { diff --git a/plugins/dap/dap-go.nix b/plugins/dap/dap-go.nix index e926a574..47f92ef5 100644 --- a/plugins/dap/dap-go.nix +++ b/plugins/dap/dap-go.nix @@ -7,7 +7,7 @@ }: with lib; let cfg = config.plugins.dap.extensions.dap-go; - dapHelpers = import ./dapHelpers.nix {inherit lib;}; + dapHelpers = import ./dapHelpers.nix {inherit lib helpers;}; in { options.plugins.dap.extensions.dap-go = { enable = mkEnableOption "dap-go"; diff --git a/plugins/dap/dap-python.nix b/plugins/dap/dap-python.nix index 72464419..9e10fd5a 100644 --- a/plugins/dap/dap-python.nix +++ b/plugins/dap/dap-python.nix @@ -7,7 +7,7 @@ }: with lib; let cfg = config.plugins.dap.extensions.dap-python; - dapHelpers = import ./dapHelpers.nix {inherit lib;}; + dapHelpers = import ./dapHelpers.nix {inherit lib helpers;}; in { options.plugins.dap.extensions.dap-python = { enable = mkEnableOption "dap-python"; diff --git a/plugins/dap/dapHelpers.nix b/plugins/dap/dapHelpers.nix index 9112aebb..ef724773 100644 --- a/plugins/dap/dapHelpers.nix +++ b/plugins/dap/dapHelpers.nix @@ -1,7 +1,8 @@ -{lib, ...}: -with lib; let - helpers = import ../helpers.nix {inherit lib;}; -in rec { +{ + lib, + helpers, +}: +with lib; rec { mkAdapterType = attrs: types.submodule { options = diff --git a/plugins/dap/default.nix b/plugins/dap/default.nix index 6dec9830..60469c39 100644 --- a/plugins/dap/default.nix +++ b/plugins/dap/default.nix @@ -7,7 +7,7 @@ }: with lib; let cfg = config.plugins.dap; - dapHelpers = import ./dapHelpers.nix {inherit lib;}; + dapHelpers = import ./dapHelpers.nix {inherit lib helpers;}; in with dapHelpers; { imports = [ diff --git a/plugins/languages/treesitter/ts-autotag.nix b/plugins/languages/treesitter/ts-autotag.nix index c2d6bebc..3ce3e4fb 100644 --- a/plugins/languages/treesitter/ts-autotag.nix +++ b/plugins/languages/treesitter/ts-autotag.nix @@ -1,12 +1,11 @@ { pkgs, lib, + helpers, config, ... }: -with lib; let - helpers = import ../../helpers.nix {inherit lib;}; -in { +with lib; { options.plugins.ts-autotag = helpers.neovim-plugin.extraOptionsOptions // { diff --git a/plugins/lsp/helpers.nix b/plugins/lsp/helpers.nix index e5092931..82ceb45a 100644 --- a/plugins/lsp/helpers.nix +++ b/plugins/lsp/helpers.nix @@ -13,13 +13,12 @@ { pkgs, config, + helpers, lib, - options, ... }: with lib; let cfg = config.plugins.lsp.servers.${name}; - helpers = import ../helpers.nix {inherit lib;}; packageOption = if package != null diff --git a/plugins/lsp/language-servers/default.nix b/plugins/lsp/language-servers/default.nix index 86b0ec4d..d282395c 100644 --- a/plugins/lsp/language-servers/default.nix +++ b/plugins/lsp/language-servers/default.nix @@ -303,7 +303,7 @@ with lib; let name = "ltex"; description = "ltex-ls for LanguageTool"; package = pkgs.ltex-ls; - settingsOptions = import ./ltex-settings.nix {inherit lib;}; + settingsOptions = import ./ltex-settings.nix {inherit lib helpers;}; settings = cfg: {ltex = cfg;}; } { diff --git a/plugins/lsp/language-servers/ltex-settings.nix b/plugins/lsp/language-servers/ltex-settings.nix index 7a927829..b0822960 100644 --- a/plugins/lsp/language-servers/ltex-settings.nix +++ b/plugins/lsp/language-servers/ltex-settings.nix @@ -1,7 +1,8 @@ -{lib}: -with lib; let - helpers = import ../../helpers.nix {inherit lib;}; -in { +{ + lib, + helpers, +}: +with lib; { enabled = helpers.defaultNullOpts.mkNullable (with types; either bool (listOf str)) diff --git a/plugins/none-ls/helpers.nix b/plugins/none-ls/helpers.nix index f6cdbcbb..d3949e9c 100644 --- a/plugins/none-ls/helpers.nix +++ b/plugins/none-ls/helpers.nix @@ -12,10 +12,10 @@ pkgs, config, lib, + helpers, ... - } @ args: + }: with lib; let - helpers = import ../helpers.nix args; cfg = config.plugins.none-ls.sources.${sourceType}.${name}; # does this evaluate package? packageOption = diff --git a/plugins/none-ls/servers.nix b/plugins/none-ls/servers.nix index e26cc48e..b89c25fc 100644 --- a/plugins/none-ls/servers.nix +++ b/plugins/none-ls/servers.nix @@ -5,7 +5,7 @@ ... }: with lib; let - helpers = import ./helpers.nix; + cmpHelpers = import ./helpers.nix; serverData = { code_actions = { eslint = { @@ -228,7 +228,7 @@ with lib; let dataFlattened = flatten serverDataFormatted; in { imports = - (map helpers.mkServer dataFlattened) + (map cmpHelpers.mkServer dataFlattened) ++ [ ./prettier.nix # Introduced January 22 2024.