From a1c7932bdbaa566996d7d7de6afb05b1ddf05fb1 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Tue, 20 Aug 2024 22:52:34 -0500 Subject: [PATCH] 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. --- .../languages/rust/rustaceanvim/default.nix | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/plugins/languages/rust/rustaceanvim/default.nix b/plugins/languages/rust/rustaceanvim/default.nix index 78fd2343..6afba9eb 100644 --- a/plugins/languages/rust/rustaceanvim/default.nix +++ b/plugins/languages/rust/rustaceanvim/default.nix @@ -52,14 +52,12 @@ helpers.neovim-plugin.mkNeovimPlugin config { callSetup = false; extraConfig = cfg: - let - configStr = '' - vim.g.rustaceanvim = ${helpers.toLuaObject cfg.settings} - ''; - in mkMerge [ { extraPackages = [ cfg.rustAnalyzerPackage ]; + + globals.rustaceanvim = cfg.settings; + # TODO: remove after 24.11 warnings = optional @@ -78,13 +76,11 @@ helpers.neovim-plugin.mkNeovimPlugin config { # 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; + plugins.rustaceanvim.settings.server.on_attach = mkDefault '' + function(client, bufnr) + return _M.lspOnAttach(client, bufnr) + end + ''; }) - # Else, just put the plugin config anywhere - (mkIf (!config.plugins.lsp.enable) { extraConfigLua = configStr; }) ]; }