Skip to content

Commit

Permalink
plugins/rustaceanvim: Allow to add on_attach to rustaceanvim (nix-com…
Browse files Browse the repository at this point in the history
…munity#979)

* plugins/rustaceanvim: Add 'onAttach'

* plugins/rustaceanvim: Put the configuration after the lsp setups to use __lspOnAttach
  • Loading branch information
traxys authored Jan 26, 2024
1 parent 7164a89 commit 368f4d6
Showing 1 changed file with 40 additions and 33 deletions.
73 changes: 40 additions & 33 deletions plugins/languages/rustaceanvim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ in {
```
'';

onAttach = helpers.defaultNullOpts.mkLuaFn "__lspOnAttach" "Function to call on attach";

cmd = helpers.mkNullOrStrLuaFnOr (with types; listOf str) ''
Command and arguments for starting rust-analyzer.
Expand Down Expand Up @@ -241,42 +243,47 @@ in {
(cfg.rustAnalyzerPackage != null)
cfg.rustAnalyzerPackage;

globals.rustaceanvim = 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;
inherit
cmd
settings
standalone
logfile
;
};
dap = with dap; {
autoload_configurations = autoloadConfigurations;
inherit adapter;
};
}
// cfg.extraOptions;
dap = with dap; {
autoload_configurations = autoloadConfigurations;
inherit adapter;
};
}
// cfg.extraOptions;
in ''
vim.g.rustaceanvim = ${helpers.toLuaObject globalOptions}
'';
};
}

0 comments on commit 368f4d6

Please sign in to comment.