├── .gitignore ├── README.md ├── doc ├── demo.png ├── eastwood.txt └── tags ├── plugin └── eastwood.vim └── syntax_checkers └── clojure └── eastwood.vim /.gitignore: -------------------------------------------------------------------------------- 1 | TODO 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vim-eastwood 2 | 3 | 4 | vim-eastwood is a vim plugin for [Eastwood](https://github.com/jonase/eastwood/), the Clojure lint tool. Rather than shelling out to Leiningen, it uses a [vim-fireplace](https://github.com/tpope/vim-fireplace/) REPL connection to only lint the current file. This has the advantage of sidestepping Leiningen's startup time and keeping Vim from hanging, though the very first time you use it with a given REPL server there will be a slight delay as it loads the `eastwood.lint` namespace. 5 | 6 | You should be aware of the side effects of [using Eastwood from a REPL](https://github.com/jonase/eastwood#running-eastwood-in-a-repl). 7 | 8 | It extends [Syntastic](https://github.com/scrooloose/syntastic)'s checkers, so you'll see those familiar markers in your UI: 9 | 10 | ![](doc/demo.png) 11 | 12 | ## Installation 13 | 14 | ### Requirements 15 | 16 | You'll want to have [Eastwood](https://github.com/jonase/eastwood/), [vim-fireplace](https://github.com/tpope/vim-fireplace/) and [Syntastic](https://github.com/scrooloose/syntastic) installed, and you'll need to make sure Eastwood is somewhere on your project's classpath. I'd recommend adding the following to your `~/.lein/profiles.clj`: 17 | 18 | ```clojure 19 | :dependencies [[jonase/eastwood "0.2.1" :exclusions [org.clojure/clojure]]] 20 | ``` 21 | 22 | You'll also need to enable this plugin as the Clojure syntax checker for Syntastic by adding the following line to your ~/.vimrc: 23 | 24 | ```vim 25 | let g:syntastic_clojure_checkers = ['eastwood'] 26 | ``` 27 | 28 | In order for Syntastic to actually lint the file you're working on, you'll also need to have a REPL connection open through fireplace. 29 | 30 | After that, the rest should take care of itself. 31 | 32 | ### Installing with Pathogen 33 | 34 | Assuming you already have [Pathogen](https://github.com/tpope/vim-pathogen) installed, you should be good to go with the following: 35 | 36 | ``` 37 | cd ~/.vim/bundle && \ 38 | git clone https://github.com/venantius/vim-eastwood.git 39 | ``` 40 | 41 | ### Installing with Vundle 42 | 43 | To install vim-eastwood with [Vundle](https://github.com/gmarik/Vundle.vim), add the following line to your `.vimrc`: 44 | ``` 45 | Bundle 'venantius/vim-eastwood' 46 | ``` 47 | 48 | ## Other Vim + Clojure Plugins 49 | 50 | If you like this, you should check out [vim-cljfmt](https://github.com/venantius/vim-cljfmt)! 51 | 52 | ## License 53 | 54 | Copyright (c) 2019 W. David Jarvis. 55 | 56 | Licensed under the Eclipse Public License, the same as Clojure. 57 | -------------------------------------------------------------------------------- /doc/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/venantius/vim-eastwood/291809ae239c17bd9d5f432af3eb55ab415a6c5f/doc/demo.png -------------------------------------------------------------------------------- /doc/eastwood.txt: -------------------------------------------------------------------------------- 1 | *eastwood.txt* Vim plugin for Eastwood, the Clojure lint tool 2 | *eastwood* 3 | _ _ _ ~ 4 | (_) | | | | ~ 5 | __ ___ _ __ ___ ___ __ _ ___| |___ _____ ___ __| | ~ 6 | \ \ / / | '_ ` _ \______/ _ \/ _` / __| __\ \ /\ / / _ \ / _ \ / _` | ~ 7 | \ V /| | | | | | |____| __/ (_| \__ \ |_ \ V V / (_) | (_) | (_| | ~ 8 | \_/ |_|_| |_| |_| \___|\__,_|___/\__| \_/\_/ \___/ \___/ \__,_| ~ 9 | ~ 10 | ~ 11 | ============================================================================== 12 | CONTENTS *vim-eastwood* 13 | 14 | 01. Intro .............................................. |eastwood-intro| 15 | 02. Features ........................................ |eastwood-features| 16 | 03. Contributions .............................. |eastwood-contributions| 17 | 04. License .......................................... |eastwood-license| 18 | 19 | ============================================================================== 20 | INTRODUCTION *eastwood-intro* 21 | 22 | vim-eastwood is a vim plugin for Eastwood, the code linter for Clojure. 23 | 24 | Rather than invoking the plugin by shelling out to Leiningen, it uses a 25 | vim-fireplace REPL connection to only lint the current file. This has 26 | the advantage of sidestepping Leiningen's startup time and keeping Vim 27 | from hanging, though the first time you use it with a given REPL server 28 | there will be a slight delay as it loads the eastwood.lint namespace. 29 | 30 | ============================================================================== 31 | FEATURES *eastwood-features* 32 | 33 | * Generates quickfix info and feeds it into Syntastic 34 | * That's it! 35 | 36 | ============================================================================== 37 | CONTRIBUTIONS *eastwood-contributions* 38 | 39 | Contributions and pull requests are welcome. 40 | 41 | ============================================================================== 42 | LICENSE *eastwood-license* 43 | 44 | EPL License. Copyright © 2015 W. David Jarvis 45 | 46 | vim:tw=78:ts=8:ft=help:norl: 47 | -------------------------------------------------------------------------------- /doc/tags: -------------------------------------------------------------------------------- 1 | eastwood eastwood.txt /*eastwood* 2 | eastwood-contributions eastwood.txt /*eastwood-contributions* 3 | eastwood-features eastwood.txt /*eastwood-features* 4 | eastwood-intro eastwood.txt /*eastwood-intro* 5 | eastwood-license eastwood.txt /*eastwood-license* 6 | eastwood.txt eastwood.txt /*eastwood.txt* 7 | vim-eastwood eastwood.txt /*vim-eastwood* 8 | -------------------------------------------------------------------------------- /plugin/eastwood.vim: -------------------------------------------------------------------------------- 1 | " eastwood.vim - Clojure linting and code cleanup plugin 2 | " Maintainer: Venantius 3 | " Version: 0.2 4 | 5 | if exists('g:syntastic_extra_filetypes') 6 | call add(g:syntastic_extra_filetypes, 'clojure') 7 | else 8 | let g:syntastic_extra_filetypes = ['clojure'] 9 | endif 10 | 11 | function! g:EastwoodRequire() 12 | let cmd = "(require 'eastwood.lint)" 13 | try 14 | call fireplace#session_eval(cmd) 15 | return '' 16 | catch /^Clojure:.*/ 17 | return '' 18 | endtry 19 | endfunction 20 | 21 | function! g:EastwoodLintNS(...) abort 22 | let opts = a:0 ? a:1 : {} 23 | let add_linters = exists('opts.add_linters') ? opts.add_linters : [] 24 | 25 | let cmd = "(->> (eastwood.lint/lint { " . 26 | \ " :namespaces '[" . fireplace#ns() . "]" . 27 | \ " :add-linters [" . join(map(copy(add_linters), '":" . v:val'), " ") ."]" . 28 | \ " })" . 29 | \ " :warnings" . 30 | \ " (map (fn [e]" . 31 | \ "{:text (:msg e)" . 32 | \ " :lnum (:line e)" . 33 | \ " :col (:column e)" . 34 | \ " :valid true" . 35 | \ " :bufnr " . bufnr('%') . 36 | \ " :type \"E\"})))" 37 | try 38 | call g:EastwoodRequire() " In case if REPL was restarted 39 | let res=fireplace#query(cmd) 40 | return res 41 | catch /^Clojure:.*/ 42 | return [] 43 | endtry 44 | endfunction 45 | -------------------------------------------------------------------------------- /syntax_checkers/clojure/eastwood.vim: -------------------------------------------------------------------------------- 1 | "============================================================================ 2 | "File: eastwood.vim 3 | "Description: Syntax checking plugin for syntastic.vim 4 | "Maintainer: Venantius 5 | "License: Distributed under the Eclipse Public License 1.0, the same as 6 | " Clojure. 7 | " 8 | "============================================================================ 9 | 10 | if exists("g:loaded_syntastic_clojure_eastwood_checker") 11 | finish 12 | endif 13 | let g:loaded_syntastic_clojure_eastwood_checker = 1 14 | 15 | let s:save_cpo = &cpo 16 | set cpo&vim 17 | 18 | " Try to require 'eastwood.lint 19 | function! SyntaxCheckers_clojure_eastwood_IsAvailable() dict 20 | try 21 | call g:EastwoodRequire() 22 | return 1 23 | catch 24 | return 0 25 | endtry 26 | endfunction 27 | 28 | function! SyntaxCheckers_clojure_eastwood_GetLocList() dict 29 | let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } 30 | let opts = {'add_linters': exists('g:eastwood_add_linters') ? g:eastwood_add_linters : []} 31 | return g:EastwoodLintNS(opts) 32 | endfunction 33 | 34 | call g:SyntasticRegistry.CreateAndRegisterChecker({ 35 | \ 'filetype': 'clojure', 36 | \ 'name': 'eastwood'}) 37 | 38 | let &cpo = s:save_cpo 39 | unlet s:save_cpo 40 | 41 | " vim: set sw=4 sts=4 et fdm=marker: 42 | --------------------------------------------------------------------------------