plugins/completion: normalize plugin defaults

This commit is contained in:
Matt Sturgeon 2024-06-11 16:51:18 +01:00
parent 48f1e30bf7
commit d61ecb3f73
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
5 changed files with 73 additions and 68 deletions

View file

@ -117,7 +117,7 @@ with lib;
autocomplete = autocomplete =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable
(with helpers.nixvimTypes; either (enum [ false ]) (listOf strLua)) (with helpers.nixvimTypes; either (enum [ false ]) (listOf strLua))
''["require('cmp.types').cmp.TriggerEvent.TextChanged"]'' [ "require('cmp.types').cmp.TriggerEvent.TextChanged" ]
'' ''
The event to trigger autocompletion. The event to trigger autocompletion.
If set to `false`, then completion is only invoked manually (e.g. by calling `cmp.complete`). If set to `false`, then completion is only invoked manually (e.g. by calling `cmp.complete`).
@ -148,7 +148,14 @@ with lib;
Boolean to show the `~` expandable indicator in cmp's floating window. Boolean to show the `~` expandable indicator in cmp's floating window.
''; '';
fields = helpers.defaultNullOpts.mkListOf types.str ''["abbr" "kind" "menu"]'' '' fields =
helpers.defaultNullOpts.mkListOf types.str
[
"abbr"
"kind"
"menu"
]
''
An array of completion fields to specify their order. An array of completion fields to specify their order.
''; '';
@ -234,12 +241,10 @@ with lib;
view = { view = {
entries = entries =
helpers.defaultNullOpts.mkNullable (with types; either str (attrsOf anything)) helpers.defaultNullOpts.mkNullable (with types; either str (attrsOf anything))
''
{ {
name = "custom"; name = "custom";
selection_order = "top_down"; selection_order = "top_down";
} }
''
'' ''
The view class used to customize nvim-cmp's appearance. The view class used to customize nvim-cmp's appearance.
''; '';
@ -267,9 +272,7 @@ with lib;
in in
{ {
completion = { completion = {
border = border = helpers.defaultNullOpts.mkBorder (genList (_: "") 8) "nvim-cmp completion popup menu" "";
helpers.defaultNullOpts.mkBorder ''[ "" "" "" "" "" "" "" "" ]'' "nvim-cmp completion popup menu"
"";
winhighlight = mkWinhighlightOption "Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None"; winhighlight = mkWinhighlightOption "Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None";
@ -294,10 +297,9 @@ with lib;
}; };
documentation = { documentation = {
border = border = helpers.defaultNullOpts.mkBorder (genList (
helpers.defaultNullOpts.mkBorder ''[ "" "" "" " " "" "" "" " " ]'' _: ""
"nvim-cmp documentation popup menu" ) 8) "nvim-cmp documentation popup menu" "";
"";
winhighlight = mkWinhighlightOption "FloatBorder:NormalFloat"; winhighlight = mkWinhighlightOption "FloatBorder:NormalFloat";

View file

@ -15,9 +15,13 @@ in
options.plugins.codeium-nvim = helpers.neovim-plugin.extraOptionsOptions // { options.plugins.codeium-nvim = helpers.neovim-plugin.extraOptionsOptions // {
package = helpers.mkPluginPackageOption "codeium.nvim" pkgs.vimPlugins.codeium-nvim; package = helpers.mkPluginPackageOption "codeium.nvim" pkgs.vimPlugins.codeium-nvim;
configPath = helpers.defaultNullOpts.mkStr ''{__raw = "vim.fn.stdpath('cache') .. '/codeium/config.json'";}'' "The path to the config file, used to store the API key."; configPath = helpers.defaultNullOpts.mkStr {
__raw = "vim.fn.stdpath('cache') .. '/codeium/config.json'";
} "The path to the config file, used to store the API key.";
binPath = helpers.defaultNullOpts.mkStr ''{__raw = "vim.fn.stdpath('cache') .. '/codeium/bin'";}'' "The path to the directory where the Codeium server will be downloaded to."; binPath = helpers.defaultNullOpts.mkStr {
__raw = "vim.fn.stdpath('cache') .. '/codeium/bin'";
} "The path to the directory where the Codeium server will be downloaded to.";
api = { api = {
host = helpers.defaultNullOpts.mkStr "server.codeium.com" '' host = helpers.defaultNullOpts.mkStr "server.codeium.com" ''

View file

@ -12,7 +12,11 @@ in
{ {
options.plugins.copilot-cmp = helpers.neovim-plugin.extraOptionsOptions // { options.plugins.copilot-cmp = helpers.neovim-plugin.extraOptionsOptions // {
event = event =
helpers.defaultNullOpts.mkNullable (with types; listOf str) ''["InsertEnter" "LspAttach"]'' helpers.defaultNullOpts.mkListOf types.str
[
"InsertEnter"
"LspAttach"
]
'' ''
Configures when the source is registered. Configures when the source is registered.
Unless you have a unique problem for your particular configuration you probably don't want Unless you have a unique problem for your particular configuration you probably don't want

View file

@ -65,14 +65,12 @@ helpers.vim-plugin.mkVimPlugin config {
filetypes = filetypes =
helpers.defaultNullOpts.mkAttrsOf types.bool helpers.defaultNullOpts.mkAttrsOf types.bool
''
{ {
help = false; help = false;
gitcommit = false; gitcommit = false;
gitrebase = false; gitrebase = false;
"." = false; "." = false;
} }
''
'' ''
A dictionary mapping whether codeium should be enabled or disabled in certain filetypes. A dictionary mapping whether codeium should be enabled or disabled in certain filetypes.
This can be used to opt out of completions for certain filetypes. This can be used to opt out of completions for certain filetypes.

View file

@ -40,19 +40,18 @@ in
layout = { layout = {
position = position =
helpers.defaultNullOpts.mkEnum helpers.defaultNullOpts.mkEnumFirstDefault
[ [
"bottom" "bottom"
"top" "top"
"left" "left"
"right" "right"
] ]
"bottom"
'' ''
The panel position. The panel position.
''; '';
ratio = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) "0.4" '' ratio = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.4 ''
The panel ratio. The panel ratio.
''; '';
}; };
@ -68,9 +67,9 @@ in
keymap = { keymap = {
accept = keymapOption "<M-l>" "Keymap for accepting the suggestion."; accept = keymapOption "<M-l>" "Keymap for accepting the suggestion.";
acceptWord = keymapOption "false" "Keymap for accepting a word suggestion."; acceptWord = keymapOption false "Keymap for accepting a word suggestion.";
acceptLine = keymapOption "false" "Keymap for accepting a line suggestion."; acceptLine = keymapOption false "Keymap for accepting a line suggestion.";
next = keymapOption "<M-]>" "Keymap for accepting the next suggestion."; next = keymapOption "<M-]>" "Keymap for accepting the next suggestion.";
@ -81,8 +80,7 @@ in
}; };
filetypes = filetypes =
helpers.defaultNullOpts.mkNullable (with types; attrsOf (either bool helpers.nixvimTypes.rawLua)) helpers.defaultNullOpts.mkAttrsOf types.bool
''
{ {
yaml = false; yaml = false;
markdown = false; markdown = false;
@ -94,7 +92,6 @@ in
cvs = false; cvs = false;
"." = false; "." = false;
} }
''
'' ''
Specify filetypes for attaching copilot. Specify filetypes for attaching copilot.
Each value can be either a boolean or a lua function that returns a boolean. Each value can be either a boolean or a lua function that returns a boolean.
@ -137,7 +134,10 @@ in
''; '';
}; };
serverOptsOverrides = helpers.defaultNullOpts.mkNullable types.attrs "{}" '' serverOptsOverrides = helpers.defaultNullOpts.mkAttrsOf' {
type = types.anything;
pluginDefault = { };
description = ''
Override copilot lsp client `settings`. Override copilot lsp client `settings`.
The settings field is where you can set the values of the options defined in The settings field is where you can set the values of the options defined in
https://github.com/zbirenbaum/copilot.lua/blob/master/SettingsOpts.md. https://github.com/zbirenbaum/copilot.lua/blob/master/SettingsOpts.md.
@ -147,10 +147,8 @@ in
numerous checks to verify copilot is actually running. numerous checks to verify copilot is actually running.
See `:h vim.lsp.start_client` for list of options. See `:h vim.lsp.start_client` for list of options.
'';
Example: example = {
```nix
{
trace = "verbose"; trace = "verbose";
settings = { settings = {
advanced = { advanced = {
@ -158,9 +156,8 @@ in
inlineSuggestCount = 3; # number of completions for getCompletions inlineSuggestCount = 3; # number of completions for getCompletions
}; };
}; };
} };
``` };
'';
}; };
}; };