├── .gitignore ├── LICENSE.txt ├── README.md ├── autoload └── notescli.vim ├── doc └── notes-cli.txt └── plugin └── notescli.vim /.gitignore: -------------------------------------------------------------------------------- 1 | /notes 2 | /notes.exe 3 | /doc/tags 4 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | the MIT License 2 | 3 | Copyright (c) 2018 rhysd 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 17 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 20 | THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Vim + [notes-cli][] for Markdown note taking 2 | ============================================ 3 | 4 | This is a Vim plugin to use [notes-cli][] more effectively on Vim (Vim8 or later). 5 | 6 | ![screencast](https://github.com/rhysd/ss/blob/master/vim-notes-cli/demo.gif?raw=true) 7 | 8 | 9 | 10 | ## Installation 11 | 12 | If you use any package manager, please follow its instruction. 13 | 14 | With [vim-plug](https://github.com/junegunn/vim-plug): 15 | 16 | ```vim 17 | Plug 'rhysd/vim-notes-cli' 18 | ``` 19 | 20 | With [dein.vim](https://github.com/Shougo/dein.vim): 21 | 22 | ```vim 23 | call dein#add('rhysd/vim-notes-cli', { 24 | \ 'lazy' : 1, 25 | \ 'on_cmd' : ['Notes', 'NotesSelect', 'NotesNew', 'NotesList', 'NotesGrep'], 26 | \ }) 27 | ``` 28 | 29 | With [minpac](https://github.com/k-takata/minpac): 30 | 31 | ```vim 32 | call minpac#add('rhysd/vim-notes-cli') 33 | ``` 34 | 35 | When you're using Vim's builtin packager, please follow instruction at `:help pack-add`. 36 | 37 | Even if you didn't install [notes-cli][], you don't need to install it. vim-notes-cli automatically 38 | installs `notes` executable and uses it locally. 39 | 40 | 41 | 42 | ## Usage 43 | 44 | You can read manual by `:help vim-notes-cli` after installation. 45 | 46 | All commands can be completed while input. Please input `` to complete arguments. 47 | 48 | ### `:NotesSelect [{args}...]` 49 | 50 | It selects one (or multiple) of candidates with [peco][] or [fzf][] and opens selected notes with new Vim buffers. 51 | You can specify a command to select by `g:notes_cli_select_cmd` and how to open buffer by `g:notes_cli_edit_cmd`. 52 | 53 | All arguments are passed to `notes list` command. You can specify category and/or tags by `-c` and/or `-t` options. 54 | 55 | **Example:** Only targets 'blog' category and 'Go' tag. 56 | 57 | ``` 58 | :NotesSelect -c blog -t Go 59 | ``` 60 | 61 | And you can specify the order of list by `-s`. 62 | 63 | **Example:** Sort the list with modified date (default is created date) 64 | 65 | ``` 66 | :NotesSelect -s modified 67 | ``` 68 | 69 | 70 | ### `:NotesFeelingLucky [{args}...]` 71 | 72 | It is similar to `:NotesSelect`, but does not select one from list. It always select the first candidate like 73 | `notes list | head -1`. 74 | This is useful when you want to open the last created/modified note. 75 | 76 | **Example:** Open last-modified note 77 | 78 | ``` 79 | :NotesFeelingLucky 80 | ``` 81 | 82 | **Example:** Open last-created note 83 | 84 | ``` 85 | :NotesFeelingLucky -s created 86 | ``` 87 | 88 | `{args}` is passed to `notes list` command. 89 | 90 | 91 | ### `:NotesNew [{category} [{file}]]` 92 | 93 | It creates new note with specified category and file name. If they are omitted, it asks them interactively 94 | with prompt. 95 | 96 | **Example:** Create 'how-to-open-file.md' with 'memo' category 97 | 98 | ``` 99 | :NotesNew memo how-to-open-file 100 | ``` 101 | 102 | 103 | ### `:NotesGrep [[{args}] /pattern/]` 104 | 105 | It searches notes with `:vimgrep`. `/pattern/` is passed to first argument of `:vimgrep`. If `{args}` is given, 106 | it is passed to `notes list` to get file paths of notes. By default, `:vimgrep` searches all notes. Please see 107 | `:help vimgrep` for details of `:vimgrep` command. 108 | 109 | When no argument is given, it asks a pattern with propmt. 110 | 111 | **Example:** Search 'open file' in all notes 112 | 113 | ``` 114 | :NotesGrep /open file/ 115 | ``` 116 | 117 | **Example:** Search 'open file' in notes tagged with 'Go' 118 | 119 | ``` 120 | :NotesGrep -t Go /open file/ 121 | ``` 122 | 123 | 124 | ### `:NotesList [{args}...]` 125 | 126 | It shows list of notes with colors. By default, it outputs the result of `notes --oneline`. 127 | 128 | **Example:** Output list of note with one note per line 129 | 130 | ``` 131 | :NotesList 132 | ``` 133 | 134 | **Example:** Output full information of each note (path, metadata, title, body) 135 | 136 | ``` 137 | :NotesList -f 138 | ``` 139 | 140 | When the cursor is on file path, entering `` opens the note in new buffer. 141 | 142 | 143 | ### `:Notes {args}...` 144 | 145 | It runs `notes` command with `{args}`. Command is run with `:terminal`. 146 | 147 | **Example:** Show help of `notes` command 148 | 149 | ``` 150 | :Notes help 151 | ``` 152 | 153 | **Example:** Update `notes` executable 154 | 155 | ``` 156 | :Notes selfupdate 157 | ``` 158 | 159 | 160 | 161 | ## License 162 | 163 | [MIT License](LICENSE.txt) 164 | 165 | [notes-cli]: https://github.com/rhysd/notes-cli 166 | [peco]: https://github.com/peco/peco 167 | [fzf]: https://github.com/junegunn/fzf 168 | -------------------------------------------------------------------------------- /autoload/notescli.vim: -------------------------------------------------------------------------------- 1 | let s:PATH_SEP = has('win32') ? '\' : '/' 2 | let s:REPO_ROOT = fnamemodify(expand(''), ':p:h:h') 3 | 4 | function! s:echoerr(msg) abort 5 | echohl ErrorMsg 6 | echom a:msg 7 | echohl None 8 | endfunction 9 | 10 | function! s:local_bin() abort 11 | let dir = get(g:, 'notes_cli_download_dir', s:REPO_ROOT) 12 | 13 | let binpath = dir . s:PATH_SEP . 'notes' 14 | if has('win32') 15 | let binpath .= '.exe' 16 | endif 17 | 18 | if filereadable(binpath) 19 | return binpath 20 | endif 21 | 22 | if exists('g:notes_cli_platform_name') 23 | let platform = g:notes_cli_platform_name 24 | elseif has('win32') 25 | let platform = 'windows' 26 | elseif has('mac') 27 | let platform = 'darwin' 28 | elseif has('unix') 29 | let platform = 'linux' 30 | else 31 | call s:echoerr('Unknown platform. Please set g:notes_cli_platform_name') 32 | return '' 33 | endif 34 | 35 | let suffix = '.zip' 36 | if has('win32') 37 | let suffix = '.exe' . suffix 38 | endif 39 | let archive = 'notes_' . platform . '_amd64' . suffix 40 | let zippath = dir . s:PATH_SEP . archive 41 | 42 | if !executable('curl') 43 | call s:echoerr('`curl` command is necessary to download binary') 44 | return '' 45 | endif 46 | 47 | if !executable('unzip') 48 | call s:echoerr('`unzip` command is necessary to unzip downloaded archive') 49 | return '' 50 | endif 51 | 52 | let out = system("curl -Ls -o /dev/null -w '%{url_effective}' https://github.com/rhysd/notes-cli/releases/latest") 53 | if v:shell_error 54 | call s:echoerr('Cannot get redurect URL: ' . out) 55 | return '' 56 | endif 57 | let tag = split(out, '/')[-1] 58 | 59 | let url = printf('https://github.com/rhysd/notes-cli/releases/download/%s/%s', tag, archive) 60 | echom 'Downloading and unarchiving the latest executable from ' . url . ' to ' . dir 61 | 62 | let curl_cmd = printf('curl -L -o %s %s 2>&1', shellescape(zippath), shellescape(url)) 63 | let unzip_cmd = printf('unzip %s -d %s', shellescape(zippath), shellescape(dir)) 64 | let out = system(curl_cmd . ' && ' . unzip_cmd) 65 | if v:shell_error 66 | call s:echoerr('Downloading with curl and unarchiving with unzip failed: ' . out) 67 | return '' 68 | endif 69 | 70 | " verify 71 | if !filereadable(binpath) 72 | call s:echoerr('Executable was not downloaded successfully. Please check following directory and set g:notes_cli_bin manually: ' . dir) 73 | return '' 74 | endif 75 | 76 | call delete(zippath) 77 | 78 | return binpath 79 | endfunction 80 | 81 | function! s:notes_bin() abort 82 | if exists('g:notes_cli_bin') 83 | return g:notes_cli_bin 84 | endif 85 | 86 | if executable('notes') 87 | let g:notes_cli_bin = 'notes' 88 | return g:notes_cli_bin 89 | endif 90 | 91 | let bin = s:local_bin() 92 | if bin !=# '' 93 | let g:notes_cli_bin = bin 94 | return g:notes_cli_bin 95 | endif 96 | 97 | return '' 98 | endfunction 99 | 100 | function! s:notes_cmd(args) abort 101 | let bin = s:notes_bin() 102 | if bin ==# '' 103 | return '' 104 | endif 105 | let args = map(copy(a:args), 'shellescape(v:val)') 106 | let out = system(bin . ' --no-color ' . join(args, ' ')) 107 | if v:shell_error 108 | call s:echoerr(out) 109 | return '' 110 | endif 111 | if out =~# '\n$' 112 | let out = out[:-2] 113 | endif 114 | return out 115 | endfunction 116 | 117 | function! s:completion(subcmd, lead) abort 118 | let args = ['help'] 119 | if a:subcmd !=# '' 120 | let args += [a:subcmd] 121 | endif 122 | 123 | let lines = split(s:notes_cmd(args), '\n') 124 | if empty(lines) 125 | return [] 126 | endif 127 | 128 | if a:subcmd ==# '' 129 | let idx = index(lines, 'Commands:') 130 | if idx == -1 131 | return [] 132 | endif 133 | let ret = [] 134 | for l in lines[idx+1:] 135 | let cmd = matchstr(l, '^ \zs\h\w*\ze\>') 136 | if cmd ==# '' 137 | continue 138 | endif 139 | let ret += [cmd] 140 | endfor 141 | if ret != [] && a:lead !=# '' 142 | call filter(ret, 'v:val =~# ''^' . a:lead . "'") 143 | endif 144 | return ret 145 | endif 146 | 147 | let idx = index(lines, 'Flags:') 148 | if idx == -1 149 | return [] 150 | endif 151 | let ret = [] 152 | for l in lines[idx+1:] 153 | let cmds = matchstr(l, '^\s\+\zs-\h, --\h[[:alnum:]-]\+') 154 | if cmds !=# '' 155 | let ret += split(cmds, ',\s\+') 156 | continue 157 | endif 158 | let cmd = matchstr(l, '^\s\+\zs--\h[[:alnum:]-]\+') 159 | if cmd !=# '' 160 | let ret += [cmd] 161 | continue 162 | endif 163 | endfor 164 | if ret != [] && a:lead !=# '' 165 | call filter(ret, 'v:val =~# ''^' . a:lead . "'") 166 | endif 167 | return ret 168 | endfunction 169 | 170 | function! notescli#c_list(lead, cmdline, col) abort 171 | return s:completion('list', a:lead) 172 | endfunction 173 | function! s:on_selector_close(ch) dict abort 174 | let lines = readfile(self.tmp) 175 | call delete(self.tmp) 176 | 177 | let home = s:notes_cmd(['config', 'home']) 178 | if home ==# '' 179 | return 180 | endif 181 | 182 | let cmd = get(g:, 'notes_cli_edit_cmd', 'edit!') 183 | for line in lines 184 | let s = split(line) 185 | if s == [] 186 | continue 187 | endif 188 | let path = home . s:PATH_SEP . s[0] 189 | execute cmd path 190 | endfor 191 | endfunction 192 | function! notescli#select(args) abort 193 | if !exists('g:notes_cli_selector_cmd') 194 | if executable('fzf') 195 | let g:notes_cli_selector_cmd ='fzf' 196 | elseif executable('peco') 197 | let g:notes_cli_selector_cmd ='peco' 198 | else 199 | call s:echoerr('`peco` nor `fzf` is not available. Please set g:notes_cli_selector_cmd') 200 | return 201 | endif 202 | endif 203 | 204 | let bin = s:notes_bin() 205 | if bin ==# '' 206 | return 207 | endif 208 | let cmd = [bin, 'list', '--oneline'] + a:args 209 | let cmd = join(cmd, ' ') . ' | ' . g:notes_cli_selector_cmd 210 | if has('win32') 211 | let cmd = ['cmd', '/c', cmd] 212 | else 213 | let cmd = ['sh', '-c', cmd] 214 | endif 215 | 216 | let ctx = {'tmp': tempname()} 217 | let options = { 218 | \ 'term_name' : 'notes: list | ' . g:notes_cli_selector_cmd, 219 | \ 'term_finish' : 'close', 220 | \ 'out_io' : 'file', 221 | \ 'out_name' : ctx.tmp, 222 | \ 'close_cb' : function('s:on_selector_close', [], ctx), 223 | \ } 224 | let ctx.bufnr = term_start(cmd, options) 225 | endfunction 226 | 227 | function! notescli#c_new(lead, cmdline, col) abort 228 | return s:completion('new', a:lead) 229 | endfunction 230 | function! notescli#new(...) abort 231 | if has_key(a:, 1) 232 | let cat = a:1 233 | else 234 | let cat = input('category?: ') 235 | endif 236 | if has_key(a:, 2) 237 | let name = a:2 238 | else 239 | let name = input('filename?: ') 240 | endif 241 | let tags = get(a:, 3, '') 242 | let out = s:notes_cmd(['new', '--no-edit', cat, name, tags]) 243 | if out ==# '' 244 | return 245 | endif 246 | let path = split(out)[-1] 247 | execute 'edit!' path 248 | normal! Go 249 | endfunction 250 | 251 | function! notescli#open_first_i_am_feeling_lucky(args) abort 252 | let args = a:args 253 | if args == [] 254 | " Open the last modified note by default 255 | let args = ['--sort', 'modified'] 256 | endif 257 | let out = s:notes_cmd(['list'] + args) 258 | if out ==# '' 259 | return 260 | endif 261 | let first = split(out)[0] 262 | execute 'edit!' first 263 | endfunction 264 | 265 | if has('win32') 266 | function! s:is_absolute(path) abort 267 | return a:path =~# '^[a-zA-Z]:[/\\]' 268 | endfunction 269 | else 270 | function! s:is_absolute(path) abort 271 | return a:path[0] ==# '/' 272 | endfunction 273 | endif 274 | 275 | function! s:open_notes_under_cursor() abort 276 | let fields = split(getline('.'), '\s\+') 277 | if len(fields) == 0 278 | echo 'No list item found under cursor' 279 | return 280 | endif 281 | 282 | let path = fields[0] 283 | if !s:is_absolute(path) 284 | let home = s:notes_cmd(['config', 'home']) 285 | if home ==# '' 286 | return 287 | endif 288 | let path = home . s:PATH_SEP . path 289 | endif 290 | 291 | if !filereadable(path) 292 | call s:echoerr('File does not exist: ' . path) 293 | return 294 | endif 295 | 296 | let cmd = get(g:, 'notes_cli_edit_cmd', 'edit!') 297 | execute cmd path 298 | endfunction 299 | 300 | function! notescli#list(args) abort 301 | let bin = s:notes_bin() 302 | if bin ==# '' 303 | return 304 | endif 305 | let args = join(a:args, ' ') 306 | let cmdline = 'terminal ' . bin . ' list --oneline' 307 | if args !=# '' 308 | let cmdline .= ' ' . args 309 | endif 310 | let pager = $NOTES_CLI_PAGER 311 | let $NOTES_CLI_PAGER = '' 312 | try 313 | execute cmdline 314 | finally 315 | if pager !=# '' 316 | let pager = $NOTES_CLI_PAGER 317 | endif 318 | endtry 319 | nnoremap :call open_notes_under_cursor() 320 | endfunction 321 | 322 | function! notescli#c_grep(lead, cmdline, col) abort 323 | " Omit 'NotesGrep ' by 10: 324 | let args = a:cmdline[10 : a:col] 325 | if args =~# '\s\+/' 326 | return [] 327 | endif 328 | return filter(s:completion('list', a:lead), 'v:val =~# ''^-c\|--category\|-t\|--tag$''') 329 | endfunction 330 | function notescli#grep(args_str) abort 331 | if a:args_str =~# '^\s*$' 332 | let pathlist = s:notes_cmd(['list']) 333 | let pat = input('Pattern in Vim regex?: ') 334 | else 335 | let idx = match(a:args_str, '\s\+\ze/[^/]*/') 336 | if idx <= 0 337 | let pathlist = s:notes_cmd(['list']) 338 | let pat = a:args_str 339 | else 340 | let pathlist = s:notes_cmd(['list'] + split(a:args_str[:idx], '\s\+')) 341 | let pat = a:args_str[idx:] 342 | endif 343 | endif 344 | 345 | if empty(pathlist) 346 | echo 'No note was found' 347 | return 348 | endif 349 | 350 | execute 'vimgrep' pat substitute(pathlist, '\n', ' ', 'g') 351 | 352 | if get(g:, 'notes_cli_open_quickfix_on_grep', 1) && len(getqflist()) > 1 353 | copen 354 | endif 355 | endfunction 356 | 357 | function! notescli#c_notes(lead, cmdline, col) abort 358 | " Omit 'Notes ' by 6: 359 | let args = split(a:cmdline[6 : a:col]) 360 | let l = len(args) 361 | if l == 0 || (l == 1 && a:lead !=# '') 362 | return s:completion('', a:lead) 363 | endif 364 | return s:completion(args[0], a:lead) 365 | endfunction 366 | function! notescli#notes(args_str) abort 367 | let bin = s:notes_bin() 368 | if bin ==# '' 369 | return 370 | endif 371 | let cmdline = 'terminal ' . bin 372 | if a:args_str !=# '' 373 | let cmdline .= ' ' . a:args_str 374 | endif 375 | execute cmdline 376 | endfunction 377 | -------------------------------------------------------------------------------- /doc/notes-cli.txt: -------------------------------------------------------------------------------- 1 | *notes-cli.txt* Manage markdown notes with notes-cli 2 | 3 | Author : rhysd 4 | 5 | CONTENTS *vim-notes-cli-contents* 6 | 7 | Introduction |vim-notes-cli-introduction| 8 | Install |vim-notes-cli-install| 9 | Usage |vim-notes-cli-usage| 10 | Commands |vim-notes-cli-commands| 11 | Variables |vim-notes-cli-variables| 12 | Repository |vim-notes-cli-repository-page| 13 | License |vim-notes-cli-license| 14 | 15 | 16 | 17 | ============================================================================== 18 | INTRODUCTION *vim-notes-cli-introduction* 19 | 20 | *vim-notes-cli* is a Vim plugin to use notes-cli more effectively on Vim (Vim8 21 | or later). 22 | notes-cli is a command line tool to manage your markdown notes. 23 | 24 | https://github.com/rhysd/notes-cli 25 | 26 | Screenshot: 27 | https://github.com/rhysd/ss/blob/master/vim-notes-cli/demo.gif?raw=true 28 | 29 | 30 | 31 | ============================================================================== 32 | INSTALL *vim-notes-cli-install* 33 | 34 | If you use any package manager, please follow its instruction. 35 | 36 | With vim-plug: 37 | > 38 | Plug 'rhysd/vim-notes-cli' 39 | < 40 | With dein.vim: 41 | > 42 | call dein#add('rhysd/vim-notes-cli') 43 | < 44 | With minpac: 45 | > 46 | call minpac#add('rhysd/vim-notes-cli') 47 | < 48 | When you're using Vim's builtin packager, please follow instruction at 49 | |pack-add|. 50 | 51 | Installing notes-cli is optional. You don't need to install it manually. 52 | |vim-notes-cli| automatically installs `notes` executable and uses it locally 53 | if it is not installed yet. 54 | 55 | vim-plug: https://github.com/junegunn/vim-plug 56 | dein.vim: https://github.com/Shougo/dein.vim 57 | minpac: https://github.com/k-takata/minpac 58 | 59 | 60 | 61 | ============================================================================== 62 | USAGE *vim-notes-cli-usage* 63 | 64 | Following commands and variables are available. 65 | 66 | All commands can be completed while input. Please input to complete 67 | arguments. 68 | 69 | 70 | ------------------------------------------------------------------------------ 71 | COMMANDS *vim-notes-cli-commands* 72 | 73 | *:NotesSelect* [{args}...] 74 | 75 | It selects one (or multiple) of candidates with `peco` or `fzf` and opens 76 | selected notes with new Vim buffers. You can specify a command to select 77 | by |g:notes_cli_select_cmd| and how to open buffer by |g:notes_cli_edit_cmd|. 78 | 79 | All arguments are passed to `notes list` command. You can specify category 80 | and/or tags by `-c` and/or `-t` options. 81 | 82 | Example: Only targets "blog" category and "Go" tag. 83 | > 84 | :NotesSelect -c blog -t Go 85 | < 86 | And you can specify the order of list by `-s`. 87 | 88 | Example: Sort the list with modified date (default is created date) 89 | > 90 | :NotesSelect -s modified 91 | < 92 | peco: https://github.com/peco/peco 93 | fzf: https://github.com/junegunn/fzf 94 | 95 | 96 | *:NotesFeelingLucky* [{args}...] 97 | 98 | It is similar to |:NotesSelect|, but does not select one from list. It 99 | always select the first candidate like `notes list | head -1`. This is 100 | useful when you want to open the last created/modified note. 101 | 102 | Example: Open last-modified note 103 | > 104 | :NotesFeelingLucky 105 | < 106 | Example: Open last-created note 107 | > 108 | :NotesFeelingLucky -s created 109 | < 110 | {args} is passed to `notes list` command. 111 | 112 | 113 | *:NotesNew* [{category} [{file}]] 114 | 115 | It creates new note with specified category and file name. If they are 116 | omitted, it asks them interactively with prompt. 117 | 118 | Example: Create 'how-to-open-file.md' with "memo" category 119 | > 120 | :NotesNew memo how-to-open-file 121 | < 122 | 123 | *:NotesGrep* [[{args}] /pattern/] 124 | 125 | It searches notes with |:vimgrep|. /pattern/ is passed to first argument of 126 | |:vimgrep|. If {args} is given, it is passed to `notes list` to get file paths 127 | of notes. By default, |:vimgrep| searches all notes. 128 | When no argument is given, it asks a pattern with propmt. 129 | 130 | Example: Search 'open file' in all notes 131 | > 132 | :NotesGrep /open file/ 133 | < 134 | Example: Search 'open file' in notes tagged with 'Go' 135 | > 136 | :NotesGrep -t Go /open file/ 137 | < 138 | 139 | *:NotesList* [{args}...] 140 | 141 | It shows list of notes with colors. By default, it outputs the result of 142 | `notes --oneline`. 143 | 144 | Example: Output list of note with one note per line 145 | > 146 | :NotesList 147 | < 148 | Example: Output full information of each note (path, metadata, title, 149 | body) 150 | > 151 | :NotesList -f 152 | < 153 | When the cursor is on file path, entering opens the note in new 154 | buffer. 155 | 156 | 157 | *:Notes* {args}... 158 | 159 | It runs `notes` command with {args}. Command is run with |:terminal| 160 | 161 | Example: Show help of `notes` command 162 | > 163 | :Notes help 164 | < 165 | Example: Update `notes` executable 166 | > 167 | :Notes selfupdate 168 | < 169 | 170 | ------------------------------------------------------------------------------ 171 | VARIABLES *vim-notes-cli-variables* 172 | 173 | *g:notes_cli_bin* |String| 174 | 175 | File path or command name of "notes" executable in your environment. If this 176 | variable is not set and "notes" command is globally available, it is used. 177 | If there is no "notes" installation, |vim-notes-cli| downloads the latest 178 | version from GitHub repository and use it locally. 179 | 180 | *g:notes_cli_selector_cmd* |String| 181 | 182 | Filter command to search notes incrementally. By default, "fzf" or "peco" 183 | command is used if available. 184 | 185 | *g:notes_cli_edit_cmd* |String| 186 | 187 | Vim command to open notes by |:NotesSelect|. For example, if you want to 188 | open notes by splitting a window vertically, "vsplit" should be set to this 189 | variable. If not set, |:edit!| will be used. 190 | 191 | *g:notes_cli_platform_name* |String| 192 | 193 | Name of your platform. Platform name is usually detected automatically so 194 | you don't need to set this variable. However, if you're using "freebsd" or 195 | "netbsd" or "openbsd", please set it to this variable. 196 | 197 | *g:notes_cli_download_dir* |String| 198 | 199 | When downloading "notes" executable by this plugin automatically, the 200 | directory path specified by this variable is used. A downloaded executable 201 | is put in the directory. If this variable is not set, the executable is put 202 | in "../../autoload/notescli.vim". 203 | 204 | *g:notes_cli_open_quickfix_on_grep* |Number| 205 | 206 | When this variable is set to 1, |quickfix| window is automatically open after 207 | searching notes with |:vimgrep| on more than one results. This variable is 208 | set to 1 by default. 209 | 210 | 211 | 212 | ============================================================================== 213 | REPOSITORY PAGE *vim-notes-cli-repository-page* 214 | 215 | The repository of |vim-notes-cli| is hosted on GitHub. 216 | 217 | https://github.com/rhysd/vim-notes-cli 218 | 219 | If you're seeing some bug or have a feature request, please create an issue at 220 | the repository. 221 | 222 | 223 | 224 | ============================================================================== 225 | LICENSE *vim-notes-cli-license* 226 | 227 | |vim-notes-cli| is distributed under The MIT license. 228 | 229 | Copyright (c) 2018 rhysd 230 | 231 | Permission is hereby granted, free of charge, to any person obtaining 232 | a copy of this software and associated documentation files (the 233 | "Software"), to deal in the Software without restriction, including 234 | without limitation the rights to use, copy, modify, merge, publish, 235 | distribute, sublicense, and/or sell copies of the Software, and to 236 | permit persons to whom the Software is furnished to do so, subject to 237 | the following conditions: 238 | The above copyright notice and this permission notice shall be 239 | included in all copies or substantial portions of the Software. 240 | 241 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 242 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 243 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 244 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 245 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 246 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 247 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 248 | 249 | 250 | ============================================================================== 251 | vim:tw=78:ts=8:ft=help:norl:et:fen:fdl=0: 252 | -------------------------------------------------------------------------------- /plugin/notescli.vim: -------------------------------------------------------------------------------- 1 | if (exists('g:loaded_notes_cli') && g:loaded_notes_cli) || &cp 2 | finish 3 | endif 4 | 5 | command! -nargs=* -complete=customlist,notescli#c_notes Notes call notescli#notes() 6 | command! -nargs=* -complete=customlist,notescli#c_list NotesSelect call notescli#select([]) 7 | command! -nargs=* -complete=customlist,notescli#c_new NotesNew call notescli#new() 8 | command! -nargs=* -complete=customlist,notescli#c_list NotesFeelingLucky call notescli#open_first_i_am_feeling_lucky([]) 9 | command! -nargs=* -complete=customlist,notescli#c_list NotesList call notescli#list([]) 10 | command! -nargs=* -complete=customlist,notescli#c_grep NotesGrep call notescli#grep() 11 | 12 | let g:loaded_notes_cli = 1 13 | --------------------------------------------------------------------------------