plugins/ui: move to by-name

This commit is contained in:
Matt Sturgeon 2024-09-04 17:42:49 +01:00
parent 2456370ab2
commit 91c6b62881
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
25 changed files with 0 additions and 13 deletions

View file

@ -0,0 +1,315 @@
{
lib,
helpers,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin {
name = "edgy";
originalName = "edgy.nvim";
package = "edgy-nvim";
maintainers = [ maintainers.GaetanLepage ];
extraConfig = cfg: {
# Those options are strongly recommended by the plugin author:
# https://github.com/folke/edgy.nvim?tab=readme-ov-file#-installation
opts = {
laststatus = mkDefault 3;
splitkeep = mkDefault "screen";
};
};
settingsOptions =
let
viewOpts = {
ft = helpers.mkNullOrStr ''
File type of the view.
'';
filter = helpers.mkNullOrLuaFn ''
Optional function to filter buffers and windows.
`fun(buf:buffer, win:window)`
'';
title = helpers.mkNullOrStr ''
Optional title of the view.
Defaults to the capitalized filetype.
'';
size = helpers.mkNullOrOption types.ints.unsigned ''
Size of the short edge of the edgebar.
For edgebars, this is the minimum width.
For panels, minimum height.
'';
pinned = helpers.mkNullOrOption types.bool ''
If true, the view will always be shown in the edgebar even when it has no windows.
'';
open = helpers.mkNullOrStr ''
Function or command to open a pinned view.
'';
wo = helpers.mkNullOrOption (with types; attrsOf anything) ''
View-specific window options.
'';
};
mkViewOptsOption =
name:
helpers.defaultNullOpts.mkListOf (
with types;
either str (submodule {
options = viewOpts;
})
) [ ] "List of the ${name} edgebar configurations.";
in
{
left = mkViewOptsOption "left";
bottom = mkViewOptsOption "bottom";
right = mkViewOptsOption "right";
top = mkViewOptsOption "top";
options =
mapAttrs
(_: defaultSize: {
size = helpers.defaultNullOpts.mkUnsignedInt defaultSize ''
Size of the short edge of the edgebar.
For edgebars, this is the minimum width.
For panels, minimum height.
'';
wo = helpers.mkNullOrOption (with types; attrsOf anything) ''
View-specific window options.
'';
})
{
left = 30;
bottom = 10;
right = 30;
top = 10;
};
animate = {
enabled = helpers.defaultNullOpts.mkBool true ''
Whether to enable animations.
'';
fps = helpers.defaultNullOpts.mkUnsignedInt 100 ''
Frames per second.
'';
cps = helpers.defaultNullOpts.mkUnsignedInt 120 ''
Cells per second.
'';
on_begin = helpers.defaultNullOpts.mkLuaFn ''
function()
vim.g.minianimate_disable = true
end
'' "Callback for the beginning of animations.";
on_end = helpers.defaultNullOpts.mkLuaFn ''
function()
vim.g.minianimate_disable = false
end
'' "Callback for the ending of animations.";
# This option accepts an attrs or a lua string.
# Hence, we convert the string to raw lua in `apply`.
spinner =
let
defaultFrames = [
""
""
""
""
""
""
""
""
""
""
];
in
helpers.mkNullOrOption' {
type =
with helpers.nixvimTypes;
either strLua (submodule {
freeformType = attrsOf anything;
options = {
frames = helpers.defaultNullOpts.mkListOf types.str defaultFrames ''
Frame characters.
'';
interval = helpers.defaultNullOpts.mkUnsignedInt 80 ''
Interval time between two consecutive frames.
'';
};
});
default = null;
example = "require('noice.util.spinners').spinners.circleFull";
apply = v: if isString v then helpers.mkRaw v else v;
description = "Spinner for pinned views that are loading.";
pluginDefault = {
frames = defaultFrames;
interval = 80;
};
};
};
exit_when_last = helpers.defaultNullOpts.mkBool false ''
Enable this to exit Neovim when only edgy windows are left.
'';
close_when_all_hidden = helpers.defaultNullOpts.mkBool true ''
Close edgy when all windows are hidden instead of opening one of them.
Disable to always keep at least one edgy split visible in each open section.
'';
wo = helpers.defaultNullOpts.mkAttrsOf types.anything {
winbar = true;
winfixwidth = true;
winfixheight = false;
winhighlight = "WinBar:EdgyWinBar,Normal:EdgyNormal";
spell = false;
signcolumn = "no";
} "Global window options for edgebar windows.";
# This option accepts an attrs or a lua string.
# Hence, we convert the string to raw lua in `apply`.
keys = helpers.defaultNullOpts.mkAttrsOf' {
type = with helpers.nixvimTypes; either strLuaFn (enum [ false ]);
apply = x: if x == null then null else mapAttrs (_: v: if isString v then helpers.mkRaw v else v) x;
description = ''
Buffer-local keymaps to be added to edgebar buffers.
Existing buffer-local keymaps will never be overridden.
Each value is either:
- A function declaration (as a raw lua string)
-> `fun(win:Edgy.Window)`
- `false` to disable this mapping.
'';
pluginDefault = {
q = ''
function(win)
win:close()
end
'';
"<c-q>" = ''
function(win)
win:hide()
end
'';
Q = ''
function(win)
win.view.edgebar:close()
end
'';
"]w" = ''
function(win)
win:next({ visible = true, focus = true })
end
'';
"[w" = ''
function(win)
win:prev({ visible = true, focus = true })
end
'';
"]W" = ''
function(win)
win:next({ pinned = false, focus = true })
end
'';
"[W" = ''
function(win)
win:prev({ pinned = false, focus = true })
end
'';
"<c-w>>" = ''
function(win)
win:resize("width", 2)
end
'';
"<c-w><lt>" = ''
function(win)
win:resize("width", -2)
end
'';
"<c-w>+" = ''
function(win)
win:resize("height", 2)
end
'';
"<c-w>-" = ''
function(win)
win:resize("height", -2)
end
'';
"<c-w>=" = ''
function(win)
win.view.edgebar:equalize()
end
'';
};
};
icons = {
closed = helpers.defaultNullOpts.mkStr " " ''
Icon for closed edgebars.
'';
open = helpers.defaultNullOpts.mkStr " " ''
Icon for opened edgebars.
'';
};
};
settingsExample = {
animate.enabled = false;
wo = {
winbar = false;
winfixwidth = false;
winfixheight = false;
winhighlight = "";
spell = false;
signcolumn = "no";
};
bottom = [
{
ft = "toggleterm";
size = 30;
filter = ''
function(buf, win)
return vim.api.nvim_win_get_config(win).relative == ""
end
'';
}
{
ft = "help";
size = 20;
filter = ''
function(buf)
return vim.bo[buf].buftype == "help"
end
'';
}
];
left = [
{
title = "nvimtree";
ft = "NvimTree";
size = 30;
}
{
ft = "Outline";
open = "SymbolsOutline";
}
{ ft = "dapui_scopes"; }
{ ft = "dapui_breakpoints"; }
{ ft = "dap-repl"; }
];
};
}

