mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-24 17:58:38 +02:00
plugins/rustaceanvim: fix checkhealth error with neotest configuration
Rustaceanvim will throw an error if the configuration is sourced after initialization. Our globals are defined at the top of the init.lua so moving the settings to leverage the globals option and setting a callback function as default to ensure we dont need to worry about something initializing it before lspOnAttach is available.
This commit is contained in:
parent
1e74f3deab
commit
a1c7932bdb
1 changed files with 8 additions and 12 deletions
|
@ -52,14 +52,12 @@ helpers.neovim-plugin.mkNeovimPlugin config {
|
||||||
callSetup = false;
|
callSetup = false;
|
||||||
extraConfig =
|
extraConfig =
|
||||||
cfg:
|
cfg:
|
||||||
let
|
|
||||||
configStr = ''
|
|
||||||
vim.g.rustaceanvim = ${helpers.toLuaObject cfg.settings}
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
mkMerge [
|
mkMerge [
|
||||||
{
|
{
|
||||||
extraPackages = [ cfg.rustAnalyzerPackage ];
|
extraPackages = [ cfg.rustAnalyzerPackage ];
|
||||||
|
|
||||||
|
globals.rustaceanvim = cfg.settings;
|
||||||
|
|
||||||
# TODO: remove after 24.11
|
# TODO: remove after 24.11
|
||||||
warnings =
|
warnings =
|
||||||
optional
|
optional
|
||||||
|
@ -78,13 +76,11 @@ helpers.neovim-plugin.mkNeovimPlugin config {
|
||||||
# If nvim-lspconfig is enabled:
|
# If nvim-lspconfig is enabled:
|
||||||
(mkIf config.plugins.lsp.enable {
|
(mkIf config.plugins.lsp.enable {
|
||||||
# Use the same `on_attach` callback as for the other LSP servers
|
# Use the same `on_attach` callback as for the other LSP servers
|
||||||
plugins.rustaceanvim.settings.server.on_attach = mkDefault "__lspOnAttach";
|
plugins.rustaceanvim.settings.server.on_attach = mkDefault ''
|
||||||
|
function(client, bufnr)
|
||||||
# Ensure the plugin config is placed **after** the rest of the LSP configuration
|
return _M.lspOnAttach(client, bufnr)
|
||||||
# (and thus after the declaration of `__lspOnAttach`)
|
end
|
||||||
plugins.lsp.postConfig = configStr;
|
'';
|
||||||
})
|
})
|
||||||
# Else, just put the plugin config anywhere
|
|
||||||
(mkIf (!config.plugins.lsp.enable) { extraConfigLua = configStr; })
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue