diff options
| -rw-r--r-- | README.md | 9 | ||||
| -rw-r--r-- | plugin/vim-recently-used.vim | 36 |
2 files changed, 23 insertions, 22 deletions
| @@ -13,7 +13,13 @@ update the list after changing to another directory with `:cd`. | |||
| 13 | 13 | ||
| 14 | This should be sufficient: | 14 | This should be sufficient: |
| 15 | 15 | ||
| 16 | git clone https://git.entwicklerseite.de/vim-recently-used ~/.vim/pack/coderonline/start/ | 16 | git clone https://git.entwicklerseite.de/vim-recently-used \ |
| 17 | ~/.vim/pack/coderonline/start/vim-recently-used | ||
| 18 | |||
| 19 | Or as submodule: | ||
| 20 | |||
| 21 | git submodule add https://git.entwicklerseite.de/vim-recently-used \ | ||
| 22 | ~/.vim/pack/coderonline/start/vim-recently-used | ||
| 17 | 23 | ||
| 18 | Or download the zip file and extract it under `~/.vim/pack/coderonline/start/`. | 24 | Or download the zip file and extract it under `~/.vim/pack/coderonline/start/`. |
| 19 | 25 | ||
| @@ -32,4 +38,3 @@ Or download the zip file and extract it under `~/.vim/pack/coderonline/start/`. | |||
| 32 | 38 | ||
| 33 | * Keep it really simple | 39 | * Keep it really simple |
| 34 | * Make it a one liner | 40 | * Make it a one liner |
| 35 | |||
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 | ||
