diff options
Diffstat (limited to 'autoload/ale/path.vim')
-rw-r--r-- | autoload/ale/path.vim | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/autoload/ale/path.vim b/autoload/ale/path.vim index 45da3709..89b119f4 100644 --- a/autoload/ale/path.vim +++ b/autoload/ale/path.vim @@ -65,7 +65,11 @@ endfunction " Output 'cd <directory> && ' " This function can be used changing the directory for a linter command. function! ale#path#CdString(directory) abort - return 'cd ' . ale#Escape(a:directory) . ' && ' + if has('win32') + return 'cd /d ' . ale#Escape(a:directory) . ' && ' + else + return 'cd ' . ale#Escape(a:directory) . ' && ' + endif endfunction " Output 'cd <buffer_filename_directory> && ' @@ -105,6 +109,21 @@ function! ale#path#GetAbsPath(base_directory, filename) abort return ale#path#Simplify(a:base_directory . l:sep . a:filename) endfunction +" Given a path, return the directory name for that path, with no trailing +" slashes. If the argument is empty(), return an empty string. +function! ale#path#Dirname(path) abort + if empty(a:path) + return '' + endif + + " For /foo/bar/ we need :h:h to get /foo + if a:path[-1:] is# '/' + return fnamemodify(a:path, ':h:h') + endif + + return fnamemodify(a:path, ':h') +endfunction + " Given a buffer number and a relative or absolute path, return 1 if the " two paths represent the same file on disk. function! ale#path#IsBufferPath(buffer, complex_filename) abort |