nvim-ufo icon indicating copy to clipboard operation
nvim-ufo copied to clipboard

Open Folds by shifting code

Open juridiener opened this issue 3 years ago • 12 comments

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.

juridiener avatar Aug 15 '22 08:08 juridiener

mini.lua

kevinhwang91 avatar Aug 15 '22 08:08 kevinhwang91

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

juridiener avatar Aug 15 '22 08:08 juridiener

How to reproduce the issue

in template.

kevinhwang91 avatar Aug 15 '22 08:08 kevinhwang91

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 >

juridiener avatar Aug 15 '22 08:08 juridiener

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.

kevinhwang91 avatar Aug 15 '22 09:08 kevinhwang91

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

juridiener avatar Aug 15 '22 09:08 juridiener

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

kevinhwang91 avatar Aug 15 '22 09:08 kevinhwang91

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

h foldclosed() h :foldc

kevinhwang91 avatar Aug 15 '22 09:08 kevinhwang91

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.

juridiener avatar Aug 15 '22 09:08 juridiener

I suggest you use the format.

kevinhwang91 avatar Aug 15 '22 10:08 kevinhwang91

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.

juridiener avatar Aug 15 '22 12:08 juridiener

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

kevinhwang91 avatar Aug 15 '22 13:08 kevinhwang91