diff options
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | ale_linters/reason/merlin.vim | 17 | ||||
-rw-r--r-- | autoload/ale.vim | 2 | ||||
-rw-r--r-- | autoload/ale/debugging.vim | 8 | ||||
-rw-r--r-- | autoload/ale/sign.vim | 6 | ||||
-rwxr-xr-x | custom-checks | 20 | ||||
-rw-r--r-- | doc/ale-reasonml.txt | 15 | ||||
-rw-r--r-- | doc/ale.txt | 1 | ||||
-rw-r--r-- | plugin/ale.vim | 10 | ||||
-rw-r--r-- | test/sign/test_sign_placement.vader | 3 | ||||
-rw-r--r-- | test/test_ale_info.vader | 42 | ||||
-rw-r--r-- | test/test_ale_var.vader | 5 |
12 files changed, 120 insertions, 12 deletions
@@ -79,7 +79,7 @@ name. That seems to be the fairest way to arrange this table. | Haskell | [ghc](https://www.haskell.org/ghc/), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools) | | HTML | [HTMLHint](http://htmlhint.com/), [proselint](http://proselint.com/), [tidy](http://www.html-tidy.org/) | | Java | [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) | -| JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [flow](https://flowtype.org/), [standard](http://standardjs.com/) +| JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [flow](https://flowtype.org/), [standard](http://standardjs.com/), [xo](https://github.com/sindresorhus/xo) | JSON | [jsonlint](http://zaa.ch/jsonlint/) | | LaTeX | [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck) | | Lua | [luacheck](https://github.com/mpeterv/luacheck) | @@ -95,6 +95,7 @@ name. That seems to be the fairest way to arrange this table. | Pug | [pug-lint](https://github.com/pugjs/pug-lint) | | Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) | | Python | [flake8](http://flake8.pycqa.org/en/latest/), [mypy](http://mypy-lang.org/), [pylint](https://www.pylint.org/) | +| ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-integration-reason-merlin` for configuration instructions | reStructuredText | [proselint](http://proselint.com/)| | RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) | | Ruby | [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org) | diff --git a/ale_linters/reason/merlin.vim b/ale_linters/reason/merlin.vim new file mode 100644 index 00000000..7bef7df8 --- /dev/null +++ b/ale_linters/reason/merlin.vim @@ -0,0 +1,17 @@ +" Author: Andrey Popp -- @andreypopp +" Description: Report errors in ReasonML code with Merlin + +if !exists('g:merlin') + finish +endif + +function! ale_linters#reason#merlin#Handle(buffer, lines) abort + return merlin#ErrorLocList() +endfunction + +call ale#linter#Define('reason', { +\ 'name': 'merlin', +\ 'executable': 'ocamlmerlin', +\ 'command': 'true', +\ 'callback': 'ale_linters#reason#merlin#Handle', +\}) diff --git a/autoload/ale.vim b/autoload/ale.vim index b911c215..b9cd648f 100644 --- a/autoload/ale.vim +++ b/autoload/ale.vim @@ -113,5 +113,5 @@ endfunction function! ale#Var(buffer, variable_name) abort let l:full_name = 'ale_' . a:variable_name - return getbufvar(a:buffer, l:full_name, g:[l:full_name]) + return getbufvar(str2nr(a:buffer), l:full_name, g:[l:full_name]) endfunction diff --git a/autoload/ale/debugging.vim b/autoload/ale/debugging.vim index 60c1b37c..f42c9e82 100644 --- a/autoload/ale/debugging.vim +++ b/autoload/ale/debugging.vim @@ -51,12 +51,20 @@ endfunction function! s:EchoLinterVariables(variable_list) abort for l:key in a:variable_list echom 'let g:' . l:key . ' = ' . string(g:[l:key]) + + if has_key(b:, l:key) + echom 'let b:' . l:key . ' = ' . string(b:[l:key]) + endif endfor endfunction function! s:EchoGlobalVariables() abort for l:key in s:global_variable_list echom 'let g:' . l:key . ' = ' . string(get(g:, l:key, v:null)) + + if has_key(b:, l:key) + echom 'let b:' . l:key . ' = ' . string(b:[l:key]) + endif endfor endfunction diff --git a/autoload/ale/sign.vim b/autoload/ale/sign.vim index e002f584..0e0250bf 100644 --- a/autoload/ale/sign.vim +++ b/autoload/ale/sign.vim @@ -169,6 +169,12 @@ endfunction " This function will set the signs which show up on the left. function! ale#sign#SetSigns(buffer, loclist) abort + if !bufexists(str2nr(a:buffer)) + " Stop immediately when attempting to set signs for a buffer which + " does not exist. + return + endif + " Find the current markers let l:current_sign_list = ale#sign#FindCurrentSigns(a:buffer) diff --git a/custom-checks b/custom-checks index 440dafe5..37d2840c 100755 --- a/custom-checks +++ b/custom-checks @@ -44,24 +44,26 @@ fi shopt -s globstar -directory="$1" +directories=("$@") check_errors() { regex="$1" message="$2" - for match in $( - grep -n "$regex" "$directory"/**/*.vim \ - | grep -o '^[^:]\+:[0-9]\+' \ - | sed 's:^\./::' - ); do - RETURN_CODE=1 - echo "$match $message" + for directory in "${directories[@]}"; do + while IFS= read -r match; do + RETURN_CODE=1 + echo "$match $message" + done < <(grep -n "$regex" "$directory"/**/*.vim \ + | grep -o '^[^:]\+:[0-9]\+' \ + | sed 's:^\./::') done } if (( FIX_ERRORS )); then - sed -i "s/^\(function.*)\) *$/\1 abort/" "$directory"/**/*.vim + for directory in "${directories[@]}"; do + sed -i "s/^\(function.*)\) *$/\1 abort/" "$directory"/**/*.vim + done fi check_errors \ diff --git a/doc/ale-reasonml.txt b/doc/ale-reasonml.txt new file mode 100644 index 00000000..3d411485 --- /dev/null +++ b/doc/ale-reasonml.txt @@ -0,0 +1,15 @@ +=============================================================================== +ALE ReasonML Integration *ale-reasonml-options* + + +------------------------------------------------------------------------------- +merlin *ale-reasonml-merlin* + + To use merlin linter for ReasonML source code you need to make sure Merlin + for Vim is correctly configured. See the corresponding Merlin wiki page for + detailed instructions + (https://github.com/the-lambda-church/merlin/wiki/vim-from-scratch). + + +------------------------------------------------------------------------------- + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale.txt b/doc/ale.txt index 7f391964..0e9ad35b 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -153,6 +153,7 @@ The following languages and tools are supported. * Pug: 'pug-lint' * Puppet: 'puppet', 'puppet-lint' * Python: 'flake8', 'mypy', 'pylint' +* ReasonML: 'merlin' * reStructuredText: 'proselint' * RPM spec: 'spec' * Rust: 'rustc' (see |ale-integration-rust|) diff --git a/plugin/ale.vim b/plugin/ale.vim index b6f6f296..0e8c369f 100644 --- a/plugin/ale.vim +++ b/plugin/ale.vim @@ -181,7 +181,15 @@ function! ALEInitAuGroups() abort augroup ALERunOnFiletypeChangeGroup autocmd! if g:ale_enabled && g:ale_lint_on_filetype_changed - autocmd FileType * call ale#Queue(300, 'lint_file') + " Set the filetype after a buffer is opened or read. + autocmd BufEnter,BufRead * let b:ale_original_filetype = &filetype + " Only start linting if the FileType actually changes after + " opening a buffer. The FileType will fire when buffers are opened. + autocmd FileType * + \ if has_key(b:, 'ale_original_filetype') + \ && b:ale_original_filetype !=# expand('<amatch>') + \| call ale#Queue(300, 'lint_file') + \| endif endif augroup END diff --git a/test/sign/test_sign_placement.vader b/test/sign/test_sign_placement.vader index 396ef5c4..518e1b81 100644 --- a/test/sign/test_sign_placement.vader +++ b/test/sign/test_sign_placement.vader @@ -132,3 +132,6 @@ Execute(Loclist items with sign_id values should be kept): \ ['16', '1000004', 'ALEErrorSign'], \ ], \ ParseSigns() + +Execute(No excpetions should be thrown when setting signs for invalid buffers): + call ale#sign#SetSigns(123456789, [{'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'}]) diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader index d5a8ed62..83d32cb0 100644 --- a/test/test_ale_info.vader +++ b/test/test_ale_info.vader @@ -37,6 +37,7 @@ Before: let g:command_header = "\n Command History:\n" After: + unlet! b:ale_linters unlet! g:output unlet! g:globals_string unlet! g:command_header @@ -45,6 +46,7 @@ After: unlet! g:ale_testft_testlinter1_foo unlet! g:ale_testft_testlinter1_bar unlet! g:ale_testft2_testlinter2_foo + unlet! b:ale_testft2_testlinter2_foo unlet! g:ale_testft2_testlinter2_bar Given nolintersft (Empty buffer with no linters): @@ -60,6 +62,26 @@ Execute (ALEInfo with no linters should return the right output): \" . g:globals_string . g:command_header, g:output Given (Empty buffer with no filetype): +Execute (ALEInfo should return buffer-local global ALE settings): + let b:ale_linters = {'x': ['y']} + let g:globals_string = substitute( + \ g:globals_string, + \ 'let g:ale_linters = {}', + \ "let g:ale_linters = {}\nlet b:ale_linters = {'x': ['y']}", + \ '' + \) + + redir => g:output + silent ALEInfo + redir END + AssertEqual "\n + \ Current Filetype: \n + \Available Linters: []\n + \ Enabled Linters: []\n + \ Linter Variables:\n + \" . g:globals_string . g:command_header, g:output + +Given (Empty buffer with no filetype): Execute (ALEInfo with no filetype should return the right output): redir => g:output silent ALEInfo @@ -167,6 +189,26 @@ Execute (ALEInfo should return appropriately named global variables): \ . g:globals_string . g:command_header, g:output Given testft.testft2 (Empty buffer with two filetypes): +Execute (ALEInfo should buffer-local linter variables): + let g:ale_testft2_testlinter2_foo = 123 + let b:ale_testft2_testlinter2_foo = 456 + + call ale#linter#Define('testft', g:testlinter1) + call ale#linter#Define('testft2', g:testlinter2) + redir => g:output + silent ALEInfo + redir END + AssertEqual "\n + \ Current Filetype: testft.testft2\n + \Available Linters: ['testlinter1', 'testlinter2']\n + \ Enabled Linters: ['testlinter1', 'testlinter2']\n + \ Linter Variables:\n + \\n + \let g:ale_testft2_testlinter2_foo = 123\n + \let b:ale_testft2_testlinter2_foo = 456" + \ . g:globals_string . g:command_header, g:output + +Given testft.testft2 (Empty buffer with two filetypes): Execute (ALEInfo should return command history): let g:ale_buffer_info[bufnr('%')] = { \ 'history': [ diff --git a/test/test_ale_var.vader b/test/test_ale_var.vader index aee8e048..576b403f 100644 --- a/test/test_ale_var.vader +++ b/test/test_ale_var.vader @@ -12,5 +12,10 @@ Execute(ale#Var should return buffer overrides): AssertEqual 'def', ale#Var(bufnr(''), 'some_variable') +Execute(ale#Var should return buffer overrides for buffer numbers as strings): + let b:ale_some_variable = 'def' + + AssertEqual 'def', ale#Var(string(bufnr('')), 'some_variable') + Execute(ale#Var should throw exceptions for undefined variables): AssertThrows call ale#Var(bufnr(''), 'undefined_variable_name') |