Better paren matching
This commit is contained in:
parent
1572562998
commit
897535d60b
@ -65,7 +65,7 @@ function! argwrap#findClosestRange()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! argwrap#extractArgumentText(range)
|
function! argwrap#extractContainerArgText(range)
|
||||||
let l:text = ''
|
let l:text = ''
|
||||||
|
|
||||||
for l:lineIndex in range(a:range.lineStart, a:range.lineEnd)
|
for l:lineIndex in range(a:range.lineStart, a:range.lineEnd)
|
||||||
@ -107,7 +107,7 @@ function! argwrap#trimArgument(text)
|
|||||||
return substitute(a:text, '^\s*\(.\{-}\)\s*$', '\1', '')
|
return substitute(a:text, '^\s*\(.\{-}\)\s*$', '\1', '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! argwrap#extractArguments(text)
|
function! argwrap#extractContainerArgs(text)
|
||||||
let l:stack = []
|
let l:stack = []
|
||||||
let l:arguments = []
|
let l:arguments = []
|
||||||
let l:argument = ''
|
let l:argument = ''
|
||||||
@ -164,19 +164,30 @@ function! argwrap#unwrapContainer(range, container, arguments)
|
|||||||
exec printf('%d,%dd_', a:range.lineStart + 1, a:range.lineEnd)
|
exec printf('%d,%dd_', a:range.lineStart + 1, a:range.lineEnd)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! argwrap#toggle()
|
function! argwrap#adjustCursor()
|
||||||
let l:range = argwrap#findClosestRange()
|
let [l:buffer, l:line, l:col, l:offset] = getpos('.')
|
||||||
if !argwrap#validateRange(l:range)
|
let l:lineText = getline('.')
|
||||||
call search('[\(\[\{]', 'W')
|
|
||||||
call search('[^\(\[\{]', 'W')
|
let l:col = match(l:lineText, '[\(\[\{]')
|
||||||
let l:range = argwrap#findClosestRange()
|
if l:col >= 0
|
||||||
if !argwrap#validateRange(l:range)
|
if l:col + 1 == strlen(l:lineText)
|
||||||
return
|
call cursor(l:line + 1, 0)
|
||||||
|
else
|
||||||
|
call cursor(l:line, l:col + 2)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
let l:argText = argwrap#extractArgumentText(l:range)
|
function! argwrap#toggle()
|
||||||
let l:arguments = argwrap#extractArguments(l:argText)
|
call argwrap#adjustCursor()
|
||||||
|
|
||||||
|
let l:range = argwrap#findClosestRange()
|
||||||
|
if !argwrap#validateRange(l:range)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:argText = argwrap#extractContainerArgText(l:range)
|
||||||
|
let l:arguments = argwrap#extractContainerArgs(l:argText)
|
||||||
let l:container = argwrap#extractContainer(l:range)
|
let l:container = argwrap#extractContainer(l:range)
|
||||||
|
|
||||||
if l:range.lineStart == l:range.lineEnd
|
if l:range.lineStart == l:range.lineEnd
|
||||||
|
Loading…
Reference in New Issue
Block a user