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 |
| 8 | " Last Change: 08 September 2013 |
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 | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 18 | let b:undo_ftplugin = 'setlocal iskeyword< define< formatoptions< comments< commentstring<' |
| 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 | |
| 34 | " Provide insert mode completions for special forms and clojure.core. As |
| 35 | " 'omnifunc' is set by popular Clojure REPL client plugins, we also set |
| 36 | " 'completefunc' so that the user has some form of completion available when |
| 37 | " 'omnifunc' is set and no REPL connection exists. |
| 38 | for s:setting in ['omnifunc', 'completefunc'] |
Bram Moolenaar | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 39 | if exists('&' . s:setting) && empty(eval('&' . s:setting)) |
| 40 | execute 'setlocal ' . s:setting . '=clojurecomplete#Complete' |
| 41 | let b:undo_ftplugin .= ' | setlocal ' . s:setting . '<' |
| 42 | endif |
Bram Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 43 | endfor |
| 44 | |
| 45 | " Take all directories of the CLOJURE_SOURCE_DIRS environment variable |
| 46 | " and add them to the path option. |
| 47 | " |
| 48 | " This is a legacy option for VimClojure users. |
| 49 | if exists('$CLOJURE_SOURCE_DIRS') |
Bram Moolenaar | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 50 | for s:dir in split($CLOJURE_SOURCE_DIRS, (has("win32") || has("win64")) ? ';' : ':') |
| 51 | let s:dir = fnameescape(s:dir) |
| 52 | " Whitespace escaping for Windows |
| 53 | let s:dir = substitute(s:dir, '\', '\\\\', 'g') |
| 54 | let s:dir = substitute(s:dir, '\ ', '\\ ', 'g') |
| 55 | execute "setlocal path+=" . s:dir . "/**" |
| 56 | endfor |
| 57 | let b:undo_ftplugin .= ' | setlocal path<' |
Bram Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 58 | endif |
| 59 | |
| 60 | " Skip brackets in ignored syntax regions when using the % command |
| 61 | if exists('loaded_matchit') |
Bram Moolenaar | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 62 | let b:match_words = &matchpairs |
| 63 | let b:match_skip = 's:comment\|string\|regex\|character' |
| 64 | let b:undo_ftplugin .= ' | unlet! b:match_words b:match_skip' |
Bram Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 65 | endif |
| 66 | |
| 67 | " Win32 can filter files in the browse dialog |
| 68 | if has("gui_win32") && !exists("b:browsefilter") |
Bram Moolenaar | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 69 | let b:browsefilter = "Clojure Source Files (*.clj)\t*.clj\n" . |
| 70 | \ "ClojureScript Source Files (*.cljs)\t*.cljs\n" . |
| 71 | \ "Java Source Files (*.java)\t*.java\n" . |
| 72 | \ "All Files (*.*)\t*.*\n" |
| 73 | let b:undo_ftplugin .= ' | unlet! b:browsefilter' |
Bram Moolenaar | fa13eef | 2013-02-06 17:34:04 +0100 | [diff] [blame] | 74 | endif |
| 75 | |
| 76 | let &cpo = s:cpo_save |
| 77 | |
| 78 | unlet! s:cpo_save s:setting s:dir |
| 79 | |
Bram Moolenaar | baca7f7 | 2013-09-22 14:42:24 +0200 | [diff] [blame] | 80 | " vim:sts=8:sw=8:ts=8:noet |