Closed xvrdm closed 6 months ago
No, there is no require
for this plugin.
However, you need to properly set up the dependencies.
:UpdateRemoteDependencies
should be recognized as a command. However, it fails on my side, saying that it misses the jupyter_client
module.
Thanks a lot for looking at it so swiftly.
jupyter
is indeed a dependency of molten
.
However, even when do create a temp shell that has jupyter, :UpdateRemoteDependencies
continues to fail.
# in my `nix flake init --template github:nix-community/nixvim` dir
nix-shell -p "python3.withPackages(ps: with ps; [ numpy pandas jupyter ])"
nix run .#
Obviously, feel free to tell me if this is outside the scope of nixnvim support. I just wasn't sure if :UpdateRemoteDependencies
was even supported or if it breaks nix paradigms.
I think we need to add it to the extraPythonPackages of nixvim
That's exactly what I was looking at. Here is the molten example for nixos: https://github.com/benlubas/molten-nvim/blob/main/docs/NixOS.md
Using home-manager, they have this part:
...
extraPython3Packages = ps: with ps; [
# ... other python packages
pynvim
jupyter-client
cairosvg # for image rendering
pnglatex # for image rendering
plotly # for image rendering
pyperclip
];
...
Is there a similar user-defined argument in nixvim?
This helped a lot to go forward.
Now I have:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
python311
quarto
];
LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
}
config/default.nix
{ self
, pkgs
, ...
}: {
# Import all your configuration modules here
imports = [
./bufferline.nix
];
extraPython3Packages = p: with p; [ jupyter-client pynvim cairosvg pnglatex plotly pyperclip ];
extraPlugins = [
{ plugin = pkgs.vimPlugins.quarto-nvim; }
{ plugin = pkgs.vimPlugins.otter-nvim; }
{
plugin = pkgs.vimUtils.buildVimPlugin {
name = "jupytext-nvim";
src = pkgs.fetchFromGitHub {
owner = "GCBallesteros";
repo = "jupytext.nvim";
rev = "68fddf28119dbaddfaea6b71f3d6aa1e081afb93";
sha256 = "x5emW+qfUTUDR72B9QdDgVdrb8wGH9D7AdtRrQm80sI=";
};
};
}
];
extraConfigLua = ''
require("jupytext").setup({
style = "markdown",
output_extension = "md",
force_ft = "markdown",
})
'';
plugins.lsp = {
enable = true;
servers = {
tsserver.enable = true;
lua-ls.enable = true;
rnix-lsp.enable = true;
pyright.enable = true;
};
};
plugins.molten = {
enable = true;
};
}
With these three parts, I can :MoltenInit
and run code in notebook cells 🥳
The current blocker is that I could only make this works with the line:
LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
in shell.nix
, which helps pass :UpdateRemotePlugins
but also seem to break the pyright
lsp. Without it I have normal LSP support, with it the LSP fails to attach to the buffer with the :LspLog
error message:
/lib/libstdc++.so.6: version `GLIBXX_3.4.32' not found
I also had the same problem, where molten
would never load by just enabling it. I fixed it by fetching the plugin manually from github and passing the required dependencies through to it.
plugins.molten = {
enable = true;
package = pkgs.vimUtils.buildVimPlugin {
pname = "molten-nvim";
version = "2024-02-23";
src = pkgs.fetchFromGitHub {
owner = "benlubas";
repo = "molten-nvim";
rev = "8346bba69e0de96278dad2038e9be74605908b7d";
# sha256 = lib.fakeSha256;
sha256 = "08f3zxzka43f87fks56594476h57yq01x7a1zdsn4acc278xg1nb";
};
passthru.python3Dependencies = ps:
with ps; [
pynvim
jupyter-client
cairosvg
ipython
nbformat
];
meta.homepage = "https://github.com/benlubas/molten-nvim/";
};
};
Maybe the original package in nixpkgs
can also be overwritten with overrideAttrs
but the above code worked for me, so i did not experiment further.
Thank you for sharing @Charging1948 I tried it but for me it did not change the situation.
LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
in shell.nix
(which breaks pyright LSP): molten
is responsive and I get results below cells.LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
in shell.nix
(which fixes pyright LSP): the entire nvim becomes extremely sluggish after :MoltenInit
and I get "on hold" below cells.@xvrdm Very Interesting. I do not override the LD_LIBRARY_PATH and it just works.
My config is a mess, but maybe it helps: https://github.com/Charging1948/neovim
@Charging1948 I actually tried your config after your first config, very impressive, but a bit overwhelming for my level of understanding. Definitely an inspiration.
I put my tiny attempt here: https://github.com/xvrdm/nixvim_sandbox
@xvrdm I tried to replicate the behavior you are experiencing, but i was able to use molten without problems:
The only thing i have added was the ipykernel, because it was missing.
At this point i dont know what the problem could be, sorry.
Thanks a lot for trying. So you manage to have both molten working and LSP support in normal python files 🤔 ? I wonder if it could be because I am trying on an arm vm. I will try it on another architecture.
In the end, I am not sure about what we could/should do at the nixvim level.
Should we add the few recommended packages to extraPython3Packages
? What do you think @traxys ?
@GaetanLepage, do you mean that they could have been automatically when a user enable molten
?
From a user perspective, I think it makes sense that I have to add these python packages via the extrapython3packages
argument @traxys pointed me to. Except if for other packages you tend to do it for the user (but I guess it would be quite challenging to keep track of).
I think we should add the required package to the extraPython3Packages
molten
23.11
Description
I am trying to use the
molten
package. Even though I enabled the package (found in the doc), I don't get any:Molten*
command in nvim. Do I need torequire
it manually?I started from
nix flake init --template github:nix-community/nixvim
and only changedconfig/default.nix
. The other changes (colorschemes, lualine, lsp) were correctly pulled/activated.Thanks for the awesome project!
Minimal, Reproducible Example (MRE)
in
config/default.nix