nix-community.nixvim/plugins/by-name/lean/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

192 lines
6 KiB
Nix
Raw Normal View History

2023-11-11 23:40:39 +01:00
{
lib,
...
}:
let
inherit (lib.nixvim) defaultNullOpts mkNullOrOption;
inherit (lib) types;
2023-11-11 23:40:39 +01:00
in
lib.nixvim.plugins.mkNeovimPlugin {
name = "lean";
packPathName = "lean.nvim";
package = "lean-nvim";
2023-11-11 23:40:39 +01:00
maintainers = [ lib.maintainers.khaneliman ];
2023-11-11 23:40:39 +01:00
dependencies = [ "lean" ];
2025-04-07 17:28:21 +02:00
imports = [
# TODO: added 2025-04-07, remove after 25.05
(lib.nixvim.mkRemovedPackageOptionModule {
plugin = "lean";
packageName = "lean";
})
];
2023-11-11 23:40:39 +01:00
settingsOptions = {
lsp = defaultNullOpts.mkNullable (types.submodule {
freeformType = types.attrsOf types.anything;
options = {
enable = defaultNullOpts.mkBool true ''
Whether to enable the Lean language server(s).
2024-05-05 19:39:35 +02:00
Set to `false` to disable, otherwise should be a table of options to pass to
`leanls`.
2023-11-11 23:40:39 +01:00
See https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#leanls
for details.
'';
2023-11-11 23:40:39 +01:00
on_attach = mkNullOrOption types.str ''
The LSP handler.
'';
init_options = mkNullOrOption (with types; attrsOf anything) ''
The options to configure the lean language server.
2023-11-11 23:40:39 +01:00
See `Lean.Lsp.InitializationOptions` for details.
'';
};
}) { } "LSP settings.";
2023-11-11 23:40:39 +01:00
ft = {
default = defaultNullOpts.mkStr "lean" ''
2023-11-11 23:40:39 +01:00
The default filetype for Lean files.
'';
nomodifiable = mkNullOrOption (types.listOf types.str) ''
2023-11-11 23:40:39 +01:00
A list of patterns which will be used to protect any matching Lean file paths from being
accidentally modified (by marking the buffer as `nomodifiable`).
By default, this list includes the Lean standard libraries, as well as files within
dependency directories (e.g. `_target`)
2023-11-11 23:40:39 +01:00
Set this to an empty table to disable.
'';
2024-05-05 19:39:35 +02:00
};
2023-11-11 23:40:39 +01:00
abbreviations = {
enable = defaultNullOpts.mkBool true ''
2023-11-11 23:40:39 +01:00
Whether to enable expanding of unicode abbreviations.
'';
extra = defaultNullOpts.mkAttrsOf' {
type = types.str;
pluginDefault = { };
description = ''
Additional abbreviations.
'';
example = lib.literalExpression ''
```nix
2024-05-05 19:39:35 +02:00
{
2023-11-11 23:40:39 +01:00
# Add a \wknight abbreviation to insert ♘
2024-05-05 19:39:35 +02:00
#
2023-11-11 23:40:39 +01:00
# Note that the backslash is implied, and that you of
# course may also use a snippet engine directly to do
# this if so desired.
wknight = "";
2024-05-05 19:39:35 +02:00
}
'';
};
leader = defaultNullOpts.mkStr "\\" ''
2023-11-11 23:40:39 +01:00
Change if you don't like the backslash.
'';
2024-05-05 19:39:35 +02:00
};
mappings = defaultNullOpts.mkBool false ''
2023-11-11 23:40:39 +01:00
Whether to enable suggested mappings.
'';
infoview = {
autoopen = defaultNullOpts.mkBool true ''
Automatically open an infoview on entering a Lean buffer.
2023-11-11 23:40:39 +01:00
Should be a function that will be called anytime a new Lean file is opened.
Return true to open an infoview, otherwise false.
Setting this to `true` is the same as `function() return true end`, i.e. autoopen for any
Lean file, or setting it to `false` is the same as `function() return false end`,
i.e. never autoopen.
'';
autopause = defaultNullOpts.mkBool false "Set whether a new pin is automatically paused.";
width = defaultNullOpts.mkPositiveInt 50 ''
2023-11-11 23:40:39 +01:00
Set infoview windows' starting width.
'';
height = defaultNullOpts.mkPositiveInt 20 ''
2023-11-11 23:40:39 +01:00
Set infoview windows' starting height.
'';
horizontal_position = defaultNullOpts.mkEnumFirstDefault [ "bottom" "top" ] ''
Put the infoview on the top or bottom when horizontal.
'';
separate_tab = defaultNullOpts.mkBool false ''
2023-11-11 23:40:39 +01:00
Always open the infoview window in a separate tabpage.
Might be useful if you are using a screen reader and don't want too many dynamic updates
in the terminal at the same time.
2023-11-11 23:40:39 +01:00
Note that `height` and `width` will be ignored in this case.
'';
indicators = defaultNullOpts.mkEnumFirstDefault [ "auto" "always" "never" ] ''
Show indicators for pin locations when entering an infoview window.
'';
show_processing = defaultNullOpts.mkBool true "";
show_no_info_message = defaultNullOpts.mkBool false "";
use_widgets = defaultNullOpts.mkBool true "Whether to use widgets.";
mappings = defaultNullOpts.mkAttrsOf types.str {
K = "click";
"<CR>" = "click";
gd = "go_to_def";
gD = "go_to_decl";
gy = "go_to_type";
I = "mouse_enter";
i = "mouse_leave";
"<Esc>" = "clear_all";
C = "clear_all";
"<LocalLeader><Tab>" = "goto_last_window";
} "Mappings.";
2023-11-11 23:40:39 +01:00
};
progress_bars = {
enable = defaultNullOpts.mkBool true ''
2023-11-11 23:40:39 +01:00
Whether to enable the progress bars.
'';
priority = defaultNullOpts.mkUnsignedInt 10 ''
2023-11-11 23:40:39 +01:00
Use a different priority for the signs.
'';
};
stderr = {
enable = defaultNullOpts.mkBool true ''
2024-03-07 19:44:13 +01:00
Redirect Lean's stderr messages somewhere (to a buffer by default).
2024-05-05 19:39:35 +02:00
'';
height = defaultNullOpts.mkPositiveInt 5 "Height of the window.";
on_lines = defaultNullOpts.mkLuaFn "nil" ''
2023-11-11 23:40:39 +01:00
A callback which will be called with (multi-line) stderr output.
2024-05-05 19:39:35 +02:00
'';
};
};
settingsExample = {
settings = {
lsp = {
enable = true;
};
ft = {
default = "lean";
nomodifiable = [ "_target" ];
};
abbreviations = {
enable = true;
extra = {
wknight = "";
};
};
mappings = false;
infoview = {
horizontal_position = "top";
separate_tab = true;
indicators = "always";
};
progress_bars = {
enable = false;
};
stderr = {
on_lines.__raw = "function(lines) vim.notify(lines) end";
};
};
};
2023-11-11 23:40:39 +01:00
# TODO: Deprecated in 2025-01-31
inherit (import ./deprecations.nix) deprecateExtraOptions optionsRenamedToSettings;
2023-11-11 23:40:39 +01:00
}