Skip to content

Commit ff2c8d5

Browse files
committed
Bake in g:clojure_highlight_clojure_core = 1
The extra time needed to add vars from clojure.core is about 2-10ms.
1 parent 8b0aeb6 commit ff2c8d5

File tree

3 files changed

+9
-21
lines changed

3 files changed

+9
-21
lines changed

autoload/vim_clojure_highlight.clj

+4-13
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@
6060
[var]
6161
(= "clojure.core" (-> var meta :ns str)))
6262

63-
(defn refers [ns include-clojure-core?]
64-
(if include-clojure-core?
65-
(ns-refers ns)
66-
(remove (comp clojure-core? peek) (ns-refers ns))))
67-
6863
(defn aliased-refers [ns]
6964
(mapcat
7065
(fn [[alias alias-ns]]
@@ -87,15 +82,11 @@
8782
(mapv (comp pr-str str first))
8883
(string/join \,)
8984
(format "'%s': [%s]" type))))
90-
(string/join \,)
91-
(format "let b:clojure_syntax_keywords = { %s }")))
85+
(string/join \,)))
9286

9387
(defn ns-syntax-command [ns & opts]
94-
(let [{:keys [local-vars clojure-core]
95-
:or {local-vars true clojure-core true}} (apply hash-map opts)
96-
refs (refers ns clojure-core)
97-
dict (syntax-keyword-dictionary (concat refs
88+
(let [{:keys [local-vars] :or {local-vars true}} (apply hash-map opts)
89+
dict (syntax-keyword-dictionary (concat (ns-refers ns)
9890
(aliased-refers ns)
9991
(when local-vars (ns-publics ns))))]
100-
(str "let b:clojure_syntax_without_core_keywords = " (if clojure-core 1 0)
101-
" | " dict)))
92+
(str "let b:clojure_syntax_without_core_keywords = 1 | let b:clojure_syntax_keywords = {" dict "}")))

autoload/vim_clojure_highlight.vim

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ function! vim_clojure_highlight#syntax_match_references(...)
1818
try
1919
call s:require()
2020

21-
let ns = "'" . fireplace#ns()
22-
let opts = (a:0 > 0 && !a:1) ? ' :local-vars false' : ''
23-
let opts .= (a:0 > 1 && !a:2) ? ' :clojure-core false' : ''
21+
let ns = "'" . fireplace#ns()
22+
let opts = (a:0 > 0 && !a:1) ? ' :local-vars false' : ''
2423

2524
execute fireplace#evalparse("(vim-clojure-highlight/ns-syntax-command " . ns . opts . ")")
2625
let &syntax = &syntax
2726
catch /./
2827
endtry
2928
endfunction
29+
30+
" vim:noet:sw=8:ts=8

plugin/vim_clojure_highlight.vim

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@ if !exists('g:clojure_highlight_local_vars')
88
let g:clojure_highlight_local_vars = 1
99
endif
1010

11-
if !exists('g:clojure_highlight_clojure_core')
12-
let g:clojure_highlight_clojure_core = 1
13-
endif
14-
1511
function! s:syntax_match_references()
1612
if g:clojure_highlight_references
17-
call vim_clojure_highlight#syntax_match_references(g:clojure_highlight_local_vars, g:clojure_highlight_clojure_core)
13+
call vim_clojure_highlight#syntax_match_references(g:clojure_highlight_local_vars)
1814
endif
1915
endfunction
2016

0 commit comments

Comments
 (0)