mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-10 09:14:31 +02:00
plugins/coq: Switch to mkNeovimPlugin (#1256)
* plugins/coq: Switch to mkNeovimPlugin This allows the user to define additional options unpackaged by nixvim. No new options were defined, nor any old option was deleted. Fixes #1114
This commit is contained in:
parent
8c3fa2e9ce
commit
6484938d4b
2 changed files with 83 additions and 40 deletions
|
@ -5,56 +5,74 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib;
|
||||||
cfg = config.plugins.coq-nvim;
|
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||||
in {
|
name = "coq-nvim";
|
||||||
options = {
|
originalName = "coq_nvim";
|
||||||
plugins.coq-nvim = {
|
defaultPackage = pkgs.vimPlugins.coq_nvim;
|
||||||
enable = mkEnableOption "coq-nvim";
|
|
||||||
|
|
||||||
package = helpers.mkPackageOption "coq-nvim" pkgs.vimPlugins.coq_nvim;
|
maintainers = [maintainers.traxys];
|
||||||
|
|
||||||
|
extraOptions = {
|
||||||
installArtifacts = mkEnableOption "and install coq-artifacts";
|
installArtifacts = mkEnableOption "and install coq-artifacts";
|
||||||
|
artifactsPackage = mkOption {
|
||||||
autoStart = mkOption {
|
type = types.package;
|
||||||
type = with types; nullOr (oneOf [bool (enum ["shut-up"])]);
|
description = "Package to use for coq-artifacts (when enabled with installArtifacts)";
|
||||||
default = null;
|
default = pkgs.vimPlugins.coq-artifacts;
|
||||||
description = "Auto-start or shut up";
|
|
||||||
};
|
|
||||||
|
|
||||||
recommendedKeymaps = mkOption {
|
|
||||||
type = with types; nullOr bool;
|
|
||||||
default = null;
|
|
||||||
description = "Use the recommended keymaps";
|
|
||||||
};
|
|
||||||
|
|
||||||
alwaysComplete = mkOption {
|
|
||||||
type = with types; nullOr bool;
|
|
||||||
default = null;
|
|
||||||
description = "Always trigger completion on keystroke";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
config = let
|
# TODO: Introduced 12-03-2022, remove 12-05-2022
|
||||||
settings = {
|
optionsRenamedToSettings = [
|
||||||
auto_start = cfg.autoStart;
|
"xdg"
|
||||||
"keymap.recommended" = cfg.recommendedKeymaps;
|
"autoStart"
|
||||||
xdg = true;
|
];
|
||||||
"completion.always" = cfg.alwaysComplete;
|
imports = let
|
||||||
|
basePath = ["plugins" "coq-nvim"];
|
||||||
|
settingsPath = basePath ++ ["settings"];
|
||||||
|
in [
|
||||||
|
(
|
||||||
|
mkRenamedOptionModule
|
||||||
|
(basePath ++ ["recommendedKeymaps"])
|
||||||
|
(settingsPath ++ ["keymap" "recommended"])
|
||||||
|
)
|
||||||
|
|
||||||
|
(
|
||||||
|
mkRenamedOptionModule
|
||||||
|
(basePath ++ ["alwaysComplete"])
|
||||||
|
(settingsPath ++ ["completion" "always"])
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
callSetup = false;
|
||||||
|
settingsOptions = {
|
||||||
|
auto_start =
|
||||||
|
helpers.mkNullOrOption
|
||||||
|
(with helpers.nixvimTypes; maybeRaw (either bool (enum ["shut-up"])))
|
||||||
|
"Auto-start or shut up";
|
||||||
|
|
||||||
|
xdg = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "Use XDG paths. May be required when installing coq with Nix.";
|
||||||
|
};
|
||||||
|
|
||||||
|
keymap.recommended = helpers.defaultNullOpts.mkBool true "Use the recommended keymaps";
|
||||||
|
|
||||||
|
completion.always = helpers.defaultNullOpts.mkBool true "Always trigger completion on keystroke";
|
||||||
};
|
};
|
||||||
in
|
|
||||||
mkIf cfg.enable {
|
extraConfig = cfg: {
|
||||||
extraPlugins =
|
extraPlugins = mkIf cfg.installArtifacts [
|
||||||
[
|
cfg.artifactsPackage
|
||||||
cfg.package
|
];
|
||||||
]
|
|
||||||
++ optional cfg.installArtifacts pkgs.vimPlugins.coq-artifacts;
|
|
||||||
plugins.lsp = {
|
plugins.lsp = {
|
||||||
preConfig = ''
|
preConfig = ''
|
||||||
vim.g.coq_settings = ${helpers.toLuaObject settings}
|
vim.g.coq_settings = ${helpers.toLuaObject cfg.settings}
|
||||||
local coq = require 'coq'
|
local coq = require 'coq'
|
||||||
'';
|
'';
|
||||||
setupWrappers = [(s: ''coq.lsp_ensure_capabilities(${s})'')];
|
setupWrappers = [(s: ''coq.lsp_ensure_capabilities(${s})'')];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
25
tests/test-sources/plugins/completion/coq.nix
Normal file
25
tests/test-sources/plugins/completion/coq.nix
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
empty = {
|
||||||
|
plugins.coq-nvim.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
nixvim-defaults = {
|
||||||
|
plugins.coq-nvim = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
xdg = true;
|
||||||
|
auto_start = true;
|
||||||
|
keymap.recommended = true;
|
||||||
|
completion.always = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
artifacts = {
|
||||||
|
plugins.coq-nvim = {
|
||||||
|
enable = true;
|
||||||
|
installArtifacts = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue