summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra D Prabhu <rprabhu@wnohang.net>2011-05-14 20:58:28 +0530
committerRaghavendra D Prabhu <rprabhu@wnohang.net>2011-05-14 20:58:28 +0530
commit1a9aaed1ab0d31f430a6cd4a3b38663170ff993f (patch)
treee0c0d3ad35f47587323e82bf014b35587d086990
parent851c6c706db0ec5b0b880294e41d2bf127934970 (diff)
downloadcomceal-1a9aaed1ab0d31f430a6cd4a3b38663170ff993f.tar.gz
comceal-1a9aaed1ab0d31f430a6cd4a3b38663170ff993f.tar.bz2
comceal-1a9aaed1ab0d31f430a6cd4a3b38663170ff993f.zip
Comceal update and fixed
-rw-r--r--after/plugin/comceal.vim96
1 files changed, 67 insertions, 29 deletions
diff --git a/after/plugin/comceal.vim b/after/plugin/comceal.vim
index 3eb81e1..eff192d 100644
--- a/after/plugin/comceal.vim
+++ b/after/plugin/comceal.vim
@@ -1,33 +1,71 @@
+" Comceal.vim
+" :Conceal 'em damn comments !
+" Author: Raghavendra Prabhu - rprabhu AT wnohang DOT net
+" Git: git.wnohang.net
+" we need the conceal feature (vim ≥ 7.3)
+" To be put under <plugin_name>/after/plugin/ if you use vundle or any another
+" convenient location but should be sourced in the after path
- " we need the conceal feature (vim ≥ 7.3)
- if !has('conceal')
- finish
- endif
-
- " remove the keywords. we'll re-add them below
-" if ! &ft
-" finish
-" endif
-
-
- let commentType=&ft."Comment"
+"Variables you can set
+" 1. g:comceal_char -- character which can be used in place of comment -- for
+" more check :help ccchar
+" 2. g:comceal_list -- conceal levels to toggle between when using the Comceal command --
+" for more check :help conceallevel
+" 3. g:comceal_default -- The comment string to assume if the file type is not
+" recognised by vim
+" 4. g:comceal_disabled -- To disable this plugin :(
+
+if exists("g:comceal_disabled") && g:comceal_disabled == 1
+ finish
+endif
+
+if exists("g:comceal_version")
+ finish
+endif
+
+" Version number
+let g:comceal_version = "0.0.1"
+if !has('conceal') || !has('folding') || &cp
+ echoerr "Either conceal or folding feature is missing: check vim --version output"
+ finish
+endif
- "syntax cluster matchi add=&ft."Comment"
- "syntax match matchComment "\v^\s*#.*" contains=@matchi conceal cchar=Ξ
- "syntax cluster matchi add=&ft."Comment"
- syntax match matchComment "\v^\s*#.*" conceal cchar=||
+if !exists("g:comceal_char")
+ let g:comceal_char=">"
+endif
+
+if !exists("g:comceal_list")
+ let g:comceal_list = [0,1,3]
+endif
- hi! link matchComment Comment
- set conceallevel=2
-
- nnoremap <silent> <leader>C :call comceal#toggle()<CR>
-
-fun! comceal#toggle()
- if !exists('s:counter')
- let s:counter = 0
- else
- let s:counter += 1
- let s:counter = s:counter % 3
- endif
- setlocal conceallevel=s:counter
+
+fun! s:matchComment()
+ if empty(&ft) && exists("g:comceal_default")
+ let l:commentstr = g:comceal_default
+ else
+ let l:commentstr = &commentstring
+ endif
+ let s:counter = index(g:comceal_list,&conceallevel)
+ let l:commentstr = escape(l:commentstr,'"*')
+ let s:commentString = "^\s*" . substitute(l:commentstr,"%s",".*","")
+ exe 'syntax match matchComment "' . s:commentString .'" conceal cchar='.g:comceal_char
+ hi! link matchComment Comment
+endfun
+
+
+fun! s:toggle(counter)
+ if empty(a:counter)
+ let s:counter = (s:counter + 1) % len(g:comceal_list)
+ else
+ let s:counter = a:counter
+ endif
+ exe 'setlocal conceallevel ='.g:comceal_list[s:counter]
endfun
+
+augroup ComcealVimEnter
+ autocmd!
+ autocmd VimEnter * call s:matchComment()
+augroup End
+
+command! -nargs=? Comceal :call s:toggle(<q-args>)
+" vim: set ts=4 sw=4 foldmethod=syntax tw=80 :