diff options
| author | Max Christian Pohle | 2020-07-17 00:28:51 +0200 |
|---|---|---|
| committer | Max Christian Pohle | 2020-07-17 00:28:51 +0200 |
| commit | 463cab0af26022d8c2cad3760383bcc6f41dd57f (patch) | |
| tree | b43bba4b499b639f29e18e9a0100aacfe6e2b7a4 /plugin/vim-recently-used.vim | |
| parent | 5a8cc26fb5084dc032153d867f8fffe00a477e48 (diff) | |
| download | vim-recently-used-463cab0af26022d8c2cad3760383bcc6f41dd57f.tar.bz2 vim-recently-used-463cab0af26022d8c2cad3760383bcc6f41dd57f.zip | |
Improved README and code comments
Diffstat (limited to 'plugin/vim-recently-used.vim')
| -rw-r--r-- | plugin/vim-recently-used.vim | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/plugin/vim-recently-used.vim b/plugin/vim-recently-used.vim index 48bb5d6..971d592 100644 --- a/plugin/vim-recently-used.vim +++ b/plugin/vim-recently-used.vim | |||
| @@ -1,16 +1,18 @@ | |||
| 1 | "======================================================================================================================= | 1 | "======================================================================================================================= |
| 2 | " MAX_SPLASH: | 2 | " vim-recently-used |
| 3 | " Shows recently used files from the current directory in a location list | 3 | " Shows recently used files from the current directory in a location list |
| 4 | "======================================================================================================================= | 4 | "======================================================================================================================= |
| 5 | 5 | ||
| 6 | command RecentlyUsed call setloclist(0, []) | 6 | " from the list of recent files: make absolute paths, filter out files not |
| 7 | \ | :lopen | 7 | " contained in cwd and finally filter out directories and non-files... |
| 8 | \ | setlocal nospell | 8 | command! RecentlyUsed call setloclist(0, []) |
| 9 | \ | setlocal signcolumn=yes | 9 | \ | :lopen |
| 10 | \ | setfiletype qf | 10 | \ | setlocal nospell |
| 11 | \ | call setloclist(0, [], 'r', { | 11 | \ | setlocal signcolumn=yes |
| 12 | \ 'title':'Recently used files in directory: '.getcwd(), | 12 | \ | setfiletype qf |
| 13 | \ 'items':sort(map(filter(filter(map(copy(v:oldfiles[:100]), | 13 | \ | call setloclist(0, [], 'r', { |
| 14 | \ 'title':'Recently used files in directory: '.getcwd(), | ||
| 15 | \ 'items':sort(map(filter(filter(map(copy(v:oldfiles[:100]), | ||
| 14 | \ {_, p->expand(p)}), | 16 | \ {_, p->expand(p)}), |
| 15 | \ 'v:val =~ "'.getcwd().'/"'), | 17 | \ 'v:val =~ "'.getcwd().'/"'), |
| 16 | \ 'filereadable(v:val)'), | 18 | \ 'filereadable(v:val)'), |
| @@ -22,20 +24,14 @@ command RecentlyUsed call setloclist(0, []) | |||
| 22 | \ fnamemodify(p, ':.') | 24 | \ fnamemodify(p, ':.') |
| 23 | \ )}}), | 25 | \ )}}), |
| 24 | \ {a1, a2 -> a1.module < a2.module}) | 26 | \ {a1, a2 -> a1.module < a2.module}) |
| 25 | \ }) | 27 | \ }) |
| 26 | 28 | ||
| 27 | " autocmd VimEnter * call setloclist(0, filter(map(copy(v:oldfiles), {_, p->{'filename': expand(get(split(p, "'"), 0))}}), { val -> echo val})) | 29 | " if we have Vim receiving input from a pipe, this VimEnter command would |
| 28 | " from the list of recent files: make absolute paths, filter out files not | 30 | " trigger an error. Also when calling Vim with other arguments. In both cases |
| 29 | " contained in cwd and finally filter out directories and non-files... | 31 | " we know what we want and that is not the list with recently opened files. |
| 30 | autocmd StdinReadPre * let s:std_in=1 | 32 | autocmd StdinReadPre * let s:std_in=1 |
| 31 | autocmd VimEnter * | 33 | autocmd VimEnter * |
| 32 | \ if !exists("s:std_in") && empty(argv()) | 34 | \ if !exists("s:std_in") && empty(argv()) |
| 33 | \ | execute ':RecentlyUsed" | 35 | \ | execute ':RecentlyUsed" |
| 34 | \ | wincmd w' | 36 | \ | wincmd w' |
| 35 | \ | endif | 37 | \ | endif |
| 36 | |||
| 37 | " http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:caddexpr | ||
| 38 | " for c in range(char2nr('a'), char2nr('z')) + range(char2nr('A'), char2nr('Z')) + range(0,9) | let p = getpos("'".nr2char(c)) | if (p[1] > 0) | exec "sign define mark_".nr2char(c)." text=".nr2char(c)." linehl=linenr" | exec "sign place ".c." name=mark_".nr2char(c)." line=".p[1] | endif | endfor | ||
| 39 | " for c in range(char2nr('a'), char2nr('z')) + range(char2nr('A'), char2nr('Z')) + range(0,9) | let p = line("'".nr2char(c)) | if (p > 0) | exec "sign define mark_".nr2char(c)." text=".nr2char(c)." linehl=linenr" | exec "sign place ".c." name=mark_".nr2char(c)." line=".p | endif | endfor | ||
| 40 | " call sign_unplace('marks') | for c in range(char2nr('a'), char2nr('z')) + range(char2nr('A'), char2nr('Z')) + range(0,9) | let p = line("'".nr2char(c)) | if (p > 0) | call sign_define("mark_".nr2char(c), { "text" : nr2char(c), "linehl": "linenr"}) | call sign_place(c, 'marks', "mark_".nr2char(c), '', {'lnum': p}) | endif | endfor | ||
| 41 | " call sign_unplace('marks') | for c in range(char2nr('a'), char2nr('z')) + range(char2nr('A'), char2nr('Z')) + range(char2nr('0'), char2nr('9')) | let p = line("'".nr2char(c)) | if (p > 0) | call sign_define("mark_".nr2char(c), { "text" : nr2char(c), "texthl": "linenr"}) | call sign_place(c, 'marks', "mark_".nr2char(c), '', {'lnum': p}) | endif | endfor | ||
