forked from dense-analysis/ale
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
* upstream/master: Cover the SaveEvent function with a test dense-analysis#734 - Use the buffer number from the events for entering buffers and saving buffers for checking buffers dense-analysis#734 - Do not clear file linter results when no buffers are run Add stylelint fixer Cover special LSP initialize response handling with Vader tests dense-analysis#517 - Get the Rust language server working in a basic way When servers never send an initialize response, but instead just publish diagnostics straight away, handle that as an initialize response Add some error message handling for LSP, for test purposes Fix some bugs so the PHP language server will show errors at least once
- Loading branch information
Showing
19 changed files
with
369 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
" Author: w0rp <devw0rp@gmail.com> | ||
" Description: A language server for Rust | ||
|
||
call ale#Set('rust_langserver_executable', 'rls') | ||
|
||
function! ale_linters#rust#langserver#GetExecutable(buffer) abort | ||
return ale#Var(a:buffer, 'rust_langserver_executable') | ||
endfunction | ||
|
||
function! ale_linters#rust#langserver#GetCommand(buffer) abort | ||
let l:executable = ale_linters#rust#langserver#GetExecutable(a:buffer) | ||
|
||
return ale#Escape(l:executable) . ' +nightly' | ||
endfunction | ||
|
||
function! ale_linters#rust#langserver#GetLanguage(buffer) abort | ||
return 'rust' | ||
endfunction | ||
|
||
function! ale_linters#rust#langserver#GetProjectRoot(buffer) abort | ||
let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') | ||
|
||
return !empty(l:cargo_file) ? fnamemodify(l:cargo_file, ':h') : '' | ||
endfunction | ||
|
||
call ale#linter#Define('rust', { | ||
\ 'name': 'langserver', | ||
\ 'lsp': 'stdio', | ||
\ 'executable_callback': 'ale_linters#rust#langserver#GetExecutable', | ||
\ 'command_callback': 'ale_linters#rust#langserver#GetCommand', | ||
\ 'language_callback': 'ale_linters#rust#langserver#GetLanguage', | ||
\ 'project_root_callback': 'ale_linters#rust#langserver#GetProjectRoot', | ||
\}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
" Author: w0rp <devw0rp@gmail.com> | ||
|
||
function! ale#events#SaveEvent() abort | ||
let l:should_lint = g:ale_enabled && g:ale_lint_on_save | ||
function! ale#events#SaveEvent(buffer) abort | ||
let l:should_lint = ale#Var(a:buffer, 'enabled') && g:ale_lint_on_save | ||
|
||
if g:ale_fix_on_save | ||
let l:will_fix = ale#fix#Fix('save_file') | ||
let l:should_lint = l:should_lint && !l:will_fix | ||
endif | ||
|
||
if l:should_lint | ||
call ale#Queue(0, 'lint_file') | ||
call ale#Queue(0, 'lint_file', a:buffer) | ||
endif | ||
endfunction | ||
|
||
function! s:LintOnEnter() abort | ||
if g:ale_enabled && g:ale_lint_on_enter && has_key(b:, 'ale_file_changed') | ||
function! s:LintOnEnter(buffer) abort | ||
if ale#Var(a:buffer, 'enabled') | ||
\&& g:ale_lint_on_enter | ||
\&& has_key(b:, 'ale_file_changed') | ||
call remove(b:, 'ale_file_changed') | ||
call ale#Queue(0, 'lint_file') | ||
call ale#Queue(0, 'lint_file', a:buffer) | ||
endif | ||
endfunction | ||
|
||
function! ale#events#EnterEvent() abort | ||
call s:LintOnEnter() | ||
function! ale#events#EnterEvent(buffer) abort | ||
call s:LintOnEnter(a:buffer) | ||
endfunction | ||
|
||
function! ale#events#FileChangedEvent(buffer) abort | ||
call setbufvar(a:buffer, 'ale_file_changed', 1) | ||
|
||
if bufnr('') == a:buffer | ||
call s:LintOnEnter() | ||
call s:LintOnEnter(a:buffer) | ||
endif | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
" Author: Mahmoud Mostafa <mah@moud.info> | ||
" Description: Fixing files with stylelint. | ||
|
||
call ale#Set('stylelint_executable', 'stylelint') | ||
call ale#Set('stylelint_use_global', 0) | ||
|
||
function! ale#fixers#stylelint#GetExecutable(buffer) abort | ||
return ale#node#FindExecutable(a:buffer, 'stylelint', [ | ||
\ 'node_modules/stylelint/bin/stylelint.js', | ||
\ 'node_modules/.bin/stylelint', | ||
\]) | ||
endfunction | ||
|
||
|
||
function! ale#fixers#stylelint#Fix(buffer) abort | ||
let l:executable = ale#fixers#stylelint#GetExecutable(a:buffer) | ||
|
||
if ale#Has('win32') && l:executable =~? 'stylelint\.js$' | ||
" For Windows, if we detect an stylelint.js script, we need to execute | ||
" it with node, or the file can be opened with a text editor. | ||
let l:head = 'node ' . ale#Escape(l:executable) | ||
else | ||
let l:head = ale#Escape(l:executable) | ||
endif | ||
|
||
return { | ||
\ 'command': l:head | ||
\ . ' --fix %t', | ||
\ 'read_temporary_file': 1, | ||
\} | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.