Compare commits

..

12 commits

Author SHA1 Message Date
Ching Pei Yang
b8aed0e102
Merge 88393d6a78 into 3c4eced9d1 2024-10-17 17:14:27 +00:00
Ching Pei Yang
88393d6a78
Merge branch 'v0.7' into feature/lzn 2024-10-17 19:14:05 +02:00
Pei Yang Ching
665f0fa106 lazy: cleanup 2024-10-17 17:29:25 +02:00
Pei Yang Ching
256a8cf62c docs: update lazy.plugins syntax 2024-10-17 17:20:35 +02:00
Pei Yang Ching
d49e46ab16 treewide: update lazy.plugins syntax 2024-10-17 17:20:35 +02:00
Pei Yang Ching
854fd340e3 lazy: use attrsOf for lazy.plugins 2024-10-17 17:20:35 +02:00
diniamo
3c4eced9d1
docs: add missing deprecation notes (#420) 2024-10-17 15:19:37 +02:00
diniamo
ff9b0eeb1f
nvim-cmp: fix rewrite remnants (#419)
* fix: bad cmp confirm

* nvim-cmp: simplify confirm bind and mapping definitions

---------

Co-authored-by: Pei Yang Ching <59727193+horriblename@users.noreply.github.com>
2024-10-17 05:57:29 +00:00
Pei Yang Ching
d76d673dd4 neo-tree: fix duplicate neo-tree install 2024-10-16 01:28:34 +02:00
diniamo
54ec473039
comment-nvim: fix visual mappings (#417) 2024-10-15 18:05:05 +02:00
Soliprem
a7e0542fd0
neorg: init (#413)
* neorg: init

* neorg: setupOpts work

* neorg: disable by default

* neorg: added changelog entry

* neorg: setupOpts setup correctly

* neorg: sane default for setupOpts

* neorg: changed description and removed reduntant treesitter activation

* neorg: added vim.treesitter.enable

* neorg: fixing capitalisation

* neorg: adding descriptions

* neorg: formatting

* neorg: added newline at the end of docs
2024-10-15 15:31:18 +00:00
Soliprem
94d2b837cf
leap: changing default binds (#416)
* leap: changed default binds

* leap: added changelog entry

* leap: fixing requested change

Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com>

* Revert "leap: added changelog entry"

This reverts commit 6aac9b2580.

* leap: added changelog entry

* leap: fix inherits

---------

Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com>
2024-10-14 22:47:44 +02:00
27 changed files with 534 additions and 380 deletions

View file

@ -174,6 +174,7 @@ isMaximal: {
notes = { notes = {
obsidian.enable = false; # FIXME: neovim fails to build if obsidian is enabled obsidian.enable = false; # FIXME: neovim fails to build if obsidian is enabled
neorg.enable = false;
orgmode.enable = false; orgmode.enable = false;
mind-nvim.enable = isMaximal; mind-nvim.enable = isMaximal;
todo-comments.enable = true; todo-comments.enable = true;

View file

@ -136,8 +136,7 @@ plugins are managed by `lz.n`.
let let
cfg = config.vim.your-plugin; cfg = config.vim.your-plugin;
in { in {
vim.lazy.plugins = [ vim.lazy.plugins.your-plugin = {
{
# instead of vim.startPlugins, use this: # instead of vim.startPlugins, use this:
package = "your-plugin"; package = "your-plugin";
@ -157,9 +156,9 @@ in {
mode = "n"; mode = "n";
action = ":YourPluginCommand"; action = ":YourPluginCommand";
} }
]
}
]; ];
};
;
} }
``` ```

View file

@ -63,6 +63,14 @@ Note that we are looking to add more alternatives in the future like
dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for
everyone. everyone.
### `type` based modules removed {#sec-type-based-modules-removed}
As part of the autocompletion rewrite, modules that used to use a `type` option
have been replaced by per-plugin modules instead. Since both modules only had
one type, you can simply change
- `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*`
- `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable`
## Changelog {#sec-release-0.7-changelog} ## Changelog {#sec-release-0.7-changelog}
[ItsSorae](https://github.com/ItsSorae): [ItsSorae](https://github.com/ItsSorae):
@ -266,8 +274,10 @@ everyone.
- Add LSP and Treesitter support for R under `vim.languages.R`. - Add LSP and Treesitter support for R under `vim.languages.R`.
- Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with - Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with
ccc ccc
- Add Neorg support under `vim.notes.neorg`
- Add LSP, diagnostics, formatter and Treesitter support for Kotlin under - Add LSP, diagnostics, formatter and Treesitter support for Kotlin under
`vim.languages.kotlin` `vim.languages.kotlin`
- changed default keybinds for leap.nvim to avoid altering expected behavior
[Bloxx12](https://github.com/Bloxx12) [Bloxx12](https://github.com/Bloxx12)
@ -279,3 +289,4 @@ everyone.
- Add LSP support for Scala via - Add LSP support for Scala via
[nvim-metals](https://github.com/scalameta/nvim-metals) [nvim-metals](https://github.com/scalameta/nvim-metals)

View file

@ -828,6 +828,22 @@
"type": "github" "type": "github"
} }
}, },
"plugin-lua-utils-nvim": {
"flake": false,
"locked": {
"lastModified": 1708177208,
"narHash": "sha256-9ildzQEMkXKZ3LHq+khGFgRQFxlIXQclQ7QU3fcU1C4=",
"owner": "nvim-neorg",
"repo": "lua-utils.nvim",
"rev": "e565749421f4bbb5d2e85e37c3cef9d56553d8bd",
"type": "github"
},
"original": {
"owner": "nvim-neorg",
"repo": "lua-utils.nvim",
"type": "github"
}
},
"plugin-lualine": { "plugin-lualine": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -989,6 +1005,38 @@
"type": "github" "type": "github"
} }
}, },
"plugin-neorg": {
"flake": false,
"locked": {
"lastModified": 1727821831,
"narHash": "sha256-yfWQ6yKytu1jkWUtRZTVICslUWej6jVYv7frmSB7/6Q=",
"owner": "nvim-neorg",
"repo": "neorg",
"rev": "afc9a37bf021acb0853e95714c4c6436e1588286",
"type": "github"
},
"original": {
"owner": "nvim-neorg",
"repo": "neorg",
"type": "github"
}
},
"plugin-neorg-telescope": {
"flake": false,
"locked": {
"lastModified": 1722358034,
"narHash": "sha256-ei4uUqpIQjGKzu5ryu0Hlmis9TS9FJsYnjt4J4QdWlw=",
"owner": "nvim-neorg",
"repo": "neorg-telescope",
"rev": "ddb2556644cae922699a239bbb0fe16e25b084b7",
"type": "github"
},
"original": {
"owner": "nvim-neorg",
"repo": "neorg-telescope",
"type": "github"
}
},
"plugin-new-file-template-nvim": { "plugin-new-file-template-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -1502,6 +1550,22 @@
"type": "github" "type": "github"
} }
}, },
"plugin-pathlib-nvim": {
"flake": false,
"locked": {
"lastModified": 1724943804,
"narHash": "sha256-YhCJeNKlcjgg3q51UWFhuIEPzNueC8YTpeuPPJDndvw=",
"owner": "pysan3",
"repo": "pathlib.nvim",
"rev": "57e5598af6fe253761c1b48e0b59b7cd6699e2c1",
"type": "github"
},
"original": {
"owner": "pysan3",
"repo": "pathlib.nvim",
"type": "github"
}
},
"plugin-plenary-nvim": { "plugin-plenary-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -1924,6 +1988,7 @@
"plugin-lsp-signature": "plugin-lsp-signature", "plugin-lsp-signature": "plugin-lsp-signature",
"plugin-lspkind": "plugin-lspkind", "plugin-lspkind": "plugin-lspkind",
"plugin-lspsaga": "plugin-lspsaga", "plugin-lspsaga": "plugin-lspsaga",
"plugin-lua-utils-nvim": "plugin-lua-utils-nvim",
"plugin-lualine": "plugin-lualine", "plugin-lualine": "plugin-lualine",
"plugin-luasnip": "plugin-luasnip", "plugin-luasnip": "plugin-luasnip",
"plugin-lz-n": "plugin-lz-n", "plugin-lz-n": "plugin-lz-n",
@ -1934,6 +1999,8 @@
"plugin-neo-tree-nvim": "plugin-neo-tree-nvim", "plugin-neo-tree-nvim": "plugin-neo-tree-nvim",
"plugin-neocord": "plugin-neocord", "plugin-neocord": "plugin-neocord",
"plugin-neodev-nvim": "plugin-neodev-nvim", "plugin-neodev-nvim": "plugin-neodev-nvim",
"plugin-neorg": "plugin-neorg",
"plugin-neorg-telescope": "plugin-neorg-telescope",
"plugin-new-file-template-nvim": "plugin-new-file-template-nvim", "plugin-new-file-template-nvim": "plugin-new-file-template-nvim",
"plugin-noice-nvim": "plugin-noice-nvim", "plugin-noice-nvim": "plugin-noice-nvim",
"plugin-none-ls": "plugin-none-ls", "plugin-none-ls": "plugin-none-ls",
@ -1966,6 +2033,7 @@
"plugin-orgmode-nvim": "plugin-orgmode-nvim", "plugin-orgmode-nvim": "plugin-orgmode-nvim",
"plugin-otter-nvim": "plugin-otter-nvim", "plugin-otter-nvim": "plugin-otter-nvim",
"plugin-oxocarbon": "plugin-oxocarbon", "plugin-oxocarbon": "plugin-oxocarbon",
"plugin-pathlib-nvim": "plugin-pathlib-nvim",
"plugin-plenary-nvim": "plugin-plenary-nvim", "plugin-plenary-nvim": "plugin-plenary-nvim",
"plugin-project-nvim": "plugin-project-nvim", "plugin-project-nvim": "plugin-project-nvim",
"plugin-registers": "plugin-registers", "plugin-registers": "plugin-registers",

View file

@ -657,6 +657,26 @@
flake = false; flake = false;
}; };
plugin-lua-utils-nvim = {
url = "github:nvim-neorg/lua-utils.nvim";
flake = false;
};
plugin-pathlib-nvim = {
url = "github:pysan3/pathlib.nvim";
flake = false;
};
plugin-neorg = {
url = "github:nvim-neorg/neorg";
flake = false;
};
plugin-neorg-telescope = {
url = "github:nvim-neorg/neorg-telescope";
flake = false;
};
plugin-nui-nvim = { plugin-nui-nvim = {
# (required by noice.nvim) # (required by noice.nvim)
url = "github:MunifTanjim/nui.nvim"; url = "github:MunifTanjim/nui.nvim";

View file

@ -31,6 +31,11 @@ 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" "autocomplete" "sources"] ''
vim.autocomplete.sources has been removed in favor of per-plugin modules.
You can add nvim-cmp sources with vim.autocomplete.nvim-cmp.sources
instead.
'')
(mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] '' (mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] ''
vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip. vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip.
'') '')

