1
1
" notes.vim - A vim plugin to take notes easily
2
- " Mantainer: bxor99
3
- " Version: 0.01-alpha
2
+ " Mantainer: fmount
3
+ " Version: 1.0
4
4
" AutoInstall: notes.vim
5
5
" ====== Enjoy ======
6
6
"
@@ -10,11 +10,12 @@ if exists('g:loaded_notes') || &cp
10
10
endif
11
11
12
12
let g: loaded_notes = 0
13
+ let g: notes_version = ' 1.0'
13
14
14
15
" For security reasons..
15
16
" if v:version < 702
16
- " echomsg 'notes: You need at least Vim 7.2'
17
- " finish
17
+ " echomsg 'notes: You need at least Vim 7.2'
18
+ " finish
18
19
" endif
19
20
20
21
if ! exists (' g:notes_folder' )
@@ -30,7 +31,7 @@ augroup bufferset
30
31
autocmd !
31
32
autocmd BufRead ,BufNewFile *.note set filetype = markdown
32
33
autocmd BufRead ,BufNewFile *.note let b: notes_start_time= localtime ()
33
- autocmd BufRead ,BufNewFile *.* syntax on
34
+ " autocmd BufRead,BufNewFile *.* syntax on
34
35
" Autosave settings
35
36
autocmd CursorHold ,BufRead *.note call notes#update_buffer ()
36
37
autocmd BufWritePre *.note let b: notes_start_time = localtime ()
@@ -41,109 +42,3 @@ command! -complete=customlist,notes#navigate -nargs=1 Note call notes#edit(<f-ar
41
42
command ! -complete =customlist , NoteList call notes#list ()
42
43
command ! -complete =customlist ,notes#navigate -nargs =1 NoteDelete call notes#delete (<f-args> ) | bdelete !
43
44
command ! NoteAutoSaveToggle :call notes#autosave_toggle ()
44
-
45
- function notes#edit (filename)
46
- let l: dir = expand (g: notes_folder )
47
- let l: tmpfilename = a: filename
48
-
49
- " Check for file extention"
50
- let l: fileext = matchstr (l: tmpfilename , ' \.\w*$' )
51
-
52
- if (empty (l: fileext ))
53
- let l: newext = ' .note'
54
- else
55
- let l: newext = ' '
56
- endif
57
-
58
- " Create l:dir if not existing
59
- if ! isdirectory (l: dir )
60
- exe " silent !mkdir " . l: dir
61
- endif
62
-
63
- " This is used when we don't pass any log
64
- if (fnamemodify (expand (a: filename , ' /' ), ' :h' ) == " " )
65
- exe " edit " . l: dir . " /" . a: filename . l: newext
66
- " This is used when we pass an absolute path
67
- elseif (expand (g: notes_folder ) != fnamemodify (expand (a: filename , ' /' ), ' :h' ))
68
- let l: filename = fnamemodify (expand (a: filename , ' /' ), ' :t' )
69
- exe " edit " . l: dir . " /" . l: filename . l: newext
70
- else
71
- exe " edit " . a: filename . l: newext
72
- endif
73
- endfunction
74
-
75
- function notes#list ()
76
- let l: dir = expand (g: notes_folder )
77
- execute " :Explore " . l: dir
78
- endfunction
79
-
80
- function notes#navigate (A,L,P )
81
- return split (globpath (g: notes_folder , " *" ), " \n " )
82
- endfunction
83
-
84
-
85
- function notes#delete (... )
86
- if (exists (' a:1' ))
87
- let note = a: 1
88
-
89
- " Check for the working directory
90
- if (expand (g: notes_folder ) != fnamemodify (expand (note, ' /' ), ' :h' ))
91
- echomsg " Working directory doesn't match"
92
- return -1
93
- endif
94
- elseif ( &ft == ' help' )
95
- echohl Error
96
- echo " Cannot delete a help buffer!"
97
- echohl None
98
- return -1
99
- else
100
- let note = expand (' %:p' )
101
- endif
102
-
103
- let delStatus = delete (note)
104
-
105
- if (delStatus == 0 )
106
- echo " Deleted " . note
107
- else
108
- echohl WarningMsg
109
- echo " Failed to delete " . note
110
- echohl None
111
- endif
112
-
113
- return delStatus
114
- endfunction
115
-
116
-
117
- " Autosave for buffered notes
118
- function notes#update_buffer ()
119
- " echomsg "Time elapsed: ".(localtime()-b:notes_start_time) "DEBUG TIME
120
- let l: note_time_elapsed = localtime () - b: notes_start_time
121
-
122
- " check for the time elapsed, the value of the autosave variable and
123
- " the current file type (through the .note extension)
124
- if (matchstr (expand (' %.t' ),' \^*.note$' ) != " " && g: notes_autosave >= 1
125
- \& & l: note_time_elapsed >= g: notes_autosave_time )
126
-
127
- " Try to update the buffer if modified
128
- let was_modified = &modified
129
- silent ! w
130
-
131
- if (was_modified && ! &modified )
132
- echomsg " (AutoSaved at " . strftime (" %H:%M:%S" ) . " )"
133
- let b: notes_start_time = localtime ()
134
- endif
135
-
136
- endif
137
- endfunction
138
-
139
- " Enable and disable the autosave function for .note files
140
- function notes#autosave_toggle ()
141
- if g: notes_autosave >= 1
142
- let g: notes_autosave = 0
143
- echo " Notes AutoSave disabled"
144
- else
145
- let g: notes_autosave = 1
146
- echo " Notes AutoSave enabled"
147
- endif
148
- endfunction
149
-
0 commit comments