Skip to content

Commit

Permalink
Version 2.1.2
Browse files Browse the repository at this point in the history
This release is compatible with Clojure 1.0 and
Clojure-Contrib 919 (in old SVN terms). Other
pre-GTIC contrib versions from Github should also
work. For Clojure(-Contrib) head consider using the
bleeding-edge branch from the repository.

The Ivy configuration will fetch an known-to-work
Clojure(-Contrib) version. For manual compilation,
you have to care for that yourself. A compiled jar
is already included in the distribution in the build
subdirectory.

Changes since v2.1.1:

* Fixed a regression of qualified keywords highlighting
* Fixed a infinite loop if there is no prompt in the Repl buffer
* Made compilation of ng client a bit more comfortable
* Added library configuration for OpenSolaris (thanks to Richard Newman)
* Changed normal invokations to ignore keymappings (reported by James Reeves)
* Fixed typo in lispwords: defmethod -> defmulti
* Added letfn to lispwords
* Added c.c.def/defnk to lispwords
* Added #_ and #! as comment indicators to syntax highlighting
  (currently only the #_ is marked as comment, the following form
  is still highlighted normally.)
* Fixed annoying o/O delay bug
* Simplified plugin installation
  • Loading branch information
Meikel Brandmeyer authored and vim-scripts committed Nov 14, 2010
1 parent 1ac6526 commit 9afcf73
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 70 deletions.
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@
# Marty Lamb

CC=gcc
WIN32_CC=/usr/local/mingw32/bin/mingw32-gcc
CFLAGS=-Wall -pedantic -s -O3

# Special library requirements
# Default:
LIBS=

# OpenSolaris 2009.06
#LIBS=-lsocket -lnsl

# Windows
#LIBS=-lwsock32

ng: ngclient/ng.c
@echo "Building ng client. To build a Windows binary, type 'make ng.exe'"
${CC} ${CFLAGS} -o ng ngclient/ng.c
${CC} ${CFLAGS} ${LIBS} -o ng ngclient/ng.c

ng.exe: ngclient/ng.c
# any idea why the command line is so sensitive to the order of
# the arguments? If CFLAGS is at the beginning, it won't link.
${WIN32_CC} -o ng.exe ngclient/ng.c -lwsock32 -O3 ${CFLAGS}

clean:
@echo "If you have a Windows binary, 'make clean' won't delete it."
@echo "You must remove this manually. Most users won't have MinGW"
Expand Down
46 changes: 31 additions & 15 deletions autoload/vimclojure.vim
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function! vimclojure#ExtractSexpr(toplevel)
function closure.f() dict
if searchpairpos('(', '', ')', 'bW' . self.flag,
\ 'vimclojure#SynIdName() !~ "clojureParen\\d"') != [0, 0]
return vimclojure#Yank('l', 'normal "ly%')
return vimclojure#Yank('l', 'normal! "ly%')
end
return ""
endfunction
Expand Down Expand Up @@ -420,7 +420,7 @@ function! vimclojure#EvalParagraph()
let closure = {}

function! closure.f() dict
normal }
normal! }
return line(".")
endfunction

Expand Down Expand Up @@ -474,7 +474,7 @@ function! vimclojure#Repl.New() dict

setfiletype clojure

normal G
normal! G
startinsert!
endfunction

Expand All @@ -498,26 +498,38 @@ function! vimclojure#Repl.doReplCommand(cmd) dict
\ "-i", self._id)
call self.showText(result)
call self.showText(self._prompt . " ")
normal G
normal! G
startinsert!
elseif a:cmd == ",ct"
let result = vimclojure#ExecuteNailWithInput("Repl",
\ "(clojure.contrib.stacktrace/print-cause-trace *e)", "-r",
\ "-i", self._id)
call self.showText(result)
call self.showText(self._prompt . " ")
normal G
normal! G
startinsert!
endif
endfunction

function! vimclojure#Repl.showPrompt() dict
call self.showText(self._prompt . " ")
normal! G
startinsert!
endfunction

function! vimclojure#Repl.getCommand() dict
let ln = line("$")
while getline(ln) !~ "^" . self._prompt
while getline(ln) !~ "^" . self._prompt && ln > 0
let ln = ln - 1
endwhile

" Special Case: User deleted Prompt by accident. Insert a new one.
if ln == 0
call self.showPrompt()
return ""
endif

