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 4444 plugins = lib . mkEnableOption "plugins" // {
4545 description = "Whether to byte compile lua plugins." ;
4646 } ;
47+ nvimRuntime = lib . mkEnableOption "nvimRuntime" // {
48+ description = "Whether to byte compile lua files in Nvim runtime." ;
49+ } ;
4750 } ;
4851 } ;
4952
Original file line number Diff line number Diff line change 261261 ++ ( optional config . wrapRc ''--add-flags -u --add-flags "${ init } "'' )
262262 ) ;
263263
264- wrappedNeovim = pkgs . wrapNeovimUnstable config . package (
264+ package =
265+ if config . performance . byteCompileLua . enable && config . performance . byteCompileLua . nvimRuntime then
266+ # Using symlinkJoin to avoid rebuilding neovim
267+ pkgs . symlinkJoin {
268+ name = "neovim-byte-compiled-${ lib . getVersion config . package } " ;
269+ paths = [ config . package ] ;
270+ # Required attributes from original neovim package
271+ inherit ( config . package ) lua ;
272+ nativeBuildInputs = [ helpers . byteCompileLuaHook ] ;
273+ postBuild = ''
274+ # Replace Nvim's binary symlink with a regular file,
275+ # or Nvim will use original runtime directory
276+ rm $out/bin/nvim
277+ cp ${ config . package } /bin/nvim $out/bin/nvim
278+
279+ runHook postFixup
280+ '' ;
281+ }
282+ else
283+ config . package ;
284+
285+ wrappedNeovim = pkgs . wrapNeovimUnstable package (
265286 neovimConfig
266287 // {
267288 wrapperArgs = lib . escapeShellArgs neovimConfig . wrapperArgs + " " + extraWrapperArgs ;
Original file line number Diff line number Diff line change 140140 test_rtp_file("plugin/test2.lua", false)
141141 '' ;
142142 } ;
143+
144+ nvim-runtime = {
145+ performance . byteCompileLua = {
146+ enable = true ;
147+ nvimRuntime = true ;
148+ } ;
149+
150+ extraPlugins = [
151+ # Python 3 dependencies
152+ ( pkgs . vimPlugins . nvim-lspconfig . overrideAttrs { passthru . python3Dependencies = ps : [ ps . pyyaml ] ; } )
153+ ] ;
154+
155+ extraConfigLuaPost = ''
156+ ${ isByteCompiledFun }
157+
158+ -- vim namespace is working
159+ vim.opt.tabstop = 2
160+ vim.api.nvim_get_runtime_file("init.lua", false)
161+ vim.lsp.get_clients()
162+ vim.treesitter.language.get_filetypes("nix")
163+ vim.iter({})
164+
165+ test_rtp_file("lua/vim/lsp.lua", true)
166+ test_rtp_file("lua/vim/iter.lua", true)
167+ test_rtp_file("lua/vim/treesitter/query.lua", true)
168+ test_rtp_file("lua/vim/lsp/buf.lua", true)
169+ test_rtp_file("plugin/editorconfig.lua", true)
170+ test_rtp_file("plugin/tutor.vim", false)
171+ test_rtp_file("ftplugin/vim.vim", false)
172+
173+ -- Python3 packages are importable
174+ vim.cmd.py3("import yaml")
175+ '' ;
176+ } ;
143177}
144178//
145179 # Two equal tests, one with combinePlugins.enable = true
You can’t perform that action at this time.
0 commit comments