aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Christian Pohle2020-07-17 00:28:51 +0200
committerMax Christian Pohle2020-07-17 00:28:51 +0200
commit463cab0af26022d8c2cad3760383bcc6f41dd57f (patch)
treeb43bba4b499b639f29e18e9a0100aacfe6e2b7a4
parent5a8cc26fb5084dc032153d867f8fffe00a477e48 (diff)
downloadvim-recently-used-463cab0af26022d8c2cad3760383bcc6f41dd57f.tar.bz2
vim-recently-used-463cab0af26022d8c2cad3760383bcc6f41dd57f.zip
Improved README and code comments
-rw-r--r--README.md9
-rw-r--r--plugin/vim-recently-used.vim36
2 files changed, 23 insertions, 22 deletions
diff --git a/README.md b/README.md
index 65559f1..dd2402e 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,13 @@ update the list after changing to another directory with `:cd`.
13 13
14This should be sufficient: 14This 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
19Or as submodule:
20
21 git submodule add https://git.entwicklerseite.de/vim-recently-used \
22 ~/.vim/pack/coderonline/start/vim-recently-used
17 23
18Or download the zip file and extract it under `~/.vim/pack/coderonline/start/`. 24Or 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
6command 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 8command! 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.
30autocmd StdinReadPre * let s:std_in=1 32autocmd StdinReadPre * let s:std_in=1
31autocmd VimEnter * 33autocmd 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
..