Home Explore Blog CI



neovim

8th chunk of `runtime/doc/indent.txt`
486821d699c6890ac09cc728b9a91d9c7d798efee999f5f90000000100000fb9
 directive.


The defaults, spelled out in full, are: >
	cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,E0,ps,ts,is,+s,
			c3,C0,/0,(2s,us,U0,w0,W0,k0,m0,j0,J0,)20,*70,#0,P0

Vim puts a line in column 1 if:
- It starts with '#' (preprocessor directives), if 'cinkeys' contains '#0'.
- It starts with a label (a keyword followed by ':', other than "case" and
  "default") and 'cinoptions' does not contain an 'L' entry with a positive
  value.
- Any combination of indentations causes the line to have less than 0
  indentation.

==============================================================================
2. Indenting by expression				*indent-expression*

The basics for using flexible indenting are explained in section |30.3| of the
user manual.

If you want to write your own indent file, it must set the 'indentexpr'
option.  Setting the 'indentkeys' option is often useful.
See the $VIMRUNTIME/indent/README.txt file for hints.
See the $VIMRUNTIME/indent directory for examples.


REMARKS ABOUT SPECIFIC INDENT FILES ~


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 configuration options.


							*g:clojure_maxlines*

Sets 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.  The default is 300.


						*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 should 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)$']
<
|g:clojure_fuzzy_indent_patterns| and |g:clojure_fuzzy_indent_blacklist| are
lists of patterns that will be matched against the 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 such that every subform is indented by 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 multi-line 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.")
<

						*g:clojure_align_subforms*

Title: Indenting by Expression and Specific Remarks About Clojure Indent Files
Summary
This section discusses indenting by expression using 'indentexpr' and 'indentkeys', and provides remarks about specific indent files, focusing on Clojure. It covers Clojure-specific indentation conventions, configuration options such as 'g:clojure_maxlines', 'g:clojure_fuzzy_indent', 'g:clojure_fuzzy_indent_patterns', 'g:clojure_fuzzy_indent_blacklist', 'g:clojure_special_indent_words', 'g:clojure_align_multiline_strings', and alignment of subforms. It explains how to customize Clojure indentation based on special forms and multi-line strings.