-
Notifications
You must be signed in to change notification settings - Fork 15
Description
I've been struggling for quite a bit now to install this plugin on my nixvim config, mostly due to my limited experience with both lua and nix. I have nixvim installed from flake into my home manager configuration and I've been trying to install this plugin with pkgs.vimUtils.buildVimPlugin and programs.nixvim.extraPlugins.
Relevant snippet:
{ pkgs, inputs, ... }:
let
mdmath = pkgs.vimUtils.buildVimPlugin {
pname = "mdmath";
version = "latest";
src = builtins.fetchGit {
url = "https://github.com/Thiago4532/mdmath.nvim";
ref = "main";
rev = "699acb27fd34bfdf92a43ce0abdd17f0c7a948fe";
};
meta.homepage = "https://github.com/Thiago4532/mdmath.nvim";
};
in
{
programs.nixvim = {
enable = true;
extraPlugins = [
mdmath
];
};
}This results in build failing with following logs:
Click to expand
structuredAttrs is enabled
Sourcing vim-gen-doc-hook
Sourcing vim-command-check-hook.sh
Using vimCommandCheckHook
Sourcing neovim-require-check-hook.sh
Using neovimRequireCheckHook
Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/8spf5yw740i2zbf2x105nmq4xbi6lbbx-source
source root is source
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: configurePhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: buildPhase
@nix { "action": "setPhase", "phase": "buildPhase" }
Running phase: checkPhase
@nix { "action": "setPhase", "phase": "checkPhase" }
no Makefile or custom checkPhase, doing nothing
Running phase: installPhase
@nix { "action": "setPhase", "phase": "installPhase" }
Running phase: fixupPhase
@nix { "action": "setPhase", "phase": "fixupPhase" }
Executing vimPluginGenTags
No docs available for /nix/store/9ild12kdy14jgsvi80j0ywmh8ih6pf6n-vimplugin-mdmath-latest/.
Finished executing vimPluginGenTags
shrinking RPATHs of ELF executables and libraries in /nix/store/9ild12kdy14jgsvi80j0ywmh8ih6pf6n-vimplugin-mdmath-latest
checking for references to /build/ in /nix/store/9ild12kdy14jgsvi80j0ywmh8ih6pf6n-vimplugin-mdmath-latest...
patching script interpreter paths in /nix/store/9ild12kdy14jgsvi80j0ywmh8ih6pf6n-vimplugin-mdmath-latest
Running phase: vimCommandCheckHook
@nix { "action": "setPhase", "phase": "vimCommandCheckHook" }
Executing vimCommandCheckHook
Running phase: neovimRequireCheckHook
@nix { "action": "setPhase", "phase": "neovimRequireCheckHook" }
Executing neovimRequireCheckHook
nvimRequireCheck is empty; entering discovery mode
Running module discovery in source directory...
build.lua
lua/mdmath/Image/diacritics.lua
lua/mdmath/Equation.lua
lua/mdmath/config.lua
lua/mdmath/nvim.lua
lua/mdmath/terminfo.lua
lua/mdmath/init.lua
lua/mdmath/tracker.lua
lua/mdmath/build.lua
lua/mdmath/marks.lua
lua/mdmath/Image.lua
lua/mdmath/highlight-colors.lua
lua/mdmath/terminfo/_system.lua
lua/mdmath/overlay.lua
lua/mdmath/util.lua
lua/mdmath/Processor.lua
Discovered modules: build mdmath.Image.diacritics mdmath.Equation mdmath.config mdmath.nvim mdmath.terminfo mdmath mdmath.tracker mdmath.build mdmath.marks mdmath.Image mdmath.highlight-colors mdmath.terminfo._system mdmath.overlay mdmath.util mdmath.Processor
Starting require checks
Attempting to require module: build
Error detected while processing pre-vimrc command line:
E5108: Error executing lua ...wmh8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/build.lua:94: attempt to yield across C-call boundary
stack traceback:
[C]: in function 'yield'
...wmh8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/build.lua:94: in function <...wmh8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/build.lua:72>
[C]: in function 'require'
[string ":lua"]:1: in main chunk
Entering Ex mode. Type "visual" to go to Normal mode.
:Failed to require module: build
Attempting to require module: mdmath.Image.diacritics
Entering Ex mode. Type "visual" to go to Normal mode.
:Successfully required module: mdmath.Image.diacritics
Attempting to require module: mdmath.Equation
Error detected while processing pre-vimrc command line:
E5108: Error executing lua ...mh8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/config.lua:38: Attempt to access mdmath.nvim options before configuring it. (Make sure to call `require'mdmath'.setup()` before using any module)
stack traceback:
[C]: in function 'error'
...mh8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/config.lua:38: in function '__index'
...wmh8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/marks.lua:8: in main chunk
[C]: in function 'require'
...8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/Equation.lua:4: in main chunk
[C]: in function 'require'
[string ":lua"]:1: in main chunk
Entering Ex mode. Type "visual" to go to Normal mode.
:Failed to require module: mdmath.Equation
Attempting to require module: mdmath.config
Entering Ex mode. Type "visual" to go to Normal mode.
:Successfully required module: mdmath.config
Attempting to require module: mdmath.nvim
Entering Ex mode. Type "visual" to go to Normal mode.
:Successfully required module: mdmath.nvim
Attempting to require module: mdmath.terminfo
Entering Ex mode. Type "visual" to go to Normal mode.
:Successfully required module: mdmath.terminfo
Attempting to require module: mdmath
Entering Ex mode. Type "visual" to go to Normal mode.
:Successfully required module: mdmath
Attempting to require module: mdmath.tracker
Entering Ex mode. Type "visual" to go to Normal mode.
:Successfully required module: mdmath.tracker
Attempting to require module: mdmath.build
Entering Ex mode. Type "visual" to go to Normal mode.
:Successfully required module: mdmath.build
Attempting to require module: mdmath.marks
Error detected while processing pre-vimrc command line:
E5108: Error executing lua ...mh8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/config.lua:38: Attempt to access mdmath.nvim options before configuring it. (Make sure to call `require'mdmath'.setup()` before using any module)
stack traceback:
[C]: in function 'error'
...mh8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/config.lua:38: in function '__index'
...wmh8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/marks.lua:8: in main chunk
[C]: in function 'require'
[string ":lua"]:1: in main chunk
Entering Ex mode. Type "visual" to go to Normal mode.
:Failed to require module: mdmath.marks
Attempting to require module: mdmath.Image
Entering Ex mode. Type "visual" to go to Normal mode.
:Successfully required module: mdmath.Image
Attempting to require module: mdmath.highlight-colors
Entering Ex mode. Type "visual" to go to Normal mode.
:Successfully required module: mdmath.highlight-colors
Attempting to require module: mdmath.terminfo._system
Entering Ex mode. Type "visual" to go to Normal mode.
:Successfully required module: mdmath.terminfo._system
Attempting to require module: mdmath.overlay
Error detected while processing pre-vimrc command line:
E5108: Error executing lua ...mh8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/config.lua:38: Attempt to access mdmath.nvim options before configuring it. (Make sure to call `require'mdmath'.setup()` before using any module)
stack traceback:
[C]: in function 'error'
...mh8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/config.lua:38: in function '__index'
...wmh8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/marks.lua:8: in main chunk
[C]: in function 'require'
...8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/Equation.lua:4: in main chunk
[C]: in function 'require'
...h8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/overlay.lua:5: in main chunk
[C]: in function 'require'
[string ":lua"]:1: in main chunk
Entering Ex mode. Type "visual" to go to Normal mode.
:Failed to require module: mdmath.overlay
Attempting to require module: mdmath.util
Entering Ex mode. Type "visual" to go to Normal mode.
:Successfully required module: mdmath.util
Attempting to require module: mdmath.Processor
Error detected while processing pre-vimrc command line:
E5108: Error executing lua ...mh8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/config.lua:38: Attempt to access mdmath.nvim options before configuring it. (Make sure to call `require'mdmath'.setup()` before using any module)
stack traceback:
[C]: in function 'error'
...mh8ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/config.lua:38: in function '__index'
...ih6pf6n-vimplugin-mdmath-latest/lua/mdmath/Processor.lua:4: in main chunk
[C]: in function 'require'
[string ":lua"]:1: in main chunk
Entering Ex mode. Type "visual" to go to Normal mode.
:Failed to require module: mdmath.Processor
======================================================
�[0;32mRequire check succeeded for the following modules:�[0m
�[0;32m- mdmath.Image.diacritics�[0m
�[0;32m- mdmath.config�[0m
�[0;32m- mdmath.nvim�[0m
�[0;32m- mdmath.terminfo�[0m
�[0;32m- mdmath�[0m
�[0;32m- mdmath.tracker�[0m
�[0;32m- mdmath.build�[0m
�[0;32m- mdmath.Image�[0m
�[0;32m- mdmath.highlight-colors�[0m
�[0;32m- mdmath.terminfo._system�[0m
�[0;32m- mdmath.util�[0m
All lua modules were checked.
�[0;31mRequire check failed for the following modules:�[0m
�[0;31m- build�[0m
�[0;31m- mdmath.Equation�[0m
�[0;31m- mdmath.marks�[0m
�[0;31m- mdmath.overlay�[0m
�[0;31m- mdmath.Processor�[0m
�[0;31mCheckout https://nixos.org/manual/nixpkgs/unstable/#testing-neovim-plugins-neovim-require-check�[0m
======================================================
It seems like during the installation/tests the require"mdmath".setup() doesn't run and tests try to access the config variables that are not set. This means it could theoretically be fixed after the installation by running setup() manually.
Build failing can be worked around by adding doCheck = false; to buildVimPlugin parameters like so:
mdmath = pkgs.vimUtils.buildVimPlugin {
pname = "mdmath";
version = "latest";
src = builtins.fetchGit {
url = "https://github.com/Thiago4532/mdmath.nvim";
ref = "main";
rev = "699acb27fd34bfdf92a43ce0abdd17f0c7a948fe";
};
meta.homepage = "https://github.com/Thiago4532/mdmath.nvim";
doCheck = false;
};This skips the checks and the build finishes successfully, but the plugin still does not function correctly.
When opening an md file an error occurs:
Error detected while processing VimEnter Autocommands for "*":
Error executing lua callback: ...k/myNeovimPackages/start/mdmath/lua/mdmath/Processor.lua:32: failed to spawn LatexProcessor: ENOENT: no such file or director
y
stack traceback:
[C]: in function 'error'
...k/myNeovimPackages/start/mdmath/lua/mdmath/Processor.lua:32: in function '_assert'
...k/myNeovimPackages/start/mdmath/lua/mdmath/Processor.lua:212: in function '_init'
...r/pack/myNeovimPackages/start/mdmath/lua/mdmath/util.lua:13: in function 'new'
...k/myNeovimPackages/start/mdmath/lua/mdmath/Processor.lua:281: in function 'from_bufnr'
...ck/myNeovimPackages/start/mdmath/lua/mdmath/Equation.lua:163: in function '_init'
...r/pack/myNeovimPackages/start/mdmath/lua/mdmath/util.lua:13: in function 'new'
...ack/myNeovimPackages/start/mdmath/lua/mdmath/overlay.lua:145: in function 'process_equation'
...ack/myNeovimPackages/start/mdmath/lua/mdmath/overlay.lua:158: in function 'fn'
...3/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:650: in function 'for_each_tree'
...ack/myNeovimPackages/start/mdmath/lua/mdmath/overlay.lua:161: in function 'parse'
...ack/myNeovimPackages/start/mdmath/lua/mdmath/overlay.lua:112: in function 'parse_view'
...ack/myNeovimPackages/start/mdmath/lua/mdmath/overlay.lua:58: in function '_init'
...r/pack/myNeovimPackages/start/mdmath/lua/mdmath/util.lua:13: in function 'new'
...ack/myNeovimPackages/start/mdmath/lua/mdmath/overlay.lua:182: in function 'create_buffer'
...ack/myNeovimPackages/start/mdmath/lua/mdmath/overlay.lua:195: in function 'enable'
...r/pack/myNeovimPackages/start/mdmath/lua/mdmath/init.lua:56: in function 'enable'
...r/pack/myNeovimPackages/start/mdmath/lua/mdmath/init.lua:47: in function 'setup'
...aad00n37ydbrxf-vimplugin-mdmath-latest/plugin/mdmath.lua:8: in function <...aad00n37ydbrxf-vimplugin-mdmath-latest/plugin/mdmath.lua:7>
I believe this is because of the plugin not having access to the dependencies (node, npm, etc.)
I tried running nvim in a nix-shell with node installed:
$ nix-shell -p nodejs
$ nvim file.mdAnd it resulted in a different error about missing mathjax:
Error executing callback:
...k/myNeovimPackages/start/mdmath/lua/mdmath/Processor.lua:209: processor runtime error: node:internal/modules/package_json_reader:256
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'mathjax' imported from /nix/store/gvrxr3gfzca52bcavxaad00n37ydbrxf-vimplugin-mdmath-latest/mdmath-js/src/pr
ocessor.js
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:256:9)
at packageResolve (node:internal/modules/esm/resolve:768:81)
at moduleResolve (node:internal/modules/esm/resolve:854:18)
at defaultResolve (node:internal/modules/esm/resolve:984:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:780:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:704:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:687:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:305:38)
at ModuleJob._link (node:internal/modules/esm/module_job:175:49) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v22.17.0
stack traceback:
[C]: in function 'error'
...k/myNeovimPackages/start/mdmath/lua/mdmath/Processor.lua:209: in function <...k/myNeovimPackages/start/mdmath/lua/mdmath/Processor.lua:200>
I felt like I was getting close and added mathjax to the shell:
$ nix-shell -p nodejs nodePackages.mathjax
$ nvim file.mdBut this is where my luck ended since the plugin was not able to find the library and threw the same error, although this time with an import suggestion:
Error executing callback:
...k/myNeovimPackages/start/mdmath/lua/mdmath/Processor.lua:209: processor runtime error: node:internal/modules/run_main:123
triggerUncaughtException(
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'mathjax' imported from /nix/store/gvrxr3gfzca52bcavxaad00n37ydbrxf-vimplugin-mdmath-latest/mdmath-js/src/pr
ocessor.js
Did you mean to import "mathjax/es5/node-main.js"?
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:256:9)
at packageResolve (node:internal/modules/esm/resolve:768:81)
at moduleResolve (node:internal/modules/esm/resolve:854:18)
at defaultResolve (node:internal/modules/esm/resolve:984:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:780:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:704:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:687:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:305:38)
at ModuleJob._link (node:internal/modules/esm/module_job:175:49) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v22.17.0
stack traceback:
[C]: in function 'error'
...k/myNeovimPackages/start/mdmath/lua/mdmath/Processor.lua:209: in function <...k/myNeovimPackages/start/mdmath/lua/mdmath/Processor.lua:200>
I am not sure if changing the import path to mathjax/es5/node-main.js would help in this case or what this path is even relatieve to.
After the file is opened :lua require"mdmath".setup() runs without errors and allows access to :MdMath commands, but :MdMath enable and disable do nothing and :MdMath build results in an error of npm being unable to modify the read-only nix store:
[mdmath]: Build failed: npm error code ENOENT
npm error syscall mkdir
npm error path /nix/store/gvrxr3gfzca52bcavxaad00n37ydbrxf-vimplugin-mdmath-latest/mdmath-js/node_modules
npm error errno -2
npm error enoent ENOENT: no such file or directory, mkdir '/nix/store/gvrxr3gfzca52bcavxaad00n37ydbrxf-vimplugin-mdmath-latest/mdmath-js/node_modules'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
npm error A complete log of this run can be found in: /home/user/.npm/_logs/2025-08-27T16_02_55_930Z-debug-0.log
I tried adding
buildInputs = with pkgs; [ nodejs, nodePackages.npm, nodePackages.mathjax ];to buildVimPlugin, didn't help.
I attempted adding a custom buildPhase to buildVimPlugin, something along the lines of:
cd $out/mdmath-js
npm installor
cp $src/* $out/*
cd $out/mdmath-js
npm installbut both resulted in npm not being able to create node_modules.
Also I was not able to figure out how to specify runtime dependencies in derivations, docs cover only build time.
At this point I gave up.
It would be a lot easier if this plugin had either full nixvim support or a flake with either an overlay or a build derivation.
I would also be very grateful if someone was able to make this work with the extraPlugins approach.
Here's the md file I used for testing:
Thank you in advance :)