plugins/lsp: move related plugins to by-name

This commit is contained in:
Matt Sturgeon 2024-09-04 17:47:06 +01:00
parent 91c6b62881
commit 8815180c62
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
23 changed files with 0 additions and 11 deletions

View file

@ -1,238 +0,0 @@
{
lib,
...
}:
let
inherit (lib) types;
inherit (lib.nixvim) defaultNullOpts mkRaw;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "conform-nvim";
luaName = "conform";
originalName = "conform.nvim";
maintainers = [ lib.maintainers.khaneliman ];
# TODO: added 2024-08-23 remove after 24.11
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"formatters"
"formattersByFt"
"logLevel"
"notifyOnError"
];
imports =
map
(
optionName:
lib.mkRemovedOptionModule
[
"plugins"
"conform-nvim"
optionName
]
''
Please use `plugins.conform-nvim.settings.${lib.nixvim.toSnakeCase optionName}` instead.
Note that nested options will now be snake_case, as well, to match upstream plugin configuration.
''
)
[
"formatAfterSave"
"formatOnSave"
];
settingsOptions =
let
lsp_format =
defaultNullOpts.mkEnumFirstDefault
[
"never"
"fallback"
"prefer"
"first"
"last"
]
''
Option for choosing lsp formatting preference.
- `never`: never use the LSP for formatting.
- `fallback`: LSP formatting is used when no other formatters are available.
- `prefer`: Use only LSP formatting when available.
- `first`: LSP formatting is used when available and then other formatters.
- `last`: Other formatters are used then LSP formatting when available.
'';
timeout_ms = defaultNullOpts.mkUnsignedInt 1000 "Time in milliseconds to block for formatting.";
quiet = defaultNullOpts.mkBool false "Don't show any notifications for warnings or failures.";
stop_after_first = defaultNullOpts.mkBool false "Only run the first available formatter in the list.";
# NOTE: These are the available options for the `default_format_opts` opt.
# They are also included in the `format_opts` options available to `format_after_save` and `format_on_save`.
defaultFormatSubmodule =
with types;
(submodule {
freeformType = attrsOf anything;
options = {
inherit
lsp_format
timeout_ms
quiet
stop_after_first
;
};
});
in
{
formatters_by_ft = defaultNullOpts.mkAttrsOf types.anything { } ''
Creates a table mapping filetypes to formatters.
You can run multiple formatters in a row by adding them in a list.
If you'd like to stop after the first successful formatter, set `stop_after_first`.
```nix
# Map of filetype to formatters
formatters_by_ft =
{
lua = [ "stylua" ];
# Conform will run multiple formatters sequentially
python = [ "isort" "black" ];
# Use stop_after_first to run only the first available formatter
javascript = {
__unkeyed-1 = "prettierd";
__unkeyed-2 = "prettier";
stop_after_first = true;
};
# Use the "*" filetype to run formatters on all filetypes.
"*" = [ "codespell" ];
# Use the "_" filetype to run formatters on filetypes that don't
# have other formatters configured.
"_" = [ "trim_whitespace" ];
};
```
'';
format_on_save = defaultNullOpts.mkNullable' {
type = with types; either strLuaFn defaultFormatSubmodule;
pluginDefault = { };
description = ''
If this is set, Conform will run the formatter asynchronously on save.
Conform will pass the table from `format_on_save` to `conform.format()`.
This can also be a function that returns the table.
See `:help conform.format` for details.
'';
apply = v: if lib.isString v then mkRaw v else v;
};
default_format_opts = defaultNullOpts.mkNullable defaultFormatSubmodule { } ''
The default options to use when calling `conform.format()`.
'';
format_after_save = defaultNullOpts.mkNullable' {
type = with types; either strLuaFn defaultFormatSubmodule;
pluginDefault = { };
description = ''
If this is set, Conform will run the formatter asynchronously after save.
Conform will pass the table from `format_after_save` to `conform.format()`.
This can also be a function that returns the table.
See `:help conform.format` for details.
'';
apply = v: if lib.isString v then mkRaw v else v;
};
log_level = defaultNullOpts.mkLogLevel "error" ''
Set the log level. Use `:ConformInfo` to see the location of the log file.
'';
notify_on_error = defaultNullOpts.mkBool true "Conform will notify you when a formatter errors.";
notify_no_formatters = defaultNullOpts.mkBool true "Conform will notify you when no formatters are available for the buffer.";
formatters =
defaultNullOpts.mkAttrsOf types.anything { }
"Custom formatters and changes to built-in formatters.";
};
settingsExample = lib.literalMD ''
```nix
{
formatters_by_ft = {
bash = [
"shellcheck"
"shellharden"
"shfmt"
];
cpp = [ "clang_format" ];
javascript = {
__unkeyed-1 = "prettierd";
__unkeyed-2 = "prettier";
timeout_ms = 2000;
stop_after_first = true;
};
"_" = [
"squeeze_blanks"
"trim_whitespace"
"trim_newlines"
];
};
format_on_save = # Lua
'''
function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
if slow_format_filetypes[vim.bo[bufnr].filetype] then
return
end
local function on_format(err)
if err and err:match("timeout$") then
slow_format_filetypes[vim.bo[bufnr].filetype] = true
end
end
return { timeout_ms = 200, lsp_fallback = true }, on_format
end
''';
format_after_save = # Lua
'''
function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
if not slow_format_filetypes[vim.bo[bufnr].filetype] then
return
end
return { lsp_fallback = true }
end
''';
log_level = "warn";
notify_on_error = false;
notify_no_formatters = false;
formatters = {
shellcheck = {
command = lib.getExe pkgs.shellcheck;
};
shfmt = {
command = lib.getExe pkgs.shfmt;
};
shellharden = {
command = lib.getExe pkgs.shellharden;
};
squeeze_blanks = {
command = lib.getExe' pkgs.coreutils "cat";
};
};
}
```
'';
}

View file

