Compare commits

...

9 commits

Author SHA1 Message Date
diniamo
b2300d276b
Merge 2b3c0cde23 into ef413736e9 2024-10-08 22:10:38 +00:00
diniamo
2b3c0cde23 nvim-dap: use outer attribute 2024-10-09 00:10:34 +02:00
diniamo
630b8ffe51 nvim-autopairs: use multiline string 2024-10-08 23:02:30 +02:00
diniamo
1ebc002042 deprecations: add entry for vsnip 2024-10-08 22:57:46 +02:00
diniamo
ebda97a032 luasnip: add missing {option} for option reference 2024-10-08 22:55:38 +02:00
diniamo
6921ac4e4e treewide: remove reduant // {default = false;}s 2024-10-08 22:54:50 +02:00
raf
ef413736e9
Merge branch 'main' into v0.7 2024-10-07 00:40:13 +00:00
Ching Pei Yang
e77632e4eb
lib: remove pointless type restriction (#408)
Some checks failed
Set up binary cache / cachix (default) (push) Has been cancelled
Set up binary cache / cachix (maximal) (push) Has been cancelled
Set up binary cache / cachix (nix) (push) Has been cancelled
Validate flake & check formatting / Validate Flake (push) Has been cancelled
Validate flake & check formatting / Formatting via Alejandra (push) Has been cancelled
2024-10-06 23:19:39 +00:00
Ching Pei Yang
b39b84490f
Docs/map rewrite (#403)
* doc: fix formatting

* docs: update keymaps section
2024-10-06 14:03:21 +00:00
9 changed files with 68 additions and 70 deletions

View file

@ -7,37 +7,26 @@ section contains a general overview to how you may utilize said functions.
## Custom Key Mappings Support for a Plugin {#sec-custom-key-mappings} ## Custom Key Mappings Support for a Plugin {#sec-custom-key-mappings}
To set a mapping, you should define it in `vim.maps.<<mode>>`. To set a mapping, you should define it in `vim.keymaps`.
The available modes are:
- normal
- insert
- select
- visual
- terminal
- normalVisualOp
- visualOnly
- operator
- insertCommand
- lang
- command
An example, simple keybinding, can look like this: An example, simple keybinding, can look like this:
```nix ```nix
{ {
vim.maps.normal = { vim.keymaps = [
"<leader>wq" = { {
key = "<leader>wq";
mode = ["n"];
action = ":wq<CR>"; action = ":wq<CR>";
silent = true; silent = true;
desc = "Save file and quit"; desc = "Save file and quit";
}; }
}; ];
} }
``` ```
There are many settings available in the options. Please refer to the There are many settings available in the options. Please refer to the
[documentation](https://notashelf.github.io/nvf/options.html#opt-vim.maps.command._name_.action) [documentation](https://notashelf.github.io/nvf/options.html#opt-vim.keymaps)
to see a list of them. to see a list of them.
**nvf** provides a list of helper commands, so that you don't have to write the **nvf** provides a list of helper commands, so that you don't have to write the

View file

@ -97,7 +97,7 @@ in {
default = {}; default = {};
type = submodule { type = submodule {
freeformType = attrsOf anything; freeformType = anything;
options = opts; options = opts;
}; };
}; };

View file

@ -31,6 +31,9 @@ in {
vim.autocomplete.type has been removed in favor of per-plugin modules. vim.autocomplete.type has been removed in favor of per-plugin modules.
You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead. You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable 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"]) (mkRenamedOptionModule ["vim" "lsp" "lspkind" "mode"] ["vim" "lsp" "lspkind" "setupOpts" "mode"])
]; ];
} }

View file

@ -1,5 +1,5 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkOption; inherit (lib.options) mkOption literalMD;
inherit (lib.types) either str listOf attrsOf nullOr submodule; inherit (lib.types) either str listOf attrsOf nullOr submodule;
inherit (lib.nvim.config) mkBool; inherit (lib.nvim.config) mkBool;
@ -42,7 +42,7 @@
See `:help map-modes` for a list of modes. See `:help map-modes` for a list of modes.
''; '';
example = ''`["n" "v" "c"]` for normal, visual and command mode''; example = literalMD ''`["n" "v" "c"]` for normal, visual and command mode'';
}; };
}; };
}; };

View file

@ -12,7 +12,9 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
startPlugins = ["nvim-autopairs"]; startPlugins = ["nvim-autopairs"];
pluginRC.autopairs = entryAnywhere "require('nvim-autopairs').setup(${toLuaObject cfg.setupOpts})"; pluginRC.autopairs = entryAnywhere ''
require('nvim-autopairs').setup(${toLuaObject cfg.setupOpts})
'';
}; };
}; };
} }

View file

@ -8,7 +8,7 @@ in {
]; ];
options.vim.autopairs.nvim-autopairs = { options.vim.autopairs.nvim-autopairs = {
enable = mkEnableOption "autopairs" // {default = false;}; enable = mkEnableOption "autopairs";
setupOpts = mkPluginSetupOption "nvim-autopairs" {}; setupOpts = mkPluginSetupOption "nvim-autopairs" {};
}; };
} }

View file

@ -14,7 +14,7 @@
cfg = config.vim.autocomplete.nvim-cmp; cfg = config.vim.autocomplete.nvim-cmp;
in { in {
options.vim.autocomplete.nvim-cmp = { options.vim.autocomplete.nvim-cmp = {
enable = mkEnableOption "nvim-cmp" // {default = false;}; enable = mkEnableOption "nvim-cmp";
setupOpts = mkPluginSetupOption "the autocomplete plugin" { setupOpts = mkPluginSetupOption "the autocomplete plugin" {
completion.completeopt = mkOption { completion.completeopt = mkOption {
type = str; type = str;

View file

@ -16,9 +16,10 @@
in { in {
config = mkMerge [ config = mkMerge [
(mkIf cfg.enable { (mkIf cfg.enable {
vim.startPlugins = ["nvim-dap"]; vim = {
startPlugins = ["nvim-dap"];
vim.pluginRC = pluginRC =
{ {
# TODO customizable keymaps # TODO customizable keymaps
nvim-dap = entryAnywhere '' nvim-dap = entryAnywhere ''
@ -28,7 +29,7 @@ in {
} }
// mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources; // mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources;
vim.maps.normal = mkMerge [ maps.normal = mkMerge [
(mkSetLuaBinding mappings.continue "require('dap').continue") (mkSetLuaBinding mappings.continue "require('dap').continue")
(mkSetLuaBinding mappings.restart "require('dap').restart") (mkSetLuaBinding mappings.restart "require('dap').restart")
(mkSetLuaBinding mappings.terminate "require('dap').terminate") (mkSetLuaBinding mappings.terminate "require('dap').terminate")
@ -47,11 +48,13 @@ in {
(mkSetLuaBinding mappings.goUp "require('dap').up") (mkSetLuaBinding mappings.goUp "require('dap').up")
(mkSetLuaBinding mappings.goDown "require('dap').down") (mkSetLuaBinding mappings.goDown "require('dap').down")
]; ];
};
}) })
(mkIf (cfg.enable && cfg.ui.enable) { (mkIf (cfg.enable && cfg.ui.enable) {
vim.startPlugins = ["nvim-dap-ui" "nvim-nio"]; vim = {
startPlugins = ["nvim-dap-ui" "nvim-nio"];
vim.pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] ('' pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] (''
local dapui = require("dapui") local dapui = require("dapui")
dapui.setup() dapui.setup()
'' ''
@ -66,7 +69,8 @@ in {
dapui.close() dapui.close()
end end
''); '');
vim.maps.normal = mkSetLuaBinding mappings.toggleDapUI "require('dapui').toggle"; maps.normal = mkSetLuaBinding mappings.toggleDapUI "require('dapui').toggle";
};
}) })
]; ];
} }

View file

@ -4,7 +4,7 @@
inherit (lib.nvim.types) pluginType; inherit (lib.nvim.types) pluginType;
in { in {
options.vim.snippets.luasnip = { options.vim.snippets.luasnip = {
enable = mkEnableOption "luasnip" // {default = false;}; enable = mkEnableOption "luasnip";
providers = mkOption { providers = mkOption {
type = listOf pluginType; type = listOf pluginType;
default = ["friendly-snippets"]; default = ["friendly-snippets"];
@ -12,7 +12,7 @@ in {
The snippet provider packages. The snippet provider packages.
::: {.note} ::: {.note}
These are simply appended to `vim.startPlugins`. These are simply appended to {option} `vim.startPlugins`.
::: :::
''; '';
example = literalExpression "[\"vimPlugins.vim-snippets\"]"; example = literalExpression "[\"vimPlugins.vim-snippets\"]";