Coder Social home page Coder Social logo

Comments (15)

GaetanLepage avatar GaetanLepage commented on June 26, 2024

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.

from nixvim.

xvrdm avatar xvrdm commented on June 26, 2024

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.

from nixvim.

traxys avatar traxys commented on June 26, 2024

I think we need to add it to the extraPythonPackages of nixvim

from nixvim.

xvrdm avatar xvrdm commented on June 26, 2024

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?

from nixvim.

traxys avatar traxys commented on June 26, 2024

We have this option: https://nix-community.github.io/nixvim/NeovimOptions/index.html?highlight=python#extrapython3packages

from nixvim.

xvrdm avatar xvrdm commented on June 26, 2024

This helped a lot to go forward.

Now I have:

  • a tiny shell.nix for the environment (to be replaced by a flake)
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  nativeBuildInputs = with pkgs; [
    python311
    quarto
  ];

  LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
}
  • Some molten python package dependency for nvim declared in the nixvim 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;
  };

}
  • The jupiter kernel and jupytext cli installed in a venv

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

from nixvim.

Charging1948 avatar Charging1948 commented on June 26, 2024

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.

from nixvim.

xvrdm avatar xvrdm commented on June 26, 2024

Thank you for sharing @Charging1948
I tried it but for me it did not change the situation.

  • With 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.
Screenshot 2024-03-06 at 13 13 17
  • Without 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.
Screenshot 2024-03-06 at 13 11 23

from nixvim.

Charging1948 avatar Charging1948 commented on June 26, 2024

@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

from nixvim.

xvrdm avatar xvrdm commented on June 26, 2024

@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

from nixvim.

Charging1948 avatar Charging1948 commented on June 26, 2024

@xvrdm I tried to replicate the behavior you are experiencing, but i was able to use molten without problems:
image

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.

from nixvim.

xvrdm avatar xvrdm commented on June 26, 2024

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.

from nixvim.

GaetanLepage avatar GaetanLepage commented on June 26, 2024

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 ?

from nixvim.

xvrdm avatar xvrdm commented on June 26, 2024

@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).

from nixvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.