Skip to content

Commit

Permalink
Merge pull request #104: Make concealing configurable
Browse files Browse the repository at this point in the history
I made a few changes while merging this pull request:

1. I changed the logic inside syntax/notes.vim to use the function
   xolox#misc#option#get() with a default option value of true (1). In
   my mind this makes a lot more sense than checking for the existence
   of variables without checking their actual values.

2. I renamed notes_conceal_italics to notes_conceal_italic to be
   consistent with the other options (IMHO).

3. I rewrote the documentation additions because A) doc/notes.txt is
   generated from README.md so the changes by @naddeoa would have gone
   lost and B) because there were typos in the additions
   (s/coneal/conceal/g).

4. The documentation for notes_conceal_code was incorrect because
   the code changes by @naddeoa only apply to the markers for inline
   code fragments, not the markers for multi line code blocks. I kept
   the implementation as is and updated the documentation to match the
   implementation.

See also pull request 104 on GitHub:
  #104
  • Loading branch information
xolox committed Mar 15, 2015
2 parents 1757bf6 + 76e0042 commit 5616b08
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 7 deletions.
24 changes: 24 additions & 0 deletions README.md
Expand Up @@ -130,6 +130,30 @@ This option defines the pathname of the text file that stores the list of known

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.

### The `g:notes_conceal_code` option

By default the backticks that mark inline code snippets are hidden when your version of Vim supports concealing of text. By setting this option to zero you stop vim-notes from hiding those backticks. In the following example, the backticks would be visible in the editor when this option is set to zero:

This is a sentence with an `inline code` fragment.

### The `g:notes_conceal_italic` option

By default the underscores that mark italic text are hidden when your version of Vim supports concealing of text. By setting this option to zero you stop vim-notes from hiding those underscores. In the following example, the underscores would be visible in the editor when this option is set to zero:

This is a sentence with _italic_ text.

### The `g:notes_conceal_bold` option

By default the stars that mark bold text are hidden when your version of Vim supports concealing of text. By setting this option to zero you stop vim-notes from hiding those stars. In the following example, the stars would be visible in the editor when this option is set to zero:

This is a sentence with *bold* text.

### The `g:notes_conceal_url` option

By default URL schemes (text fragments like `http://`) are hidden when your version of Vim supports concealing of text. By setting this option to zero you stop vim-notes from hiding URL schemes. In the following example, the `https://` text would be visible in the editor when this option is set to zero:

You can find the vim-notes plug-in at https://github.com/xolox/vim-notes.

## 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.:
Expand Down
4 changes: 2 additions & 2 deletions autoload/xolox/notes.vim
@@ -1,12 +1,12 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
" Last Change: March 5, 2015
" Last Change: March 15, 2015
" 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.31.1'
let g:xolox#notes#version = '0.32'
let g:xolox#notes#url_pattern = '\<\(mailto:\|javascript:\|\w\{3,}://\)\(\S*\w\)\+/\?'
let s:scriptdir = expand('<sfile>:p:h')

Expand Down
44 changes: 44 additions & 0 deletions doc/notes.txt
Expand Up @@ -22,6 +22,10 @@ Contents ~
13. The |g:notes_indexscript| option
14. The |g:notes_tagsindex| option
15. The |g:notes_markdown_program| option
16. The |g:notes_conceal_code| option
17. The |g:notes_conceal_italic| option
18. The |g:notes_conceal_bold| option
19. The |g:notes_conceal_url| option
4. Commands |notes-commands|
1. The |:Note| command
2. The |:NoteFromSelectedText| command
Expand Down Expand Up @@ -338,6 +342,46 @@ 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.

-------------------------------------------------------------------------------
The *g:notes_conceal_code* option

By default the backticks that mark inline code snippets are hidden when your
version of Vim supports concealing of text. By setting this option to zero you
stop vim-notes from hiding those backticks. In the following example, the
backticks would be visible in the editor when this option is set to zero:
>
This is a sentence with an `inline code` fragment.
<
-------------------------------------------------------------------------------
The *g:notes_conceal_italic* option

By default the underscores that mark italic text are hidden when your version
of Vim supports concealing of text. By setting this option to zero you stop
vim-notes from hiding those underscores. In the following example, the
underscores would be visible in the editor when this option is set to zero:
>
This is a sentence with _italic_ text.
<
-------------------------------------------------------------------------------
The *g:notes_conceal_bold* option

By default the stars that mark bold text are hidden when your version of Vim
supports concealing of text. By setting this option to zero you stop vim-notes
from hiding those stars. In the following example, the stars would be visible
in the editor when this option is set to zero:
>
This is a sentence with *bold* text.
<
-------------------------------------------------------------------------------
The *g:notes_conceal_url* option

By default URL schemes (text fragments like 'http://') are hidden when your
version of Vim supports concealing of text. By setting this option to zero you
stop vim-notes from hiding URL schemes. In the following example, the
'https://' text would be visible in the editor when this option is set to zero:
>
You can find the vim-notes plug-in at https://github.com/xolox/vim-notes.
<
===============================================================================
*notes-commands*
Commands ~
Expand Down
10 changes: 5 additions & 5 deletions syntax/notes.vim
@@ -1,6 +1,6 @@
" Vim syntax script
" Author: Peter Odding <peter@peterodding.com>
" Last Change: November 27, 2014
" Last Change: March 15, 2015
" URL: http://peterodding.com/code/vim/notes/

" Note: This file is encoded in UTF-8 including a byte order mark so
Expand Down Expand Up @@ -57,7 +57,7 @@ highlight def link notesSingleQuoted Special
highlight def link notesDoubleQuoted String

" Highlight inline code fragments (same as Markdown syntax). {{{2
if has('conceal')
if has('conceal') && xolox#misc#option#get('notes_conceal_code', 1)
syntax region notesInlineCode matchgroup=notesInlineCodeMarker start=/`/ end=/`/ concealends
highlight link notesItalicMarker notesInlineCodeMarker
else
Expand All @@ -67,7 +67,7 @@ syntax cluster notesInline add=notesInlineCode
highlight def link notesInlineCode Special

" Highlight text emphasized in italic font. {{{2
if has('conceal')
if has('conceal') && xolox#misc#option#get('notes_conceal_italic', 1)
syntax region notesItalic matchgroup=notesItalicMarker start=/\<_\k\@=/ end=/_\>\|\n/ contains=@Spell concealends
highlight link notesItalicMarker notesHiddenMarker
else
Expand All @@ -77,7 +77,7 @@ syntax cluster notesInline add=notesItalic
highlight notesItalic gui=italic cterm=italic

" Highlight text emphasized in bold font. {{{2
if has('conceal')
if has('conceal') && xolox#misc#option#get('notes_conceal_bold', 1)
syntax region notesBold matchgroup=notesBoldMarker start=/\*\k\@=/ end=/\S\@<=\*/ contains=@Spell concealends
highlight link notesBoldMarker notesHiddenMarker
else
Expand All @@ -97,7 +97,7 @@ 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')
if has('conceal') && xolox#misc#option#get('notes_conceal_url', 1)
syntax match notesUrlScheme @\(mailto:\|javascript:\|\w\{3,}://\)@ contained containedin=notesRealURL conceal
highlight def link notesUrlScheme notesRealURL
endif
Expand Down

0 comments on commit 5616b08

Please sign in to comment.