-
-
Notifications
You must be signed in to change notification settings - Fork 348
lib/options: lib/neovim-plugin: Add lazyLoad option to plugins #1866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
af73ce0
maintainers: add psfloyd
psfloyd 23a58d2
lib/options: add mkLazyLoadOption
psfloyd 6f3373b
plugins/lz-n: init
psfloyd befa7d9
lib/options: use keymap helper for lazyLoad.keys
psfloyd 02c0a9d
plugins/lz-n: added tests
psfloyd 5d1f730
lib/neovim-plugin: add lazyLoad
psfloyd 74e5dc4
plugins/qmk: add default values for name and layout options
psfloyd c35da90
plugin/lz-n: fix enabledInSpec option for lz.n
psfloyd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,4 +70,10 @@ | |
githubId = 4646110; | ||
name = "Nikita Shirokov"; | ||
}; | ||
psfloyd = { | ||
email = "[email protected]"; | ||
github = "psfloyd"; | ||
githubId = 30784060; | ||
name = "Pedro Sánchez"; | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ lib | ||
, helpers | ||
, config | ||
, pkgs | ||
, ... | ||
}: | ||
let | ||
inherit (helpers) mkNullOrLuaFn' nixvimTypes mkLazyLoadOption; | ||
|
||
name = "lz-n"; | ||
originalName = "lz.n"; | ||
cfg = config.plugins.${name}; | ||
in | ||
with lib; | ||
helpers.neovim-plugin.mkNeovimPlugin config { | ||
inherit name originalName; | ||
maintainers = with helpers.maintainers; [ psfloyd ]; | ||
defaultPackage = pkgs.vimPlugins.lz-n; | ||
|
||
settingsDescription = '' | ||
The configuration options for **${originalName}** using `vim.g.lz_n`. | ||
|
||
`{ load = "fun"; }` -> `vim.g.lz_n = { load = fun, }` | ||
''; | ||
|
||
settingsOptions = { | ||
load = mkNullOrLuaFn' { | ||
description = '' | ||
Function used by `lz.n` to load plugins. | ||
''; | ||
default = null; | ||
pluginDefault = "vim.cmd.packadd"; | ||
}; | ||
}; | ||
|
||
settingsExample = { | ||
load = "vim.cmd.packadd"; | ||
}; | ||
|
||
callSetup = false; # Does not use setup | ||
allowLazyLoad = false; | ||
|
||
extraOptions = with nixvimTypes; { | ||
plugins = mkOption { | ||
description = "List of plugins processed by lz.n"; | ||
default = [ ]; | ||
type = listOf (mkLazyLoadOption { }).type; | ||
}; | ||
}; | ||
|
||
extraConfig = cfg: { | ||
globals.lz_n = cfg.settings; | ||
extraConfigLua = | ||
let | ||
processKeymap = | ||
keymaps: | ||
if keymaps == null then | ||
null | ||
else | ||
map ( | ||
keymap: | ||
{ | ||
__unkeyed_1 = keymap.key; | ||
__unkeyed_2 = keymap.action; | ||
inherit (keymap) mode; | ||
} | ||
// keymap.options | ||
) keymaps; | ||
pluginToLua = plugin: { | ||
"__unkeyed" = plugin.name; | ||
inherit (plugin) | ||
beforeAll | ||
before | ||
after | ||
event | ||
cmd | ||
ft | ||
colorscheme | ||
priority | ||
load | ||
; | ||
enabled = enabledInSpec; | ||
keys = processKeymap plugin.keys; | ||
}; | ||
pluginListToLua = map pluginToLua; | ||
plugins = pluginListToLua cfg.plugins; | ||
pluginSpecs = if length plugins == 1 then head plugins else plugins; | ||
in | ||
mkIf (cfg.plugins != [ ]) '' | ||
require('lz.n').load( | ||
${helpers.toLuaObject pluginSpecs} | ||
) | ||
''; | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ pkgs, ... }: | ||
{ | ||
# Empty configuration | ||
empty = { | ||
plugins.lz-n.enable = true; | ||
}; | ||
|
||
# Settings | ||
example = { | ||
plugins.lz-n = { | ||
enable = true; | ||
settings = { | ||
load = "vim.cmd.packadd"; | ||
}; | ||
}; | ||
|
||
}; | ||
|
||
test = { | ||
extraPlugins = with pkgs.vimPlugins; [ | ||
neo-tree-nvim | ||
telescope-nvim | ||
onedarker-nvim | ||
vimtex | ||
|
||
]; | ||
plugins.lz-n = { | ||
enable = true; | ||
plugins = [ | ||
# On keymap with setup function | ||
{ | ||
name = "neo-tree.nvim"; | ||
keys = [ | ||
{ | ||
mode = [ "n" ]; | ||
key = "<leader>ft"; | ||
action = "<CMD>Neotree toggle<CR>"; | ||
options = { | ||
desc = "NeoTree toggle"; | ||
}; | ||
} | ||
{ | ||
mode = [ | ||
"n" | ||
"v" | ||
]; | ||
key = "gft"; | ||
action = "<CMD>Neotree toggle<CR>"; | ||
options = { | ||
desc = "NeoTree toggle"; | ||
}; | ||
} | ||
]; | ||
after = # lua | ||
'' | ||
function() | ||
require("neo-tree").setup() | ||
end | ||
''; | ||
} | ||
# On command no setup function | ||
{ | ||
name = "telescope.nvim"; | ||
cmd = [ "Telescope" ]; | ||
} | ||
# On colorschme | ||
{ | ||
name = "onedarker.nvim"; | ||
colorscheme = [ "onedarker" ]; | ||
} | ||
# On filetype with before function | ||
{ | ||
name = "vimtex"; | ||
ft = [ "plaintex" ]; | ||
before = # lua | ||
'' | ||
function() | ||
vim.g.vimtex_compiler_method = "latexrun" | ||
end | ||
''; | ||
} | ||
]; | ||
}; | ||
}; | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.