luckasRanarison / nvim-devdocs

Neovim DevDocs integration
MIT License
270 stars 20 forks source link

Glow doesn't work #27

Closed albertocerrone closed 1 year ago

albertocerrone commented 1 year ago

Hi there!

I have tried to add glow like suggested by the documentation but seems not to be working. this is my config:

  {
    "luckasRanarison/nvim-devdocs",
    cmd = { "DevdocsFetch", "DevdocsInstall", "DevdocsUpdate", "DevdocsUpdateAll", "DevdocsUninstall", "DevdocsOpen",
      "DevdocsOpenFloat", },
    opts = {
      wrap = true,
      float_win = {
        relative = "editor",
        height = 75,
        width = 170,
        border = "rounded",
      },
      ensure_installed = {
        "python-3.11",
        "django-4.2",
        "bootstrap-5"
      },

    },
    previewer_cmd = "glow",
    cmd_args = {"-s", "dark", "-w", "80" },
    picker_cmd_args = { "-p"},
    dependencies = {
      "nvim-lua/plenary.nvim",
      "nvim-telescope/telescope.nvim",
      "nvim-treesitter/nvim-treesitter",
    },
  },

thank you so much

luckasRanarison commented 1 year ago

Hi! Does this happen when opening a doc? If you're talking about the picker's preview, the picker_cmd option is missing in your config, you have to set it to true:

{
  picker_cmd = true,
}
albertocerrone commented 1 year ago

Ok so I've added:

{
  picker_cmd = true,
}

but it doesn't work. I've installed glow (the cli tool from glow) and it works properly in my CLI (iTerm) but it still not working I've tried as well to use glow.nvim but without any success

mvaldes14 commented 1 year ago

same issue, the cli is installed and the setup is exactly the same (calling setup instead of just opts) but preview doesn't render in glow and when picking it just displays pure markdown.

luckasRanarison commented 1 year ago

That's weird, I'm basically using the same options as in the example and it works for me. I'll try to investigate that.

luckasRanarison commented 1 year ago

Could you guys try to change the cmd with another command that can output things like cat for example?

albertocerrone commented 1 year ago

I tried with cat and this is the result: image I don't think changed anything

albertocerrone commented 1 year ago

Just for the sake of total clarity. My machine is a M2 macbook. I don't know if there are any problems related to this

luckasRanarison commented 1 year ago

Hi there!

I have tried to add glow like suggested by the documentation but seems not to be working. this is my config:

  {
    "luckasRanarison/nvim-devdocs",
    cmd = { "DevdocsFetch", "DevdocsInstall", "DevdocsUpdate", "DevdocsUpdateAll", "DevdocsUninstall", "DevdocsOpen",
      "DevdocsOpenFloat", },
    opts = {
      wrap = true,
      float_win = {
        relative = "editor",
        height = 75,
        width = 170,
        border = "rounded",
      },
      ensure_installed = {
        "python-3.11",
        "django-4.2",
        "bootstrap-5"
      },

    },
    previewer_cmd = "glow",
    cmd_args = {"-s", "dark", "-w", "80" },
    picker_cmd_args = { "-p"},
    dependencies = {
      "nvim-lua/plenary.nvim",
      "nvim-telescope/telescope.nvim",
      "nvim-treesitter/nvim-treesitter",
    },
  },

thank you so much

I just realized you put this block outside opts, it should be inside.

    previewer_cmd = "glow",
    cmd_args = {"-s", "dark", "-w", "80" },
    picker_cmd_args = { "-p"},
greggannicott commented 1 year ago

Possible Solution

tl;dr: update to latest version of plugin

Details:

I had the same issue, and have what I believe to be the same configuration (see below).

However, once I updated to the latest version of the plugin (using Lazy) and restarted, it worked ok.

The one issue I did have is I now need to re-install all my docs.

Hope this information helps!

For reference, my config:

require("nvim-devdocs").setup({
    dir_path = vim.fn.stdpath("data") .. "/devdocs", -- installation directory
    telescope = {}, -- passed to the telescope picker
    telescope_alt = { -- when searching globally without preview
        layout_config = {
            width = 75,
        },
    },
    float_win = { -- passed to nvim_open_win(), see :h api-floatwin
        relative = "editor",
        height = 25,
        width = 100,
        border = "rounded",
    },
    wrap = false, -- text wrap
    previewer_cmd = "glow", -- for example: "glow"
    cmd_args = { "-s", "dark", "-w", "80" },
    picker_cmd = true,
    picker_cmd_args = { "-p" },
    ensure_installed = {}, -- get automatically installed
})
albertocerrone commented 1 year ago

@luckasRanarison mate ahahhaha! I'm so sorry ahahah rookie mistake. Now seems working with glow. the only issue is that takes ages to load each of the docs (~15secs). Is this a known issue?

luckasRanarison commented 1 year ago

It's a problem with glow itself, glow is really slow and it only makes a single write after finishing processing the whole file. It'd be better if glow generates output line by line.

benelan commented 1 year ago

It's a problem with glow itself, glow is really slow and it only makes a single write after finishing processing the whole file. It'd be better if glow generates output line by line.

Would it be possible to cache the results from glow so it doesn't need to rerender each time? You'd have to make sure to bust the cache when the doc source is updated.

That would be another solution to the issue I mentioned here https://github.com/luckasRanarison/nvim-devdocs/issues/8#issuecomment-1693923918

luckasRanarison commented 1 year ago

Caching the preview may be possible but we can't reuse the preview when opening the doc like a normal buffer.

luckasRanarison commented 1 year ago

@luckasRanarison mate ahahhaha! I'm so sorry ahahah rookie mistake. Now seems working with glow. the only issue is that takes ages to load each of the docs (~15secs). Is this a known issue?

Update: the docs are now small enough, only the currently selected section is shown so rendering with glow should be fast now. See #42

Closing this as completed.