Skip to content

Commit 9ac6cb8

Browse files
committed
Provide more setup tips in the README
cf. guns#4
1 parent aac76b4 commit 9ac6cb8

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

README.markdown

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,47 @@ please refer to [Pathogen](https://github.com/tpope/vim-pathogen).
3939
# Usage
4040

4141
`vim-clojure-highlight` installs an autocommand that detects and highlights
42-
local vars, ns-refers, and aliased references every time a `*.clj` file is
43-
(re)loaded.
42+
local vars, ns-refers, and aliased references every time a `*.clj` file
43+
is (re)loaded. The syntax highlighting reflects the state of the REPL, so
44+
unevaluated references remain unmatched.
4445

45-
This will fail silently if fireplace is unable to connect to an nREPL server.
46+
This will fail silently if no fireplace nREPL sessions exist.
4647

47-
Reload your buffer with `:e` to update syntax matches. Alternately, use the
48-
`:ClojureHighlightReferences` command in a custom autocommand or mapping to do
49-
the same.
48+
Reload your buffer with `:e` after an eval to update syntax matches.
49+
Alternately, use the `:ClojureHighlightReferences` command in a custom
50+
autocommand or mapping to do the same.
5051

51-
See the `doc/vim-clojure-highlight.txt` for more commands and options.
52+
# Eager loading
53+
54+
If you would like to eager-load a fireplace session so that
55+
vim-clojure-highlight works on the first load of a clojure file, install an
56+
autocommand hook that calls `:Require`:
57+
58+
```vim
59+
" Evaluate Clojure buffers on load
60+
autocmd BufRead *.clj try | silent! Require | catch /^Fireplace/ | endtry
61+
```
62+
63+
# Rainbow parentheses and other syntax extensions
64+
65+
Since vim-clojure-highlight dynamically alters the syntax state of a buffer,
66+
it's possible that other syntax extensions will be affected by this plugin.
67+
68+
A simple workaround is to activate Clojure syntax extensions in an autocmd:
69+
70+
```vim
71+
autocmd Syntax clojure EnableSyntaxExtension
72+
```
73+
74+
For example, this is how you might enable
75+
[`rainbow_parentheses.vim`](https://github.com/kien/rainbow_parentheses.vim)
76+
for Clojure buffers:
77+
78+
```vim
79+
autocmd VimEnter * RainbowParenthesesToggle
80+
autocmd Syntax clojure RainbowParenthesesLoadRound
81+
autocmd Syntax clojure RainbowParenthesesLoadSquare
82+
autocmd Syntax clojure RainbowParenthesesLoadBraces
83+
```
84+
85+
See `doc/vim-clojure-highlight.txt` for more commands and options.

plugin/vim_clojure_highlight.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ endfunction
2727

2828
augroup vim_clojure_highlight
2929
autocmd!
30-
autocmd BufRead *.clj call s:syntax_match_references()
30+
autocmd BufRead *.clj ClojureHighlightReferences
3131
augroup END
3232

3333
command! -bar ToggleClojureHighlightReferences call s:toggle_clojure_highlight_references()

0 commit comments

Comments
 (0)