Skip to content

Commit aa0e67d

Browse files
jballancguns
authored andcommitted
Add fold arguments to appropriate syntax forms
This change makes it so that setting `foldmethod` to `syntax` allows you to fold up Clojure S-Exps.
1 parent a7c6158 commit aa0e67d

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

doc/clojure.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,17 @@ This option is off by default.
123123
" Default
124124
let g:clojure_align_subforms = 0
125125
<
126+
*g:clojure_fold*
127+
128+
Setting this option enables folding Clojure code via syntax forms. Any list,
129+
vector, or map that extends over more than one line can be folded using the
130+
standard Vim |fold-commands|.
131+
132+
This option is off by default.
133+
>
134+
" Default
135+
let g:clojure_fold = 0
136+
<
126137

127138
ABOUT *clojure-about*
128139

syntax/clojure.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ if exists("b:current_syntax")
1515
finish
1616
endif
1717

18+
if has("folding") && exists("g:clojure_fold")
19+
setlocal foldmethod=syntax
20+
endif
21+
1822
" Generated from https://github.com/guns/vim-clojure-static/blob/%%RELEASE_TAG%%/clj/src/vim_clojure_static/generate.clj
1923
" Clojure version 1.5.1
2024
syntax keyword clojureConstant nil
@@ -117,9 +121,9 @@ syntax keyword clojureCommentTodo contained FIXME XXX TODO FIXME: XXX: TODO:
117121
syntax match clojureComment ";.*$" contains=clojureCommentTodo,@Spell
118122
syntax match clojureComment "#!.*$"
119123

120-
syntax region clojureSexp matchgroup=clojureParen start="(" matchgroup=clojureParen end=")" contains=TOP,@Spell
121-
syntax region clojureVector matchgroup=clojureParen start="\[" matchgroup=clojureParen end="]" contains=TOP,@Spell
122-
syntax region clojureMap matchgroup=clojureParen start="{" matchgroup=clojureParen end="}" contains=TOP,@Spell
124+
syntax region clojureSexp matchgroup=clojureParen start="(" matchgroup=clojureParen end=")" contains=TOP,@Spell fold
125+
syntax region clojureVector matchgroup=clojureParen start="\[" matchgroup=clojureParen end="]" contains=TOP,@Spell fold
126+
syntax region clojureMap matchgroup=clojureParen start="{" matchgroup=clojureParen end="}" contains=TOP,@Spell fold
123127

124128
" Highlight superfluous closing parens, brackets and braces.
125129
syntax match clojureError "]\|}\|)"

0 commit comments

Comments
 (0)