summaryrefslogtreecommitdiffstats
path: root/doc/clojure.txt
blob: 07fce86b968b7f1a33652b76237d6397955a47ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'clojure') == -1

*clojure.txt*	Clojure runtime files

INTRODUCTION						*clojure-introduction*

Meikel Brandmeyer's excellent Clojure runtime files. Includes syntax, indent,
ftdetect, and ftplugin scripts.

CLOJURE					*ft-clojure-indent* *clojure-indent*

Clojure indentation differs somewhat from traditional Lisps, due in part to
the use of square and curly brackets, and otherwise by community convention.
These conventions are not universally followed, so the Clojure indent script
offers a few configurable options, listed below.

If the current vim does not include searchpairpos(), the indent script falls
back to normal 'lisp' indenting, and the following options are ignored.

							*g:clojure_maxlines*

Set maximum scan distance of searchpairpos(). Larger values trade performance
for correctness when dealing with very long forms. A value of 0 will scan
without limits.
>
	" Default
	let g:clojure_maxlines = 100
<
						*g:clojure_fuzzy_indent*
					*g:clojure_fuzzy_indent_patterns*
					*g:clojure_fuzzy_indent_blacklist*

The 'lispwords' option is a list of comma-separated words that mark special
forms whose subforms must be indented with two spaces.

For example:
>
	(defn bad []
	      "Incorrect indentation")

	(defn good []
	  "Correct indentation")
<
If you would like to specify 'lispwords' with a |pattern| instead, you can use
the fuzzy indent feature:
>
	" Default
	let g:clojure_fuzzy_indent = 1
	let g:clojure_fuzzy_indent_patterns = ['^with', '^def', '^let']
	let g:clojure_fuzzy_indent_blacklist =
		\ ['-fn$', '\v^with-%(meta|out-str|loading-context)$']

	" Legacy comma-delimited string version; the list format above is
	" recommended. Note that patterns are implicitly anchored with ^ and $
	let g:clojure_fuzzy_indent_patterns = 'with.*,def.*,let.*'
<
|g:clojure_fuzzy_indent_patterns| and |g:clojure_fuzzy_indent_blacklist| are
|Lists| of patterns that will be matched against the unquoted, unqualified
symbol at the head of a list. This means that a pattern like "^foo" will match
all these candidates: "foobar", "my.ns/foobar", and "#'foobar".

Each candidate word is tested for special treatment in this order:

	1. Return true if word is literally in 'lispwords'
	2. Return false if word matches a pattern in
	   |g:clojure_fuzzy_indent_blacklist|
	3. Return true if word matches a pattern in
	   |g:clojure_fuzzy_indent_patterns|
	4. Return false and indent normally otherwise

					*g:clojure_special_indent_words*

Some forms in Clojure are indented so that every subform is indented only two
spaces, regardless of 'lispwords'. If you have a custom construct that should
be indented in this idiosyncratic fashion, you can add your symbols to the
default list below.
>
	" Default
	let g:clojure_special_indent_words =
	   \ 'deftype,defrecord,reify,proxy,extend-type,extend-protocol,letfn'
<
					*g:clojure_align_multiline_strings*

Align subsequent lines in multiline strings to the column after the opening
quote, instead of the same column.

For example:
>
	(def default
	  "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
	  eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
	  enim ad minim veniam, quis nostrud exercitation ullamco laboris
	  nisi ut aliquip ex ea commodo consequat.")

	(def aligned
	  "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
	   eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
	   enim ad minim veniam, quis nostrud exercitation ullamco laboris
	   nisi ut aliquip ex ea commodo consequat.")
<
This option is off by default.
>
	" Default
	let g:clojure_align_multiline_strings = 0
<
						*g:clojure_align_subforms*

By default, parenthesized compound forms that look like function calls and
whose head subform is on its own line have subsequent subforms indented by
two spaces relative to the opening paren:
>
	(foo
	  bar
	  baz)
<
Setting this option changes this behavior so that all subforms are aligned to
the same column, emulating the default behavior of clojure-mode.el:
>
	(foo
	 bar
	 baz)
<
This option is off by default.
>
	" Default
	let g:clojure_align_subforms = 0
<

CLOJURE							*ft-clojure-syntax*

The default syntax groups can be augmented through the
*g:clojure_syntax_keywords* and *b:clojure_syntax_keywords* variables. The
value should be a |Dictionary| of syntax group names to a |List| of custom
identifiers:
>
	let g:clojure_syntax_keywords = {
	    \ 'clojureMacro': ["defproject", "defcustom"],
	    \ 'clojureFunc': ["string/join", "string/replace"]
	    \ }
<
Refer to the Clojure syntax script for valid syntax group names.

If the |buffer-variable| *b:clojure_syntax_without_core_keywords* is set, only
language constants and special forms are matched.

Setting *g:clojure_fold* enables folding Clojure code via the syntax engine.
Any list, vector, or map that extends over more than one line can be folded
using the standard Vim |fold-commands|.

Please note that this option does not work with scripts that redefine the
bracket syntax regions, such as rainbow-parentheses plugins.

This option is off by default.
>
	" Default
	let g:clojure_fold = 0
<

ABOUT							*clojure-about*

This document and associated runtime files are maintained at:
https://github.com/guns/vim-clojure-static

Distributed under the Vim license. See |license|.

syntax/clojure.vim

	Copyright 2007-2008 (c) Toralf Wittner <toralf.wittner@gmail.com>
	Copyright 2008-2012 (c) Meikel Brandmeyer <mb@kotka.de>

ftdetect/clojure.vim,
ftplugin/clojure.vim,
indent/clojure.vim

	Copyright 2008-2012 (c) Meikel Brandmeyer <mb@kotka.de>

Modified and relicensed under the Vim License for distribution with Vim:

	Copyright 2013-2014 (c) Sung Pae <self@sungpae.com>

Last Change: %%RELEASE_DATE%%

 vim:tw=78:noet:sw=8:sts=8:ts=8:ft=help:norl:

endif