View file

@ -11,19 +11,15 @@
inherit (self.options.vim.comments.comment-nvim) mappings; inherit (self.options.vim.comments.comment-nvim) mappings;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = [ vim.startPlugins = ["comment-nvim"];
"comment-nvim"
];
vim.lazy.plugins = [ vim.lazy.plugins.comment-nvim = {
{
package = "comment-nvim"; package = "comment-nvim";
setupModule = "Comment"; setupModule = "Comment";
inherit (cfg) setupOpts; inherit (cfg) setupOpts;
keys = [ keys = [
(mkLznBinding ["n"] cfg.mappings.toggleOpLeaderLine "<Plug>(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description) (mkLznBinding ["n"] cfg.mappings.toggleOpLeaderLine "<Plug>(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description)
(mkLznBinding ["n"] cfg.mappings.toggleOpLeaderBlock "<Plug>(comment_toggle_blockwise)" mappings.toggleOpLeaderBlock.description) (mkLznBinding ["n"] cfg.mappings.toggleOpLeaderBlock "<Plug>(comment_toggle_blockwise)" mappings.toggleOpLeaderBlock.description)
(mkLznExprBinding ["n"] cfg.mappings.toggleCurrentLine '' (mkLznExprBinding ["n"] cfg.mappings.toggleCurrentLine ''
function() function()
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_linewise_current)' return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_linewise_current)'
@ -41,7 +37,6 @@ in {
(mkLznBinding ["x"] cfg.mappings.toggleSelectedLine "<Plug>(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description) (mkLznBinding ["x"] cfg.mappings.toggleSelectedLine "<Plug>(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description)
(mkLznBinding ["x"] cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description) (mkLznBinding ["x"] cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description)
]; ];
} };
];
}; };
} }

