From 48c59c95d2c49e8bb9bf1d33817c68418798756c Mon Sep 17 00:00:00 2001 From: Laurence Chen Date: Fri, 16 Feb 2018 23:13:12 +0000 Subject: [PATCH] first commit --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ plugin/vim-kibit.vim | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 README.md create mode 100644 plugin/vim-kibit.vim diff --git a/README.md b/README.md new file mode 100644 index 0000000..d14b37b --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# Kibit-vim + +[kibit](https://github.com/jonase/kibit) is a static code analyzer for Clojure, ClojureScript, cljx and other Clojure variants. + +## Usage + +vim-kibit allows you to analyze the current opened file by running: + +`:KibitCheck` + + +## Installation + +### Requirements + +You'll want to have [kibit](https://github.com/jonase/kibit) and [vim-fireplace](https://github.com/tpope/vim-fireplace/) installed, and you'll need to make sure Kibit is somewhere on your project's classpath. I'd recommend adding the following to your `~/.lein/profiles.clj`: + +```clojure +{:dependencies [[jonase/kibit "0.1.5" :exclusions [org.clojure/clojure]]]} +``` + +You'll also need to have a REPL connection open through fireplace. + +After that, the rest should take care of itself. + +### Installing with Pathogen + +Assuming you already have [Pathogen](https://github.com/tpope/vim-pathogen) installed, you should be good to go with the following: + +``` +cd ~/.vim/bundle && \ +git clone https://github.com/humorless/vim-kibit.git +``` + +## License + +Copyright © 2018 Laurence Chen + +Distributed under the Eclipse Public License, the same as Clojure. diff --git a/plugin/vim-kibit.vim b/plugin/vim-kibit.vim new file mode 100644 index 0000000..93df3fa --- /dev/null +++ b/plugin/vim-kibit.vim @@ -0,0 +1,40 @@ +let g:kibit_required = 0 + +function! s:RequireKibit() + let l:cmd = "(require 'kibit.check)" + try + silent! call fireplace#session_eval(l:cmd) + return 1 + catch /^Clojure: class java.io.FileNotFoundException*/ + echom "vim-kibit: Could not locate kibit/core__init.class" + return 0 + catch /^Fireplace:.*/ + echom v:exception + return 0 + endtry +endfunction + +function! s:KibitCommand(CurrentFileName) + return '(print (kibit.check/check-file "' . a:CurrentFileName .'"))' +endfunction + +function! s:KibitCheck() + let g:kibit_required = s:RequireKibit() + " If kibit.check has already been required, or was successfully imported + " above + let l:CurrentFileName = expand("%") + if g:kibit_required + try + call fireplace#session_eval(s:KibitCommand(l:CurrentFileName)) + return 1 + catch /^Clojure: */ + echom "kibit check-file failed" + return 0 + catch /^Fireplace:.*/ + echom v:exception + return 0 + endtry + endif +endfunction + +command! KibitCheck call s:KibitCheck()