Ver Fonte

New option: g:startify_mapping_nowait

This option forces the use of <nowait> mappings.

This might be useful if you have global mappings that start with the same
characters as indexes from Startify.

References #180
Closes #186.
somini há 10 anos atrás
pai
commit
5b43cef057
2 ficheiros alterados com 21 adições e 4 exclusões
  1. 6 4
      autoload/startify.vim
  2. 15 0
      doc/startify.txt

+ 6 - 4
autoload/startify.vim

@@ -12,6 +12,7 @@ let g:autoloaded_startify = 1
 " Init: values {{{1
 let s:numfiles       = get(g:, 'startify_files_number', 10)
 let s:show_special   = get(g:, 'startify_enable_special', 1)
+let s:nowait         = get(g:, 'startify_mapping_nowait')
 let s:delete_buffers = get(g:, 'startify_session_delete_buffers')
 let s:relative_path  = get(g:, 'startify_relative_path') ? ':.' : ':p:~'
 let s:session_dir    = resolve(expand(get(g:, 'startify_session_dir',
@@ -81,7 +82,8 @@ function! startify#insane_in_the_membrane() abort
   if filereadable('Session.vim')
     call append('$', ['   [0]  '. getcwd() . s:sep .'Session.vim', ''])
     call s:register(line('$')-1, '0', 'session',
-          \ 'call startify#session_delete_buffers() | source', 'Session.vim')
+          \ 'call startify#session_delete_buffers() | source', 'Session.vim',
+          \ s:nowait)
     let s:entry_number = 1
     let l:show_session = 1
   endif
@@ -433,7 +435,7 @@ function! s:display_by_path(path_prefix, path_format) abort
       if has('win32')
         let absolute_path = substitute(absolute_path, '\[', '\[[]', 'g')
       endif
-      call s:register(line('$'), index, 'file', 'edit', absolute_path)
+      call s:register(line('$'), index, 'file', 'edit', absolute_path, s:nowait)
       let s:entry_number += 1
     endfor
 
@@ -533,7 +535,7 @@ function! s:show_sessions() abort
     if has('win32')
       let fname = substitute(fname, '\[', '\[[]', 'g')
     endif
-    call s:register(line('$'), index, 'session', 'SLoad', fname)
+    call s:register(line('$'), index, 'session', 'SLoad', fname, s:nowait)
     let s:entry_number += 1
   endfor
 
@@ -561,7 +563,7 @@ function! s:show_bookmarks() abort
     if has('win32')
       let fname = substitute(fname, '\[', '\[[]', 'g')
     endif
-    call s:register(line('$'), index, 'file', 'edit', fname)
+    call s:register(line('$'), index, 'file', 'edit', fname, s:nowait)
     unlet bookmark  " avoid type mismatch for heterogeneous lists
   endfor
 

+ 15 - 0
doc/startify.txt

@@ -98,6 +98,7 @@ default values.
     |g:startify_enable_unsafe|
     |g:startify_files_number|
     |g:startify_list_order|
+    |g:startify_mapping_nowait|
     |g:startify_relative_path|
     |g:startify_session_autoload|
     |g:startify_session_delete_buffers|
@@ -464,6 +465,20 @@ Show filenames relative to the current working directory instead of as
 absolute paths. This only applies to the "files" list, since the "dir" list is
 relative by nature.
 
+-----------------------------------------------------------------------------
+                                                    *g:startify_mapping_nowait*
+>
+    let g:startify_mapping_nowait = 0
+<
+Force the usage of |<nowait>| in all mappings.
+
+This helps guarding against global mappings that start with the same
+characters as a Startify index, but might break local mappings, e.g. when you
+have indexes "1" and "11", the "11" won't be accessable anymore, since "1"
+will be opened right way.
+
+Only use this when you know what you're doing.
+
 ==============================================================================
 AUTOCMD                                                       *startify-autocmd*