From c4661ec60a6cb11deb77ec290d954d9070667bf5 Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Thu, 16 Jul 2020 22:27:58 +0200 Subject: Initial release as a separate plugin --- README.md | 35 +++++++++++++++++++++++++++++ doc/tags | 2 ++ doc/vim-recently-used.txt | 12 ++++++++++ plugin/autoload/vim-recently-used.vim | 41 ++++++++++++++++++++++++++++++++++ screenshot.png | Bin 0 -> 129709 bytes 5 files changed, 90 insertions(+) create mode 100644 README.md create mode 100644 doc/tags create mode 100644 doc/vim-recently-used.txt create mode 100644 plugin/autoload/vim-recently-used.vim create mode 100644 screenshot.png diff --git a/README.md b/README.md new file mode 100644 index 0000000..fd849f0 --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ +# vim-recently-used + +Here comes one of my most frequently used plugins! + +This plugin shows a list of recently used files from the current directory when +starting Vim. There is also a simple command `:RecentlyUsed` available to +update the list after changing to another directory with `:cd`. + +![screenshot](/screenshot.png) + + +## Installation + +This should be sufficient: + + git clone https://github.com/coderonline/vim-recently-used ~/.vim/pack/coderonline/ + +Or download the zip file and extract it under `~/.vim/pack/coderonline`. + +## Installation using plugin managers + +### vim-plug + + Plug 'coderonline/vim-recently-used' + +### dein.vim + + call dein#add('coderonline/vim-recently-used') + + +## Design goals + +* Keep it really simple +* Make it a one liner + diff --git a/doc/tags b/doc/tags new file mode 100644 index 0000000..7a7b76f --- /dev/null +++ b/doc/tags @@ -0,0 +1,2 @@ +vim-recently-used-usage vim-recently-used.txt /*vim-recently-used-usage* +vim-recently-used.txt vim-recently-used.txt /*vim-recently-used.txt* diff --git a/doc/vim-recently-used.txt b/doc/vim-recently-used.txt new file mode 100644 index 0000000..851a12c --- /dev/null +++ b/doc/vim-recently-used.txt @@ -0,0 +1,12 @@ +*vim-recently-used.txt* A Vim plugin to show a list with recently used files + +============================================================================== +USAGE INSTRUCTIONS *vim-recently-used-usage* + +:RecentlyUsed + + Shows a list of recently used files from the current working directory + in the quickfix list. This command refreshes the list in the current + working directory, See |:cd| and |:pwd|. + +vim:tw=78:ts=8:ft=help:norl: 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 @@ +"======================================================================================================================= +" MAX_SPLASH: +" Shows recently used files from the current directory in a location list +"======================================================================================================================= + +command RecentlyUsed call setloclist(0, []) + \ | :lopen + \ | setlocal nospell + \ | setlocal signcolumn=yes + \ | setfiletype qf + \ | call setloclist(0, [], 'r', { + \ 'title':'Recently used files in directory: '.getcwd(), + \ 'items':sort(map(filter(filter(map(copy(v:oldfiles[:100]), + \ {_, p->expand(p)}), + \ 'v:val =~ "'.getcwd().'/"'), + \ 'filereadable(v:val)'), + \ {_, p->{'filename': p, + \ 'module': printf("%s | %-*s ", + \ strftime("%F %H:%M", + \ getftime(p)), + \ winwidth(0) - wincol() - 22, + \ fnamemodify(p, ':.') + \ )}}), + \ {a1, a2 -> a1.module < a2.module}) + \ }) + +" autocmd VimEnter * call setloclist(0, filter(map(copy(v:oldfiles), {_, p->{'filename': expand(get(split(p, "'"), 0))}}), { val -> echo val})) +" from the list of recent files: make absolute paths, filter out files not +" contained in cwd and finally filter out directories and non-files... +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * + \ if !exists("s:std_in") && empty(argv()) + \ | execute ':RecentlyUsed" + \ | wincmd w' + \ | endif + +" http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:caddexpr +" 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 +" 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 +" 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 +" 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 diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..a5cc78a Binary files /dev/null and b/screenshot.png differ -- cgit v1.2.3