View file

@ -6,17 +6,13 @@
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.binds) addDescriptionsToMappings;
inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
inherit (builtins) attrNames; inherit (builtins) attrNames;
cfg = config.vim.autocomplete.nvim-cmp; cfg = config.vim.autocomplete.nvim-cmp;
luasnipEnable = config.vim.snippets.luasnip.enable; luasnipEnable = config.vim.snippets.luasnip.enable;
inherit (cfg) mappings;
self = import ./nvim-cmp.nix {inherit lib config;};
mappingDefinitions = self.options.vim.autocomplete.nvim-cmp.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
@ -45,39 +41,20 @@ in {
}; };
pluginRC.nvim-cmp = mkIf cfg.enable (entryAfter ["autopairs" "luasnip"] '' pluginRC.nvim-cmp = mkIf cfg.enable (entryAfter ["autopairs" "luasnip"] ''
local luasnip = require("luasnip") ${optionalString luasnipEnable "local luasnip = require('luasnip')"}
local cmp = require("cmp") local cmp = require("cmp")
cmp.setup(${toLuaObject cfg.setupOpts}) cmp.setup(${toLuaObject cfg.setupOpts})
''); '');
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section # `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
autocomplete.nvim-cmp.setupOpts.mapping = { autocomplete.nvim-cmp.setupOpts.mapping = {
${mappings.complete.value} = mkLuaInline "cmp.mapping.complete()"; ${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
${mappings.close.value} = mkLuaInline "cmp.mapping.abort()"; ${mappings.close} = mkLuaInline "cmp.mapping.abort()";
${mappings.scrollDocsUp.value} = mkLuaInline "cmp.mapping.scroll_docs(-4)"; ${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
${mappings.scrollDocsDown.value} = mkLuaInline "cmp.mapping.scroll_docs(4)"; ${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)";
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })";
${mappings.confirm.value} = mkLuaInline '' ${mappings.next} = mkLuaInline ''
cmp.mapping(function(fallback)
if cmp.visible() then
${
if luasnipEnable
then ''
if luasnip.expandable() then
luasnip.expand()
else
cmp.confirm({ select = true })
end
''
else "cmp.confirm({ select = true })"
}
else
fallback()
end
end)
'';
${mappings.next.value} = mkLuaInline ''
cmp.mapping(function(fallback) cmp.mapping(function(fallback)
local has_words_before = function() local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0)) local line, col = unpack(vim.api.nvim_win_get_cursor(0))
@ -98,7 +75,7 @@ in {
end) end)
''; '';
${mappings.previous.value} = mkLuaInline '' ${mappings.previous} = mkLuaInline ''
cmp.mapping(function(fallback) cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()

View file

@ -54,8 +54,7 @@ in {
vim = { vim = {
startPlugins = ["nvim-nio"]; startPlugins = ["nvim-nio"];
lazy.plugins = [ lazy.plugins.nvim-dap-ui = {
{
package = "nvim-dap-ui"; package = "nvim-dap-ui";
setupModule = "dapui"; setupModule = "dapui";
setupOpts = {}; setupOpts = {};
@ -63,8 +62,7 @@ in {
keys = [ keys = [
(mkSetLuaLznBinding mappings.toggleDapUI "function() require('dapui').toggle() end") (mkSetLuaLznBinding mappings.toggleDapUI "function() require('dapui').toggle() end")
]; ];
} };
];
pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] ( pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] (
optionalString cfg.ui.autoStart '' optionalString cfg.ui.autoStart ''

View file

@ -14,19 +14,15 @@ in {
"plenary-nvim" # commons library "plenary-nvim" # commons library
"image-nvim" # optional for image previews "image-nvim" # optional for image previews
"nui-nvim" # ui library "nui-nvim" # ui library
# neotree
"neo-tree-nvim"
]; ];
lazy.plugins = [ lazy.plugins.neo-tree-nvim = {
{
package = "neo-tree-nvim"; package = "neo-tree-nvim";
setupModule = "neo-tree"; setupModule = "neo-tree";
inherit (cfg) setupOpts; inherit (cfg) setupOpts;
cmd = ["Neotree"]; cmd = ["Neotree"];
} };
];
visuals.nvimWebDevicons.enable = true; visuals.nvimWebDevicons.enable = true;
}; };

View file

@ -15,12 +15,12 @@
inherit (self.options.vim.filetree.nvimTree) mappings; inherit (self.options.vim.filetree.nvimTree) mappings;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.binds.whichKey.register = pushDownDefault { vim = {
binds.whichKey.register = pushDownDefault {
"<leader>t" = "+NvimTree"; "<leader>t" = "+NvimTree";
}; };
vim.lazy.plugins = [ lazy.plugins.nvim-tree-lua = {
{
package = "nvim-tree-lua"; package = "nvim-tree-lua";
setupModule = "nvim-tree"; setupModule = "nvim-tree";
inherit (cfg) setupOpts; inherit (cfg) setupOpts;
@ -31,10 +31,9 @@ in {
(mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description) (mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
(mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description) (mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
]; ];
} };
];
vim.pluginRC.nvimtreelua = entryAnywhere '' pluginRC.nvimtreelua = entryAnywhere ''
${ ${
optionalString cfg.setupOpts.disable_netrw '' optionalString cfg.setupOpts.disable_netrw ''
-- disable netrew completely -- disable netrew completely
@ -85,4 +84,5 @@ in {
} }
''; '';
}; };
};
} }

View file

@ -14,8 +14,7 @@
in { in {
config = mkIf (cfg.enable && cfg.trouble.enable) { config = mkIf (cfg.enable && cfg.trouble.enable) {
vim = { vim = {
lazy.plugins = [ lazy.plugins.trouble = {
{
package = "trouble"; package = "trouble";
setupModule = "trouble"; setupModule = "trouble";
inherit (cfg.trouble) setupOpts; inherit (cfg.trouble) setupOpts;
@ -29,8 +28,7 @@ in {
(mkSetLznBinding mappings.quickfix "<cmd>TroubleToggle quickfix<CR>") (mkSetLznBinding mappings.quickfix "<cmd>TroubleToggle quickfix<CR>")
(mkSetLznBinding mappings.locList "<cmd>TroubleToggle loclist<CR>") (mkSetLznBinding mappings.locList "<cmd>TroubleToggle loclist<CR>")
]; ];
} };
];
binds.whichKey.register = pushDownDefault { binds.whichKey.register = pushDownDefault {
"<leader>l" = "Trouble"; "<leader>l" = "Trouble";

View file

@ -2,6 +2,7 @@
imports = [ imports = [
./obsidian ./obsidian
./orgmode ./orgmode
./neorg
./mind-nvim ./mind-nvim
./todo-comments ./todo-comments
]; ];

View file

@ -0,0 +1,41 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.binds) pushDownDefault;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.notes.neorg;
in {
config = mkIf cfg.enable (mkMerge [
{
vim = {
startPlugins = [
"lua-utils-nvim"
"nui-nvim"
"nvim-nio"
"pathlib-nvim"
"plenary-nvim"
"neorg"
"neorg-telescope"
];
binds.whichKey.register = pushDownDefault {
"<leader>o" = "+Notes";
};
pluginRC.neorg = entryAnywhere ''
require('neorg').setup(${toLuaObject cfg.setupOpts})
'';
};
}
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.norgPackage];
})
]);
}

View file

@ -0,0 +1,6 @@
{
imports = [
./neorg.nix
./config.nix
];
}

View file

@ -0,0 +1,50 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) submodule listOf str;
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
in {
options.vim.notes.neorg = {
enable = mkEnableOption ''
Neorg: An intuitive note-taking and organization tool with a structured nested syntax.
'';
setupOpts = mkPluginSetupOption "Neorg" {
load = {
"core.defaults" = mkOption {
default = {};
description = ''
all of the most important modules that any user would want to have a "just works" experience
'';
type = submodule {
options = {
enable = mkEnableOption ''
all of the most important modules that any user would want to have a "just works" experience
'';
config = {
disable = mkOption {
description = ''
list of modules from to be disabled from core.defaults
'';
type = listOf str;
default = [];
example = ["core.autocommands" "core.itero"];
};
};
};
};
};
};
};
treesitter = {
enable = mkEnableOption "Neorg treesitter" // {default = config.vim.languages.enableTreesitter;};
norgPackage = mkGrammarOption pkgs "norg";
};
};
}

View file

@ -14,8 +14,7 @@
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
lazy.plugins = [ lazy.plugins.toggleterm-nvim = {
{
package = "toggleterm-nvim"; package = "toggleterm-nvim";
cmd = ["ToggleTerm" "ToggleTermSendCurrentLine" "ToggleTermSendVisualLines" "ToggleTermSendVisualSelection" "ToggleTermSetName" "ToggleTermToggleAll"]; cmd = ["ToggleTerm" "ToggleTermSendCurrentLine" "ToggleTermSendVisualLines" "ToggleTermSendVisualSelection" "ToggleTermSetName" "ToggleTermToggleAll"];
keys = [ keys = [
@ -45,8 +44,7 @@ in {
vim.keymap.set('n', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = '${lazygitMapDesc}'}) vim.keymap.set('n', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = '${lazygitMapDesc}'})
''; '';
} };
];
}; };
}; };
} }

