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

use matchpairs for g:targets_argClosing/Opening #130

Open
Konfekt opened this issue Nov 4, 2015 · 5 comments
Open

use matchpairs for g:targets_argClosing/Opening #130

Konfekt opened this issue Nov 4, 2015 · 5 comments

Comments

@Konfekt
Copy link

Konfekt commented Nov 4, 2015

How about using matchpairs to set g:targets_argClosing/Opening by default ? That could be achieved by

let g:targets_argOpening = '['
let g:targets_argClosing = '['

let mps = split(&g:matchpairs, ',')
for mp in mps
  let mpOC = split(mp, ':')
  let g:targets_argOpening = g:targets_argOpening . mpOC[0]
  let g:targets_argClosing = g:targets_argClosing . mpOC[1]
endfor
unlet mps
unlet mp
unlet mpOC

let g:targets_argOpening = g:targets_argOpening . ']'
let g:targets_argClosing = g:targets_argClosing . ']'
@Konfekt
Copy link
Author

Konfekt commented Nov 4, 2015

The comparison with &g:matchpairs also suggests a buffer local version b:targets_argClosing/Opening.

@wellle
Copy link
Owner

wellle commented Nov 5, 2015

That's an interesting idea.

But it would change the current default to include curly braces. Also I believe the closing ] needs to be escaped inside [] unless it's the first character (that's why I put it like this).

@Konfekt
Copy link
Author

Konfekt commented Nov 5, 2015

There might be good reasons to differ from setglobal matchpairs& but as a dilettante I see none.

True that ] must be escaped. Another reason to prefer the syntax of matchpairs ? Again, as an outsider, the enclosing [ ] do not seem necessary.

@Konfekt
Copy link
Author

Konfekt commented Nov 5, 2015

My bad, now I understand that [..] is a regex. Still, perhaps the regex could by default coincide with that given by&g:matchpairs.

@Konfekt
Copy link
Author

Konfekt commented Nov 5, 2015

Here is an updated version of the above script converting &matchpairs into an opening and closing regex pattern as expected by g:targets_argOpening/Closing:

let g:targets_argOpening = '['
let g:targets_argClosing = '['

let mps = split(&g:matchpairs, ',')
for mp in mps
  let mpOC = split(mp, ':')
  let g:targets_argOpening = g:targets_argOpening . escape(mpOC[0], ']^-\')
  let g:targets_argClosing = g:targets_argClosing . escape(mpOC[1], ']^-\')
endfor
unlet mps
unlet mp
unlet mpOC

let g:targets_argOpening = g:targets_argOpening . ']'
let g:targets_argClosing = g:targets_argClosing . ']'

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

No branches or pull requests

2 participants