Commits

Meikel Brandmeyer committed 10f15f1

Allow batch error handling

Sometimes poping up a new buffer is not really an option. eg. when
some script. So still allow for the old behaviour while the new
nice one is the default.

Fixes #48

Comments (0)

Files changed (2)

autoload/vimclojure.vim

 	endif
 endif
 
+if !exists("g:vimclojure#UseErrorBuffer")
+	let vimclojure#UseErrorBuffer = 1
+endif
+
+function! vimclojure#ReportError(msg)
+	if g:vimclojure#UseErrorBuffer
+		let buf = g:vimclojure#ResultBuffer.New()
+		call buf.showText(a:msg)
+	else
+		echoerr substitute(a:msg, '\n\(\t\?\)', ' ', 'g')
+	endif
+endfunction
+
 function! vimclojure#SynIdName()
 	return synIDattr(synID(line("."), col("."), 0), "name")
 endfunction
 	try
 		return call(a:f, a:000)
 	catch /.*/
-		let buf = g:vimclojure#ResultBuffer.New()
-		call buf.showText(v:exception)
+		call vimclojure#ReportError(v:exception)
 	endtry
 endfunction
 
 					endif
 					let b:vimclojure_namespace = namespace.value
 				catch /.*/
-					let buf = g:vimclojure#ResultBuffer.New()
-					call buf.showText("Could not determine the Namespace of the file.\n\n"
+					call vimclojure#ReportError(
+								\ "Could not determine the Namespace of the file.\n\n"
 								\ . "This might have different reasons. Please check, that the ng server\n"
 								\ . "is running with the correct classpath and that the file does not contain\n"
 								\ . "syntax errors. The interactive features will not be enabled, ie. the\n"
         let vimclojure#SplitSize = 10
 <
 
+Errors
+------
+
+Errors are reported in a temporary buffer. This is to make error messages
+more readable. In particular when they contain stacktraces from the Java
+side. However this may interfer with scripts which do not expect that a
+new buffer pops up. So one can go back to the old behaviour.
+>
+        let vimclojure#UseErrorBuffer = 0
+<
+Note: the error might not be shown by vim. Check the output of |:message|
+for errors.
+
 Syntax Highlighting                 *ft-clj-syntax*
 -------------------
 
         g:vimclojure#ParenRainbow
                 Controls the colorisation of the differing levels of
                 parenthesisation. If non-zero, different levels will be
-                colored differently.
+                colored differently. Disabled by default.
 
         g:vimclojure#DynamicHighlighting
                 Uses the dynamic features of VimClojure to dynamically add
                 the symbols of required and used namespaces. The file needs
                 to be correct (ie. w/o syntax errors and on the classpath)
                 for this to work. If this is not the case, dynamic
-                highlighting is not done. Disable by default.
+                highlighting is not done. Disabled by default.
 <
 The g:vimclojure#ParenRainbow option provides 10 levels of individual
 colorisation for the parentheses. Because of the quantity of colorisation