Skip to content

Commit 1240182

Browse files
committed
Update README for clojure_syntax_keywords
1 parent c012e5a commit 1240182

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

README.markdown

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ filetype plugin indent on
5555
Features
5656
========
5757

58-
* Syntax highlighting for Clojure and ClojureScript buffers.
58+
* [Augmentable](#syntax-options) syntax highlighting for Clojure and
59+
ClojureScript buffers.
5960

6061
* [Configurable](#indent-options) Clojure-specific indentation.
6162

@@ -74,15 +75,14 @@ Third Party Extensions
7475

7576
* Rainbow Parentheses
7677

77-
kien's
78-
[`rainbow_parentheses.vim`](https://github.com/kien/rainbow_parentheses.vim)
78+
kien's [`rainbow_parentheses.vim`](https://github.com/kien/rainbow_parentheses.vim)
7979
is highly recommended.
8080

8181
* Extended Syntax Highlighting
8282

83-
[`vim-clojure-highlight`](https://github.com/guns/vim-clojure-highlight)
84-
is a fireplace.vim plugin that extends syntax highlighting to referred and
85-
aliased vars.
83+
[`vim-clojure-highlight`](https://github.com/guns/vim-clojure-highlight) is
84+
a fireplace.vim plugin that extends syntax highlighting to local, referred,
85+
and aliased vars via [`b:clojure_syntax_keywords`](#syntax-options).
8686

8787
This is a reimplementation of the DynamicHighlighting feature from
8888
VimClojure.
@@ -94,6 +94,31 @@ If you would like to get more serious about programming in Clojure, consider
9494
using an interactive
9595
[Clojure REPL plugin](https://github.com/guns/vim-clojure-static/wiki/Clojure-REPL-Plugins).
9696

97+
Syntax Options
98+
==============
99+
100+
Syntax highlighting for public vars from `clojure.core` is provided by
101+
default, but any symbol can be matched and highlighted by adding it to the
102+
`g:clojure_syntax_keywords` or `b:clojure_syntax_keywords` variables:
103+
104+
```vim
105+
let g:clojure_syntax_keywords = {
106+
\ 'clojureMacro': ["defproject", "defcustom"],
107+
\ 'clojureFunc': ["string/join", "string/replace"]
108+
\ }
109+
```
110+
111+
See `s:clojure_syntax_keywords` in the [syntax script](syntax/clojure.vim) for
112+
a complete example.
113+
114+
The global version of this variable is intended for users that always wish
115+
to have a certain set of symbols highlighted in a certain way, while the
116+
buffer-local version is intended for plugin authors who wish to highlight
117+
symbols dynamically.
118+
119+
[`vim-clojure-highlight`](https://github.com/guns/vim-clojure-highlight) uses
120+
this feature to highlight extra vars when connected to a REPL.
121+
97122
Indent Options
98123
==============
99124

doc/clojure.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ This option is off by default.
126126

127127
CLOJURE *ft-clojure-syntax*
128128

129+
The default syntax groups can be augmented through the
130+
*g:clojure_syntax_keywords* and *b:clojure_syntax_keywords* variables. The
131+
value should be a |Dictionary| of syntax group names to a |List| of custom
132+
identifiers:
133+
>
134+
let g:clojure_syntax_keywords = {
135+
\ 'clojureMacro': ["defproject", "defcustom"],
136+
\ 'clojureFunc': ["string/join", "string/replace"]
137+
\ }
138+
<
139+
Refer to the Clojure syntax script for valid syntax group names.
140+
129141
Setting *g:clojure_fold* enables folding Clojure code via the syntax engine.
130142
Any list, vector, or map that extends over more than one line can be folded
131143
using the standard Vim |fold-commands|.

0 commit comments

Comments
 (0)