nvim-neorg / neorg

Modernity meets insane extensibility. The future of organizing your life in Neovim.
GNU General Public License v3.0
6.1k stars 205 forks source link

core.latex.renderer: dependency core.integrations.image not satisfied (lazy.nvim) #1398

Open fractal-robot opened 2 months ago

fractal-robot commented 2 months ago

Prerequisites

Neovim Version

v0.10.0-dev

Neorg setup

require("neorg").setup({
    load = {
        ["core.defaults"] = {},

        ["core.completion"] = {
            config = {
                engine = "nvim-cmp",
            },
        },

        ["core.concealer"] = {},

        ["core.latex.renderer"] = {
            config = {
                render_on_enter = false,
            },
        },

        ["core.autocommands"] = {},
        ["core.integrations.treesitter"] = {},
        ["core.neorgcmd"] = {},

        ["core.dirman"] = {
            config = {
                workspaces = {
                    notes = "~/notes",
                },
                default_workspace = "notes",
            },
        },
    },
})

Actual behavior

.../.local/share/nvim/lazy/neorg/lua/neorg/core/modules.lua:307
Unable to load module core.latex.renderer, wanted dependency core.integrations.image was not
 satisfied. Be sure to load the module and its appropriate config too!

Expected behavior

Neorg detecting the installation of image.nvim, installed as follows:

return {
    "3rd/image.nvim",
    dependencies = { "luarocks.nvim" },

    config = function()
        require("image").setup({
            backend = "kitty",
            integrations = {
                neorg = {
                    enabled = true,
                    clear_in_insert_mode = false,
                    download_remote_images = true,
                    only_render_image_at_cursor = false,
                    filetypes = { "norg" },
                },
            },

            max_width = 80,
        })
    end,
}

Instead, I get the following error:

.../.local/share/nvim/lazy/neorg/lua/neorg/core/modules.lua:307
Unable to load module core.latex.renderer, wanted dependency core.integrations.image was not
 satisfied. Be sure to load the module and its appropriate config too!

Here is how neorg is installed:

return {
    {
        "vhyrro/luarocks.nvim",
        priority = 1000, -- We'd like this plugin to load first out of the rest
        config = true, -- This automatically runs `require("luarocks-nvim").setup()`
    },
    {
        "nvim-neorg/neorg",
        dependencies = { "luarocks.nvim" },
        -- put any other flags you wanted to pass to lazy here!
        config = function()
            require("neorg").setup({
                                      ...........

Steps to reproduce

Using lazy.nvim, try to use the module core.latex.renderer

Potentially conflicting plugins

-

Other information

No response

Help

Yes, but I don't know how to start. I would need guidance (check question below)

Implementation help

No response

pysan3 commented 2 months ago

As it literally says in the error message, you need to add ["core.integrations.image"] = {} to the setup({ load = ... }) as well.

fractal-robot commented 2 months ago

I through that it was misleading, since there is no integration core.integration.image in the wiki, nor the latex rendering is working when I explicitly add this integration in my config:

Error executing Lua callback: ...al/share/nvim/lazy/image.nvim/lua/image/utils/logger.lua:54: 11:27:24.744156 [image.nvim] image.nvim: file not found: /tmp/nvim.usr/AqmtRU/4
stack traceback:
        [C]: in function 'handler'
        ...al/share/nvim/lazy/image.nvim/lua/image/utils/logger.lua:54: in function 'throw'
        ...sr/.local/share/nvim/lazy/image.nvim/lua/image/image.lua:235: in function 'from_file'
        ...org/lua/neorg/modules/core/integrations/image/module.lua:35: in function 'new_image'
        ...y/neorg/lua/neorg/modules/core/latex/renderer/module.lua:78: in function 'callback'
        ...ua/neorg/modules/core/integrations/treesitter/module.lua:729: in function 'execute_query'
        ...y/neorg/lua/neorg/modules/core/latex/renderer/module.lua:61: in function 'latex_renderer'
        ...y/neorg/lua/neorg/modules/core/latex/renderer/module.lua:198: in function 'on_event'
        .../.local/share/nvim/lazy/neorg/lua/neorg/core/modules.lua:794: in function 'broadcast_event'
        ...im/lazy/neorg/lua/neorg/modules/core/neorgcmd/module.lua:298: in function <...im/lazy/neorg/lua/neorg/modules/core/neorgcmd/module.lua:205>

Note that the use of .image render the image correctly using image.nvim

fractal-robot commented 2 months ago

The error changes when I install the TeX Live suit using sudo pacman -S texlive.

So maybe the error does not come from image.nvim, or the rendering of the image at all, but from the way the latex code is compiled?

Maybe the instructions on how to use the latex preview should be made clear in the wiki page.

If you need more data specific to my system, I can do a more complete report.

benlubas commented 2 months ago

Yes you need latex installed to render latex. I have this requirement added on the branch where I'm updating the renderer.

Want help with the new error? you can add it to the thread.

fractal-robot commented 2 months ago

Here is the new error:

stack traceback:
    ...y/neorg/lua/neorg/modules/core/latex/renderer/module.lua:169: in function 'render_inline_math'
    ...y/neorg/lua/neorg/modules/core/latex/renderer/module.lua:199: in function 'on_event'
    .../.local/share/nvim/lazy/neorg/lua/neorg/core/modules.lua:794: in function 'broadcast_event'
    ...im/lazy/neorg/lua/neorg/modules/core/neorgcmd/module.lua:298: in function <...im/lazy/neorg/lua/neorg/modules/core/neorgcmd/module.lua:205>
   Error  03:04:26 PM msg_show.lua_error   Neorg render-latex Error executing Lua callback: ...y/neorg/lua/neorg/modules/core/latex/renderer/module.lua:169: attempt to index a nil value

When trying to render this latex expression: $x = 2$.

neorg.lua

return {
  "nvim-neorg/neorg",
  dependencies = { "max397574/neorg-contexts" },

  config = function()
    require("neorg").setup({
      load = {
        ["core.defaults"] = {},

        ["core.completion"] = {
          config = {
            engine = "nvim-cmp",
          },
        },

        ["core.concealer"] = {},

        ["external.context"] = {},

        ["core.latex.renderer"] = {
          config = {
            render_on_enter = false,
          },
        },

        ["core.autocommands"] = {},
        ["core.integrations.treesitter"] = {},
        ["core.neorgcmd"] = {},
        ["core.integrations.image"] = {},

        ["core.dirman"] = {
          config = {
            workspaces = {
              notes = "~/notes",
            },
            default_workspace = "notes",
          },
        },
      },
    })

    vim.wo.foldlevel = 99
    vim.wo.conceallevel = 2
  end,
}

image.lua

return {
  "3rd/image.nvim",

  config = function()
    require("image").setup({
      backend = "kitty",
      integrations = {
        neorg = {
          enabled = true,
          clear_in_insert_mode = false,
          download_remote_images = true,
          only_render_image_at_cursor = false,
          filetypes = { "norg" },
        },
      },

      window_overlap_clear_enabled = true,
    })
  end,
}

Other informations

benlubas commented 2 months ago

I can look into it but at this point it's probably not worth. Can you test my async latex render branch and see if it still fails? There's a PR up for it.

fractal-robot commented 2 months ago
"benlubas/neorg",
branch = "feat/async_images_via_nio",

This is working using your async latex render branch. image

Thanks a lot for this!

I will close the issue once your PR is merged.