Commits

Meikel Brandmeyer committed 1612829

Allow toggle of ParenRainbow

Fixes #65

  • Participants
  • Parent commits 7a30882

Comments (0)

Files changed (5)

vim/autoload/vimclojure.vim

 	execute "setlocal lw+=" . a:word
 endfunction
 
+function! vimclojure#ToggleParenRainbow()
+	highlight clear clojureParen1
+	highlight clear clojureParen2
+	highlight clear clojureParen3
+	highlight clear clojureParen4
+	highlight clear clojureParen5
+	highlight clear clojureParen6
+	highlight clear clojureParen7
+	highlight clear clojureParen8
+	highlight clear clojureParen9
+
+	let g:vimclojure#ParenRainbow = !g:vimclojure#ParenRainbow
+
+	if g:vimclojure#ParenRainbow != 0
+		if &background == "dark"
+			highlight clojureParen1 ctermfg=yellow      guifg=orange1
+			highlight clojureParen2 ctermfg=green       guifg=yellow1
+			highlight clojureParen3 ctermfg=cyan        guifg=greenyellow
+			highlight clojureParen4 ctermfg=magenta     guifg=green1
+			highlight clojureParen5 ctermfg=red         guifg=springgreen1
+			highlight clojureParen6 ctermfg=yellow      guifg=cyan1
+			highlight clojureParen7 ctermfg=green       guifg=slateblue1
+			highlight clojureParen8 ctermfg=cyan        guifg=magenta1
+			highlight clojureParen9 ctermfg=magenta     guifg=purple1
+		else
+			highlight clojureParen1 ctermfg=darkyellow  guifg=orangered3
+			highlight clojureParen2 ctermfg=darkgreen   guifg=orange2
+			highlight clojureParen3 ctermfg=blue        guifg=yellow3
+			highlight clojureParen4 ctermfg=darkmagenta guifg=olivedrab4
+			highlight clojureParen5 ctermfg=red         guifg=green4
+			highlight clojureParen6 ctermfg=darkyellow  guifg=paleturquoise3
+			highlight clojureParen7 ctermfg=darkgreen   guifg=deepskyblue4
+			highlight clojureParen8 ctermfg=blue        guifg=darkslateblue
+			highlight clojureParen9 ctermfg=darkmagenta guifg=darkviolet
+		endif
+	else
+		highlight link clojureParen1 clojureParen0
+		highlight link clojureParen2 clojureParen0
+		highlight link clojureParen3 clojureParen0
+		highlight link clojureParen4 clojureParen0
+		highlight link clojureParen5 clojureParen0
+		highlight link clojureParen6 clojureParen0
+		highlight link clojureParen7 clojureParen0
+		highlight link clojureParen8 clojureParen0
+		highlight link clojureParen9 clojureParen0
+	endif
+endfunction
+
 " Epilog
 let &cpo = s:save_cpo

vim/doc/clojure.txt

                         of the buffer. This modifies the way the form is
                         indented.
 
+<LocalLeader>tr                                 *tr* *ToggleParenRainbow*
+                        Toggle the paren rainbow option. Note: After
+                        toggling the default colors will be used. Not any
+                        customised ones.
+
 Vim Repl
 --------
 

vim/ftplugin/clojure.vim

 endtry
 
 call vimclojure#MapPlug("n", "aw", "AddToLispWords")
+call vimclojure#MapPlug("n", "tr", "ToggleParenRainbow")
 
 call vimclojure#MapCommandPlug("n", "lw", "DocLookupWord")
 call vimclojure#MapCommandPlug("n", "li", "DocLookupInteractive")

vim/plugin/clojure.vim

 command! -nargs=0 ClojureRepl call vimclojure#StartRepl()
 
 call vimclojure#MakeProtectedPlug("n", "AddToLispWords", "vimclojure#AddToLispWords", "expand(\"<cword>\")")
+call vimclojure#MakeProtectedPlug("n", "ToggleParenRainbow", "vimclojure#ToggleParenRainbow", "")
 
 call vimclojure#MakeProtectedPlug("n", "DocLookupWord", "vimclojure#DocLookup", "expand(\"<cword>\")")
 call vimclojure#MakeProtectedPlug("n", "DocLookupInteractive", "vimclojure#DocLookup", "input(\"Symbol to look up: \")")

vim/syntax/clojure.vim

 syn match   clojureAnonArg contained "%\(\d\|&\)\?"
 syn match   clojureVarArg contained "&"
 
