clojure-vim/clojure.vim

Create sub-filetypes for EDN, boot and Leiningen files

Closed this issue · 1 comments

axvr commented

This is a proposal/request for comments for a possible future change. No change will be made/merged without feedback or demand.


It is possible to make Clojure.vim automatically mark specific Clojure files as Clojure sub-types by using a lesser known Vim feature detailed under :h 'filetype'. This may improve configurabilty and allow other plugins to run specific code for each sub-filetype.

This can be done by changing the filetype detection code to something like this:

" ftdetect/clojure.vim
autocmd BufNewFile,BufRead *.clj,*.cljc,*.cljs setlocal filetype=clojure  " Maybe even separate out cljs?
autocmd BufNewFile,BufRead *.edn setlocal filetype=clojure.edn
autocmd BufNewFile,BufRead {build,profile}.boot setlocal filetype=clojure.boot
autocmd BufNewFile,BufRead project.clj setlocal filetype=clojure.lein

This would also make it possible to add additional syntax keywords per sub-filetype, such as highlighting defproject only in project.clj files.

There may be better ways of achieving the same goals without having to add lots of new filetypes (which may conflict with other filetypes included in Vim). If you can think of any or have any thoughts on this, please leave a comment below.

axvr commented

Closing this because I no longer think it is necessary.

If this is something you would like, please leave a comment detailing your potential use case.