kevinhwang91 / nvim-ufo

Not UFO in the sky, but an ultra fold in Neovim.
BSD 3-Clause "New" or "Revised" License
2.23k stars 44 forks source link

Open Folds by shifting code #66

Open juridiener opened 2 years ago

juridiener commented 2 years ago

Neovim version (nvim -v | head -n1)

NVIM 7.0

Operating system/version

macOS

How to reproduce the issue

https://user-images.githubusercontent.com/92093874/184601497-9371e74b-d89e-45a5-8d32-dd212aa0aec3.mov

Expected behavior

Does not open fold.

Actual behavior

Open folds by shifting code left or right.

kevinhwang91 commented 2 years ago

mini.lua

juridiener commented 2 years ago

Hey, thank you for your fast response. What you mean with mini.lua?

kevinhwang91 commented 2 years ago

How to reproduce the issue

in template.

juridiener commented 2 years ago

In Packer: use {'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async'}

nvim-ufo.lua: local status_ok, ufo = pcall(require, "ufo") if not status_ok then return end

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

after/plugin/folding.lua: local opt = vim.opt

opt.foldcolumn = "1" opt.foldlevel = 99 opt.foldlevelstart = -1 opt.foldenable = true

vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] vim.o.foldcolumn = '1'

lsp.lua: M.capabilities.textDocument.foldingRange = { dynamicRegistration = false, lineFoldingOnly = true, }

To reproduce the issue: Close a div tag then shift+v and the type < or >

kevinhwang91 commented 2 years ago

You have edited the text in the folding range, and it must be opened. It's Vim behavior.

I suggest you enhance your < and >. Detect fold whether is closed and then close the selection again.

juridiener commented 2 years ago

How i would do it? Sorry I have no experience with neovim and how to write custom functions.

kevinhwang91 commented 2 years ago

maybe ufo can help, but I am not interesting for now. Set this feature as low priority.

kevinhwang91 commented 2 years ago

How i would do it? Sorry I have no experience with neovim and how to write custom functions.

h foldclosed() h :foldc

juridiener commented 2 years ago

okay, yeah it's only in my opinion important if you refactor large html code. That would help. For other cases it's a low important feature. Thanks for helping.

kevinhwang91 commented 2 years ago

I suggest you use the format.

juridiener commented 2 years ago

I noticed that behaviour as well when i copy or cut an div-tag and paste it in a different location the fold opens. I hope you have some time to implement this. I don't know how difficult it is to implement this feature. But i would be really appreciate it, and it would be cover all cases for folding.

kevinhwang91 commented 2 years ago

I noticed that behaviour as well when i copy or cut an div-tag and paste it in a different location the fold opens. I hope you have some time to implement this. I don't know how difficult it is to implement this feature. But i would be really appreciate it, and it would be cover all cases for folding.

It's difficult.

https://github.com/kevinhwang91/nvim-ufo/issues/60#issuecomment-1199040389