blob: 217711f26e943bcbe51c34a4124fb2cd9b2123e1 [file] [log] [blame]
Bram Moolenaarfa13eef2013-02-06 17:34:04 +01001" Vim filetype plugin file
Bram Moolenaar6f1d9a02016-07-24 14:12:38 +02002" Language: Clojure
3" Author: Meikel Brandmeyer <mb@kotka.de>
Bram Moolenaarfa13eef2013-02-06 17:34:04 +01004"
Bram Moolenaar6f1d9a02016-07-24 14:12:38 +02005" Maintainer: Sung Pae <self@sungpae.com>
6" URL: https://github.com/guns/vim-clojure-static
7" License: Same as Vim
8" Last Change: 18 July 2016
Bram Moolenaarfa13eef2013-02-06 17:34:04 +01009
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010010if exists("b:did_ftplugin")
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020011 finish
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010012endif
13let b:did_ftplugin = 1
14
15let s:cpo_save = &cpo
16set cpo&vim
17
Bram Moolenaara6878372014-03-22 21:02:50 +010018let b:undo_ftplugin = 'setlocal iskeyword< define< formatoptions< comments< commentstring< lispwords<'
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020019
20setlocal iskeyword+=?,-,*,!,+,/,=,<,>,.,:,$
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010021
22" There will be false positives, but this is better than missing the whole set
23" of user-defined def* definitions.
24setlocal define=\\v[(/]def(ault)@!\\S*
25
Bram Moolenaar76f3b1a2014-03-27 22:30:07 +010026" Remove 't' from 'formatoptions' to avoid auto-wrapping code.
27setlocal formatoptions-=t
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010028
29" Lisp comments are routinely nested (e.g. ;;; SECTION HEADING)
30setlocal comments=n:;
31setlocal commentstring=;\ %s
32
Bram Moolenaara6878372014-03-22 21:02:50 +010033" 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"
Bram Moolenaar76f3b1a2014-03-27 22:30:07 +010045" -*- LISPWORDS -*-
Bram Moolenaar6f1d9a02016-07-24 14:12:38 +020046" Generated from https://github.com/guns/vim-clojure-static/blob/vim-release-011/clj/src/vim_clojure_static/generate.clj
Bram Moolenaar76f3b1a2014-03-27 22:30:07 +010047setlocal 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 +010048
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010049" Provide insert mode completions for special forms and clojure.core. As
50" 'omnifunc' is set by popular Clojure REPL client plugins, we also set
51" 'completefunc' so that the user has some form of completion available when
52" 'omnifunc' is set and no REPL connection exists.
53for s:setting in ['omnifunc', 'completefunc']
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020054 if exists('&' . s:setting) && empty(eval('&' . s:setting))
55 execute 'setlocal ' . s:setting . '=clojurecomplete#Complete'
56 let b:undo_ftplugin .= ' | setlocal ' . s:setting . '<'
57 endif
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010058endfor
59
60" Take all directories of the CLOJURE_SOURCE_DIRS environment variable
61" and add them to the path option.
62"
63" This is a legacy option for VimClojure users.
64if exists('$CLOJURE_SOURCE_DIRS')
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020065 for s:dir in split($CLOJURE_SOURCE_DIRS, (has("win32") || has("win64")) ? ';' : ':')
66 let s:dir = fnameescape(s:dir)
67 " Whitespace escaping for Windows
68 let s:dir = substitute(s:dir, '\', '\\\\', 'g')
69 let s:dir = substitute(s:dir, '\ ', '\\ ', 'g')
70 execute "setlocal path+=" . s:dir . "/**"
71 endfor
72 let b:undo_ftplugin .= ' | setlocal path<'
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010073endif
74
75" Skip brackets in ignored syntax regions when using the % command
76if exists('loaded_matchit')
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020077 let b:match_words = &matchpairs
78 let b:match_skip = 's:comment\|string\|regex\|character'
79 let b:undo_ftplugin .= ' | unlet! b:match_words b:match_skip'
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010080endif
81
82" Win32 can filter files in the browse dialog
83if has("gui_win32") && !exists("b:browsefilter")
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020084 let b:browsefilter = "Clojure Source Files (*.clj)\t*.clj\n" .
Bram Moolenaar6f1d9a02016-07-24 14:12:38 +020085 \ "ClojureScript Source Files (*.cljs)\t*.cljs\n" .
86 \ "Java Source Files (*.java)\t*.java\n" .
87 \ "All Files (*.*)\t*.*\n"
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020088 let b:undo_ftplugin .= ' | unlet! b:browsefilter'
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010089endif
90
91let &cpo = s:cpo_save
92
93unlet! s:cpo_save s:setting s:dir
94
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020095" vim:sts=8:sw=8:ts=8:noet