Meikel  Brandmeyer avatar 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)


 	return cmd
+function! vimclojure#ReplDoEnter()
+	execute "normal! a\<CR>x"
+	normal! ==x
+	if getline(".") =~ '^\s*$'
+		startinsert!
+	else
+		startinsert
+	endif
 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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.