benlubas / molten-nvim

A neovim plugin for interactively running code with the jupyter kernel. Fork of magma-nvim with improvements in image rendering, performance, and more
GNU General Public License v3.0
531 stars 30 forks source link

[Help] Cannot configure Molten #203

Closed Ibrahim-teyim closed 3 months ago

Ibrahim-teyim commented 3 months ago

Setting up the plugin image.nvim produced the following error:

image.nvim: magick rock not found, please install it and restart your editor. Error: "module 'magick' not found

Also using Quarto complains about code runner not being initialised

Finally Molten cannot find cells.

I am new to neovim and using lazy.nvim. Below are my plugin.lua files.

molten-nvim.lua:

return {
  {
    "benlubas/molten-nvim",
    version = "^1.0.0", -- use version <2.0.0 to avoid breaking changes
    build = ":UpdateRemotePlugins",
    init = function()
      -- Configuration options
      vim.g.molten_output_win_max_height = 12
      vim.g.molten_auto_open_output = false
      vim.g.molten_image_provider = "image.nvim"
      vim.g.molten_wrap_output = true
      vim.g.molten_virt_text_output = true
      vim.g.molten_virt_lines_off_by_1 = true

      -- Key mappings
      vim.keymap.set("n", "<leader>mi", ":MoltenInit<CR>", { silent = true, desc = "Initialize Molten" })
      vim.keymap.set(
        "n",
        "<leader>me",
        ":MoltenEvaluateOperator<CR>",
        { silent = true, desc = "Molten run operator selection" }
      )
      vim.keymap.set("n", "<leader>rl", ":MoltenEvaluateLine<CR>", { silent = true, desc = "Molten evaluate line" })
      vim.keymap.set(
        "n",
        "<leader>rr",
        ":MoltenReevaluateCell<CR>",
        { silent = true, desc = "Molten re-evaluate cell" }
      )
      vim.keymap.set(
        "v",
        "<leader>r",
        ":<C-u>MoltenEvaluateVisual<CR>gv",
        { silent = true, desc = "Molten evaluate visual selection" }
      )
      vim.keymap.set(
        "n",
        "<leader>mo",
        ":noautocmd MoltenEnterOutput<CR>",
        { silent = true, desc = "Molten enter output" }
      )
    end,
  },
  {
    -- see the image.nvim readme for more information about configuring this plugin
    "3rd/image.nvim",
    opts = {
      backend = "kitty", -- whatever backend you would like to use
      max_width = 100,
      max_height = 12,
      max_height_window_percentage = math.huge,
      max_width_window_percentage = math.huge,
      window_overlap_clear_enabled = true, -- toggles images when windows are overlapped
      window_overlap_clear_ft_ignore = { "cmp_menu", "cmp_docs", "" },
    },
  },
}

jupytext.lua:

  return {
    "GCBallesteros/jupytext.nvim",
    config = function()
      require("jupytext").setup({
        custom_language_formatting = {
          python = {
            extension = "md",
            style = "markdown",
            force_ft = "markdown", -- you can set whatever filetype you want here
          },
        },
      })
    end,
    -- Depending on your nvim distro or config you may need to make the loading not lazy
    lazy = false,
}

quarto.lua

return {
  {
    "jmbuhr/otter.nvim",
    lazy = false,
  },
  {

    "quarto-dev/quarto-nvim", -- Replace with the correct repository if different
    ft = { "quarto", "markdown" },
    config = function()
      local runner = require("quarto.runner")

      -- Set up key mappings for quarto.runner
      vim.keymap.set("n", "<leader>rc", runner.run_cell, { desc = "run cell", silent = true })
      vim.keymap.set("n", "<leader>ra", runner.run_above, { desc = "run cell and above", silent = true })
      vim.keymap.set("n", "<leader>rA", runner.run_all, { desc = "run all cells", silent = true })
      -- vim.keymap.set("n", "<leader>rl", runner.run_line, { desc = "run line", silent = true })
      vim.keymap.set("v", "<leader>r", runner.run_range, { desc = "run visual range", silent = true })
      vim.keymap.set("n", "<leader>RA", function()
        runner.run_all(true)
      end, { desc = "run all cells of all languages", silent = true })
    end,
    lazy = false, -- Ensure the plugin is loaded immediately, or set to true if you prefer lazy loading
  },
}
benlubas commented 3 months ago

This is an image.nvim error. Please refer to the image.nvim README. Specifically this part

Ibrahim-teyim commented 3 months ago

This is an image.nvim error. Please refer to the image.nvim README. Specifically this part

The image issue is fixed now, thank you for your help, I specifically used this link..

Could you help with the other issues? P.S running line by line works but running as a cell does not work.

benlubas commented 3 months ago

Also using Quarto complains about code runner not being initialised

You need to run :QuatoActivate probably

Finally Molten cannot find cells.

I assume you're using :MoltenEvaluateCell when a cell doesn't exist yet. Molten cell != markdown/quarto cell.

Molten cells are defined in the molten readme