mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-23 17:28:39 +02:00
treewide: Reformat with nixfmt
This commit is contained in:
parent
c6281260dc
commit
62f32bfc71
459 changed files with 28139 additions and 26377 deletions
|
@ -5,94 +5,90 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.rustaceanvim;
|
||||
in {
|
||||
meta.maintainers = [maintainers.GaetanLepage];
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ maintainers.GaetanLepage ];
|
||||
|
||||
options.plugins.rustaceanvim =
|
||||
helpers.neovim-plugin.extraOptionsOptions
|
||||
// {
|
||||
enable = mkEnableOption "rustaceanvim";
|
||||
options.plugins.rustaceanvim = helpers.neovim-plugin.extraOptionsOptions // {
|
||||
enable = mkEnableOption "rustaceanvim";
|
||||
|
||||
package = helpers.mkPackageOption "rustaceanvim" pkgs.vimPlugins.rustaceanvim;
|
||||
package = helpers.mkPackageOption "rustaceanvim" pkgs.vimPlugins.rustaceanvim;
|
||||
|
||||
rustAnalyzerPackage = mkOption {
|
||||
type = with types; nullOr package;
|
||||
default = pkgs.rust-analyzer;
|
||||
description = ''
|
||||
Which package to use for `rust-analyzer`.
|
||||
Set to `null` to disable its automatic installation.
|
||||
rustAnalyzerPackage = mkOption {
|
||||
type = with types; nullOr package;
|
||||
default = pkgs.rust-analyzer;
|
||||
description = ''
|
||||
Which package to use for `rust-analyzer`.
|
||||
Set to `null` to disable its automatic installation.
|
||||
'';
|
||||
example = null;
|
||||
};
|
||||
|
||||
tools = {
|
||||
executor = helpers.defaultNullOpts.mkNullable (
|
||||
with helpers.nixvimTypes;
|
||||
either strLuaFn (enum [
|
||||
"termopen"
|
||||
"quickfix"
|
||||
"toggleterm"
|
||||
"vimux"
|
||||
])
|
||||
) "termopen" "How to execute terminal commands.";
|
||||
|
||||
onInitialized = helpers.mkNullOrLuaFn ''
|
||||
`fun(health:RustAnalyzerInitializedStatus)`
|
||||
Function that is invoked when the LSP server has finished initializing.
|
||||
'';
|
||||
|
||||
reloadWorkspaceFromCargoToml = helpers.defaultNullOpts.mkBool true ''
|
||||
Automatically call `RustReloadWorkspace` when writing to a `Cargo.toml` file.
|
||||
'';
|
||||
|
||||
hoverActions = {
|
||||
replaceBuiltinHover = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether to replace Neovim's built-in `vim.lsp.buf.hover` with hover actions.
|
||||
'';
|
||||
example = null;
|
||||
};
|
||||
|
||||
tools = {
|
||||
executor =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(
|
||||
with helpers.nixvimTypes;
|
||||
either
|
||||
strLuaFn
|
||||
(enum ["termopen" "quickfix" "toggleterm" "vimux"])
|
||||
)
|
||||
"termopen"
|
||||
"How to execute terminal commands.";
|
||||
floatWinConfig = helpers.defaultNullOpts.mkAttrsOf types.anything ''
|
||||
{
|
||||
border = [
|
||||
["╭" "FloatBorder"]
|
||||
["─" "FloatBorder"]
|
||||
["╮" "FloatBorder"]
|
||||
["│" "FloatBorder"]
|
||||
["╯" "FloatBorder"]
|
||||
["─" "FloatBorder"]
|
||||
["╰" "FloatBorder"]
|
||||
["│" "FloatBorder"]
|
||||
];
|
||||
max_width = null;
|
||||
max_height = null;
|
||||
auto_focus = false;
|
||||
}
|
||||
'' "Options applied to floating windows. See |api-win_config|.";
|
||||
|
||||
onInitialized = helpers.mkNullOrLuaFn ''
|
||||
`fun(health:RustAnalyzerInitializedStatus)`
|
||||
Function that is invoked when the LSP server has finished initializing.
|
||||
crateGraph = {
|
||||
backend = helpers.defaultNullOpts.mkStr "x11" ''
|
||||
Backend used for displaying the graph.
|
||||
See: https://graphviz.org/docs/outputs
|
||||
'';
|
||||
|
||||
reloadWorkspaceFromCargoToml = helpers.defaultNullOpts.mkBool true ''
|
||||
Automatically call `RustReloadWorkspace` when writing to a `Cargo.toml` file.
|
||||
output = helpers.mkNullOrStr ''
|
||||
Where to store the output.
|
||||
No output if unset.
|
||||
Relative path from `cwd`.
|
||||
'';
|
||||
|
||||
hoverActions = {
|
||||
replaceBuiltinHover = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether to replace Neovim's built-in `vim.lsp.buf.hover` with hover actions.
|
||||
'';
|
||||
};
|
||||
full = helpers.defaultNullOpts.mkBool true ''
|
||||
`true` for all crates.io and external crates, false only the local crates.
|
||||
'';
|
||||
|
||||
floatWinConfig =
|
||||
helpers.defaultNullOpts.mkAttrsOf types.anything
|
||||
''
|
||||
{
|
||||
border = [
|
||||
["╭" "FloatBorder"]
|
||||
["─" "FloatBorder"]
|
||||
["╮" "FloatBorder"]
|
||||
["│" "FloatBorder"]
|
||||
["╯" "FloatBorder"]
|
||||
["─" "FloatBorder"]
|
||||
["╰" "FloatBorder"]
|
||||
["│" "FloatBorder"]
|
||||
];
|
||||
max_width = null;
|
||||
max_height = null;
|
||||
auto_focus = false;
|
||||
}
|
||||
''
|
||||
"Options applied to floating windows. See |api-win_config|.";
|
||||
|
||||
crateGraph = {
|
||||
backend = helpers.defaultNullOpts.mkStr "x11" ''
|
||||
Backend used for displaying the graph.
|
||||
See: https://graphviz.org/docs/outputs
|
||||
'';
|
||||
|
||||
output = helpers.mkNullOrStr ''
|
||||
Where to store the output.
|
||||
No output if unset.
|
||||
Relative path from `cwd`.
|
||||
'';
|
||||
|
||||
full = helpers.defaultNullOpts.mkBool true ''
|
||||
`true` for all crates.io and external crates, false only the local crates.
|
||||
'';
|
||||
|
||||
enabledGraphvizBackends =
|
||||
helpers.defaultNullOpts.mkListOf types.str
|
||||
enabledGraphvizBackends =
|
||||
helpers.defaultNullOpts.mkListOf types.str
|
||||
''
|
||||
[
|
||||
"bmp" "cgimage" "canon" "dot" "gv" "xdot" "xdot1.2" "xdot1.4" "eps" "exr" "fig" "gd"
|
||||
|
@ -106,55 +102,53 @@ in {
|
|||
Override the enabled graphviz backends list, used for input validation and autocompletion.
|
||||
'';
|
||||
|
||||
pipe = helpers.mkNullOrStr ''
|
||||
Override the pipe symbol in the shell command.
|
||||
Useful if using a shell that is not supported by this plugin.
|
||||
'';
|
||||
};
|
||||
|
||||
openUrl = helpers.defaultNullOpts.mkLuaFn "require('rustaceanvim.os').open_url" ''
|
||||
If set, overrides how to open URLs.
|
||||
pipe = helpers.mkNullOrStr ''
|
||||
Override the pipe symbol in the shell command.
|
||||
Useful if using a shell that is not supported by this plugin.
|
||||
'';
|
||||
};
|
||||
|
||||
server = {
|
||||
autoAttach = helpers.mkNullOrStrLuaFnOr types.bool ''
|
||||
Whether to automatically attach the LSP client.
|
||||
Defaults to `true` if the `rust-analyzer` executable is found.
|
||||
openUrl = helpers.defaultNullOpts.mkLuaFn "require('rustaceanvim.os').open_url" ''
|
||||
If set, overrides how to open URLs.
|
||||
'';
|
||||
};
|
||||
|
||||
This can also be the definition of a function (`fun():boolean`).
|
||||
server = {
|
||||
autoAttach = helpers.mkNullOrStrLuaFnOr types.bool ''
|
||||
Whether to automatically attach the LSP client.
|
||||
Defaults to `true` if the `rust-analyzer` executable is found.
|
||||
|
||||
Default:
|
||||
```lua
|
||||
function()
|
||||
local cmd = types.evaluate(RustaceanConfig.server.cmd)
|
||||
---@cast cmd string[]
|
||||
local rs_bin = cmd[1]
|
||||
return vim.fn.executable(rs_bin) == 1
|
||||
end
|
||||
```
|
||||
'';
|
||||
This can also be the definition of a function (`fun():boolean`).
|
||||
|
||||
onAttach = helpers.defaultNullOpts.mkLuaFn "__lspOnAttach" "Function to call on attach";
|
||||
Default:
|
||||
```lua
|
||||
function()
|
||||
local cmd = types.evaluate(RustaceanConfig.server.cmd)
|
||||
---@cast cmd string[]
|
||||
local rs_bin = cmd[1]
|
||||
return vim.fn.executable(rs_bin) == 1
|
||||
end
|
||||
```
|
||||
'';
|
||||
|
||||
cmd = helpers.mkNullOrStrLuaFnOr (with types; listOf str) ''
|
||||
Command and arguments for starting rust-analyzer.
|
||||
onAttach = helpers.defaultNullOpts.mkLuaFn "__lspOnAttach" "Function to call on attach";
|
||||
|
||||
This can also be the definition of a function (`fun():string[]`).
|
||||
cmd = helpers.mkNullOrStrLuaFnOr (with types; listOf str) ''
|
||||
Command and arguments for starting rust-analyzer.
|
||||
|
||||
Default:
|
||||
```lua
|
||||
function()
|
||||
return { 'rust-analyzer', '--log-file', RustaceanConfig.server.logfile }
|
||||
end
|
||||
```
|
||||
'';
|
||||
This can also be the definition of a function (`fun():string[]`).
|
||||
|
||||
settings =
|
||||
helpers.mkNullOrStrLuaFnOr (types.submodule {
|
||||
options =
|
||||
import ../lsp/language-servers/rust-analyzer-config.nix lib pkgs;
|
||||
})
|
||||
Default:
|
||||
```lua
|
||||
function()
|
||||
return { 'rust-analyzer', '--log-file', RustaceanConfig.server.logfile }
|
||||
end
|
||||
```
|
||||
'';
|
||||
|
||||
settings =
|
||||
helpers.mkNullOrStrLuaFnOr
|
||||
(types.submodule { options = import ../lsp/language-servers/rust-analyzer-config.nix lib pkgs; })
|
||||
''
|
||||
Setting passed to rust-analyzer.
|
||||
Defaults to a function that looks for a `rust-analyzer.json` file or returns an empty table.
|
||||
|
@ -170,29 +164,33 @@ in {
|
|||
```
|
||||
'';
|
||||
|
||||
standalone = helpers.defaultNullOpts.mkBool true ''
|
||||
Standalone file support (enabled by default).
|
||||
Disabling it may improve rust-analyzer's startup time.
|
||||
'';
|
||||
standalone = helpers.defaultNullOpts.mkBool true ''
|
||||
Standalone file support (enabled by default).
|
||||
Disabling it may improve rust-analyzer's startup time.
|
||||
'';
|
||||
|
||||
logfile =
|
||||
helpers.defaultNullOpts.mkNullable (with helpers.nixvimTypes; either str rawLua)
|
||||
logfile =
|
||||
helpers.defaultNullOpts.mkNullable (with helpers.nixvimTypes; either str rawLua)
|
||||
''{__raw = "vim.fn.tempname() .. '-rust-analyzer.log'";}''
|
||||
"The path to the rust-analyzer log file.";
|
||||
};
|
||||
};
|
||||
|
||||
dap = {
|
||||
autoloadConfigurations = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether to autoload nvim-dap configurations when rust-analyzer has attached ?
|
||||
'';
|
||||
dap = {
|
||||
autoloadConfigurations = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether to autoload nvim-dap configurations when rust-analyzer has attached ?
|
||||
'';
|
||||
|
||||
adapter = let
|
||||
adapter =
|
||||
let
|
||||
dapConfig = types.submodule {
|
||||
freeformType = with types; attrsOf anything;
|
||||
options = {
|
||||
# Common options
|
||||
type = mkOption {
|
||||
type = types.enum ["executable" "server"];
|
||||
type = types.enum [
|
||||
"executable"
|
||||
"server"
|
||||
];
|
||||
description = "The type for the debug adapter.";
|
||||
};
|
||||
|
||||
|
@ -220,67 +218,58 @@ in {
|
|||
};
|
||||
};
|
||||
in
|
||||
helpers.mkNullOrStrLuaFnOr
|
||||
(
|
||||
with types;
|
||||
either
|
||||
(enum [false])
|
||||
dapConfig
|
||||
)
|
||||
''
|
||||
Defaults to creating the `rt_lldb` adapter, which is a `DapServerConfig` if `codelldb`
|
||||
is detected, and a `DapExecutableConfig` if `lldb` is detected.
|
||||
Set to `false` to disable.
|
||||
'';
|
||||
};
|
||||
helpers.mkNullOrStrLuaFnOr (with types; either (enum [ false ]) dapConfig) ''
|
||||
Defaults to creating the `rt_lldb` adapter, which is a `DapServerConfig` if `codelldb`
|
||||
is detected, and a `DapExecutableConfig` if `lldb` is detected.
|
||||
Set to `false` to disable.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
extraPackages = [cfg.rustAnalyzerPackage];
|
||||
extraPackages = [ cfg.rustAnalyzerPackage ];
|
||||
|
||||
plugins.lsp.postConfig = let
|
||||
globalOptions = with cfg;
|
||||
{
|
||||
tools = with tools; {
|
||||
inherit executor;
|
||||
on_initialized = onInitialized;
|
||||
reload_workspace_from_cargo_toml = reloadWorkspaceFromCargoToml;
|
||||
hover_actions = {
|
||||
replace_builtin_hover = hoverActions.replaceBuiltinHover;
|
||||
plugins.lsp.postConfig =
|
||||
let
|
||||
globalOptions =
|
||||
with cfg;
|
||||
{
|
||||
tools = with tools; {
|
||||
inherit executor;
|
||||
on_initialized = onInitialized;
|
||||
reload_workspace_from_cargo_toml = reloadWorkspaceFromCargoToml;
|
||||
hover_actions = {
|
||||
replace_builtin_hover = hoverActions.replaceBuiltinHover;
|
||||
};
|
||||
float_win_config = floatWinConfig;
|
||||
create_graph = {
|
||||
inherit (crateGraph) backend output full;
|
||||
enabled_graphviz_backends = crateGraph.enabledGraphvizBackends;
|
||||
inherit (crateGraph) pipe;
|
||||
};
|
||||
open_url = openUrl;
|
||||
};
|
||||
float_win_config = floatWinConfig;
|
||||
create_graph = {
|
||||
server = with server; {
|
||||
auto_attach = autoAttach;
|
||||
on_attach = onAttach;
|
||||
inherit
|
||||
(crateGraph)
|
||||
backend
|
||||
output
|
||||
full
|
||||
cmd
|
||||
settings
|
||||
standalone
|
||||
logfile
|
||||
;
|
||||
enabled_graphviz_backends = crateGraph.enabledGraphvizBackends;
|
||||
inherit (crateGraph) pipe;
|
||||
};
|
||||
open_url = openUrl;
|
||||
};
|
||||
server = with server; {
|
||||
auto_attach = autoAttach;
|
||||
on_attach = onAttach;
|
||||
inherit
|
||||
cmd
|
||||
settings
|
||||
standalone
|
||||
logfile
|
||||
;
|
||||
};
|
||||
dap = with dap; {
|
||||
autoload_configurations = autoloadConfigurations;
|
||||
inherit adapter;
|
||||
};
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
in ''
|
||||
vim.g.rustaceanvim = ${helpers.toLuaObject globalOptions}
|
||||
'';
|
||||
dap = with dap; {
|
||||
autoload_configurations = autoloadConfigurations;
|
||||
inherit adapter;
|
||||
};
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
in
|
||||
''
|
||||
vim.g.rustaceanvim = ${helpers.toLuaObject globalOptions}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue