To my knowledge there doesn't exist a Vim function that accomplishes what you're asking for. But I came up with my s:Get_file_perm function whose result I assign to the w:file_perm variable:
" ...
let w:file_perm=<sid>Get_file_perm()
" ...
function! s:Get_file_perm()
let a=getfperm(expand('%:p'))
if strlen(a)
return a
else
let b=printf("%o", xor(0777,system("umask")))
let c=""
for d in [0, 1, 2]
let c.=and(b[d], 4) ? "r" : "-"
let c.=and(b[d], 2) ? "w" : "-"
let c.=and(b[d], 1) ? "x" : "-"
endfor
return c
endif
endfunction
The function checks (if) to see if the permissions (getfperm) for the current file path ('%:p') exist (strlen). In the case of a new file ("") the else-block bitwise subtracts (xor) the octal umask from the octal literal 0777 (rwxrwxrwx) – all permission bits set.
For the owner- (0) , group- (1) and permissions for others (2) it iteratively (for) checks for each read- (4), write- (2) and execute (1) bit that it is set (and). If the corresponding bit is set it appends (.=) "r", "w" and "x" to the c variable, respectively. Else "-" is appended to symbolize that the respective operation is not permitted.
%:pjust return the directory the file is currently in? Try just%, instead. Also, what's wrong with (from command mode)::!ls -l %– Alex Leach Dec 12 '12 at 18:27autochdiroption enabledexpand('%')expands only to the file'sbasename. With the:pmodifier the absolute path is coerced.:h expandis your friend. – Tim Friske Dec 12 '12 at 20:16