blob: 2b935a577ec9e7f69ba51b8dbc1c06a69bb38514 [file] [log] [blame]
Bram Moolenaarfa13eef2013-02-06 17:34:04 +01001" Vim filetype plugin file
Bram Moolenaarbaca7f72013-09-22 14:42:24 +02002" Language: Clojure
3" Author: Meikel Brandmeyer <mb@kotka.de>
Bram Moolenaarfa13eef2013-02-06 17:34:04 +01004"
Bram Moolenaarbaca7f72013-09-22 14:42:24 +02005" 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 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 Moolenaarbaca7f72013-09-22 14:42:24 +020018let b:undo_ftplugin = 'setlocal iskeyword< define< formatoptions< comments< commentstring<'
19
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
26" Remove 't' from 'formatoptions' to avoid auto-wrapping code. The '+=croql'
27" is standard ftplugin boilerplate, although it is arguably intrusive.
28setlocal formatoptions-=t formatoptions+=croql
29
30" Lisp comments are routinely nested (e.g. ;;; SECTION HEADING)
31setlocal comments=n:;
32setlocal 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.
38for s:setting in ['omnifunc', 'completefunc']
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020039 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 Moolenaarfa13eef2013-02-06 17:34:04 +010043endfor
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.
49if exists('$CLOJURE_SOURCE_DIRS')
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020050 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 Moolenaarfa13eef2013-02-06 17:34:04 +010058endif
59
60" Skip brackets in ignored syntax regions when using the % command
61if exists('loaded_matchit')
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020062 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 Moolenaarfa13eef2013-02-06 17:34:04 +010065endif
66
67" Win32 can filter files in the browse dialog
68if has("gui_win32") && !exists("b:browsefilter")
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020069 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 Moolenaarfa13eef2013-02-06 17:34:04 +010074endif
75
76let &cpo = s:cpo_save
77
78unlet! s:cpo_save s:setting s:dir
79
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020080" vim:sts=8:sw=8:ts=8:noet