mirror of
https://github.com/amix/vimrc
synced 2025-07-09 10:45:00 +08:00
gitignore sources_non_forked_cache
This commit is contained in:
@ -0,0 +1,70 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: A linter for checking ALE project code itself.
|
||||
|
||||
function! ale_linters#vim#ale_custom_linting_rules#GetExecutable(buffer) abort
|
||||
let l:filename = expand('#' . a:buffer . ':p')
|
||||
let l:dir_list = []
|
||||
|
||||
for l:dir in split(&runtimepath, ',')
|
||||
if l:filename[:len(l:dir) - 1] is# l:dir
|
||||
call add(l:dir_list, l:dir)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return !empty(l:dir_list)
|
||||
\ ? findfile('test/script/custom-linting-rules', join(l:dir_list, ','))
|
||||
\ : ''
|
||||
endfunction
|
||||
|
||||
function! s:GetALEProjectDir(buffer) abort
|
||||
let l:executable = ale_linters#vim#ale_custom_linting_rules#GetExecutable(a:buffer)
|
||||
|
||||
return ale#path#Dirname(ale#path#Dirname(ale#path#Dirname(l:executable)))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#vim#ale_custom_linting_rules#GetCwd(buffer) abort
|
||||
let l:executable = ale_linters#vim#ale_custom_linting_rules#GetExecutable(a:buffer)
|
||||
|
||||
return ale#path#Dirname(ale#path#Dirname(ale#path#Dirname(l:executable)))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#vim#ale_custom_linting_rules#GetCommand(buffer) abort
|
||||
let l:temp_dir = ale#command#CreateDirectory(a:buffer)
|
||||
let l:temp_file = l:temp_dir . '/example.vim'
|
||||
|
||||
let l:lines = getbufline(a:buffer, 1, '$')
|
||||
call ale#util#Writefile(a:buffer, l:lines, l:temp_file)
|
||||
|
||||
return '%e ' . ale#Escape(l:temp_dir)
|
||||
endfunction
|
||||
|
||||
function! ale_linters#vim#ale_custom_linting_rules#Handle(buffer, lines) abort
|
||||
let l:dir = s:GetALEProjectDir(a:buffer)
|
||||
let l:output = []
|
||||
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+) (.+)$'
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
" Ignore trailing whitespace errors if we've turned them off.
|
||||
if !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
|
||||
\&& l:match[3] is# 'Trailing whitespace'
|
||||
continue
|
||||
endif
|
||||
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[2],
|
||||
\ 'text': l:match[3],
|
||||
\ 'type': 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('vim', {
|
||||
\ 'name': 'ale_custom_linting_rules',
|
||||
\ 'executable': function('ale_linters#vim#ale_custom_linting_rules#GetExecutable'),
|
||||
\ 'cwd': function('ale_linters#vim#ale_custom_linting_rules#GetCwd'),
|
||||
\ 'command': function('ale_linters#vim#ale_custom_linting_rules#GetCommand'),
|
||||
\ 'callback': 'ale_linters#vim#ale_custom_linting_rules#Handle',
|
||||
\ 'read_buffer': 0,
|
||||
\})
|
61
sources_non_forked/ale/ale_linters/vim/vimls.vim
Normal file
61
sources_non_forked/ale/ale_linters/vim/vimls.vim
Normal file
@ -0,0 +1,61 @@
|
||||
" Author: Jeffrey Lau - https://github.com/zoonfafer
|
||||
" Description: Vim Language Server integration for ALE
|
||||
|
||||
call ale#Set('vim_vimls_executable', 'vim-language-server')
|
||||
call ale#Set('vim_vimls_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('vim_vimls_config', {})
|
||||
|
||||
function! ale_linters#vim#vimls#GetProjectRoot(buffer) abort
|
||||
let l:trigger_file_candidates = [
|
||||
\ '.vimrc',
|
||||
\ 'init.vim',
|
||||
\]
|
||||
|
||||
for l:candidate in l:trigger_file_candidates
|
||||
let l:trigger_file = fnamemodify(bufname(a:buffer), ':t')
|
||||
|
||||
if l:trigger_file is# l:candidate
|
||||
return fnamemodify(
|
||||
\ bufname(a:buffer),
|
||||
\ ':h',
|
||||
\)
|
||||
endif
|
||||
endfor
|
||||
|
||||
let l:trigger_dir_candidates = [
|
||||
\ 'autoload',
|
||||
\ 'plugin',
|
||||
\ '.git',
|
||||
\]
|
||||
|
||||
let l:path_upwards = ale#path#Upwards(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
|
||||
for l:path in l:path_upwards
|
||||
for l:candidate in l:trigger_dir_candidates
|
||||
let l:trigger_dir = ale#path#Simplify(
|
||||
\ l:path . '/' . l:candidate,
|
||||
\)
|
||||
|
||||
if isdirectory(l:trigger_dir)
|
||||
return fnamemodify(
|
||||
\ l:trigger_dir,
|
||||
\ ':p:h:h',
|
||||
\)
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('vim', {
|
||||
\ 'name': 'vimls',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'lsp_config': {b -> ale#Var(b, 'vim_vimls_config')},
|
||||
\ 'executable': {b -> ale#path#FindExecutable(b, 'vim_vimls', [
|
||||
\ 'node_modules/.bin/vim-language-server',
|
||||
\ ])},
|
||||
\ 'command': '%e --stdio',
|
||||
\ 'language': 'vim',
|
||||
\ 'project_root': function('ale_linters#vim#vimls#GetProjectRoot'),
|
||||
\})
|
65
sources_non_forked/ale/ale_linters/vim/vint.vim
Normal file
65
sources_non_forked/ale/ale_linters/vim/vint.vim
Normal file
@ -0,0 +1,65 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>, KabbAmine <amine.kabb@gmail.com>
|
||||
" Description: This file adds support for checking Vim code with Vint.
|
||||
|
||||
" This flag can be used to change enable/disable style issues.
|
||||
call ale#Set('vim_vint_show_style_issues', 1)
|
||||
call ale#Set('vim_vint_executable', 'vint')
|
||||
let s:enable_neovim = has('nvim') ? ' --enable-neovim' : ''
|
||||
let s:format = '-f "{file_path}:{line_number}:{column_number}: {severity}: {policy_name} - {description} (see {reference})"'
|
||||
|
||||
function! ale_linters#vim#vint#GetCommand(buffer, version) abort
|
||||
let l:can_use_no_color_flag = empty(a:version)
|
||||
\ || ale#semver#GTE(a:version, [0, 3, 7])
|
||||
|
||||
let l:warning_flag = ale#Var(a:buffer, 'vim_vint_show_style_issues') ? '-s' : '-w'
|
||||
|
||||
" Use the --stdin-display-name argument if supported, temp file otherwise.
|
||||
let l:stdin_or_temp = ale#semver#GTE(a:version, [0, 4, 0])
|
||||
\ ? ' --stdin-display-name %s -'
|
||||
\ : ' %t'
|
||||
|
||||
return '%e'
|
||||
\ . ' ' . l:warning_flag
|
||||
\ . (l:can_use_no_color_flag ? ' --no-color' : '')
|
||||
\ . s:enable_neovim
|
||||
\ . ' ' . s:format
|
||||
\ . l:stdin_or_temp
|
||||
endfunction
|
||||
|
||||
let s:word_regex_list = [
|
||||
\ '\v^Undefined variable: ([^ ]+)',
|
||||
\ '\v^Make the scope explicit like ...([^ ]+). ',
|
||||
\ '\v^.*start with a capital or contain a colon: ([^ ]+)',
|
||||
\ '\v.*instead of .(\=[=~]).',
|
||||
\]
|
||||
|
||||
function! ale_linters#vim#vint#Handle(buffer, lines) abort
|
||||
let l:loclist = ale#handlers#gcc#HandleGCCFormat(a:buffer, a:lines)
|
||||
|
||||
for l:item in l:loclist
|
||||
let l:match = []
|
||||
|
||||
for l:regex in s:word_regex_list
|
||||
let l:match = matchlist(l:item.text, l:regex)
|
||||
|
||||
if !empty(l:match)
|
||||
let l:item.end_col = l:item.col + len(l:match[1]) - 1
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
return l:loclist
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('vim', {
|
||||
\ 'name': 'vint',
|
||||
\ 'executable': {buffer -> ale#Var(buffer, 'vim_vint_executable')},
|
||||
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
|
||||
\ buffer,
|
||||
\ ale#Var(buffer, 'vim_vint_executable'),
|
||||
\ '%e --version',
|
||||
\ function('ale_linters#vim#vint#GetCommand'),
|
||||
\ )},
|
||||
\ 'callback': 'ale_linters#vim#vint#Handle',
|
||||
\})
|
Reference in New Issue
Block a user