diff --git a/README.md b/README.md index d1a23cf..2c9226f 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,12 @@ This option defines the pathname of the Python script that's used to perform acc 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_fold_ignore_code` option + +The notes syntax uses `#` to mark headings which define foldable sections of text. The notes syntax also supports embedding fragments of syntax highlighted text. Of course the plug-in should not fold lines starting with `#` inside a code block, because `#` is frequently used for single line comments! The fold function knows how to deal with this, however I suspect the current implementation to be very slow, so it's not enabled by default. If you set this variable to true the feature will be enabled: + + :let g:notes_fold_ignore_code = 1 + ## Commands To edit one of your existing notes 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.: diff --git a/autoload/xolox/notes.vim b/autoload/xolox/notes.vim index 98dec30..57dc027 100644 --- a/autoload/xolox/notes.vim +++ b/autoload/xolox/notes.vim @@ -1,12 +1,12 @@ " Vim auto-load script " Author: Peter Odding -" Last Change: October 18, 2011 +" Last Change: October 23, 2011 " 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. -let g:xolox#notes#version = '0.12' +let g:xolox#notes#version = '0.12.1' function! xolox#notes#shortcut() " {{{1 " The "note:" pseudo protocol is just a shortcut for the :Note command. @@ -852,6 +852,15 @@ endfunction function! xolox#notes#foldexpr() " {{{3 " Folding expression to fold atx style Markdown headings. + if xolox#misc#option#get('notes_fold_ignore_code', 0) + let pos_save = getpos('.') + call setpos('.', [0, v:lnum, 1, 0]) + let in_code = (search('{{{\|\(}}}\)', 'bnpW') == 1) + call setpos('.', pos_save) + if in_code + return '=' + endif + endif let lastlevel = foldlevel(v:lnum - 1) let nextlevel = match(getline(v:lnum), '^#\+\zs') if lastlevel <= 0 && nextlevel >= 1 diff --git a/doc/notes.txt b/doc/notes.txt index 6bcefce..9a0f4aa 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -135,6 +135,19 @@ 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_fold_ignore_code* option + +The notes syntax uses '#' to mark headings which define foldable sections of +text. The notes syntax also supports embedding fragments of syntax highlighted +text. Of course the plug-in should not fold lines starting with '#' inside a +code block, because '#' is frequently used for single line comments! The fold +function knows how to deal with this, however I suspect the current +implementation to be very slow, so it's not enabled by default. If you set +this variable to true the feature will be enabled: +> + :let g:notes_fold_ignore_code = 1 + =============================================================================== *notes-commands* Commands ~