vim-clojure-highlight
vim-clojure-highlight copied to clipboard
Recolouring parentheses
Hey,
Really like the addon, just one thing ticks me off. When I run :ClojureHighlightReferences, all my parentheses, which all have different colors thanks to vim-niji, become the same color. Any idea how to prevent this?
This appears to be an issue more with vim-clojure-static which is actually doing the highlighting work. Not sure what, if anything, should be changed with that plugin.
However vim-niji doesn't modify the highlighting of anything except parentheses and braces, so you should be able to call niji#highlight() after :ClojureHighlightReferences each time and get both forms of highlighting.
I have the same problem as FrigoEU, only I am using rainbow_parentheses.vim.
When I call :ClojureHighlightReferences, the things that vim-clojure-highlight are supposed to work on seem to go through correctly, but parentheses all receive the same colour. And, unfortunately, I cannot fix it with a subsequent call to :RainbowParenthesesToggleAll (or similar commands). They remain un-rainbowy :)
I've taken a screenshot, which you can see here, to illustrate the difference. On the right side, I've called :ClojureHighlightReferences .
http://sta.sh/0230rd7q439i
Should I report this at the vim-clojure-static repo?
Hello all,
Thanks for the heads up on this issue, @Reefersleep, I admit I forgot this exists. My apologies to @FrigoEU for the lack of response.
One solution is to setup the rainbow parens plugin in the Syntax hook:
autocmd VimEnter * RainbowParenthesesToggle
autocmd Syntax clojure RainbowParenthesesLoadRound
autocmd Syntax clojure RainbowParenthesesLoadSquare
autocmd Syntax clojure RainbowParenthesesLoadBraces
This is actually the setup recommended by rainbow_parentheses.vim
, and it
works with vim-clojure-highlight.
I've updated the README with this advice, along with another tip for eager-loading vim-clojure-highlight:
" Evaluate Clojure buffers on load
autocmd BufRead *.clj try | silent! Require | catch /^Fireplace/ | endtry
Hope that clears everything up!
Hello guns
Cheers for the reply!
Adding those 4 + 1 lines to my ~/.vimrc seems to get me most of the way there; when I load up a .clj with a repl running in the project root, I get the syntax highlighting, but not the parens - but now, I am able to load it with :RainbowParenthesesToggle, once I'm inside vim. Is there maybe a way that I can sneak that call into the Require autocmd? I figure that the other lines are called before that one and that is why my parens are dull upon entry. (I've tried reordering them, no difference - I guess it depends on when the specific hooks are executed)
Also, two side effects - opening the .clj file gets somewhat slow, but I guess there's no way around that, as this is the process of highlighting occupying the thread. And, if I open a .cljs file (which I haven't managed to hook up to repls yet), or a .clj file without a lein repl, my parens are dull. Do you know a simple way out of this, perhaps by slightly modifying the vimscript above? I should really learn how to read/write it myself :/
Wait, wait, wait, my mistake - of course I had already defined some activation of rainbow parens in my ~/.vimrc, so by adding those extra lines, I was deactivating my previous activation!
So, in conclusion, I now have the following in my /.vimrc :
autocmd VimEnter * RainbowParenthesesToggle
autocmd Syntax clojure RainbowParenthesesLoadRound
autocmd Syntax clojure RainbowParenthesesLoadSquare
autocmd Syntax clojure RainbowParenthesesLoadBraces
" Evaluate Clojure buffers on load
autocmd BufRead *.clj try | silent! Require | catch /^Fireplace/ | endtry
And, with a lein repl running in the same project root, I get both syntax highlighting and rainbow parens upon entry, and rainbow parens work for both cljs and clj files without a repl. Huzzah!
@Reefersleep wrote:
Also, two side effects - opening the .clj file gets somewhat slow, but I guess there's no way around that, as this is the process of highlighting occupying the thread
More specifically, it's the (require 'my-ns :reload)
that's taking the bulk
of the time, which will be painfully slow if you have classpath.vim installed,
since it fires off a one-time REPL to complete the evaluation.
If that's the pause you are experiencing, I'd recommend either deleting following line:
autocmd BufRead *.clj try | silent! Require | catch /^Fireplace/ | endtry
or deleting classpath.vim to prevent the one-time REPL spin up on load.
Happy to hear that fixes your problems.
@FrigoEU:
I know you have probably moved on with your life, but if you are still interested in this issue, I imagine that something like the following would work for vim-niji:
autocmd Syntax clojure call niji#highlight()
Well, my terminal is not that fast to begin with. I think I've probably fudged things up by adding stupid stuff to my .vimrc and/or by configuring other terminal-related stuff stupidly. Also, disk harddrive. Upgrading to SSD soon.
In any case, I don't have classpath.vim installed, the syntax highlighting only works with a project root repl. Without it, vim loads in about less than half a second, with it, it's ~1,5 seconds. I think the culprit is just the Require/highlight, because when I do cpr with vim-fireplace, it's not exactly fast either.
I'm hoping the SSD will make the need to optimize my terminal configurations redundant ^^
Very happy with the result here, thanks a lot, guns! :+1:
For those who stumble across this and want to use luochen1990/rainbow, I was able to make it work with vim-clojure-highlight without having to add any autocmd
s. Since I'm using vim-plug, I just had to add two lines to my .vimrc
:
Plug 'luochen1990/rainbow'
let g:rainbow_active = 1
So now that section of my .vimrc
(with other plugins removed) looks like this:
" Specify a directory for plugins
call plug#begin('~/.vim/plugged')
" Rainbow parentheses
Plug 'luochen1990/rainbow'
" Initialize plugin system
call plug#end()
" Activate rainbow parentheses
let g:rainbow_active = 1