Commits

Meikel Brandmeyer committed ce48728

Bind keys to messages in case of problems

Fixes #43

Comments (0)

Files changed (2)

autoload/vimclojure.vim

 	endif
 endfunction
 
+function! vimclojure#MapCommandPlug(mode, keys, plug)
+	if exists("b:vimclojure_namespace")
+		call vimclojure#MapPlug(a:mode, a:keys, a:plug)
+	elseif g:vimclojure#WantNailgun == 1
+		let msg = ':call vimclojure#ReportError("VimClojure could not initialise the server connection.\n'
+					\ . 'That means you will not be able to use the interactive features.\n'
+					\ . 'Reasons might be that the server is not running or that there is\n'
+					\ . 'some trouble with the classpath.\n\n'
+					\ . 'VimClojure will *not* start the server for you or handle the classpath.\n'
+					\ . 'There is a plethora of tools like ivy, maven, gradle and leiningen,\n'
+					\ . 'which do this better than VimClojure could ever do it.")'
+		execute a:mode . "map <buffer> <silent> <LocalLeader>" . a:keys
+					\ . " " . msg . "<CR>"
+	endif
+endfunction
+
 function! vimclojure#ProtectedPlug(f, ...)
 	try
 		return call(a:f, a:000)

ftplugin/clojure.vim

 
 call vimclojure#MapPlug("n", "aw", "AddToLispWords")
 
+call vimclojure#MapCommandPlug("n", "lw", "DocLookupWord")
+call vimclojure#MapCommandPlug("n", "li", "DocLookupInteractive")
+call vimclojure#MapCommandPlug("n", "jw", "JavadocLookupWord")
+call vimclojure#MapCommandPlug("n", "ji", "JavadocLookupInteractive")
+call vimclojure#MapCommandPlug("n", "fd", "FindDoc")
+
+call vimclojure#MapCommandPlug("n", "mw", "MetaLookupWord")
+call vimclojure#MapCommandPlug("n", "mi", "MetaLookupInteractive")
+
+call vimclojure#MapCommandPlug("n", "sw", "SourceLookupWord")
+call vimclojure#MapCommandPlug("n", "si", "SourceLookupInteractive")
+
+call vimclojure#MapCommandPlug("n", "gw", "GotoSourceWord")
+call vimclojure#MapCommandPlug("n", "gi", "GotoSourceInteractive")
+
+call vimclojure#MapCommandPlug("n", "rf", "RequireFile")
+call vimclojure#MapCommandPlug("n", "rF", "RequireFileAll")
+
+call vimclojure#MapCommandPlug("n", "rt", "RunTests")
+
+call vimclojure#MapCommandPlug("n", "me", "MacroExpand")
+call vimclojure#MapCommandPlug("n", "m1", "MacroExpand1")
+
+call vimclojure#MapCommandPlug("n", "ef", "EvalFile")
+call vimclojure#MapCommandPlug("n", "el", "EvalLine")
+call vimclojure#MapCommandPlug("v", "eb", "EvalBlock")
+call vimclojure#MapCommandPlug("n", "et", "EvalToplevel")
+call vimclojure#MapCommandPlug("n", "ep", "EvalParagraph")
+
+call vimclojure#MapCommandPlug("n", "sr", "StartRepl")
+call vimclojure#MapCommandPlug("n", "sR", "StartLocalRepl")
+
 if exists("b:vimclojure_namespace")
-	call vimclojure#MapPlug("n", "lw", "DocLookupWord")
-	call vimclojure#MapPlug("n", "li", "DocLookupInteractive")
-	call vimclojure#MapPlug("n", "jw", "JavadocLookupWord")
-	call vimclojure#MapPlug("n", "ji", "JavadocLookupInteractive")
-	call vimclojure#MapPlug("n", "fd", "FindDoc")
-
-	call vimclojure#MapPlug("n", "mw", "MetaLookupWord")
-	call vimclojure#MapPlug("n", "mi", "MetaLookupInteractive")
-
-	call vimclojure#MapPlug("n", "sw", "SourceLookupWord")
-	call vimclojure#MapPlug("n", "si", "SourceLookupInteractive")
-
-	call vimclojure#MapPlug("n", "gw", "GotoSourceWord")
-	call vimclojure#MapPlug("n", "gi", "GotoSourceInteractive")
-
-	call vimclojure#MapPlug("n", "rf", "RequireFile")
-	call vimclojure#MapPlug("n", "rF", "RequireFileAll")
-
-	call vimclojure#MapPlug("n", "rt", "RunTests")
-
-	call vimclojure#MapPlug("n", "me", "MacroExpand")
-	call vimclojure#MapPlug("n", "m1", "MacroExpand1")
-
-	call vimclojure#MapPlug("n", "ef", "EvalFile")
-	call vimclojure#MapPlug("n", "el", "EvalLine")
-	call vimclojure#MapPlug("v", "eb", "EvalBlock")
-	call vimclojure#MapPlug("n", "et", "EvalToplevel")
-	call vimclojure#MapPlug("n", "ep", "EvalParagraph")
-
-	call vimclojure#MapPlug("n", "sr", "StartRepl")
-	call vimclojure#MapPlug("n", "sR", "StartLocalRepl")
-
 	setlocal omnifunc=vimclojure#OmniCompletion
 
 	augroup VimClojure