Skip to content

Commit 34e8dab

Browse files
committed
Refactor range handling
1 parent 3512163 commit 34e8dab

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Noteworthy
22
Note-taking is a practice that every good developer should employ, so why should
33
the process be tedious? Noteworthy provides a very quick and painless way to
4-
create and open notes that are kept in predefined places. Works with both static
5-
and project-specific libraries.
4+
create, open, and search through notes that are kept in predefined places. Works
5+
with both static and project-specific libraries.
66

77
## Table of Contents
88
- [Installation](#installation)

autoload/noteworthy.vim

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
""
22
" Open/create a note.
3-
function! noteworthy#Note(line1, line2, ...) abort
4-
call s:File('edit', a:000, a:line1, a:line2)
3+
function! noteworthy#Note(range, line1, line2, ...) abort
4+
call s:File('edit', a:000, a:range, a:line1, a:line2)
55
endfunction
66

77
""
88
" Open/create a note in a new tab.
9-
function! noteworthy#Tnote(line1, line2, ...) abort
10-
call s:File('tabedit', a:000, a:line1, a:line2)
9+
function! noteworthy#Tnote(range, line1, line2, ...) abort
10+
call s:File('tabedit', a:000, a:range, a:line1, a:line2)
1111
endfunction
1212

1313
""
1414
" Open/create a note in a new split.
1515
function! noteworthy#Snote(line1, line2, ...) abort
1616
call s:File(get(
1717
\ g:, 'noteworthy_split_size', ''
18-
\ ) . 'split', a:000, a:line1, a:line2)
18+
\ ) . 'split', a:000, a:range, a:line1, a:line2)
1919
endfunction
2020

2121
""
2222
" Open/create a note in a new vertical split.
2323
function! noteworthy#Vnote(line1, line2, ...) abort
2424
call s:File(get(
2525
\ g:, 'noteworthy_vsplit_size', ''
26-
\ ) . 'vsplit', a:000, a:line1, a:line2)
26+
\ ) . 'vsplit', a:000, a:range, a:line1, a:line2)
2727
endfunction
2828

2929
""
@@ -181,12 +181,12 @@ endfunction
181181

182182
""
183183
" Create or open a note in the current library.
184-
function! s:File(command, segments, line1, line2) abort
184+
function! s:File(command, segments, range, line1, line2) abort
185185
let l:delim = s:GetNoteDelimiter()
186186
let l:fext = s:GetNoteFileExt()
187187
let l:file = s:GetFileName(a:segments, l:delim)
188188
let l:basedir = fnamemodify(l:file, ':h')
189-
if a:line1 != 0 | let l:lines = getline(a:line1, a:line2) | endif
189+
if a:range | let l:lines = getline(a:line1, a:line2) | endif
190190
if !isdirectory(l:basedir) | call mkdir(l:basedir, 'p') | endif
191191
execute a:command l:file
192192
if get(g:, 'noteworthy_use_header', 1) && getfsize(l:file) <= 0

plugin/noteworthy.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,27 @@ endif
1414
" :Note {topic}, ...
1515
" Create or edit a note. Opens in current window.
1616
command! -nargs=+ -range=0 -complete=custom,noteworthy#Completion Note
17-
\ call noteworthy#Note(<range> ? <line1> : 0, <range> ? <line2> : 0, <f-args>)
17+
\ call noteworthy#Note(<range>, <line1>, <line2>, <f-args>)
1818

1919
""
2020
" :[N]VNote {topic}, ...
2121
" Create or edit a note. Opens in vertical split, [N] columns wide (default:
2222
" split current window in half)
2323
command! -range=0 -nargs=+ -complete=custom,noteworthy#Completion Vnote
24-
\ call noteworthy#Vnote(<range> ? <line1> : 0, <range> ? <line2> : 0, <f-args>)
24+
\ call noteworthy#Vnote(<range>, <line1>, <line2>, <f-args>)
2525

2626
""
2727
" :[N]SNote {topic}, ...
2828
" Create or edit a note. Opens in split, [N] columns wide (default: split
2929
" current window in half)
3030
command! -range=0 -nargs=+ -complete=custom,noteworthy#Completion Snote
31-
\ call noteworthy#Snote(<range> ? <line1> : 0, <range> ? <line2> : 0, <f-args>)
31+
\ call noteworthy#Snote(<range>, <line1>, <line2>, <f-args>)
3232

3333
""
3434
" :TNote {topic}, ...
3535
" Create or edit a note. Opens in new tab.
3636
command! -range=0 -nargs=+ -complete=custom,noteworthy#Completion Tnote
37-
\ call noteworthy#Tnote(<range> ? <line1> : 0, <range> ? <line2> : 0, <f-args>)
37+
\ call noteworthy#Tnote(<range>, <line1>, <line2>, <f-args>)
3838

3939
""
4040
" :NoteLibrary [{directory}]

0 commit comments

Comments
 (0)