diff --git a/etc/soft/nvim/+plugins/vim-startify/README.md b/etc/soft/nvim/+plugins/vim-startify/README.md index 6ca7393..913628e 100644 --- a/etc/soft/nvim/+plugins/vim-startify/README.md +++ b/etc/soft/nvim/+plugins/vim-startify/README.md @@ -37,6 +37,9 @@ documentation for further customization: :h startify :h startify-faq +If you want to share anything with your fellow plugin users, make sure to visit +the [wiki](https://github.com/mhinz/vim-startify/wiki). + ## Screenshot ![Startify in action!](https://github.com/mhinz/vim-startify/blob/master/images/startify-menu.png) diff --git a/etc/soft/nvim/+plugins/vim-startify/autoload/startify.vim b/etc/soft/nvim/+plugins/vim-startify/autoload/startify.vim index 024a5bf..3b9867a 100644 --- a/etc/soft/nvim/+plugins/vim-startify/autoload/startify.vim +++ b/etc/soft/nvim/+plugins/vim-startify/autoload/startify.vim @@ -67,11 +67,13 @@ function! startify#insane_in_the_membrane(on_vimenter) abort \ colorcolumn= \ foldcolumn=0 \ matchpairs= + \ modifiable \ nobuflisted \ nocursorcolumn \ nocursorline \ nolist \ nonumber + \ noreadonly \ norelativenumber \ nospell \ noswapfile @@ -97,14 +99,14 @@ function! startify#insane_in_the_membrane(on_vimenter) abort \ 'tick': 0, \ } - if s:show_special - call append('$', [s:padding_left .'[e] ', '']) + if g:startify_enable_special + call append('$', [s:leftpad .'[e] ', '']) endif call s:register(line('$')-1, 'e', 'special', 'enew', '') let b:startify.entry_number = 0 if filereadable('Session.vim') - call append('$', [s:padding_left .'[0] '. getcwd() . s:sep .'Session.vim', '']) + call append('$', [s:leftpad .'[0] '. getcwd() . s:sep .'Session.vim', '']) call s:register(line('$')-1, '0', 'session', \ 'call startify#session_delete_buffers() | source', 'Session.vim') let b:startify.entry_number = 1 @@ -122,8 +124,8 @@ function! startify#insane_in_the_membrane(on_vimenter) abort silent $delete _ - if s:show_special - call append('$', ['', s:padding_left .'[q] ']) + if g:startify_enable_special + call append('$', ['', s:leftpad .'[q] ']) call s:register(line('$'), 'q', 'special', 'call s:close()', '') else " Don't overwrite the last regular entry, thus +1 @@ -134,7 +136,7 @@ function! startify#insane_in_the_membrane(on_vimenter) abort let b:startify.firstline = 2 let b:startify.firstline += len(g:startify_header) " no special, no local Session.vim, but a section header - if !s:show_special && !exists('l:show_session') && has_key(lists[0], 'header') + if !g:startify_enable_special && !exists('l:show_session') && has_key(lists[0], 'header') let b:startify.firstline += len(lists[0].header) + 1 endif @@ -150,6 +152,8 @@ function! startify#insane_in_the_membrane(on_vimenter) abort setlocal nomodifiable nomodified + call s:hide_endofbuffer_markers() + call s:set_mappings() call cursor(b:startify.firstline, 5) autocmd startify CursorMoved call s:set_cursor() @@ -431,14 +435,14 @@ endfunction " Function: #pad {{{1 function! startify#pad(lines) abort - return map(copy(a:lines), 's:padding_left . v:val') + return map(copy(a:lines), 's:leftpad . v:val') endfunction " Function: #center {{{1 function! startify#center(lines) abort let longest_line = max(map(copy(a:lines), 'strwidth(v:val)')) return map(copy(a:lines), - \ 'repeat(" ", (&columns / 2) - (longest_line / 2) - 1) . v:val') + \ 'repeat(" ", (winwidth(0) / 2) - (longest_line / 2) - 1) . v:val') endfunction " Function: s:get_lists {{{1 @@ -464,11 +468,11 @@ function! s:get_lists() abort return lists else return [ - \ { 'header': [s:padding_left .'MRU'], 'type': 'files' }, - \ { 'header': [s:padding_left .'MRU '. getcwd()], 'type': 'dir' }, - \ { 'header': [s:padding_left .'Sessions'], 'type': 'sessions' }, - \ { 'header': [s:padding_left .'Bookmarks'], 'type': 'bookmarks' }, - \ { 'header': [s:padding_left .'Commands'], 'type': 'commands' }, + \ { 'header': [s:leftpad .'MRU'], 'type': 'files' }, + \ { 'header': [s:leftpad .'MRU '. getcwd()], 'type': 'dir' }, + \ { 'header': [s:leftpad .'Sessions'], 'type': 'sessions' }, + \ { 'header': [s:leftpad .'Bookmarks'], 'type': 'bookmarks' }, + \ { 'header': [s:leftpad .'Commands'], 'type': 'commands' }, \ ] endif endfunction @@ -509,7 +513,7 @@ function! s:show_lists(lists) abort let path = get(entry, 'path', '') let type = get(entry, 'type', empty(path) ? 'special' : 'file') let index = s:get_index_as_string() - call append('$', s:padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . entry.line) + call append('$', s:leftpad .'['. index .']'. repeat(' ', (3 - strlen(index))) . entry.line) call s:register(line('$'), index, type, cmd, path) endfor call append('$', '') @@ -556,12 +560,8 @@ function! s:display_by_path(path_prefix, path_format, use_env) abort let oldfiles = call(get(g:, 'startify_enable_unsafe') ? 's:filter_oldfiles_unsafe' : 's:filter_oldfiles', \ [a:path_prefix, a:path_format, a:use_env]) - let entry_format = "s:padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) ." - if exists('*StartifyEntryFormat') - let entry_format .= StartifyEntryFormat() - else - let entry_format .= 'entry_path' - endif + let entry_format = "s:leftpad .'['. index .']'. repeat(' ', (3 - strlen(index))) ." + let entry_format .= exists('*StartifyEntryFormat') ? StartifyEntryFormat() : 'entry_path' if !empty(oldfiles) if exists('s:last_message') @@ -584,7 +584,7 @@ endfunction " Function: s:filter_oldfiles {{{1 function! s:filter_oldfiles(path_prefix, path_format, use_env) abort let path_prefix = '\V'. escape(a:path_prefix, '\') - let counter = s:numfiles + let counter = g:startify_files_number let entries = {} let oldfiles = [] @@ -598,7 +598,12 @@ function! s:filter_oldfiles(path_prefix, path_format, use_env) abort continue endif - let absolute_path = fnamemodify(resolve(fname), ":p") + try + let absolute_path = fnamemodify(resolve(fname), ":p") + catch /E655/ " Too many symbolic links (cycle?) + call s:warn('Symlink loop detected! Skipping: '. fname) + continue + endtry " filter duplicates, bookmarks and entries from the skiplist if has_key(entries, absolute_path) \ || !filereadable(absolute_path) @@ -608,7 +613,7 @@ function! s:filter_oldfiles(path_prefix, path_format, use_env) abort endif let entry_path = '' - if s:tf + if !empty(g:startify_transformations) let entry_path = s:transform(absolute_path) endif if empty(entry_path) @@ -639,7 +644,7 @@ endfunction " Function: s:filter_oldfiles_unsafe {{{1 function! s:filter_oldfiles_unsafe(path_prefix, path_format, use_env) abort let path_prefix = '\V'. escape(a:path_prefix, '\') - let counter = s:numfiles + let counter = g:startify_files_number let entries = {} let oldfiles = [] let is_dir = escape(s:sep, '\') . '$' @@ -679,7 +684,7 @@ endfunction " Function: s:show_files {{{1 function! s:show_files() abort - return s:display_by_path('', s:relative_path, get(g:, 'startify_use_env')) + return s:display_by_path('', g:startify_relative_path, get(g:, 'startify_use_env')) endfunction " Function: s:show_sessions {{{1 @@ -717,7 +722,7 @@ function! s:show_sessions() abort let index = s:get_index_as_string() let fname = fnamemodify(sfiles[i], ':t') let dname = sfiles[i] ==# v:this_session ? fname.' (*)' : fname - call append('$', s:padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . dname) + call append('$', s:leftpad .'['. index .']'. repeat(' ', (3 - strlen(index))) . dname) if has('win32') let fname = substitute(fname, '\[', '\[[]', 'g') endif @@ -740,6 +745,9 @@ function! s:show_bookmarks() abort call s:print_section_header() endif + let entry_format = "s:leftpad .'['. index .']'. repeat(' ', (3 - strlen(index))) ." + let entry_format .= exists('*StartifyEntryFormat') ? StartifyEntryFormat() : 'entry_path' + for bookmark in g:startify_bookmarks if type(bookmark) == type({}) let [index, path] = items(bookmark)[0] @@ -747,14 +755,17 @@ function! s:show_bookmarks() abort let [index, path] = [s:get_index_as_string(), bookmark] endif + let absolute_path = path + let entry_path = '' - if s:tf + if !empty(g:startify_transformations) let entry_path = s:transform(fnamemodify(resolve(expand(path)), ':p')) endif if empty(entry_path) let entry_path = path endif - call append('$', s:padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . entry_path) + + call append('$', eval(entry_format)) if has('win32') let path = substitute(path, '\[', '\[[]', 'g') @@ -787,7 +798,7 @@ function! s:show_commands() abort " If no list is given, the description is the command itself. let [desc, cmd] = type(command) == type([]) ? command : [command, command] - call append('$', s:padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . desc) + call append('$', s:leftpad .'['. index .']'. repeat(' ', (3 - strlen(index))) . desc) call s:register(line('$'), index, 'special', cmd, '') unlet entry command @@ -798,7 +809,7 @@ endfunction " Function: s:is_in_skiplist {{{1 function! s:is_in_skiplist(arg) abort - for regexp in s:skiplist + for regexp in g:startify_skiplist try if a:arg =~# regexp return 1 @@ -811,7 +822,7 @@ endfunction " Function: s:set_cursor {{{1 function! s:set_cursor() abort - let b:startify.oldline = exists('b:startify.newline') ? b:startify.newline : 2 + len(s:padding_left) + let b:startify.oldline = exists('b:startify.newline') ? b:startify.newline : s:fixed_column let b:startify.newline = line('.') " going up (-1) or down (1) @@ -912,18 +923,24 @@ function! startify#set_mark(type, ...) abort let index = expand('') setlocal modifiable + " https://github.com/vim/vim/issues/8053 + let showmatch = &showmatch + let &showmatch = 0 + if entry.marked && index[0] == a:type let entry.cmd = 'edit' let entry.marked = 0 - execute 'normal! ci]'. entry.index + execute 'normal! "_ci]'. entry.index else let entry.cmd = default_cmds[a:type] let entry.marked = 1 let entry.tick = b:startify.tick let b:startify.tick += 1 - execute 'normal! ci]'. repeat(a:type, len(index)) + execute 'normal! "_ci]'. repeat(a:type, len(index)) endif + let &showmatch = showmatch + setlocal nomodifiable nomodified " Reset cursor to fixed column, which is important for s:set_cursor(). call cursor(origline, s:fixed_column) @@ -951,11 +968,11 @@ function! s:check_user_options(path) abort if get(g:, 'startify_change_to_dir', 1) if isdirectory(a:path) - execute 'lcd' a:path + execute s:cd_cmd() a:path else let dir = fnamemodify(a:path, ':h') if isdirectory(dir) - execute 'lcd' dir + execute s:cd_cmd() dir else " Do nothing. E.g. a:path == `scp://foo/bar` endif @@ -969,13 +986,23 @@ function! s:cd_to_vcs_root(path) abort for vcs in [ '.git', '.hg', '.bzr', '.svn' ] let root = finddir(vcs, dir .';') if !empty(root) - execute 'lcd' fnameescape(fnamemodify(root, ':h')) + execute s:cd_cmd() fnameescape(fnamemodify(root, ':h')) return 1 endif endfor return 0 endfunction +" Function: s:cd_cmd {{{1 +function! s:cd_cmd() abort + let g:startify_change_cmd = get(g:, 'startify_change_cmd', 'lcd') + if g:startify_change_cmd !~# '^[lt]\?cd$' + call s:warn('Invalid value for g:startify_change_cmd. Defaulting to :lcd') + let g:startify_change_cmd = 'lcd' + endif + return g:startify_change_cmd +endfunction + " Function: s:close {{{1 function! s:close() abort if len(filter(range(0, bufnr('$')), 'buflisted(v:val)')) - &buflisted @@ -1040,7 +1067,7 @@ function! s:create_last_session_link(session_path) let cmd = printf('ln -sf %s %s', \ shellescape(fnamemodify(a:session_path, ':t')), \ shellescape(s:session_dir .'/__LAST__')) - call system(cmd) + silent call system(cmd) if v:shell_error call s:warn("Can't create 'last used session' symlink.") endif @@ -1056,13 +1083,24 @@ function! s:init_env() \ 'PWD': 1, \ } - function! s:get_env() + if exists('*environ') + let env = items(environ()) + else redir => s silent! execute "norm!:ec$\'\\\\'\" redir END redraw - return split(s) - endfunction + let env = map(split(s), '[v:val, eval("$".v:val)]') + endif + + for [var, val] in env + if has('win32') ? (val[1] != ':') : (val[0] != '/') + \ || has_key(ignore, var) + \ || len(var) > len(val) + continue + endif + call insert(s:env, [var, val], 0) + endfor function! s:compare_by_key_len(foo, bar) return len(a:foo[0]) - len(a:bar[0]) @@ -1071,16 +1109,6 @@ function! s:init_env() return len(a:bar[1]) - len(a:foo[1]) endfunction - for k in s:get_env() - silent! execute "let v = eval('$'.k)" - if has('win32') ? (v[1] != ':') : (v[0] != '/') - \ || has_key(ignore, k) - \ || len(k) > len(v) - continue - endif - call insert(s:env, [k,v], 0) - endfor - let s:env = sort(s:env, 's:compare_by_key_len') let s:env = sort(s:env, 's:compare_by_val_len') endfunction @@ -1096,6 +1124,24 @@ function s:transform(absolute_path) return '' endfunction +" Function: s:hide_endofbuffer_markers {{{1 +" Use the bg color of Normal to set the fg color of EndOfBuffer, effectively +" hiding it. +function! s:hide_endofbuffer_markers() + if !exists('+winhl') + return + endif + let val = synIDattr(hlID('Normal'), 'bg') + if empty(val) + return + elseif val =~ '^\d*$' + execute 'highlight StartifyEndOfBuffer ctermfg='. val + else + execute 'highlight StartifyEndOfBuffer guifg='. val + endif + setlocal winhighlight=EndOfBuffer:StartifyEndOfBuffer +endfunction + " Function: s:warn {{{1 function! s:warn(msg) abort echohl WarningMsg @@ -1106,21 +1152,22 @@ endfunction " Init: values {{{1 let s:sep = startify#get_separator() -let s:numfiles = get(g:, 'startify_files_number', 10) -let s:show_special = get(g:, 'startify_enable_special', 1) -let s:relative_path = get(g:, 'startify_relative_path') ? ':~:.' : ':p:~' -let s:tf = exists('g:startify_transformations') +let g:startify_files_number = get(g:, 'startify_files_number', 10) +let g:startify_enable_special = get(g:, 'startify_enable_special', 1) +let g:startify_relative_path = get(g:, 'startify_relative_path') ? ':~:.' : ':p:~' let s:session_dir = startify#get_session_path() +let g:startify_transformations = get(g:, 'startify_transformations', []) -let s:skiplist = get(g:, 'startify_skiplist', [ - \ 'runtime/doc/.*\.txt', - \ 'bundle/.*/doc/.*\.txt', - \ 'plugged/.*/doc/.*\.txt', +let g:startify_skiplist = extend(get(g:, 'startify_skiplist', []), [ + \ 'runtime/doc/.*\.txt$', + \ 'bundle/.*/doc/.*\.txt$', + \ 'plugged/.*/doc/.*\.txt$', \ '/.git/', \ 'fugitiveblame$', - \ escape(fnamemodify(resolve($VIMRUNTIME), ':p'), '\') .'doc/.*\.txt', - \ ]) + \ escape(fnamemodify(resolve($VIMRUNTIME), ':p'), '\') .'doc/.*\.txt$', + \ ], 'keep') -let s:padding_left = repeat(' ', get(g:, 'startify_padding_left', 3)) -let s:fixed_column = len(s:padding_left) + 2 +let g:startify_padding_left = get(g:, 'startify_padding_left', 3) +let s:leftpad = repeat(' ', g:startify_padding_left) +let s:fixed_column = g:startify_padding_left + 2 let s:batchmode = '' diff --git a/etc/soft/nvim/+plugins/vim-startify/autoload/startify/fortune.vim b/etc/soft/nvim/+plugins/vim-startify/autoload/startify/fortune.vim index 9745c37..21fff81 100644 --- a/etc/soft/nvim/+plugins/vim-startify/autoload/startify/fortune.vim +++ b/etc/soft/nvim/+plugins/vim-startify/autoload/startify/fortune.vim @@ -22,7 +22,7 @@ endfunction " Function: #quote {{{1 function! startify#fortune#quote() abort - return s:quotes[s:get_random_offset(len(s:quotes))] + return g:startify_custom_header_quotes[s:get_random_offset(len(g:startify_custom_header_quotes))] endfunction " Function: #boxed {{{1 @@ -73,14 +73,14 @@ let s:cow = [ \ ' || ||', \ ] -let s:unicode = &encoding == 'utf-8' && get(g:, 'startify_fortune_use_unicode') +let g:startify_fortune_use_unicode = &encoding == 'utf-8' && get(g:, 'startify_fortune_use_unicode') -let s:char_top_bottom = ['-', '─'][s:unicode] -let s:char_sides = ['|', '│'][s:unicode] -let s:char_top_left = ['*', '╭'][s:unicode] -let s:char_top_right = ['*', '╮'][s:unicode] -let s:char_bottom_right = ['*', '╯'][s:unicode] -let s:char_bottom_left = ['*', '╰'][s:unicode] +let s:char_top_bottom = ['-', '─'][g:startify_fortune_use_unicode] +let s:char_sides = ['|', '│'][g:startify_fortune_use_unicode] +let s:char_top_left = ['*', '╭'][g:startify_fortune_use_unicode] +let s:char_top_right = ['*', '╮'][g:startify_fortune_use_unicode] +let s:char_bottom_right = ['*', '╯'][g:startify_fortune_use_unicode] +let s:char_bottom_left = ['*', '╰'][g:startify_fortune_use_unicode] let s:predefined_quotes = [ \ ["Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.", '', '- Brian Kernighan'], @@ -238,6 +238,6 @@ let s:predefined_quotes = [ \ ['What one programmer can do in one month, two programmers can do in two months.', '', '- Frederick P. Brooks'], \ ] -let s:quotes = exists('g:startify_custom_header_quotes') +let g:startify_custom_header_quotes = exists('g:startify_custom_header_quotes') \ ? g:startify_custom_header_quotes \ : startify#fortune#predefined_quotes() diff --git a/etc/soft/nvim/+plugins/vim-startify/doc/startify.txt b/etc/soft/nvim/+plugins/vim-startify/doc/startify.txt index 5de7280..1581b78 100644 --- a/etc/soft/nvim/+plugins/vim-startify/doc/startify.txt +++ b/etc/soft/nvim/+plugins/vim-startify/doc/startify.txt @@ -101,6 +101,7 @@ default values. |g:startify_bookmarks| |g:startify_change_to_dir| |g:startify_change_to_vcs_root| + |g:startify_change_cmd| |g:startify_custom_header| |g:startify_enable_special| |g:startify_list_order| @@ -328,10 +329,7 @@ This is a list of commands to be executed before saving a session. Example: > - let g:startify_session_before_save = [ - \ 'echo "Cleaning up before saving.."', - \ 'silent! NERDTreeTabsClose' - \ ] + let g:startify_session_before_save = [ 'silent! tabdo NERDTreeClose' ] < ------------------------------------------------------------------------------ *g:startify_session_persistence* @@ -368,6 +366,11 @@ NOTE: Buffers with unsaved changes are silently ignored. < When opening a file or bookmark, change to its directory. +You want to disable this, if you're using |'autochdir'| as well. + +NOTE: It defaults to 1, because that was already the behaviour at the time +this option was introduced. + ------------------------------------------------------------------------------ *g:startify_change_to_vcs_root* > @@ -379,22 +382,42 @@ VCS (if there is one). At the moment only git, hg, bzr and svn are supported. ------------------------------------------------------------------------------ + *g:startify_change_cmd* +> + let g:startify_change_cmd = 'lcd' +< +The default command for switching directories. Valid values: + + 'cd' (|:cd|) + 'lcd' (|:lcd|) + 'tcd' (|:tcd|) + +Affects |g:startify_change_to_dir| and |g:startify_change_to_vcs_root|. + +------------------------------------------------------------------------------ *g:startify_skiplist* > - let g:startify_skiplist = [ - \ 'COMMIT_EDITMSG', - \ escape(fnamemodify(resolve($VIMRUNTIME), ':p'), '\') .'doc', - \ 'bundle/.*/doc', - \ ] + let g:startify_skiplist = [] < A list of Vim regular expressions that is used to filter recently used files. See |pattern.txt| for what patterns can be used. +The following patterns are filtered by default: + + 'runtime/doc/.*\.txt$' + 'bundle/.*/doc/.*\.txt$' + 'plugged/.*/doc/.*\.txt$' + '/.git/' + 'fugitiveblame$' + escape(fnamemodify(resolve($VIMRUNTIME), ':p'), '\') .'doc/.*\.txt$' + NOTE: Due to the nature of patterns, you can't just use "~/mysecret" but have to use "$HOME .'/mysecret.txt'". The former would do something entirely -different: |/\~|. When using backslashes as path separators, escape them. -Otherwise using "C:\this\vim\path\is\problematic" would not match what you -expect, since |/\v| is a pattern, too. +different: |/\~|. + +NOTE: When using backslashes as path separators, escape them. Otherwise using +"C:\this\vim\path\is\problematic" would not match what you would expect, since +|/\v| is a pattern, too. Example: >