diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2e0a6ff --- /dev/null +++ b/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2011 Andreas Wålm , except where otherwise +noted. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +The Software shall be used for Good, not Evil. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..f7b7113 --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +# jshint.vim + +This plugin is a front for the jshint NodeJS cli module. +This plugin will allow you to run jshint from vim, and shows the results in a split window. + +## Installation + + +### jshint + +You have to install [jshint](http://jshint.org/), of course. + +Install on a system with npm: + + npm install jshint + +Otherwise, you are on your own. + +### The Plugin + +Use [pathogen.vim](https://github.com/vim-scripts/pathogen.vim) + + +## Usage + + :JSHint {file} + +It default to current file. + +### Keyboard Shortcuts + +In the quickfix window, you can use: + + o to open in new window + go to preview file (open but maintain focus on jshint results) + q to close the quickfix window + + + +## License + +Copyright (c) 2011 Andreas Wålm , except where otherwise +noted. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +The Software shall be used for Good, not Evil. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/doc/jshint.txt b/doc/jshint.txt new file mode 100644 index 0000000..4af9e53 --- /dev/null +++ b/doc/jshint.txt @@ -0,0 +1,35 @@ +*jshint.vim* A plugin that integrates JSHint with Vim + +============================================================================== +Author: Andreas Wålm *jshint-author* +License: See *LICENSE* file + +============================================================================== +INTRODUCTION *jshint* + +This plugin is a front for JSHint. + +This plugin will allow you to run JSHint from vim, and shows the results in +a split window. + +:JSHint {file} *:JSHint* + + Test {file} with jshint. + If {file} not provided it uses current file. + + Behaves just like the |:grep| command, but will open the |Quickfix| + window for you. + +Hints found in file will be listed in the split window, along with the +line and column number. + + on a line in this window will open the file, and place the cursor on +the matching line. + +Press 'o' in a line in |Quickfix| will open the file in a new window and place +the cursor on the matching line. + +Pressing 'go' will do a preview (open but maintain focus on jshint results) + +Press 'q' to close |Quickfix| window. + diff --git a/plugin/jshint.vim b/plugin/jshint.vim new file mode 100644 index 0000000..7d767d5 --- /dev/null +++ b/plugin/jshint.vim @@ -0,0 +1,50 @@ +" NOTE: You must have jshint in your path. +" +" Install: +" +" On system with npm: +" npm install jshint +" + +" Location of jshint utility, change in vimrc i different +if !exists("g:jshintprg") + let g:jshintprg="jshint" +endif + +function! s:JSHint(cmd, args) + redraw + echo "JSHint ..." + + " If no file is provided, use current file + if empty(a:args) + let l:fileargs = expand("%") + else + let l:fileargs = a:args + end + + let grepprg_bak=&grepprg + let grepformat_bak=&grepformat + try + let &grepprg=g:jshintprg + let &grepformat="%f: line %l\\,\ col %c\\, %m" + silent execute a:cmd . " " . l:fileargs + finally + let &grepprg=grepprg_bak + let &grepformat=grepformat_bak + endtry + + botright copen + + " close quickfix + exec "nnoremap q :ccl" + + " open in a new window + exec "nnoremap o " + + " preview + exec "nnoremap go " + + redraw! +endfunction + +command! -bang -nargs=* -complete=file JSHint call s:JSHint('grep',)