From ae8e828514ec7e201cc0c88e206749d6d5bc14b3 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sun, 22 Dec 2024 12:42:29 -0500 Subject: [PATCH] fix(nvim): defer vim calls --- flake.lock | Bin 57273 -> 57792 bytes flake.nix | Bin 11855 -> 11994 bytes .../neovim/langs/c-lang/default.nix | 5 +++-- .../neovim/langs/csharp/default.nix | 9 ++++----- homeManagerModules/neovim/langs/default.nix | 10 +++++++++- .../neovim/langs/json/default.nix | 5 +++-- .../neovim/langs/lua/default.nix | 5 +++-- .../neovim/langs/markdown/default.nix | 5 +++-- .../neovim/langs/rust/default.nix | 5 +++-- .../neovim/langs/web/default.nix | 10 ++++++---- inputs/default.nix | 5 +++++ 11 files changed, 39 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index 30248134b0dd1e4ab46169f41ebd9ab5e802a18e..1e60b8faf3c296b3451fd627ba738fb6ce75e1c4 100644 GIT binary patch delta 208 zcmdnFpZUOH<_-QOJSnMVsX6%tx_M=pxs%T)`mmW;SeRNGPhKD|r(KwsUl5XEkZ9nQ z?Q7wl7nbDjUtv~O9^~YjR^gMGSXESzXkh4PZctF-Ir(9**klD!naKyrSlFRvPL8`M zp>AfDYGIU`VwPfTZl0EGX_As+YMzvwlwxRUVw7Z_oM@h6Y-(VXHhCj&His@uBmX7S i&E6%2w(`iX(=9GaRPD~#VJx_QS&Mm+#U_(}W# delta 23 fcmX?bn0e=Z<_-QOo8`)KZ6|j(acw@k`LiwnhOi4` diff --git a/flake.nix b/flake.nix index 58a27048ecfecb366fb4ff11b438670bed5c730f..db600794189155c3d6da4e12de8cfff78abfb77c 100644 GIT binary patch delta 49 zcmX>fb1Qa3izH74Ei{xg0sna3=DEb9! diff --git a/homeManagerModules/neovim/langs/c-lang/default.nix b/homeManagerModules/neovim/langs/c-lang/default.nix index 97fb5630..ae519d0c 100644 --- a/homeManagerModules/neovim/langs/c-lang/default.nix +++ b/homeManagerModules/neovim/langs/c-lang/default.nix @@ -29,8 +29,9 @@ in { if (devShells['c-lang'] == nil) then devShells['c-lang'] = 1; - require('nix-develop').nix_develop({'${flakeEnv}#c-lang'}); - vim.cmd[[LspStart]]; + require('nix-develop').nix_develop({'${flakeEnv}#c-lang'}, vim.schedule_wrap(function() + vim.cmd[[LspStart]]; + end)); end end, }); diff --git a/homeManagerModules/neovim/langs/csharp/default.nix b/homeManagerModules/neovim/langs/csharp/default.nix index aeb34360..0907a0fb 100644 --- a/homeManagerModules/neovim/langs/csharp/default.nix +++ b/homeManagerModules/neovim/langs/csharp/default.nix @@ -70,11 +70,10 @@ in { if (devShells['csharp'] == nil) then devShells['csharp'] = 1; - require('nix-develop').nix_develop({'${flakeEnv}#csharp'}); - startRoslyn(); - - os.execute('sleep 1') - vim.cmd[[e]]; -- reload to attach on current file + require('nix-develop').nix_develop({'${flakeEnv}#csharp'}, vim.schedule_wrap(function() + startRoslyn(); + vim.cmd[[e]]; -- reload to attach on current file + end)); end end, }); diff --git a/homeManagerModules/neovim/langs/default.nix b/homeManagerModules/neovim/langs/default.nix index 4df45eb8..c285c9e7 100644 --- a/homeManagerModules/neovim/langs/default.nix +++ b/homeManagerModules/neovim/langs/default.nix @@ -4,6 +4,9 @@ self: { pkgs, ... }: let + inherit (self.inputs) nix-develop-nvim-src; + inherit (self.lib.${pkgs.system}) mkVersion; + inherit (lib) fileContents mkBefore mkIf; cfg = config.programs.neovim; @@ -63,7 +66,6 @@ in { # lsp plugins nvim-lspconfig lsp-status-nvim - nix-develop-nvim # completion plugins cmp-buffer cmp-nvim-lsp @@ -73,6 +75,12 @@ in { ; }) ++ [ + # FIXME: defer inside plugin instead + (pkgs.vimPlugins.nix-develop-nvim.overrideAttrs (o: { + name = "vimplugin-${o.pname}-${mkVersion nix-develop-nvim-src}"; + src = nix-develop-nvim-src; + })) + { plugin = pkgs.vimPlugins.nvim-cmp; type = "lua"; diff --git a/homeManagerModules/neovim/langs/json/default.nix b/homeManagerModules/neovim/langs/json/default.nix index 3d4c3409..8fad537b 100644 --- a/homeManagerModules/neovim/langs/json/default.nix +++ b/homeManagerModules/neovim/langs/json/default.nix @@ -23,8 +23,9 @@ in { if (devShells['json'] == nil) then devShells['json'] = 1; - require('nix-develop').nix_develop({'${flakeEnv}#json'}); - vim.cmd[[LspStart]]; + require('nix-develop').nix_develop({'${flakeEnv}#json'}, vim.schedule_wrap(function() + vim.cmd[[LspStart]]; + end)); end end, }); diff --git a/homeManagerModules/neovim/langs/lua/default.nix b/homeManagerModules/neovim/langs/lua/default.nix index c8ea2368..1dc722c1 100644 --- a/homeManagerModules/neovim/langs/lua/default.nix +++ b/homeManagerModules/neovim/langs/lua/default.nix @@ -31,8 +31,9 @@ in { if (devShells['lua'] == nil) then devShells['lua'] = 1; - require('nix-develop').nix_develop({'${flakeEnv}#lua'}); - vim.cmd[[LspStart]]; + require('nix-develop').nix_develop({'${flakeEnv}#lua'}, vim.schedule_wrap(function() + vim.cmd[[LspStart]]; + end)); end end, }); diff --git a/homeManagerModules/neovim/langs/markdown/default.nix b/homeManagerModules/neovim/langs/markdown/default.nix index 3bde213c..a80b1390 100644 --- a/homeManagerModules/neovim/langs/markdown/default.nix +++ b/homeManagerModules/neovim/langs/markdown/default.nix @@ -35,8 +35,9 @@ in { if (devShells['markdown'] == nil) then devShells['markdown'] = 1; - require('nix-develop').nix_develop({'${flakeEnv}#markdown'}); - vim.cmd[[LspStart]]; + require('nix-develop').nix_develop({'${flakeEnv}#markdown'}, vim.schedule_wrap(function() + vim.cmd[[LspStart]]; + end)); end end, }); diff --git a/homeManagerModules/neovim/langs/rust/default.nix b/homeManagerModules/neovim/langs/rust/default.nix index b58b6648..917c2ea8 100644 --- a/homeManagerModules/neovim/langs/rust/default.nix +++ b/homeManagerModules/neovim/langs/rust/default.nix @@ -23,8 +23,9 @@ in { if (devShells['rust'] == nil) then devShells['rust'] = 1; - require('nix-develop').nix_develop({'${flakeEnv}#rust'}); - vim.cmd[[LspStart]]; + require('nix-develop').nix_develop({'${flakeEnv}#rust'}, vim.schedule_wrap(function() + vim.cmd[[LspStart]]; + end)); end end, }); diff --git a/homeManagerModules/neovim/langs/web/default.nix b/homeManagerModules/neovim/langs/web/default.nix index f9840d95..df9aa769 100644 --- a/homeManagerModules/neovim/langs/web/default.nix +++ b/homeManagerModules/neovim/langs/web/default.nix @@ -29,8 +29,9 @@ in { if (devShells['web'] == nil) then devShells['web'] = 1; - require('nix-develop').nix_develop({'${flakeEnv}#web'}); - vim.cmd[[LspStart]]; + require('nix-develop').nix_develop({'${flakeEnv}#web'}, vim.schedule_wrap(function() + vim.cmd[[LspStart]]; + end)); end end, }); @@ -44,8 +45,9 @@ in { if (devShells['web'] == nil) then devShells['web'] = 1; - require('nix-develop').nix_develop({'${flakeEnv}#web'}); - vim.cmd[[LspStart]]; + require('nix-develop').nix_develop({'${flakeEnv}#web'}, vim.schedule_wrap(function() + vim.cmd[[LspStart]]; + end)); end end, }); diff --git a/inputs/default.nix b/inputs/default.nix index 34473ff6..6d3438c6 100644 --- a/inputs/default.nix +++ b/inputs/default.nix @@ -281,6 +281,11 @@ let owner = "seblj"; repo = "roslyn.nvim"; } + { + name = "nix-develop-nvim-src"; + owner = "matt1432"; + repo = "nix-develop.nvim"; + } # Overlays & packages {