File tree Expand file tree Collapse file tree 3 files changed +59
-1
lines changed
tests/test-sources/modules/performance Expand file tree Collapse file tree 3 files changed +59
-1
lines changed Original file line number Diff line number Diff line change 2121 plugins = lib . mkEnableOption "plugins" // {
2222 description = "Whether to byte compile lua plugins." ;
2323 } ;
24+ nvimRuntime = lib . mkEnableOption "nvimRuntime" // {
25+ description = "Whether to byte compile lua files in Nvim runtime." ;
26+ } ;
2427 } ;
2528
2629 combinePlugins = {
Original file line number Diff line number Diff line change 244244 ++ ( optional config . wrapRc ''--add-flags -u --add-flags "${ init } "'' )
245245 ) ;
246246
247- wrappedNeovim = pkgs . wrapNeovimUnstable config . package (
247+ package =
248+ if config . performance . byteCompileLua . enable && config . performance . byteCompileLua . nvimRuntime then
249+ # Using symlinkJoin to avoid rebuilding neovim
250+ pkgs . symlinkJoin {
251+ name = "neovim-byte-compiled-${ lib . getVersion config . package } " ;
252+ paths = [ config . package ] ;
253+ # Required attributes from original neovim package
254+ inherit ( config . package ) lua ;
255+ nativeBuildInputs = [ helpers . byteCompileLuaHook ] ;
256+ postBuild = ''
257+ # Replace Nvim's binary symlink with a regular file,
258+ # or Nvim will use original runtime directory
259+ rm $out/bin/nvim
260+ cp ${ config . package } /bin/nvim $out/bin/nvim
261+
262+ runHook postFixup
263+ '' ;
264+ }
265+ else
266+ config . package ;
267+
268+ wrappedNeovim = pkgs . wrapNeovimUnstable package (
248269 neovimConfig
249270 // {
250271 wrapperArgs = lib . escapeShellArgs neovimConfig . wrapperArgs + " " + extraWrapperArgs ;
Original file line number Diff line number Diff line change 182182 test_rtp_file("plugin/test2.lua", false)
183183 '' ;
184184 } ;
185+
186+ nvim-runtime = {
187+ performance . byteCompileLua = {
188+ enable = true ;
189+ nvimRuntime = true ;
190+ } ;
191+
192+ extraPlugins = [
193+ # Python 3 dependencies
194+ ( pkgs . vimPlugins . nvim-lspconfig . overrideAttrs { passthru . python3Dependencies = ps : [ ps . pyyaml ] ; } )
195+ ] ;
196+
197+ extraConfigLuaPost = ''
198+ ${ isByteCompiledFun }
199+
200+ -- vim namespace is working
201+ vim.opt.tabstop = 2
202+ vim.api.nvim_get_runtime_file("init.lua", false)
203+ vim.lsp.get_clients()
204+ vim.treesitter.language.get_filetypes("nix")
205+ vim.iter({})
206+
207+ test_rtp_file("lua/vim/lsp.lua", true)
208+ test_rtp_file("lua/vim/iter.lua", true)
209+ test_rtp_file("lua/vim/treesitter/query.lua", true)
210+ test_rtp_file("lua/vim/lsp/buf.lua", true)
211+ test_rtp_file("plugin/editorconfig.lua", true)
212+ test_rtp_file("plugin/tutor.vim", false)
213+ test_rtp_file("ftplugin/vim.vim", false)
214+
215+ -- Python3 packages are importable
216+ vim.cmd.py3("import yaml")
217+ '' ;
218+ } ;
185219}
186220//
187221 # Two equal tests, one with combinePlugins.enable = true
You can’t perform that action at this time.
0 commit comments