mirror of
https://github.com/amix/vimrc
synced 2025-09-13 15:15:01 +08:00
Cleaning deps.
This commit is contained in:
Submodule sources_non_forked/vim-notes deleted from 14838be7c5
5
sources_non_forked/vim-notes/.gitignore
vendored
Normal file
5
sources_non_forked/vim-notes/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
doc/tags
|
||||
misc/notes/index.pickle
|
||||
misc/notes/recent.txt
|
||||
misc/notes/tags.txt
|
||||
misc/notes/user/
|
13
sources_non_forked/vim-notes/INSTALL.md
Normal file
13
sources_non_forked/vim-notes/INSTALL.md
Normal file
@ -0,0 +1,13 @@
|
||||
*Please note that the vim-notes plug-in requires my vim-misc plug-in which is separately distributed.*
|
||||
|
||||
Unzip the most recent ZIP archives of the [vim-notes] [download-notes] and [vim-misc] [download-misc] plug-ins inside your Vim profile directory (usually this is `~/.vim` on UNIX and `%USERPROFILE%\vimfiles` on Windows), restart Vim and execute the command `:helptags ~/.vim/doc` (use `:helptags ~\vimfiles\doc` instead on Windows).
|
||||
|
||||
If you prefer you can also use [Pathogen] [pathogen], [Vundle] [vundle] or a similar tool to install & update the [vim-notes] [github-notes] and [vim-misc] [github-misc] plug-ins using a local clone of the git repository.
|
||||
|
||||
|
||||
[download-misc]: http://peterodding.com/code/vim/downloads/misc.zip
|
||||
[download-notes]: http://peterodding.com/code/vim/downloads/notes.zip
|
||||
[github-misc]: http://github.com/xolox/vim-misc
|
||||
[github-notes]: http://github.com/xolox/vim-notes
|
||||
[pathogen]: http://www.vim.org/scripts/script.php?script_id=2332
|
||||
[vundle]: https://github.com/gmarik/vundle
|
360
sources_non_forked/vim-notes/README.md
Normal file
360
sources_non_forked/vim-notes/README.md
Normal file
@ -0,0 +1,360 @@
|
||||
# Easy note taking in Vim
|
||||
|
||||
The vim-notes plug-in for the [Vim text editor] [vim] makes it easy to manage your notes in Vim:
|
||||
|
||||
* **Starting a new note:** Execute the `:Note` command to create a new buffer and load the appropriate file type and syntax
|
||||
* You can also start a note with Vim commands like `:edit`, `:tabedit` and `:split` by starting the filename with `note:`, as in `:edit note:todo` (the part after `note:` doesn't have to be the complete note title and if it's empty a new note will be created)
|
||||
* You can start a new note with the selected text as title in the current window using the `\en` mapping or `:NoteFromSelectedText` command (there are similar mappings and commands for opening split windows and tab pages)
|
||||
* **Saving notes:** Just use Vim's [:write] [write] and [:update] [update] commands, you don't need to provide a filename because it will be set based on the title (first line) of your note (you also don't need to worry about special characters, they'll be escaped)
|
||||
* **Editing existing notes:** Execute `:Note anything` to edit a note containing `anything` in its title (if no notes are found a new one is created with its title set to `anything`)
|
||||
* The `:Note` and `:DeleteNote` commands support tab completion of note titles
|
||||
* **Deleting notes:** The `:DeleteNote` command enables you to delete the current note
|
||||
* **Searching notes:** `:SearchNotes keyword …` searches for keywords and `:SearchNotes /pattern/` searches for regular expressions
|
||||
* The `:SearchNotes` command supports tab completion of keywords and sorts candidates by relevance ([Levenshtein distance] [levenshtein])
|
||||
* **Smart defaults:** Without an argument `:SearchNotes` searches for the word under the cursor (if the word starts with `@` that character will be included in the search, this means you can easily search for *@tagged* notes)
|
||||
* **Back-references:** The `:RelatedNotes` command find all notes referencing the current file
|
||||
* A [Python 2] [python] script is included that accelerates keyword searches using a keyword index
|
||||
* The `:RecentNotes` command lists your notes by modification date, starting with the most recently edited note
|
||||
* **Navigating between notes:** The included syntax script highlights note names as hyper links and the file type plug-in redefines [gf] [gf] to jump between notes (the [Control-w f] [ctrlwf] mapping to jump to a note in a split window and the [Control-w gf] [ctrlwgf] mapping to jump to a note in a new tab page also work)
|
||||
* **Writing aids:** The included file type plug-in contains mappings for automatic curly quotes, arrows and list bullets and supports completion of note titles using Control-X Control-U and completion of tags using Control-X Control-O
|
||||
* **Embedded file types:** The included syntax script supports embedded highlighting using blocks marked with `{{{type … }}}` which allows you to embed highlighted code and configuration snippets in your notes
|
||||
|
||||
Here's a screen shot of the syntax mode using the [Slate] [slate] color scheme and the font [Monaco] [monaco]:
|
||||
|
||||

|
||||
|
||||
## Install & usage
|
||||
|
||||
*Please note that the vim-notes plug-in requires my vim-misc plug-in which is separately distributed.*
|
||||
|
||||
Unzip the most recent ZIP archives of the [vim-notes] [download-notes] and [vim-misc] [download-misc] plug-ins inside your Vim profile directory (usually this is `~/.vim` on UNIX and `%USERPROFILE%\vimfiles` on Windows), restart Vim and execute the command `:helptags ~/.vim/doc` (use `:helptags ~\vimfiles\doc` instead on Windows). To get started execute `:Note` or `:edit note:`, this will start a new note that contains instructions on how to continue from there (and how to use the plug-in in general).
|
||||
|
||||
If you prefer you can also use [Pathogen] [pathogen], [Vundle] [vundle] or a similar tool to install & update the [vim-notes] [github-notes] and [vim-misc] [github-misc] plug-ins using a local clone of the git repository.
|
||||
|
||||
## Options
|
||||
|
||||
All options have reasonable defaults so if the plug-in works after installation you don't need to change any options. The options are available for people who like to customize how the plug-in works. You can set these options in your [vimrc script] [vimrc] by including a line like this:
|
||||
|
||||
:let g:notes_directories = ['~/Documents/Notes', '~/Dropbox/Shared Notes']
|
||||
|
||||
Note that after changing an option in your [vimrc script] [vimrc] you have to restart Vim for the changes to take effect.
|
||||
|
||||
### The `g:notes_directories` option
|
||||
|
||||
Your notes are stored in one or more directories. This option defines where you want to store your notes. Its value should be a list (there's an example above) with one or more pathnames. The default is a single value which depends on circumstances but should work for most people:
|
||||
|
||||
* If the profile directory where the plug-in is installed is writable, the directory `misc/notes/user` under the profile directory is used. This is for compatibility with [Pathogen] [pathogen]; the notes will be stored inside the plug-in's bundle.
|
||||
|
||||
* If the above doesn't work out, the default depends on the platform: `~/vimfiles/misc/notes/user` on Windows and `~/.vim/misc/notes/user` on other platforms.
|
||||
|
||||
#### Backwards compatibility
|
||||
|
||||
In the past the notes plug-in only supported a single directory and the corresponding option was called `g:notes_directory`. When support for multiple notes directories was introduced the option was renamed to `g:notes_directories` to reflect that the value is now a list of directory pathnames.
|
||||
|
||||
For backwards compatibility with old configurations (all of them as of this writing :-) the notes plug-in still uses `g:notes_directory` when it is defined (its no longer defined by the plug-in). However when the plug-in warns you to change your configuration you probably should because this compatibility will be removed at some point.
|
||||
|
||||
### The `g:notes_suffix` option
|
||||
|
||||
The suffix to add to generated filenames. The plug-in generates filenames for your notes based on the title (first line) of each note and by default these filenames don't include an extension like `.txt`. You can use this option to make the plug-in automatically append an extension without having to embed the extension in the note's title, e.g.:
|
||||
|
||||
:let g:notes_suffix = '.txt'
|
||||
|
||||
### The `g:notes_title_sync` option
|
||||
|
||||
When you rename a file in your notes directory but don't change the title, the plug-in will notice this the next time you open the note in Vim. Likewise when you change the title in another text editor but don't rename the file. By default the plug-in will prompt you whether you want it to update the title of the note, rename the file on disk or dismiss the prompt without doing anything.
|
||||
|
||||
If you set this option to the string `'no'` this feature will be completely disabled. If you set it to `'change_title'` it will automatically change the title to match the filename. If you set it to `'rename_file'` it will automatically rename the file on disk to match the title.
|
||||
|
||||
### The `g:notes_smart_quotes` option
|
||||
|
||||
By default the notes plug-in automatically performs several substitutions on the text you type in insert mode, for example regular quote marks are replaced with curly quotes. The full list of substitutions can be found below in the documentation on mappings. If you don't want the plug-in to perform these substitutions, you can set this option to zero like this:
|
||||
|
||||
:let g:notes_smart_quotes = 0
|
||||
|
||||
### The `g:notes_ruler_text` option
|
||||
|
||||
The text of the ruler line inserted when you type `***` in quick succession. It defaults to three asterisks separated by spaces, center aligned to the text width.
|
||||
|
||||
### The `g:notes_list_bullets` option
|
||||
|
||||
A list of characters used as list bullets. When you're using a Unicode encoding this defaults to `['•', '◦', '▸', '▹', '▪', '▫']`, otherwise it defaults to `['*', '-', '+']`.
|
||||
|
||||
When you change the nesting level (indentation) of a line containing a bullet point using one of the mappings `Tab`, `Shift-Tab`, `Alt-Left` and `Alt-Right` the bullet point will be automatically changed to correspond to the new nesting level.
|
||||
|
||||
The first level of list items gets the first bullet point in `g:notes_list_bullets`, the second level gets the second, etc. When you're indenting a list item to a level where the `g:notes_list_bullets` doesn't have enough bullets, the plug-in starts again at the first bullet in the list (in other words the selection of bullets wraps around).
|
||||
|
||||
### The `g:notes_tab_indents` option
|
||||
|
||||
By default `Tab` is mapped to indent list items and `Shift-Tab` is mapped to dedent list items. You can disable these mappings by adding the following to your [vimrc script] [vimrc]:
|
||||
|
||||
:let g:notes_tab_indents = 0
|
||||
|
||||
### The `g:notes_alt_indents` option
|
||||
|
||||
By default `Alt-Right` is mapped to indent list items and `Alt-Left` is mapped to dedent list items. You can disable these mappings by adding the following to your [vimrc script] [vimrc]:
|
||||
|
||||
:let g:notes_alt_indents = 0
|
||||
|
||||
### The `g:notes_shadowdir` option
|
||||
|
||||
The notes plug-in comes with some default notes containing documentation about the plug-in. This option defines the path of the directory containing these notes.
|
||||
|
||||
### The `g:notes_indexfile` option
|
||||
|
||||
This option defines the pathname of the optional keyword index used by the `:SearchNotes` to perform accelerated keyword searching.
|
||||
|
||||
### The `g:notes_indexscript` option
|
||||
|
||||
This option defines the pathname of the Python script that's used to perform accelerated keyword searching with `:SearchNotes`.
|
||||
|
||||
### The `g:notes_tagsindex` option
|
||||
|
||||
This option defines the pathname of the text file that stores the list of known tags used for tag name completion and the `:ShowTaggedNotes` command. The text file is created automatically when it's first needed, after that you can recreate it manually by executing `:IndexTaggedNotes` (see below).
|
||||
|
||||
### The `g:notes_markdown_program` option
|
||||
|
||||
The `:NoteToHtml` command requires the [Markdown] [markdown] program. By default the name of this program is assumed to be simply `markdown`. If you want to use a different program for Markdown to HTML conversion, set this option to the name of the program.
|
||||
|
||||
## Commands
|
||||
|
||||
To edit one of your existing notes (or create a new one) you can use Vim commands such as [:edit] [edit], [:split] [split] and [:tabedit] [tabedit] with a filename that starts with *note:* followed by (part of) the title of one of your notes, e.g.:
|
||||
|
||||
:edit note:todo
|
||||
|
||||
This shortcut also works from the command line:
|
||||
|
||||
$ gvim note:todo
|
||||
|
||||
When you don't follow *note:* with anything a new note is created like when you execute `:Note` without any arguments.
|
||||
|
||||
### The `:Note` command
|
||||
|
||||
When executed without any arguments this command starts a new note in the current window. If you pass one or more arguments the command will edit an existing note containing the given words in the title. If more than one note is found you'll be asked which note you want to edit. If no notes are found a new note is started with the given word(s) as title.
|
||||
|
||||
This command will fail when changes have been made to the current buffer, unless you use `:Note!` which discards any changes.
|
||||
|
||||
When you are using multiple directories to store your notes and you run `:Note` while editing an existing note, a new note will inherit the directory of the note from which you started. Otherwise the note is created in the first directory in `g:notes_directories`.
|
||||
|
||||
*This command supports tab completion:* If you complete one word, all existing notes containing the given word somewhere in their title are suggested. If you type more than one word separated by spaces, the plug-in will complete only the missing words so that the resulting command line contains the complete note title and nothing more.
|
||||
|
||||
### The `:NoteFromSelectedText` command
|
||||
|
||||
Start a new note in the current window with the selected text as the title of the note. The name of this command isn't very well suited to daily use, that's because it's intended to be executed from a mapping. The default mapping for this command is `\en` (the backslash is actually the character defined by the [mapleader] [mapleader] variable).
|
||||
|
||||
When you are using multiple directories to store your notes and you run `:NoteFromSelectedText` while editing an existing note, the new note will inherit the directory of the note from which it was created.
|
||||
|
||||
### The `:SplitNoteFromSelectedText` command
|
||||
|
||||
Same as `:NoteFromSelectedText` but opens the new note in a vertical split window. The default mapping for this command is `\sn`.
|
||||
|
||||
### The `:TabNoteFromSelectedText` command
|
||||
|
||||
Same as `:NoteFromSelectedText` but opens the new note in a new tab page. The default mapping for this command is `\tn`.
|
||||
|
||||
### The `:DeleteNote` command
|
||||
|
||||
The `:DeleteNote` command deletes a note file, destroys the buffer and removes the note from the internal cache of filenames and note titles. If you pass a note name as an argument to `:DeleteNote` it will delete the given note, otherwise it will delete the current note. This fails when changes have been made to the buffer, unless you use `:DeleteNote!` which discards any changes.
|
||||
|
||||
### The `:SearchNotes` command
|
||||
|
||||
This command wraps [:vimgrep] [vimgrep] and enables you to search through your notes using one or more keywords or a regular expression pattern. To search for a pattern you pass a single argument that starts/ends with a slash:
|
||||
|
||||
:SearchNotes /TODO\|FIXME\|XXX/
|
||||
|
||||
To search for one or more keywords you can just omit the slashes, this matches notes containing all of the given keywords:
|
||||
|
||||
:SearchNotes syntax highlighting
|
||||
|
||||
#### `:SearchNotes` understands @tags
|
||||
|
||||
If you don't pass any arguments to the `:SearchNotes` command it will search for the word under the cursor. If the word under the cursor starts with '@' this character will be included in the search, which makes it possible to easily add *@tags* to your *@notes* and then search for those tags. To make searching for tags even easier you can create key mappings for the `:SearchNotes` command:
|
||||
|
||||
" Make the C-] combination search for @tags:
|
||||
imap <C-]> <C-o>:SearchNotes<CR>
|
||||
nmap <C-]> :SearchNotes<CR>
|
||||
|
||||
" Make double mouse click search for @tags. This is actually quite a lot of
|
||||
" fun if you don't use the mouse for text selections anyway; you can click
|
||||
" between notes as if you're in a web browser:
|
||||
imap <2-LeftMouse> <C-o>:SearchNotes<CR>
|
||||
nmap <2-LeftMouse> :SearchNotes<CR>
|
||||
|
||||
These mappings are currently not enabled by default because they conflict with already useful key mappings, but if you have any suggestions for alternatives feel free to contact me through GitHub or at <peter@peterodding.com>.
|
||||
|
||||
#### Accelerated searching with Python
|
||||
|
||||
After collecting a fair amount of notes (say more than 5 MB) you will probably start to get annoyed at how long it takes Vim to search through all of your notes. To make searching more scalable the notes plug-in includes a Python script which uses a persistent full text index of your notes stored in a file.
|
||||
|
||||
The first time the Python script is run it will need to build the complete index which can take a moment, but after the index has been initialized updates and searches should be more or less instantaneous.
|
||||
|
||||
### The `:RelatedNotes` command
|
||||
|
||||
This command makes it easy to find all notes related to the current file: If you are currently editing a note then a search for the note's title is done, otherwise this searches for the absolute path of the current file.
|
||||
|
||||
### The `:RecentNotes` command
|
||||
|
||||
If you execute the `:RecentNotes` command it will open a Vim buffer that lists all your notes grouped by the day they were edited, starting with your most recently edited note. If you pass an argument to `:RecentNotes` it will filter the list of notes by matching the title of each note against the argument which is interpreted as a Vim pattern.
|
||||
|
||||
### The `:MostRecentNote` command
|
||||
|
||||
This command edits your most recently edited note (whether you just opened the note or made changes to it). The plug-in will remember the most recent note between restarts of Vim and is shared between all instances of Vim.
|
||||
|
||||
### The `:ShowTaggedNotes` command
|
||||
|
||||
To show a list of all notes that contains *@tags* you can use the `:ShowTaggedNotes` command. If you pass a count to this command it will limit the list of tags to those that have been used at least this many times. For example the following two commands show tags that have been used at least ten times:
|
||||
|
||||
:10ShowTaggedNotes
|
||||
:ShowTaggedNotes 10
|
||||
|
||||
### The `:IndexTaggedNotes` command
|
||||
|
||||
The notes plug-in defines an omni completion function that can be used to complete the names of tags. To trigger the omni completion you type Control-X Control-O. When you type `@` in insert mode the plug-in will automatically start omni completion.
|
||||
|
||||
The completion menu is populated from a text file listing all your tags, one on each line. The first time omni completion triggers, an index of tag names is generated and saved to the location set by `g:notes_tagsindex`. After this file is created, it will be updated automatically as you edit notes and add/remove tags.
|
||||
|
||||
If for any reason you want to recreate the list of tags you can execute the `:IndexTaggedNotes` command.
|
||||
|
||||
### The `:NoteToHtml` command
|
||||
|
||||
This command converts the current note to HTML. It works by first converting the current note to [Markdown] [markdown] and then using the `markdown` program to convert that to HTML. It requires an external program to convert Markdown to HTML. By default the program `markdown` is used, but you can change the name of the program using the `g:notes_markdown_program` option.
|
||||
|
||||
Note that this command can be a bit slow, because the parser for the note taking syntax is written in Vim script (for portability) and has not been optimized for speed (yet).
|
||||
|
||||
### The `:NoteToMarkdown` command
|
||||
|
||||
Convert the current note to a [Markdown document] [markdown]. The vim-notes syntax shares a lot of similarities with the Markdown text format, but there are some notable differences, which this command takes care of:
|
||||
|
||||
* The first line of a note is an implicit document title. In Markdown format it has to be marked with `#`. This also implies that the remaining headings should be shifted by one level.
|
||||
|
||||
* Preformatted blocks are marked very differently in notes and Markdown (`{{{` and `}}}` markers versus 4 space indentation).
|
||||
|
||||
* The markers and indentation of list items differ between notes and Markdown (dumb bullets vs Unicode bullets and 3 vs 4 spaces).
|
||||
|
||||
Note that this command can be a bit slow, because the parser for the note taking syntax is written in Vim script (for portability) and has not been optimized for speed (yet).
|
||||
|
||||
## Mappings
|
||||
|
||||
The following key mappings are defined inside notes.
|
||||
|
||||
### Insert mode mappings
|
||||
|
||||
* `@` automatically triggers tag completion
|
||||
* `'` becomes `‘` or `’` depending on where you type it
|
||||
* `"` becomes `“` or `”` (same goes for these)
|
||||
* `--` becomes `—`
|
||||
* `->` becomes `→`
|
||||
* `<-` becomes `←`
|
||||
* the bullets `*`, `-` and `+` become `•`
|
||||
* the three characters `***` in insert mode in quick succession insert a horizontal ruler delimited by empty lines
|
||||
* `Tab` and `Alt-Right` increase indentation of list items (works on the current line and selected lines)
|
||||
* `Shift-Tab` and `Alt-Left` decrease indentation of list items
|
||||
* `Enter` on a line with only a list bullet removes the bullet and starts a new line below the current line
|
||||
* `\en` executes `:NoteFromSelectedText`
|
||||
* `\sn` executes `:SplitNoteFromSelectedText`
|
||||
* `\tn` executes `:TabNoteFromSelectedText`
|
||||
|
||||
## Customizing the syntax highlighting of notes
|
||||
|
||||
The syntax mode for notes is written so you can override styles you don't like. To do so you can add lines such as the following to your [vimrc script] [vimrc]:
|
||||
|
||||
" Don't highlight single quoted strings.
|
||||
highlight link notesSingleQuoted Normal
|
||||
|
||||
" Show double quoted strings in italic font.
|
||||
highlight notesDoubleQuoted gui=italic
|
||||
|
||||
See the documentation of the [:highlight] [highlight] command for more information. Below are the names of the syntax items defined by the notes syntax mode:
|
||||
|
||||
* `notesName` - the names of other notes, usually highlighted as a hyperlink
|
||||
* `notesTagName` - words preceded by an `@` character, also highlighted as a hyperlink
|
||||
* `notesListBullet` - the bullet characters used for list items
|
||||
* `notesListNumber` - numbers in front of list items
|
||||
* `notesDoubleQuoted` - double quoted strings
|
||||
* `notesSingleQuoted` - single quoted strings
|
||||
* `notesItalic` - strings between two `_` characters
|
||||
* `notesBold` - strings between two `*` characters
|
||||
* `notesTextURL` - plain domain name (recognized by leading `www.`)
|
||||
* `notesRealURL` - URLs (e.g. <http://vim.org/>)
|
||||
* `notesEmailAddr` - e-mail addresses
|
||||
* `notesUnixPath` - UNIX file paths (e.g. `~/.vimrc` and `/home/peter/.vimrc`)
|
||||
* `notesPathLnum` - line number following a UNIX path
|
||||
* `notesWindowsPath` - Windows file paths (e.g. `c:\users\peter\_vimrc`)
|
||||
* `notesTodo` - `TODO` markers
|
||||
* `notesXXX` - `XXX` markers
|
||||
* `notesFixMe` - `FIXME` markers
|
||||
* `notesInProgress` - `CURRENT`, `INPROGRESS`, `STARTED` and `WIP` markers
|
||||
* `notesDoneItem` - lines containing the marker `DONE`, usually highlighted as a comment
|
||||
* `notesDoneMarker` - `DONE` markers
|
||||
* `notesVimCmd` - Vim commands, words preceded by an `:` character
|
||||
* `notesTitle` - the first line of each note
|
||||
* `notesShortHeading` - short sentences ending in a `:` character
|
||||
* `notesAtxHeading` - lines preceded by one or more `#` characters
|
||||
* `notesBlockQuote` - lines preceded by a `>` character
|
||||
* `notesRule` - lines containing only whitespace and `* * *`
|
||||
* `notesCodeStart` - the `{{{` markers that begin a block of code (including the syntax name)
|
||||
* `notesCodeEnd` - the `}}}` markers that end a block of code
|
||||
* `notesModeLine` - Vim [modeline] [modeline] in last line of notes
|
||||
* `notesLastEdited` - last edited dates in `:ShowTaggedNotes` buffers
|
||||
|
||||
## Other plug-ins that work well with the notes plug-in
|
||||
|
||||
### utl.vim
|
||||
|
||||
The [utl.vim] [utl] universal text linking plug-in enables links between your notes, other local files and remote resources like web pages.
|
||||
|
||||
### shell.vim
|
||||
|
||||
My [shell.vim] [shell] plug-in also enables easy navigation between your notes and environment like local files and directories, web pages and e-mail addresses by providing key mappings and commands to e.g. open the file/URL under the text cursor. This plug-in can also change Vim to full screen which can be really nice for large notes.
|
||||
|
||||
### VOoM
|
||||
|
||||
The [VOoM] [voom] outlining plug-in should work well for notes if you use the Markdown style headers starting with `#`, however it has been reported that this combination may not always work so well in practice (sometimes losing notes!)
|
||||
|
||||
### Txtfmt
|
||||
|
||||
If the text formatting supported by the notes plug-in is not enough for you, consider trying the [Txtfmt] [txtfmt] (The Vim Highlighter) plug-in. To use the two plug-ins together, create the file `after/ftplugin/notes.vim` inside your Vim profile with the following contents:
|
||||
|
||||
" Enable Txtfmt formatting inside notes.
|
||||
setlocal filetype=notes.txtfmt
|
||||
|
||||
## Contact
|
||||
|
||||
If you have questions, bug reports, suggestions, etc. the author can be contacted at <peter@peterodding.com>. The latest version is available at <http://peterodding.com/code/vim/notes/> and <http://github.com/xolox/vim-notes>. If you like the script please vote for it on [Vim Online] [vim_online].
|
||||
|
||||
## License
|
||||
|
||||
This software is licensed under the [MIT license] [mit].
|
||||
© 2013 Peter Odding <<peter@peterodding.com>>.
|
||||
|
||||
|
||||
[ctrlwf]: http://vimdoc.sourceforge.net/htmldoc/windows.html#CTRL-W_f
|
||||
[ctrlwgf]: http://vimdoc.sourceforge.net/htmldoc/windows.html#CTRL-W_gf
|
||||
[download-misc]: http://peterodding.com/code/vim/downloads/misc.zip
|
||||
[download-notes]: http://peterodding.com/code/vim/downloads/notes.zip
|
||||
[edit]: http://vimdoc.sourceforge.net/htmldoc/editing.html#:edit
|
||||
[gf]: http://vimdoc.sourceforge.net/htmldoc/editing.html#gf
|
||||
[github-misc]: http://github.com/xolox/vim-misc
|
||||
[github-notes]: http://github.com/xolox/vim-notes
|
||||
[highlight]: http://vimdoc.sourceforge.net/htmldoc/syntax.html#:highlight
|
||||
[levenshtein]: http://en.wikipedia.org/wiki/Levenshtein_distance
|
||||
[mapleader]: http://vimdoc.sourceforge.net/htmldoc/map.html#mapleader
|
||||
[markdown]: http://en.wikipedia.org/wiki/Markdown
|
||||
[mit]: http://en.wikipedia.org/wiki/MIT_License
|
||||
[modeline]: http://vimdoc.sourceforge.net/htmldoc/options.html#modeline
|
||||
[monaco]: http://en.wikipedia.org/wiki/Monaco_(typeface)
|
||||
[pathogen]: http://www.vim.org/scripts/script.php?script_id=2332
|
||||
[python]: http://python.org/
|
||||
[shell]: http://www.vim.org/scripts/script.php?script_id=3123
|
||||
[slate]: http://code.google.com/p/vim/source/browse/runtime/colors/slate.vim
|
||||
[split]: http://vimdoc.sourceforge.net/htmldoc/windows.html#:split
|
||||
[tabedit]: http://vimdoc.sourceforge.net/htmldoc/tabpage.html#:tabedit
|
||||
[txtfmt]: http://www.vim.org/scripts/script.php?script_id=2208
|
||||
[update]: http://vimdoc.sourceforge.net/htmldoc/editing.html#:update
|
||||
[utl]: http://www.vim.org/scripts/script.php?script_id=293
|
||||
[vim]: http://www.vim.org/
|
||||
[vim_online]: http://www.vim.org/scripts/script.php?script_id=3375
|
||||
[vimgrep]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:vimgrep
|
||||
[vimrc]: http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc
|
||||
[voom]: http://www.vim.org/scripts/script.php?script_id=2657
|
||||
[vundle]: https://github.com/gmarik/vundle
|
||||
[write]: http://vimdoc.sourceforge.net/htmldoc/editing.html#:write
|
15
sources_non_forked/vim-notes/TODO.md
Normal file
15
sources_non_forked/vim-notes/TODO.md
Normal file
@ -0,0 +1,15 @@
|
||||
# To-do list for the `notes.vim` plug-in
|
||||
|
||||
* The note name highlighting uses word boundaries so that 'git' inside 'fugitive' is not highlighted, however this breaks highlighting of note names ending in punctuation (or more generically ending in non-word characters).
|
||||
* The `ftplugin/notes.vim` script used to clear the [matchpairs] [matchpairs] option so that pairs of characters are not highlighted in notes (the irrelevant highlighting was starting to annoy me). Several people have since complained that Vim rings a bell or flashes the screen for every key press in insert mode when editing notes. I've now removed the matchpairs manipulation from the plug-in but I suspect that this may actually be a bug in Vim; to be investigated. See also [issue 10 on GitHub] [issue_10].
|
||||
* Override `<F1>` to show a quick reference of available commands?
|
||||
* Define aliases of the available commands that start with `Note` (to help people getting started with the plug-in).
|
||||
* Add a key mapping to toggle text folding (currently in my `~/.vimrc`)
|
||||
* Add a key mapping or command to toggle the visibility of `{{{ … }}}` code markers?
|
||||
* Find a good way to support notes with generates contents, e.g. *'all notes'*.
|
||||
* When renaming a note, also update references to the note in other notes? (make this optional of course!)
|
||||
* Improve highlighting of lines below a line with a `DONE` marker; when navigating over such lines, the highlighting will sometimes disappear (except on the first line). See also [issue #2 on GitHub] [issue_2].
|
||||
|
||||
[issue_2]: https://github.com/xolox/vim-notes/issues/2
|
||||
[issue_10]: https://github.com/xolox/vim-notes/issues/10
|
||||
[matchpairs]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27matchpairs%27
|
1
sources_non_forked/vim-notes/addon-info.json
Normal file
1
sources_non_forked/vim-notes/addon-info.json
Normal file
@ -0,0 +1 @@
|
||||
{"vim_script_nr": 3375, "dependencies": {"vim-misc": {}}, "homepage": "http://peterodding.com/code/vim/notes", "name": "vim-notes"}
|
1221
sources_non_forked/vim-notes/autoload/xolox/notes.vim
Normal file
1221
sources_non_forked/vim-notes/autoload/xolox/notes.vim
Normal file
File diff suppressed because it is too large
Load Diff
84
sources_non_forked/vim-notes/autoload/xolox/notes/html.vim
Normal file
84
sources_non_forked/vim-notes/autoload/xolox/notes/html.vim
Normal file
@ -0,0 +1,84 @@
|
||||
" Vim auto-load script
|
||||
" Author: Peter Odding <peter@peterodding.com>
|
||||
" Last Change: June 23, 2013
|
||||
" URL: http://peterodding.com/code/vim/notes/
|
||||
|
||||
if !exists('g:notes_markdown_program')
|
||||
let g:notes_markdown_program = 'markdown'
|
||||
endif
|
||||
|
||||
function! xolox#notes#html#view() " {{{1
|
||||
" Convert the current note to a web page and show the web page in a browser.
|
||||
" Requires [Markdown] [markdown] to be installed; you'll get a warning if it
|
||||
" isn't.
|
||||
"
|
||||
" [markdown]: http://en.wikipedia.org/wiki/Markdown
|
||||
try
|
||||
" Convert the note's text to HTML using Markdown.
|
||||
let starttime = xolox#misc#timer#start()
|
||||
let note_title = xolox#notes#current_title()
|
||||
let filename = xolox#notes#title_to_fname(note_title)
|
||||
let note_text = join(getline(1, '$'), "\n")
|
||||
let raw_html = xolox#notes#html#convert_note(note_text)
|
||||
let styled_html = xolox#notes#html#apply_template({
|
||||
\ 'encoding': &encoding,
|
||||
\ 'title': note_title,
|
||||
\ 'content': raw_html,
|
||||
\ 'version': g:xolox#notes#version,
|
||||
\ 'date': strftime('%A %B %d, %Y at %H:%M'),
|
||||
\ 'filename': fnamemodify(filename, ':~'),
|
||||
\ })
|
||||
let filename = s:create_temporary_file(note_title)
|
||||
if writefile(split(styled_html, "\n"), filename) != 0
|
||||
throw printf("Failed to write HTML file! (%s)", filename)
|
||||
endif
|
||||
" Open the generated HTML in a web browser.
|
||||
call xolox#misc#open#url('file://' . filename)
|
||||
call xolox#misc#timer#stop("notes.vim %s: Rendered HTML preview in %s.", g:xolox#notes#version, starttime)
|
||||
catch
|
||||
call xolox#misc#msg#warn("notes.vim %s: %s at %s", g:xolox#notes#version, v:exception, v:throwpoint)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#html#convert_note(note_text) " {{{1
|
||||
" Convert a note's text to a web page (HTML) using the [Markdown text
|
||||
" format] [markdown] as an intermediate format. This function takes the text
|
||||
" of a note (the first argument) and converts it to HTML, returning a
|
||||
" string.
|
||||
if !executable(g:notes_markdown_program)
|
||||
throw "HTML conversion requires the `markdown' program! On Debian/Ubuntu you can install it by executing `sudo apt-get install markdown'."
|
||||
endif
|
||||
let markdown = xolox#notes#markdown#convert_note(a:note_text)
|
||||
let result = xolox#misc#os#exec({'command': g:notes_markdown_program, 'stdin': markdown})
|
||||
let html = join(result['stdout'], "\n")
|
||||
return html
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#html#apply_template(variables) " {{{1
|
||||
" The vim-notes plug-in contains a web page template that's used to provide
|
||||
" a bit of styling when a note is converted to a web page and presented to
|
||||
" the user. This function takes the original HTML produced by [Markdown]
|
||||
" [markdown] (the first argument) and wraps it in the configured template,
|
||||
" returning the final HTML as a string.
|
||||
let filename = expand(g:notes_html_template)
|
||||
call xolox#misc#msg#debug("notes.vim %s: Reading web page template from %s ..", g:xolox#notes#version, filename)
|
||||
let template = join(readfile(filename), "\n")
|
||||
let output = substitute(template, '{{\(.\{-}\)}}', '\= s:template_callback(a:variables)', 'g')
|
||||
return output
|
||||
endfunction
|
||||
|
||||
function! s:template_callback(variables) " {{{1
|
||||
" Callback for xolox#notes#html#apply_template().
|
||||
let key = xolox#misc#str#trim(submatch(1))
|
||||
return get(a:variables, key, '')
|
||||
endfunction
|
||||
|
||||
function! s:create_temporary_file(note_title) " {{{1
|
||||
" Create a temporary filename for a note converted to an HTML document,
|
||||
" based on the title of the note.
|
||||
if !exists('s:temporary_directory')
|
||||
let s:temporary_directory = xolox#misc#path#tempdir()
|
||||
endif
|
||||
let filename = xolox#misc#str#slug(a:note_title) . '.html'
|
||||
return xolox#misc#path#merge(s:temporary_directory, filename)
|
||||
endfunction
|
@ -0,0 +1,94 @@
|
||||
" Vim auto-load script
|
||||
" Author: Peter Odding <peter@peterodding.com>
|
||||
" Last Change: June 23, 2013
|
||||
" URL: http://peterodding.com/code/vim/notes/
|
||||
|
||||
function! xolox#notes#markdown#view() " {{{1
|
||||
" Convert the current note to a Markdown document and show the converted text.
|
||||
let note_text = join(getline(1, '$'), "\n")
|
||||
let markdown_text = xolox#notes#markdown#convert_note(note_text)
|
||||
vnew
|
||||
call setline(1, split(markdown_text, "\n"))
|
||||
setlocal filetype=markdown
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#markdown#convert_note(note_text) " {{{1
|
||||
" Convert a note's text to the [Markdown text format] [markdown]. The syntax
|
||||
" used by vim-notes has a lot of similarities with Markdown, but there are
|
||||
" some notable differences like the note title and the way code blocks are
|
||||
" represented. This function takes the text of a note (the first argument)
|
||||
" and converts it to the Markdown format, returning a string.
|
||||
"
|
||||
" [markdown]: http://en.wikipedia.org/wiki/Markdown
|
||||
let starttime = xolox#misc#timer#start()
|
||||
let blocks = xolox#notes#parser#parse_note(a:note_text)
|
||||
call map(blocks, 'xolox#notes#markdown#convert_block(v:val)')
|
||||
let markdown = join(blocks, "\n\n")
|
||||
call xolox#misc#timer#stop("notes.vim %s: Converted note to Markdown in %s.", g:xolox#notes#version, starttime)
|
||||
return markdown
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#markdown#convert_block(block) " {{{1
|
||||
" Convert a single block produced by `xolox#misc#notes#parser#parse_note()`
|
||||
" (the first argument, expected to be a dictionary) to the [Markdown text
|
||||
" format] [markdown]. Returns a string.
|
||||
if a:block.type == 'title'
|
||||
let text = s:make_urls_explicit(a:block.text)
|
||||
return printf("# %s", text)
|
||||
elseif a:block.type == 'heading'
|
||||
let marker = repeat('#', 1 + a:block.level)
|
||||
let text = s:make_urls_explicit(a:block.text)
|
||||
return printf("%s %s", marker, text)
|
||||
elseif a:block.type == 'code'
|
||||
let comment = "<!-- An innocent comment to force Markdown out of list parsing mode. See also http://meta.stackoverflow.com/a/99637 -->"
|
||||
let text = xolox#misc#str#indent(xolox#misc#str#dedent(a:block.text), 4)
|
||||
return join([comment, text], "\n\n")
|
||||
elseif a:block.type == 'divider'
|
||||
return '* * *'
|
||||
elseif a:block.type == 'list'
|
||||
let items = []
|
||||
if a:block.ordered
|
||||
let counter = 1
|
||||
for item in a:block.items
|
||||
let indent = repeat(' ', item.indent * 4)
|
||||
let text = s:make_urls_explicit(item.text)
|
||||
call add(items, printf("%s%d. %s", indent, counter, text))
|
||||
let counter += 1
|
||||
endfor
|
||||
else
|
||||
for item in a:block.items
|
||||
let indent = repeat(' ', item.indent * 4)
|
||||
let text = s:make_urls_explicit(item.text)
|
||||
call add(items, printf("%s- %s", indent, text))
|
||||
endfor
|
||||
endif
|
||||
return join(items, "\n\n")
|
||||
elseif a:block.type == 'block-quote'
|
||||
let lines = []
|
||||
for line in a:block.lines
|
||||
let prefix = repeat('>', line.level)
|
||||
call add(lines, printf('%s %s', prefix, line.text))
|
||||
endfor
|
||||
return join(lines, "\n")
|
||||
elseif a:block.type == 'paragraph'
|
||||
let text = s:make_urls_explicit(a:block.text)
|
||||
if len(text) <= 50 && text =~ ':$'
|
||||
let text = printf('**%s**', text)
|
||||
endif
|
||||
return text
|
||||
else
|
||||
let msg = "Encountered unsupported block: %s!"
|
||||
throw printf(msg, string(a:block))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:make_urls_explicit(text) " {{{1
|
||||
" In the vim-notes syntax, URLs are implicitly hyperlinks.
|
||||
" In Markdown syntax they have to be wrapped in <markers>.
|
||||
return substitute(a:text, g:xolox#notes#url_pattern, '\= s:url_callback(submatch(0))', 'g')
|
||||
endfunction
|
||||
|
||||
function! s:url_callback(url)
|
||||
let label = substitute(a:url, '^\w\+:\(//\)\?', '', '')
|
||||
return printf('[%s](%s)', label, a:url)
|
||||
endfunction
|
333
sources_non_forked/vim-notes/autoload/xolox/notes/parser.vim
Normal file
333
sources_non_forked/vim-notes/autoload/xolox/notes/parser.vim
Normal file
@ -0,0 +1,333 @@
|
||||
" Vim auto-load script
|
||||
" Author: Peter Odding <peter@peterodding.com>
|
||||
" Last Change: July 18, 2013
|
||||
" URL: http://peterodding.com/code/vim/notes/
|
||||
|
||||
function! xolox#notes#parser#parse_note(text) " {{{1
|
||||
" Parser for the note taking syntax used by vim-notes.
|
||||
let starttime = xolox#misc#timer#start()
|
||||
let context = s:create_parse_context(a:text)
|
||||
let note_title = context.next_line()
|
||||
let blocks = [{'type': 'title', 'text': note_title}]
|
||||
while context.has_more()
|
||||
let chr = context.peek(1)
|
||||
if chr == "\n"
|
||||
" Ignore empty lines.
|
||||
call context.next(1)
|
||||
continue
|
||||
elseif chr == '#'
|
||||
let block = s:parse_heading(context)
|
||||
elseif chr == '>'
|
||||
let block = s:parse_block_quote(context)
|
||||
elseif chr == '{' && context.peek(3) == "\{\{\{"
|
||||
let block = s:parse_code_block(context)
|
||||
else
|
||||
let lookahead = s:match_bullet_or_divider(context, 0)
|
||||
if !empty(lookahead)
|
||||
if lookahead.type =~ 'list'
|
||||
let block = s:parse_list(context)
|
||||
elseif lookahead.type == 'divider'
|
||||
let block = s:parse_divider(context)
|
||||
else
|
||||
let msg = "Programming error! Unsupported lookahead: %s."
|
||||
throw printf(msg, string(lookahead))
|
||||
endif
|
||||
else
|
||||
let block = s:parse_paragraph(context)
|
||||
endif
|
||||
endif
|
||||
" Don't include empty blocks in the output.
|
||||
if !empty(block)
|
||||
call add(blocks, block)
|
||||
endif
|
||||
endwhile
|
||||
call xolox#misc#timer#stop("notes.vim %s: Parsed note into %i blocks in %s.", g:xolox#notes#version, len(blocks), starttime)
|
||||
return blocks
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#parser#view_parse_nodes() " {{{1
|
||||
" Parse the current note and show the parse nodes in a temporary buffer.
|
||||
let note_text = join(getline(1, '$'), "\n")
|
||||
let parse_nodes = xolox#notes#parser#parse_note(note_text)
|
||||
vnew
|
||||
call setline(1, map(parse_nodes, 'string(v:val)'))
|
||||
setlocal filetype=vim nomodified nowrap
|
||||
endfunction
|
||||
|
||||
function! s:create_parse_context(text) " {{{1
|
||||
" Create an object to encapsulate the lowest level of parser state.
|
||||
let context = {'text': a:text, 'index': 0}
|
||||
" The has_more() method returns 1 (true) when more input is available, 0
|
||||
" (false) otherwise.
|
||||
function context.has_more()
|
||||
return self.index < len(self.text)
|
||||
endfunction
|
||||
" The peek() method returns the next character without consuming it.
|
||||
function context.peek(n)
|
||||
if self.has_more()
|
||||
return self.text[self.index : self.index + (a:n - 1)]
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
" The next() method returns the next character and consumes it.
|
||||
function context.next(n)
|
||||
let result = self.peek(a:n)
|
||||
let self.index += a:n
|
||||
return result
|
||||
endfunction
|
||||
" The next_line() method returns the current line and consumes it.
|
||||
function context.next_line()
|
||||
let line = ''
|
||||
while self.has_more()
|
||||
let chr = self.next(1)
|
||||
if chr == "\n" || chr == ""
|
||||
" We hit the end of line or input.
|
||||
return line
|
||||
else
|
||||
" The line continues.
|
||||
let line .= chr
|
||||
endif
|
||||
endwhile
|
||||
return line
|
||||
endfunction
|
||||
return context
|
||||
endfunction
|
||||
|
||||
function! s:match_bullet_or_divider(context, consume_lookahead) " {{{1
|
||||
" Check whether the current line starts with a list bullet.
|
||||
let result = {}
|
||||
let context = copy(a:context)
|
||||
let line = context.next_line()
|
||||
let bullet = matchstr(line, s:bullet_pattern)
|
||||
if !empty(bullet)
|
||||
" Disambiguate list bullets from horizontal dividers.
|
||||
if line =~ '^\s\+\*\s\*\s\*$'
|
||||
let result.type = 'divider'
|
||||
else
|
||||
" We matched a bullet! Now we still need to distinguish ordered from
|
||||
" unordered list items.
|
||||
if bullet =~ '\d'
|
||||
let result.type = 'ordered-list'
|
||||
else
|
||||
let result.type = 'unordered-list'
|
||||
endif
|
||||
let indent = matchstr(bullet, '^\s*')
|
||||
let result.indent = len(indent)
|
||||
" Since we already skipped the whitespace and matched the bullet, it's
|
||||
" very little work to mark our position for the benefit of the caller.
|
||||
if a:consume_lookahead
|
||||
let a:context.index += len(bullet)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:match_line(context) " {{{1
|
||||
" Get the text of the current line, stopping at end of the line or just
|
||||
" before the start of a code block marker, whichever comes first.
|
||||
let line = ''
|
||||
while a:context.has_more()
|
||||
let chr = a:context.peek(1)
|
||||
if chr == '{' && a:context.peek(3) == "\{\{\{"
|
||||
" XXX The start of a code block implies the end of whatever came before.
|
||||
" The marker above contains back slashes so that Vim doesn't apply
|
||||
" folding because of the marker :-).
|
||||
return line
|
||||
elseif chr == "\n"
|
||||
call a:context.next(1)
|
||||
return line . "\n"
|
||||
else
|
||||
let line .= a:context.next(1)
|
||||
endif
|
||||
endwhile
|
||||
" We hit the end of the input.
|
||||
return line
|
||||
endfunction
|
||||
|
||||
function! s:parse_heading(context) " {{{1
|
||||
" Parse the upcoming heading in the input stream.
|
||||
let level = 0
|
||||
while a:context.peek(1) == '#'
|
||||
let level += 1
|
||||
call a:context.next(1)
|
||||
endwhile
|
||||
let text = xolox#misc#str#trim(s:match_line(a:context))
|
||||
return {'type': 'heading', 'level': level, 'text': text}
|
||||
endfunction
|
||||
|
||||
function! s:parse_block_quote(context) " {{{1
|
||||
" Parse the upcoming block quote in the input stream.
|
||||
let lines = []
|
||||
while a:context.has_more()
|
||||
if a:context.peek(1) != '>'
|
||||
break
|
||||
endif
|
||||
let line = s:match_line(a:context)
|
||||
let level = len(matchstr(line, '^>\+'))
|
||||
let text = matchstr(line, '^>\+\s*\zs.\{-}\ze\_s*$')
|
||||
call add(lines, {'level': level, 'text': text})
|
||||
endwhile
|
||||
return {'type': 'block-quote', 'lines': lines}
|
||||
endfunction
|
||||
|
||||
function! s:parse_code_block(context) " {{{1
|
||||
" Parse the upcoming code block in the input stream.
|
||||
let language = ''
|
||||
let text = ''
|
||||
" Skip the start marker.
|
||||
call a:context.next(3)
|
||||
" Get the optional language name.
|
||||
while a:context.peek(1) =~ '\w'
|
||||
let language .= a:context.next(1)
|
||||
endwhile
|
||||
" Skip the whitespace separating the start marker and/or language name from
|
||||
" the text.
|
||||
while a:context.peek(1) =~ '[ \t]'
|
||||
call a:context.next(1)
|
||||
endwhile
|
||||
" Get the text inside the code block.
|
||||
while a:context.has_more()
|
||||
let chr = a:context.next(1)
|
||||
if chr == '}' && a:context.peek(2) == '}}'
|
||||
call a:context.next(2)
|
||||
break
|
||||
endif
|
||||
let text .= chr
|
||||
endwhile
|
||||
" Strip trailing whitespace.
|
||||
let text = substitute(text, '\_s\+$', '', '')
|
||||
return {'type': 'code', 'language': language, 'text': text}
|
||||
endfunction
|
||||
|
||||
function! s:parse_divider(context) " {{{1
|
||||
" Parse the upcoming horizontal divider in the input stream.
|
||||
call a:context.next_line()
|
||||
return {'type': 'divider'}
|
||||
endfunction
|
||||
|
||||
function! s:parse_list(context) " {{{1
|
||||
" Parse the upcoming sequence of list items in the input stream.
|
||||
let list_type = 'unknown'
|
||||
let items = []
|
||||
let lines = []
|
||||
let indent = 0
|
||||
" Outer loop to consume one or more list items.
|
||||
while a:context.has_more()
|
||||
let lookahead = s:match_bullet_or_divider(a:context, 1)
|
||||
if !empty(lookahead)
|
||||
" Save the previous list item with the old indent level.
|
||||
call s:save_item(items, lines, indent)
|
||||
let lines = []
|
||||
" Set the new indent level (three spaces -> one level).
|
||||
let indent = lookahead.indent / 3
|
||||
" The current line starts with a list bullet.
|
||||
if list_type == 'unknown'
|
||||
" The first bullet determines the type of list.
|
||||
let list_type = lookahead.type
|
||||
endif
|
||||
endif
|
||||
let line = s:match_line(a:context)
|
||||
call add(lines, line)
|
||||
if line[-1:] != "\n"
|
||||
" XXX When match_line() returns a line that doesn't end in a newline
|
||||
" character, it means either we hit the end of the input or the current
|
||||
" line continues in a code block (which is not ours to parse :-).
|
||||
break
|
||||
elseif line =~ '^\_s*$'
|
||||
" For now an empty line terminates the list item.
|
||||
" TODO Add support for list items with multiple paragraphs of text.
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
call s:save_item(items, lines, indent)
|
||||
return {'type': 'list', 'ordered': (list_type == 'ordered-list'), 'items': items}
|
||||
endfunction
|
||||
|
||||
function! s:save_item(items, lines, indent)
|
||||
let text = join(a:lines, "\n")
|
||||
if text =~ '\S'
|
||||
let text = xolox#misc#str#compact(text)
|
||||
call add(a:items, {'text': text, 'indent': a:indent})
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:parse_paragraph(context) " {{{1
|
||||
" Parse the upcoming paragraph in the input stream.
|
||||
let lines = []
|
||||
while a:context.has_more()
|
||||
if !empty(s:match_bullet_or_divider(a:context, 0))
|
||||
" If the next line starts with a list bullet it shouldn't
|
||||
" be included in the paragraph we're currently parsing.
|
||||
break
|
||||
else
|
||||
let line = s:match_line(a:context)
|
||||
call add(lines, line)
|
||||
if line =~ '^\_s*$'
|
||||
" An empty line marks the end of the paragraph.
|
||||
break
|
||||
elseif line[-1:] != "\n"
|
||||
" XXX When match_line() returns a line that doesn't end in a newline
|
||||
" character, it means either we hit the end of the input or the current
|
||||
" line continues in a code block (which is not ours to parse :-).
|
||||
break
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
" Don't include empty paragraphs in the output.
|
||||
let text = join(lines, "\n")
|
||||
if text =~ '\S'
|
||||
return {'type': 'paragraph', 'text': xolox#misc#str#compact(text)}
|
||||
else
|
||||
return {}
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:generate_list_item_bullet_pattern() " {{{1
|
||||
" Generate a regular expression that matches any kind of list bullet.
|
||||
let choices = copy(g:notes_unicode_bullets)
|
||||
for bullet in g:notes_ascii_bullets
|
||||
call add(choices, xolox#misc#escape#pattern(bullet))
|
||||
endfor
|
||||
call add(choices, '\d\+[[:punct:]]\?')
|
||||
return join(choices, '\|')
|
||||
endfunction
|
||||
|
||||
let s:bullet_pattern = '^\s*\(' . s:generate_list_item_bullet_pattern() . '\)\s\+'
|
||||
|
||||
function! xolox#notes#parser#run_tests() " {{{1
|
||||
" Tests for the note taking syntax parser.
|
||||
call xolox#misc#test#reset()
|
||||
call xolox#misc#test#wrap('xolox#notes#parser#test_parsing_of_note_titles')
|
||||
call xolox#misc#test#wrap('xolox#notes#parser#test_parsing_of_headings')
|
||||
call xolox#misc#test#wrap('xolox#notes#parser#test_parsing_of_paragraphs')
|
||||
call xolox#misc#test#wrap('xolox#notes#parser#test_parsing_of_code_blocks')
|
||||
call xolox#misc#test#wrap('xolox#notes#parser#test_parsing_of_list_items')
|
||||
call xolox#misc#test#wrap('xolox#notes#parser#test_parsing_of_block_quotes')
|
||||
call xolox#misc#test#summarize()
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#parser#test_parsing_of_note_titles()
|
||||
call xolox#misc#test#assert_equals([{'type': 'title', 'text': 'Just the title'}], xolox#notes#parser#parse_note('Just the title'))
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#parser#test_parsing_of_headings()
|
||||
call xolox#misc#test#assert_equals([{'type': 'title', 'text': 'Just the title'}, {'type': 'heading', 'level': 1, 'text': 'This is a heading'}], xolox#notes#parser#parse_note("Just the title\n\n# This is a heading"))
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#parser#test_parsing_of_paragraphs()
|
||||
call xolox#misc#test#assert_equals([{'type': 'title', 'text': 'Just the title'}, {'type': 'paragraph', 'text': 'This is a paragraph'}], xolox#notes#parser#parse_note("Just the title\n\nThis is a paragraph"))
|
||||
call xolox#misc#test#assert_equals([{'type': 'title', 'text': 'Just the title'}, {'type': 'paragraph', 'text': 'This is a paragraph'}, {'type': 'paragraph', 'text': "And here's another paragraph!"}], xolox#notes#parser#parse_note("Just the title\n\nThis is a paragraph\n\n\n\nAnd here's another paragraph!"))
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#parser#test_parsing_of_code_blocks()
|
||||
call xolox#misc#test#assert_equals([{'type': 'title', 'text': 'Just the title'}, {'type': 'code', 'language': '', 'text': "This is a code block\nwith two lines"}], xolox#notes#parser#parse_note("Just the title\n\n{{{ This is a code block\nwith two lines }}}"))
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#parser#test_parsing_of_list_items()
|
||||
call xolox#misc#test#assert_equals([{'type': 'title', 'text': 'Just the title'}, {'type': 'list', 'ordered': 1, 'items': [{'indent': 0, 'text': 'item one'}, {'indent': 0, 'text': 'item two'}, {'indent': 0, 'text': 'item three'}]}], xolox#notes#parser#parse_note("Just the title\n\n1. item one\n2. item two\n3. item three"))
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#parser#test_parsing_of_block_quotes()
|
||||
call xolox#misc#test#assert_equals([{'type': 'title', 'text': 'Just the title'}, {'type': 'block-quote', 'lines': [{'level': 1, 'text': 'block'}, {'level': 2, 'text': 'quoted'}, {'level': 1, 'text': 'text'}]}], xolox#notes#parser#parse_note("Just the title\n\n> block\n>> quoted\n> text"))
|
||||
endfunction
|
100
sources_non_forked/vim-notes/autoload/xolox/notes/recent.vim
Normal file
100
sources_non_forked/vim-notes/autoload/xolox/notes/recent.vim
Normal file
@ -0,0 +1,100 @@
|
||||
" Vim auto-load script
|
||||
" Author: Peter Odding <peter@peterodding.com>
|
||||
" Last Change: May 16, 2013
|
||||
" URL: http://peterodding.com/code/vim/notes/
|
||||
|
||||
function! xolox#notes#recent#show(bang, title_filter) " {{{1
|
||||
call xolox#misc#msg#info("notes.vim %s: Generating overview of recent notes ..", g:xolox#notes#version)
|
||||
" Show generated note listing all notes by last modified time.
|
||||
let starttime = xolox#misc#timer#start()
|
||||
let bufname = '[Recent Notes]'
|
||||
" Prepare a buffer to hold the list of recent notes.
|
||||
call xolox#misc#buffer#prepare({
|
||||
\ 'name': bufname,
|
||||
\ 'path': xolox#misc#path#merge($HOME, bufname)})
|
||||
" Filter notes by pattern (argument)?
|
||||
let notes = []
|
||||
let title_filter = '\v' . a:title_filter
|
||||
for [fname, title] in items(xolox#notes#get_fnames_and_titles(0))
|
||||
if title =~? title_filter
|
||||
call add(notes, [getftime(fname), title])
|
||||
endif
|
||||
endfor
|
||||
" Start note with "You have N note(s) [matching filter]".
|
||||
let readme = "You have "
|
||||
if empty(notes)
|
||||
let readme .= "no notes"
|
||||
elseif len(notes) == 1
|
||||
let readme .= "one note"
|
||||
else
|
||||
let readme .= len(notes) . " notes"
|
||||
endif
|
||||
if a:title_filter != ''
|
||||
let quote_format = xolox#notes#unicode_enabled() ? '‘%s’' : "`%s'"
|
||||
let readme .= " matching " . printf(quote_format, a:title_filter)
|
||||
endif
|
||||
" Explain the sorting of the notes.
|
||||
if empty(notes)
|
||||
let readme .= "."
|
||||
elseif len(notes) == 1
|
||||
let readme .= ", it's listed below."
|
||||
else
|
||||
let readme .= ". They're listed below grouped by the day they were edited, starting with your most recently edited note."
|
||||
endif
|
||||
" Add the generated text to the buffer.
|
||||
call setline(1, ["Recent notes", "", readme])
|
||||
" Reformat the text in the buffer to auto-wrap.
|
||||
normal Ggqq
|
||||
" Sort, group and format the list of (matching) notes.
|
||||
let last_date = ''
|
||||
let list_item_format = xolox#notes#unicode_enabled() ? ' • %s' : ' * %s'
|
||||
call sort(notes)
|
||||
call reverse(notes)
|
||||
let lines = []
|
||||
for [ftime, title] in notes
|
||||
let date = xolox#notes#friendly_date(ftime)
|
||||
if date != last_date
|
||||
call add(lines, '')
|
||||
call add(lines, substitute(date, '^\w', '\u\0', '') . ':')
|
||||
let last_date = date
|
||||
endif
|
||||
call add(lines, printf(list_item_format, title))
|
||||
endfor
|
||||
" Add the formatted list of notes to the buffer.
|
||||
call setline(line('$') + 1, lines)
|
||||
" Load the notes file type.
|
||||
call xolox#notes#set_filetype()
|
||||
let &l:statusline = bufname
|
||||
" Change the status line
|
||||
" Lock the buffer contents.
|
||||
call xolox#misc#buffer#lock()
|
||||
" And we're done!
|
||||
call xolox#misc#timer#stop("notes.vim %s: Generated %s in %s.", g:xolox#notes#version, bufname, starttime)
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#recent#track() " {{{1
|
||||
let fname = expand('%:p')
|
||||
let indexfile = expand(g:notes_recentindex)
|
||||
call xolox#misc#msg#debug("notes.vim %s: Recording '%s' as most recent note in %s ..", g:xolox#notes#version, fname, indexfile)
|
||||
if writefile([fname], indexfile) == -1
|
||||
call xolox#misc#msg#warn("notes.vim %s: Failed to record most recent note in %s!", g:xolox#notes#version, indexfile)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#recent#edit(bang) " {{{1
|
||||
" Edit the most recently edited (not necessarily changed) note.
|
||||
let indexfile = expand(g:notes_recentindex)
|
||||
call xolox#misc#msg#debug("notes.vim %s: Recalling most recent note from %s ..", g:xolox#notes#version, indexfile)
|
||||
try
|
||||
let fname = readfile(indexfile)[0]
|
||||
if empty(fname)
|
||||
throw "The index of recent notes is empty?!"
|
||||
endif
|
||||
catch
|
||||
call xolox#misc#msg#warn("notes.vim %s: Failed to recall most recent note from %s: %s", g:xolox#notes#version, indexfile, v:exception)
|
||||
return
|
||||
endtry
|
||||
call xolox#misc#msg#info("notes.vim %s: Editing most recent note '%s' ..", g:xolox#notes#version, fname)
|
||||
execute 'edit' . a:bang fnameescape(fname)
|
||||
call xolox#notes#set_filetype()
|
||||
endfunction
|
201
sources_non_forked/vim-notes/autoload/xolox/notes/tags.vim
Normal file
201
sources_non_forked/vim-notes/autoload/xolox/notes/tags.vim
Normal file
@ -0,0 +1,201 @@
|
||||
" Vim auto-load script
|
||||
" Author: Peter Odding <peter@peterodding.com>
|
||||
" Last Change: May 5, 2013
|
||||
" URL: http://peterodding.com/code/vim/notes/
|
||||
|
||||
if !exists('s:currently_tagged_notes')
|
||||
let s:currently_tagged_notes = {} " The in-memory representation of tags and the notes in which they're used.
|
||||
let s:previously_tagged_notes = {} " Copy of index as it is / should be now on disk (to detect changes).
|
||||
let s:last_disk_sync = 0 " Whether the on-disk representation of the tags has been read.
|
||||
let s:buffer_name = 'Tagged Notes' " The buffer name for the list of tagged notes.
|
||||
let s:loading_index = 0
|
||||
endif
|
||||
|
||||
function! xolox#notes#tags#load_index() " {{{1
|
||||
if s:loading_index
|
||||
" Guard against recursive calls.
|
||||
return s:currently_tagged_notes
|
||||
endif
|
||||
let starttime = xolox#misc#timer#start()
|
||||
let indexfile = expand(g:notes_tagsindex)
|
||||
let lastmodified = getftime(indexfile)
|
||||
if lastmodified == -1
|
||||
let s:loading_index = 1
|
||||
call xolox#notes#tags#create_index()
|
||||
let s:loading_index = 0
|
||||
elseif lastmodified > s:last_disk_sync
|
||||
let s:currently_tagged_notes = {}
|
||||
for line in readfile(indexfile)
|
||||
let filenames = split(line, "\t")
|
||||
if len(filenames) > 1
|
||||
let tagname = remove(filenames, 0)
|
||||
let s:currently_tagged_notes[tagname] = filenames
|
||||
endif
|
||||
endfor
|
||||
let s:previously_tagged_notes = deepcopy(s:currently_tagged_notes)
|
||||
let s:last_disk_sync = lastmodified
|
||||
call xolox#misc#timer#stop("notes.vim %s: Loaded tags index in %s.", g:xolox#notes#version, starttime)
|
||||
endif
|
||||
return s:currently_tagged_notes
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#tags#create_index() " {{{1
|
||||
let exists = filereadable(expand(g:notes_tagsindex))
|
||||
let starttime = xolox#misc#timer#start()
|
||||
let filenames = xolox#notes#get_fnames(0)
|
||||
let s:currently_tagged_notes = {}
|
||||
for idx in range(len(filenames))
|
||||
if filereadable(filenames[idx])
|
||||
let title = xolox#notes#fname_to_title(filenames[idx])
|
||||
call xolox#misc#msg#info("notes.vim %s: Scanning note %i/%i: %s", g:xolox#notes#version, idx + 1, len(filenames), title)
|
||||
call xolox#notes#tags#scan_note(title, join(readfile(filenames[idx]), "\n"))
|
||||
endif
|
||||
endfor
|
||||
if xolox#notes#tags#save_index()
|
||||
let s:previously_tagged_notes = deepcopy(s:currently_tagged_notes)
|
||||
call xolox#misc#timer#stop('notes.vim %s: %s tags index in %s.', g:xolox#notes#version, exists ? "Updated" : "Created", starttime)
|
||||
else
|
||||
call xolox#misc#msg#warn("notes.vim %s: Failed to save tags index as %s!", g:xolox#notes#version, g:notes_tagsindex)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#tags#save_index() " {{{1
|
||||
let indexfile = expand(g:notes_tagsindex)
|
||||
let existingfile = filereadable(indexfile)
|
||||
let nothingchanged = (s:currently_tagged_notes == s:previously_tagged_notes)
|
||||
if existingfile && nothingchanged
|
||||
call xolox#misc#msg#debug("notes.vim %s: Index not dirty so not saved.", g:xolox#notes#version)
|
||||
return 1 " Nothing to be done
|
||||
else
|
||||
let lines = []
|
||||
for [tagname, filenames] in items(s:currently_tagged_notes)
|
||||
call add(lines, join([tagname] + filenames, "\t"))
|
||||
endfor
|
||||
let status = writefile(lines, indexfile) == 0
|
||||
if status
|
||||
call xolox#misc#msg#debug("notes.vim %s: Index saved to %s.", g:xolox#notes#version, g:notes_tagsindex)
|
||||
let s:last_disk_sync = getftime(indexfile)
|
||||
else
|
||||
call xolox#misc#msg#debug("notes.vim %s: Failed to save index to %s.", g:xolox#notes#version, g:notes_tagsindex)
|
||||
endif
|
||||
return status
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#tags#scan_note(title, text) " {{{1
|
||||
" Add a note to the tags index.
|
||||
call xolox#notes#tags#load_index()
|
||||
" Don't scan tags inside code blocks.
|
||||
let text = substitute(a:text, '{{{\w\+\_.\{-}}}}', '', 'g')
|
||||
" Split everything on whitespace.
|
||||
for token in split(text)
|
||||
" Match words that start with @ and don't contain { (BibTeX entries).
|
||||
if token =~ '^@\w' && token !~ '{'
|
||||
" Strip any trailing punctuation.
|
||||
let token = substitute(token[1:], '[[:punct:]]*$', '', '')
|
||||
if token != ''
|
||||
if !has_key(s:currently_tagged_notes, token)
|
||||
let s:currently_tagged_notes[token] = [a:title]
|
||||
elseif index(s:currently_tagged_notes[token], a:title) == -1
|
||||
" Keep the tags sorted.
|
||||
call xolox#misc#list#binsert(s:currently_tagged_notes[token], a:title, 1)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#tags#forget_note(title) " {{{1
|
||||
" Remove a note from the tags index.
|
||||
call xolox#notes#tags#load_index()
|
||||
for tagname in keys(s:currently_tagged_notes)
|
||||
call filter(s:currently_tagged_notes[tagname], "v:val != a:title")
|
||||
if empty(s:currently_tagged_notes[tagname])
|
||||
unlet s:currently_tagged_notes[tagname]
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#tags#show_tags(minsize) " {{{1
|
||||
" TODO Mappings to "zoom" in/out (show only big tags).
|
||||
let starttime = xolox#misc#timer#start()
|
||||
call xolox#notes#tags#load_index()
|
||||
let lines = [s:buffer_name, '']
|
||||
if empty(s:currently_tagged_notes)
|
||||
call add(lines, "You haven't used any tags yet!")
|
||||
else
|
||||
" Create a dictionary with note titles as keys.
|
||||
let unmatched = {}
|
||||
for title in xolox#notes#get_titles(0)
|
||||
let unmatched[title] = 1
|
||||
endfor
|
||||
let totalnotes = len(unmatched)
|
||||
" Group matching notes and remove them from the dictionary.
|
||||
let grouped_notes = []
|
||||
let numtags = 0
|
||||
for tagname in sort(keys(s:currently_tagged_notes), 1)
|
||||
let numnotes = len(s:currently_tagged_notes[tagname])
|
||||
if numnotes >= a:minsize
|
||||
let matched_notes = s:currently_tagged_notes[tagname]
|
||||
for title in matched_notes
|
||||
if has_key(unmatched, title)
|
||||
unlet unmatched[title]
|
||||
endif
|
||||
endfor
|
||||
call add(grouped_notes, {'name': tagname, 'notes': matched_notes})
|
||||
let numtags += 1
|
||||
endif
|
||||
endfor
|
||||
" Add a "fake tag" with all unmatched notes.
|
||||
if !empty(unmatched)
|
||||
call add(grouped_notes, {'name': "Unmatched notes", 'notes': keys(unmatched)})
|
||||
endif
|
||||
" Format the results as a note.
|
||||
let bullet = xolox#notes#get_bullet('*')
|
||||
for group in grouped_notes
|
||||
let tagname = group['name']
|
||||
let friendly_name = xolox#notes#tags#friendly_name(tagname)
|
||||
let numnotes = len(group['notes'])
|
||||
if numnotes >= a:minsize
|
||||
call extend(lines, ['', printf('# %s (%i note%s)', friendly_name, numnotes, numnotes == 1 ? '' : 's'), ''])
|
||||
for title in group['notes']
|
||||
let lastmodified = xolox#notes#friendly_date(getftime(xolox#notes#title_to_fname(title)))
|
||||
call add(lines, ' ' . bullet . ' ' . title . ' (last edited ' . lastmodified . ')')
|
||||
endfor
|
||||
endif
|
||||
endfor
|
||||
if a:minsize <= 1
|
||||
let message = printf("You've used %i %s in %i %s",
|
||||
\ numtags, numtags == 1 ? "tag" : "tags",
|
||||
\ totalnotes, totalnotes == 1 ? "note" : "notes")
|
||||
else
|
||||
let message = printf("There %s %i %s that %s been used at least %s times",
|
||||
\ numtags == 1 ? "is" : "are", numtags,
|
||||
\ numtags == 1 ? "tag" : "tags",
|
||||
\ numtags == 1 ? "has" : "have", a:minsize)
|
||||
endif
|
||||
let message .= ", " . (numtags == 1 ? "it's" : "they're")
|
||||
let message .= " listed below. Tags and notes are sorted alphabetically and after each note is the date when it was last modified."
|
||||
if !empty(unmatched)
|
||||
if a:minsize <= 1
|
||||
let message .= " At the bottom is a list of untagged notes."
|
||||
else
|
||||
let message .= " At the bottom is a list of unmatched notes."
|
||||
endif
|
||||
endif
|
||||
if numtags > 1 && !(&foldmethod == 'expr' && &foldenable)
|
||||
let message .= " You can enable text folding to get an overview of just the tag names and how many times they've been used."
|
||||
endif
|
||||
call insert(lines, message, 2)
|
||||
endif
|
||||
call xolox#misc#buffer#prepare(s:buffer_name)
|
||||
call setline(1, lines)
|
||||
call xolox#misc#buffer#lock()
|
||||
call xolox#notes#set_filetype()
|
||||
setlocal nospell wrap
|
||||
call xolox#misc#timer#stop('notes.vim %s: Generated [%s] in %s.', g:xolox#notes#version, s:buffer_name, starttime)
|
||||
endfunction
|
||||
|
||||
function! xolox#notes#tags#friendly_name(tagname) " {{{1
|
||||
return substitute(a:tagname, '\(\U\)\(\u\)', '\1 \2', 'g')
|
||||
endfunction
|
677
sources_non_forked/vim-notes/doc/notes.txt
Normal file
677
sources_non_forked/vim-notes/doc/notes.txt
Normal file
@ -0,0 +1,677 @@
|
||||
*notes.txt* Easy note taking in Vim
|
||||
|
||||
===============================================================================
|
||||
Contents ~
|
||||
|
||||
1. Introduction |notes-introduction|
|
||||
2. Install & usage |notes-install-usage|
|
||||
3. Options |notes-options|
|
||||
1. The |g:notes_directories| option
|
||||
1. Backwards compatibility |notes-backwards-compatibility|
|
||||
2. The |g:notes_suffix| option
|
||||
3. The |g:notes_title_sync| option
|
||||
4. The |g:notes_smart_quotes| option
|
||||
5. The |g:notes_ruler_text| option
|
||||
6. The |g:notes_list_bullets| option
|
||||
7. The |g:notes_tab_indents| option
|
||||
8. The |g:notes_alt_indents| option
|
||||
9. The |g:notes_shadowdir| option
|
||||
10. The |g:notes_indexfile| option
|
||||
11. The |g:notes_indexscript| option
|
||||
12. The |g:notes_tagsindex| option
|
||||
13. The |g:notes_markdown_program| option
|
||||
4. Commands |notes-commands|
|
||||
1. The |:Note| command
|
||||
2. The |:NoteFromSelectedText| command
|
||||
3. The |:SplitNoteFromSelectedText| command
|
||||
4. The |:TabNoteFromSelectedText| command
|
||||
5. The |:DeleteNote| command
|
||||
6. The |:SearchNotes| command
|
||||
1. |:SearchNotes| understands @tags |searchnotes-understands-tags|
|
||||
2. Accelerated searching with Python |notes-accelerated-searching-with-python|
|
||||
7. The |:RelatedNotes| command
|
||||
8. The |:RecentNotes| command
|
||||
9. The |:MostRecentNote| command
|
||||
10. The |:ShowTaggedNotes| command
|
||||
11. The |:IndexTaggedNotes| command
|
||||
12. The |:NoteToHtml| command
|
||||
13. The |:NoteToMarkdown| command
|
||||
5. Mappings |notes-mappings|
|
||||
1. Insert mode mappings |notes-insert-mode-mappings|
|
||||
6. Customizing the syntax highlighting of notes |customizing-syntax-highlighting-of-notes|
|
||||
7. Other plug-ins that work well with the notes plug-in |other-plug-ins-that-work-well-with-notes-plug-in|
|
||||
1. utl.vim |notes-utl.vim|
|
||||
2. shell.vim |notes-shell.vim|
|
||||
3. VOoM |notes-voom|
|
||||
4. Txtfmt |notes-txtfmt|
|
||||
8. Contact |notes-contact|
|
||||
9. License |notes-license|
|
||||
10. References |notes-references|
|
||||
|
||||
===============================================================================
|
||||
*notes-introduction*
|
||||
Introduction ~
|
||||
|
||||
The vim-notes plug-in for the Vim text editor makes it easy to manage your
|
||||
notes in Vim:
|
||||
|
||||
- **Starting a new note:** Execute the |:Note| command to create a new buffer
|
||||
and load the appropriate file type and syntax
|
||||
|
||||
- You can also start a note with Vim commands like ':edit', ':tabedit' and
|
||||
':split' by starting the filename with 'note:', as in ':edit note:todo'
|
||||
(the part after 'note:' doesn't have to be the complete note title and if
|
||||
it's empty a new note will be created)
|
||||
|
||||
- You can start a new note with the selected text as title in the current
|
||||
window using the '\en' mapping or |:NoteFromSelectedText| command (there
|
||||
are similar mappings and commands for opening split windows and tab pages)
|
||||
|
||||
- **Saving notes:** Just use Vim's |:write| and |:update| commands, you don't
|
||||
need to provide a filename because it will be set based on the title (first
|
||||
line) of your note (you also don't need to worry about special characters,
|
||||
they'll be escaped)
|
||||
|
||||
- **Editing existing notes:** Execute ':Note anything' to edit a note
|
||||
containing 'anything' in its title (if no notes are found a new one is
|
||||
created with its title set to 'anything')
|
||||
|
||||
- The |:Note| and |:DeleteNote| commands support tab completion of note
|
||||
titles
|
||||
|
||||
- **Deleting notes:** The |:DeleteNote| command enables you to delete the
|
||||
current note
|
||||
|
||||
- **Searching notes:**':SearchNotes keyword …' searches for keywords and
|
||||
':SearchNotes /pattern/' searches for regular expressions
|
||||
|
||||
- The |:SearchNotes| command supports tab completion of keywords and sorts
|
||||
candidates by relevance (Levenshtein distance [1])
|
||||
|
||||
- **Smart defaults:** Without an argument |:SearchNotes| searches for the
|
||||
word under the cursor (if the word starts with '@' that character will be
|
||||
included in the search, this means you can easily search for _@tagged_
|
||||
notes)
|
||||
|
||||
- **Back-references:** The |:RelatedNotes| command find all notes referencing
|
||||
the current file
|
||||
|
||||
- A Python 2 [2] script is included that accelerates keyword searches using a
|
||||
keyword index
|
||||
|
||||
- The |:RecentNotes| command lists your notes by modification date, starting
|
||||
with the most recently edited note
|
||||
|
||||
- **Navigating between notes:** The included syntax script highlights note
|
||||
names as hyper links and the file type plug-in redefines |gf| to jump
|
||||
between notes (the Control-w f (see |CTRL-W_f|) mapping to jump to a note
|
||||
in a split window and the Control-w gf (see |CTRL-W_gf|) mapping to jump to
|
||||
a note in a new tab page also work)
|
||||
|
||||
- **Writing aids:** The included file type plug-in contains mappings for
|
||||
automatic curly quotes, arrows and list bullets and supports completion of
|
||||
note titles using Control-X Control-U and completion of tags using
|
||||
Control-X Control-O
|
||||
|
||||
- **Embedded file types:** The included syntax script supports embedded
|
||||
highlighting using blocks marked with '{{{type … }}}' which allows you to
|
||||
embed highlighted code and configuration snippets in your notes
|
||||
|
||||
Here's a screen shot of the syntax mode using the Slate [3] color scheme and
|
||||
the font Monaco [4]:
|
||||
|
||||
Image: Syntax mode screen shot (see reference [5])
|
||||
|
||||
===============================================================================
|
||||
*notes-install-usage*
|
||||
Install & usage ~
|
||||
|
||||
_Please note that the vim-notes plug-in requires my vim-misc plug-in which is
|
||||
separately distributed._
|
||||
|
||||
Unzip the most recent ZIP archives of the vim-notes [6] and vim-misc [7] plug-
|
||||
ins inside your Vim profile directory (usually this is '~/.vim' on UNIX and
|
||||
'%USERPROFILE%\vimfiles' on Windows), restart Vim and execute the command
|
||||
':helptags ~/.vim/doc' (use ':helptags ~\vimfiles\doc' instead on Windows). To
|
||||
get started execute |:Note| or ':edit note:', this will start a new note that
|
||||
contains instructions on how to continue from there (and how to use the plug-in
|
||||
in general).
|
||||
|
||||
If you prefer you can also use Pathogen [8], Vundle [9] or a similar tool to
|
||||
install & update the vim-notes [10] and vim-misc [11] plug-ins using a local
|
||||
clone of the git repository.
|
||||
|
||||
===============================================================================
|
||||
*notes-options*
|
||||
Options ~
|
||||
|
||||
All options have reasonable defaults so if the plug-in works after installation
|
||||
you don't need to change any options. The options are available for people who
|
||||
like to customize how the plug-in works. You can set these options in your
|
||||
|vimrc| script by including a line like this:
|
||||
>
|
||||
:let g:notes_directories = ['~/Documents/Notes', '~/Dropbox/Shared Notes']
|
||||
<
|
||||
Note that after changing an option in your |vimrc| script you have to restart
|
||||
Vim for the changes to take effect.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *g:notes_directories* option
|
||||
|
||||
Your notes are stored in one or more directories. This option defines where you
|
||||
want to store your notes. Its value should be a list (there's an example above)
|
||||
with one or more pathnames. The default is a single value which depends on
|
||||
circumstances but should work for most people:
|
||||
|
||||
- If the profile directory where the plug-in is installed is writable, the
|
||||
directory 'misc/notes/user' under the profile directory is used. This is
|
||||
for compatibility with Pathogen [8]; the notes will be stored inside the
|
||||
plug-in's bundle.
|
||||
|
||||
- If the above doesn't work out, the default depends on the platform:
|
||||
'~/vimfiles/misc/notes/user' on Windows and '~/.vim/misc/notes/user' on
|
||||
other platforms.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
*notes-backwards-compatibility*
|
||||
Backwards compatibility ~
|
||||
|
||||
In the past the notes plug-in only supported a single directory and the
|
||||
corresponding option was called 'g:notes_directory'. When support for multiple
|
||||
notes directories was introduced the option was renamed to
|
||||
|g:notes_directories| to reflect that the value is now a list of directory
|
||||
pathnames.
|
||||
|
||||
For backwards compatibility with old configurations (all of them as of this
|
||||
writing :-) the notes plug-in still uses 'g:notes_directory' when it is defined
|
||||
(its no longer defined by the plug-in). However when the plug-in warns you to
|
||||
change your configuration you probably should because this compatibility will
|
||||
be removed at some point.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *g:notes_suffix* option
|
||||
|
||||
The suffix to add to generated filenames. The plug-in generates filenames for
|
||||
your notes based on the title (first line) of each note and by default these
|
||||
filenames don't include an extension like '.txt'. You can use this option to
|
||||
make the plug-in automatically append an extension without having to embed the
|
||||
extension in the note's title, e.g.:
|
||||
>
|
||||
:let g:notes_suffix = '.txt'
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
The *g:notes_title_sync* option
|
||||
|
||||
When you rename a file in your notes directory but don't change the title, the
|
||||
plug-in will notice this the next time you open the note in Vim. Likewise when
|
||||
you change the title in another text editor but don't rename the file. By
|
||||
default the plug-in will prompt you whether you want it to update the title of
|
||||
the note, rename the file on disk or dismiss the prompt without doing anything.
|
||||
|
||||
If you set this option to the string "'no'" this feature will be completely
|
||||
disabled. If you set it to "'change_title'" it will automatically change the
|
||||
title to match the filename. If you set it to "'rename_file'" it will
|
||||
automatically rename the file on disk to match the title.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *g:notes_smart_quotes* option
|
||||
|
||||
By default the notes plug-in automatically performs several substitutions on
|
||||
the text you type in insert mode, for example regular quote marks are replaced
|
||||
with curly quotes. The full list of substitutions can be found below in the
|
||||
documentation on mappings. If you don't want the plug-in to perform these
|
||||
substitutions, you can set this option to zero like this:
|
||||
>
|
||||
:let g:notes_smart_quotes = 0
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
The *g:notes_ruler_text* option
|
||||
|
||||
The text of the ruler line inserted when you type '***' in quick succession. It
|
||||
defaults to three asterisks separated by spaces, center aligned to the text
|
||||
width.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *g:notes_list_bullets* option
|
||||
|
||||
A list of characters used as list bullets. When you're using a Unicode encoding
|
||||
this defaults to "['•', '◦', '▸', '▹', '▪', '▫']", otherwise it defaults to
|
||||
"['*', '-', '+']".
|
||||
|
||||
When you change the nesting level (indentation) of a line containing a bullet
|
||||
point using one of the mappings 'Tab', 'Shift-Tab', 'Alt-Left' and 'Alt-Right'
|
||||
the bullet point will be automatically changed to correspond to the new nesting
|
||||
level.
|
||||
|
||||
The first level of list items gets the first bullet point in
|
||||
|g:notes_list_bullets|, the second level gets the second, etc. When you're
|
||||
indenting a list item to a level where the |g:notes_list_bullets| doesn't have
|
||||
enough bullets, the plug-in starts again at the first bullet in the list (in
|
||||
other words the selection of bullets wraps around).
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *g:notes_tab_indents* option
|
||||
|
||||
By default 'Tab' is mapped to indent list items and 'Shift-Tab' is mapped to
|
||||
dedent list items. You can disable these mappings by adding the following to
|
||||
your |vimrc| script:
|
||||
>
|
||||
:let g:notes_tab_indents = 0
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
The *g:notes_alt_indents* option
|
||||
|
||||
By default 'Alt-Right' is mapped to indent list items and 'Alt-Left' is mapped
|
||||
to dedent list items. You can disable these mappings by adding the following to
|
||||
your |vimrc| script:
|
||||
>
|
||||
:let g:notes_alt_indents = 0
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
The *g:notes_shadowdir* option
|
||||
|
||||
The notes plug-in comes with some default notes containing documentation about
|
||||
the plug-in. This option defines the path of the directory containing these
|
||||
notes.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *g:notes_indexfile* option
|
||||
|
||||
This option defines the pathname of the optional keyword index used by the
|
||||
|:SearchNotes| to perform accelerated keyword searching.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *g:notes_indexscript* option
|
||||
|
||||
This option defines the pathname of the Python script that's used to perform
|
||||
accelerated keyword searching with |:SearchNotes|.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *g:notes_tagsindex* option
|
||||
|
||||
This option defines the pathname of the text file that stores the list of known
|
||||
tags used for tag name completion and the |:ShowTaggedNotes| command. The text
|
||||
file is created automatically when it's first needed, after that you can
|
||||
recreate it manually by executing |:IndexTaggedNotes| (see below).
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *g:notes_markdown_program* option
|
||||
|
||||
The |:NoteToHtml| command requires the Markdown [12] program. By default the
|
||||
name of this program is assumed to be simply 'markdown'. If you want to use a
|
||||
different program for Markdown to HTML conversion, set this option to the name
|
||||
of the program.
|
||||
|
||||
===============================================================================
|
||||
*notes-commands*
|
||||
Commands ~
|
||||
|
||||
To edit one of your existing notes (or create a new one) you can use Vim
|
||||
commands such as |:edit|, |:split| and |:tabedit| with a filename that starts
|
||||
with _note:_ followed by (part of) the title of one of your notes, e.g.:
|
||||
>
|
||||
:edit note:todo
|
||||
<
|
||||
This shortcut also works from the command line:
|
||||
>
|
||||
$ gvim note:todo
|
||||
<
|
||||
When you don't follow _note:_ with anything a new note is created like when you
|
||||
execute |:Note| without any arguments.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *:Note* command
|
||||
|
||||
When executed without any arguments this command starts a new note in the
|
||||
current window. If you pass one or more arguments the command will edit an
|
||||
existing note containing the given words in the title. If more than one note is
|
||||
found you'll be asked which note you want to edit. If no notes are found a new
|
||||
note is started with the given word(s) as title.
|
||||
|
||||
This command will fail when changes have been made to the current buffer,
|
||||
unless you use ':Note!' which discards any changes.
|
||||
|
||||
When you are using multiple directories to store your notes and you run |:Note|
|
||||
while editing an existing note, a new note will inherit the directory of the
|
||||
note from which you started. Otherwise the note is created in the first
|
||||
directory in |g:notes_directories|.
|
||||
|
||||
_This command supports tab completion:_ If you complete one word, all existing
|
||||
notes containing the given word somewhere in their title are suggested. If you
|
||||
type more than one word separated by spaces, the plug-in will complete only the
|
||||
missing words so that the resulting command line contains the complete note
|
||||
title and nothing more.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *:NoteFromSelectedText* command
|
||||
|
||||
Start a new note in the current window with the selected text as the title of
|
||||
the note. The name of this command isn't very well suited to daily use, that's
|
||||
because it's intended to be executed from a mapping. The default mapping for
|
||||
this command is '\en' (the backslash is actually the character defined by the
|
||||
|mapleader| variable).
|
||||
|
||||
When you are using multiple directories to store your notes and you run
|
||||
|:NoteFromSelectedText| while editing an existing note, the new note will
|
||||
inherit the directory of the note from which it was created.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *:SplitNoteFromSelectedText* command
|
||||
|
||||
Same as |:NoteFromSelectedText| but opens the new note in a vertical split
|
||||
window. The default mapping for this command is '\sn'.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *:TabNoteFromSelectedText* command
|
||||
|
||||
Same as |:NoteFromSelectedText| but opens the new note in a new tab page. The
|
||||
default mapping for this command is '\tn'.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *:DeleteNote* command
|
||||
|
||||
The |:DeleteNote| command deletes a note file, destroys the buffer and removes
|
||||
the note from the internal cache of filenames and note titles. If you pass a
|
||||
note name as an argument to |:DeleteNote| it will delete the given note,
|
||||
otherwise it will delete the current note. This fails when changes have been
|
||||
made to the buffer, unless you use ':DeleteNote!' which discards any changes.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *:SearchNotes* command
|
||||
|
||||
This command wraps |:vimgrep| and enables you to search through your notes
|
||||
using one or more keywords or a regular expression pattern. To search for a
|
||||
pattern you pass a single argument that starts/ends with a slash:
|
||||
>
|
||||
:SearchNotes /TODO\|FIXME\|XXX/
|
||||
<
|
||||
To search for one or more keywords you can just omit the slashes, this matches
|
||||
notes containing all of the given keywords:
|
||||
>
|
||||
:SearchNotes syntax highlighting
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
*searchnotes-understands-tags*
|
||||
:SearchNotes understands @tags ~
|
||||
|
||||
If you don't pass any arguments to the |:SearchNotes| command it will search
|
||||
for the word under the cursor. If the word under the cursor starts with '@'
|
||||
this character will be included in the search, which makes it possible to
|
||||
easily add _@tags_ to your _@notes_ and then search for those tags. To make
|
||||
searching for tags even easier you can create key mappings for the
|
||||
|:SearchNotes| command:
|
||||
>
|
||||
" Make the C-] combination search for @tags:
|
||||
imap <C-]> <C-o>:SearchNotes<CR>
|
||||
nmap <C-]> :SearchNotes<CR>
|
||||
|
||||
" Make double mouse click search for @tags. This is actually quite a lot of
|
||||
" fun if you don't use the mouse for text selections anyway; you can click
|
||||
" between notes as if you're in a web browser:
|
||||
imap <2-LeftMouse> <C-o>:SearchNotes<CR>
|
||||
nmap <2-LeftMouse> :SearchNotes<CR>
|
||||
<
|
||||
These mappings are currently not enabled by default because they conflict with
|
||||
already useful key mappings, but if you have any suggestions for alternatives
|
||||
feel free to contact me through GitHub or at peter@peterodding.com.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
*notes-accelerated-searching-with-python*
|
||||
Accelerated searching with Python ~
|
||||
|
||||
After collecting a fair amount of notes (say more than 5 MB) you will probably
|
||||
start to get annoyed at how long it takes Vim to search through all of your
|
||||
notes. To make searching more scalable the notes plug-in includes a Python
|
||||
script which uses a persistent full text index of your notes stored in a file.
|
||||
|
||||
The first time the Python script is run it will need to build the complete
|
||||
index which can take a moment, but after the index has been initialized updates
|
||||
and searches should be more or less instantaneous.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *:RelatedNotes* command
|
||||
|
||||
This command makes it easy to find all notes related to the current file: If
|
||||
you are currently editing a note then a search for the note's title is done,
|
||||
otherwise this searches for the absolute path of the current file.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *:RecentNotes* command
|
||||
|
||||
If you execute the |:RecentNotes| command it will open a Vim buffer that lists
|
||||
all your notes grouped by the day they were edited, starting with your most
|
||||
recently edited note. If you pass an argument to |:RecentNotes| it will filter
|
||||
the list of notes by matching the title of each note against the argument which
|
||||
is interpreted as a Vim pattern.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *:MostRecentNote* command
|
||||
|
||||
This command edits your most recently edited note (whether you just opened the
|
||||
note or made changes to it). The plug-in will remember the most recent note
|
||||
between restarts of Vim and is shared between all instances of Vim.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *:ShowTaggedNotes* command
|
||||
|
||||
To show a list of all notes that contains _@tags_ you can use the
|
||||
|:ShowTaggedNotes| command. If you pass a count to this command it will limit
|
||||
the list of tags to those that have been used at least this many times. For
|
||||
example the following two commands show tags that have been used at least ten
|
||||
times:
|
||||
>
|
||||
:10ShowTaggedNotes
|
||||
:ShowTaggedNotes 10
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
The *:IndexTaggedNotes* command
|
||||
|
||||
The notes plug-in defines an omni completion function that can be used to
|
||||
complete the names of tags. To trigger the omni completion you type Control-X
|
||||
Control-O. When you type '@' in insert mode the plug-in will automatically
|
||||
start omni completion.
|
||||
|
||||
The completion menu is populated from a text file listing all your tags, one on
|
||||
each line. The first time omni completion triggers, an index of tag names is
|
||||
generated and saved to the location set by |g:notes_tagsindex|. After this file
|
||||
is created, it will be updated automatically as you edit notes and add/remove
|
||||
tags.
|
||||
|
||||
If for any reason you want to recreate the list of tags you can execute the
|
||||
|:IndexTaggedNotes| command.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *:NoteToHtml* command
|
||||
|
||||
This command converts the current note to HTML. It works by first converting
|
||||
the current note to Markdown [12] and then using the 'markdown' program to
|
||||
convert that to HTML. It requires an external program to convert Markdown to
|
||||
HTML. By default the program 'markdown' is used, but you can change the name of
|
||||
the program using the |g:notes_markdown_program| option.
|
||||
|
||||
Note that this command can be a bit slow, because the parser for the note
|
||||
taking syntax is written in Vim script (for portability) and has not been
|
||||
optimized for speed (yet).
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The *:NoteToMarkdown* command
|
||||
|
||||
Convert the current note to a Markdown document [12]. The vim-notes syntax
|
||||
shares a lot of similarities with the Markdown text format, but there are some
|
||||
notable differences, which this command takes care of:
|
||||
|
||||
- The first line of a note is an implicit document title. In Markdown format
|
||||
it has to be marked with '#'. This also implies that the remaining headings
|
||||
should be shifted by one level.
|
||||
|
||||
- Preformatted blocks are marked very differently in notes and Markdown
|
||||
('{{{' and '}}}' markers versus 4 space indentation).
|
||||
|
||||
- The markers and indentation of list items differ between notes and Markdown
|
||||
(dumb bullets vs Unicode bullets and 3 vs 4 spaces).
|
||||
|
||||
Note that this command can be a bit slow, because the parser for the note
|
||||
taking syntax is written in Vim script (for portability) and has not been
|
||||
optimized for speed (yet).
|
||||
|
||||
===============================================================================
|
||||
*notes-mappings*
|
||||
Mappings ~
|
||||
|
||||
The following key mappings are defined inside notes.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
*notes-insert-mode-mappings*
|
||||
Insert mode mappings ~
|
||||
|
||||
- '@' automatically triggers tag completion
|
||||
- "'" becomes '‘' or '’' depending on where you type it
|
||||
- '"' becomes '“' or '”' (same goes for these)
|
||||
- '--' becomes '—'
|
||||
- '->' becomes '→'
|
||||
- '<-' becomes '←'
|
||||
- the bullets '*', '-' and '+' become '•'
|
||||
- the three characters '***' in insert mode in quick succession insert a
|
||||
horizontal ruler delimited by empty lines
|
||||
- 'Tab' and 'Alt-Right' increase indentation of list items (works on the
|
||||
current line and selected lines)
|
||||
- 'Shift-Tab' and 'Alt-Left' decrease indentation of list items
|
||||
- 'Enter' on a line with only a list bullet removes the bullet and starts a
|
||||
new line below the current line
|
||||
- '\en' executes |:NoteFromSelectedText|
|
||||
- '\sn' executes |:SplitNoteFromSelectedText|
|
||||
- '\tn' executes |:TabNoteFromSelectedText|
|
||||
|
||||
===============================================================================
|
||||
*customizing-syntax-highlighting-of-notes*
|
||||
Customizing the syntax highlighting of notes ~
|
||||
|
||||
The syntax mode for notes is written so you can override styles you don't like.
|
||||
To do so you can add lines such as the following to your |vimrc| script:
|
||||
>
|
||||
" Don't highlight single quoted strings.
|
||||
highlight link notesSingleQuoted Normal
|
||||
|
||||
" Show double quoted strings in italic font.
|
||||
highlight notesDoubleQuoted gui=italic
|
||||
<
|
||||
See the documentation of the |:highlight| command for more information. Below
|
||||
are the names of the syntax items defined by the notes syntax mode:
|
||||
|
||||
- 'notesName' - the names of other notes, usually highlighted as a hyperlink
|
||||
- 'notesTagName' - words preceded by an '@' character, also highlighted as a
|
||||
hyperlink
|
||||
- 'notesListBullet' - the bullet characters used for list items
|
||||
- 'notesListNumber' - numbers in front of list items
|
||||
- 'notesDoubleQuoted' - double quoted strings
|
||||
- 'notesSingleQuoted' - single quoted strings
|
||||
- 'notesItalic' - strings between two '_' characters
|
||||
- 'notesBold' - strings between two '*' characters
|
||||
- 'notesTextURL' - plain domain name (recognized by leading 'www.')
|
||||
- 'notesRealURL' - URLs (e.g. http://vim.org/)
|
||||
- 'notesEmailAddr' - e-mail addresses
|
||||
- 'notesUnixPath' - UNIX file paths (e.g. '~/.vimrc' and
|
||||
'/home/peter/.vimrc')
|
||||
- 'notesPathLnum' - line number following a UNIX path
|
||||
- 'notesWindowsPath' - Windows file paths (e.g. 'c:\users\peter\_vimrc')
|
||||
- 'notesTodo' - 'TODO' markers
|
||||
- 'notesXXX' - 'XXX' markers
|
||||
- 'notesFixMe' - 'FIXME' markers
|
||||
- 'notesInProgress' - 'CURRENT', 'INPROGRESS', 'STARTED' and 'WIP' markers
|
||||
- 'notesDoneItem' - lines containing the marker 'DONE', usually highlighted
|
||||
as a comment
|
||||
- 'notesDoneMarker' - 'DONE' markers
|
||||
- 'notesVimCmd' - Vim commands, words preceded by an ':' character
|
||||
- 'notesTitle' - the first line of each note
|
||||
- 'notesShortHeading' - short sentences ending in a ':' character
|
||||
- 'notesAtxHeading' - lines preceded by one or more '#' characters
|
||||
- 'notesBlockQuote' - lines preceded by a '>' character
|
||||
- 'notesRule' - lines containing only whitespace and '* * *'
|
||||
- 'notesCodeStart' - the '{{{' markers that begin a block of code (including
|
||||
the syntax name)
|
||||
- 'notesCodeEnd' - the '}}}' markers that end a block of code
|
||||
- 'notesModeLine' - Vim |modeline| in last line of notes
|
||||
- 'notesLastEdited' - last edited dates in |:ShowTaggedNotes| buffers
|
||||
|
||||
===============================================================================
|
||||
*other-plug-ins-that-work-well-with-notes-plug-in*
|
||||
Other plug-ins that work well with the notes plug-in ~
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
*notes-utl.vim*
|
||||
utl.vim ~
|
||||
|
||||
The utl.vim [13] universal text linking plug-in enables links between your
|
||||
notes, other local files and remote resources like web pages.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
*notes-shell.vim*
|
||||
shell.vim ~
|
||||
|
||||
My shell.vim [14] plug-in also enables easy navigation between your notes and
|
||||
environment like local files and directories, web pages and e-mail addresses by
|
||||
providing key mappings and commands to e.g. open the file/URL under the text
|
||||
cursor. This plug-in can also change Vim to full screen which can be really
|
||||
nice for large notes.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
*notes-voom*
|
||||
VOoM ~
|
||||
|
||||
The VOoM [15] outlining plug-in should work well for notes if you use the
|
||||
Markdown style headers starting with '#', however it has been reported that
|
||||
this combination may not always work so well in practice (sometimes losing
|
||||
notes!)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
*notes-txtfmt*
|
||||
Txtfmt ~
|
||||
|
||||
If the text formatting supported by the notes plug-in is not enough for you,
|
||||
consider trying the Txtfmt [16] (The Vim Highlighter) plug-in. To use the two
|
||||
plug-ins together, create the file 'after/ftplugin/notes.vim' inside your Vim
|
||||
profile with the following contents:
|
||||
>
|
||||
" Enable Txtfmt formatting inside notes.
|
||||
setlocal filetype=notes.txtfmt
|
||||
<
|
||||
===============================================================================
|
||||
*notes-contact*
|
||||
Contact ~
|
||||
|
||||
If you have questions, bug reports, suggestions, etc. the author can be
|
||||
contacted at peter@peterodding.com. The latest version is available at
|
||||
http://peterodding.com/code/vim/notes/ and http://github.com/xolox/vim-notes.
|
||||
If you like the script please vote for it on Vim Online [17].
|
||||
|
||||
===============================================================================
|
||||
*notes-license*
|
||||
License ~
|
||||
|
||||
This software is licensed under the MIT license [18]. © 2013 Peter Odding
|
||||
<peter@peterodding.com>.
|
||||
|
||||
===============================================================================
|
||||
*notes-references*
|
||||
References ~
|
||||
|
||||
[1] http://en.wikipedia.org/wiki/Levenshtein_distance
|
||||
[2] http://python.org/
|
||||
[3] http://code.google.com/p/vim/source/browse/runtime/colors/slate.vim
|
||||
[4] http://en.wikipedia.org/wiki/Monaco_(typeface)
|
||||
[5] http://peterodding.com/code/vim/notes/syntax.png
|
||||
[6] http://peterodding.com/code/vim/downloads/notes.zip
|
||||
[7] http://peterodding.com/code/vim/downloads/misc.zip
|
||||
[8] http://www.vim.org/scripts/script.php?script_id=2332
|
||||
[9] https://github.com/gmarik/vundle
|
||||
[10] http://github.com/xolox/vim-notes
|
||||
[11] http://github.com/xolox/vim-misc
|
||||
[12] http://en.wikipedia.org/wiki/Markdown
|
||||
[13] http://www.vim.org/scripts/script.php?script_id=293
|
||||
[14] http://www.vim.org/scripts/script.php?script_id=3123
|
||||
[15] http://www.vim.org/scripts/script.php?script_id=2657
|
||||
[16] http://www.vim.org/scripts/script.php?script_id=2208
|
||||
[17] http://www.vim.org/scripts/script.php?script_id=3375
|
||||
[18] http://en.wikipedia.org/wiki/MIT_License
|
||||
|
||||
vim: ft=help
|
141
sources_non_forked/vim-notes/ftplugin/notes.vim
Normal file
141
sources_non_forked/vim-notes/ftplugin/notes.vim
Normal file
@ -0,0 +1,141 @@
|
||||
" Vim file type plug-in
|
||||
" Author: Peter Odding <peter@peterodding.com>
|
||||
" Last Change: May 16, 2013
|
||||
" URL: http://peterodding.com/code/vim/notes/
|
||||
|
||||
if exists('b:did_ftplugin')
|
||||
finish
|
||||
else
|
||||
let b:did_ftplugin = 1
|
||||
endif
|
||||
|
||||
" Copy indent from previous line. {{{1
|
||||
setlocal autoindent
|
||||
let b:undo_ftplugin = 'set autoindent<'
|
||||
|
||||
" Set &tabstop and &shiftwidth options for bulleted lists. {{{1
|
||||
setlocal tabstop=3 shiftwidth=3 expandtab
|
||||
let b:undo_ftplugin .= ' | set tabstop< shiftwidth< expandtab<'
|
||||
|
||||
" Automatic formatting for bulleted lists. {{{1
|
||||
let &l:comments = xolox#notes#get_comments_option()
|
||||
setlocal formatoptions=tcron
|
||||
let b:undo_ftplugin .= ' | set comments< formatoptions<'
|
||||
|
||||
" Automatic text folding based on headings. {{{1
|
||||
setlocal foldmethod=expr
|
||||
setlocal foldexpr=xolox#notes#foldexpr()
|
||||
setlocal foldtext=xolox#notes#foldtext()
|
||||
let b:undo_ftplugin .= ' | set foldmethod< foldexpr< foldtext<'
|
||||
|
||||
" Enable concealing of notes syntax markers? {{{1
|
||||
if has('conceal')
|
||||
setlocal conceallevel=3
|
||||
let b:undo_ftplugin .= ' | set conceallevel<'
|
||||
endif
|
||||
|
||||
" Change <cfile> to jump to notes by name. {{{1
|
||||
setlocal includeexpr=xolox#notes#include_expr(v:fname)
|
||||
let b:undo_ftplugin .= ' | set includeexpr<'
|
||||
|
||||
" Enable completion of note titles using C-x C-u. {{{1
|
||||
setlocal completefunc=xolox#notes#user_complete
|
||||
let b:undo_ftplugin .= ' | set completefunc<'
|
||||
|
||||
" Enable completion of tag names using C-x C-o. {{{1
|
||||
setlocal omnifunc=xolox#notes#omni_complete
|
||||
let b:undo_ftplugin .= ' | set omnifunc<'
|
||||
|
||||
" Automatic completion of tag names after typing "@". {{{1
|
||||
|
||||
inoremap <buffer> <silent> @ @<C-x><C-o>
|
||||
let b:undo_ftplugin .= ' | execute "iunmap <buffer> @"'
|
||||
|
||||
" Automatic completion of tag names should not interrupt the flow of typing,
|
||||
" for this we have to change the (unfortunately) global option &completeopt.
|
||||
set completeopt+=longest
|
||||
|
||||
" Change double-dash to em-dash as it is typed. {{{1
|
||||
if g:notes_smart_quotes && xolox#notes#unicode_enabled()
|
||||
inoremap <buffer> -- —
|
||||
let b:undo_ftplugin .= ' | execute "iunmap <buffer> --"'
|
||||
endif
|
||||
|
||||
" Change plain quotes to curly quotes as they're typed. {{{1
|
||||
if g:notes_smart_quotes
|
||||
inoremap <buffer> <expr> ' xolox#notes#insert_quote(1)
|
||||
inoremap <buffer> <expr> " xolox#notes#insert_quote(2)
|
||||
let b:undo_ftplugin .= ' | execute "iunmap <buffer> ''"'
|
||||
let b:undo_ftplugin .= ' | execute ''iunmap <buffer> "'''
|
||||
endif
|
||||
|
||||
" Change ASCII style arrows to Unicode arrows. {{{1
|
||||
if g:notes_smart_quotes && xolox#notes#unicode_enabled()
|
||||
inoremap <buffer> -> →
|
||||
inoremap <buffer> <- ←
|
||||
let b:undo_ftplugin .= ' | execute "iunmap <buffer> ->"'
|
||||
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <-"'
|
||||
endif
|
||||
|
||||
" Convert ASCII list bullets to Unicode bullets. {{{1
|
||||
if g:notes_smart_quotes
|
||||
inoremap <buffer> <expr> * xolox#notes#insert_bullet('*')
|
||||
inoremap <buffer> <expr> - xolox#notes#insert_bullet('-')
|
||||
inoremap <buffer> <expr> + xolox#notes#insert_bullet('+')
|
||||
let b:undo_ftplugin .= ' | execute "iunmap <buffer> *"'
|
||||
let b:undo_ftplugin .= ' | execute "iunmap <buffer> -"'
|
||||
let b:undo_ftplugin .= ' | execute "iunmap <buffer> +"'
|
||||
endif
|
||||
|
||||
" Format three asterisks as a horizontal ruler. {{{1
|
||||
inoremap <buffer> *** <C-o>:call xolox#notes#insert_ruler()<CR>
|
||||
let b:undo_ftplugin .= ' | execute "iunmap <buffer> ***"'
|
||||
|
||||
" Indent list items using <Tab> and <Shift-Tab>? {{{1
|
||||
if g:notes_tab_indents
|
||||
inoremap <buffer> <silent> <Tab> <C-o>:call xolox#notes#indent_list(1, line('.'), line('.'))<CR>
|
||||
snoremap <buffer> <silent> <Tab> <C-o>:<C-u>call xolox#notes#indent_list(1, line("'<"), line("'>"))<CR><C-o>gv
|
||||
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <Tab>"'
|
||||
let b:undo_ftplugin .= ' | execute "sunmap <buffer> <Tab>"'
|
||||
inoremap <buffer> <silent> <S-Tab> <C-o>:call xolox#notes#indent_list(-1, line('.'), line('.'))<CR>
|
||||
snoremap <buffer> <silent> <S-Tab> <C-o>:<C-u>call xolox#notes#indent_list(-1, line("'<"), line("'>"))<CR><C-o>gv
|
||||
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <S-Tab>"'
|
||||
let b:undo_ftplugin .= ' | execute "sunmap <buffer> <S-Tab>"'
|
||||
endif
|
||||
|
||||
" Indent list items using <Alt-Left> and <Alt-Right>? {{{1
|
||||
if g:notes_alt_indents
|
||||
inoremap <buffer> <silent> <A-Right> <C-o>:call xolox#notes#indent_list(1, line('.'), line('.'))<CR>
|
||||
snoremap <buffer> <silent> <A-Right> <C-o>:<C-u>call xolox#notes#indent_list(1, line("'<"), line("'>"))<CR><C-o>gv
|
||||
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <A-Right>"'
|
||||
let b:undo_ftplugin .= ' | execute "sunmap <buffer> <A-Right>"'
|
||||
inoremap <buffer> <silent> <A-Left> <C-o>:call xolox#notes#indent_list(-1, line('.'), line('.'))<CR>
|
||||
snoremap <buffer> <silent> <A-Left> <C-o>:<C-u>call xolox#notes#indent_list(-1, line("'<"), line("'>"))<CR><C-o>gv
|
||||
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <A-Left>"'
|
||||
let b:undo_ftplugin .= ' | execute "sunmap <buffer> <A-Left>"'
|
||||
endif
|
||||
|
||||
" Automatically remove empty list items on Enter. {{{1
|
||||
inoremap <buffer> <silent> <expr> <CR> xolox#notes#cleanup_list()
|
||||
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <CR>"'
|
||||
|
||||
" Shortcuts to create new notes from the selected text. {{{1
|
||||
|
||||
vnoremap <buffer> <silent> <Leader>en :NoteFromSelectedText<CR>
|
||||
let b:undo_ftplugin .= ' | execute "vunmap <buffer> <Leader>en"'
|
||||
|
||||
vnoremap <buffer> <silent> <Leader>sn :SplitNoteFromSelectedText<CR>
|
||||
let b:undo_ftplugin .= ' | execute "vunmap <buffer> <Leader>sn"'
|
||||
|
||||
vnoremap <buffer> <silent> <Leader>tn :TabNoteFromSelectedText<CR>
|
||||
let b:undo_ftplugin .= ' | execute "vunmap <buffer> <Leader>tn"'
|
||||
|
||||
" }}}1
|
||||
|
||||
" This is currently the only place where a command is guaranteed to be
|
||||
" executed when the user edits a note. Maybe I shouldn't abuse this (it
|
||||
" doesn't feel right ;-) but for now it will do.
|
||||
call xolox#notes#recent#track()
|
||||
call xolox#notes#check_sync_title()
|
||||
|
||||
" vim: ts=2 sw=2 et
|
312
sources_non_forked/vim-notes/misc/notes/search-notes.py
Executable file
312
sources_non_forked/vim-notes/misc/notes/search-notes.py
Executable file
@ -0,0 +1,312 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Python script for fast text file searching using keyword index on disk.
|
||||
#
|
||||
# Author: Peter Odding <peter@peterodding.com>
|
||||
# Last Change: September 2, 2013
|
||||
# URL: http://peterodding.com/code/vim/notes/
|
||||
# License: MIT
|
||||
#
|
||||
# This Python script can be used by the notes.vim plug-in to perform fast
|
||||
# keyword searches in the user's notes. It has two advantages over just
|
||||
# using Vim's internal :vimgrep command to search all of the user's notes:
|
||||
#
|
||||
# - Very large notes don't slow searching down so much;
|
||||
# - Hundreds of notes can be searched in less than a second.
|
||||
#
|
||||
# The keyword index is a Python dictionary that's persisted using the pickle
|
||||
# module. The structure of the dictionary may seem very naive but it's quite
|
||||
# fast. Also the pickle protocol makes sure repeating strings are stored only
|
||||
# once, so it's not as bad as it may appear at first sight :-).
|
||||
#
|
||||
# For more information about the Vim plug-in see http://peterodding.com/code/vim/notes/.
|
||||
|
||||
"""
|
||||
Usage: search-notes.py [OPTIONS] KEYWORD...
|
||||
|
||||
Search one or more directories of plain text files using a full text index,
|
||||
updated automatically during each invocation of the program.
|
||||
|
||||
Valid options include:
|
||||
|
||||
-i, --ignore-case ignore case of keyword(s)
|
||||
-l, --list=SUBSTR list keywords matching substring
|
||||
-d, --database=FILE set path to keywords index file
|
||||
-n, --notes=DIR set directory with user notes (can be repeated)
|
||||
-e, --encoding=NAME set character encoding of notes
|
||||
-v, --verbose make more noise
|
||||
-h, --help show this message and exit
|
||||
|
||||
For more information see http://peterodding.com/code/vim/notes/
|
||||
"""
|
||||
|
||||
# Standard library modules.
|
||||
import fnmatch
|
||||
import getopt
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
|
||||
# Load the faster C variant of the pickle module where possible, but
|
||||
# fall back to the Python implementation that's always available.
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except ImportError:
|
||||
import pickle
|
||||
|
||||
# Try to import the Levenshtein module, don't error out if it's not installed.
|
||||
try:
|
||||
import Levenshtein
|
||||
levenshtein_supported = True
|
||||
except ImportError:
|
||||
levenshtein_supported = False
|
||||
|
||||
# The version of the index format that's supported by this revision of the
|
||||
# `search-notes.py' script; if an existing index file is found with an
|
||||
# unsupported version, the script knows that it should rebuild the index.
|
||||
INDEX_VERSION = 2
|
||||
|
||||
class NotesIndex:
|
||||
|
||||
def __init__(self):
|
||||
''' Entry point to the notes search. '''
|
||||
global_timer = Timer()
|
||||
self.init_logging()
|
||||
keywords = self.parse_args()
|
||||
self.load_index()
|
||||
self.update_index()
|
||||
if self.dirty:
|
||||
self.save_index()
|
||||
print "Python works fine!"
|
||||
if self.keyword_filter is not None:
|
||||
self.list_keywords(self.keyword_filter)
|
||||
self.logger.debug("Finished listing keywords in %s", global_timer)
|
||||
else:
|
||||
matches = self.search_index(keywords)
|
||||
if matches:
|
||||
print '\n'.join(sorted(matches))
|
||||
self.logger.debug("Finished searching index in %s", global_timer)
|
||||
|
||||
def init_logging(self):
|
||||
''' Initialize the logging subsystem. '''
|
||||
self.logger = logging.getLogger('search-notes')
|
||||
self.logger.addHandler(logging.StreamHandler(sys.stderr))
|
||||
if os.isatty(0):
|
||||
self.logger.setLevel(logging.INFO)
|
||||
|
||||
def parse_args(self):
|
||||
''' Parse the command line arguments. '''
|
||||
try:
|
||||
opts, keywords = getopt.getopt(sys.argv[1:], 'il:d:n:e:vh',
|
||||
['ignore-case', 'list=', 'database=', 'notes=', 'encoding=', 'verbose', 'help'])
|
||||
except getopt.GetoptError, error:
|
||||
print str(error)
|
||||
self.usage()
|
||||
sys.exit(2)
|
||||
# Define the command line option defaults.
|
||||
self.database_file = '~/.vim/misc/notes/index.pickle'
|
||||
self.user_directories = ['~/.vim/misc/notes/user/']
|
||||
self.character_encoding = 'UTF-8'
|
||||
self.case_sensitive = True
|
||||
self.keyword_filter = None
|
||||
# Map command line options to variables.
|
||||
for opt, arg in opts:
|
||||
if opt in ('-i', '--ignore-case'):
|
||||
self.case_sensitive = False
|
||||
self.logger.debug("Disabling case sensitivity")
|
||||
elif opt in ('-l', '--list'):
|
||||
self.keyword_filter = arg.strip().lower()
|
||||
elif opt in ('-d', '--database'):
|
||||
self.database_file = arg
|
||||
elif opt in ('-n', '--notes'):
|
||||
self.user_directories.append(arg)
|
||||
elif opt in ('-e', '--encoding'):
|
||||
self.character_encoding = arg
|
||||
elif opt in ('-v', '--verbose'):
|
||||
self.logger.setLevel(logging.DEBUG)
|
||||
elif opt in ('-h', '--help'):
|
||||
self.usage()
|
||||
sys.exit(0)
|
||||
else:
|
||||
assert False, "Unhandled option"
|
||||
self.logger.debug("Index file: %s", self.database_file)
|
||||
self.logger.debug("Notes directories: %r", self.user_directories)
|
||||
self.logger.debug("Character encoding: %s", self.character_encoding)
|
||||
if self.keyword_filter is not None:
|
||||
self.keyword_filter = self.decode(self.keyword_filter)
|
||||
# Canonicalize pathnames, check validity.
|
||||
self.database_file = self.munge_path(self.database_file)
|
||||
self.user_directories = map(self.munge_path, self.user_directories)
|
||||
self.user_directories = filter(os.path.isdir, self.user_directories)
|
||||
if not any(os.path.isdir(p) for p in self.user_directories):
|
||||
sys.stderr.write("None of the notes directories exist!\n")
|
||||
sys.exit(1)
|
||||
# Return tokenized keyword arguments.
|
||||
return [self.normalize(k) for k in self.tokenize(' '.join(keywords))]
|
||||
|
||||
def load_index(self):
|
||||
''' Load the keyword index or start with an empty one. '''
|
||||
try:
|
||||
load_timer = Timer()
|
||||
self.logger.debug("Loading index from %s ..", self.database_file)
|
||||
with open(self.database_file) as handle:
|
||||
self.index = pickle.load(handle)
|
||||
self.logger.debug("Format version of index loaded from disk: %i", self.index['version'])
|
||||
assert self.index['version'] == INDEX_VERSION, "Incompatible index format detected!"
|
||||
self.first_use = False
|
||||
self.dirty = False
|
||||
self.logger.debug("Loaded %i notes from index in %s", len(self.index['files']), load_timer)
|
||||
except Exception, e:
|
||||
self.logger.warn("Failed to load index from file: %s", e)
|
||||
self.first_use = True
|
||||
self.dirty = True
|
||||
self.index = {'keywords': {}, 'files': {}, 'version': INDEX_VERSION}
|
||||
|
||||
def save_index(self):
|
||||
''' Save the keyword index to disk. '''
|
||||
save_timer = Timer()
|
||||
with open(self.database_file, 'w') as handle:
|
||||
pickle.dump(self.index, handle)
|
||||
self.logger.debug("Saved index to disk in %s", save_timer)
|
||||
|
||||
def update_index(self):
|
||||
''' Update the keyword index by scanning the notes directory. '''
|
||||
update_timer = Timer()
|
||||
# First we find the filenames and last modified times of the notes on disk.
|
||||
notes_on_disk = {}
|
||||
last_count = 0
|
||||
for directory in self.user_directories:
|
||||
for filename in os.listdir(directory):
|
||||
# Vim swap files are ignored.
|
||||
if (filename != '.swp' and not fnmatch.fnmatch(filename, '.s??')
|
||||
and not fnmatch.fnmatch(filename, '.*.s??')):
|
||||
abspath = os.path.join(directory, filename)
|
||||
if os.path.isfile(abspath):
|
||||
notes_on_disk[abspath] = os.path.getmtime(abspath)
|
||||
self.logger.info("Found %i notes in %s ..", len(notes_on_disk) - last_count, directory)
|
||||
last_count = len(notes_on_disk)
|
||||
# Check for updated and/or deleted notes since the last run?
|
||||
if not self.first_use:
|
||||
for filename in self.index['files'].keys():
|
||||
if filename not in notes_on_disk:
|
||||
# Forget a deleted note.
|
||||
self.delete_note(filename)
|
||||
else:
|
||||
# Check whether previously seen note has changed?
|
||||
last_modified_on_disk = notes_on_disk[filename]
|
||||
last_modified_in_db = self.index['files'][filename]
|
||||
if last_modified_on_disk > last_modified_in_db:
|
||||
self.delete_note(filename)
|
||||
self.add_note(filename, last_modified_on_disk)
|
||||
# Already checked this note, we can forget about it.
|
||||
del notes_on_disk[filename]
|
||||
# Add new notes to index.
|
||||
for filename, last_modified in notes_on_disk.iteritems():
|
||||
self.add_note(filename, last_modified)
|
||||
self.logger.debug("Updated index in %s", update_timer)
|
||||
|
||||
def add_note(self, filename, last_modified):
|
||||
''' Add a note to the index (assumes the note is not already indexed). '''
|
||||
self.logger.info("Adding file to index: %s", filename)
|
||||
self.index['files'][filename] = last_modified
|
||||
with open(filename) as handle:
|
||||
for kw in self.tokenize(handle.read()):
|
||||
if kw not in self.index['keywords']:
|
||||
self.index['keywords'][kw] = [filename]
|
||||
else:
|
||||
self.index['keywords'][kw].append(filename)
|
||||
self.dirty = True
|
||||
|
||||
def delete_note(self, filename):
|
||||
''' Remove a note from the index. '''
|
||||
self.logger.info("Removing file from index: %s", filename)
|
||||
del self.index['files'][filename]
|
||||
for kw in self.index['keywords']:
|
||||
self.index['keywords'][kw] = [x for x in self.index['keywords'][kw] if x != filename]
|
||||
self.dirty = True
|
||||
|
||||
def search_index(self, keywords):
|
||||
''' Return names of files containing all of the given keywords. '''
|
||||
matches = None
|
||||
normalized_db_keywords = [(k, self.normalize(k)) for k in self.index['keywords']]
|
||||
for usr_kw in keywords:
|
||||
submatches = set()
|
||||
for original_db_kw, normalized_db_kw in normalized_db_keywords:
|
||||
# Yes I'm using a nested for loop over all keywords in the index. If
|
||||
# I really have to I'll probably come up with something more
|
||||
# efficient, but really it doesn't seem to be needed -- I have over
|
||||
# 850 notes (about 8 MB) and 25000 keywords and it's plenty fast.
|
||||
if usr_kw in normalized_db_kw:
|
||||
submatches.update(self.index['keywords'][original_db_kw])
|
||||
if matches is None:
|
||||
matches = submatches
|
||||
else:
|
||||
matches &= submatches
|
||||
return list(matches) if matches else []
|
||||
|
||||
def list_keywords(self, substring, limit=25):
|
||||
''' Print all (matching) keywords to standard output. '''
|
||||
decorated = []
|
||||
substring = self.normalize(substring)
|
||||
for kw, filenames in self.index['keywords'].iteritems():
|
||||
normalized_kw = self.normalize(kw)
|
||||
if substring in normalized_kw:
|
||||
if levenshtein_supported:
|
||||
decorated.append((Levenshtein.distance(normalized_kw, substring), -len(filenames), kw))
|
||||
else:
|
||||
decorated.append((-len(filenames), kw))
|
||||
decorated.sort()
|
||||
selection = [d[-1] for d in decorated[:limit]]
|
||||
print self.encode(u'\n'.join(selection))
|
||||
|
||||
def tokenize(self, text):
|
||||
''' Tokenize a string into a list of normalized, unique keywords. '''
|
||||
words = set()
|
||||
text = self.decode(text)
|
||||
for word in re.findall(r'\w+', text, re.UNICODE):
|
||||
word = word.strip()
|
||||
if word != '' and not word.isspace() and len(word) >= 2:
|
||||
words.add(word)
|
||||
return words
|
||||
|
||||
def normalize(self, keyword):
|
||||
''' Normalize the case of a keyword if configured to do so. '''
|
||||
return keyword if self.case_sensitive else keyword.lower()
|
||||
|
||||
def encode(self, text):
|
||||
''' Encode a string in the user's preferred character encoding. '''
|
||||
return text.encode(self.character_encoding, 'ignore')
|
||||
|
||||
def decode(self, text):
|
||||
''' Decode a string in the user's preferred character encoding. '''
|
||||
return text.decode(self.character_encoding, 'ignore')
|
||||
|
||||
def munge_path(self, path):
|
||||
''' Canonicalize user-defined path, making it absolute. '''
|
||||
return os.path.abspath(os.path.expanduser(path))
|
||||
|
||||
def usage(self):
|
||||
print __doc__.strip()
|
||||
|
||||
class Timer:
|
||||
|
||||
"""
|
||||
Easy to use timer to keep track of long during operations.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.start_time = time.time()
|
||||
|
||||
def __str__(self):
|
||||
return "%.2f seconds" % self.elapsed_time
|
||||
|
||||
@property
|
||||
def elapsed_time(self):
|
||||
return time.time() - self.start_time
|
||||
|
||||
if __name__ == '__main__':
|
||||
NotesIndex()
|
||||
|
||||
# vim: ts=2 sw=2 et
|
13
sources_non_forked/vim-notes/misc/notes/shadow/New note
Normal file
13
sources_non_forked/vim-notes/misc/notes/shadow/New note
Normal file
@ -0,0 +1,13 @@
|
||||
New note
|
||||
|
||||
To get started enter a title for your note above. When you’re ready to save
|
||||
your note just use Vim’s :write or :update commands, a filename will be picked
|
||||
automatically based on the title.
|
||||
|
||||
* * *
|
||||
|
||||
The notes plug-in comes with self hosting documentation. To jump to these notes
|
||||
position your cursor on the highlighted name and press ‘gf’ in normal mode:
|
||||
|
||||
• Note taking syntax
|
||||
• Note taking commands
|
@ -0,0 +1,94 @@
|
||||
Note taking commands
|
||||
|
||||
To edit existing notes you can use Vim commands such as :edit, :split and
|
||||
:tabedit with a filename that starts with ‘note:’ followed by (part of) the
|
||||
title of one of your notes, e.g.:
|
||||
{{{vim
|
||||
:edit note:todo
|
||||
}}}
|
||||
When you don’t follow ‘note:’ with anything a new note is created.
|
||||
The following commands can be used to manage your notes:
|
||||
|
||||
# :Note starts new notes and edits existing ones
|
||||
|
||||
If you don’t pass any arguments to the :Note command it will start editing a
|
||||
new note. If you pass (part of) of the title of one of your existing notes that
|
||||
note will be edited. If no notes match the given argument then a new note is
|
||||
created with its title set to the text you passed to :Note. This command will
|
||||
fail when changes have been made to the current buffer, unless you use :Note!
|
||||
which discards any changes.
|
||||
|
||||
To start a new note and use the currently selected text as the title for the
|
||||
note you can use the :NoteFromSelectedText command. The name of this command
|
||||
isn’t very well suited to daily use, however the idea is that users will define
|
||||
their own mapping to invoke this command. For example:
|
||||
{{{vim
|
||||
" Map \ns in visual mode to start new note with selected text as title.
|
||||
vmap <Leader>ns :NoteFromSelectedText<CR>
|
||||
}}}
|
||||
# :DeleteNote deletes the current note
|
||||
|
||||
The :DeleteNote command deletes the current note, destroys the buffer and
|
||||
removes the note from the internal cache of filenames and note titles. This
|
||||
fails when changes have been made to the current buffer, unless you use
|
||||
:DeleteNote! which discards any changes.
|
||||
|
||||
# :SearchNotes searches your notes
|
||||
|
||||
This command wraps :vimgrep and enables you to search through your notes using
|
||||
a regular expression pattern or keywords. To search for a pattern you pass a
|
||||
single argument that starts & ends with a slash:
|
||||
|
||||
:SearchNotes /TODO\|FIXME\|XXX/
|
||||
|
||||
To search for one or more keywords you can just omit the slashes, this matches
|
||||
notes containing all of the given keywords:
|
||||
|
||||
:SearchNotes syntax highlighting
|
||||
|
||||
## :SearchNotes understands @tags
|
||||
|
||||
If you don’t pass any arguments to the :SearchNotes command it will search for
|
||||
the word under the cursor. If the word under the cursor starts with ‘@’ this
|
||||
character will be included in the search, which makes it possible to easily
|
||||
add @tags to your @notes and then search for those tags. To make searching for
|
||||
tags even easier you can create key mappings for the :SearchNotes command:
|
||||
{{{vim
|
||||
" Make the C-] combination search for @tags:
|
||||
imap <C-]> <C-o>:SearchNotes<CR>
|
||||
nmap <C-]> :SearchNotes<CR>
|
||||
|
||||
" Make double mouse click search for @tags. This is actually quite a lot of
|
||||
" fun if you don’t use the mouse for text selections anyway; you can click
|
||||
" between notes as if you’re in a web browser:
|
||||
imap <2-LeftMouse> <C-o>:SearchNotes<CR>
|
||||
nmap <2-LeftMouse> :SearchNotes<CR>
|
||||
}}}
|
||||
These mappings are currently not enabled by default because they conflict with
|
||||
already useful key mappings, but if you have any suggestions for alternatives
|
||||
feel free to contact me through GitHub or at peter@peterodding.com.
|
||||
|
||||
## Accelerated searching with Python
|
||||
|
||||
After collecting a fair amount of notes (say >= 5 MB) you will probably start
|
||||
to get annoyed at how long it takes Vim to search through all of your notes. To
|
||||
make searching more scalable the notes plug-in includes a Python script which
|
||||
uses a persistent keyword index of your notes stored in a file.
|
||||
|
||||
The first time the Python script is run it will need to build the complete
|
||||
index which can take a moment, but after the index has been initialized
|
||||
updates and searches should be more or less instantaneous.
|
||||
|
||||
# :RelatedNotes finds related notes
|
||||
|
||||
This command makes it easy to find all notes related to the current file: If
|
||||
you are currently editing a note then a search for the note’s title is done,
|
||||
otherwise this searches for the absolute path of the current file.
|
||||
|
||||
# :RecentNotes lists notes by modification date
|
||||
|
||||
If you execute the :RecentNotes command it will open a Vim buffer that lists
|
||||
all your notes grouped by the day they were edited, starting with your most
|
||||
recently edited note. If you pass an argument to :RecentNotes it will filter
|
||||
the list of notes by matching the title of each note against the argument which
|
||||
is interpreted as a Vim pattern.
|
@ -0,0 +1,54 @@
|
||||
Note taking syntax
|
||||
|
||||
This note contains examples of the syntax highlighting styles supported by the
|
||||
notes plug-in. When your Vim configuration supports concealing of text, the
|
||||
markers which enable the syntax highlighting won’t be visible. In this case you
|
||||
can make the markers visible by selecting the text.
|
||||
|
||||
# Headings
|
||||
|
||||
Lines prefixed with one or more ‘#’ symbols are headings which can be used for
|
||||
automatic text folding. There’s also an alternative heading format which isn’t
|
||||
folded, it consists of a line shorter than 60 letters that starts with an
|
||||
uppercase letter and ends in a colon (the hard wrapping in this paragraph
|
||||
illustrates why the “starts with uppercase” rule is needed):
|
||||
|
||||
# Inline formatting
|
||||
|
||||
Text styles:
|
||||
• _italic text_
|
||||
• *bold text*
|
||||
|
||||
Hyper links and such:
|
||||
• Hyper links: http://www.vim.org/, sftp://server/file
|
||||
• Domain names: www.python.org
|
||||
• E-mail addresses: user@host.ext
|
||||
• UNIX filenames: ~/relative/to/home, /absolute/path
|
||||
• Windows filenames: ~\relative\to\home, c:\absolute\path, \\server\share
|
||||
|
||||
# Lists
|
||||
|
||||
Bulleted lists can be used for to-do lists:
|
||||
• DONE Publish my notes.vim plug-in
|
||||
• TODO Write an indent script for atx headings
|
||||
• XXX This one is really important
|
||||
|
||||
Numbered lists are also supported:
|
||||
1. And You can
|
||||
2) use any type
|
||||
3/ of marker
|
||||
|
||||
# Block quotes
|
||||
|
||||
> Quotes are written using
|
||||
> the convention from e-mail
|
||||
|
||||
# Embedded syntax highlighting
|
||||
|
||||
If you type three ‘{’ characters followed by the name of a Vim file type, all
|
||||
text until the three closing ‘}’ characters will be highlighted using the
|
||||
indicated file type. Here are some examples of the Fibonacci sequence:
|
||||
|
||||
Lua: {{{lua function fib(n) return n < 2 and n or fib(n - 1) + fib(n - 2) end }}}
|
||||
Vim script: {{{vim function fib(n) | return n < 2 ? n : fib(n - 1) + fib(n - 2) | endfunction }}}
|
||||
Python: {{{python def fib(n): return n < 2 and n or fib(n - 1) + fib(n - 2) }}}
|
40
sources_non_forked/vim-notes/misc/notes/template.html
Normal file
40
sources_non_forked/vim-notes/misc/notes/template.html
Normal file
@ -0,0 +1,40 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="{{ encoding }}">
|
||||
<title>{{ title }}</title>
|
||||
<!-- jQuery from the Google CDN. -->
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
|
||||
<!-- Bootstrap CSS & JS from the Bootstrap CDN. -->
|
||||
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" >
|
||||
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
|
||||
<style type="text/css">
|
||||
body {
|
||||
margin: 2.5em auto 10em auto;
|
||||
width: 50em;
|
||||
max-width: 90%;
|
||||
}
|
||||
h2 { margin-top: 1.5em; }
|
||||
h3 { margin-top: 1.25em; }
|
||||
h4 { margin-top: 1em; }
|
||||
h5 { margin-top: 0.75em; }
|
||||
h6 { margin-top: 0.5em; }
|
||||
hr { margin: 5em 0; }
|
||||
#footer {
|
||||
margin-top: 5em;
|
||||
opacity: 0.5;
|
||||
line-height: 2.5em;
|
||||
}
|
||||
#footer:hover { opacity: 1.0; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
{{ content }}
|
||||
</div>
|
||||
<div id="footer">
|
||||
Exported by <a href="http://peterodding.com/code/vim/notes/" class="btn">vim-notes {{ version }}</a>
|
||||
on {{ date }} based on the note <code>{{ filename }}</code>.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
79
sources_non_forked/vim-notes/plugin/notes.vim
Normal file
79
sources_non_forked/vim-notes/plugin/notes.vim
Normal file
@ -0,0 +1,79 @@
|
||||
" Vim plug-in
|
||||
" Author: Peter Odding <peter@peterodding.com>
|
||||
" Last Change: August 19, 2013
|
||||
" URL: http://peterodding.com/code/vim/notes/
|
||||
|
||||
" Support for automatic update using the GLVS plug-in.
|
||||
" GetLatestVimScripts: 3375 1 :AutoInstall: notes.zip
|
||||
|
||||
" Don't source the plug-in when it's already been loaded or &compatible is set.
|
||||
if &cp || exists('g:loaded_notes')
|
||||
finish
|
||||
endif
|
||||
|
||||
" Make sure vim-misc is installed.
|
||||
try
|
||||
" The point of this code is to do something completely innocent while making
|
||||
" sure the vim-misc plug-in is installed. We specifically don't use Vim's
|
||||
" exists() function because it doesn't load auto-load scripts that haven't
|
||||
" already been loaded yet (last tested on Vim 7.3).
|
||||
call type(g:xolox#misc#version)
|
||||
catch
|
||||
echomsg "Warning: The vim-notes plug-in requires the vim-misc plug-in which seems not to be installed! For more information please review the installation instructions in the readme (also available on the homepage and on GitHub). The vim-notes plug-in will now be disabled."
|
||||
let g:loaded_notes = 1
|
||||
finish
|
||||
endtry
|
||||
|
||||
" Initialize the configuration defaults.
|
||||
call xolox#notes#init()
|
||||
|
||||
" User commands to create, delete and search notes.
|
||||
command! -bar -bang -nargs=? -complete=customlist,xolox#notes#cmd_complete Note call xolox#notes#edit(<q-bang>, <q-args>)
|
||||
command! -bar -bang -nargs=? -complete=customlist,xolox#notes#cmd_complete DeleteNote call xolox#notes#delete(<q-bang>, <q-args>)
|
||||
command! -bang -nargs=? -complete=customlist,xolox#notes#keyword_complete SearchNotes call xolox#notes#search(<q-bang>, <q-args>)
|
||||
command! -bar -bang RelatedNotes call xolox#notes#related(<q-bang>)
|
||||
command! -bar -bang -nargs=? RecentNotes call xolox#notes#recent#show(<q-bang>, <q-args>)
|
||||
command! -bar -bang MostRecentNote call xolox#notes#recent#edit(<q-bang>)
|
||||
command! -bar -count=1 ShowTaggedNotes call xolox#notes#tags#show_tags(<count>)
|
||||
command! -bar IndexTaggedNotes call xolox#notes#tags#create_index()
|
||||
command! -bar NoteToMarkdown call xolox#notes#markdown#view()
|
||||
command! -bar NoteToHtml call xolox#notes#html#view()
|
||||
|
||||
" TODO Generalize this so we have one command + modifiers (like :tab)?
|
||||
command! -bar -bang -range NoteFromSelectedText call xolox#notes#from_selection(<q-bang>, 'edit')
|
||||
command! -bar -bang -range SplitNoteFromSelectedText call xolox#notes#from_selection(<q-bang>, 'vsplit')
|
||||
command! -bar -bang -range TabNoteFromSelectedText call xolox#notes#from_selection(<q-bang>, 'tabnew')
|
||||
|
||||
" Automatic commands to enable the :edit note:… shortcut and load the notes file type.
|
||||
|
||||
augroup PluginNotes
|
||||
autocmd!
|
||||
au SwapExists * call xolox#notes#swaphack()
|
||||
au BufUnload * call xolox#notes#unload_from_cache()
|
||||
au BufReadPost,BufWritePost * call xolox#notes#refresh_syntax()
|
||||
au InsertEnter,InsertLeave * call xolox#notes#refresh_syntax()
|
||||
au CursorHold,CursorHoldI * call xolox#notes#refresh_syntax()
|
||||
" NB: "nested" is used here so that SwapExists automatic commands apply
|
||||
" to notes (which is IMHO better than always showing the E325 prompt).
|
||||
au BufReadCmd note:* nested call xolox#notes#shortcut()
|
||||
" Automatic commands to read/write notes (used for automatic renaming).
|
||||
exe 'au BufReadCmd' xolox#notes#autocmd_pattern(g:notes_shadowdir, 0) 'call xolox#notes#edit_shadow()'
|
||||
for s:directory in xolox#notes#find_directories(0)
|
||||
exe 'au BufWriteCmd' xolox#notes#autocmd_pattern(s:directory, 1) 'call xolox#notes#save()'
|
||||
endfor
|
||||
unlet s:directory
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
let s:template = 'au BufNewFile,BufRead %s if &bt == "" | setl ft=notes | end'
|
||||
for s:directory in xolox#notes#find_directories(0)
|
||||
execute printf(s:template, xolox#notes#autocmd_pattern(s:directory, 1))
|
||||
endfor
|
||||
unlet s:directory
|
||||
execute printf(s:template, xolox#notes#autocmd_pattern(g:notes_shadowdir, 0))
|
||||
augroup END
|
||||
|
||||
" Make sure the plug-in is only loaded once.
|
||||
let g:loaded_notes = 1
|
||||
|
||||
" vim: ts=2 sw=2 et
|
162
sources_non_forked/vim-notes/syntax/notes.vim
Normal file
162
sources_non_forked/vim-notes/syntax/notes.vim
Normal file
@ -0,0 +1,162 @@
|
||||
" Vim syntax script
|
||||
" Author: Peter Odding <peter@peterodding.com>
|
||||
" Last Change: July 16, 2013
|
||||
" URL: http://peterodding.com/code/vim/notes/
|
||||
|
||||
" Note: This file is encoded in UTF-8 including a byte order mark so
|
||||
" that Vim loads the script using the right encoding transparently.
|
||||
|
||||
" Quit when a syntax file was already loaded.
|
||||
if exists('b:current_syntax')
|
||||
finish
|
||||
endif
|
||||
|
||||
" Check for spelling errors in all text.
|
||||
syntax spell toplevel
|
||||
|
||||
" Inline elements. {{{1
|
||||
|
||||
" Cluster of elements which never contain a newline character.
|
||||
syntax cluster notesInline contains=notesName
|
||||
|
||||
" Default highlighting style for notes syntax markers.
|
||||
highlight def link notesHiddenMarker Ignore
|
||||
|
||||
" Highlight note names as hyperlinks. {{{2
|
||||
call xolox#notes#highlight_names(1)
|
||||
syntax cluster notesInline add=notesName
|
||||
highlight def link notesName Underlined
|
||||
|
||||
" Highlight @tags as hyperlinks. {{{2
|
||||
syntax match notesTagName /\(^\|\s\)\@<=@\k\+/
|
||||
highlight def link notesTagName Underlined
|
||||
|
||||
" Highlight list bullets and numbers. {{{2
|
||||
execute 'syntax match notesListBullet /' . escape(xolox#notes#leading_bullet_pattern(), '/') . '/'
|
||||
highlight def link notesListBullet Comment
|
||||
syntax match notesListNumber /^\s*\zs\d\+[[:punct:]]\?\ze\s/
|
||||
highlight def link notesListNumber Comment
|
||||
|
||||
" Highlight quoted fragments. {{{2
|
||||
if xolox#notes#unicode_enabled()
|
||||
syntax match notesDoubleQuoted /“.\{-}”/
|
||||
syntax match notesSingleQuoted /‘.\{-}’/
|
||||
else
|
||||
syntax match notesDoubleQuoted /".\{-}"/
|
||||
syntax match notesSingleQuoted /`.\{-}'/
|
||||
endif
|
||||
highlight def link notesSingleQuoted Special
|
||||
highlight def link notesDoubleQuoted String
|
||||
|
||||
" Highlight text emphasized in italic font. {{{2
|
||||
if has('conceal')
|
||||
syntax region notesItalic matchgroup=notesItalicMarker start=/\<_\k\@=/ end=/_\>\|\n/ contains=@Spell concealends
|
||||
highlight link notesItalicMarker notesHiddenMarker
|
||||
else
|
||||
syntax match notesItalic /\<_\k[^_]*\k_\>/
|
||||
endif
|
||||
syntax cluster notesInline add=notesItalic
|
||||
highlight notesItalic gui=italic cterm=italic
|
||||
|
||||
" Highlight text emphasized in bold font. {{{2
|
||||
if has('conceal')
|
||||
syntax region notesBold matchgroup=notesBoldMarker start=/\*\k\@=/ end=/\S\@<=\*/ contains=@Spell concealends
|
||||
highlight link notesBoldMarker notesHiddenMarker
|
||||
else
|
||||
syntax match notesBold /\*\k[^*]*\k\*/
|
||||
endif
|
||||
syntax cluster notesInline add=notesBold
|
||||
highlight notesBold gui=bold cterm=bold
|
||||
|
||||
" Highlight domain names, URLs, e-mail addresses and filenames. {{{2
|
||||
|
||||
" FIXME This setting is lost once the user switches color scheme!
|
||||
highlight notesSubtleURL gui=underline guifg=fg
|
||||
|
||||
syntax match notesTextURL @\<www\.\(\S*\w\)\+/\?@
|
||||
syntax cluster notesInline add=notesTextURL
|
||||
highlight def link notesTextURL notesSubtleURL
|
||||
execute printf('syntax match notesRealURL @%s@', g:xolox#notes#url_pattern)
|
||||
syntax cluster notesInline add=notesRealURL
|
||||
highlight def link notesRealURL notesSubtleURL
|
||||
if has('conceal')
|
||||
syntax match notesUrlScheme @\(mailto:\|javascript:\|\w\{3,}://\)@ contained containedin=notesRealURL conceal
|
||||
highlight def link notesUrlScheme notesRealURL
|
||||
endif
|
||||
syntax match notesEmailAddr /\<\w[^@ \t\r]*\w@\w[^@ \t\r]\+\w\>/
|
||||
syntax cluster notesInline add=notesEmailAddr
|
||||
highlight def link notesEmailAddr notesSubtleURL
|
||||
syntax match notesUnixPath /\k\@<![\/~]\S\+\(\/\|[^ [:punct:]]\)/
|
||||
syntax cluster notesInline add=notesUnixPath
|
||||
highlight def link notesUnixPath Directory
|
||||
syntax match notesPathLnum /:\d\+/ contained containedin=notesUnixPath
|
||||
highlight def link notesPathLnum Comment
|
||||
syntax match notesWindowsPath /\k\@<![A-Za-z]:\S\+\([\\/]\|[^ [:punct:]]\)/
|
||||
syntax cluster notesInline add=notesWindowsPath
|
||||
highlight def link notesWindowsPath Directory
|
||||
|
||||
" Highlight TODO, DONE, FIXME and XXX markers. {{{2
|
||||
syntax match notesTodo /\<TODO\>/
|
||||
syntax match notesXXX /\<XXX\>/
|
||||
syntax match notesFixMe /\<FIXME\>/
|
||||
syntax match notesInProgress /\<\(CURRENT\|INPROGRESS\|STARTED\|WIP\)\>/
|
||||
syntax match notesDoneItem /^\(\s\+\).*\<DONE\>.*\(\n\1\s.*\)*/ contains=@notesInline
|
||||
syntax match notesDoneMarker /\<DONE\>/ containedin=notesDoneItem
|
||||
highlight def link notesTodo WarningMsg
|
||||
highlight def link notesXXX WarningMsg
|
||||
highlight def link notesFixMe WarningMsg
|
||||
highlight def link notesDoneItem Comment
|
||||
highlight def link notesDoneMarker Question
|
||||
highlight def link notesInProgress Directory
|
||||
|
||||
" Highlight Vim command names in :this notation. {{{2
|
||||
syntax match notesVimCmd /:\w\+\(!\|\>\)/ contains=ALLBUT,@Spell
|
||||
syntax cluster notesInline add=notesVimCmd
|
||||
highlight def link notesVimCmd Special
|
||||
|
||||
" Block level elements. {{{1
|
||||
|
||||
" The first line of each note contains the title. {{{2
|
||||
syntax match notesTitle /^.*\%1l.*$/ contains=@notesInline
|
||||
highlight def link notesTitle ModeMsg
|
||||
|
||||
" Short sentences ending in a colon are considered headings. {{{2
|
||||
syntax match notesShortHeading /^\s*\zs\u.\{1,50}\k:\ze\(\s\|$\)/ contains=@notesInline
|
||||
highlight def link notesShortHeading Title
|
||||
|
||||
" Atx style headings are also supported. {{{2
|
||||
syntax match notesAtxHeading /^#\+.*/ contains=notesAtxMarker,@notesInline
|
||||
highlight def link notesAtxHeading Title
|
||||
syntax match notesAtxMarker /^#\+/ contained
|
||||
highlight def link notesAtxMarker Comment
|
||||
|
||||
" E-mail style block quotes are highlighted as comments. {{{2
|
||||
syntax match notesBlockQuote /\(^\s*>.*\n\)\+/ contains=@notesInline
|
||||
highlight def link notesBlockQuote Comment
|
||||
|
||||
" Horizontal rulers. {{{2
|
||||
syntax match notesRule /\(^\s\+\)\zs\*\s\*\s\*$/
|
||||
highlight def link notesRule Comment
|
||||
|
||||
" Highlight embedded blocks of source code, log file messages, basically anything Vim can highlight. {{{2
|
||||
" NB: I've escaped these markers so that Vim doesn't interpret them when editing this file…
|
||||
syntax match notesCodeStart /{{[{]\w*/
|
||||
syntax match notesCodeEnd /}}[}]/
|
||||
highlight def link notesCodeStart Ignore
|
||||
highlight def link notesCodeEnd Ignore
|
||||
call xolox#notes#highlight_sources(1)
|
||||
|
||||
" Hide mode line at end of file. {{{2
|
||||
syntax match notesModeLine /\_^vim:.*\_s*\%$/
|
||||
highlight def link notesModeLine LineNr
|
||||
|
||||
" Last edited dates in :ShowTaggedNotes buffers.
|
||||
syntax match notesLastEdited /(last edited \(today\|yesterday\|\w\+, \w\+ \d\+, \d\+\))/
|
||||
highlight def link notesLastEdited LineNr
|
||||
|
||||
" }}}1
|
||||
|
||||
" Set the currently loaded syntax mode.
|
||||
let b:current_syntax = 'notes'
|
||||
|
||||
" vim: ts=2 sw=2 et bomb fdl=1
|
Reference in New Issue
Block a user