-if vimclojure#ParenRainbow != 0
-	syn region clojureSexpLevel0 matchgroup=clojureParen0 start="(" matchgroup=clojureParen0 end=")"           contains=@clojureTopCluster,clojureSexpLevel1
-	syn region clojureSexpLevel1 matchgroup=clojureParen1 start="(" matchgroup=clojureParen1 end=")" contained contains=@clojureTopCluster,clojureSexpLevel2
-	syn region clojureSexpLevel2 matchgroup=clojureParen2 start="(" matchgroup=clojureParen2 end=")" contained contains=@clojureTopCluster,clojureSexpLevel3
-	syn region clojureSexpLevel3 matchgroup=clojureParen3 start="(" matchgroup=clojureParen3 end=")" contained contains=@clojureTopCluster,clojureSexpLevel4
-	syn region clojureSexpLevel4 matchgroup=clojureParen4 start="(" matchgroup=clojureParen4 end=")" contained contains=@clojureTopCluster,clojureSexpLevel5
-	syn region clojureSexpLevel5 matchgroup=clojureParen5 start="(" matchgroup=clojureParen5 end=")" contained contains=@clojureTopCluster,clojureSexpLevel6
-	syn region clojureSexpLevel6 matchgroup=clojureParen6 start="(" matchgroup=clojureParen6 end=")" contained contains=@clojureTopCluster,clojureSexpLevel7
-	syn region clojureSexpLevel7 matchgroup=clojureParen7 start="(" matchgroup=clojureParen7 end=")" contained contains=@clojureTopCluster,clojureSexpLevel8
-	syn region clojureSexpLevel8 matchgroup=clojureParen8 start="(" matchgroup=clojureParen8 end=")" contained contains=@clojureTopCluster,clojureSexpLevel9
-	syn region clojureSexpLevel9 matchgroup=clojureParen9 start="(" matchgroup=clojureParen9 end=")" contained contains=@clojureTopCluster,clojureSexpLevel0
-else
-	syn region clojureSexp       matchgroup=clojureParen0 start="(" matchgroup=clojureParen0 end=")"           contains=@clojureTopCluster
-endif
+syn region clojureSexpLevel0 matchgroup=clojureParen0 start="(" matchgroup=clojureParen0 end=")"           contains=@clojureTopCluster,clojureSexpLevel1
+syn region clojureSexpLevel1 matchgroup=clojureParen1 start="(" matchgroup=clojureParen1 end=")" contained contains=@clojureTopCluster,clojureSexpLevel2
+syn region clojureSexpLevel2 matchgroup=clojureParen2 start="(" matchgroup=clojureParen2 end=")" contained contains=@clojureTopCluster,clojureSexpLevel3
+syn region clojureSexpLevel3 matchgroup=clojureParen3 start="(" matchgroup=clojureParen3 end=")" contained contains=@clojureTopCluster,clojureSexpLevel4
+syn region clojureSexpLevel4 matchgroup=clojureParen4 start="(" matchgroup=clojureParen4 end=")" contained contains=@clojureTopCluster,clojureSexpLevel5
+syn region clojureSexpLevel5 matchgroup=clojureParen5 start="(" matchgroup=clojureParen5 end=")" contained contains=@clojureTopCluster,clojureSexpLevel6
+syn region clojureSexpLevel6 matchgroup=clojureParen6 start="(" matchgroup=clojureParen6 end=")" contained contains=@clojureTopCluster,clojureSexpLevel7
+syn region clojureSexpLevel7 matchgroup=clojureParen7 start="(" matchgroup=clojureParen7 end=")" contained contains=@clojureTopCluster,clojureSexpLevel8
+syn region clojureSexpLevel8 matchgroup=clojureParen8 start="(" matchgroup=clojureParen8 end=")" contained contains=@clojureTopCluster,clojureSexpLevel9
+syn region clojureSexpLevel9 matchgroup=clojureParen9 start="(" matchgroup=clojureParen9 end=")" contained contains=@clojureTopCluster,clojureSexpLevel0
 
 syn region  clojureAnonFn  matchgroup=clojureParen0 start="#(" matchgroup=clojureParen0 end=")"  contains=@clojureTopCluster,clojureAnonArg,clojureSexpLevel0
 syn region  clojureVector  matchgroup=clojureParen0 start="\[" matchgroup=clojureParen0 end="\]" contains=@clojureTopCluster,clojureVarArg,clojureSexpLevel0
 		highlight default clojureParen8 ctermfg=blue        guifg=darkslateblue
 		highlight default clojureParen9 ctermfg=darkmagenta guifg=darkviolet
 	endif
+else
+	HiLink clojureParen1 clojureParen0
+	HiLink clojureParen2 clojureParen0
+	HiLink clojureParen3 clojureParen0
+	HiLink clojureParen4 clojureParen0
+	HiLink clojureParen5 clojureParen0
+	HiLink clojureParen6 clojureParen0
+	HiLink clojureParen7 clojureParen0
+	HiLink clojureParen8 clojureParen0
+	HiLink clojureParen9 clojureParen0
 endif
 
 delcommand HiLink