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

Better parsing of comments in Vim Script #273

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

lemeb
Copy link

@lemeb lemeb commented Oct 11, 2019

Hi @jiangmiao!

I love auto-pairs, but there one thing that has annoyed me for quite a while. When I edit a vimscript file, and I try to put an in-line comment, meaning a comment after any instruction, auto-pairs detects it as a normal quote, and that leads to mayhem:

here

I think I found a way to fix this problem, and it is by changing the regex to detect quotes starting comments in allPairs.

Have a great day!

Screenshots

Old Regex

Screen Shot 2019-10-11 at 13 01 11

New Regex

Screen Shot 2019-10-11 at 13 02 04

Appendix

Here is the test code, so you can play with it if necessary.

    " A. PLUGS IN PURGATORY
        " (To be deleted if they end up being disappointing.)
        Plug "kassio/neoterm"                   " Better Terminal integration
        Plug "kassio/neoterm"                   " Better Terminal integration
        let g:neoterm_default_mod = 'belowright' " in its proper place
        Plug "kassio/neoterm"
        Plug kassio/neoterm"dd
        Plug kassio/neoterm" dd
        Plug kassio/neoterm " dd
        Plug " kassio/neoterm " dd " Totaly

        ddddd "dddsdsd \"\"

" /^.*\zs".*$/  
"djdjdj"

let bol = '^\s*\zs"'
let no_q = '(\\\"|[^"])*'
let eol = '^("'.no_q.'"*|[^"])* \zs"\ze'.no_q.'$'
let re_old = '\v^\s*\zs"'
let re_new = '\v'.bol.'|'.eol

" Try the different regexes
execute '/'.re_new.'/'
echo '/'.re_new.'/'

@disrupted
Copy link

what's missing to get this merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants