]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Concealing links
authorHiroshi Shirosaki <h.shirosaki@gmail.com>
Tue, 19 Jan 2016 09:18:04 +0000 (18:18 +0900)
committerHiroshi Shirosaki <h.shirosaki@gmail.com>
Tue, 19 Jan 2016 09:18:04 +0000 (18:18 +0900)
Add conceal to syntax link to help readability.
Fix #244

README.md
syntax/markdown.vim
test/syntax.vader

index 60203812abf04678aa82d06e704bf169f9a0d99b..ec200b6d32510a46f02435911c67811d5d601325 100644 (file)
--- a/README.md
+++ b/README.md
@@ -113,6 +113,18 @@ It never increases its default size (half screen), it only shrinks.
 let g:vim_markdown_toc_autofit = 1
 ```
 
+### Syntax Concealing
+
+Concealing is set for some syntax.
+
+For example, conceal `[link text](link url)` as just `link text`.
+
+To enable/disable conceal use Vim's standard conceal configuration.
+
+```vim
+set conceallevel = 2
+```
+
 ### Syntax extensions
 
 The following options control which syntax extensions will be turned on. They are off by default.
index b81269868d07aa171627e420417f72f65a05b418..46eb5a9ed952e54c64711937e684351a4411da63 100644 (file)
@@ -34,6 +34,13 @@ syn spell toplevel
 syn case ignore
 syn sync linebreaks=1
 
+let s:conceal = ''
+let s:concealends = ''
+if has('conceal')
+  let s:conceal = ' conceal'
+  let s:concealends = ' concealends'
+endif
+
 "additions to HTML groups
 syn region htmlItalic start="\\\@<!\*\ze[^\\\*\t ]" end="[^\\\*\t ]\zs\*" keepend oneline
 syn region htmlItalic start="\\\@<!_\ze[^\\_\t ]" end="[^\\_\t ]\zs_" keepend oneline
@@ -44,9 +51,9 @@ syn region htmlBoldItalic start="___\ze\S" end="\S\zs___" keepend oneline
 
 " [link](URL) | [link][id] | [link][] | ![image](URL)
 syn region mkdFootnotes matchgroup=mkdDelimiter start="\[^"    end="\]"
-syn region mkdID matchgroup=mkdDelimiter        start="\["    end="\]" contained oneline
-syn region mkdURL matchgroup=mkdDelimiter       start="("     end=")"  contained oneline
-syn region mkdLink matchgroup=mkdDelimiter      start="\\\@<!!\?\[" end="\]\ze\s*[[(]" contains=@mkdNonListItem,@Spell nextgroup=mkdURL,mkdID skipwhite oneline
+execute 'syn region mkdID matchgroup=mkdDelimiter    start="\["    end="\]" contained oneline' . s:conceal
+execute 'syn region mkdURL matchgroup=mkdDelimiter   start="("     end=")"  contained oneline' . s:conceal
+execute 'syn region mkdLink matchgroup=mkdDelimiter  start="\\\@<!!\?\[" end="\]\ze\s*[[(]" contains=@mkdNonListItem,@Spell nextgroup=mkdURL,mkdID skipwhite oneline' . s:concealends
 
 " Autolink without angle brackets.
 " mkd  inline links:           protocol   optional  user:pass@       sub/domain                 .com, .co.uk, etc      optional port   path/querystring/hash fragment
index 6f0a6943e888a3625cd5461b6a36d749dc5c141c..bdc599f39dadb8cadc6686131fa4b97611578ef2 100644 (file)
@@ -98,6 +98,20 @@ Execute (multiple links on a line):
   AssertNotEqual SyntaxOf('c'), 'mkdLink'
   AssertNotEqual SyntaxOf('c'), 'mkdURL'
 
+Given markdown;
+[a](b)
+
+Execute (conceal link):
+  setlocal conceallevel=2
+  AssertEqual synconcealed(1, 1)[0], 1
+  AssertEqual synconcealed(1, 2)[0], 0
+  AssertEqual synconcealed(1, 3)[0], 1
+  AssertEqual synconcealed(1, 4)[0], 1
+  AssertEqual synconcealed(1, 4)[0], 1
+  AssertEqual synconcealed(1, 5)[0], 1
+  AssertEqual synconcealed(1, 6)[0], 1
+  setlocal conceallevel=0
+
 # Autolinks
 
 Given markdown;