diff options
author | Max Christian Pohle | 2020-07-16 22:27:58 +0200 |
---|---|---|
committer | Max Christian Pohle | 2020-07-16 22:27:58 +0200 |
commit | c4661ec60a6cb11deb77ec290d954d9070667bf5 (patch) | |
tree | c1cd924ca39e3d0d4f8aad033f3bd4d3d9345d81 /plugin | |
download | vim-recently-used-c4661ec60a6cb11deb77ec290d954d9070667bf5.tar.bz2 vim-recently-used-c4661ec60a6cb11deb77ec290d954d9070667bf5.zip |
Initial release as a separate plugin
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/autoload/vim-recently-used.vim | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/plugin/autoload/vim-recently-used.vim b/plugin/autoload/vim-recently-used.vim new file mode 100644 index 0000000..48bb5d6 --- /dev/null +++ b/plugin/autoload/vim-recently-used.vim | |||
@@ -0,0 +1,41 @@ | |||
1 | "======================================================================================================================= | ||
2 | " MAX_SPLASH: | ||
3 | " Shows recently used files from the current directory in a location list | ||
4 | "======================================================================================================================= | ||
5 | |||
6 | command RecentlyUsed call setloclist(0, []) | ||
7 | \ | :lopen | ||
8 | \ | setlocal nospell | ||
9 | \ | setlocal signcolumn=yes | ||
10 | \ | setfiletype qf | ||
11 | \ | call setloclist(0, [], 'r', { | ||
12 | \ 'title':'Recently used files in directory: '.getcwd(), | ||
13 | \ 'items':sort(map(filter(filter(map(copy(v:oldfiles[:100]), | ||
14 | \ {_, p->expand(p)}), | ||
15 | \ 'v:val =~ "'.getcwd().'/"'), | ||
16 | \ 'filereadable(v:val)'), | ||
17 | \ {_, p->{'filename': p, | ||
18 | \ 'module': printf("%s | %-*s ", | ||
19 | \ strftime("%F %H:%M", | ||
20 | \ getftime(p)), | ||
21 | \ winwidth(0) - wincol() - 22, | ||
22 | \ fnamemodify(p, ':.') | ||
23 | \ )}}), | ||
24 | \ {a1, a2 -> a1.module < a2.module}) | ||
25 | \ }) | ||
26 | |||
27 | " autocmd VimEnter * call setloclist(0, filter(map(copy(v:oldfiles), {_, p->{'filename': expand(get(split(p, "'"), 0))}}), { val -> echo val})) | ||
28 | " from the list of recent files: make absolute paths, filter out files not | ||
29 | " contained in cwd and finally filter out directories and non-files... | ||
30 | autocmd StdinReadPre * let s:std_in=1 | ||
31 | autocmd VimEnter * | ||
32 | \ if !exists("s:std_in") && empty(argv()) | ||
33 | \ | execute ':RecentlyUsed" | ||
34 | \ | wincmd w' | ||
35 | \ | 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 | ||