preservim / nerdcommenter

Vim plugin for intensely nerdy commenting powers
Creative Commons Zero v1.0 Universal
4.97k stars 447 forks source link

fix: correct logic for switching alt delimiters #536

Open carlostobon opened 3 weeks ago

carlostobon commented 3 weeks ago
alerque commented 3 weeks ago

This is a direct revert of fea637c from #531 by @svalaskevicius. There must me something one or both of you are not testing because it can't be right both ways. What versions of VIM are you using to test with?

carlostobon commented 3 weeks ago

Yeah it's essentially a revert of. Running archlinux with binary from the pkg manager and current version VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Aug 11 2024 20:40:17). Im probably doing something wrong but certainly that line is causing the bug.

alerque commented 3 weeks ago

It looks like a pretty safe bet that @svalaskevicius is running NeoVIM based on his dotfiles:

https://github.com/svalaskevicius/dotfiles/blob/master/.config/nvim/conf/plugins.vim#L25

That might have something to do with why you're coming to opposite conclusions. I don't think we should just revert either way or even just gate it on VIM vs. NeoVIM, there is probably an actually right way to do this that works properly in both environments. That's what we should go for.

carlostobon commented 3 weeks ago

Completely agree with you. Thanks for your time.

alerque commented 3 weeks ago

(Personally I'd prefer to keep this open to track the known problem until we find a fix, the "closed" label doesn't encourage participation or responses which we kind of need here to sort this out.)

carlostobon commented 3 weeks ago

Sounds perfect!

anthdono commented 2 weeks ago

Confirming commit 3f860f2 breaks alternate delims in the latest Neovim nightly as of writing, however it is working fine in Vim 9.1.

I agree with @alerque, as this is a Vim library, it may not be appropriate to revert the change due to behaviour in Neovim, albeit a nuisance.

I'll try find some time to investigate a solution for #531 that works for both Vim and Neovim.

anthdono commented 2 weeks ago

I am incorrect, it looks like 3f860f2 breaks alternate delims in Vim too. Just re-tested on Vim 9.1.650 with react typescript, minimal config for reproduction below:

nmap <leader>/ <Plug>NERDCommenterToggle
vmap <leader>/ <Plug>NERDCommenterToggle
let g:NERDSpaceDelims = 1
let g:NERDDefaultAlign = 'left'
let g:NERDCommentEmptyLines = 1
let g:NERDCustomDelimiters = {
\   'typescript': { 'left': '//', 'leftAlt': '/**', 'rightAlt': '*/' },
\   'typescriptreact': { 'left': '//', 'leftAlt': '{/*', 'rightAlt': '*/}' },
\   'javascript': { 'left': '//', 'leftAlt': '{/*', 'rightAlt': '*/}' },
\   'kotlin': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }
\ }

Reverting 3f860f2 fixes the issue, this commit should be merged.