View file

@ -0,0 +1,29 @@
{
lib,
helpers,
config,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin {
name = "headlines";
originalName = "headlines.nvim";
package = "headlines-nvim";
maintainers = [ maintainers.GaetanLepage ];
settingsExample = {
org.headline_highlights = false;
norg = {
headline_highlights = [ "Headline" ];
codeblock_highlight = false;
};
markdown.headline_highlights = [ "Headline1" ];
};
extraConfig = cfg: {
warnings = optional (!config.plugins.treesitter.enable) ''
Nixvim (plugins.headlines): headlines requires `plugins.treesitter` to be enabled with the relevant grammars installed.
'';
};
}

View file

@ -0,0 +1,164 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
cfg = config.plugins.image;
in
{
meta.maintainers = [ maintainers.GaetanLepage ];
options.plugins.image = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "image.nvim";
package = lib.mkPackageOption pkgs "image.nvim" {
default = [
"vimPlugins"
"image-nvim"
];
};
backend =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"kitty"
"ueberzug"
]
''
All the backends support rendering inside Tmux.
- kitty - best in class, works great and is very snappy
- ueberzug - backed by ueberzugpp, supports any terminal, but has lower performance
- Supports multiple images thanks to @jstkdng.
'';
integrations =
let
mkIntegrationOptions = integrationName: filetypesDefault: {
enabled = helpers.defaultNullOpts.mkBool true ''
Whether to enable the markdown integration.
'';
clearInInsertMode = helpers.defaultNullOpts.mkBool false ''
Clears the image when entering insert mode.
'';
downloadRemoteImages = helpers.defaultNullOpts.mkBool true ''
Whether to download remote images.
'';
onlyRenderImageAtCursor = helpers.defaultNullOpts.mkBool false ''
Whether to limit rendering to the image at the current cursor position.
'';
filetypes = helpers.defaultNullOpts.mkListOf types.str filetypesDefault ''
Markdown extensions (ie. quarto) can go here.
'';
};
in
mapAttrs mkIntegrationOptions {
markdown = [
"markdown"
"vimwiki"
];
neorg = [ "norg" ];
syslang = [ "syslang" ];
};
maxWidth = helpers.mkNullOrOption types.ints.unsigned "Image maximum width.";
maxHeight = helpers.mkNullOrOption types.ints.unsigned "Image maximum height.";
maxWidthWindowPercentage = helpers.mkNullOrOption types.ints.unsigned ''
Image maximum width as a percentage of the window width.
'';
maxHeightWindowPercentage = helpers.defaultNullOpts.mkUnsignedInt 50 ''
Image maximum height as a percentage of the window height.
'';
windowOverlapClearEnabled = helpers.defaultNullOpts.mkBool false ''
Toggles images when windows are overlapped.
'';
windowOverlapClearFtIgnore =
helpers.defaultNullOpts.mkListOf types.str
[
"cmp_menu"
"cmp_docs"
""
]
''
Toggles images when windows are overlapped.
'';
editorOnlyRenderWhenFocused = helpers.defaultNullOpts.mkBool false ''
Auto show/hide images when the editor gains/looses focus.
'';
tmuxShowOnlyInActiveWindow = helpers.defaultNullOpts.mkBool false ''
Auto show/hide images in the correct Tmux window (needs visual-activity off).
'';
hijackFilePatterns =
helpers.defaultNullOpts.mkListOf types.str
[
"*.png"
"*.jpg"
"*.jpeg"
"*.gif"
"*.webp"
]
''
Render image files as images when opened.
'';
};
config = mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraLuaPackages = ps: [ ps.magick ];
extraPackages = [
# In theory, we could remove that if the user explicitly disables `downloadRemoteImages` for
# all integrations but shipping `curl` is not too heavy.
pkgs.curl
] ++ optional (cfg.backend == "ueberzug") pkgs.ueberzugpp;
extraConfigLua =
let
setupOptions =
with cfg;
{
inherit backend;
integrations =
let
processIntegrationOptions = v: {
inherit (v) enabled;
clear_in_insert_mode = v.clearInInsertMode;
download_remote_images = v.downloadRemoteImages;
only_render_image_at_cursor = v.onlyRenderImageAtCursor;
inherit (v) filetypes;
};
in
mapAttrs (_: processIntegrationOptions) integrations;
max_width = maxWidth;
max_height = maxHeight;
max_width_window_percentage = maxWidthWindowPercentage;
max_height_window_percentage = maxHeightWindowPercentage;
window_overlap_clear_enabled = windowOverlapClearEnabled;
window_overlap_clear_ft_ignore = windowOverlapClearFtIgnore;
editor_only_render_when_focused = editorOnlyRenderWhenFocused;
tmux_show_only_in_active_window = tmuxShowOnlyInActiveWindow;
hijack_file_patterns = hijackFilePatterns;
}
// cfg.extraOptions;
in
''
require('image').setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -0,0 +1,97 @@
{
lib,
helpers,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin {
name = "neoscroll";
originalName = "neoscroll.nvim";
package = "neoscroll-nvim";
maintainers = [ maintainers.GaetanLepage ];
settingsOptions = {
mappings =
helpers.defaultNullOpts.mkListOf types.str
[
"<C-u>"
"<C-d>"
"<C-b>"
"<C-f>"
"<C-y>"
"<C-e>"
"zt"
"zz"
"zb"
]
''
All the keys defined in this option will be mapped to their corresponding default
scrolling animation. To no map any key pass an empty table:
```nix
mappings.__empty = null;
```
'';
hide_cursor = helpers.defaultNullOpts.mkBool true ''
If 'termguicolors' is set, hide the cursor while scrolling.
'';
step_eof = helpers.defaultNullOpts.mkBool true ''
When `move_cursor` is `true` scrolling downwards will stop when the bottom line of the
window is the last line of the file.
'';
respect_scrolloff = helpers.defaultNullOpts.mkBool false ''
The cursor stops at the scrolloff margin.
Try combining this option with either `stop_eof` or `cursor_scrolls_alone` (or both).
'';
cursor_scrolls_alone = helpers.defaultNullOpts.mkBool true ''
The cursor will keep on scrolling even if the window cannot scroll further.
'';
easing_function = helpers.mkNullOrStr ''
Name of the easing function to use by default in all scrolling animamtions.
`scroll()` that don't provide the optional `easing` argument will use this easing
function.
If set to `null` (the default) no easing function will be used in the scrolling animation
(constant scrolling speed).
'';
pre_hook = helpers.mkNullOrLuaFn ''
Function to run before the scrolling animation starts.
The function will be called with the `info` parameter which can be optionally passed to
`scroll()` (or any of the provided wrappers).
This can be used to conditionally run different hooks for different types of scrolling
animations.
'';
post_hook = helpers.mkNullOrLuaFn ''
Equivalent to `pre_hook` but the function will run after the scrolling animation ends.
'';
performance_mode = helpers.defaultNullOpts.mkBool false ''
Option to enable "Performance Mode" on all buffers.
'';
};
settingsExample = {
mappings = [
"<C-u>"
"<C-d>"
"<C-b>"
"<C-f>"
"<C-y>"
"<C-e>"
"zt"
"zz"
"zb"
];
hide_cursor = true;
stop_eof = true;
respect_scrolloff = false;
cursor_scrolls_alone = true;
easing_function = "quadratic";
};
}

View file

@ -0,0 +1,423 @@
{
lib,
helpers,
config,
pkgs,
...
}:
# TODO: This uses a lot of types.anything because noice.nvim types are quite complex.
# It should be possible to map them to nix, but they would not map really well through
# toLuaObject, we would maybe need some ad-hoc pre-processing functions.
with lib;
{
options.plugins.noice = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption ''
noice.nvim, an experimental nvim UI.
Note that if treesitter is enabled you need the following parsers:
vim, regex, lua, bash, markdown, markdown_inline
'';
package = lib.mkPackageOption pkgs "noice" {
default = [
"vimPlugins"
"noice-nvim"
];
};
cmdline = {
enabled = helpers.defaultNullOpts.mkBool true "enables Noice cmdline UI";
view = helpers.defaultNullOpts.mkStr "cmdline_popup" "";
opts = helpers.defaultNullOpts.mkAttrsOf types.anything { } "";
format =
helpers.defaultNullOpts.mkAttrsOf types.anything
{
cmdline = {
pattern = "^:";
icon = "";
lang = "vim";
};
search_down = {
kind = "search";
pattern = "^/";
icon = " ";
lang = "regex";
};
search_up = {
kind = "search";
pattern = "?%?";
icon = " ";
lang = "regex";
};
filter = {
pattern = "^:%s*!";
icon = "$";
lang = "bash";
};
lua = {
pattern = "^:%s*lua%s+";
icon = "";
lang = "lua";
};
help = {
pattern = "^:%s*he?l?p?%s+";
icon = "";
};
input = { };
}
''
conceal: (default=true) This will hide the text in the cmdline that matches the pattern.
view: (default is cmdline view)
opts: any options passed to the view
icon_hl_group: optional hl_group for the icon
title: set to anything or empty string to hide
lua = false, to disable a format, set to `false`
'';
};
messages = {
enabled = helpers.defaultNullOpts.mkBool true ''
Enables the messages UI.
NOTE: If you enable messages, then the cmdline is enabled automatically.
'';
view = helpers.defaultNullOpts.mkStr "notify" "default view for messages";
viewError = helpers.defaultNullOpts.mkStr "notify" "default view for errors";
viewWarn = helpers.defaultNullOpts.mkStr "notify" "default view for warnings";
viewHistory = helpers.defaultNullOpts.mkStr "messages" "view for :messages";
viewSearch = helpers.defaultNullOpts.mkStr "virtualtext" "view for search count messages";
};
popupmenu = {
enabled = helpers.defaultNullOpts.mkBool true "enables the Noice popupmenu UI";
backend = helpers.defaultNullOpts.mkEnumFirstDefault [
"nui"
"cmp"
] "";
kindIcons = helpers.defaultNullOpts.mkNullable (
with types; either bool (attrsOf anything)
) { } "Icons for completion item kinds. set to `false` to disable icons";
};
redirect = helpers.defaultNullOpts.mkAttrsOf types.anything {
view = "popup";
filter = {
event = "msg_show";
};
} "default options for require('noice').redirect";
commands = helpers.defaultNullOpts.mkAttrsOf types.anything {
history = {
view = "split";
opts = {
enter = true;
format = "details";
};
filter = {
any = [
{ event = "notify"; }
{ error = true; }
{ warning = true; }
{
event = "msg_show";
kind = [ "" ];
}
{
event = "lsp";
kind = "message";
}
];
};
};
last = {
view = "popup";
opts = {
enter = true;
format = "details";
};
filter = {
any = [
{ event = "notify"; }
{ error = true; }
{ warning = true; }
{
event = "msg_show";
kind = [ "" ];
}
{
event = "lsp";
kind = "message";
}
];
};
filter_opts = {
count = 1;
};
};
errors = {
view = "popup";
opts = {
enter = true;
format = "details";
};
filter = {
error = true;
};
filter_opts = {
reverse = true;
};
};
} "You can add any custom commands that will be available with `:Noice command`";
notify = {
enabled = helpers.defaultNullOpts.mkBool true ''
Enable notification handling.
Noice can be used as `vim.notify` so you can route any notification like other messages.
Notification messages have their level and other properties set.
event is always "notify" and kind can be any log level as a string.
The default routes will forward notifications to nvim-notify.
Benefit of using Noice for this is the routing and consistent history view.
'';
view = helpers.defaultNullOpts.mkStr "notify" "";
};
lsp = {
progress = {
enabled = helpers.defaultNullOpts.mkBool true "enable LSP progress";
format = helpers.defaultNullOpts.mkNullable (with types; either str anything) "lsp_progress" ''
Lsp Progress is formatted using the builtins for lsp_progress
'';
formatDone = helpers.defaultNullOpts.mkNullable (with types; either str anything) "lsp_progress" "";
throttle = helpers.defaultNullOpts.mkNum (literalExpression "1000 / 30") "frequency to update lsp progress message";
view = helpers.defaultNullOpts.mkStr "mini" "";
};
override = helpers.defaultNullOpts.mkAttrsOf types.bool {
"vim.lsp.util.convert_input_to_markdown_lines" = false;
"vim.lsp.util.stylize_markdown" = false;
"cmp.entry.get_documentation" = false;
} "";
hover = {
enabled = helpers.defaultNullOpts.mkBool true "enable hover UI";
view = helpers.defaultNullOpts.mkStr (literalMD "use defaults from documentation") ""; # TODO: description
opts =
helpers.defaultNullOpts.mkAttrsOf types.anything { }
"merged with defaults from documentation";
};
signature = {
enabled = helpers.defaultNullOpts.mkBool true "enable signature UI";
autoOpen = {
enabled = helpers.defaultNullOpts.mkBool true "";
trigger = helpers.defaultNullOpts.mkBool true "Automatically show signature help when typing a trigger character from the LSP";
luasnip = helpers.defaultNullOpts.mkBool true "Will open signature help when jumping to Luasnip insert nodes";
throttle = helpers.defaultNullOpts.mkNum 50 ''
Debounce lsp signature help request by 50ms
'';
};
view = helpers.defaultNullOpts.mkStr null "when null, use defaults from documentation";
opts =
helpers.defaultNullOpts.mkAttrsOf types.anything { }
"merged with defaults from documentation";
};
message = {
enabled = helpers.defaultNullOpts.mkBool true "enable display of messages";
view = helpers.defaultNullOpts.mkStr "notify" "";
opts = helpers.defaultNullOpts.mkAttrsOf types.anything { } "";
};
documentation = {
view = helpers.defaultNullOpts.mkStr "hover" "";
opts = helpers.defaultNullOpts.mkAttrsOf types.anything {
lang = "markdown";
replace = true;
render = "plain";
format = [ "{message}" ];
win_options = {
concealcursor = "n";
conceallevel = 3;
};
} "";
};
};
markdown = {
hover = helpers.defaultNullOpts.mkAttrsOf types.str {
"|(%S-)|".__raw = "vim.cmd.help"; # vim help links
"%[.-%]%((%S-)%)".__raw = "require('noice.util').open"; # markdown links
} "set handlers for hover (lua code)";
highlights = helpers.defaultNullOpts.mkAttrsOf types.str {
"|%S-|" = "@text.reference";
"@%S+" = "@parameter";
"^%s*(Parameters:)" = "@text.title";
"^%s*(Return:)" = "@text.title";
"^%s*(See also:)" = "@text.title";
"{%S-}" = "@parameter";
} "set highlight groups";
};
health = {
checker = helpers.defaultNullOpts.mkBool true "Disable if you don't want health checks to run";
};
smartMove = {
enabled = helpers.defaultNullOpts.mkBool true ''
Noice tries to move out of the way of existing floating windows.
You can disable this behaviour here
'';
excludedFiletypes =
helpers.defaultNullOpts.mkListOf types.str
[
"cmp_menu"
"cmp_docs"
"notify"
]
''
add any filetypes here, that shouldn't trigger smart move
'';
};
presets =
helpers.defaultNullOpts.mkNullable (with types; either bool anything)
{
bottom_search = false;
command_palette = false;
long_message_to_split = false;
inc_rename = false;
lsp_doc_border = false;
}
"
you can enable a preset by setting it to true, or a table that will override the preset
config. you can also add custom presets that you can enable/disable with enabled=true
";
throttle = helpers.defaultNullOpts.mkNum (literalExpression "1000 / 30") ''
how frequently does Noice need to check for ui updates? This has no effect when in blocking
mode
'';
views = helpers.defaultNullOpts.mkAttrsOf types.anything { } "";
routes = helpers.defaultNullOpts.mkListOf (types.attrsOf types.anything) [ ] "";
status = helpers.defaultNullOpts.mkAttrsOf types.anything { } "";
format = helpers.defaultNullOpts.mkAttrsOf types.anything { } "";
};
config =
let
cfg = config.plugins.noice;
setupOptions = {
inherit (cfg)
presets
views
routes
status
format
;
cmdline = {
inherit (cfg.cmdline)
enabled
view
opts
format
;
};
messages =
let
cfgM = cfg.messages;
in
{
inherit (cfgM) enabled view;
view_error = cfgM.viewError;
view_warn = cfgM.viewWarn;
view_history = cfgM.viewHistory;
view_search = cfgM.viewSearch;
};
popupmenu =
let
cfgP = cfg.popupmenu;
in
{
inherit (cfgP) enabled backend;
kind_icons = cfgP.kindIcons;
};
inherit (cfg) redirect commands;
notify = {
inherit (cfg.notify) enabled view;
};
lsp =
let
cfgL = cfg.lsp;
in
{
progress =
let
cfgLP = cfgL.progress;
in
{
inherit (cfgLP)
enabled
format
throttle
view
;
format_done = cfgLP.formatDone;
};
inherit (cfgL) override;
hover = {
inherit (cfgL.hover) enabled view opts;
};
signature =
let
cfgLS = cfgL.signature;
in
{
inherit (cfgLS) enabled view opts;
auto_open = {
inherit (cfgLS.autoOpen)
enabled
trigger
luasnip
throttle
;
};
};
message = {
inherit (cfgL.message) enabled view opts;
};
documentation = {
inherit (cfgL.documentation) view opts;
};
};
markdown = {
inherit (cfg.markdown) hover highlights;
};
health = {
inherit (cfg.health) checker;
};
smart_move =
let
cfgS = cfg.smartMove;
in
{
inherit (cfgS) enabled;
excluded_filetypes = cfgS.excludedFiletypes;
};
};
in
mkIf cfg.enable {
# nui-nvim & nvim-notify are dependencies of the vimPlugins.noice-nvim package
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require("noice").setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -0,0 +1,11 @@
{
lib,
...
}:
lib.nixvim.vim-plugin.mkVimPlugin {
name = "numbertoggle";
originalName = "vim-numbertoggle";
package = "vim-numbertoggle";
maintainers = [ lib.nixvim.maintainers.refaelsh ];
}

View file

@ -0,0 +1,137 @@
{
lib,
helpers,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin {
name = "specs";
originalName = "specs.nvim";
package = "specs-nvim";
maintainers = [ maintainers.GaetanLepage ];
# TODO: introduced 2024-06-10, remove on 2024-08-10
optionsRenamedToSettings = [
"show_jumps"
"min_jump"
];
imports =
let
basePluginPath = [
"plugins"
"specs"
];
settingsPath = basePluginPath ++ [ "settings" ];
renameToPopup =
old: new:
mkRenamedOptionModule (basePluginPath ++ [ old ]) (
settingsPath
++ [
"popup"
new
]
);
in
[
(renameToPopup "delay" "delay_ms")
(renameToPopup "increment" "inc_ms")
(renameToPopup "blend" "blend")
(renameToPopup "width" "width")
(mkRemovedOptionModule (
basePluginPath ++ [ "color" ]
) "Please, use `settings.popup.winhl` directly.")
(mkRemovedOptionModule (
basePluginPath ++ [ "fader" ]
) "Please, use `settings.popup.fader` directly.")
(mkRemovedOptionModule (
basePluginPath ++ [ "resizer" ]
) "Please, use `settings.popup.resizer` directly.")
(mkRemovedOptionModule (
basePluginPath ++ [ "ignored_filetypes" ]
) "Please, use `settings.ignore_filetypes` instead.")
(mkRemovedOptionModule (
basePluginPath ++ [ "ignored_buffertypes" ]
) "Please, use `settings.ignore_buftypes` instead.")
];
settingsOptions = {
show_jumps = helpers.defaultNullOpts.mkBool true ''
Whether to show an animation each time the cursor jumps.
'';
min_jump = helpers.defaultNullOpts.mkUnsignedInt 30 ''
Minimum jump distance to trigger the animation.
'';
popup = {
delay_ms = helpers.defaultNullOpts.mkUnsignedInt 10 ''
Delay before popup displays.
'';
inc_ms = helpers.defaultNullOpts.mkUnsignedInt 5 ''
Time increments used for fade/resize effects.
'';
blend = helpers.defaultNullOpts.mkUnsignedInt 10 ''
Starting blend, between 0 (opaque) and 100 (transparent), see `:h winblend`.
'';
width = helpers.defaultNullOpts.mkUnsignedInt 20 ''
Width of the popup.
'';
winhl = helpers.defaultNullOpts.mkStr "PMenu" ''
The name of the window highlight group of the popup.
'';
fader = helpers.defaultNullOpts.mkLuaFn "require('specs').exp_fader" ''
The fader function to use.
'';
resizer = helpers.defaultNullOpts.mkLuaFn "require('specs').shrink_resizer" ''
The resizer function to use.
'';
};
ignore_filetypes = helpers.defaultNullOpts.mkAttrsOf types.bool { } ''
An attrs where keys are filetypes and values are a boolean stating whether animation should be
enabled or not for this filetype.
'';
ignore_buftypes = helpers.defaultNullOpts.mkAttrsOf types.bool { nofile = true; } ''
An attrs where keys are buftypes and values are a boolean stating whether animation should be
enabled or not for this buftype.
'';
};
settingsExample = {
show_jumps = true;
min_jump = 30;
popup = {
delay_ms = 0;
inc_ms = 10;
blend = 10;
width = 10;
winhl = "PMenu";
fader = ''
function(blend, cnt)
if cnt > 100 then
return 80
else return nil end
end
'';
resizer = ''
function(width, ccol, cnt)
if width-cnt > 0 then
return {width+cnt, ccol}
else return nil end
end
'';
};
ignore_filetypes = { };
ignore_buftypes = {
nofile = true;
};
};
}

View file

@ -0,0 +1,177 @@
{
lib,
helpers,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin {
name = "statuscol";
originalName = "statuscol.nvim";
package = "statuscol-nvim";
maintainers = [ maintainers.GaetanLepage ];
settingsOptions = {
setopt = helpers.defaultNullOpts.mkBool true ''
Whether to set the `statuscolumn` option, may be set to false for those who want to use the
click handlers in their own `statuscolumn`: `_G.Sc[SFL]a()`.
Although I recommend just using the segments field below to build your statuscolumn to
benefit from the performance optimizations in this plugin.
'';
thousands = helpers.defaultNullOpts.mkNullable (with types; either str (enum [ false ])) false ''
`false` or line number thousands separator string ("." / ",").
'';
relculright = helpers.defaultNullOpts.mkBool false ''
Whether to right-align the cursor line number with `relativenumber` set.
'';
ft_ignore = helpers.defaultNullOpts.mkListOf types.str null ''
Lua table with 'filetype' values for which `statuscolumn` will be unset.
'';
bt_ignore = helpers.defaultNullOpts.mkListOf types.str null ''
Lua table with 'buftype' values for which `statuscolumn` will be unset.
'';
segments =
let
segmentType = types.submodule {
freeformType = with types; attrsOf anything;
options = {
text = mkOption {
type = with helpers.nixvimTypes; nullOr (listOf (either str rawLua));
default = null;
description = "Segment text.";
example = [ "%C" ];
};
click = helpers.mkNullOrStr ''
`%@` click function label, applies to each text element.
'';
hl = helpers.mkNullOrStr ''
`%#` highlight group label, applies to each text element.
'';
condition = helpers.mkNullOrOption (
with helpers.nixvimTypes; listOf (either bool rawLua)
) "Table of booleans or functions returning a boolean.";
sign = {
name = helpers.defaultNullOpts.mkListOf types.str [ ] ''
List of lua patterns to match the sign name against.
'';
text = helpers.defaultNullOpts.mkListOf types.str [ ] ''
List of lua patterns to match the extmark sign text against.
'';
namespace = helpers.defaultNullOpts.mkListOf types.str [ ] ''
List of lua patterns to match the extmark sign namespace against.
'';
maxwidth = helpers.defaultNullOpts.mkUnsignedInt 1 ''
Maximum number of signs that will be displayed in this segment
'';
colwidth = helpers.defaultNullOpts.mkUnsignedInt 2 ''
Maximum number of display cells per sign in this segment.
'';
auto = helpers.defaultNullOpts.mkBool false ''
When true, the segment will not be drawn if no signs matching the pattern are
currently placed in the buffer.
'';
fillchar = helpers.defaultNullOpts.mkStr " " ''
Character used to fill a segment with less signs than maxwidth.
'';
fillcharhl = helpers.mkNullOrStr ''
Highlight group used for fillchar (SignColumn/CursorLineSign if omitted).
'';
};
};
};
in
helpers.defaultNullOpts.mkListOf segmentType [
{
text = [ "%C" ];
click = "v:lua.ScFa";
}
{
text = [ "%s" ];
click = "v:lua.ScSa";
}
{
text = [
{ __raw = "require('statuscol.builtin').lnumfunc"; }
" "
];
condition = [
true
{ __raw = "require('statuscol.builtin').not_empty"; }
];
click = "v:lua.ScLa";
}
] "The statuscolumn can be customized through the `segments` option.";
clickmod = helpers.defaultNullOpts.mkStr "c" ''
Modifier used for certain actions in the builtin clickhandlers:
`a` for Alt, `c` for Ctrl and `m` for Meta.
'';
clickhandlers = mkOption {
type = with helpers.nixvimTypes; attrsOf strLuaFn;
default = { };
description = ''
Builtin click handlers.
'';
apply = mapAttrs (_: helpers.mkRaw);
example = {
Lnum = "require('statuscol.builtin').lnum_click";
FoldClose = "require('statuscol.builtin').foldclose_click";
FoldOpen = "require('statuscol.builtin').foldopen_click";
FoldOther = "require('statuscol.builtin').foldother_click";
};
};
};
settingsExample = {
setopt = true;
thousands = ".";
relculright = true;
ft_ignore = null;
bt_ignore = null;
segments = [
{
text = [ "%C" ];
click = "v:lua.ScFa";
}
{
text = [ "%s" ];
click = "v:lua.ScSa";
}
{
text = [
{ __raw = "require('statuscol.builtin').lnumfunc"; }
" "
];
condition = [
true
{ __raw = "require('statuscol.builtin').not_empty"; }
];
click = "v:lua.ScLa";
}
];
clickmod = "c";
clickhandlers = {
Lnum = "require('statuscol.builtin').lnum_click";
FoldClose = "require('statuscol.builtin').foldclose_click";
FoldOpen = "require('statuscol.builtin').foldopen_click";
FoldOther = "require('statuscol.builtin').foldother_click";
};
};
}

View file

@ -0,0 +1,68 @@
{
lib,
helpers,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin {
name = "transparent";
originalName = "transparent.nvim";
package = "transparent-nvim";
maintainers = [ maintainers.GaetanLepage ];
settingsOptions = {
groups =
helpers.defaultNullOpts.mkListOf types.str
[
"Normal"
"NormalNC"
"Comment"
"Constant"
"Special"
"Identifier"
"Statement"
"PreProc"
"Type"
"Underlined"
"Todo"
"String"
"Function"
"Conditional"
"Repeat"
"Operator"
"Structure"
"LineNr"
"NonText"
"SignColumn"
"CursorLine"
"CursorLineNr"
"StatusLine"
"StatusLineNC"
"EndOfBuffer"
]
''
The list of transparent groups.
'';
extra_groups = helpers.defaultNullOpts.mkListOf types.str [ ] ''
Additional groups that should be cleared.
'';
exclude_groups = helpers.defaultNullOpts.mkListOf types.str [ ] ''
Groups that you don't want to clear.
'';
};
settingsExample = {
extra_groups = [
"BufferLineTabClose"
"BufferLineBufferSelected"
"BufferLineFill"
"BufferLineBackground"
"BufferLineSeparator"
"BufferLineIndicatorSelected"
];
exclude_groups = [ ];
};
}

View file

@ -0,0 +1,80 @@
{
lib,
helpers,
config,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin {
name = "twilight";
originalName = "twilight.nvim";
package = "twilight-nvim";
maintainers = [ maintainers.GaetanLepage ];
settingsOptions = {
dimming = {
alpha = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.25 ''
Amount of dimming.
'';
color =
helpers.defaultNullOpts.mkListOf types.str
[
"Normal"
"#ffffff"
]
''
Highlight groups / colors to use.
'';
term_bg = helpers.defaultNullOpts.mkStr "#000000" ''
If `guibg=NONE`, this will be used to calculate text color.
'';
inactive = helpers.defaultNullOpts.mkBool false ''
When true, other windows will be fully dimmed (unless they contain the same buffer).
'';
};
context = helpers.defaultNullOpts.mkUnsignedInt 10 ''
Amount of lines we will try to show around the current line.
'';
treesitter = helpers.defaultNullOpts.mkBool true ''
Use `treesitter` when available for the filetype.
`treesitter` is used to automatically expand the visible text, but you can further control
the types of nodes that should always be fully expanded.
'';
expand = helpers.defaultNullOpts.mkListOf types.str [
"function"
"method"
"table"
"if_statement"
] "For treesitter, we will always try to expand to the top-most ancestor with these types.";
exclude = helpers.defaultNullOpts.mkListOf types.str [ ] ''
Exclude these filetypes.
'';
};
settingsExample = {
dimming.alpha = 0.4;
context = 20;
treesitter = true;
expand = [
"function"
"method"
];
};
extraConfig = cfg: {
warnings =
optional
((isBool cfg.settings.treesitter) && cfg.settings.treesitter && (!config.plugins.treesitter.enable))
''
Nixvim (plugins.twilight): You have set `plugins.twilight.treesitter` to `true` but `plugins.treesitter.enable` is false.
'';
};
}

View file

@ -0,0 +1,75 @@
{
lib,
helpers,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin {
name = "virt-column";
originalName = "virt-column.nvim";
package = "virt-column-nvim";
maintainers = [ helpers.maintainers.alisonjenkins ];
settingsOptions = {
enabled = helpers.defaultNullOpts.mkBool true ''
Enables or disables virt-column.
'';
char = helpers.defaultNullOpts.mkNullable (with types; either str (listOf str)) [ "" ] ''
Character, or list of characters, that get used to display the virtual column.
Each character has to have a display width of 0 or 1.
'';
virtcolumn = helpers.defaultNullOpts.mkStr "" ''
Comma-separated list of screen columns same syntax as `:help colorcolumn`.
'';
highlight = helpers.defaultNullOpts.mkNullable (with types; either str (listOf str)) "NonText" ''
Highlight group, or list of highlight groups, that get applied to the virtual column.
'';
exclude = {
filetypes = helpers.defaultNullOpts.mkListOf types.str [
"lspinfo"
"packer"
"checkhealth"
"help"
"man"
"TelescopePrompt"
"TelescopeResults"
] "List of `filetype`s for which virt-column is disabled.";
buftypes = helpers.defaultNullOpts.mkListOf types.str [
"nofile"
"quickfix"
"terminal"
"prompt"
] "List of `buftype`s for which virt-column is disabled.";
};
};
settingsExample = {
enabled = true;
char = "";
virtcolumn = "";
highlight = "NonText";
exclude = {
filetypes = [
"lspinfo"
"packer"
"checkhealth"
"help"
"man"
"TelescopePrompt"
"TelescopeResults"
];
buftypes = [
"nofile"
"quickfix"
"terminal"
"prompt"
];
};
};
}

View file

@ -0,0 +1,139 @@
{
lib,
helpers,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin {
name = "zen-mode";
originalName = "zen-mode.nvim";
package = "zen-mode-nvim";
maintainers = [ maintainers.GaetanLepage ];
# Optionally, explicitly declare some options. You don't have to.
settingsOptions = {
window = {
backdrop = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.95 ''
Shade the backdrop of the Zen window.
Set to 1 to keep the same as Normal.
'';
width =
helpers.defaultNullOpts.mkNullable
(
with helpers.nixvimTypes;
oneOf [
ints.positive
(numbers.between 0.0 1.0)
rawLua
]
)
120
''
Width of the zen window.
Can be:
- an absolute number of cells when > 1
- a percentage of the width / height of the editor when <= 1
- a function that returns the width or the height
'';
height =
helpers.defaultNullOpts.mkNullable
(
with helpers.nixvimTypes;
oneOf [
ints.positive
(numbers.between 0.0 1.0)
rawLua
]
)
1
''
Height of the Zen window.
Can be:
- an absolute number of cells when > 1
- a percentage of the width / height of the editor when <= 1
- a function that returns the width or the height
'';
options = helpers.defaultNullOpts.mkAttrsOf types.anything { } ''
By default, no options are changed for the Zen window.
You can set any `vim.wo` option here.
Example:
```nix
{
signcolumn = "no";
number = false;
relativenumber = false;
cursorline = false;
cursorcolumn = false;
foldcolumn = "0";
list = false;
}
```
'';
};
plugins = {
options =
helpers.defaultNullOpts.mkAttrsOf types.anything
{
enabled = true;
ruler = false;
showcmd = false;
laststatus = 0;
}
''
Disable some global vim options (`vim.o`...).
'';
};
on_open = helpers.defaultNullOpts.mkLuaFn "function(win) end" ''
Callback where you can add custom code when the Zen window opens.
'';
on_close = helpers.defaultNullOpts.mkLuaFn "function(win) end" ''
Callback where you can add custom code when the Zen window closes.
'';
};
settingsExample = {
window = {
backdrop = 0.95;
width = 0.8;
height = 1;
options.signcolumn = "no";
};
plugins = {
options = {
enabled = true;
ruler = false;
showcmd = false;
};
twilight.enabled = false;
gitsigns.enabled = true;
tmux.enabled = false;
};
on_open = ''
function()
require("gitsigns.actions").toggle_current_line_blame()
vim.cmd('IBLDisable')
vim.opt.relativenumber = false
vim.opt.signcolumn = "no"
require("gitsigns.actions").refresh()
end
'';
on_close = ''
function()
require("gitsigns.actions").toggle_current_line_blame()
vim.cmd('IBLEnable')
vim.opt.relativenumber = true
vim.opt.signcolumn = "yes:2"
require("gitsigns.actions").refresh()
end
'';
};
}