]> Sergey Matveev's repositories - dotfiles.git/blob - vim/.vim/plugin/whereami.vim
f3a4f3c94d94c1b80b20f0f7e998e4163598f189
[dotfiles.git] / vim / .vim / plugin / whereami.vim
1 if exists("g:loaded_mein_whereami") | finish | endif
2 let g:loaded_mein_whereami = 1
3
4 function! s:pwdLoad()
5     let g:mein_pwdL=trim(system("pwd -L"))
6     let g:mein_pwdP=trim(system("pwd -P"))
7 endfunction
8
9 autocmd VimEnter * call s:pwdLoad()
10
11 function! WhereAmI(fmt)
12     let fullpath = expand("%:p")
13     if fullpath[:len(g:mein_pwdP)-1] ==# g:mein_pwdP
14         let fullpath = g:mein_pwdL . fullpath[len(g:mein_pwdP):]
15     endif
16     if a:fmt == "gnu"
17         let where = fullpath . ":" . line(".")
18     elseif a:fmt == "lldb"
19         let where = "breakpoint set --file " . fullpath . " --line " . line(".")
20     else
21         let where = "unknown fmt"
22     endif
23     let @* = where
24     echomsg where
25 endfunction
26
27 nmap <leader>w :call WhereAmI("gnu")<CR>
28 nmap <leader>W :call WhereAmI("lldb")<CR>