blob: 4da7554d85b411e9357cbc6dfb4ffa75bf70afa4 [file] [log] [blame]
Bram Moolenaarfa13eef2013-02-06 17:34:04 +01001" Vim filetype plugin file
Bram Moolenaar942db232021-02-13 18:14:48 +01002" Language: Clojure
Bram Moolenaar113cb512021-11-07 20:27:04 +00003" Maintainer: Alex Vear <alex@vear.uk>
Bram Moolenaar942db232021-02-13 18:14:48 +01004" Former Maintainers: Sung Pae <self@sungpae.com>
5" Meikel Brandmeyer <mb@kotka.de>
6" URL: https://github.com/clojure-vim/clojure.vim
7" License: Vim (see :h license)
Bram Moolenaar46eea442022-03-30 10:51:39 +01008" Last Change: 2022-03-24
Doug Kearns93197fd2024-01-14 20:59:02 +01009" 2024 Jan 14 by Vim Project (browsefilter)
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010010
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010011if exists("b:did_ftplugin")
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020012 finish
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010013endif
14let b:did_ftplugin = 1
15
16let s:cpo_save = &cpo
17set cpo&vim
18
Bram Moolenaara6878372014-03-22 21:02:50 +010019let b:undo_ftplugin = 'setlocal iskeyword< define< formatoptions< comments< commentstring< lispwords<'
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020020
Bram Moolenaar113cb512021-11-07 20:27:04 +000021setlocal iskeyword+=?,-,*,!,+,/,=,<,>,.,:,$,%,&,\|
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010022
23" There will be false positives, but this is better than missing the whole set
24" of user-defined def* definitions.
25setlocal define=\\v[(/]def(ault)@!\\S*
26
Bram Moolenaar76f3b1a2014-03-27 22:30:07 +010027" Remove 't' from 'formatoptions' to avoid auto-wrapping code.
28setlocal formatoptions-=t
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010029
30" Lisp comments are routinely nested (e.g. ;;; SECTION HEADING)
31setlocal comments=n:;
32setlocal commentstring=;\ %s
33
Bram Moolenaara6878372014-03-22 21:02:50 +010034" Specially indented symbols from clojure.core and clojure.test.
35"
36" Clojure symbols are indented in the defn style when they:
37"
38" * Define vars and anonymous functions
39" * Create new lexical scopes or scopes with altered environments
40" * Create conditional branches from a predicate function or value
41"
42" The arglists for these functions are generally in the form of [x & body];
43" Functions that accept a flat list of forms do not treat the first argument
44" specially and hence are not indented specially.
45"
Bram Moolenaar76f3b1a2014-03-27 22:30:07 +010046" -*- LISPWORDS -*-
Bram Moolenaar46eea442022-03-30 10:51:39 +010047" Generated from https://github.com/clojure-vim/clojure.vim/blob/fd280e33e84c88e97860930557dba3ff80b1a82d/clj/src/vim_clojure_static/generate.clj
Bram Moolenaar76f3b1a2014-03-27 22:30:07 +010048setlocal 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,doseq,dotimes,doto,extend,extend-protocol,extend-type,fn,for,if,if-let,if-not,if-some,let,letfn,locking,loop,ns,proxy,reify,set-test,testing,when,when-first,when-let,when-not,when-some,while,with-bindings,with-in-str,with-local-vars,with-open,with-precision,with-redefs,with-redefs-fn,with-test
Bram Moolenaara6878372014-03-22 21:02:50 +010049
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010050" Provide insert mode completions for special forms and clojure.core. As
51" 'omnifunc' is set by popular Clojure REPL client plugins, we also set
52" 'completefunc' so that the user has some form of completion available when
53" 'omnifunc' is set and no REPL connection exists.
54for s:setting in ['omnifunc', 'completefunc']
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020055 if exists('&' . s:setting) && empty(eval('&' . s:setting))
56 execute 'setlocal ' . s:setting . '=clojurecomplete#Complete'
57 let b:undo_ftplugin .= ' | setlocal ' . s:setting . '<'
58 endif
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010059endfor
60
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010061" Skip brackets in ignored syntax regions when using the % command
62if exists('loaded_matchit')
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020063 let b:match_words = &matchpairs
64 let b:match_skip = 's:comment\|string\|regex\|character'
65 let b:undo_ftplugin .= ' | unlet! b:match_words b:match_skip'
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010066endif
67
Bram Moolenaar113cb512021-11-07 20:27:04 +000068" Filter files in the browse dialog
69if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
Doug Kearns93197fd2024-01-14 20:59:02 +010070 let b:browsefilter = "Clojure Files\t*.clj;*.cljc;*.cljs;*.cljx\n" .
Bram Moolenaar46eea442022-03-30 10:51:39 +010071 \ "EDN Files\t*.edn\n" .
72 \ "Java Files\t*.java\n"
Doug Kearns93197fd2024-01-14 20:59:02 +010073 if has("win32")
74 let b:browsefilter .= "All Files (*.*)\t*\n"
75 else
76 let b:browsefilter .= "All Files (*)\t*\n"
77 endif
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020078 let b:undo_ftplugin .= ' | unlet! b:browsefilter'
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010079endif
80
81let &cpo = s:cpo_save
82
83unlet! s:cpo_save s:setting s:dir
84
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020085" vim:sts=8:sw=8:ts=8:noet