• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisión42f45e73aaf82419c922ccee0353b07a2d686d78 (tree)
Tiempo2023-02-15 04:19:42
Autorbadcoff33 <none@none>
Commiterbadcoff33

Log Message

move between older/newer notes

Cambiar Resumen

Diferencia incremental

--- /dev/null
+++ b/plugin/notes.vim
@@ -0,0 +1,50 @@
1+
2+execute mkdir(expand("~/.notes"), "p")
3+nnoremap <Leader>n <Cmd>call NotesToday()<CR>
4+
5+let g:notes_files = []
6+
7+function! NotesToday()
8+ execute "drop" strftime("~/.notes/note-%d-%m-%y.txt")
9+ setfiletype markdown
10+ nnoremap <buffer> <LocalLeader>B <Cmd>call NotesBacklog(+1)<CR>
11+ nnoremap <buffer> <LocalLeader>F <Cmd>call NotesBacklog(-1)<CR>
12+ let g:notes_file_idx = 0
13+endfunction
14+
15+function! NotesUpdateBacklog(days)
16+ let one_day = 86400
17+ let now = localtime()
18+ let files = []
19+ for day in range(0, -a:days, -1)
20+ let file_candidate = strftime("~/.notes/note-%d-%m-%y.txt", (now - now % one_day) + ( day * one_day ) )
21+ if filereadable(expand(file_candidate))
22+ call add(files, expand(file_candidate))
23+ endif
24+ endfor
25+ return files
26+endfunction
27+
28+function! NotesBacklog(dir)
29+ let one_day = 86400
30+ let now = localtime()
31+ let display = ["Select a note from the past:"]
32+ let g:notes_files = NotesUpdateBacklog(60)
33+ let last_idx = len(g:notes_files) - 1
34+
35+ let g:notes_file_idx += a:dir
36+ if g:notes_file_idx <= 0
37+ let g:notes_file_idx = 0
38+ elseif g:notes_file_idx >= last_idx
39+ let g:notes_file_idx = last_idx
40+ endif
41+ echo g:notes_file_idx
42+ try
43+ execute "drop" g:notes_files[g:notes_file_idx]
44+ nnoremap <buffer> <LocalLeader>B <Cmd>call NotesBacklog(+1)<CR>
45+ nnoremap <buffer> <LocalLeader>F <Cmd>call NotesBacklog(-1)<CR>
46+ setfiletype markdown
47+ catch /.*/
48+ endtry
49+endfunction
50+
--- a/vimrc
+++ b/vimrc
@@ -237,9 +237,6 @@ inoremap <C-s>} <C-o>b{<Esc>ea}
237237 let mapleader = " "
238238 let maplocalleader = "!"
239239
240-" quick note taking
241-nnoremap <expr> <Leader>n ":drop "..strftime("~/Documents/Notes/note-%d-%m-%y.txt".."<CR>:setfiletype markdown<CR>")
242-
243240 " toggle options
244241 nnoremap <Leader>os <cmd>setlocal invspell spell?<CR>
245242 nnoremap <Leader>op <cmd>setlocal invpaste paste?<CR>
@@ -265,10 +262,6 @@ function! s:ToggleQuickfix()
265262 windo if &buftype== "quickfix" | let is_open = v:true | endif
266263 if is_open == v:false
267264 let qf = getqflist()
268- let max_len = 0
269- for e in qf
270- let max_len = len(e["text"]) > max_len ? len(e["text"]) : max_len
271- endfor
272265 if winnr("$") == 1 && &columns >= 140
273266 vert copen
274267 wincmd p