Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
humorless committed Feb 16, 2018
0 parents commit 48c59c9
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
40 changes: 40 additions & 0 deletions plugin/vim-kibit.vim
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 48c59c9

Please sign in to comment.