mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 02:11:33 +00:00
modules/autopairs
feat: apply new module format to nvim-autopairs
This commit is contained in:
parent
f567b08e92
commit
b917526be7
8 changed files with 325 additions and 268 deletions
|
@ -1,43 +1,5 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.autopairs;
|
||||
in {
|
||||
options.vim = {
|
||||
autopairs = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "enable autopairs";
|
||||
};
|
||||
|
||||
type = mkOption {
|
||||
type = types.enum ["nvim-autopairs"];
|
||||
default = "nvim-autopairs";
|
||||
description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
mkIf cfg.enable
|
||||
{
|
||||
vim.startPlugins = ["nvim-autopairs"];
|
||||
|
||||
vim.luaConfigRC.autopairs = nvim.dag.entryAnywhere ''
|
||||
require("nvim-autopairs").setup{}
|
||||
${optionalString (config.vim.autocomplete.type == "nvim-compe") ''
|
||||
require('nvim-autopairs.completion.compe').setup({
|
||||
map_cr = true,
|
||||
map_complete = true,
|
||||
auto_select = false,
|
||||
})
|
||||
''}
|
||||
'';
|
||||
};
|
||||
_: {
|
||||
imports = [
|
||||
./nvim-autopairs
|
||||
];
|
||||
}
|
||||
|
|
27
modules/autopairs/nvim-autopairs/config.nix
Normal file
27
modules/autopairs/nvim-autopairs/config.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.autopairs;
|
||||
in {
|
||||
config =
|
||||
mkIf (cfg.enable)
|
||||
{
|
||||
vim.startPlugins = ["nvim-autopairs"];
|
||||
|
||||
vim.luaConfigRC.autopairs = nvim.dag.entryAnywhere ''
|
||||
require("nvim-autopairs").setup{}
|
||||
${optionalString (config.vim.autocomplete.type == "nvim-compe") ''
|
||||
require('nvim-autopairs.completion.compe').setup({
|
||||
map_cr = ${boolToString cfg.nvim-compe.map_cr},
|
||||
map_complete = ${boolToString cfg.nvim-compe.map_complete},
|
||||
auto_select = ${boolToString cfg.nvim-compe.auto_select},
|
||||
})
|
||||
''}
|
||||
'';
|
||||
};
|
||||
}
|
6
modules/autopairs/nvim-autopairs/default.nix
Normal file
6
modules/autopairs/nvim-autopairs/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./nvim-autopairs.nix
|
||||
];
|
||||
}
|
46
modules/autopairs/nvim-autopairs/nvim-autopairs.nix
Normal file
46
modules/autopairs/nvim-autopairs/nvim-autopairs.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.autopairs;
|
||||
in {
|
||||
options.vim = {
|
||||
autopairs = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "enable autopairs";
|
||||
};
|
||||
|
||||
type = mkOption {
|
||||
type = types.enum ["nvim-autopairs"];
|
||||
default = "nvim-autopairs";
|
||||
description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]";
|
||||
};
|
||||
|
||||
nvim-compe = {
|
||||
map_cr = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "map <CR> on insert mode";
|
||||
};
|
||||
|
||||
map_complete = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "auto insert `(` after select function or method item";
|
||||
};
|
||||
|
||||
auto_select = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "auto select first item";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue