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

Compatibility with nvim-ufo #599

Closed
Zhou-Yicheng opened this issue Aug 20, 2023 · 7 comments · Fixed by #615
Closed

Compatibility with nvim-ufo #599

Zhou-Yicheng opened this issue Aug 20, 2023 · 7 comments · Fixed by #615
Labels
bug Something isn't working

Comments

@Zhou-Yicheng
Copy link

Describe the bug

Fold automatically every time type ESC in insert mode

Steps to reproduce

  1. Install Neovim
  2. Install nvim-orgmode with nvim-ufo
  3. Setup orgmode treesitter grammar
  4. Setup UFO with folding provider of treesitter indent
  5. Run :TSUpdate org
  6. Open an org file
  7. Enter insert mode then type ESC

Expected behavior

Back to normal mode without folding

Emacs functionality

No response

Minimal init.lua

    require('orgmode').setup()
    require('orgmode').setup_ts_grammar()
    require('ufo').setup({
      provider_selector = function(bufnr, filetype, buftype)
        return { 'treesitter', 'indent' }
      end,
    })

Screenshots and recordings

No response

OS / Distro

Gentoo 2.14

Neovim version/commit

v0.9.1

Additional context

No response

@Zhou-Yicheng Zhou-Yicheng added the bug Something isn't working label Aug 20, 2023
@m3xan1k
Copy link

m3xan1k commented Sep 7, 2023

Experiencing same issue

@orhnk
Copy link

orhnk commented Sep 24, 2023

It's reproducible yes.
But strangely achieves the same thing while keeping the folds there!

Note

I face this issue in general when using nvim-ufo.
(e.g) undoing inside a file (not specific to .org)

@PriceHiller
Copy link
Contributor

This is really an issue with UFO in some aspects. A good work around is to disable UFO in org buffers. I ran into this myself just now while migrating to orgmode.

Here's how I disable UFO in certain buffers:

local ft_options = {
    norg = "", -- Neorg had the same issue
    org = "" -- We "disable" ufo in org files by giving back an empty provider to UFO
}

require('ufo').setup({
    provider_selector = function(_, filetype, _)
        return ft_options[filetype] or { "treesitter", "indent" }
    end,
})

I still get folding in org files without the weird "auto-folding" going on from UFO. Recommend you give it a shot.

@orhnk
Copy link

orhnk commented Sep 24, 2023

@treatybreaker This didn't solve the issue on #614 Thanks for sharing anyway!
but using:

vim.cmd [[setlocal nofoldenable]] -- No folds initially

disables folds. You can use it with an autocmd.

@PriceHiller
Copy link
Contributor

@treatybreaker This didn't solve the issue on #614 Thanks for sharing anyway! but using:

vim.cmd [[setlocal nofoldenable]] -- No folds initially

disables folds. You can use it with an autocmd.

It still seems as though UFO's folds are much superior to what we get out the gate with orgmode here.

nofoldenable still leads to some folds being incorrectly calculated like in #614, UFO works around that but introduces the esc/undo bug here.

Somewhat frustrating, I think I'll set aside some time later to find the root cause.

@PriceHiller
Copy link
Contributor

Hey @Zhou-Yicheng, @UTFeight, @m3xan1k,

With the merging of #615 UFO should play nice with Orgmode if you set org_startup_folded to inherit or showeverything.

require("orgmode").setup({
    -- ...
    org_startup_folded = "inherit"
})

Give it a shot, that fixes UFO issues for me.

@orhnk
Copy link

orhnk commented Sep 27, 2023

The issue solved!
Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants