Skip to content
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

plugins/which-key: fix mkLuaFn examples; plugins/yazi: fix mkLuaFn examples #2007

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions plugins/filetrees/yazi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
enable_mouse_support = defaultNullOpts.mkBool false "Enables mouse support.";

open_file_function = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = ''
function(chosen_file)
vim.cmd(string.format("edit %s", vim.fn.fnameescape(chosen_file)))
end
'';
pluginDefault = # Lua
''
function(chosen_file)
vim.cmd(string.format("edit %s", vim.fn.fnameescape(chosen_file)))
end
'';
description = ''
What Neovim should do a when a file was opened (selected) in yazi.

Expand Down Expand Up @@ -92,30 +93,33 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {

hooks = {
yazi_opened = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = ''
function(preselected_path, yazi_buffer_id, config)
end
'';
pluginDefault = # Lua
''
function(preselected_path, yazi_buffer_id, config)
end
'';
description = ''
If you want to execute a custom action when yazi has been opened,
you can define it here.
'';
};

yazi_closed_successfully = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = ''
function(chosen_file, config, state)
end
'';
pluginDefault = # Lua
''
function(chosen_file, config, state)
end
'';
description = "When yazi was successfully closed";
};

yazi_opened_multiple_files = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = ''
function(chosen_files)
vim.cmd("args" .. table.concat(chosen_files, " "))
end
'';
pluginDefault = # Lua
''
function(chosen_files)
vim.cmd("args" .. table.concat(chosen_files, " "))
end
'';
description = ''
When yazi opened multiple files. The default is to send them to the
quickfix list, but if you want to change that, you can define it here
Expand Down
21 changes: 12 additions & 9 deletions plugins/utils/which-key.nix
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,12 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
};

filter = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = ''
function(mapping)
return true
end
'';
pluginDefault = # Lua
''
function(mapping)
return true
end
'';
description = "Filter used to exclude mappings";
};

Expand Down Expand Up @@ -283,10 +284,12 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
] "Manually setup triggers";

defer = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = ''
function(ctx)
return ctx.mode == "V" or ctx.mode == "<C-V>
end'';
pluginDefault = # Lua
''
function(ctx)
return ctx.mode == "V" or ctx.mode == "<C-V>
end
'';
description = ''
Start hidden and wait for a key to be pressed before showing the popup.

Expand Down
40 changes: 22 additions & 18 deletions tests/test-sources/plugins/filetrees/yazi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
use_yazi_client_id_flag = false;
enable_mouse_support = false;

open_file_function.__raw = ''
function(chosen_file)
vim.cmd(string.format("edit %s", vim.fn.fnameescape(chosen_file)))
end
'';
open_file_function = # Lua
''
function(chosen_file)
vim.cmd(string.format("edit %s", vim.fn.fnameescape(chosen_file)))
end
'';

clipboard_register = "*";

Expand All @@ -37,21 +38,24 @@
set_keymappings_function = null;

hooks = {
yazi_opened.__raw = ''
function(preselected_path, yazi_buffer_id, config)
end
'';
yazi_opened = # Lua
''
function(preselected_path, yazi_buffer_id, config)
end
'';

yazi_closed_successfully.__raw = ''
function(chosen_file, config, state)
end
'';
yazi_closed_successfully = # Lua
''
function(chosen_file, config, state)
end
'';

yazi_opened_multiple_files.__raw = ''
function(chosen_files)
vim.cmd("args" .. table.concat(chosen_files, " "))
end
'';
yazi_opened_multiple_files = # Lua
''
function(chosen_files)
vim.cmd("args" .. table.concat(chosen_files, " "))
end
'';
};

highlight_groups = {
Expand Down
20 changes: 11 additions & 9 deletions tests/test-sources/plugins/utils/which-key.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
end
'';

filter.__raw = ''
function(mapping)
return true
filter = # Lua
''
function(mapping)
return true
end
'';
'';

spec = [ ];

Expand All @@ -33,11 +34,12 @@
}
];

defer.__raw = ''
function(ctx)
return ctx.mode == "V" or ctx.mode == "<C-V>"
end
'';
defer = # Lua
''
function(ctx)
return ctx.mode == "V" or ctx.mode == "<C-V>"
end
'';

plugins = {
marks = true;
Expand Down