xref: /vim-8.2.3635/runtime/ftplugin/clojure.vim (revision 76f3b1ad)
1fa13eef3SBram Moolenaar" Vim filetype plugin file
2fa13eef3SBram Moolenaar" Language:	Clojure
3fa13eef3SBram Moolenaar" Author:	Meikel Brandmeyer <[email protected]>
4fa13eef3SBram Moolenaar"
5fa13eef3SBram Moolenaar" Maintainer:	Sung Pae <[email protected]>
6fa13eef3SBram Moolenaar" URL:		https://github.com/guns/vim-clojure-static
7fa13eef3SBram Moolenaar" License:	Same as Vim
8*76f3b1adSBram Moolenaar" Last Change:	27 March 2014
9fa13eef3SBram Moolenaar
10fa13eef3SBram Moolenaarif exists("b:did_ftplugin")
11fa13eef3SBram Moolenaar	finish
12fa13eef3SBram Moolenaarendif
13fa13eef3SBram Moolenaarlet b:did_ftplugin = 1
14fa13eef3SBram Moolenaar
15fa13eef3SBram Moolenaarlet s:cpo_save = &cpo
16fa13eef3SBram Moolenaarset cpo&vim
17fa13eef3SBram Moolenaar
18a6878375SBram Moolenaarlet b:undo_ftplugin = 'setlocal iskeyword< define< formatoptions< comments< commentstring< lispwords<'
19baca7f70SBram Moolenaar
20baca7f70SBram Moolenaarsetlocal iskeyword+=?,-,*,!,+,/,=,<,>,.,:,$
21fa13eef3SBram Moolenaar
22fa13eef3SBram Moolenaar" There will be false positives, but this is better than missing the whole set
23fa13eef3SBram Moolenaar" of user-defined def* definitions.
24fa13eef3SBram Moolenaarsetlocal define=\\v[(/]def(ault)@!\\S*
25fa13eef3SBram Moolenaar
26*76f3b1adSBram Moolenaar" Remove 't' from 'formatoptions' to avoid auto-wrapping code.
27*76f3b1adSBram Moolenaarsetlocal formatoptions-=t
28fa13eef3SBram Moolenaar
29fa13eef3SBram Moolenaar" Lisp comments are routinely nested (e.g. ;;; SECTION HEADING)
30fa13eef3SBram Moolenaarsetlocal comments=n:;
31fa13eef3SBram Moolenaarsetlocal commentstring=;\ %s
32fa13eef3SBram Moolenaar
33a6878375SBram Moolenaar" Specially indented symbols from clojure.core and clojure.test.
34a6878375SBram Moolenaar"
35a6878375SBram Moolenaar" Clojure symbols are indented in the defn style when they:
36a6878375SBram Moolenaar"
37a6878375SBram Moolenaar"   * Define vars and anonymous functions
38a6878375SBram Moolenaar"   * Create new lexical scopes or scopes with altered environments
39a6878375SBram Moolenaar"   * Create conditional branches from a predicate function or value
40a6878375SBram Moolenaar"
41a6878375SBram Moolenaar" The arglists for these functions are generally in the form of [x & body];
42a6878375SBram Moolenaar" Functions that accept a flat list of forms do not treat the first argument
43a6878375SBram Moolenaar" specially and hence are not indented specially.
44a6878375SBram Moolenaar"
45*76f3b1adSBram Moolenaar" -*- LISPWORDS -*-
46*76f3b1adSBram Moolenaar" Generated from https://github.com/guns/vim-clojure-static/blob/vim-release-010/clj/src/vim_clojure_static/generate.clj
47*76f3b1adSBram Moolenaarsetlocal 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
48a6878375SBram Moolenaar
49fa13eef3SBram Moolenaar" Provide insert mode completions for special forms and clojure.core. As
50fa13eef3SBram Moolenaar" 'omnifunc' is set by popular Clojure REPL client plugins, we also set
51fa13eef3SBram Moolenaar" 'completefunc' so that the user has some form of completion available when
52fa13eef3SBram Moolenaar" 'omnifunc' is set and no REPL connection exists.
53fa13eef3SBram Moolenaarfor s:setting in ['omnifunc', 'completefunc']
54fa13eef3SBram Moolenaar	if exists('&' . s:setting) && empty(eval('&' . s:setting))
55fa13eef3SBram Moolenaar		execute 'setlocal ' . s:setting . '=clojurecomplete#Complete'
56fa13eef3SBram Moolenaar		let b:undo_ftplugin .= ' | setlocal ' . s:setting . '<'
57fa13eef3SBram Moolenaar	endif
58fa13eef3SBram Moolenaarendfor
59fa13eef3SBram Moolenaar
60fa13eef3SBram Moolenaar" Take all directories of the CLOJURE_SOURCE_DIRS environment variable
61fa13eef3SBram Moolenaar" and add them to the path option.
62fa13eef3SBram Moolenaar"
63fa13eef3SBram Moolenaar" This is a legacy option for VimClojure users.
64fa13eef3SBram Moolenaarif exists('$CLOJURE_SOURCE_DIRS')
65fa13eef3SBram Moolenaar	for s:dir in split($CLOJURE_SOURCE_DIRS, (has("win32") || has("win64")) ? ';' : ':')
66fa13eef3SBram Moolenaar		let s:dir = fnameescape(s:dir)
67fa13eef3SBram Moolenaar		" Whitespace escaping for Windows
68fa13eef3SBram Moolenaar		let s:dir = substitute(s:dir, '\', '\\\\', 'g')
69fa13eef3SBram Moolenaar		let s:dir = substitute(s:dir, '\ ', '\\ ', 'g')
70fa13eef3SBram Moolenaar		execute "setlocal path+=" . s:dir . "/**"
71fa13eef3SBram Moolenaar	endfor
72fa13eef3SBram Moolenaar	let b:undo_ftplugin .= ' | setlocal path<'
73fa13eef3SBram Moolenaarendif
74fa13eef3SBram Moolenaar
75fa13eef3SBram Moolenaar" Skip brackets in ignored syntax regions when using the % command
76fa13eef3SBram Moolenaarif exists('loaded_matchit')
77fa13eef3SBram Moolenaar	let b:match_words = &matchpairs
78fa13eef3SBram Moolenaar	let b:match_skip = 's:comment\|string\|regex\|character'
79fa13eef3SBram Moolenaar	let b:undo_ftplugin .= ' | unlet! b:match_words b:match_skip'
80fa13eef3SBram Moolenaarendif
81fa13eef3SBram Moolenaar
82fa13eef3SBram Moolenaar" Win32 can filter files in the browse dialog
83fa13eef3SBram Moolenaarif has("gui_win32") && !exists("b:browsefilter")
84fa13eef3SBram Moolenaar	let b:browsefilter = "Clojure Source Files (*.clj)\t*.clj\n" .
85fa13eef3SBram Moolenaar			   \ "ClojureScript Source Files (*.cljs)\t*.cljs\n" .
86fa13eef3SBram Moolenaar			   \ "Java Source Files (*.java)\t*.java\n" .
87fa13eef3SBram Moolenaar			   \ "All Files (*.*)\t*.*\n"
88fa13eef3SBram Moolenaar	let b:undo_ftplugin .= ' | unlet! b:browsefilter'
89fa13eef3SBram Moolenaarendif
90fa13eef3SBram Moolenaar
91fa13eef3SBram Moolenaarlet &cpo = s:cpo_save
92fa13eef3SBram Moolenaar
93fa13eef3SBram Moolenaarunlet! s:cpo_save s:setting s:dir
94fa13eef3SBram Moolenaar
95baca7f70SBram Moolenaar" vim:sts=8:sw=8:ts=8:noet
96