@ -1,683 +0,0 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
cfg = config.plugins.fidget;
mkIconOption =
default: desc:
helpers.defaultNullOpts.mkNullable
(
with types;
oneOf [
str
helpers.nixvimTypes.rawLua
(listOf str)
(attrsOf (either str ints.unsigned))
]
)
default
''
${desc}
- When a string literal is given (e.g., `""`), it is used as a static icon.
- When a list or attrs (e.g., `["dots"]` or `{pattern = "clock"; period = 2;}`) is given, it
is used to generate an animation function.
- When a function is specified (e.g., `{__raw = "function(now) return now % 2 < 1 and '+' or '-' end";}`),
it is used as the animation function.
'';
notificationConfigType = types.submodule {
options = {
name = helpers.mkNullOrOption types.str ''
Name of the group; if `null`, the key is used as name.
'';
icon = helpers.mkNullOrOption types.str ''
Icon of the group; if `null`, no icon is used.
'';
iconOnLeft = helpers.mkNullOrOption types.bool ''
If true, icon is rendered on the left instead of right.
'';
annoteSeparator = helpers.defaultNullOpts.mkStr " " ''
Separator between message from annote.
'';
ttl = helpers.defaultNullOpts.mkUnsignedInt 3 ''
How long a notification item should exist.
'';
renderLimit = helpers.mkNullOrOption types.ints.unsigned ''
How many notification items to show at once.
'';
groupStyle = helpers.defaultNullOpts.mkStr "Title" ''
Style used to highlight group name.
'';
iconStyle = helpers.mkNullOrOption types.str ''
Style used to highlight icon; if `null`, use `groupStyle`.
'';
annoteStyle = helpers.defaultNullOpts.mkStr "Question" ''
Default style used to highlight item annotes.
'';
debugStyle = helpers.mkNullOrOption types.str ''
Style used to highlight debug item annotes.
'';
infoStyle = helpers.mkNullOrOption types.str ''
Style used to highlight info item annotes.
'';
warnStyle = helpers.mkNullOrOption types.str ''
Style used to highlight warn item annotes.
'';
errorStyle = helpers.mkNullOrOption types.str ''
Style used to highlight error item annotes.
'';
debugAnnote = helpers.mkNullOrOption types.str ''
Default annotation for debug items.
'';
infoAnnote = helpers.mkNullOrOption types.str ''
Default annotation for info items.
'';
warnAnnote = helpers.mkNullOrOption types.str ''
Default annotation for warn items.
'';
errorAnnote = helpers.mkNullOrOption types.str ''
Default annotation for error items.
'';
priority = helpers.defaultNullOpts.mkUnsignedInt 50 ''
Order in which group should be displayed.
'';
skipHistory = helpers.defaultNullOpts.mkBool true ''
Whether progress notifications should be omitted from history.
'';
};
};
in
{
# TODO: deprecation warnings introduced 2023/12/22: remove in early February 2024
imports =
map
(
oldOption:
mkRemovedOptionModule
[
"plugins"
"fidget"
oldOption
]
''
Nixvim: The fidget.nvim plugin has been completely rewritten. Hence, the options have changed.
Please, take a look at the updated documentation and adapt your configuration accordingly.
> https://github.com/j-hui/fidget.nvim
''
)
[
"text"
"align"
"timer"
"window"
"fmt"
"sources"
"debug"
];
options = {
plugins.fidget = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "fidget-nvim";
package = lib.mkPackageOption pkgs "fidget-nvim" {
default = [
"vimPlugins"
"fidget-nvim"
];
};
# Options related to LSP progress subsystem
progress = {
pollRate = helpers.defaultNullOpts.mkNullable (with types; either (enum [ false ]) number) 0 ''
How and when to poll for progress messages.
Set to `0` to immediately poll on each `|LspProgress|` event.
Set to a positive number to poll for progress messages at the specified frequency
(Hz, i.e., polls per second).
Combining a slow `poll_rate` (e.g., `0.5`) with the `ignoreDoneAlready` setting can be
used to filter out short-lived progress tasks, de-cluttering notifications.
Note that if too many LSP progress messages are sent between polls, Neovim's progress
ring buffer will overflow and messages will be overwritten (dropped), possibly causing
stale progress notifications.
Workarounds include using the `|fidget.option.progress.lsp.progress_ringbuf_size|`
option, or manually calling `|fidget.notification.reset|`.
Set to `false` to disable polling altogether; you can still manually poll progress
messages by calling `|fidget.progress.poll|`.
'';
suppressOnInsert = helpers.defaultNullOpts.mkBool false ''
Suppress new messages while in insert mode.
Note that progress messages for new tasks will be dropped, but existing tasks will be
processed to completion.
'';
ignoreDoneAlready = helpers.defaultNullOpts.mkBool false ''
Ignore new tasks that are already complete.
This is useful if you want to avoid excessively bouncy behavior, and only seeing
notifications for long-running tasks. Works best when combined with a low `pollRate`.
'';
ignoreEmptyMessage = helpers.defaultNullOpts.mkBool true ''
Ignore new tasks that don't contain a message.
Some servers may send empty messages for tasks that don't actually exist.
And if those tasks are never completed, they will become stale in Fidget.
This option tells Fidget to ignore such messages unless the LSP server has anything
meaningful to say.
Note that progress messages for new empty tasks will be dropped, but existing tasks will
be processed to completion.
'';
notificationGroup = helpers.defaultNullOpts.mkLuaFn "function(msg) return msg.lsp_name end" ''
How to get a progress message's notification group key
Set this to return a constant to group all LSP progress messages together.
Example:
```lua
notification_group = function(msg)
-- N.B. you may also want to configure this group key ("lsp_progress")
-- using progress.display.overrides or notification.configs
return "lsp_progress"
end
```
'';
clearOnDetach =
helpers.defaultNullOpts.mkStrLuaFnOr (types.enum [ false ])
''
function(client_id)
local client = vim.lsp.get_client_by_id(client_id)
return client and client.name or nil
end
''
''
Clear notification group when LSP server detaches
This option should be set to a function that, given a client ID number, returns the
notification group to clear.
No group will be cleared if the function returns `nil`.
The default setting looks up and returns the LSP client name, which is also used by
`notificationGroup`.
Set this option to `false` to disable this feature entirely (no `|LspDetach|` callback
will be installed).
'';
ignore = helpers.defaultNullOpts.mkListOf types.str [ ] ''
List of LSP servers to ignore.
'';
# Options related to how LSP progress messages are displayed as notifications
display = {
renderLimit = helpers.defaultNullOpts.mkNullable (with types; either (enum [ false ]) number) 16 ''
How many LSP messages to show at once.
If `false`, no limit.
This is used to configure each LSP notification group, so by default, this is a
per-server limit.
'';
doneTtl = helpers.defaultNullOpts.mkStrLuaOr types.ints.unsigned "3" ''
How long a message should persist after completion.
Set to `0` to use notification group config default, and `math.huge` to show
notification indefinitely (until overwritten).
Measured in seconds.
'';
doneIcon = mkIconOption "" "Icon shown when all LSP progress tasks are complete.";
doneStyle = helpers.defaultNullOpts.mkStr "Constant" ''
Highlight group for completed LSP tasks.
'';
progressTtl = helpers.defaultNullOpts.mkStrLuaFnOr types.ints.unsigned "math.huge" ''
How long a message should persist when in progress.
'';
progressIcon = mkIconOption ''
{
pattern = "dots";
}
'' "Icon shown when LSP progress tasks are in progress";
progressStyle = helpers.defaultNullOpts.mkStr "WarningMsg" ''
Highlight group for in-progress LSP tasks.
'';
groupStyle = helpers.defaultNullOpts.mkStr "Title" ''
Highlight group for group name (LSP server name).
'';
iconStyle = helpers.defaultNullOpts.mkStr "Question" ''
Highlight group for group icons.
'';
priority = helpers.defaultNullOpts.mkUnsignedInt 30 ''
Ordering priority for LSP notification group.
'';
skipHistory = helpers.defaultNullOpts.mkBool true ''
Whether progress notifications should be omitted from history.
'';
formatMessage = helpers.defaultNullOpts.mkLua "require('fidget.progress.display').default_format_message" ''
How to format a progress message.
```lua
format_message = function(msg)
if string.find(msg.title, "Indexing") then
return nil -- Ignore "Indexing..." progress messages
end
if msg.message then
return msg.message
else
return msg.done and "Completed" or "In progress..."
end
end
```
'';
formatAnnote = helpers.defaultNullOpts.mkLuaFn "function(msg) return msg.title end" "How to format a progress annotation.";
formatGroupName = helpers.defaultNullOpts.mkLuaFn "function(group) return tostring(group) end" "How to format a progress notification group's name.";
overrides =
helpers.defaultNullOpts.mkAttrsOf notificationConfigType
{
rust_analyzer = {
name = "rust-analyzer";
};
}
''
Override options from the default notification config.
Keys of the table are each notification group's `key`.
'';
};
# Options related to Neovim's built-in LSP client
lsp = {
progressRingbufSize = helpers.defaultNullOpts.mkUnsignedInt 0 ''
Configure the nvim's LSP progress ring buffer size.
Useful for avoiding progress message overflow when the LSP server blasts more messages
than the ring buffer can handle.
Leaves the progress ringbuf size at its default if this setting is 0 or less.
Doesn't do anything for Neovim pre-v0.10.0.
'';
};
};
# Options related to notification subsystem
notification = {
pollRate = helpers.defaultNullOpts.mkUnsignedInt 10 ''
How frequently to update and render notifications.
Measured in Hertz (frames per second).
'';
filter = helpers.defaultNullOpts.mkLogLevel "info" ''
Minimum notifications level.
Note that this filter only applies to notifications with an explicit numeric level
(i.e., `vim.log.levels`).
Set to `"off"` to filter out all notifications with an numeric level, or `"trace"` to
turn off filtering.
'';
historySize = helpers.defaultNullOpts.mkUnsignedInt 128 ''
Number of removed messages to retain in history.
Set to 0 to keep around history indefinitely (until cleared).
'';
overrideVimNotify = helpers.defaultNullOpts.mkBool false ''
Automatically override `vim.notify()` with Fidget.
Equivalent to the following:
```lua
fidget.setup({ --[[ options ]] })
vim.notify = fidget.notify
```
'';
configs =
helpers.defaultNullOpts.mkAttrsOf (with types; either str notificationConfigType)
{ default = "require('fidget.notification').default_config"; }
''
How to configure notification groups when instantiated.
A configuration with the key `"default"` should always be specified, and is used as
the fallback for notifications lacking a group key.
To see the default config, run:
`:lua print(vim.inspect(require("fidget.notification").default_config))`
'';
redirect =
helpers.defaultNullOpts.mkStrLuaFnOr (types.enum [ false ])
''
function(msg, level, opts)
if opts and opts.on_open then
return require("fidget.integration.nvim-notify").delegate(msg, level, opts)
end
end
''
''
Conditionally redirect notifications to another backend.
This option is useful for delegating notifications to another backend that supports
features Fidget has not (yet) implemented.
For instance, Fidget uses a single, shared buffer and window for rendering all
notifications, so it lacks a per-notification `on_open` callback that can be used to,
e.g., set the `|filetype|` for a specific notification.
For such notifications, Fidget's default `redirect` delegates such notifications with
an `on_open` callback to `|nvim-notify|` (if available).
'';
# Options related to how notifications are rendered as text
view = {
stackUpwards = helpers.defaultNullOpts.mkBool true ''
Display notification items from bottom to top.
Setting this to `true` tends to lead to more stable animations when the window is
bottom-aligned.
'';
iconSeparator = helpers.defaultNullOpts.mkStr " " ''
Separator between group name and icon.
Must not contain any newlines.
Set to `""` to remove the gap between names and icons in all notification groups.
'';
groupSeparator =
helpers.defaultNullOpts.mkNullable (with types; either str (enum [ false ])) "---"
''
Separator between notification groups.
Must not contain any newlines.
Set to `false` to omit separator entirely.
'';
groupSeparatorHl = helpers.defaultNullOpts.mkNullable (
with types; either str (enum [ false ])
) "Comment" "Highlight group used for group separator.";
};
# Options related to the notification window and buffer
window = {
normalHl = helpers.defaultNullOpts.mkStr "Comment" ''
Base highlight group in the notification window.
Used by any Fidget notification text that is not otherwise highlighted, i.e., message
text.
Note that we use this blanket highlight for all messages to avoid adding separate
highlights to each line (whose lengths may vary).
Set to empty string to keep your theme defaults.
With `winblend` set to anything less than `100`, this will also affect the background
color in the notification box area (see `winblend` docs).
'';
winblend = helpers.defaultNullOpts.mkUnsignedInt 100 ''
Background color opacity in the notification window.
Note that the notification window is rectangular, so any cells covered by that
rectangular area is affected by the background color of `normal_hl`.
With `winblend` set to anything less than `100`, the background of `normal_hl` will be
blended with that of whatever is underneath, including, e.g., a shaded `colorcolumn`,
which is usually not desirable.
However, if you would like to display the notification window as its own "boxed" area
(especially if you are using a non-"none" `border`), you may consider setting
`winblend` to something less than `100`.
'';
border = helpers.defaultNullOpts.mkBorder "none" "the notification window" "";
borderHl = helpers.defaultNullOpts.mkStr "" ''
Highlight group for notification window border.
Set to empty string to keep your theme's default `FloatBorder` highlight.
'';
zindex = helpers.defaultNullOpts.mkUnsignedInt 45 ''
Stacking priority of the notification window.
Note that the default priority for Vim windows is 50.
'';
maxWidth = helpers.defaultNullOpts.mkUnsignedInt 0 ''
Maximum width of the notification window.
`0` means no maximum width.
'';
maxHeight = helpers.defaultNullOpts.mkUnsignedInt 0 ''
Maximum height of the notification window.
`0` means no maximum height.
'';
xPadding = helpers.defaultNullOpts.mkUnsignedInt 1 ''
Padding from right edge of window boundary.
'';
yPadding = helpers.defaultNullOpts.mkUnsignedInt 0 ''
Padding from bottom edge of window boundary.
'';
align =
helpers.defaultNullOpts.mkEnum
[
"top"
"bottom"
"avoid_cursor"
]
"bottom"
''
How to align the notification window.
'';
relative =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"editor"
"win"
]
''
What the notification window position is relative to.
'';
};
};
integration = {
nvim-tree = {
enable = helpers.defaultNullOpts.mkBool true ''
Integrate with nvim-tree/nvim-tree.lua (if installed).
Dynamically offset Fidget's notifications window when the nvim-tree window is open on
the right side + the Fidget window is "editor"-relative.
'';
};
};
# Options related to logging
logger = {
level = helpers.defaultNullOpts.mkLogLevel "warn" "Minimum logging level";
floatPrecision = helpers.defaultNullOpts.mkNullable (
with types; numbers.between 0.0 1.0
) 1.0e-2 "Limit the number of decimals displayed for floats.";
path =
helpers.defaultNullOpts.mkStr
{ __raw = "string.format('%s/fidget.nvim.log', vim.fn.stdpath('cache'))"; }
''
Where Fidget writes its logs to.
Using `{__raw = "vim.fn.stdpath('cache')";}`, the default path usually ends up at
`~/.cache/nvim/fidget.nvim.log`.
'';
};
};
};
config = mkIf cfg.enable {
warnings =
optional
(
(isBool cfg.integration.nvim-tree.enable)
&& cfg.integration.nvim-tree.enable
&& !config.plugins.nvim-tree.enable
)
''
You have set `plugins.fidget.integrations.nvim-tree.enable` to true but have not enabled `plugins.nvim-tree`.
'';
extraPlugins = [ cfg.package ];
extraConfigLua =
let
processNotificationConfig =
notificationConfig: with notificationConfig; {
inherit name icon;
icon_on_left = iconOnLeft;
annote_separator = annoteSeparator;
inherit ttl;
render_limit = renderLimit;
group_style = groupStyle;
icon_style = iconStyle;
annote_style = annoteStyle;
debug_style = debugStyle;
info_style = infoStyle;
warn_style = warnStyle;
error_style = errorStyle;
debug_annote = debugAnnote;
info_annote = infoAnnote;
warn_annote = warnAnnote;
error_annote = errorAnnote;
inherit priority;
skip_history = skipHistory;
};
setupOptions =
with cfg;
{
progress = with progress; {
poll_rate = pollRate;
suppress_on_insert = suppressOnInsert;
ignore_done_already = ignoreDoneAlready;
ignore_empty_message = ignoreEmptyMessage;
notification_group = notificationGroup;
clear_on_detach = clearOnDetach;
inherit ignore;
display = with display; {
render_limit = renderLimit;
done_ttl = doneTtl;
done_icon = doneIcon;
done_style = doneStyle;
progress_ttl = progressTtl;
progress_icon = progressIcon;
progress_style = progressStyle;
group_style = groupStyle;
icon_style = iconStyle;
inherit priority;
skip_history = skipHistory;
format_message = formatMessage;
format_annote = formatAnnote;
format_group_name = formatGroupName;
overrides = helpers.ifNonNull' overrides (mapAttrs (_: processNotificationConfig) overrides);
};
lsp = with lsp; {
progress_ringbuf_size = progressRingbufSize;
};
};
notification = with notification; {
poll_rate = pollRate;
inherit filter;
history_size = historySize;
override_vim_notify = overrideVimNotify;
configs = helpers.ifNonNull' configs (
mapAttrs (
_: value: if isString value then helpers.mkRaw value else processNotificationConfig value
) configs
);
inherit redirect;
view = with view; {
stack_upwards = stackUpwards;
icon_separator = iconSeparator;
group_separator = groupSeparator;
group_separator_hl = groupSeparatorHl;
};
window = with window; {
normal_hl = normalHl;
inherit winblend border;
border_hl = borderHl;
inherit zindex;
max_width = maxWidth;
max_height = maxHeight;
x_padding = xPadding;
y_padding = yPadding;
inherit align relative;
};
};
integration = with integration; {
nvim-tree = with nvim-tree; {
inherit enable;
};
};
logger = with logger; {
inherit level;
float_precision = floatPrecision;
inherit path;
};
}
// cfg.extraOptions;
in
''
require("fidget").setup${helpers.toLuaObject setupOptions}
'';
};
}

