]> Sergey Matveev's repositories - dotfiles.git/blobdiff - vim/.vim/plugin/whereami.vim
Symbolic links friendly WhereAmI
[dotfiles.git] / vim / .vim / plugin / whereami.vim
index 71367936c61dc074e9cc6a329f63b99baf00e787..f3a4f3c94d94c1b80b20f0f7e998e4163598f189 100644 (file)
@@ -1,7 +1,28 @@
-function! WhereAmI()
-    let where = expand('%:p') . ":" . line('.')
+if exists("g:loaded_mein_whereami") | finish | endif
+let g:loaded_mein_whereami = 1
+
+function! s:pwdLoad()
+    let g:mein_pwdL=trim(system("pwd -L"))
+    let g:mein_pwdP=trim(system("pwd -P"))
+endfunction
+
+autocmd VimEnter * call s:pwdLoad()
+
+function! WhereAmI(fmt)
+    let fullpath = expand("%:p")
+    if fullpath[:len(g:mein_pwdP)-1] ==# g:mein_pwdP
+        let fullpath = g:mein_pwdL . fullpath[len(g:mein_pwdP):]
+    endif
+    if a:fmt == "gnu"
+        let where = fullpath . ":" . line(".")
+    elseif a:fmt == "lldb"
+        let where = "breakpoint set --file " . fullpath . " --line " . line(".")
+    else
+        let where = "unknown fmt"
+    endif
     let @* = where
     echomsg where
 endfunction
 
-nmap <leader>w :call WhereAmI()<CR>
+nmap <leader>w :call WhereAmI("gnu")<CR>
+nmap <leader>W :call WhereAmI("lldb")<CR>