View file

@ -9,15 +9,13 @@
cfg = config.vim.binds.cheatsheet; cfg = config.vim.binds.cheatsheet;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.lazy.plugins = [ vim.lazy.plugins.cheatsheet-nvim = {
{
package = "cheatsheet-nvim"; package = "cheatsheet-nvim";
setupModule = "cheatsheet"; setupModule = "cheatsheet";
setupOpts = {}; setupOpts = {};
cmd = ["Cheatsheet" "CheatsheetEdit"]; cmd = ["Cheatsheet" "CheatsheetEdit"];
before = optionalString config.vim.lazy.enable "require('lz.n').trigger_load('telescope')"; before = optionalString config.vim.lazy.enable "require('lz.n').trigger_load('telescope')";
} };
];
}; };
} }

View file

@ -10,14 +10,12 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
startPlugins = ["plenary-nvim"]; startPlugins = ["plenary-nvim"];
lazy.plugins = [ lazy.plugins.diffview-nvim = {
{
package = "diffview-nvim"; package = "diffview-nvim";
cmd = ["DiffviewClose" "DiffviewFileHistory" "DiffviewFocusFiles" "DiffviewLog" "DiffviewOpen" "DiffviewRefresh" "DiffviewToggleFiles"]; cmd = ["DiffviewClose" "DiffviewFileHistory" "DiffviewFocusFiles" "DiffviewLog" "DiffviewOpen" "DiffviewRefresh" "DiffviewToggleFiles"];
setupModule = "diffview"; setupModule = "diffview";
inherit (cfg) setupOpts; inherit (cfg) setupOpts;
} };
];
}; };
}; };
} }

View file

@ -10,8 +10,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["dressing-nvim"]; vim.startPlugins = ["dressing-nvim"];
vim.lazy.plugins = [ vim.lazy.plugins.icon-picker-nvim = {
{
package = "icon-picker-nvim"; package = "icon-picker-nvim";
setupModule = "icon-picker"; setupModule = "icon-picker";
setupOpts = { setupOpts = {
@ -19,7 +18,6 @@ in {
}; };
cmd = ["IconPickerInsert" "IconPickerNormal" "IconPickerYank"]; cmd = ["IconPickerInsert" "IconPickerNormal" "IconPickerYank"];
} };
];
}; };
} }

View file

@ -3,7 +3,7 @@
lib, lib,
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf mkDefault;
inherit (lib.nvim.binds) mkLznBinding; inherit (lib.nvim.binds) mkLznBinding;
cfg = config.vim.utility.motion.leap; cfg = config.vim.utility.motion.leap;
@ -11,8 +11,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
startPlugins = ["vim-repeat"]; startPlugins = ["vim-repeat"];
lazy.plugins = [ lazy.plugins.leap-nvim = {
{
package = "leap-nvim"; package = "leap-nvim";
keys = [ keys = [
(mkLznBinding ["n" "o" "x"] cfg.mappings.leapForwardTo "<Plug>(leap-forward-to)" "Leap forward to") (mkLznBinding ["n" "o" "x"] cfg.mappings.leapForwardTo "<Plug>(leap-forward-to)" "Leap forward to")
@ -54,8 +53,9 @@ in {
}, },
} }
''; '';
} };
];
binds.whichKey.register."<leader>s" = mkDefault "+Leap";
}; };
}; };
} }

