Commits

Meikel Brandmeyer committed 34b160c

Change Repl enter hook behaviour

Evaluation is only started when pressing enter at the end of the buffer:
last line, last character. Otherwise a newline is inserted. Hopefully this
allows for more natural editing.

Fixes #70

Comments (0)

Files changed (1)

vim/autoload/vimclojure.vim

 	return cmd
 endfunction
 
+function! vimclojure#ReplDoEnter()
+	execute "normal! a\<CR>x"
+	normal! ==x
+	if getline(".") =~ '^\s*$'
+		startinsert!
+	else
+		startinsert
+	endif
+endfunction
+
 function! vimclojure#Repl.enterHook() dict
+	if line(".") < line("$") || col(".") + 1 < col("$")
+		call vimclojure#ReplDoEnter()
+		return
+	endif
+
 	let cmd = self.getCommand()
 
 	" Special Case: Showed prompt (or user just hit enter).
 	let result = vimclojure#ExecuteNailWithInput("CheckSyntax", cmd,
 				\ "-n", b:vimclojure_namespace)
 	if result.value == 0 && result.stderr == ""
-		execute "normal! GA\<CR>x"
-		normal! ==x
-		startinsert!
+		call vimclojure#ReplDoEnter()
 	elseif result.stderr != ""
 		let buf = g:vimclojure#ResultBuffer.New()
 		call buf.showOutput(result)