···57 # our config
58 userConfig,
5960+ # PERF: clean runtime path so it only contains explicit runtime directories
61+ # - removes directories from homedir as well as nix data directories
62+ # - this means some programs that ship extra nvim data files need to be
63+ # explicitly added to the rtp with a package override
64+ cleanRuntimePath ? false,
65+ additionalRuntimePaths ? [ ],
66+67 # other customisation
68 aliases ? [ ],
69 keepDesktopFiles ? false,
···122 package.cpath = "${luaLib.genLuaCPathAbsStr luaEnv};$LUA_CPATH" .. package.cpath
123 vim.env.PATH = vim.env.PATH .. ":${makeBinPath extraPackages}"
124 vim.g.snippets_path = "$out/pack/${pname}/start/init-plugin/snippets"
125+ ''
126+ + (
127+ if cleanRuntimePath then
128+ (
129+ let
130+ # if the runtime path is cleaned, it will be faster to leave the nvim
131+ # base paths at the start since most startup dependencies will be
132+ # found there.
133+ # $out will be put *before* the additionalRuntimePaths to replicate the behavior of `:prepend('$out')`.
134+ runtimePaths = [
135+ "${basePackage}/lib/nvim"
136+ "${basePackage}/share/nvim/runtime"
137+ "$out"
138+ ]
139+ ++ additionalRuntimePaths;
140+ rtp = builtins.concatStringsSep "," runtimePaths;
141+ in
142+ ''
143+ vim.o.runtimepath = "${rtp}"
144+ vim.o.packpath = "${rtp}"
145+ ''
146+ )
147+ else
148+ ''
149+ vim.opt.runtimepath:prepend('$out')
150+ vim.opt.packpath:prepend('$out')
151+ ''
152+ )
153+ + ''
154 vim.loader.enable()
155156 ${lib.concatMapAttrsStringSep "\n" (provider: enabled: ''