mirror of
https://github.com/amix/vimrc
synced 2025-06-23 06:35:01 +08:00
Updated plugins
This commit is contained in:
4
sources_non_forked/ale/ale_linters/bats/shellcheck.vim
Normal file
4
sources_non_forked/ale/ale_linters/bats/shellcheck.vim
Normal file
@ -0,0 +1,4 @@
|
||||
" Author: Ian2020 <https://github.com/Ian2020>
|
||||
" Description: shellcheck linter for bats scripts.
|
||||
|
||||
call ale#handlers#shellcheck#DefineLinter('bats')
|
24
sources_non_forked/ale/ale_linters/rust/analyzer.vim
Normal file
24
sources_non_forked/ale/ale_linters/rust/analyzer.vim
Normal file
@ -0,0 +1,24 @@
|
||||
" Author: Jon Gjengset <jon@thesquareplanet.com>
|
||||
" Description: The next generation language server for Rust
|
||||
|
||||
call ale#Set('rust_analyzer_executable', 'rust-analyzer')
|
||||
call ale#Set('rust_analyzer_config', {})
|
||||
|
||||
function! ale_linters#rust#analyzer#GetCommand(buffer) abort
|
||||
return '%e'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#rust#analyzer#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': 'analyzer',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'lsp_config': {b -> ale#Var(b, 'rust_analyzer_config')},
|
||||
\ 'executable': {b -> ale#Var(b, 'rust_analyzer_executable')},
|
||||
\ 'command': function('ale_linters#rust#analyzer#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#rust#analyzer#GetProjectRoot'),
|
||||
\})
|
@ -1,107 +1,4 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: This file adds support for using the shellcheck linter with
|
||||
" shell scripts.
|
||||
" Description: shellcheck linter for shell scripts.
|
||||
|
||||
" This global variable can be set with a string of comma-separated error
|
||||
" codes to exclude from shellcheck. For example:
|
||||
"
|
||||
" let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004'
|
||||
call ale#Set('sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', ''))
|
||||
call ale#Set('sh_shellcheck_executable', 'shellcheck')
|
||||
call ale#Set('sh_shellcheck_dialect', 'auto')
|
||||
call ale#Set('sh_shellcheck_options', '')
|
||||
call ale#Set('sh_shellcheck_change_directory', 1)
|
||||
|
||||
function! ale_linters#sh#shellcheck#GetDialectArgument(buffer) abort
|
||||
let l:shell_type = ale#handlers#sh#GetShellType(a:buffer)
|
||||
|
||||
if !empty(l:shell_type)
|
||||
" Use the dash dialect for /bin/ash, etc.
|
||||
if l:shell_type is# 'ash'
|
||||
return 'dash'
|
||||
endif
|
||||
|
||||
return l:shell_type
|
||||
endif
|
||||
|
||||
" If there's no hashbang, try using Vim's buffer variables.
|
||||
if getbufvar(a:buffer, 'is_bash', 0)
|
||||
return 'bash'
|
||||
elseif getbufvar(a:buffer, 'is_sh', 0)
|
||||
return 'sh'
|
||||
elseif getbufvar(a:buffer, 'is_kornshell', 0)
|
||||
return 'ksh'
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#sh#shellcheck#GetCommand(buffer, version) abort
|
||||
let l:options = ale#Var(a:buffer, 'sh_shellcheck_options')
|
||||
let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions')
|
||||
let l:dialect = ale#Var(a:buffer, 'sh_shellcheck_dialect')
|
||||
let l:external_option = ale#semver#GTE(a:version, [0, 4, 0]) ? ' -x' : ''
|
||||
let l:cd_string = ale#Var(a:buffer, 'sh_shellcheck_change_directory')
|
||||
\ ? ale#path#BufferCdString(a:buffer)
|
||||
\ : ''
|
||||
|
||||
if l:dialect is# 'auto'
|
||||
let l:dialect = ale_linters#sh#shellcheck#GetDialectArgument(a:buffer)
|
||||
endif
|
||||
|
||||
return l:cd_string
|
||||
\ . '%e'
|
||||
\ . (!empty(l:dialect) ? ' -s ' . l:dialect : '')
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '')
|
||||
\ . l:external_option
|
||||
\ . ' -f gcc -'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#sh#shellcheck#Handle(buffer, lines) abort
|
||||
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+) \[([^\]]+)\]$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
if l:match[4] is# 'error'
|
||||
let l:type = 'E'
|
||||
elseif l:match[4] is# 'note'
|
||||
let l:type = 'I'
|
||||
else
|
||||
let l:type = 'W'
|
||||
endif
|
||||
|
||||
let l:item = {
|
||||
\ 'lnum': str2nr(l:match[2]),
|
||||
\ 'type': l:type,
|
||||
\ 'text': l:match[5],
|
||||
\ 'code': l:match[6],
|
||||
\}
|
||||
|
||||
if !empty(l:match[3])
|
||||
let l:item.col = str2nr(l:match[3])
|
||||
endif
|
||||
|
||||
" If the filename is something like <stdin>, <nofile> or -, then
|
||||
" this is an error for the file we checked.
|
||||
if l:match[1] isnot# '-' && l:match[1][0] isnot# '<'
|
||||
let l:item['filename'] = l:match[1]
|
||||
endif
|
||||
|
||||
call add(l:output, l:item)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('sh', {
|
||||
\ 'name': 'shellcheck',
|
||||
\ 'executable': {buffer -> ale#Var(buffer, 'sh_shellcheck_executable')},
|
||||
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
|
||||
\ buffer,
|
||||
\ ale#Var(buffer, 'sh_shellcheck_executable'),
|
||||
\ '%e --version',
|
||||
\ function('ale_linters#sh#shellcheck#GetCommand'),
|
||||
\ )},
|
||||
\ 'callback': 'ale_linters#sh#shellcheck#Handle',
|
||||
\})
|
||||
call ale#handlers#shellcheck#DefineLinter('sh')
|
||||
|
107
sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim
Normal file
107
sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim
Normal file
@ -0,0 +1,107 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: This file adds support for using the shellcheck linter
|
||||
|
||||
function! ale#handlers#shellcheck#GetDialectArgument(buffer) abort
|
||||
let l:shell_type = ale#handlers#sh#GetShellType(a:buffer)
|
||||
|
||||
if !empty(l:shell_type)
|
||||
" Use the dash dialect for /bin/ash, etc.
|
||||
if l:shell_type is# 'ash'
|
||||
return 'dash'
|
||||
endif
|
||||
|
||||
return l:shell_type
|
||||
endif
|
||||
|
||||
" If there's no hashbang, try using Vim's buffer variables.
|
||||
if getbufvar(a:buffer, 'is_bash', 0)
|
||||
return 'bash'
|
||||
elseif getbufvar(a:buffer, 'is_sh', 0)
|
||||
return 'sh'
|
||||
elseif getbufvar(a:buffer, 'is_kornshell', 0)
|
||||
return 'ksh'
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#shellcheck#GetCommand(buffer, version) abort
|
||||
let l:options = ale#Var(a:buffer, 'sh_shellcheck_options')
|
||||
let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions')
|
||||
let l:dialect = ale#Var(a:buffer, 'sh_shellcheck_dialect')
|
||||
let l:external_option = ale#semver#GTE(a:version, [0, 4, 0]) ? ' -x' : ''
|
||||
let l:cd_string = ale#Var(a:buffer, 'sh_shellcheck_change_directory')
|
||||
\ ? ale#path#BufferCdString(a:buffer)
|
||||
\ : ''
|
||||
|
||||
if l:dialect is# 'auto'
|
||||
let l:dialect = ale#handlers#shellcheck#GetDialectArgument(a:buffer)
|
||||
endif
|
||||
|
||||
return l:cd_string
|
||||
\ . '%e'
|
||||
\ . (!empty(l:dialect) ? ' -s ' . l:dialect : '')
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '')
|
||||
\ . l:external_option
|
||||
\ . ' -f gcc -'
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#shellcheck#Handle(buffer, lines) abort
|
||||
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+) \[([^\]]+)\]$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
if l:match[4] is# 'error'
|
||||
let l:type = 'E'
|
||||
elseif l:match[4] is# 'note'
|
||||
let l:type = 'I'
|
||||
else
|
||||
let l:type = 'W'
|
||||
endif
|
||||
|
||||
let l:item = {
|
||||
\ 'lnum': str2nr(l:match[2]),
|
||||
\ 'type': l:type,
|
||||
\ 'text': l:match[5],
|
||||
\ 'code': l:match[6],
|
||||
\}
|
||||
|
||||
if !empty(l:match[3])
|
||||
let l:item.col = str2nr(l:match[3])
|
||||
endif
|
||||
|
||||
" If the filename is something like <stdin>, <nofile> or -, then
|
||||
" this is an error for the file we checked.
|
||||
if l:match[1] isnot# '-' && l:match[1][0] isnot# '<'
|
||||
let l:item['filename'] = l:match[1]
|
||||
endif
|
||||
|
||||
call add(l:output, l:item)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#shellcheck#DefineLinter(filetype) abort
|
||||
" This global variable can be set with a string of comma-separated error
|
||||
" codes to exclude from shellcheck. For example:
|
||||
" let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004'
|
||||
call ale#Set('sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', ''))
|
||||
call ale#Set('sh_shellcheck_executable', 'shellcheck')
|
||||
call ale#Set('sh_shellcheck_dialect', 'auto')
|
||||
call ale#Set('sh_shellcheck_options', '')
|
||||
call ale#Set('sh_shellcheck_change_directory', 1)
|
||||
|
||||
call ale#linter#Define(a:filetype, {
|
||||
\ 'name': 'shellcheck',
|
||||
\ 'executable': {buffer -> ale#Var(buffer, 'sh_shellcheck_executable')},
|
||||
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
|
||||
\ buffer,
|
||||
\ ale#Var(buffer, 'sh_shellcheck_executable'),
|
||||
\ '%e --version',
|
||||
\ function('ale#handlers#shellcheck#GetCommand'),
|
||||
\ )},
|
||||
\ 'callback': 'ale#handlers#shellcheck#Handle',
|
||||
\})
|
||||
endfunction
|
13
sources_non_forked/ale/doc/ale-bats.txt
Normal file
13
sources_non_forked/ale/doc/ale-bats.txt
Normal file
@ -0,0 +1,13 @@
|
||||
===============================================================================
|
||||
ALE Bats Integration *ale-bats-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
shellcheck *ale-bats-shellcheck*
|
||||
|
||||
The `shellcheck` linter for Bats uses the sh options for `shellcheck`; see:
|
||||
|ale-sh-shellcheck|.
|
||||
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
@ -9,7 +9,7 @@ Integration Information
|
||||
files for Rust distributed in Vim >=8.0.0501 or upstream:
|
||||
https://github.com/rust-lang/rust.vim
|
||||
|
||||
Note that there are three possible linters for Rust files:
|
||||
Note that there are several possible linters and fixers for Rust files:
|
||||
|
||||
1. rustc -- The Rust compiler is used to check the currently edited file.
|
||||
So, if your project consists of multiple files, you will get some errors
|
||||
@ -23,7 +23,12 @@ Integration Information
|
||||
over cargo. rls implements the Language Server Protocol for incremental
|
||||
compilation of Rust code, and can check Rust files while you type. `rls`
|
||||
requires Rust files to contained in Cargo projects.
|
||||
4. rustfmt -- If you have `rustfmt` installed, you can use it as a fixer to
|
||||
4. analyzer -- If you have rust-analyzer installed, you might prefer using
|
||||
this linter over cargo and rls. rust-analyzer also implements the
|
||||
Language Server Protocol for incremental compilation of Rust code, and is
|
||||
the next iteration of rls. rust-analyzer, like rls, requires Rust files
|
||||
to contained in Cargo projects.
|
||||
5. rustfmt -- If you have `rustfmt` installed, you can use it as a fixer to
|
||||
consistently reformat your Rust code.
|
||||
|
||||
Only cargo is enabled by default. To switch to using rustc instead of cargo,
|
||||
@ -36,6 +41,25 @@ Integration Information
|
||||
Also note that rustc 1.12. or later is needed.
|
||||
|
||||
|
||||
===============================================================================
|
||||
analyzer *ale-rust-analyzer*
|
||||
|
||||
g:ale_rust_analyzer_executable *g:ale_rust_analyzer_executable*
|
||||
*b:ale_rust_analyzer_executable*
|
||||
Type: |String|
|
||||
Default: `'rust-analyzer'`
|
||||
|
||||
This variable can be modified to change the executable path for
|
||||
`rust-analyzer`.
|
||||
|
||||
|
||||
g:ale_rust_analyzer_config *g:ale_rust_analyzer_config*
|
||||
*b:ale_rust_analyzer_config*
|
||||
Type: |Dictionary|
|
||||
Default: `{}`
|
||||
|
||||
Dictionary with configuration settings for rust-analyzer.
|
||||
|
||||
===============================================================================
|
||||
cargo *ale-rust-cargo*
|
||||
|
||||
|
@ -35,6 +35,8 @@ Notes:
|
||||
* `shell` (-n flag)
|
||||
* `shellcheck`
|
||||
* `shfmt`
|
||||
* Bats
|
||||
* `shellcheck`
|
||||
* BibTeX
|
||||
* `bibclean`
|
||||
* Bourne Shell
|
||||
@ -408,6 +410,7 @@ Notes:
|
||||
* Rust
|
||||
* `cargo`!!
|
||||
* `rls`
|
||||
* `rust-analyzer`
|
||||
* `rustc` (see |ale-integration-rust|)
|
||||
* `rustfmt`
|
||||
* Sass
|
||||
|
@ -2279,6 +2279,8 @@ documented in additional help files.
|
||||
gcc...................................|ale-asm-gcc|
|
||||
awk.....................................|ale-awk-options|
|
||||
gawk..................................|ale-awk-gawk|
|
||||
bats....................................|ale-bats-options|
|
||||
shellcheck............................|ale-bats-shellcheck|
|
||||
bib.....................................|ale-bib-options|
|
||||
bibclean..............................|ale-bib-bibclean|
|
||||
c.......................................|ale-c-options|
|
||||
@ -2579,6 +2581,7 @@ documented in additional help files.
|
||||
sorbet................................|ale-ruby-sorbet|
|
||||
standardrb............................|ale-ruby-standardrb|
|
||||
rust....................................|ale-rust-options|
|
||||
analyzer..............................|ale-rust-analyzer|
|
||||
cargo.................................|ale-rust-cargo|
|
||||
rls...................................|ale-rust-rls|
|
||||
rustc.................................|ale-rust-rustc|
|
||||
|
@ -44,6 +44,8 @@ formatting.
|
||||
* shell [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set)
|
||||
* [shellcheck](https://www.shellcheck.net/)
|
||||
* [shfmt](https://github.com/mvdan/sh)
|
||||
* Bats
|
||||
* [shellcheck](https://www.shellcheck.net/)
|
||||
* BibTeX
|
||||
* [bibclean](http://ftp.math.utah.edu/pub/bibclean/)
|
||||
* Bourne Shell
|
||||
@ -417,6 +419,7 @@ formatting.
|
||||
* Rust
|
||||
* [cargo](https://github.com/rust-lang/cargo) :floppy_disk: (see `:help ale-integration-rust` for configuration instructions)
|
||||
* [rls](https://github.com/rust-lang-nursery/rls) :warning:
|
||||
* [rust-analyzer](https://github.com/rust-analyzer/rust-analyzer) :warning:
|
||||
* [rustc](https://www.rust-lang.org/) :warning:
|
||||
* [rustfmt](https://github.com/rust-lang-nursery/rustfmt)
|
||||
* Sass
|
||||
|
Reference in New Issue
Block a user