plugins/rustaceanvim: Allow to add on_attach to rustaceanvim (#979)

* plugins/rustaceanvim: Add 'onAttach'

* plugins/rustaceanvim: Put the configuration after the lsp setups to use __lspOnAttach
This commit is contained in:
traxys 2024-01-26 14:38:07 +01:00 committed by GitHub
parent 7164a89f72
commit 368f4d6a58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -135,6 +135,8 @@ in {
``` ```
''; '';
onAttach = helpers.defaultNullOpts.mkLuaFn "__lspOnAttach" "Function to call on attach";
cmd = helpers.mkNullOrStrLuaFnOr (with types; listOf str) '' cmd = helpers.mkNullOrStrLuaFnOr (with types; listOf str) ''
Command and arguments for starting rust-analyzer. Command and arguments for starting rust-analyzer.
@ -241,42 +243,47 @@ in {
(cfg.rustAnalyzerPackage != null) (cfg.rustAnalyzerPackage != null)
cfg.rustAnalyzerPackage; cfg.rustAnalyzerPackage;
globals.rustaceanvim = with cfg; plugins.lsp.postConfig = let
{ globalOptions = with cfg;
tools = with tools; { {
inherit executor; tools = with tools; {
on_initialized = onInitialized; inherit executor;
reload_workspace_from_cargo_toml = reloadWorkspaceFromCargoToml; on_initialized = onInitialized;
hover_actions = { reload_workspace_from_cargo_toml = reloadWorkspaceFromCargoToml;
replace_builtin_hover = hoverActions.replaceBuiltinHover; 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; server = with server; {
create_graph = { auto_attach = autoAttach;
on_attach = onAttach;
inherit inherit
(crateGraph) cmd
backend settings
output standalone
full logfile
; ;
enabled_graphviz_backends = crateGraph.enabledGraphvizBackends;
inherit (crateGraph) pipe;
}; };
open_url = openUrl; dap = with dap; {
}; autoload_configurations = autoloadConfigurations;
server = with server; { inherit adapter;
auto_attach = autoAttach; };
inherit }
cmd // cfg.extraOptions;
settings in ''
standalone vim.g.rustaceanvim = ${helpers.toLuaObject globalOptions}
logfile '';
;
};
dap = with dap; {
autoload_configurations = autoloadConfigurations;
inherit adapter;
};
}
// cfg.extraOptions;
}; };
} }