Add g:startify_transformations
This commit is contained in:
parent
5bef697e17
commit
ffb80ec99e
|
@ -25,6 +25,17 @@ let s:skiplist = get(g:, 'startify_skiplist', [
|
||||||
\ 'bundle/.*/doc',
|
\ 'bundle/.*/doc',
|
||||||
\ ])
|
\ ])
|
||||||
|
|
||||||
|
let s:transformations = {}
|
||||||
|
if exists('g:startify_transformations')
|
||||||
|
for [k,V] in items(g:startify_transformations)
|
||||||
|
call extend(s:transformations, { fnamemodify(resolve(expand(k)), ':p'): V })
|
||||||
|
unlet V " avoid type mismatch dict <-> string
|
||||||
|
endfor
|
||||||
|
let s:tf = 1
|
||||||
|
else
|
||||||
|
let s:tf = 0
|
||||||
|
endif
|
||||||
|
|
||||||
" Function: #get_separator {{{1
|
" Function: #get_separator {{{1
|
||||||
function! startify#get_separator() abort
|
function! startify#get_separator() abort
|
||||||
return !exists('+shellslash') || &shellslash ? '/' : '\'
|
return !exists('+shellslash') || &shellslash ? '/' : '\'
|
||||||
|
@ -483,7 +494,10 @@ function! s:filter_oldfiles(path_prefix, path_format, use_env) abort
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let entry_path = fnamemodify(absolute_path, a:path_format)
|
let entry_path = s:tf
|
||||||
|
\ ? s:transform(absolute_path)
|
||||||
|
\ : fnamemodify(absolute_path, a:path_format)
|
||||||
|
|
||||||
let entries[absolute_path] = 1
|
let entries[absolute_path] = 1
|
||||||
let counter -= 1
|
let counter -= 1
|
||||||
let oldfiles += [[fnameescape(absolute_path), entry_path]]
|
let oldfiles += [[fnameescape(absolute_path), entry_path]]
|
||||||
|
@ -584,17 +598,25 @@ function! s:show_bookmarks() abort
|
||||||
endif
|
endif
|
||||||
|
|
||||||
for bookmark in g:startify_bookmarks
|
for bookmark in g:startify_bookmarks
|
||||||
if type(bookmark) == 4 " dict?
|
if type(bookmark) == type({})
|
||||||
let [index, fname] = items(bookmark)[0]
|
let [index, path] = items(bookmark)[0]
|
||||||
else " string
|
else " string
|
||||||
let [index, fname] = [s:get_index_as_string(s:entry_number), bookmark]
|
let [index, path] = [s:get_index_as_string(s:entry_number), bookmark]
|
||||||
let s:entry_number += 1
|
let s:entry_number += 1
|
||||||
endif
|
endif
|
||||||
call append('$', ' ['. index .']'. repeat(' ', (3 - strlen(index))) . fname)
|
|
||||||
if has('win32')
|
if s:tf
|
||||||
let fname = substitute(fname, '\[', '\[[]', 'g')
|
let entry_path = s:transform(fnamemodify(resolve(expand(path)), ':p'))
|
||||||
|
else
|
||||||
|
let entry_path = path
|
||||||
endif
|
endif
|
||||||
call s:register(line('$'), index, 'file', 'edit', fname, s:nowait)
|
call append('$', ' ['. index .']'. repeat(' ', (3 - strlen(index))) . entry_path)
|
||||||
|
|
||||||
|
if has('win32')
|
||||||
|
let path = substitute(path, '\[', '\[[]', 'g')
|
||||||
|
endif
|
||||||
|
call s:register(line('$'), index, 'file', 'edit', path, s:nowait)
|
||||||
|
|
||||||
unlet bookmark " avoid type mismatch for heterogeneous lists
|
unlet bookmark " avoid type mismatch for heterogeneous lists
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
@ -833,3 +855,12 @@ function! s:init_env()
|
||||||
let s:env = sort(s:env, 's:compare_by_val_len')
|
let s:env = sort(s:env, 's:compare_by_val_len')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Function: s:transform {{{1
|
||||||
|
function s:transform(absolute_path)
|
||||||
|
if has_key(s:transformations, a:absolute_path)
|
||||||
|
let V = s:transformations[a:absolute_path]
|
||||||
|
return type(V) == type('') ? V : V(a:absolute_path)
|
||||||
|
endif
|
||||||
|
return a:absolute_path
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue