~maxgyver83/hare-jump.vim

d5417b6014dc5f3c570324b0f14ec8c6fcf1e25d — Max Schillinger 2 months ago b226728
Search only single-token identifiers in current function
1 files changed, 11 insertions(+), 9 deletions(-)

M plugin/harejump.vim
M plugin/harejump.vim => plugin/harejump.vim +11 -9
@@ 19,15 19,17 @@ function! harejump#JumpToDefinition(identifier = '')
  end

  " check if identifier is a variable/constant in the current function
  let fndefinitionline = s:InFunction()
  if fndefinitionline
    if s:SearchAndJumpInFile('\(let\|const\|def\) \(([^)]*\)\?' .. tokens[-1] .. '\>', 'bW', fndefinitionline)
      return 1
    endif
    " try to jump to function argument
    " TODO: This might also jump to a cast of the symbol.
    if s:SearchAndJumpInFile(tokens[-1] .. ': ', 'bW', fndefinitionline)
      return 1
  if len(tokens) == 1
    let fndefinitionline = s:InFunction()
    if fndefinitionline
      if s:SearchAndJumpInFile('\(let\|const\|def\) \(([^)]*\)\?' .. tokens[-1] .. '\>', 'bW', fndefinitionline)
        return 1
      endif
      " try to jump to function argument
      " TODO: This might also jump to a cast of the symbol.
      if s:SearchAndJumpInFile(tokens[-1] .. ': ', 'bW', fndefinitionline)
        return 1
      endif
    endif
  endif