View file

@ -9,22 +9,22 @@ in {
leapForwardTo = mkOption { leapForwardTo = mkOption {
type = nullOr str; type = nullOr str;
description = "Leap forward to"; description = "Leap forward to";
default = "s"; default = "<leader>ss";
}; };
leapBackwardTo = mkOption { leapBackwardTo = mkOption {
type = nullOr str; type = nullOr str;
description = "Leap backward to"; description = "Leap backward to";
default = "S"; default = "<leader>sS";
}; };
leapForwardTill = mkOption { leapForwardTill = mkOption {
type = nullOr str; type = nullOr str;
description = "Leap forward till"; description = "Leap forward till";
default = "x"; default = "<leader>sx";
}; };
leapBackwardTill = mkOption { leapBackwardTill = mkOption {
type = nullOr str; type = nullOr str;
description = "Leap backward till"; description = "Leap backward till";
default = "X"; default = "<leader>sX";
}; };
leapFromWindow = mkOption { leapFromWindow = mkOption {
type = nullOr str; type = nullOr str;

View file

@ -30,8 +30,7 @@ in {
startPlugins = ["nvim-surround"]; startPlugins = ["nvim-surround"];
pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})"; pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})";
lazy.plugins = [ lazy.plugins.nvim-surround = {
{
package = "nvim-surround"; package = "nvim-surround";
setupModule = "nvim-surround"; setupModule = "nvim-surround";
inherit (cfg) setupOpts; inherit (cfg) setupOpts;
@ -48,8 +47,7 @@ in {
change change
change_line change_line
]); ]);
} };
];
utility.surround.setupOpts.keymaps = mkIf cfg.useVendoredKeybindings vendoredKeybinds; utility.surround.setupOpts.keymaps = mkIf cfg.useVendoredKeybindings vendoredKeybinds;
}; };

View file

@ -20,8 +20,7 @@ in {
vim = { vim = {
startPlugins = ["plenary-nvim"]; startPlugins = ["plenary-nvim"];
lazy.plugins = [ lazy.plugins.telescope = {
{
package = "telescope"; package = "telescope";
setupModule = "telescope"; setupModule = "telescope";
inherit (cfg) setupOpts; inherit (cfg) setupOpts;
@ -69,8 +68,7 @@ in {
(mkSetLznBinding mappings.findProjects "<cmd Telescope projects<CR>") (mkSetLznBinding mappings.findProjects "<cmd Telescope projects<CR>")
] ]
); );
} };
];
binds.whichKey.register = pushDownDefault { binds.whichKey.register = pushDownDefault {
"<leader>f" = "+Telescope"; "<leader>f" = "+Telescope";

View file

@ -8,13 +8,11 @@
cfg = config.vim.visuals.fidget-nvim; cfg = config.vim.visuals.fidget-nvim;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.lazy.plugins = [ vim.lazy.plugins.fidget-nvim = {
{
package = "fidget-nvim"; package = "fidget-nvim";
setupModule = "fidget"; setupModule = "fidget";
event = "LspAttach"; event = "LspAttach";
inherit (cfg) setupOpts; inherit (cfg) setupOpts;
} };
];
}; };
} }

View file

