Bram Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 1 | " Vim filetype plugin file |
Bram Moolenaar | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 2 | " Language: Clojure |
| 3 | " Author: Meikel Brandmeyer <mb@kotka.de> |
Bram Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 4 | " |
Bram Moolenaar | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 5 | " Maintainer: Sung Pae <self@sungpae.com> |
| 6 | " URL: https://github.com/guns/vim-clojure-static |
| 7 | " License: Same as Vim |
Bram Moolenaar | a687837 | 2014-03-22 21:02:50 +0100 | [diff] [blame] | 8 | " Last Change: 16 February 2014 |
Bram Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 9 | |
Bram Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 10 | if exists("b:did_ftplugin") |
Bram Moolenaar | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 11 | finish |
Bram Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 12 | endif |
| 13 | let b:did_ftplugin = 1 |
| 14 | |
| 15 | let s:cpo_save = &cpo |
| 16 | set cpo&vim |
| 17 | |
Bram Moolenaar | a687837 | 2014-03-22 21:02:50 +0100 | [diff] [blame] | 18 | let b:undo_ftplugin = 'setlocal iskeyword< define< formatoptions< comments< commentstring< lispwords<' |
Bram Moolenaar | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 19 | |
| 20 | setlocal iskeyword+=?,-,*,!,+,/,=,<,>,.,:,$ |
Bram Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 21 | |
| 22 | " There will be false positives, but this is better than missing the whole set |
| 23 | " of user-defined def* definitions. |
| 24 | setlocal define=\\v[(/]def(ault)@!\\S* |
| 25 | |
| 26 | " Remove 't' from 'formatoptions' to avoid auto-wrapping code. The '+=croql' |
| 27 | " is standard ftplugin boilerplate, although it is arguably intrusive. |
| 28 | setlocal formatoptions-=t formatoptions+=croql |
| 29 | |
| 30 | " Lisp comments are routinely nested (e.g. ;;; SECTION HEADING) |
| 31 | setlocal comments=n:; |
| 32 | setlocal commentstring=;\ %s |
| 33 | |
Bram Moolenaar | a687837 | 2014-03-22 21:02:50 +0100 | [diff] [blame] | 34 | " 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 | " |
| 46 | " Generated from https://github.com/guns/vim-clojure-static/blob/vim-release-009/clj/src/vim_clojure_static/generate.clj |
| 47 | 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 |
| 48 | |
Bram Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 49 | " 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. |
| 53 | for s:setting in ['omnifunc', 'completefunc'] |
Bram Moolenaar | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 54 | 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 Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 58 | endfor |
| 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. |
| 64 | if exists('$CLOJURE_SOURCE_DIRS') |
Bram Moolenaar | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 65 | 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 Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 73 | endif |
| 74 | |
| 75 | " Skip brackets in ignored syntax regions when using the % command |
| 76 | if exists('loaded_matchit') |
Bram Moolenaar | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 77 | 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 Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 80 | endif |
| 81 | |
| 82 | " Win32 can filter files in the browse dialog |
| 83 | if has("gui_win32") && !exists("b:browsefilter") |
Bram Moolenaar | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 84 | let b:browsefilter = "Clojure Source Files (*.clj)\t*.clj\n" . |
| 85 | \ "ClojureScript Source Files (*.cljs)\t*.cljs\n" . |
| 86 | \ "Java Source Files (*.java)\t*.java\n" . |
| 87 | \ "All Files (*.*)\t*.*\n" |
| 88 | let b:undo_ftplugin .= ' | unlet! b:browsefilter' |
Bram Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 89 | endif |
| 90 | |
| 91 | let &cpo = s:cpo_save |
| 92 | |
| 93 | unlet! s:cpo_save s:setting s:dir |
| 94 | |
Bram Moolenaar | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 95 | " vim:sts=8:sw=8:ts=8:noet |