This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sign define compile_error text=xx texthl=ErrorMsg | |
function! Tapi_ClearSourceErrors(bufnum, arg) | |
silent! sign unplace 1 | |
endfunction | |
function! Tapi_SourceError(bufnum, data) | |
execute "sign place 1 name=compile_error line=" . a:data[1] . " file=" . a:data[0] | |
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn- send-to-vim | |
[data] | |
{:pre [(sequential? data)]} | |
(when (System/getenv "VIMRUNTIME") | |
(print (str "\u001B]51;" (json/generate-string data) "\u0007")))) | |
(defn- find-source | |
[filename] | |
(or (->> (clojure.string/split (System/getProperty "java.class.path") #":") | |
(map #(str % "/" filename)) | |
(filter #(.exists (io/as-file %))) | |
first) | |
filename)) | |
(defn- nice-compile-error | |
[error] | |
(send-to-vim ["call" "Tapi_ClearSourceErrors" []]) | |
(if (instance? clojure.lang.Compiler$CompilerException error) | |
(do | |
(println (str "\u001B[1;31m" (.getMessage error) "\u001B[0m")) | |
(send-to-vim ["call" "Tapi_SourceError" [(find-source (.-source error)) (.-line error)]]) | |
:compile-error) | |
error)) | |
(def refresh (comp nice-compile-error clojure.tools.namespace.repl/refresh)) | |
(def refresh-all (comp nice-compile-error clojure.tools.namespace.repl/refresh-all)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment