Skip to content

Instantly share code, notes, and snippets.

@4513ECHO
Last active July 1, 2022 13:12
Show Gist options
  • Save 4513ECHO/dc5a7d899f5d4019a699ea9a8b47c9b5 to your computer and use it in GitHub Desktop.
Save 4513ECHO/dc5a7d899f5d4019a699ea9a8b47c9b5 to your computer and use it in GitHub Desktop.
sample function of kana/vim-gf-user
function! gf#vimrc#find() abort
let path = expand('<cfile>')
let [line, col] = [0, 0]
if path =~# '\v:\d+%(:\d+)?:?$'
let line = matchstr(path, '\v\d+\ze%(:\d+)?:?$')
let col = matchstr(path, '\v:\d+:\zs\d+\ze:?$')
let path = matchstr(path, '\v.{-}\ze:\d+%(:\d+)?:?$')
endif
if path =~# '^file://'
let path = substitute(path, '^file://', '', '')
endif
return {
\ 'path': path,
\ 'line': line,
\ 'col': empty(col) ? 0 : col,
\ }
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment