diff --git a/README.md b/README.md index 5cb0441..df7ed31 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ regions, such as rainbow parenphesis plugins.) ### Syntax options +#### `g:clojure_syntax_keywords` + Syntax highlighting of public vars in `clojure.core` is provided by default, but additional symbols can be highlighted by adding them to the `g:clojure_syntax_keywords` variable. @@ -58,6 +60,14 @@ will not be highlighted by default. This is useful for namespaces that have set `(:refer-clojure :only [])`. +#### `g:clojure_discard_macro` + +Set this variable to `1` to enable highlighting of the +"[discard reader macro](https://clojure.org/guides/weird_characters#_discard)". +Due to limitations in Vim's syntax rules we cannot correctly highlight stacked +discard macros (e.g. `#_#_`). + + ### Indent options Clojure indentation differs somewhat from traditional Lisps, due in part to diff --git a/doc/clojure.txt b/doc/clojure.txt index a063cb9..b3e0b3a 100644 --- a/doc/clojure.txt +++ b/doc/clojure.txt @@ -115,9 +115,11 @@ clojure-mode.el: CLOJURE *ft-clojure-syntax* + *g:clojure_syntax_keywords* + Syntax highlighting of public vars in "clojure.core" is provided by default, but additional symbols can be highlighted by adding them to the -*g:clojure_syntax_keywords* variable. The value should be a |Dictionary| of +|g:clojure_syntax_keywords| variable. The value should be a |Dictionary| of syntax group names, each containing a |List| of identifiers. > let g:clojure_syntax_keywords = { @@ -135,11 +137,26 @@ By setting the *b:clojure_syntax_without_core_keywords* variable, vars from "clojure.core" will not be highlighted by default. This is useful for namespaces that have set `(:refer-clojure :only [])` -Setting *g:clojure_fold* to `1` will enable the folding of Clojure code. Any + + *g:clojure_fold* + +Setting |g:clojure_fold| to `1` will enable the folding of Clojure code. Any list, vector or map that extends over more than one line can be folded using the standard Vim |fold-commands|. + *g:clojure_discard* + +Set this variable to `1` to enable basic highlighting of Clojure's "discard +reader macro". +> + #_(defn foo [x] + (println x)) +< +Note that this option will not correctly highlight stacked discard macros +(e.g. `#_#_`). + + ABOUT *clojure-about* This document and associated runtime files are maintained at: diff --git a/syntax/clojure.vim b/syntax/clojure.vim index 5acdffa..254f5f5 100644 --- a/syntax/clojure.vim +++ b/syntax/clojure.vim @@ -136,16 +136,17 @@ syntax match clojureComment "#!.*$" syntax match clojureComment "," " Comment out discarded forms. -" TODO: stacking support and/or option to enable/disable this. -syntax region clojureDiscard matchgroup=clojureDiscard start=/#_[ ,\t\n`'~]*/ end=/[, \t\n()\[\]{}";]/me=e-1 -syntax region clojureDiscard matchgroup=clojureDiscard start=/#_[ ,\t\n`'~]*"/ skip=/\\[\\"]/ end=/"/ -syntax region clojureDiscard matchgroup=clojureDiscard start=/#_[ ,\t\n`'~]*(/ end=/)/ contains=clojureDiscardForm -syntax region clojureDiscard matchgroup=clojureDiscard start=/#_[ ,\t\n`'~]*\[/ end=/\]/ contains=clojureDiscardForm -syntax region clojureDiscard matchgroup=clojureDiscard start=/#_[ ,\t\n`'~]*{/ end=/}/ contains=clojureDiscardForm - -syntax region clojureDiscardForm start="(" end=")" contained contains=clojureDiscardForm -syntax region clojureDiscardForm start="{" end="}" contained contains=clojureDiscardForm -syntax region clojureDiscardForm start="\[" end="\]" contained contains=clojureDiscardForm +if exists('g:clojure_discard_macro') && g:clojure_discard_macro + syntax region clojureDiscard matchgroup=clojureDiscard start=/#_[ ,\t\n`'~]*/ end=/[, \t\n()\[\]{}";]/me=e-1 + syntax region clojureDiscard matchgroup=clojureDiscard start=/#_[ ,\t\n`'~]*"/ skip=/\\[\\"]/ end=/"/ + syntax region clojureDiscard matchgroup=clojureDiscard start=/#_[ ,\t\n`'~]*(/ end=/)/ contains=clojureDiscardForm + syntax region clojureDiscard matchgroup=clojureDiscard start=/#_[ ,\t\n`'~]*\[/ end=/\]/ contains=clojureDiscardForm + syntax region clojureDiscard matchgroup=clojureDiscard start=/#_[ ,\t\n`'~]*{/ end=/}/ contains=clojureDiscardForm + + syntax region clojureDiscardForm start="(" end=")" contained contains=clojureDiscardForm + syntax region clojureDiscardForm start="{" end="}" contained contains=clojureDiscardForm + syntax region clojureDiscardForm start="\[" end="\]" contained contains=clojureDiscardForm +endif " -*- TOP CLUSTER -*- " Generated from https://github.com/clojure-vim/clojure.vim/blob/%%RELEASE_TAG%%/clj/src/vim_clojure_static/generate.clj