@@ -24,7 +24,10 @@ setlocal indentkeys=!,o,O
2424" NOTE: To debug this code, make sure to "set debug+=msg" otherwise errors
2525" will occur silently.
2626
27- " TODO: After all optimisations create Vim9script variant of the core algorithm.
27+ " Get the value of a configuration option.
28+ function ! s: Conf (opt , default)
29+ return get (b: , a: opt , get (g: , a: opt , a: default ))
30+ endfunction
2831
2932" Returns "1" if position "i_char" in "line_str" is preceded by an odd number
3033" of backslash characters (i.e. escaped).
@@ -33,9 +36,10 @@ function! s:IsEscaped(line_str, i_char)
3336 return (strlen (ln ) - strlen(trim(ln, '\', 2))) % 2
3437endfunction
3538
36- " Repeatedly search for tokens on a given line (in reverse order) building up
37- " a list of tokens and their positions. Ignores escaped tokens. Does not
38- " care about strings, as that is handled by "s:InsideForm".
39+ " Repeatedly search for indentation significant Clojure tokens on a given line
40+ " (in reverse order) building up a list of tokens and their positions.
41+ " Ignores escaped tokens. Does not care about strings, which is handled by
42+ " "s:InsideForm".
3943function ! s: TokeniseLine (line_num)
4044 let tokens = []
4145 let ln = getline(a:line_num)
@@ -68,9 +72,10 @@ endfunction
6872
6973let s: pairs = {' (' : ' )' , ' [' : ' ]' , ' {' : ' }' }
7074
71- " This procedure is kind of like a really lightweight Clojure reader. It
72- " looks at the lines above the current line, tokenises them (from right to
73- " left), and performs reductions to find the parent form and where it is.
75+ " This procedure is kind of like a really lightweight Clojure reader that
76+ " analyses from the inside out. It looks at the lines above the current line,
77+ " tokenises them (from right to left), and performs reductions to find the
78+ " parent form and where it is.
7479function ! s: InsideForm (lnum)
7580 " Reset cursor to first column of the line we wish to indent.
7681 call cursor (a: lnum , 1 )
@@ -127,11 +132,6 @@ function! s:InsideForm(lnum)
127132 return [' ^' , [0 , 0 ]] " Default to top-level.
128133endfunction
129134
130- " Get the value of a configuration option.
131- function ! s: Conf (opt , default)
132- return get (b: , a: opt , get (g: , a: opt , a: default ))
133- endfunction
134-
135135" Returns "1" when the previous operator used was "=" and is currently active.
136136function ! s: EqualsOperatorInEffect ()
137137 return v: operator == # ' =' && state (' o' ) == # ' o'
0 commit comments