mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-23 09:18:38 +02:00
plugins/rustaceanvim: switch to mkNeovimPlugin
This commit is contained in:
parent
c490fbe5d9
commit
5b09c711e2
6 changed files with 590 additions and 440 deletions
|
@ -69,7 +69,7 @@
|
||||||
./languages/python/jupytext.nix
|
./languages/python/jupytext.nix
|
||||||
./languages/qmk.nix
|
./languages/qmk.nix
|
||||||
./languages/rust/rust-tools.nix
|
./languages/rust/rust-tools.nix
|
||||||
./languages/rust/rustaceanvim.nix
|
./languages/rust/rustaceanvim
|
||||||
./languages/sniprun.nix
|
./languages/sniprun.nix
|
||||||
./languages/tagbar.nix
|
./languages/tagbar.nix
|
||||||
./languages/texpresso.nix
|
./languages/texpresso.nix
|
||||||
|
|
|
@ -1,304 +0,0 @@
|
||||||
{
|
|
||||||
lib,
|
|
||||||
helpers,
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
|
||||||
let
|
|
||||||
cfg = config.plugins.rustaceanvim;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
meta.maintainers = [ maintainers.GaetanLepage ];
|
|
||||||
|
|
||||||
options.plugins.rustaceanvim = helpers.neovim-plugin.extraOptionsOptions // {
|
|
||||||
enable = mkEnableOption "rustaceanvim";
|
|
||||||
|
|
||||||
package = helpers.mkPluginPackageOption "rustaceanvim" pkgs.vimPlugins.rustaceanvim;
|
|
||||||
|
|
||||||
rustAnalyzerPackage = helpers.mkPackageOption {
|
|
||||||
name = "rust-analyzer";
|
|
||||||
default = pkgs.rust-analyzer;
|
|
||||||
};
|
|
||||||
|
|
||||||
tools =
|
|
||||||
let
|
|
||||||
executors = [
|
|
||||||
"termopen"
|
|
||||||
"quickfix"
|
|
||||||
"toggleterm"
|
|
||||||
"vimux"
|
|
||||||
"neotest"
|
|
||||||
];
|
|
||||||
testExecutors = executors ++ [ "background" ];
|
|
||||||
in
|
|
||||||
{
|
|
||||||
executor = helpers.defaultNullOpts.mkEnum executors "termopen" ''
|
|
||||||
`{execute_command} (fun(cmd:string,args:string[],cwd:string|nil,opts?:RustaceanExecutorOpts))`
|
|
||||||
The executor to use for runnables/debuggables.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
```lua
|
|
||||||
{
|
|
||||||
execute_command = function(command, args, cwd, _)
|
|
||||||
require('toggleterm.terminal').Terminal
|
|
||||||
:new({
|
|
||||||
dir = cwd,
|
|
||||||
cmd = require('rustaceanvim.shell').make_command_from_args(command, args),
|
|
||||||
close_on_exit = false,
|
|
||||||
direction = 'vertical',
|
|
||||||
})
|
|
||||||
:toggle()
|
|
||||||
end
|
|
||||||
}
|
|
||||||
```
|
|
||||||
'';
|
|
||||||
|
|
||||||
testExecutor = helpers.defaultNullOpts.mkEnum testExecutors "termopen" ''
|
|
||||||
`{execute_command} (fun(cmd:string,args:string[],cwd:string|nil,opts?:RustaceanExecutorOpts))`
|
|
||||||
The executor to use for runnables that are tests/testables
|
|
||||||
'';
|
|
||||||
|
|
||||||
crateTestExecutor = helpers.defaultNullOpts.mkEnum testExecutors "termopen" ''
|
|
||||||
`{execute_command} (fun(cmd:string,args:string[],cwd:string|nil,opts?:RustaceanExecutorOpts))`
|
|
||||||
The executor to use for runnables that are crate test suites (--all-targets)
|
|
||||||
'';
|
|
||||||
|
|
||||||
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.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
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
|
|
||||||
''
|
|
||||||
[
|
|
||||||
"bmp" "cgimage" "canon" "dot" "gv" "xdot" "xdot1.2" "xdot1.4" "eps" "exr" "fig" "gd"
|
|
||||||
"gd2" "gif" "gtk" "ico" "cmap" "ismap" "imap" "cmapx" "imap_np" "cmapx_np" "jpg"
|
|
||||||
"jpeg" "jpe" "jp2" "json" "json0" "dot_json" "xdot_json" "pdf" "pic" "pct" "pict"
|
|
||||||
"plain" "plain-ext" "png" "pov" "ps" "ps2" "psd" "sgi" "svg" "svgz" "tga" "tiff"
|
|
||||||
"tif" "tk" "vml" "vmlz" "wbmp" "webp" "xlib" "x11"
|
|
||||||
]
|
|
||||||
''
|
|
||||||
''
|
|
||||||
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.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
server = {
|
|
||||||
autoAttach = helpers.mkNullOrStrLuaFnOr types.bool ''
|
|
||||||
Whether to automatically attach the LSP client.
|
|
||||||
Defaults to `true` if the `rust-analyzer` executable is found.
|
|
||||||
|
|
||||||
This can also be the definition of a function (`fun():boolean`).
|
|
||||||
|
|
||||||
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
|
|
||||||
```
|
|
||||||
'';
|
|
||||||
|
|
||||||
onAttach = helpers.defaultNullOpts.mkLuaFn "__lspOnAttach" "Function to call on attach";
|
|
||||||
|
|
||||||
cmd = helpers.mkNullOrStrLuaFnOr (with types; listOf str) ''
|
|
||||||
Command and arguments for starting rust-analyzer.
|
|
||||||
|
|
||||||
This can also be the definition of a function (`fun():string[]`).
|
|
||||||
|
|
||||||
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.
|
|
||||||
See https://rust-analyzer.github.io/manual.html#configuration.
|
|
||||||
|
|
||||||
This can also be the definition of a function (`fun(project_root:string|nil):table`).
|
|
||||||
|
|
||||||
Default:
|
|
||||||
```lua
|
|
||||||
function(project_root)
|
|
||||||
return require('rustaceanvim.config.server').load_rust_analyzer_settings(project_root)
|
|
||||||
end
|
|
||||||
```
|
|
||||||
'';
|
|
||||||
|
|
||||||
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)
|
|
||||||
''{__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 ?
|
|
||||||
'';
|
|
||||||
|
|
||||||
adapter =
|
|
||||||
let
|
|
||||||
dapConfig = types.submodule {
|
|
||||||
freeformType = with types; attrsOf anything;
|
|
||||||
options = {
|
|
||||||
# Common options
|
|
||||||
type = mkOption {
|
|
||||||
type = types.enum [
|
|
||||||
"executable"
|
|
||||||
"server"
|
|
||||||
];
|
|
||||||
description = "The type for the debug adapter.";
|
|
||||||
};
|
|
||||||
|
|
||||||
name = helpers.mkNullOrStr "The name of this adapter.";
|
|
||||||
|
|
||||||
# Executable
|
|
||||||
command = helpers.defaultNullOpts.mkStr "lldb-vscode" ''
|
|
||||||
The command to run for this adapter.
|
|
||||||
'';
|
|
||||||
|
|
||||||
args = helpers.mkNullOrStr "Its arguments.";
|
|
||||||
|
|
||||||
# Server
|
|
||||||
host = helpers.mkNullOrStr "The host to connect to.";
|
|
||||||
|
|
||||||
port = helpers.mkNullOrStr "The port to connect to.";
|
|
||||||
|
|
||||||
executable = {
|
|
||||||
command = helpers.mkNullOrStr "The command for the executable.";
|
|
||||||
|
|
||||||
args = helpers.mkNullOrOption (with helpers.nixvimTypes; maybeRaw (listOf str)) ''
|
|
||||||
Its arguments.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
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.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
extraPlugins = [ cfg.package ];
|
|
||||||
|
|
||||||
extraPackages = [ cfg.rustAnalyzerPackage ];
|
|
||||||
|
|
||||||
plugins.lsp.postConfig =
|
|
||||||
let
|
|
||||||
globalOptions =
|
|
||||||
with cfg;
|
|
||||||
{
|
|
||||||
tools = with tools; {
|
|
||||||
inherit executor;
|
|
||||||
test_executor = testExecutor;
|
|
||||||
crate_test_executor = crateTestExecutor;
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
server = with server; {
|
|
||||||
auto_attach = autoAttach;
|
|
||||||
on_attach = if onAttach == null then helpers.mkRaw "__lspOnAttach" else onAttach;
|
|
||||||
inherit
|
|
||||||
cmd
|
|
||||||
settings
|
|
||||||
standalone
|
|
||||||
logfile
|
|
||||||
;
|
|
||||||
};
|
|
||||||
dap = with dap; {
|
|
||||||
autoload_configurations = autoloadConfigurations;
|
|
||||||
inherit adapter;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// cfg.extraOptions;
|
|
||||||
in
|
|
||||||
''
|
|
||||||
vim.g.rustaceanvim = ${helpers.toLuaObject globalOptions}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
74
plugins/languages/rust/rustaceanvim/default.nix
Normal file
74
plugins/languages/rust/rustaceanvim/default.nix
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
helpers,
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||||
|
name = "rustaceanvim";
|
||||||
|
defaultPackage = pkgs.vimPlugins.rustaceanvim;
|
||||||
|
|
||||||
|
maintainers = [ maintainers.GaetanLepage ];
|
||||||
|
|
||||||
|
# TODO: introduced 2024-05-17, remove on 2024-02-17
|
||||||
|
deprecateExtraOptions = true;
|
||||||
|
optionsRenamedToSettings = import ./renamed-options.nix;
|
||||||
|
|
||||||
|
extraOptions = {
|
||||||
|
rustAnalyzerPackage = helpers.mkPackageOption {
|
||||||
|
name = "rust-analyzer";
|
||||||
|
default = pkgs.rust-analyzer;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
settingsOptions = import ./settings-options.nix { inherit lib helpers pkgs; };
|
||||||
|
|
||||||
|
settingsExample = {
|
||||||
|
server = {
|
||||||
|
standalone = false;
|
||||||
|
cmd = [
|
||||||
|
"rustup"
|
||||||
|
"run"
|
||||||
|
"nightly"
|
||||||
|
"rust-analyzer"
|
||||||
|
];
|
||||||
|
settings = {
|
||||||
|
rust-analyzer = {
|
||||||
|
inlayHints = {
|
||||||
|
lifetimeElisionHints = {
|
||||||
|
enable = "always";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
check = {
|
||||||
|
command = "clippy";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
callSetup = false;
|
||||||
|
extraConfig =
|
||||||
|
cfg:
|
||||||
|
let
|
||||||
|
configStr = ''
|
||||||
|
vim.g.rustaceanvim = ${helpers.toLuaObject cfg.settings}
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
mkMerge [
|
||||||
|
{ extraPackages = [ cfg.rustAnalyzerPackage ]; }
|
||||||
|
# If nvim-lspconfig is enabled:
|
||||||
|
(mkIf config.plugins.lsp.enable {
|
||||||
|
# Use the same `on_attach` callback as for the other LSP servers
|
||||||
|
plugins.rustaceanvim.settings.server.on_attach = mkDefault "__lspOnAttach";
|
||||||
|
|
||||||
|
# Ensure the plugin config is placed **after** the rest of the LSP configuration
|
||||||
|
# (and thus after the declaration of `__lspOnAttach`)
|
||||||
|
plugins.lsp.postConfig = configStr;
|
||||||
|
})
|
||||||
|
# Else, just put the plugin config anywhere
|
||||||
|
(mkIf (!config.plugins.lsp.enable) { extraConfigLua = configStr; })
|
||||||
|
];
|
||||||
|
}
|
92
plugins/languages/rust/rustaceanvim/renamed-options.nix
Normal file
92
plugins/languages/rust/rustaceanvim/renamed-options.nix
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
[
|
||||||
|
[
|
||||||
|
"tools"
|
||||||
|
"executor"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"tools"
|
||||||
|
"testExecutors"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"tools"
|
||||||
|
"crateTestExecutor"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"tools"
|
||||||
|
"onInitialized"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"tools"
|
||||||
|
"reloadWorkspaceFromCargoToml"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"tools"
|
||||||
|
"hoverActions"
|
||||||
|
"replaceBuiltinHover"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"tools"
|
||||||
|
"floatWinConfig"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"tools"
|
||||||
|
"crateGraph"
|
||||||
|
"backend"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"tools"
|
||||||
|
"crateGraph"
|
||||||
|
"output"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"tools"
|
||||||
|
"crateGraph"
|
||||||
|
"full"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"tools"
|
||||||
|
"crateGraph"
|
||||||
|
"enabledGraphvizBackends"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"tools"
|
||||||
|
"crateGraph"
|
||||||
|
"pipe"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"tools"
|
||||||
|
"openUrl"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"server"
|
||||||
|
"autoAttach"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"server"
|
||||||
|
"onAttach"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"server"
|
||||||
|
"cmd"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"server"
|
||||||
|
"settings"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"server"
|
||||||
|
"standalone"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"server"
|
||||||
|
"logfile"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"dap"
|
||||||
|
"autoloadConfigurations"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"dap"
|
||||||
|
"adapter"
|
||||||
|
]
|
||||||
|
]
|
295
plugins/languages/rust/rustaceanvim/settings-options.nix
Normal file
295
plugins/languages/rust/rustaceanvim/settings-options.nix
Normal file
|
@ -0,0 +1,295 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
helpers,
|
||||||
|
pkgs,
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
{
|
||||||
|
tools =
|
||||||
|
let
|
||||||
|
executors = [
|
||||||
|
"termopen"
|
||||||
|
"quickfix"
|
||||||
|
"toggleterm"
|
||||||
|
"vimux"
|
||||||
|
"neotest"
|
||||||
|
];
|
||||||
|
testExecutors = executors ++ [ "background" ];
|
||||||
|
executorSubmodule = types.submodule {
|
||||||
|
options = {
|
||||||
|
execute_command = helpers.mkNullOrLuaFn ''
|
||||||
|
```lua
|
||||||
|
fun(cmd:string,args:string[],cwd:string|nil,opts?:RustaceanExecutorOpts)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```lua
|
||||||
|
function(command, args, cwd, _)
|
||||||
|
require('toggleterm.terminal').Terminal
|
||||||
|
:new({
|
||||||
|
dir = cwd,
|
||||||
|
cmd = require('rustaceanvim.shell').make_command_from_args(command, args),
|
||||||
|
close_on_exit = false,
|
||||||
|
direction = 'vertical',
|
||||||
|
})
|
||||||
|
:toggle()
|
||||||
|
end
|
||||||
|
```
|
||||||
|
```
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
executor =
|
||||||
|
helpers.defaultNullOpts.mkNullable (with types; either (enum executors) executorSubmodule)
|
||||||
|
"termopen"
|
||||||
|
''
|
||||||
|
The executor to use for runnables/debuggables.
|
||||||
|
Either an executor alias or an attrs with the `execute_command` key.
|
||||||
|
'';
|
||||||
|
|
||||||
|
test_executor =
|
||||||
|
helpers.mkNullOrOption (with types; either (enum testExecutors) executorSubmodule)
|
||||||
|
''
|
||||||
|
The executor to use for runnables that are tests/testables
|
||||||
|
Either a test executor alias or an attrs with the `execute_command` key.
|
||||||
|
'';
|
||||||
|
|
||||||
|
crate_test_executor =
|
||||||
|
helpers.mkNullOrOption (with types; either (enum testExecutors) executorSubmodule)
|
||||||
|
''
|
||||||
|
The executor to use for runnables that are crate test suites (`--all-targets`).
|
||||||
|
Either a test executor alias or an attrs with the `execute_command` key.
|
||||||
|
'';
|
||||||
|
|
||||||
|
cargo_override = helpers.mkNullOrStr ''
|
||||||
|
Set this to override the 'cargo' command for runnables, debuggables (etc., e.g. to `"cross"`).
|
||||||
|
If set, this takes precedence over `enable_nextest`.
|
||||||
|
'';
|
||||||
|
|
||||||
|
enable_nextest = helpers.defaultNullOpts.mkBool true ''
|
||||||
|
Whether to enable nextest.
|
||||||
|
If enabled, `cargo test` commands will be transformed to `cargo nextest run` commands.
|
||||||
|
Defaults to `true` if cargo-nextest is detected.
|
||||||
|
Ignored if `cargo_override` is set.
|
||||||
|
'';
|
||||||
|
|
||||||
|
enable_clippy = helpers.defaultNullOpts.mkBool true ''
|
||||||
|
Whether to enable clippy checks on save if a clippy installation is detected.
|
||||||
|
'';
|
||||||
|
|
||||||
|
on_initialized = helpers.mkNullOrLuaFn ''
|
||||||
|
`fun(health:RustAnalyzerInitializedStatus)`
|
||||||
|
Function that is invoked when the LSP server has finished initializing.
|
||||||
|
'';
|
||||||
|
|
||||||
|
reload_workspace_from_cargo_toml = helpers.defaultNullOpts.mkBool true ''
|
||||||
|
Automatically call `RustReloadWorkspace` when writing to a `Cargo.toml` file.
|
||||||
|
'';
|
||||||
|
|
||||||
|
hover_actions = {
|
||||||
|
replace_builtin_hover = helpers.defaultNullOpts.mkBool true ''
|
||||||
|
Whether to replace Neovim's built-in `vim.lsp.buf.hover` with hover actions.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
code_actions = {
|
||||||
|
group_icon = helpers.defaultNullOpts.mkStr " ▶" ''
|
||||||
|
Text appended to a group action.
|
||||||
|
'';
|
||||||
|
|
||||||
|
ui_select_fallback = helpers.defaultNullOpts.mkBool false ''
|
||||||
|
Whether to fall back to `vim.ui.select` if there are no grouped code actions.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
float_win_config = {
|
||||||
|
auto_focus = helpers.defaultNullOpts.mkBool false ''
|
||||||
|
Whether the window gets automatically focused.
|
||||||
|
'';
|
||||||
|
|
||||||
|
open_split =
|
||||||
|
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||||
|
[
|
||||||
|
"horizontal"
|
||||||
|
"vertical"
|
||||||
|
]
|
||||||
|
''
|
||||||
|
Whether splits opened from floating preview are vertical.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
crate_graph = {
|
||||||
|
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.
|
||||||
|
'';
|
||||||
|
|
||||||
|
enabled_graphviz_backends =
|
||||||
|
helpers.defaultNullOpts.mkListOf types.str
|
||||||
|
''
|
||||||
|
[
|
||||||
|
"bmp" "cgimage" "canon" "dot" "gv" "xdot" "xdot1.2" "xdot1.4" "eps" "exr" "fig" "gd"
|
||||||
|
"gd2" "gif" "gtk" "ico" "cmap" "ismap" "imap" "cmapx" "imap_np" "cmapx_np" "jpg"
|
||||||
|
"jpeg" "jpe" "jp2" "json" "json0" "dot_json" "xdot_json" "pdf" "pic" "pct" "pict"
|
||||||
|
"plain" "plain-ext" "png" "pov" "ps" "ps2" "psd" "sgi" "svg" "svgz" "tga" "tiff"
|
||||||
|
"tif" "tk" "vml" "vmlz" "wbmp" "webp" "xlib" "x11"
|
||||||
|
]
|
||||||
|
''
|
||||||
|
''
|
||||||
|
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.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
open_url = helpers.defaultNullOpts.mkLuaFn "require('rustaceanvim.os').open_url" ''
|
||||||
|
If set, overrides how to open URLs.
|
||||||
|
`fun(url:string):nil`
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
server = {
|
||||||
|
auto_attach = helpers.mkNullOrStrLuaFnOr types.bool ''
|
||||||
|
Whether to automatically attach the LSP client.
|
||||||
|
Defaults to `true` if the `rust-analyzer` executable is found.
|
||||||
|
|
||||||
|
This can also be the definition of a function (`fun():boolean`).
|
||||||
|
|
||||||
|
Plugin default:
|
||||||
|
```lua
|
||||||
|
function(bufnr)
|
||||||
|
if #vim.bo[bufnr].buftype > 0 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local path = vim.api.nvim_buf_get_name(bufnr)
|
||||||
|
if not os.is_valid_file_path(path) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local cmd = types.evaluate(RustaceanConfig.server.cmd)
|
||||||
|
---@cast cmd string[]
|
||||||
|
local rs_bin = cmd[1]
|
||||||
|
return vim.fn.executable(rs_bin) == 1
|
||||||
|
end
|
||||||
|
```
|
||||||
|
'';
|
||||||
|
|
||||||
|
on_attach = helpers.mkNullOrLuaFn ''
|
||||||
|
Function to call on attach.
|
||||||
|
If `plugins.lsp` is enabled, it defaults to the Nixvim global `__lspOnAttach` function.
|
||||||
|
Otherwise it defaults to `null`.
|
||||||
|
'';
|
||||||
|
|
||||||
|
cmd = helpers.mkNullOrStrLuaFnOr (with types; listOf str) ''
|
||||||
|
Command and arguments for starting rust-analyzer.
|
||||||
|
|
||||||
|
This can also be the definition of a function:
|
||||||
|
`fun(project_root:string|nil,default_settings:table):table`
|
||||||
|
|
||||||
|
Plugin 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.
|
||||||
|
See https://rust-analyzer.github.io/manual.html#configuration.
|
||||||
|
|
||||||
|
This can also be the definition of a function:
|
||||||
|
`fun(project_root:string|nil, default_settings: table|nil):table`
|
||||||
|
|
||||||
|
Plugin default:
|
||||||
|
```lua
|
||||||
|
function(project_root, default_settings)
|
||||||
|
return require('rustaceanvim.config.server').load_rust_analyzer_settings(project_root, { default_settings = default_settings })
|
||||||
|
end
|
||||||
|
```
|
||||||
|
'';
|
||||||
|
|
||||||
|
standalone = helpers.defaultNullOpts.mkBool true ''
|
||||||
|
Standalone file support (enabled by default).
|
||||||
|
Disabling it may improve rust-analyzer's startup time.
|
||||||
|
'';
|
||||||
|
|
||||||
|
logfile = helpers.defaultNullOpts.mkStr ''{__raw = "vim.fn.tempname() .. '-rust-analyzer.log'";}'' ''
|
||||||
|
The path to the rust-analyzer log file.
|
||||||
|
'';
|
||||||
|
|
||||||
|
load_vscode_settings = helpers.defaultNullOpts.mkBool false ''
|
||||||
|
Whether to search (upward from the buffer) for rust-analyzer settings in `.vscode/settings` json.
|
||||||
|
If found, loaded settings will override configured options.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
dap = {
|
||||||
|
autoload_configurations = helpers.defaultNullOpts.mkBool true ''
|
||||||
|
Whether to autoload nvim-dap configurations when rust-analyzer has attached.
|
||||||
|
'';
|
||||||
|
|
||||||
|
adapter =
|
||||||
|
let
|
||||||
|
dapConfig = types.submodule {
|
||||||
|
freeformType = with types; attrsOf anything;
|
||||||
|
options = {
|
||||||
|
# Common options
|
||||||
|
type = mkOption {
|
||||||
|
type = types.enum [
|
||||||
|
"executable"
|
||||||
|
"server"
|
||||||
|
];
|
||||||
|
description = "The type for the debug adapter.";
|
||||||
|
};
|
||||||
|
|
||||||
|
name = helpers.mkNullOrStr "The name of this adapter.";
|
||||||
|
|
||||||
|
# Executable
|
||||||
|
command = helpers.defaultNullOpts.mkStr "lldb-vscode" ''
|
||||||
|
The command to run for this adapter.
|
||||||
|
'';
|
||||||
|
|
||||||
|
args = helpers.mkNullOrStr "Its arguments.";
|
||||||
|
|
||||||
|
# Server
|
||||||
|
host = helpers.mkNullOrStr "The host to connect to.";
|
||||||
|
|
||||||
|
port = helpers.mkNullOrStr "The port to connect to.";
|
||||||
|
|
||||||
|
executable = {
|
||||||
|
command = helpers.mkNullOrStr "The command for the executable.";
|
||||||
|
|
||||||
|
args = helpers.mkNullOrOption (with helpers.nixvimTypes; maybeRaw (listOf str)) ''
|
||||||
|
Its arguments.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
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.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
|
@ -7,150 +7,143 @@
|
||||||
plugins.rustaceanvim = {
|
plugins.rustaceanvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
tools = {
|
settings = {
|
||||||
executor = "termopen";
|
|
||||||
onInitialized = null;
|
tools = {
|
||||||
reloadWorkspaceFromCargoToml = true;
|
executor = "termopen";
|
||||||
hoverActions = {
|
test_executor = "background";
|
||||||
replaceBuiltinHover = true;
|
crate_test_executor = "background";
|
||||||
|
cargo_override = null;
|
||||||
|
enable_nextest = true;
|
||||||
|
enable_clippy = true;
|
||||||
|
on_initialized = null;
|
||||||
|
reload_workspace_from_cargo_toml = true;
|
||||||
|
hover_actions = {
|
||||||
|
replace_builtin_hover = true;
|
||||||
|
};
|
||||||
|
code_actions = {
|
||||||
|
group_icon = " ▶";
|
||||||
|
ui_select_fallback = false;
|
||||||
|
};
|
||||||
|
float_win_config = {
|
||||||
|
auto_focus = false;
|
||||||
|
open_split = "horizontal";
|
||||||
|
};
|
||||||
|
crate_graph = {
|
||||||
|
backend = "x11";
|
||||||
|
output = null;
|
||||||
|
full = true;
|
||||||
|
enabled_graphviz_backends = [
|
||||||
|
"bmp"
|
||||||
|
"cgimage"
|
||||||
|
"canon"
|
||||||
|
"dot"
|
||||||
|
"gv"
|
||||||
|
"xdot"
|
||||||
|
"xdot1.2"
|
||||||
|
"xdot1.4"
|
||||||
|
"eps"
|
||||||
|
"exr"
|
||||||
|
"fig"
|
||||||
|
"gd"
|
||||||
|
"gd2"
|
||||||
|
"gif"
|
||||||
|
"gtk"
|
||||||
|
"ico"
|
||||||
|
"cmap"
|
||||||
|
"ismap"
|
||||||
|
"imap"
|
||||||
|
"cmapx"
|
||||||
|
"imap_np"
|
||||||
|
"cmapx_np"
|
||||||
|
"jpg"
|
||||||
|
"jpeg"
|
||||||
|
"jpe"
|
||||||
|
"jp2"
|
||||||
|
"json"
|
||||||
|
"json0"
|
||||||
|
"dot_json"
|
||||||
|
"xdot_json"
|
||||||
|
"pdf"
|
||||||
|
"pic"
|
||||||
|
"pct"
|
||||||
|
"pict"
|
||||||
|
"plain"
|
||||||
|
"plain-ext"
|
||||||
|
"png"
|
||||||
|
"pov"
|
||||||
|
"ps"
|
||||||
|
"ps2"
|
||||||
|
"psd"
|
||||||
|
"sgi"
|
||||||
|
"svg"
|
||||||
|
"svgz"
|
||||||
|
"tga"
|
||||||
|
"tiff"
|
||||||
|
"tif"
|
||||||
|
"tk"
|
||||||
|
"vml"
|
||||||
|
"vmlz"
|
||||||
|
"wbmp"
|
||||||
|
"webp"
|
||||||
|
"xlib"
|
||||||
|
"x11"
|
||||||
|
];
|
||||||
|
pipe = null;
|
||||||
|
};
|
||||||
|
open_url = "require('rustaceanvim.os').open_url";
|
||||||
};
|
};
|
||||||
floatWinConfig = {
|
server = {
|
||||||
border = [
|
auto_attach = ''
|
||||||
[
|
function(bufnr)
|
||||||
"╭"
|
if #vim.bo[bufnr].buftype > 0 then
|
||||||
"FloatBorder"
|
return false
|
||||||
]
|
end
|
||||||
[
|
local path = vim.api.nvim_buf_get_name(bufnr)
|
||||||
"─"
|
if not os.is_valid_file_path(path) then
|
||||||
"FloatBorder"
|
return false
|
||||||
]
|
end
|
||||||
[
|
local cmd = types.evaluate(RustaceanConfig.server.cmd)
|
||||||
"╮"
|
---@cast cmd string[]
|
||||||
"FloatBorder"
|
local rs_bin = cmd[1]
|
||||||
]
|
return vim.fn.executable(rs_bin) == 1
|
||||||
[
|
end
|
||||||
"│"
|
'';
|
||||||
"FloatBorder"
|
on_attach = null;
|
||||||
]
|
cmd = ''
|
||||||
[
|
function()
|
||||||
"╯"
|
return { 'rust-analyzer', '--log-file', RustaceanConfig.server.logfile }
|
||||||
"FloatBorder"
|
end
|
||||||
]
|
'';
|
||||||
[
|
settings = ''
|
||||||
"─"
|
function(project_root, default_settings)
|
||||||
"FloatBorder"
|
return require('rustaceanvim.config.server').load_rust_analyzer_settings(project_root, { default_settings = default_settings })
|
||||||
]
|
end
|
||||||
[
|
'';
|
||||||
"╰"
|
standalone = true;
|
||||||
"FloatBorder"
|
logfile.__raw = "vim.fn.tempname() .. '-rust-analyzer.log'";
|
||||||
]
|
load_vscode_settings = false;
|
||||||
[
|
|
||||||
"│"
|
|
||||||
"FloatBorder"
|
|
||||||
]
|
|
||||||
];
|
|
||||||
max_width = null;
|
|
||||||
max_height = null;
|
|
||||||
auto_focus = false;
|
|
||||||
};
|
};
|
||||||
crateGraph = {
|
dap = {
|
||||||
backend = "x11";
|
autoload_configurations = true;
|
||||||
output = null;
|
adapter = null;
|
||||||
full = true;
|
|
||||||
enabledGraphvizBackends = [
|
|
||||||
"bmp"
|
|
||||||
"cgimage"
|
|
||||||
"canon"
|
|
||||||
"dot"
|
|
||||||
"gv"
|
|
||||||
"xdot"
|
|
||||||
"xdot1.2"
|
|
||||||
"xdot1.4"
|
|
||||||
"eps"
|
|
||||||
"exr"
|
|
||||||
"fig"
|
|
||||||
"gd"
|
|
||||||
"gd2"
|
|
||||||
"gif"
|
|
||||||
"gtk"
|
|
||||||
"ico"
|
|
||||||
"cmap"
|
|
||||||
"ismap"
|
|
||||||
"imap"
|
|
||||||
"cmapx"
|
|
||||||
"imap_np"
|
|
||||||
"cmapx_np"
|
|
||||||
"jpg"
|
|
||||||
"jpeg"
|
|
||||||
"jpe"
|
|
||||||
"jp2"
|
|
||||||
"json"
|
|
||||||
"json0"
|
|
||||||
"dot_json"
|
|
||||||
"xdot_json"
|
|
||||||
"pdf"
|
|
||||||
"pic"
|
|
||||||
"pct"
|
|
||||||
"pict"
|
|
||||||
"plain"
|
|
||||||
"plain-ext"
|
|
||||||
"png"
|
|
||||||
"pov"
|
|
||||||
"ps"
|
|
||||||
"ps2"
|
|
||||||
"psd"
|
|
||||||
"sgi"
|
|
||||||
"svg"
|
|
||||||
"svgz"
|
|
||||||
"tga"
|
|
||||||
"tiff"
|
|
||||||
"tif"
|
|
||||||
"tk"
|
|
||||||
"vml"
|
|
||||||
"vmlz"
|
|
||||||
"wbmp"
|
|
||||||
"webp"
|
|
||||||
"xlib"
|
|
||||||
"x11"
|
|
||||||
];
|
|
||||||
pipe = null;
|
|
||||||
};
|
};
|
||||||
openUrl = "require('rustaceanvim.os').open_url";
|
|
||||||
};
|
|
||||||
server = {
|
|
||||||
autoAttach = ''
|
|
||||||
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 = ''
|
|
||||||
function()
|
|
||||||
return { 'rust-analyzer', '--log-file', RustaceanConfig.server.logfile }
|
|
||||||
end
|
|
||||||
'';
|
|
||||||
settings = ''
|
|
||||||
function(project_root)
|
|
||||||
return require('rustaceanvim.config.server').load_rust_analyzer_settings(project_root)
|
|
||||||
end
|
|
||||||
'';
|
|
||||||
standalone = true;
|
|
||||||
logfile.__raw = "vim.fn.tempname() .. '-rust-analyzer.log'";
|
|
||||||
};
|
|
||||||
dap = {
|
|
||||||
autoloadConfigurations = true;
|
|
||||||
adapter = null;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
with-lspconfig = {
|
||||||
|
plugins = {
|
||||||
|
lsp.enable = true;
|
||||||
|
rustaceanvim.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
rust-analyzer-settings = {
|
rust-analyzer-settings = {
|
||||||
plugins.rustaceanvim = {
|
plugins.rustaceanvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
server.settings = {
|
settings.server.settings = {
|
||||||
linkedProjects = [ "foo/bar/hello" ];
|
linkedProjects = [ "foo/bar/hello" ];
|
||||||
numThreads = 42;
|
numThreads = 42;
|
||||||
joinLines.joinElseIf = true;
|
joinLines.joinElseIf = true;
|
||||||
|
@ -163,7 +156,7 @@
|
||||||
plugins.rustaceanvim = {
|
plugins.rustaceanvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
dap.adapter = {
|
settings.dap.adapter = {
|
||||||
type = "executable";
|
type = "executable";
|
||||||
name = "lldb";
|
name = "lldb";
|
||||||
command = "lldb-vscode";
|
command = "lldb-vscode";
|
||||||
|
@ -176,7 +169,7 @@
|
||||||
plugins.rustaceanvim = {
|
plugins.rustaceanvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
dap.adapter = {
|
settings.dap.adapter = {
|
||||||
type = "server";
|
type = "server";
|
||||||
name = "my-dap-server";
|
name = "my-dap-server";
|
||||||
host = "127.0.0.1";
|
host = "127.0.0.1";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue