clojure.txt (11826B)
1 *vimclojure.txt* *clojure.vim* 2 3 VimClojure - A Clojure Environment 4 ================================== 5 6 Introduction 7 ------------ 8 9 VimClojure is a filetype plugin and development environment for Clojure. It 10 provides indenting, syntax highlighting and – if configured – interactive 11 features like omni completion, documentation lookup and a Repl running in a 12 Vim buffer. 13 14 Nailgun Server *clj-nailgun-server* 15 -------------- 16 17 To use the interactive part you have to start the nailgun server via the jar 18 file. Make sure, that clojure and clojure-contrib are in your classpath and 19 start the com.martiansoftware.nailgun.NGServer class. Example invocation: 20 > 21 java -cp clojure.jar:clojure-contrib.jar:vimclojure.jar com.martiansoftware.nailgun.NGServer 127.0.0.1 22 < 23 This may look different depending on your system. 24 25 You can stop the server by invoking the nailgun client with the ng-stop 26 argument. 27 > 28 ng ng-stop 29 < 30 Set the clj_want_gorilla variable in your vimrc. 31 > 32 let g:clj_want_gorilla = 1 33 < 34 Note: Should there be an error when executing an interactive command 35 and the error message goes away to quickly, you can use |:messages| to 36 recall the message and read it conveniently without time pressure. 37 38 Syntax Highlighting *ft-clj-syntax* 39 ------------------- 40 41 The clojure syntax highlighting provides several options: 42 > 43 g:clj_highlight_builtins 44 If it exists and is nonzero, then Clojure's builtin functions 45 are highlighted. This useful to distuingish macros and special 46 forms from functions. 47 48 g:clj_highlight_contrib 49 If it exists and is nonzero, then Clojure-Contrib's functions 50 are highlighted. (Currently incomplete) 51 52 g:clj_paren_rainbow 53 If it exists and is nonzero, then differing levels of 54 parenthesisation will receive different highlighting. 55 < 56 The g:clj_paren_rainbow option provides 10 levels of individual colorisation 57 for the parentheses. Because of the quantity of colorisation levels, unlike 58 non-rainbow highlighting, the rainbow mode specifies its highlighting using 59 ctermfg and guifg, thereby bypassing the usual colorscheme control using 60 standard highlighting groups. The actual highlighting used depends on the 61 dark/bright setting (see |'bg'|). 62 63 Keybindings 64 ----------- 65 66 Note: <LocalLeader> is a Vim feature. More information can be found 67 under the |maplocalleader| help topic. 68 69 You can redefine any key mapping using some autocommand in your .vimrc file. 70 All mappings use so-called Plugs. Simply prepend <Plug>Clojure to the given 71 Plug name and your setting will override the default mapping. 72 > 73 aucmd BufRead,BufNewFile *.clj nmap xyz <Plug>ClojureEvalToplevel 74 < 75 76 <LocalLeader>et *et* *EvalToplevel* 77 Send off the toplevel sexpression currently 78 containing the cursor to the Clojure server. 79 80 <LocalLeader>ef *ef* *EvalFile* 81 Send off the current file to the Clojure Server. 82 83 <LocalLeader>eb *eb* *EvalBlock* 84 Send off the the mark visual block to the 85 Clojure server. Obviously this mapping is only 86 active in visual mode. 87 Note: This does not check for structure. 88 89 <LocalLeader>el *el* *EvalLine* 90 Send off the current line to the Clojure Server. 91 Note: This does not check for structure. 92 93 <LocalLeader>ep *ep* *EvalParagraph* 94 Send off the current paragraph to the Clojure Server. 95 Note: This does not check for structure. 96 97 <LocalLeader>rf *rf* *RequireFile* 98 Require the namespace of the current file with 99 the :reload flag. Note: For this to work with 100 a remote Clojure server, the files have to put in 101 place before issueing the command, eg. via scp 102 or NFS. 103 104 <LocalLeader>rF *rF* *RequireFileAll* 105 Require the namespace of the current file with 106 the :reload-all flag. Note: For this to work with 107 a remote Clojure server, the files have to put in 108 place before issueing the command, eg. via scp 109 or NFS. 110 111 <LocalLeader>me *me* *MacroExpand* 112 Expand the innermost sexpression currently 113 containing the cursor using macroexpand. 114 115 <LocalLeader>m1 *m1* *MacroExpand1* 116 Same as MacroExpand, but use macroexpand-1. 117 118 119 <LocalLeader>lw *lw* *DocLookupWord* 120 Lookup up the word under the cursor and print 121 the documentation for it via (doc). 122 123 <LocalLeader>li *li* *DocLookupInteractive* 124 Lookup the documentation of an arbitrary word. 125 The user is prompted for input. 126 127 <LocalLeader>fd *fd* *FindDoc* 128 Find a the documentation for a given pattern 129 with (find-doc). The user is prompted for input. 130 131 <LocalLeader>jw *jw* *JavadocLookupWord* 132 Open the javadoc for the word under the cursor 133 in an external browser. 134 135 <LocalLeader>ji *ji* *JavadocLookupInteractive* 136 Open the javadoc for an arbitrary word in an 137 external browser. The user is prompted for input. 138 139 <LocalLeader>sw *sw* *SourceLookupWord* 140 Show a read-only view of the source the word under 141 the cursor. For this to work, the source must be 142 available in the Classpath or as a file (depending 143 on how the source was loaded). 144 145 <LocalLeader>si *si* *SourceLookupInteractive* 146 Show a read-only view of the source of an arbitrary 147 word. For this to work, the source must be available 148 in the Classpath or as a file (depending on how the 149 source was loaded). 150 151 <LocalLeader>gw *gw* *GotoSourceWord* 152 Goto the source of the word under the cursor. For this 153 to work, the source must be available in a directory 154 of the |'path'| option. The directories in the 155 CLOJURE_SOURCE_DIRS environment variable will be added 156 to the |'path'| setting. 157 158 <LocalLeader>gi *gi* *GotoSourceInteractive* 159 Goto the source of an arbitrary word. For this to work, 160 the source must be available in a directory of the 161 |'path'| option. The directories in the 162 CLOJURE_SOURCE_DIRS environment variable will be added 163 to the |'path'| setting. 164 165 <LocalLeader>mw *mw* *MetaLookupWord* 166 Lookup the meta data of the word under the cursor. 167 168 <LocalLeader>mi *mi* *MetaLookupInteractive* 169 Lookup the meta data of an arbitrary word. The 170 user is prompted for input. 171 172 <LocalLeader>sr *sr* *StartRepl* 173 Start a new Vim Repl in a fresh buffer. There 174 might be multiple Repls at the same time. 175 176 Vim Repl 177 -------- 178 179 Start a Repl via the |sr| shortcut. At the prompt just type expressions. 180 Hitting enter will determine, whether the expression is complete and 181 will send it to the Clojure instance. In case the expression is incomplete, 182 eg. after "(defn foo" will result in a newline for multiline expressions. 183 184 Previously sent expressions may be recalled via <C-Up> and <C-Down>. 185 Note: sending multiple expressions will save them in the same history 186 entry. So playing back with <C-Up> will again send all of the contained 187 expressions. 188 189 The Plugs are: 190 - <Plug>ClojureReplEnterHook for the enter key 191 - <Plug>ClojureReplUpHistory for going backwards in history (<C-Up>) 192 - <Plug>ClojureReplDownHistory for going forwards in history (<C-Down>) 193 194 The following convenience commands are provided: 195 196 - ,close - close the Repl and free the Repl resources in the server process 197 - ,st - print a stack trace of *e as with clojure.contrib.stacktrace 198 - ,ct - print a cause trace of *e as with clojure.contrib.stacktrace 199 200 Pretty Printing 201 --------------- 202 203 In case Tom Faulhaber's cl-format package is available in the Classpath 204 it will be used for pretty printing, eg. of macroexpansions. The Repl 205 can be told to use pretty printing via a global Var. 206 > 207 (set! de.kotka.vimclojure.repl/*print-pretty* true) 208 < 209 210 Omni Completion 211 --------------- 212 213 VimClojure supports omni completion for Clojure code. Hitting <C-X><C-O> in 214 insert mode will try to provide completions for the item in front of the 215 cursor. 216 217 The completion tries to be somewhat intelligent in what it completes. 218 219 - a word starting with an upper case letter will be completed to an 220 imported class. 221 Str<C-x><C-o> => String, StringBuilder, ... 222 223 - a word containing dots will be completed to a namespace. 224 c.c<C-x><C-o> => clojure.core, clojure.contrib.repl-utils, ... 225 226 - everything else will be completed to a Var, an alias or namespace. 227 228 - a word containing a slash will be handled differently 229 - if the word starts with an upper case letter, will complete 230 static fields of the given class 231 String/va<C-x><C-o> => String/valueOf 232 233 - otherwise it is treated as a namespace or alias 234 clojure.core/re<C-x><C-o> => clojure.core/read, ... 235 236 The completion uses certain characters to split the matching. This are 237 hyphens and (for namespaces) dots. So r-s<C-x><C-o> matches read-string. 238 239 Note: Completion of symbols and keywords is also provided via the <C-N> 240 functionality of Vim. 241 242 License 243 ------- 244 245 Copyright (c) 2008,2009 Meikel Brandmeyer, Frankfurt am Main 246 All rights reserved. 247 248 Permission is hereby granted, free of charge, to any person obtaining a copy 249 of this software and associated documentation files (the "Software"), to deal 250 in the Software without restriction, including without limitation the rights 251 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 252 copies of the Software, and to permit persons to whom the Software is 253 furnished to do so, subject to the following conditions: 254 255 The above copyright notice and this permission notice shall be included in 256 all copies or substantial portions of the Software. 257 258 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 259 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 260 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 261 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 262 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 263 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 264 THE SOFTWARE. 265 ============================================================================== 266 .. vim: set ft=help norl ts=8 tw=78 et :