let cmd = vimclojure#Yank("l", ln . "," . line("$") . "yank l")
let cmd = substitute(cmd, "^" . self._prompt . "\\s*", "", "")
Expand All @@ -528,6 +540,11 @@ endfunction
function! vimclojure#Repl.enterHook() dict
let cmd = self.getCommand()

" Special Case: Showed prompt (or user just hit enter).
if cmd == ""
return
endif

if self.isReplCommand(cmd)
call self.doReplCommand(cmd)
return
Expand All @@ -536,18 +553,17 @@ function! vimclojure#Repl.enterHook() dict
let result = vimclojure#ExecuteNailWithInput("CheckSyntax", cmd)
if result == "false"
execute "normal! GA\<CR>x"
normal ==x
normal! ==x
startinsert!
else
let result = vimclojure#ExecuteNailWithInput("Repl", cmd,
\ "-r", "-i", self._id)
call self.showText(result)

let self._historyDepth = 0
let self._history = [cmd] + self._history
call self.showText(self._prompt . " ")
normal G
call self.showPrompt()
endif
startinsert!
endfunction

function! vimclojure#Repl.upHistory() dict
Expand All @@ -563,7 +579,7 @@ function! vimclojure#Repl.upHistory() dict
call self.showText(self._prompt . " " . cmd)
endif

normal G$
normal! G$
endfunction

function! vimclojure#Repl.downHistory() dict
Expand All @@ -582,17 +598,17 @@ function! vimclojure#Repl.downHistory() dict
call self.showText(self._prompt . " ")
endif

normal G$
normal! G$
endfunction

function! vimclojure#Repl.deleteLast() dict
normal G
normal! G

while getline("$") !~ self._prompt
normal dd
normal! dd
endwhile

normal dd
normal! dd
endfunction

" Highlighting
Expand Down
38 changes: 37 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,44 @@
<target name="clean-all" depends="clean-lib,clean"
description="--> clean all project files"/>

<target name="install" if="vimdir"
<target name="install"
description="--> install the vim plugin">
<condition property="do.custom.install">
<isset property="vimdir"/>
</condition>
<condition property="do.windows.install">
<and>
<not><isset property="vimdir"/></not>
<os family="windows"/>
</and>
</condition>
<condition property="do.unix.install">
<and>
<not><isset property="vimdir"/></not>
<os family="unix"/>
</and>
</condition>
<antcall target="do-install"/>
</target>

<target name="do-install"
depends="do-windows-install,do-unix-install,do-custom-install"/>

<target name="do-windows-install" if="do.windows.install">
<property name="vimdir" location="${user.home}/vimfiles"/>
<antcall target="real-do-install"/>
</target>

<target name="do-unix-install" if="do.unix.install">
<property name="vimdir" location="${user.home}/.vim"/>
<antcall target="real-do-install"/>
</target>

<target name="do-custom-install" if="do.custom.install">
<antcall target="real-do-install"/>
</target>

<target name="real-do-install">
<mkdir dir="${vimdir}/autoload"/>
<mkdir dir="${vimdir}/doc"/>
<mkdir dir="${vimdir}/indent"/>
Expand Down
Binary file added build/vimclojure.jar
Binary file not shown.
8 changes: 7 additions & 1 deletion doc/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ similar to:
clojure.jar=/path/to/clojure.jar
clojure-contrib.jar=/path/to/clojure-contrib.jar
nailgun-client=ng
vimdir=/path/to/install/vim/plugin
vimdir=/custom/installation/path/for/vimplugin
––8<––––8<––––8<––

Once you have created this file, simply run ant. This should give a
Expand All @@ -60,6 +60,9 @@ it only in case you are sure, that you can rebuild it. You may see an error
when building the nailgun-client. That's ok.

Running „ant install“ will install the vim plugin into the named directory.
If you omit the vimdir line in the local.properties file the vim plugin
will be installed in the user's runtime directory – <home>/.vim on Unic/Mac,
<home>\vimfiles on Windows.

To run the Nailgun server you need the clojure.jar, clojure-contrib.jar and
vimclojure.jar in your Classpath:
Expand All @@ -82,6 +85,9 @@ let vimclojure#NailgunClient = "/path/to/your/ng"
Please refer to the online documentation in the doc folder for further
information on how to use VimClojure, its features and its caveats.

Note: You might need to check the Makefile for special lib requirments
to compile the nailgun client, eg. OpenSolaris.

Using Ivy
=========

Expand Down
2 changes: 1 addition & 1 deletion ftplugin/clojure.vim
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function! ClojureGetFoldingLevel(lineno)
function closure.f() dict
execute self.lineno

