Skip to content

Commit 5dea5ab

Browse files
committed
Move 'lispwords' setting to ftplugin
The scheme filetype sets lispwords in its ftplugin, so we should set lispwords in our ftplugin for compatibility. This also prepares vim-clojure-static for the lispwords-global-local patch I will be sending upstream as `setlocal lispwords=` effectively resets lispwords to the global value instead of blanking it. cf. issue #43 Finally, the new setlocal syntax is compact, which Bram always appreciates.
1 parent 3910ac4 commit 5dea5ab

3 files changed

Lines changed: 43 additions & 81 deletions

File tree

clj/src/vim_clojure_static/generate.clj

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,25 @@
139139
:script (set script)
140140
:block (set block)}))
141141

142+
(def lispwords
143+
"Specially indented symbols in clojure.core and clojure.test. Please read
144+
the commit message tagged `lispwords-guidelines` when adding new words to
145+
this list."
146+
(set/union
147+
;; Definitions
148+
'#{bound-fn def definline definterface defmacro defmethod defmulti defn
149+
defn- defonce defprotocol defrecord defstruct deftest deftest- deftype
150+
extend extend-protocol extend-type fn ns proxy reify set-test}
151+
;; Binding forms
152+
'#{as-> binding doall dorun doseq dotimes doto for if-let let letfn
153+
locking loop testing when-first when-let with-bindings with-in-str
154+
with-local-vars with-open with-precision with-redefs with-redefs-fn
155+
with-test}
156+
;; Conditional branching
157+
'#{case cond-> cond->> condp if if-not when when-not while}
158+
;; Exception handling
159+
'#{catch}))
160+
142161
;;
143162
;; Vimscript literals
144163
;;
@@ -249,6 +268,10 @@
249268
(fmt "script=" :script)
250269
(fmt "block=" :block)])))
251270

271+
(def vim-lispwords
272+
"Vimscript literal `setlocal lispwords=` statement."
273+
(str "setlocal lispwords=" (string/join \, (sort lispwords)) "\n"))
274+
252275
(comment
253276
;; Generate the vim literal definitions for pasting into the runtime files.
254277
(spit "tmp/clojure-defs.vim"
@@ -266,6 +289,9 @@
266289
vim-unicode-block-char-classes
267290
\newline
268291
generation-comment
292+
vim-lispwords
293+
\newline
294+
generation-comment
269295
clojure-version-comment
270296
vim-completion-words))
271297
;; Generate an example file with all possible character property literals.

ftplugin/clojure.vim

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let b:did_ftplugin = 1
1515
let s:cpo_save = &cpo
1616
set cpo&vim
1717

18-
let b:undo_ftplugin = 'setlocal iskeyword< define< formatoptions< comments< commentstring<'
18+
let b:undo_ftplugin = 'setlocal iskeyword< define< formatoptions< comments< commentstring< lispwords<'
1919

2020
setlocal iskeyword+=?,-,*,!,+,/,=,<,>,.,:,$
2121

@@ -30,6 +30,21 @@ setlocal formatoptions-=t
3030
setlocal comments=n:;
3131
setlocal commentstring=;\ %s
3232

33+
" Specially indented symbols from clojure.core and clojure.test.
34+
"
35+
" Clojure symbols are indented in the defn style when they:
36+
"
37+
" * Define vars and anonymous functions
38+
" * Create new lexical scopes or scopes with altered environments
39+
" * Create conditional branches from a predicate function or value
40+
"
41+
" The arglists for these functions are generally in the form of [x & body];
42+
" Functions that accept a flat list of forms do not treat the first argument
43+
" specially and hence are not indented specially.
44+
"
45+
" Generated from https://github.com/guns/vim-clojure-static/blob/%%RELEASE_TAG%%/clj/src/vim_clojure_static/generate.clj
46+
setlocal lispwords=as->,binding,bound-fn,case,catch,cond->,cond->>,condp,def,definline,definterface,defmacro,defmethod,defmulti,defn,defn-,defonce,defprotocol,defrecord,defstruct,deftest,deftest-,deftype,doall,dorun,doseq,dotimes,doto,extend,extend-protocol,extend-type,fn,for,if,if-let,if-not,let,letfn,locking,loop,ns,proxy,reify,set-test,testing,when,when-first,when-let,when-not,while,with-bindings,with-in-str,with-local-vars,with-open,with-precision,with-redefs,with-redefs-fn,with-test
47+
3348
" Provide insert mode completions for special forms and clojure.core. As
3449
" 'omnifunc' is set by popular Clojure REPL client plugins, we also set
3550
" 'completefunc' so that the user has some form of completion available when

