Skip to content

Commit

Permalink
fix(lazy-nvim): load plugins without adding to rtp
Browse files Browse the repository at this point in the history
this means plugins no longer autoload
  • Loading branch information
vdbe committed May 23, 2024
1 parent 458e461 commit e77e4db
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 60 deletions.
20 changes: 11 additions & 9 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath, })
if vim.g.nix_plugins_path == nil then
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath, })
end
end
vim.opt.rtp:prepend(lazypath)

Expand Down
14 changes: 2 additions & 12 deletions lua/nobody/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,11 @@ require("lazy").setup(
import = "nobody.plugins",
},
{ -- opts
defaults = {
pin = vim.g.nix_plugins_path ~= nil,
},
install = {
missing = vim.g.nix_plugins_path == nil,
missing = vim.g.is_nix == false,
},
change_detection = {
notify = false,
},
performance = {
rtp = {
paths = {
vim.g.nix_plugins_path -- Not needed when merging plugins with `symLinkJoin`
},
},
notify = vim.g.is_nix == false,
},
}
)
Expand Down
1 change: 1 addition & 0 deletions lua/nobody/plugins/colorscheme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ return {
{
"catppuccin/nvim",
name = "catppuccin",
dir = vim.g.nix_plugins_path,
lazy = false,
priority = 1000,
config = function(_, opts)
Expand Down
4 changes: 3 additions & 1 deletion lua/nobody/plugins/treesitter.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
return {
{
"tree-sitter/tree-sitter",
"nvim-treesitter/nvim-treesitter",
name = "nvim-treesitter",
version = false,
dir = vim.g.nix_plugins_path,
event = { "VeryLazy" },
lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline
init = function(plugin)
Expand Down
39 changes: 29 additions & 10 deletions nix/pkgs/neovim/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
...
}: let
inherit (lib) fileset;
inherit (lib.strings) getName optionalString;
inherit (lib.lists) findFirst filter;

config = pkgs.vimUtils.buildVimPlugin {
inherit version;
Expand All @@ -31,7 +33,13 @@
lazy-nvim
catppuccin-nvim
nvim-treesitter
];
] ++ extraPlugins;

lazyNvim = findFirst (plugin: (getName plugin) == "lazy-nvim") null plugins;
filteredPlugins = if lazyNvim == null then
plugins
else
filter (plugin: (getName plugin) != "lazy-nvim") plugins;

extraPackages' =
[
Expand All @@ -41,14 +49,21 @@
neovimConfig = pkgs.neovimUtils.makeNeovimConfig {
withPython3 = true;
withRuby = false;
plugins = [
(pkgs.symlinkJoin {
name = "neovim-plugins";
paths = [vimPlugins.nvim-treesitter.withAllGrammars] ++ plugins ++ [config] ++ extraPlugins;
})
];
plugins = [config];
# plugins = [
# (pkgs.symlinkJoin {
# name = "neovim-plugins";
# paths = plugins ++ [config] ++ extraPlugins;
# })
# ];
};

plugins' = pkgs.symlinkJoin {
name = "neovim-plugins";
paths = filteredPlugins;
};


neovim-unwrapped' = neovim-unwrapped.overrideAttrs (_: previousAttrs: {
treesitter-parsers = {};
preConfigure =
Expand All @@ -71,8 +86,12 @@ in
+ " "
+ ''--suffix PATH : "${lib.makeBinPath extraPackages'}"'';

luaRcContent = ''
vim.g.nix_plugins_path = '${config}'
require("nobody")
luaRcContent = optionalString (lazyNvim != null) ''
vim.opt.rtp:prepend("${lazyNvim}");
'' + ''
vim.g.is_nix = true
vim.g.nix_plugins_path = "${plugins'}"
require("nobody");
'';
})
2 changes: 0 additions & 2 deletions nix/pkgs/vimPlugins/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
or []
++ [
./patches/lazy-nvim/no-helptags.patch
./patches/lazy-nvim/loader__load.patch
./patches/lazy-nvim/loader_get_main.patch
];
});

Expand Down
13 changes: 0 additions & 13 deletions nix/pkgs/vimPlugins/patches/lazy-nvim/loader__load.patch

This file was deleted.

13 changes: 0 additions & 13 deletions nix/pkgs/vimPlugins/patches/lazy-nvim/loader_get_main.patch

This file was deleted.

15 changes: 15 additions & 0 deletions nix/sources/grammars/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@
"revision": "7b4275d077ae196fc0ce42ab3ad091574e3ec519",
"url": "https://api.github.com/repos/tree-sitter/tree-sitter-typescript/tarball/v0.21.1",
"hash": "1w113zbh322i39pr3cym4n4kvs33sg004mpca5mydh1nx19w06x1"
},
"tree-sitter-vimdoc": {
"type": "GitRelease",
"repository": {
"type": "GitHub",
"owner": "neovim",
"repo": "tree-sitter-vimdoc"
},
"pre_releases": false,
"version_upper_bound": null,
"release_prefix": null,
"version": "v2.5.1",
"revision": "241b5e2dd7bd8eb7f7ef84f14cbfdd26d474bda3",
"url": "https://api.github.com/repos/neovim/tree-sitter-vimdoc/tarball/v2.5.1",
"hash": "0br4i6s1f43nm2j61k3i2mfdr02hwnscnwm59lnbj00pdlv69sdv"
}
},
"version": 3
Expand Down

0 comments on commit e77e4db

Please sign in to comment.