Allow customisation of the signs
Too many plugins use the default priority of 10 so they race/chase. Allow uses to configure the priorities and make sure that the defaults are documented.
This commit is contained in:
parent
e634982d78
commit
c1b544fb3c
12 changed files with 370 additions and 113 deletions
|
|
@ -37,49 +37,68 @@ if ! exists( ':' . s:make_cmd )
|
|||
endif
|
||||
|
||||
function! VimGetCurrentFunction()
|
||||
echom s:GetCurrentFunction()
|
||||
echom s:GetCurrentFunction()[ 0 ]
|
||||
endfunction
|
||||
|
||||
function! s:GetCurrentFunction()
|
||||
" Store the cursor position; we'll need to reset it
|
||||
let [ l:buf, l:row, l:col, l:offset ] = getpos( '.' )
|
||||
let [ buf, row, col, offset ] = getpos( '.' )
|
||||
|
||||
let l:test_function = ''
|
||||
let [ test_function, test_function_line ] = [ v:null, -1 ]
|
||||
|
||||
let l:pattern = '\V\C\s\*function!\?\s\+\(\<\w\+\>\)\.\*\$'
|
||||
let pattern = '\V\C\s\*func\%\(tion\)\?!\?\s\+\(\<\w\+\>\)\.\*\$'
|
||||
|
||||
let l:lnum = prevnonblank( '.' )
|
||||
let lnum = prevnonblank( '.' )
|
||||
|
||||
" Find the top-level method and class
|
||||
while l:lnum > 0
|
||||
call cursor( l:lnum, 1 )
|
||||
let l:lnum = search( l:pattern, 'bcnWz' )
|
||||
while lnum > 0
|
||||
call cursor( lnum, 1 )
|
||||
let lnum = search( pattern, 'bcnWz' )
|
||||
|
||||
if l:lnum <= 0
|
||||
call cursor( l:row, l:col )
|
||||
return l:test_function
|
||||
if lnum <= 0
|
||||
call cursor( row, col )
|
||||
return [ test_function, test_function_line ]
|
||||
endif
|
||||
|
||||
let l:this_decl = substitute( getline( l:lnum ), l:pattern, '\1', '' )
|
||||
let l:this_decl_is_test = match( l:this_decl, '\V\C\^Test_' ) >= 0
|
||||
let this_decl = substitute( getline( lnum ), pattern, '\1', '' )
|
||||
let this_decl_is_test = match( this_decl, '\V\C\^Test_' ) >= 0
|
||||
|
||||
if l:this_decl_is_test
|
||||
let l:test_function = l:this_decl
|
||||
if this_decl_is_test
|
||||
let [ test_function, test_function_line ] = [ this_decl, lnum ]
|
||||
|
||||
if indent( l:lnum ) == 0
|
||||
call cursor( l:row, l:col )
|
||||
return l:test_function
|
||||
if indent( lnum ) == 0
|
||||
call cursor( row, col )
|
||||
return [ test_function, test_function_line ]
|
||||
endif
|
||||
endif
|
||||
|
||||
let l:lnum = prevnonblank( l:lnum - 1 )
|
||||
let lnum = prevnonblank( lnum - 1 )
|
||||
endwhile
|
||||
|
||||
return [ v:null, -1 ]
|
||||
endfunction
|
||||
|
||||
function! s:RunTestUnderCursorInVimspector()
|
||||
update
|
||||
let l:test_func_name = s:GetCurrentFunction()[ 0 ]
|
||||
|
||||
if l:test_func_name ==# ''
|
||||
echo 'No test method found'
|
||||
return
|
||||
endif
|
||||
|
||||
echo "Running test '" . l:test_func_name . "'"
|
||||
|
||||
call vimspector#LaunchWithSettings( {
|
||||
\ 'configuration': 'Run test',
|
||||
\ 'TestFunction': l:test_func_name
|
||||
\ } )
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:RunTestUnderCursor()
|
||||
update
|
||||
let l:test_func_name = s:GetCurrentFunction()
|
||||
let l:test_func_name = s:GetCurrentFunction()[ 0 ]
|
||||
|
||||
if l:test_func_name ==# ''
|
||||
echo 'No test method found'
|
||||
|
|
@ -132,10 +151,36 @@ if ! has( 'gui_running' )
|
|||
nnoremap <buffer> Â :call <SID>RunAllTests()<CR>
|
||||
" † is right-option+t
|
||||
nnoremap <buffer> † :call <SID>RunTestUnderCursor()<CR>
|
||||
nnoremap <buffer> <leader>† :call <SID>RunTestUnderCursorInVimspector()<CR>
|
||||
" å is the right-option+q
|
||||
nnoremap <buffer> å :cfirst<CR>
|
||||
" å is the right-option+a
|
||||
nnoremap <buffer> œ :cnext<CR>
|
||||
nnoremap <buffer> œ :FuncLine<CR>
|
||||
" Ω is the right-option+z
|
||||
nnoremap <buffer> Ω :cprevious<CR>
|
||||
endif
|
||||
|
||||
function! s:GoToCurrentFunctionLine( ... )
|
||||
if a:0 < 1
|
||||
call inputsave()
|
||||
let lnum = str2nr( input( 'Enter line num: ' ) )
|
||||
call inputrestore()
|
||||
else
|
||||
let lnum = a:1
|
||||
endif
|
||||
|
||||
let [ f, l ] = s:GetCurrentFunction()
|
||||
if f is v:null
|
||||
return
|
||||
endif
|
||||
|
||||
let lnum += l
|
||||
|
||||
echo 'Function' f 'at line' l '(jump to line ' lnum . ')'
|
||||
|
||||
call cursor( [ lnum, indent( lnum ) ] )
|
||||
endfunction
|
||||
|
||||
command! -buffer -nargs=? -bar
|
||||
\ FuncLine
|
||||
\ :call s:GoToCurrentFunctionLine( <f-args> )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue