-function! whereami#pwdLoad()
- let g:whereami_pwdL=trim(system("pwd -L"))
- let g:whereami_pwdP=trim(system("pwd -P"))
-endfunction
+vim9script
-function! whereami#do(fmt) abort
- let fullpath = expand("%:p")
- if fullpath[:len(g:whereami_pwdP)-1] ==# g:whereami_pwdP
- let fullpath = g:whereami_pwdL . fullpath[len(g:whereami_pwdP):]
+export def PwdLoad()
+ g:whereami_pwdL = trim(system("pwd -L"))
+ g:whereami_pwdP = trim(system("pwd -P"))
+enddef
+
+export def Do(fmt: string)
+ var fullpath = expand("%:p")
+ if fullpath[ : len(g:whereami_pwdP) - 1] ==# g:whereami_pwdP
+ fullpath = g:whereami_pwdL .. fullpath[len(g:whereami_pwdP) : ]
endif
- let where = printf(a:fmt, fullpath, line("."))
- let @* = where
+ var where = printf(fmt, fullpath, line("."))
+ @* = where
echomsg where
-endfunction
+enddef