Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support setting buftype_allowlist to work around issues with nvim-docs-view #36

Open
swaits opened this issue Oct 20, 2023 · 1 comment
Labels

Comments

@swaits
Copy link

swaits commented Oct 20, 2023

Here's my config (lazy.vim):

return {
  "andrewferrier/wrapping.nvim",
  keys = {
    { "<leader>uw", "<cmd>ToggleWrapMode<cr>", desc = "Toggle Hard/Soft Mode", mode = "n" },
  },
  opts = {
    softener = {
      { markdown = true },
      { ["nvim-docs-view"] = true }, -- this is not working
    },
  },
}

The nvim-docs-view filetype is from the buffer opened by the nvim-docs-view plugin.

This plugin automatically shows the hover text (ie usually docs) for whatever is under the cursor.

By default, it doesn't wrap anything. When I switch to that window and toggle wrapping I get the message that it switched to hard mode. When I toggle it a second time, it says it switched to soft mode, and indeed the documentation text is then properly wrapping.

Note that I used the ["nvim-docs-view"] syntax because hyphens are not legal in the normal key = value syntax.

@andrewferrier
Copy link
Owner

andrewferrier commented May 25, 2024

Hi, sorry for the long delay, I eventually got wrong to looking at this. I think I've fixed this issue in commit 4c87a23. There were two issues; one the way that wrapping.nvim detects filetype changes, which I've enhanced, and secondly the fact that it was discard all buffers with buftype not blank. nvim-docs-view uses a nofile buffer. I've added an additional undocumented option to support this.

If you can please test this (with the latest master branch), that would be great, if this works I'll document it and release it properly.

You'll need to use configuration a bit like this:

return {
    url = "andrewferrier/wrapping.nvim",
    config = function()
        require("wrapping").setup({
            softener = { markdown = true, ["nvim-docs-view"] = true },
            auto_set_mode_filetype_allowlist = {
                "markdown",
                "nvim-docs-view",
            },
            buftype_allowlist = {
                "nofile",
            },
        })
    end,
}

Please let me know if that works.

@andrewferrier andrewferrier changed the title trouble forcing soft wrap mode on specific filetype Support setting buftype_allowlist to work around issues with nvim-docs-view May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants