Use relative paths when previewing file locations (#2238)

* Use relative paths when previewing file locations

Example: ALEFindReferences -relative
This commit is contained in:
Alvin Chan
2019-01-27 02:18:20 -08:00
committed by w0rp
parent b8bf7b220d
commit 6288c8b08e
4 changed files with 59 additions and 16 deletions

View File

@@ -41,16 +41,23 @@ endfunction
" Show a location selection preview window, given some items.
" Each item should have 'filename', 'line', and 'column' keys.
function! ale#preview#ShowSelection(item_list) abort
function! ale#preview#ShowSelection(item_list, ...) abort
let l:options = get(a:000, 0, {})
let l:sep = has('win32') ? '\' : '/'
let l:lines = []
" Create lines to display to users.
for l:item in a:item_list
let l:match = get(l:item, 'match', '')
let l:filename = l:item.filename
if get(l:options, 'use_relative_paths')
let l:filename = substitute(l:item.filename, '^' . getcwd() . l:sep, '', '') " no-custom-checks
endif
call add(
\ l:lines,
\ l:item.filename
\ l:filename
\ . ':' . l:item.line
\ . ':' . l:item.column
\ . (!empty(l:match) ? ' ' . l:match : ''),