@ -3,7 +3,8 @@
config, config,
... ...
}: let }: let
inherit (builtins) toJSON typeOf head length tryEval filter concatLists concatStringsSep; inherit (builtins) toJSON typeOf head length filter concatLists concatStringsSep;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
@ -21,14 +22,7 @@
else keySpec.action; else keySpec.action;
}; };
toLuaLznSpec = spec: let toLuaLznSpec = name: spec:
name =
if typeOf spec.package == "string"
then spec.package
else if (spec.package ? pname && (tryEval spec.package.pname).success)
then spec.package.pname
else spec.package.name;
in
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"]) (removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
// { // {
"@1" = name; "@1" = name;
@ -62,9 +56,9 @@
# empty list or str or (listOf str) # empty list or str or (listOf str)
else spec.keys; else spec.keys;
}; };
lznSpecs = map toLuaLznSpec cfg.plugins; lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
specToNotLazyConfig = spec: '' specToNotLazyConfig = _: spec: ''
do do
${optionalString (spec.before != null) spec.before} ${optionalString (spec.before != null) spec.before}
${optionalString (spec.setupModule != null) ${optionalString (spec.setupModule != null)
@ -73,34 +67,32 @@
end end
''; '';
specToKeymaps = spec: specToKeymaps = _: spec:
if typeOf spec.keys == "list" if typeOf spec.keys == "list"
then map (x: removeAttrs x ["ft"]) (filter (lznKey: lznKey.action != null && lznKey.ft == null) spec.keys) then map (x: removeAttrs x ["ft"]) (filter (lznKey: lznKey.action != null && lznKey.ft == null) spec.keys)
else if spec.keys == null || typeOf spec.keys == "string" else if spec.keys == null || typeOf spec.keys == "string"
then [] then []
else [spec.keys]; else [spec.keys];
notLazyConfig = concatStringsSep "\n" (map specToNotLazyConfig cfg.plugins); notLazyConfig = concatStringsSep "\n" (mapAttrsToList specToNotLazyConfig cfg.plugins);
in { in {
config.vim = mkMerge [ config.vim = mkMerge [
(mkIf cfg.enable { (mkIf cfg.enable {
startPlugins = ["lz-n" "lzn-auto-require"]; startPlugins = ["lz-n" "lzn-auto-require"];
optPlugins = map (plugin: plugin.package) cfg.plugins; optPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins;
luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] '' luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] ''
require('lz.n').load(${toLuaObject lznSpecs}) require('lz.n').load(${toLuaObject lznSpecs})
''; '';
}) })
( (mkIf (!cfg.enable) {
mkIf (!cfg.enable) { startPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins;
startPlugins = map (plugin: plugin.package) cfg.plugins;
luaConfigPre = luaConfigPre =
concatStringsSep "\n" concatStringsSep "\n"
(filter (x: x != null) (map (spec: spec.beforeAll) cfg.plugins)); (filter (x: x != null) (mapAttrsToList (_: spec: spec.beforeAll) cfg.plugins));
luaConfigRC.unlazy = entryAfter ["pluginConfigs"] notLazyConfig; luaConfigRC.unlazy = entryAfter ["pluginConfigs"] notLazyConfig;
keymaps = concatLists (map specToKeymaps cfg.plugins); keymaps = concatLists (mapAttrsToList specToKeymaps cfg.plugins);
} })
)
]; ];
} }

View file

@ -188,19 +188,29 @@ in {
plugins = mkOption { plugins = mkOption {
default = []; default = [];
type = listOf lznPluginType; type = attrsOf lznPluginType;
description = "list of plugins to lazy load"; description = ''
Plugins to lazy load.
The attribute key is used as the plugin name: for the default `vim.g.lz_n.load`
function this should be either the `package.pname` or `package.name`.
'';
example = '' example = ''
[
{ {
toggleterm-nvim = {
package = "toggleterm-nvim"; package = "toggleterm-nvim";
setupModule = "toggleterm"; setupModule = "toggleterm";
setupOpts = cfg.setupOpts; setupOpts = cfg.setupOpts;
after = "require('toggleterm').do_something()"; after = "require('toggleterm').do_something()";
cmd = ["ToggleTerm"]; cmd = ["ToggleTerm"];
};
$${pkgs.vimPlugins.vim-bbye.pname} = {
package = pkgs.vimPlugins.vim-bbye;
cmd = ["Bdelete" "Bwipeout"];
};
} }
]
''; '';
}; };
}; };