indent/clojure.vim

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let b:did_indent = 1
2121
let s:save_cpo = &cpo
2222
set cpo&vim
2323

24-
let b:undo_indent = 'setlocal autoindent< smartindent< lispwords< expandtab< softtabstop< shiftwidth< indentexpr< indentkeys<'
24+
let b:undo_indent = 'setlocal autoindent< smartindent< expandtab< softtabstop< shiftwidth< indentexpr< indentkeys<'
2525

2626
setlocal noautoindent nosmartindent
2727
setlocal softtabstop=2 shiftwidth=2 expandtab
@@ -312,85 +312,6 @@ else
312312

313313
endif
314314

315-
" Specially indented symbols from clojure.core and clojure.test.
316-
"
317-
" Clojure symbols are indented in the defn style when they:
318-
"
319-
" * Define vars and anonymous functions
320-
" * Create new lexical scopes or scopes with altered environments
321-
" * Create conditional branches from a predicate function or value
322-
"
323-
" The arglists for these functions are generally in the form of [x & body];
324-
" Functions that accept a flat list of forms do not treat the first argument
325-
" specially and hence are not indented specially.
326-
327-
" Definitions
328-
setlocal lispwords=
329-
setlocal lispwords+=bound-fn
330-
setlocal lispwords+=def
331-
setlocal lispwords+=definline
332-
setlocal lispwords+=definterface
333-
setlocal lispwords+=defmacro
334-
setlocal lispwords+=defmethod
335-
setlocal lispwords+=defmulti
336-
setlocal lispwords+=defn
337-
setlocal lispwords+=defn-
338-
setlocal lispwords+=defonce
339-
setlocal lispwords+=defprotocol
340-
setlocal lispwords+=defrecord
341-
setlocal lispwords+=defstruct
342-
setlocal lispwords+=deftest " clojure.test
343-
setlocal lispwords+=deftest- " clojure.test
344-
setlocal lispwords+=deftype
345-
setlocal lispwords+=extend
346-
setlocal lispwords+=extend-protocol
347-
setlocal lispwords+=extend-type
348-
setlocal lispwords+=fn
349-
setlocal lispwords+=ns
350-
setlocal lispwords+=proxy
351-
setlocal lispwords+=reify
352-
setlocal lispwords+=set-test " clojure.test
353-
354-
" Binding forms
355-
setlocal lispwords+=as->
356-
setlocal lispwords+=binding
357-
setlocal lispwords+=doall
358-
setlocal lispwords+=dorun
359-
setlocal lispwords+=doseq
360-
setlocal lispwords+=dotimes
361-
setlocal lispwords+=doto
362-
setlocal lispwords+=for
363-
setlocal lispwords+=if-let
364-
setlocal lispwords+=let
365-
setlocal lispwords+=letfn
366-
setlocal lispwords+=locking
367-
setlocal lispwords+=loop
368-
setlocal lispwords+=testing " clojure.test
369-
setlocal lispwords+=when-first
370-
setlocal lispwords+=when-let
371-
setlocal lispwords+=with-bindings
372-
setlocal lispwords+=with-in-str
373-
setlocal lispwords+=with-local-vars
374-
setlocal lispwords+=with-open
375-
setlocal lispwords+=with-precision
376-
setlocal lispwords+=with-redefs
377-
setlocal lispwords+=with-redefs-fn
378-
setlocal lispwords+=with-test " clojure.test
379-
380-
" Conditional branching
381-
setlocal lispwords+=case
382-
setlocal lispwords+=cond->
383-
setlocal lispwords+=cond->>
384-
setlocal lispwords+=condp
385-
setlocal lispwords+=if
386-
setlocal lispwords+=if-not
387-
setlocal lispwords+=when
388-
setlocal lispwords+=when-not
389-
setlocal lispwords+=while
390-
391-
" Exception handling
392-
setlocal lispwords+=catch
393-
394315
let &cpo = s:save_cpo
395316
unlet! s:save_cpo
396317

0 commit comments

Comments
 (0)