View file

@ -1,61 +0,0 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
{
options.plugins.inc-rename = {
enable = mkEnableOption "inc-rename, a plugin previewing LSP renaming";
package = lib.mkPackageOption pkgs "inc-rename" {
default = [
"vimPlugins"
"inc-rename-nvim"
];
};
cmdName = helpers.defaultNullOpts.mkStr "IncRename" "the name of the command";
hlGroup = helpers.defaultNullOpts.mkStr "Substitute" "the highlight group used for highlighting the identifier's new name";
previewEmptyName = helpers.defaultNullOpts.mkBool false ''
whether an empty new name should be previewed; if false the command preview will be cancelled
instead
'';
showMessage = helpers.defaultNullOpts.mkBool true ''
whether to display a `Renamed m instances in n files` message after a rename operation
'';
inputBufferType = helpers.defaultNullOpts.mkNullable (types.enum [ "dressing" ]) null ''
the type of the external input buffer to use
'';
postHook = helpers.defaultNullOpts.mkLuaFn null ''
callback to run after renaming, receives the result table (from LSP handler) as an argument
'';
};
config =
let
cfg = config.plugins.inc-rename;
setupOptions = {
cmd_name = cfg.cmdName;
hl_group = cfg.hlGroup;
preview_empty_name = cfg.previewEmptyName;
show_message = cfg.showMessage;
input_buffer_type = cfg.inputBufferType;
post_hook = cfg.postHook;
};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require("inc_rename").setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -1,123 +0,0 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
cfg = config.plugins.lsp-format;
in
{
options.plugins.lsp-format = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "lsp-format.nvim";
package = lib.mkPackageOption pkgs "lsp-format.nvim" {
default = [
"vimPlugins"
"lsp-format-nvim"
];
};
setup = mkOption {
type =
with types;
attrsOf (submodule {
# Allow the user to provide other options
freeformType = types.attrs;
options = {
exclude = helpers.mkNullOrOption (listOf str) "List of client names to exclude from formatting.";
order = helpers.mkNullOrOption (listOf str) ''
List of client names. Formatting is requested from clients in the following
order: first all clients that are not in the `order` table, then the remaining
clients in the order as they occur in the `order` table.
(same logic as |vim.lsp.buf.formatting_seq_sync()|).
'';
sync = helpers.defaultNullOpts.mkBool false ''
Whether to turn on synchronous formatting.
The editor will block until formatting is done.
'';
force = helpers.defaultNullOpts.mkBool false ''
If true, the format result will always be written to the buffer, even if the
buffer changed.
'';
};
});
description = "The setup option maps |filetypes| to format options.";
example = {
go = {
exclude = [ "gopls" ];
order = [
"gopls"
"efm"
];
sync = true;
force = true;
};
};
default = { };
};
lspServersToEnable = mkOption {
type =
with types;
either (enum [
"none"
"all"
]) (listOf str);
default = "all";
description = ''
Choose the LSP servers for which lsp-format should be enabled.
Possible values:
- "all" (default): Enable formatting for all language servers
- "none": Do not enable formatting on any language server.
You might choose this if for some reason you want to manually call
`require("lsp-format").on_attach(client)` in the `onAttach` function of your language
servers.
- list of LS names: Manually choose the servers by name
'';
example = [
"efm"
"gopls"
];
};
};
config =
let
setupOptions = cfg.setup // cfg.extraOptions;
in
mkIf cfg.enable {
warnings = mkIf (!config.plugins.lsp.enable) [
"You have enabled `plugins.lsp-format` but have `plugins.lsp` disabled."
];
extraPlugins = [ cfg.package ];
plugins.lsp = {
onAttach = mkIf (cfg.lspServersToEnable == "all") ''
require("lsp-format").on_attach(client)
'';
servers =
if (isList cfg.lspServersToEnable) then
genAttrs cfg.lspServersToEnable (serverName: {
onAttach.function = ''
require("lsp-format").on_attach(client)
'';
})
else
{ };
};
extraConfigLua = ''
require("lsp-format").setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -1,38 +0,0 @@
{
lib,
helpers,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin {
name = "lsp-lines";
luaName = "lsp_lines";
originalName = "lsp_lines.nvim";
package = "lsp_lines-nvim";
# This plugin has no settings; it is configured via vim.diagnostic.config
hasSettings = false;
maintainers = [ maintainers.MattSturgeon ];
# TODO: Introduced 2024-06-25, remove after 24.11
imports = [
(mkRenamedOptionModule
[
"plugins"
"lsp-lines"
"currentLine"
]
[
"diagnostics"
"virtual_lines"
"only_current_line"
]
)
];
extraConfig = cfg: {
# Strongly recommended by the plugin, to avoid duplication.
diagnostics.virtual_text = mkDefault false;
};
}

View file

@ -1,87 +0,0 @@
{
lib,
helpers,
config,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin {
name = "lsp-status";
originalName = "lsp-status.nvim";
package = "lsp-status-nvim";
maintainers = [ helpers.maintainers.b3nb5n ];
settingsOptions =
let
mkIndicatorOption =
default:
helpers.defaultNullOpts.mkStr default ''
The string to show as diagnostics.
If you don't have Nerd/Awesome Fonts you can replace defaults with ASCII chars.
'';
in
{
kind_labels = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
An optional map from LSP symbol kinds to label symbols. Used to decorate the current function name.
'';
select_symbol = helpers.defaultNullOpts.mkStr "" ''
An optional handler of the form `function(cursor_pos, document_symbol)` that should return
`true` if `document_symbol` (a `DocumentSymbol`) should be accepted as the symbol currently
containing the cursor.
'';
current_function = helpers.defaultNullOpts.mkBool true ''
True if the current function should be updated and displayed in the default statusline component.
'';
show_filename = helpers.defaultNullOpts.mkBool true ''
True if the current function should be updated and displayed in the default statusline component.
'';
indicator_ok = mkIndicatorOption "";
indicator_errors = mkIndicatorOption "";
indicator_warnings = mkIndicatorOption "";
indicator_info = mkIndicatorOption "🛈";
indicator_hint = mkIndicatorOption "";
indicator_separator = helpers.defaultNullOpts.mkStr " " ''
A string which goes between each diagnostic group symbol and its count.
'';
component_separator = helpers.defaultNullOpts.mkStr " " ''
A string which goes between each "chunk" of the statusline component (i.e. different diagnostic groups, messages).
'';
diagnostics = helpers.defaultNullOpts.mkBool true ''
If false, the default statusline component does not display LSP diagnostics.
'';
};
callSetup = false;
extraConfig = cfg: {
assertions = [
{
assertion = config.plugins.lsp.enable;
message = ''
Nixvim (plugins.lsp-status): `plugins.lsp` must be enabled to use lsp-status
'';
}
];
plugins.lsp = {
preConfig = ''
do
local lsp_status = require('lsp-status')
lsp_status.config(${helpers.toLuaObject cfg.settings})
lsp_status.register_progress()
end
'';
# the lsp status plugin needs to hook into the on attach and capabilities
# fields of the lsp setup call to track the progress of initializing the lsp
onAttach = "require('lsp-status').on_attach(client)";
capabilities = "capabilities = vim.tbl_extend('keep', capabilities or {}, require('lsp-status').capabilities)";
};
};
}

View file

@ -1,637 +0,0 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
cfg = config.plugins.lspsaga;
mkKeymapOption =
default:
helpers.defaultNullOpts.mkNullable (with types; either str (listOf str)) (
if isString default then default else "[${concatStringsSep " " default}]"
);
in
{
imports =
let
basePluginPath = [
"plugins"
"lspsaga"
];
in
map
(
optionName:
# See https://github.com/NixOS/nixpkgs/pull/247916
# TODO remove those warnings in ~2 months (October 2023)
mkRemovedOptionModule (basePluginPath ++ [ optionName ]) ''
The `lspsaga` plugin used by default in Nixvim has changed to https://github.com/nvimdev/lspsaga.nvim.
Please, adapt your config to the new options.
Documentation available at https://nix-community.github.io/nixvim/plugins/lspsaga/index.html.
''
)
[
"signs"
"headers"
"maxDialogWidth"
"icons"
"maxFinderPreviewLines"
"keys"
"borderStyle"
"renamePromptPrefix"
];
options = {
plugins.lspsaga = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "lspsaga.nvim";
package = lib.mkPackageOption pkgs "lspsaga" {
default = [
"vimPlugins"
"lspsaga-nvim"
];
};
iconsPackage = lib.mkPackageOption pkgs [
"vimPlugins"
"nvim-web-devicons"
] { nullable = true; };
ui = {
border = helpers.defaultNullOpts.mkBorder "single" "lspsaga" "";
devicon = helpers.defaultNullOpts.mkBool true "Whether to use nvim-web-devicons.";
title = helpers.defaultNullOpts.mkBool true "Show title in some float window.";
expand = helpers.defaultNullOpts.mkStr "" "Expand icon.";
collapse = helpers.defaultNullOpts.mkStr "" "Collapse icon.";
codeAction = helpers.defaultNullOpts.mkStr "💡" "Code action icon.";
actionfix = helpers.defaultNullOpts.mkStr "" "Action fix icon.";
lines = helpers.defaultNullOpts.mkListOf types.str [
""
""
""
""
""
] "Symbols used in virtual text connect.";
kind = helpers.defaultNullOpts.mkAttrsOf types.anything { } "LSP kind custom table.";
impSign = helpers.defaultNullOpts.mkStr "󰳛 " "Implement icon.";
};
hover = {
maxWidth = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.9 ''
Defines float window width.
'';
maxHeight = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.8 ''
Defines float window height.
'';
openLink = helpers.defaultNullOpts.mkStr "gx" "Key for opening links.";
openCmd = helpers.defaultNullOpts.mkStr "!chrome" "cmd for opening links.";
};
diagnostic = {
showCodeAction = helpers.defaultNullOpts.mkBool true ''
Show code action in diagnostic jump window.
Its useful. Suggested to set to `true`.
'';
showLayout = helpers.defaultNullOpts.mkStr "float" ''
Config layout of diagnostic window not jump window.
'';
showNormalHeight = helpers.defaultNullOpts.mkInt 10 ''
Show window height when diagnostic show window layout is normal.
'';
jumpNumShortcut = helpers.defaultNullOpts.mkBool true ''
Enable number shortcuts to execute code action quickly.
'';
maxWidth = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.8 ''
Diagnostic jump window max width.
'';
maxHeight = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.6 ''
Diagnostic jump window max height.
'';
maxShowWidth = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.9 ''
Show window max width when layout is float.
'';
maxShowHeight = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.6 ''
Show window max height when layout is float.
'';
textHlFollow = helpers.defaultNullOpts.mkBool true ''
Diagnostic jump window text highlight follow diagnostic type.
'';
borderFollow = helpers.defaultNullOpts.mkBool true ''
Diagnostic jump window border follow diagnostic type.
'';
extendRelatedInformation = helpers.defaultNullOpts.mkBool false ''
When have `relatedInformation`, diagnostic message is extended to show it.
'';
diagnosticOnlyCurrent = helpers.defaultNullOpts.mkBool false ''
Only show diagnostic virtual text on the current line.
'';
keys = {
execAction = mkKeymapOption "o" "Execute action (in jump window).";
quit = mkKeymapOption "q" "Quit key for the jump window.";
toggleOrJump = mkKeymapOption "<CR>" ''
Toggle or jump to position when in `diagnostic_show` window.
'';
quitInShow =
mkKeymapOption
[
"q"
"<ESC>"
]
''
Quit key for the diagnostic_show window.
'';
};
};
codeAction = {
numShortcut = helpers.defaultNullOpts.mkBool true ''
Whether number shortcut for code actions are enabled.
'';
showServerName = helpers.defaultNullOpts.mkBool false ''
Show language server name.
'';
extendGitSigns = helpers.defaultNullOpts.mkBool false ''
Extend gitsigns plugin diff action.
'';
onlyInCursor = helpers.defaultNullOpts.mkBool true "";
keys = {
quit = mkKeymapOption "q" "Quit the float window.";
exec = mkKeymapOption "<CR>" "Execute action.";
};
};
lightbulb = {
enable = helpers.defaultNullOpts.mkBool true "Enable lightbulb.";
sign = helpers.defaultNullOpts.mkBool true "Show sign in status column.";
debounce = helpers.defaultNullOpts.mkInt 10 "Timer debounce.";
signPriority = helpers.defaultNullOpts.mkInt 40 "Sign priority.";
virtualText = helpers.defaultNullOpts.mkBool true "Show virtual text at the end of line.";
};
scrollPreview = {
scrollDown = mkKeymapOption "<C-f>" "Scroll down.";
scrollUp = mkKeymapOption "<C-b>" "Scroll up.";
};
finder = {
maxHeight = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.5 ''
`max_height` of the finder window (float layout).
'';
leftWidth = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.3 ''
Width of the left finder window (float layout).
'';
rightWidth = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.3 ''
Width of the right finder window (float layout).
'';
methods = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
Keys are alias of LSP methods.
Values are LSP methods, which you want show in finder.
Example:
```nix
{
tyd = "textDocument/typeDefinition";
}
```
'';
default = helpers.defaultNullOpts.mkStr "ref+imp" ''
Default search results shown, `ref` for "references" and `imp` for "implementation".
'';
layout =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"float"
"normal"
]
''
`normal` will use the normal layout window priority is lower than command layout.
'';
silent = helpers.defaultNullOpts.mkBool false ''
If its true, it will disable show the no response message.
'';
filter = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
Keys are LSP methods.
Values are a filter handler.
Function parameter are `client_id` and `result`.
'';
keys = {
shuttle = mkKeymapOption "[w" "Shuttle between the finder layout window.";
toggleOrOpen = mkKeymapOption "o" "Toggle expand or open.";
vsplit = mkKeymapOption "s" "Open in vsplit.";
split = mkKeymapOption "i" "Open in split.";
tabe = mkKeymapOption "t" "Open in tabe.";
tabnew = mkKeymapOption "r" "Open in new tab.";
quit = mkKeymapOption "q" "Quit the finder, only works in layout left window.";
close = mkKeymapOption "<C-c>k" "Close finder.";
};
};
definition = {
width = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.6 ''
Defines float window width.
'';
height = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.5 ''
Defines float window height.
'';
keys = {
edit = mkKeymapOption "<C-c>o" "edit";
vsplit = mkKeymapOption "<C-c>v" "vsplit";
split = mkKeymapOption "<C-c>i" "split";
tabe = mkKeymapOption "<C-c>t" "tabe";
quit = mkKeymapOption "q" "quit";
close = mkKeymapOption "<C-c>k" "close";
};
};
rename = {
inSelect = helpers.defaultNullOpts.mkBool true ''
Default is `true`.
Whether the name is selected when the float opens.
In some situation, just like want to change one or less characters, `inSelect` is not so
useful.
You can tell the Lspsaga to start in normal mode using an extra argument like
`:Lspsaga lsp_rename mode=n`.
'';
autoSave = helpers.defaultNullOpts.mkBool false ''
Auto save file when the rename is done.
'';
projectMaxWidth = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0
1.0
) 0.5 "Width for the `project_replace` float window.";
projectMaxHeight = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0
1.0
) 0.5 "Height for the `project_replace` float window.";
keys = {
quit = mkKeymapOption "<C-k>" "Quit rename window or `project_replace` window.";
exec = mkKeymapOption "<CR>" ''
Execute rename in `rename` window or execute replace in `project_replace` window.
'';
select = mkKeymapOption "x" ''
Select or cancel select item in `project_replace` float window.
'';
};
};
symbolInWinbar = {
enable = helpers.defaultNullOpts.mkBool true "Enable.";
separator = helpers.defaultNullOpts.mkStr " " "Separator character.";
hideKeyword = helpers.defaultNullOpts.mkBool false "Hide keyword.";
showFile = helpers.defaultNullOpts.mkBool true "Show file.";
folderLevel = helpers.defaultNullOpts.mkInt 1 "Folder level.";
colorMode = helpers.defaultNullOpts.mkBool true "Color mode.";
delay = helpers.defaultNullOpts.mkInt 300 "Delay.";
};
outline = {
winPosition = helpers.defaultNullOpts.mkStr "right" "`right` window position.";
winWidth = helpers.defaultNullOpts.mkInt 30 "Window width.";
autoPreview = helpers.defaultNullOpts.mkBool true ''
Auto preview when cursor moved in outline window.
'';
detail = helpers.defaultNullOpts.mkBool true "Show detail.";
autoClose = helpers.defaultNullOpts.mkBool true ''
Auto close itself when outline window is last window.
'';
closeAfterJump = helpers.defaultNullOpts.mkBool false "Close after jump.";
layout =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"normal"
"float"
]
''
`float` or `normal`.
If set to float, above options will ignored.
'';
maxHeight = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.5 ''
Height of outline float layout.
'';
leftWidth = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.3 ''
Width of outline float layout left window.
'';
keys = {
toggleOrJump = mkKeymapOption "o" "Toggle or jump.";
quit = mkKeymapOption "q" "Quit outline window.";
jump = mkKeymapOption "e" "Jump to pos even on a expand/collapse node.";
};
};
callhierarchy = {
layout =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"float"
"normal"
]
''
- Layout `normal` and `float`.
- Or you can pass in an extra argument like `:Lspsaga incoming_calls ++normal`, which
overrides this option.
'';
keys = {
edit = mkKeymapOption "e" "Edit (open) file.";
vsplit = mkKeymapOption "s" "vsplit";
split = mkKeymapOption "i" "split";
tabe = mkKeymapOption "t" "Open in new tab.";
close = mkKeymapOption "<C-c>k" "Close layout.";
quit = mkKeymapOption "q" "Quit layout.";
shuttle = mkKeymapOption "[w" "Shuttle between the layout left and right.";
toggleOrReq = mkKeymapOption "u" "Toggle or do request.";
};
};
implement = {
enable = helpers.defaultNullOpts.mkBool true ''
When buffer has instances of the interface type, Lspsaga will show extra information for
it.
'';
sign = helpers.defaultNullOpts.mkBool true "Show sign in status column.";
virtualText = helpers.defaultNullOpts.mkBool true "Show virtual text at the end of line.";
priority = helpers.defaultNullOpts.mkInt 100 "Sign priority.";
};
beacon = {
enable = helpers.defaultNullOpts.mkBool true ''
In Lspsaga, some commands jump around in buffer(s).
With beacon enabled, it will show a beacon to tell you where the cursor is.
'';
frequency = helpers.defaultNullOpts.mkInt 7 "Frequency.";
};
};
};
config = mkIf cfg.enable {
extraPlugins =
[ cfg.package ]
++ optional (
cfg.iconsPackage != null && (cfg.ui.devicon == null || cfg.ui.devicon)
) cfg.iconsPackage;
warnings = mkIf (
# https://nvimdev.github.io/lspsaga/implement/#default-options
(isBool cfg.implement.enable && cfg.implement.enable)
&& (isBool cfg.symbolInWinbar.enable && !cfg.symbolInWinbar.enable)
) [ "You have enabled the `implement` module but it requires `symbolInWinbar` to be enabled." ];
extraConfigLua =
let
setupOptions =
with cfg;
{
ui = with ui; {
inherit
border
devicon
title
expand
collapse
;
code_action = codeAction;
inherit actionfix lines kind;
imp_sign = impSign;
};
hover = with hover; {
max_width = maxWidth;
max_height = maxHeight;
open_link = openLink;
open_cmd = openCmd;
};
diagnostic = with diagnostic; {
show_code_action = showCodeAction;
show_layout = showLayout;
show_normal_height = showNormalHeight;
jump_num_shortcut = jumpNumShortcut;
max_width = maxWidth;
max_height = maxHeight;
max_show_width = maxShowWidth;
max_show_height = maxShowHeight;
text_hl_follow = textHlFollow;
border_follow = borderFollow;
extend_relatedInformation = extendRelatedInformation;
diagnostic_only_current = diagnosticOnlyCurrent;
keys = with keys; {
exec_action = execAction;
inherit quit;
toggle_or_jump = toggleOrJump;
quit_in_show = quitInShow;
};
};
code_action = with codeAction; {
num_shortcut = numShortcut;
show_server_name = showServerName;
extend_gitsigns = extendGitSigns;
only_in_cursor = onlyInCursor;
keys = with keys; {
inherit quit exec;
};
};
lightbulb = with lightbulb; {
inherit enable sign debounce;
sign_priority = signPriority;
virtual_text = virtualText;
};
scroll_preview = with scrollPreview; {
scroll_down = scrollDown;
scroll_up = scrollUp;
};
finder = with finder; {
max_height = maxHeight;
left_width = leftWidth;
right_width = rightWidth;
inherit
methods
default
layout
silent
;
# Keys are LSP methods. Values are a filter handler.
filter = helpers.ifNonNull' filter (mapAttrs (n: helpers.mkRaw) filter);
keys = with keys; {
inherit shuttle;
toggle_or_open = toggleOrOpen;
inherit
vsplit
split
tabe
tabnew
quit
close
;
};
};
definition = with definition; {
inherit width height;
keys = with keys; {
inherit
edit
vsplit
split
tabe
quit
close
;
};
};
rename = with rename; {
in_select = inSelect;
auto_save = autoSave;
project_max_width = projectMaxWidth;
project_max_height = projectMaxHeight;
keys = with keys; {
inherit quit exec select;
};
};
symbol_in_winbar = with symbolInWinbar; {
inherit enable separator;
hide_keyword = hideKeyword;
show_file = showFile;
folder_level = folderLevel;
color_mode = colorMode;
dely = delay;
};
outline = with outline; {
win_position = winPosition;
win_width = winWidth;
auto_preview = autoPreview;
inherit detail;
auto_close = autoClose;
close_after_jump = closeAfterJump;
inherit layout;
max_height = maxHeight;
left_width = leftWidth;
keys = with keys; {
toggle_or_jump = toggleOrJump;
inherit quit jump;
};
};
callhierarchy = with callhierarchy; {
inherit layout;
keys = with keys; {
inherit
edit
vsplit
split
tabe
close
quit
shuttle
;
toggle_or_req = toggleOrReq;
};
};
implement = with implement; {
inherit enable sign;
virtual_text = virtualText;
inherit priority;
};
beacon = with beacon; {
inherit enable frequency;
};
}
// cfg.extraOptions;
in
''
require('lspsaga').setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -1,237 +0,0 @@
{
lib,
helpers,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin {
name = "nvim-lightbulb";
maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-02-15. Remove on 2024-03-15
imports =
map
(
optionName:
mkRemovedOptionModule [
"plugins"
"nvim-lightbulb"
optionName
] "Please use `plugins.nvim-lightbulb.settings` instead."
)
[
"ignore"
"sign"
"float"
"virtualText"
"statusText"
"autocmd"
];
settingsOptions = {
priority = helpers.defaultNullOpts.mkUnsignedInt 10 ''
Priority of the lightbulb for all handlers except float.
'';
hide_in_unfocused_buffer = helpers.defaultNullOpts.mkBool true ''
Whether or not to hide the lightbulb when the buffer is not focused.
Only works if configured during `NvimLightbulb.setup`.
'';
link_highlights = helpers.defaultNullOpts.mkBool true ''
Whether or not to link the highlight groups automatically.
Default highlight group links:
- `LightBulbSign` -> `DiagnosticSignInfo`
- `LightBulbFloatWin` -> `DiagnosticFloatingInfo`
- `LightBulbVirtualText` -> `DiagnosticVirtualTextInfo`
- `LightBulbNumber` -> `DiagnosticSignInfo`
- `LightBulbLine` -> `CursorLine`
Only works if configured during `NvimLightbulb.setup`.
'';
validate_config =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"auto"
"always"
"never"
]
''
Perform full validation of configuration.
- "auto" only performs full validation in `NvimLightbulb.setup`.
- "always" performs full validation in `NvimLightbulb.update_lightbulb` as well.
- "never" disables config validation.
'';
action_kinds = helpers.mkNullOrOption (with types; listOf str) ''
Code action kinds to observe.
To match all code actions, set to `null`.
Otherwise, set to a list of kinds.
Example:
```nix
[
"quickfix"
"refactor.rewrite"
]
```
See: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind
'';
sign = {
enabled = helpers.defaultNullOpts.mkBool true "Sign column.";
text = helpers.defaultNullOpts.mkStr "💡" ''
Text to show in the sign column.
Must be between 1-2 characters.
'';
hl = helpers.defaultNullOpts.mkStr "LightBulbSign" ''
Highlight group to highlight the sign column text.
'';
};
virtual_text = {
enabled = helpers.defaultNullOpts.mkBool false "Virtual text.";
text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the virt_text.";
pos = helpers.defaultNullOpts.mkStr "eol" ''
Position of virtual text given to |nvim_buf_set_extmark|.
Can be a number representing a fixed column (see `virt_text_pos`).
Can be a string representing a position (see `virt_text_win_col`).
'';
hl = helpers.defaultNullOpts.mkStr "LightBulbVirtualText" ''
Highlight group to highlight the virtual text.
'';
hl_mode = helpers.defaultNullOpts.mkStr "combine" ''
How to combine other highlights with text highlight.
See `hl_mode` of |nvim_buf_set_extmark|.
'';
};
float = {
enabled = helpers.defaultNullOpts.mkBool false "Floating window.";
text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the floating window.";
hl = helpers.defaultNullOpts.mkStr "LightBulbFloatWin" ''
Highlight group to highlight the floating window.
'';
win_opts = helpers.defaultNullOpts.mkAttrsOf types.anything { } ''
Window options.
See |vim.lsp.util.open_floating_preview| and |nvim_open_win|.
Note that some options may be overridden by |open_floating_preview|.
'';
};
status_text = {
enabled = helpers.defaultNullOpts.mkBool false ''
Status text.
When enabled, will allow using |NvimLightbulb.get_status_text| to retrieve the configured text.
'';
text = helpers.defaultNullOpts.mkStr "💡" "Text to set if a lightbulb is available.";
text_unavailable = helpers.defaultNullOpts.mkStr "" ''
Text to set if a lightbulb is unavailable.
'';
};
number = {
enabled = helpers.defaultNullOpts.mkBool false "Number column.";
hl = helpers.defaultNullOpts.mkStr "LightBulbNumber" ''
Highlight group to highlight the number column if there is a lightbulb.
'';
};
line = {
enabled = helpers.defaultNullOpts.mkBool false "Content line.";
hl = helpers.defaultNullOpts.mkStr "LightBulbLine" ''
Highlight group to highlight the line if there is a lightbulb.
'';
};
autocmd = {
enabled = helpers.defaultNullOpts.mkBool false ''
Autocmd configuration.
If enabled, automatically defines an autocmd to show the lightbulb.
If disabled, you will have to manually call |NvimLightbulb.update_lightbulb|.
Only works if configured during `NvimLightbulb.setup`.
'';
updatetime = helpers.defaultNullOpts.mkInt 200 ''
See |updatetime|.
Set to a negative value to avoid setting the updatetime.
'';
pattern = helpers.defaultNullOpts.mkListOf types.str [ "*" ] ''
See |nvim_create_autocmd| and |autocmd-pattern|.
'';
events =
helpers.defaultNullOpts.mkListOf types.str
[
"CursorHold"
"CursorHoldI"
]
''
See |nvim_create_autocmd|.
'';
};
ignore = {
clients = helpers.defaultNullOpts.mkListOf types.str [ ] ''
LSP client names to ignore.
Example: {"null-ls", "lua_ls"}
'';
ft = helpers.defaultNullOpts.mkListOf types.str [ ] ''
Filetypes to ignore.
Example: {"neo-tree", "lua"}
'';
actions_without_kind = helpers.defaultNullOpts.mkBool false ''
Ignore code actions without a `kind` like `refactor.rewrite`, quickfix.
'';
};
};
settingsExample = {
sign = {
enabled = false;
text = "󰌶";
};
virtual_text = {
enabled = true;
text = "󰌶";
};
float = {
enabled = false;
text = " 󰌶 ";
win_opts.border = "rounded";
};
status_text = {
enabled = false;
text = " 󰌶 ";
};
number = {
enabled = false;
};
line = {
enabled = false;
};
autocmd = {
enabled = true;
updatetime = 200;
};
};
}

View file

@ -1,163 +0,0 @@
{
lib,
helpers,
config,
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin {
name = "schemastore";
originalName = "SchemaStore.nvim";
package = "SchemaStore-nvim";
maintainers = [ maintainers.GaetanLepage ];
extraOptions =
let
schemaEntry = types.submodule {
freeformType = with types; attrsOf anything;
options = {
name = mkOption {
type = with helpers.nixvimTypes; maybeRaw str;
description = "The name of the schema.";
};
description = helpers.mkNullOrStr "A description for this schema.";
fileMatch =
helpers.mkNullOrOption (with helpers.nixvimTypes; maybeRaw (either str (listOf (maybeRaw str))))
''
Which filename to match against for this schema.
'';
url = mkOption {
type = with helpers.nixvimTypes; maybeRaw str;
description = "The URL of this schema.";
};
};
};
schemaOpts = {
select = helpers.defaultNullOpts.mkListOf types.str [ ] ''
A list of strings representing the names of schemas to select.
If this option is not present, all schemas are returned.
If it is present, only the selected schemas are returned.
`select` and `ignore` are mutually exclusive.
See the [schema catalog](https://github.com/SchemaStore/schemastore/blob/master/src/api/json/catalog.json).
'';
ignore = helpers.defaultNullOpts.mkListOf types.str [ ] ''
A list of strings representing the names of schemas to ignore.
`select` and `ignore` are mutually exclusive.
See the [schema catalog](https://github.com/SchemaStore/schemastore/blob/master/src/api/json/catalog.json).
'';
replace = helpers.defaultNullOpts.mkAttrsOf schemaEntry { } ''
An attrs of elements representing schemas to replace with a custom schema.
The string key is the name of the schema to replace, the table value is the schema definition.
If a schema with the given name isn't found, the custom schema will not be returned.
'';
extra = helpers.defaultNullOpts.mkListOf schemaEntry [ ] ''
Additional schemas to include.
'';
};
in
{
json = {
enable = mkOption {
type = types.bool;
default = true;
example = false;
description = "Whether to enable the json schemas in jsonls.";
};
settings = helpers.mkSettingsOption {
options = schemaOpts;
description = "Options supplied to the `require('schemastore').json.schemas` function.";
example = {
replace."package.json" = {
description = "package.json overridden";
fileMatch = [ "package.json" ];
name = "package.json";
url = "https://example.com/package.json";
};
extra = [
{
description = "My custom JSON schema";
fileMatch = "foo.json";
name = "foo.json";
url = "https://example.com/schema/foo.json";
}
{
description = "My other custom JSON schema";
fileMatch = [
"bar.json"
".baar.json"
];
name = "bar.json";
url = "https://example.com/schema/bar.json";
}
];
};
};
};
yaml = {
enable = mkOption {
type = types.bool;
default = true;
example = false;
description = "Whether to enable the yaml schemas in yamlls.";
};
settings = helpers.mkSettingsOption {
options = schemaOpts;
description = "Options supplied to the `require('schemastore').yaml.schemas` function.";
};
};
};
extraConfig = cfg: {
warnings =
(optional (!(cfg.json.enable || cfg.yaml.enable)) ''
NixVim(plugins.schemastore): you have enabled the plugin, but neither `json` or `yaml` schemas are enabled.
'')
++ (optional (!(cfg.json.enable -> config.plugins.lsp.servers.jsonls.enable)) ''
NixVim(plugins.schemastore): you have enabled `json` schemas, but `plugins.lsp.servers.jsonls` is not enabled.
'')
++ (optional (!(cfg.yaml.enable -> config.plugins.lsp.servers.yamlls.enable)) ''
NixVim(plugins.schemastore): you have enabled `yaml` schemas, but `plugins.lsp.servers.yamlls` is not enabled.
'');
plugins.lsp.servers = {
jsonls.settings = mkIf cfg.json.enable {
schemas.__raw = ''
require('schemastore').json.schemas({${helpers.toLuaObject cfg.json.settings}})
'';
# The plugin recommends to enable this option in its README.
# Learn more: https://github.com/b0o/SchemaStore.nvim/issues/8
validate = mkDefault true;
};
yamlls.settings = mkIf cfg.yaml.enable {
schemaStore = {
# From the README: "You must disable built-in schemaStore support if you want to use
# this plugin and its advanced options like `ignore`."
enable = mkDefault false;
# From the README: "Avoid TypeError: Cannot read properties of undefined (reading 'length')"
url = mkDefault "";
};
schemas.__raw = ''
require('schemastore').yaml.schemas({${helpers.toLuaObject cfg.yaml.settings}})
'';
};
};
};
}

View file

@ -1,313 +0,0 @@
{
lib,
helpers,
pkgs,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin {
name = "trouble";
originalName = "trouble-nvim";
package = "trouble-nvim";
maintainers = [ maintainers.loicreynier ];
# TODO introduced 2024-03-15: remove 2024-05-15
optionsRenamedToSettings = [
"autoClose"
"autoFold"
"autoOpen"
"autoJump"
"autoPreview"
"foldClosed"
"foldOpen"
"group"
"height"
"icons"
"indentLines"
"mode"
"padding"
"position"
"width"
"useDiagnosticSigns"
[
"actionKeys"
"cancel"
]
[
"actionKeys"
"close"
]
[
"actionKeys"
"closeFolds"
]
[
"actionKeys"
"hover"
]
[
"actionKeys"
"jump"
]
[
"actionKeys"
"jumpClose"
]
[
"actionKeys"
"next"
]
[
"actionKeys"
"openFolds"
]
[
"actionKeys"
"openSplit"
]
[
"actionKeys"
"openTab"
]
[
"actionKeys"
"openVsplit"
]
[
"actionKeys"
"previous"
]
[
"actionKeys"
"refresh"
]
[
"actionKeys"
"toggleFold"
]
[
"actionKeys"
"toggleMode"
]
[
"actionKeys"
"togglePreview"
]
[
"signs"
"error"
]
[
"signs"
"hint"
]
[
"signs"
"other"
]
[
"signs"
"warning"
]
];
settingsOptions = {
position =
helpers.defaultNullOpts.mkEnum
[
"top"
"left"
"right"
"bottom"
]
"bottom"
''
Position of the list.
'';
height = helpers.defaultNullOpts.mkInt 10 ''
Height of the trouble list when position is top or bottom.
'';
width = helpers.defaultNullOpts.mkInt 50 ''
Width of the list when position is left or right.
'';
icons = helpers.defaultNullOpts.mkBool true "Use devicons for filenames";
mode = helpers.defaultNullOpts.mkEnum [
"workspace_diagnostics"
"document_diagnostics"
"quickfix"
"lsp_references"
"loclist"
] "workspace_diagnostics" "Mode for default list";
fold_open = helpers.defaultNullOpts.mkStr "" "Icon used for open folds";
fold_closed = helpers.defaultNullOpts.mkStr "" "Icon used for closed folds";
group = helpers.defaultNullOpts.mkBool true "Group results by file";
padding = helpers.defaultNullOpts.mkBool true "Add an extra new line on top of the list";
cycle_results = helpers.defaultNullOpts.mkBool true "Whether to cycle item list when reaching beginning or end of list";
action_keys =
mapAttrs
(
action: config:
helpers.defaultNullOpts.mkNullable (
with types; either str (listOf str)
) config.default config.description
)
{
close = {
default = "q";
description = "Close the list";
};
cancel = {
default = "<esc>";
description = "Cancel the preview and get back to your last window / buffer / cursor";
};
refresh = {
default = "r";
description = "Manually refresh";
};
jump = {
default = [
"<cr>"
"<tab>"
];
description = "Jump to the diagnostic or open / close folds";
};
open_split = {
default = [ "<c-x>" ];
description = "Open buffer in new split";
};
open_vsplit = {
default = [ "<c-v>" ];
description = "Open buffer in new vsplit";
};
open_tab = {
default = [ "<c-t>" ];
description = "Open buffer in new tab";
};
jump_close = {
default = [ "o" ];
description = "Jump to the diagnostic and close the list";
};
toggle_mode = {
default = "m";
description = "toggle between 'workspace' and 'document' diagnostics mode";
};
toggle_preview = {
default = "P";
description = "Toggle auto_preview";
};
hover = {
default = "K";
description = "Opens a small popup with the full multiline message";
};
preview = {
default = "p";
description = "Preview the diagnostic location";
};
close_folds = {
default = [
"zM"
"zm"
];
description = "Close all folds";
};
open_folds = {
default = [
"zR"
"zr"
];
description = "Open all folds";
};
toggle_fold = {
default = [
"zA"
"za"
];
description = "Toggle fold of current file";
};
previous = {
default = "k";
description = "Previous item";
};
next = {
default = "j";
description = "Next item";
};
};
indent_lines = helpers.defaultNullOpts.mkBool true ''
Add an indent guide below the fold icons.
'';
win_config = helpers.defaultNullOpts.mkAttrsOf types.anything {
border = "single";
} "Configuration for floating windows. See `|nvim_open_win()|`.";
auto_open = helpers.defaultNullOpts.mkBool false ''
Automatically open the list when you have diagnostics.
'';
auto_close = helpers.defaultNullOpts.mkBool false ''
Automatically close the list when you have no diagnostics.
'';
auto_preview = helpers.defaultNullOpts.mkBool true ''
Automatically preview the location of the diagnostic.
<esc> to close preview and go back to last window.
'';
auto_fold = helpers.defaultNullOpts.mkBool false ''
Automatically fold a file trouble list at creation.
'';
auto_jump = helpers.defaultNullOpts.mkListOf types.str [ "lsp_definitions" ] ''
For the given modes, automatically jump if there is only a single result.
'';
include_declaration = helpers.defaultNullOpts.mkListOf types.str [
"lsp_references"
"lsp_implementations"
"lsp_definitions"
] "For the given modes, include the declaration of the current symbol in the results.";
signs =
mapAttrs
(
diagnostic: default:
helpers.defaultNullOpts.mkStr default "Icon/text for ${diagnostic} diagnostics."
)
{
error = "";
warning = "";
hint = "";
information = "";
other = "";
};
use_diagnostic_signs = helpers.defaultNullOpts.mkBool false ''
Enabling this will use the signs defined in your lsp client
'';
};
extraOptions = {
iconsPackage = lib.mkPackageOption pkgs [
"vimPlugins"
"nvim-web-devicons"
] { nullable = true; };
};
extraConfig = cfg: {
extraPlugins = mkIf (cfg.iconsPackage != null) [ cfg.iconsPackage ];
};
}

View file

@ -1,129 +0,0 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
cfg = config.plugins.wtf;
defaultKeymaps = {
ai = {
key = "gw";
mode = [
"n"
"x"
];
action.__raw = "require('wtf').ai";
};
search = {
key = "gW";
mode = "n";
action.__raw = "require('wtf').search";
};
};
in
{
options = {
plugins.wtf = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "wtf.nvim";
package = lib.mkPackageOption pkgs "wtf.nvim" {
default = [
"vimPlugins"
"wtf-nvim"
];
};
keymaps = mapAttrs (
action: defaults:
helpers.mkNullOrOption' {
type =
with types;
coercedTo str (key: defaultKeymaps.${action} // { inherit key; }) (
helpers.keymaps.mkMapOptionSubmodule {
inherit defaults;
lua = true;
}
);
apply = v: if v == null then null else helpers.keymaps.removeDeprecatedMapAttrs v;
description = "Keymap for the ${action} action.";
}
) defaultKeymaps;
popupType =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"popup"
"horizontal"
"vertical"
]
''
Default AI popup type.
'';
openaiApiKey = helpers.defaultNullOpts.mkStr null ''
An alternative way to set your API key.
'';
openaiModelId = helpers.defaultNullOpts.mkStr "gpt-3.5-turbo" "ChatGPT Model.";
context = helpers.defaultNullOpts.mkBool true "Send code as well as diagnostics.";
language = helpers.defaultNullOpts.mkStr "english" ''
Set your preferred language for the response.
'';
additionalInstructions = helpers.mkNullOrOption types.str "Any additional instructions.";
searchEngine = helpers.defaultNullOpts.mkEnumFirstDefault [
"google"
"duck_duck_go"
"stack_overflow"
"github"
] "Default search engine.";
hooks = {
requestStarted = helpers.defaultNullOpts.mkLuaFn "nil" "Callback for request start.";
requestFinished = helpers.defaultNullOpts.mkLuaFn "nil" "Callback for request finished.";
};
winhighlight = helpers.defaultNullOpts.mkStr "Normal:Normal,FloatBorder:FloatBorder" ''
Add custom colours.
'';
};
};
config =
let
setupOptions =
with cfg;
{
popup_type = popupType;
openai_api_key = openaiApiKey;
openai_model_id = openaiModelId;
inherit context language;
additional_instructions = additionalInstructions;
search_engine = searchEngine;
hooks = {
request_started = hooks.requestStarted;
request_finished = hooks.requestFinished;
};
inherit winhighlight;
}
// cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
keymaps = filter (keymap: keymap != null) (attrValues cfg.keymaps);
extraConfigLua = ''
require("wtf").setup(${helpers.toLuaObject setupOptions})
'';
};
}