if vimclojure#SynIdName() =~ 'clojureParen\d' && vimclojure#Yank('l', 'normal "lyl') == '('
if vimclojure#SynIdName() =~ 'clojureParen\d' && vimclojure#Yank('l', 'normal! "lyl') == '('
return 1
endif

Expand Down
69 changes: 33 additions & 36 deletions indent/clojure.vim
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,11 @@ setlocal indentkeys=!,o,O
if exists("*searchpairpos")

function! s:MatchPairs(open, close, stopat)
let closure = { 'open': a:open, 'close': a:close, 'stopat': a:stopat }

function closure.f() dict
" Stop only on vector and map [ resp. {. Ignore the ones in strings and
" comments.
return searchpairpos(self.open, '', self.close, 'bW',
" Stop only on vector and map [ resp. {. Ignore the ones in strings and
" comments.
return searchpairpos(a:open, '', a:close, 'bWn',
\ 'vimclojure#SynIdName() !~ "clojureParen\\d"',
\ self.stopat)
endfunction

return vimclojure#WithSavedPosition(closure)
\ a:stopat)
endfunction

function! VimClojureCheckForStringWorker()
Expand All @@ -61,7 +55,7 @@ function! VimClojureCheckForStringWorker()
if vimclojure#SynIdName() != "clojureString"
return -1
endif
if vimclojure#Yank('l', 'normal "lyl') != '\\'
if vimclojure#Yank('l', 'normal! "lyl') != '\\'
return -1
endif
call cursor(0, col("$") - 1)
Expand All @@ -80,7 +74,19 @@ function! VimClojureCheckForString()
return vimclojure#WithSavedPosition({'f': function("VimClojureCheckForStringWorker")})
endfunction

function! GetClojureIndentWorker()
function! GetClojureIndent()
" Get rid of special case.
if line(".") == 1
return 0
endif

" We have to apply some heuristics here to figure out, whether to use
" normal lisp indenting or not.
let i = VimClojureCheckForString()
if i > -1
return i
endif

call cursor(0, 1)

" Find the next enclosing [ or {. We can limit the second search
Expand Down Expand Up @@ -129,10 +135,13 @@ function! GetClojureIndentWorker()
endif

" In case after the paren is a whitespace, we search for the next word.
normal l
if vimclojure#Yank('l', 'normal "lyl') == ' '
normal w
normal! l
let reg = getreg("l")
normal! "lyl
if getreg("l") == ' '
normal! w
endif
call setreg("l", reg)

" If we moved to another line, there is no word after the (. We
" use the ( position for indent.
Expand All @@ -142,7 +151,10 @@ function! GetClojureIndentWorker()

" We still have to check, whether the keyword starts with a (, [ or {.
" In that case we use the ( position for indent.
let w = vimclojure#Yank('l', 'normal "lye')
let reg = getreg("l")
normal! "lye
let w = getreg("l")
call setreg("l", reg)
if stridx('([{', w[0]) > 0
return paren[1]
endif
Expand All @@ -151,31 +163,15 @@ function! GetClojureIndentWorker()
return paren[1] + &shiftwidth - 1
endif

normal w
normal! w
if paren[0] < line(".")
return paren[1] + &shiftwidth - 1
endif

normal ge
normal! ge
return col(".") + 1
endfunction

function! GetClojureIndent()
" Get rid of special case.
if line(".") == 1
return 0
endif

" We have to apply some heuristics here to figure out, whether to use
" normal lisp indenting or not.
let i = VimClojureCheckForString()
if i > -1
return i
endif

return vimclojure#WithSavedPosition({'f': function("GetClojureIndentWorker")})
endfunction

setlocal indentexpr=GetClojureIndent()

else
Expand All @@ -189,8 +185,9 @@ else
endif

" Defintions:
setlocal lispwords=def,def-,defn,defn-,defmacro,defmacro-,defmethod,defmethod
setlocal lispwords+=defonce,defvar,defvar-,defunbound,let,fn,binding,proxy
setlocal lispwords=def,def-,defn,defn-,defmacro,defmacro-,defmethod,defmulti
setlocal lispwords+=defonce,defvar,defvar-,defunbound,let,fn,letfn,binding,proxy
setlocal lispwords+=defnk

" Conditionals and Loops:
setlocal lispwords+=if,if-not,if-let,when,when-not,when-let,when-first
Expand Down
Loading

0 comments on commit 9afcf73

Please sign in to comment.