From 148a4184e3ab38fdc10b1f464f59c31433d7031f Mon Sep 17 00:00:00 2001 From: Neil Kirsopp Date: Mon, 17 Feb 2014 16:04:54 +0000 Subject: [PATCH] Workaround certain words being reserved in Vim. Of particular note is 'contains' as anything that does a `(:require [midje.sweet :refer :all])` will end up with contains being referred into the namespace. --- autoload/vim_clojure_highlight.clj | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/autoload/vim_clojure_highlight.clj b/autoload/vim_clojure_highlight.clj index 6f70afa..fbefa47 100644 --- a/autoload/vim_clojure_highlight.clj +++ b/autoload/vim_clojure_highlight.clj @@ -22,10 +22,21 @@ (instance? clojure.lang.MultiFn f)) :fn :else :def))) +(def ^:private syntax-reserved-words + #{"contains" "oneline" "fold" "display" "extend" "concealends" "conceal" + "cchar" "contained" "containedin" "nextgroup" "transparent" "skipwhite" + "skipnl" "skipempty"}) + +;; Wrap the last characte[r] to get around Vim's errors re. reserved words +(defn- fix-reserved-words [w] + (if (syntax-reserved-words w) + (string/replace w #"(.)$" "[$1]") + w)) + (defn- syntax-keyword-statements [seq-name->var] (mapv (fn [[type sks]] - (let [names (string/join \space (mapv first sks))] + (let [names (string/join \space (mapv (comp fix-reserved-words str first) sks))] (case type :macro (str "syntax keyword clojureMacro " names) :fn (str "syntax keyword clojureFunc " names)