File tree Expand file tree Collapse file tree
autoload/vital/__vital__/System Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -197,12 +197,23 @@ function! s:is_case_tolerant() abort
197197endfunction
198198
199199
200+ function ! s: expand_home (path ) abort
201+ if a: path [:0 ] !=# ' ~'
202+ return a: path
203+ endif
204+ let post_home_idx = match (a: path , s: path_sep_pattern )
205+ return post_home_idx is # -1
206+ \ ? s: remove_last_separator (expand (a: path ))
207+ \ : s: remove_last_separator (expand (a: path [0 : post_home_idx - 1 ]))
208+ \ . a: path [post_home_idx :]
209+ endfunction
210+
200211function ! s: abspath (path ) abort
201212 if s: is_absolute (a: path )
202213 return a: path
203214 endif
204- " Note:
205- " the behavior of ':p' for non existing file path/directory is not defined
215+ " NOTE: The behavior of ':p' for a non existing file/directory path
216+ " is not defined.
206217 return (filereadable (a: path ) || isdirectory (a: path ))
207218 \ ? fnamemodify (a: path , ' :p' )
208219 \ : s: join (fnamemodify (getcwd (), ' :p' ), a: path )
Original file line number Diff line number Diff line change @@ -97,6 +97,15 @@ is_case_tolerant() *Vital.System.Filepath.is_case_tolerant()*
9797 Return non-zero if filesystem ignores alphabetic case of a filename,
9898 zero otherwise.
9999
100+ expand_home({path} ) *Vital.System.Filepath.expand_home()*
101+ Return a home-expanded path of {path} . The home directory expansion
102+ will not have a trailing directory separator.
103+
104+ Like | expand() | , but only expanding a leading "~" home directory
105+ sequence, or like | fnamemodify() | with the ":p" modifier, but without
106+ full path expansion or unpredictable results if a file name doesn't
107+ exist and doesn't have an absolute path. See | filename-modifiers | .
108+
100109abspath({path} ) *Vital.System.Filepath.abspath()*
101110 Return an absolute path of {path} .
102111 If the {path} is already an absolute path, it returns the {path} .
You can’t perform that action at this time.
0 commit comments