Skip to content

Commit c018733

Browse files
committed
Add update-vim! to automate updating vim repo
1 parent 8b6577d commit c018733

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

ftdetect/clojure.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
autocmd BufNewFile,BufRead *.clj,*.cljs set filetype=clojure
1+
au BufNewFile,BufRead *.clj,*.cljs setf clojure

vim_clojure_static.clj

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
;; Copy this file to a project running the latest Clojure release and generate
66
;; updated Vimscript definitions.
77

8-
(ns vim-clojure-static)
8+
(ns vim-clojure-static
9+
(:require clojure.string clojure.java.shell))
910

1011
(def generation-message
1112
(str "\" Generated from https://github.com/guns/vim-clojure-static/blob/vim-release-001/vim_clojure_static.clj"
@@ -69,5 +70,22 @@
6970
sort
7071
(clojure.string/join \,)))))
7172

73+
(defn update-vim!
74+
"Update runtime files in dir/runtime"
75+
[src dst]
76+
(let [join (fn [& args] (clojure.string/join \/ args))
77+
indent-file (join dst "runtime/doc/indent.txt")
78+
indent-buf (slurp indent-file)
79+
indent-match (re-find #"(?ms)^CLOJURE.*?(?=^[ \p{Lu}]+\t*\*)" indent-buf)
80+
indent-doc (re-find #"(?ms)^CLOJURE.*(?=^ABOUT)" (slurp (join src "doc/clojure.txt")))]
81+
;; Insert indentation documentation
82+
(spit indent-file (clojure.string/replace-first indent-buf
83+
indent-match
84+
(str indent-doc \newline)))
85+
;; Copy runtime files
86+
(doseq [file ["autoload/clojurecomplete.vim" "ftplugin/clojure.vim" "indent/clojure.vim" "syntax/clojure.vim"]]
87+
(println (clojure.java.shell/sh "cp" (join src file) (join dst "runtime" file))))))
88+
7289
(comment
73-
(spit "/tmp/clojure-defs.vim" (str syntax-keywords "\n\n" completion-words)))
90+
(spit "/tmp/clojure-defs.vim" (str syntax-keywords "\n\n" completion-words))
91+
(update-vim! "/home/guns/src/vim-clojure-static" "/home/guns/src/vim"))

0 commit comments

Comments
 (0)