mirror of
https://github.com/amix/vimrc
synced 2025-08-30 02:44:59 +08:00
Updated vim plugins
This commit is contained in:
@ -0,0 +1,46 @@
|
||||
" Author: Horacio Sanson <https://github.com/hsanson>
|
||||
" Description: Support ansible language server https://github.com/ansible/ansible-language-server/
|
||||
|
||||
call ale#Set('ansible_language_server_executable', 'ansible-language-server')
|
||||
call ale#Set('ansible_language_server_config', {})
|
||||
|
||||
function! ale_linters#ansible#ansible_language_server#Executable(buffer) abort
|
||||
return ale#Var(a:buffer, 'ansible_language_server_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#ansible#ansible_language_server#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#ansible#ansible_language_server#Executable(a:buffer)
|
||||
|
||||
return ale#Escape(l:executable) . ' --stdio'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#ansible#ansible_language_server#FindProjectRoot(buffer) abort
|
||||
let l:dir = fnamemodify(
|
||||
\ ale#path#FindNearestFile(a:buffer, 'ansible.cfg'),
|
||||
\ ':h'
|
||||
\)
|
||||
|
||||
if l:dir isnot# '.' && isdirectory(l:dir)
|
||||
return l:dir
|
||||
endif
|
||||
|
||||
let l:dir = fnamemodify(
|
||||
\ ale#path#FindNearestDirectory(a:buffer, '.git'),
|
||||
\ ':h:h'
|
||||
\)
|
||||
|
||||
if l:dir isnot# '.' && isdirectory(l:dir)
|
||||
return l:dir
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('ansible', {
|
||||
\ 'name': 'ansible-language-server',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': function('ale_linters#ansible#ansible_language_server#Executable'),
|
||||
\ 'command': function('ale_linters#ansible#ansible_language_server#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#ansible#ansible_language_server#FindProjectRoot'),
|
||||
\ 'lsp_config': {b -> ale#Var(b, 'ansible_language_server_config')}
|
||||
\})
|
@ -1,10 +1,15 @@
|
||||
" Author: Ty-Lucas Kelley <tylucaskelley@gmail.com>
|
||||
" Description: Adds support for markdownlint
|
||||
|
||||
call ale#Set('markdown_markdownlint_executable', 'markdownlint')
|
||||
call ale#Set('markdown_markdownlint_options', '')
|
||||
|
||||
function! ale_linters#markdown#markdownlint#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'markdown_markdownlint_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#markdown#markdownlint#GetCommand(buffer) abort
|
||||
let l:executable = 'markdownlint'
|
||||
let l:executable = ale_linters#markdown#markdownlint#GetExecutable(a:buffer)
|
||||
|
||||
let l:options = ale#Var(a:buffer, 'markdown_markdownlint_options')
|
||||
|
||||
@ -14,7 +19,7 @@ endfunction
|
||||
|
||||
call ale#linter#Define('markdown', {
|
||||
\ 'name': 'markdownlint',
|
||||
\ 'executable': 'markdownlint',
|
||||
\ 'executable': function('ale_linters#markdown#markdownlint#GetExecutable'),
|
||||
\ 'lint_file': 1,
|
||||
\ 'output_stream': 'both',
|
||||
\ 'command': function('ale_linters#markdown#markdownlint#GetCommand'),
|
||||
|
72
sources_non_forked/ale/ale_linters/sql/sqlfluff.vim
Normal file
72
sources_non_forked/ale/ale_linters/sql/sqlfluff.vim
Normal file
@ -0,0 +1,72 @@
|
||||
" Author: Carl Smedstad <carl.smedstad at protonmail dot com>
|
||||
" Description: sqlfluff for SQL files
|
||||
|
||||
let g:ale_sql_sqlfluff_executable =
|
||||
\ get(g:, 'ale_sql_sqlfluff_executable', 'sqlfluff')
|
||||
|
||||
let g:ale_sql_sqlfluff_options =
|
||||
\ get(g:, 'ale_sql_sqlfluff_options', '')
|
||||
|
||||
function! ale_linters#sql#sqlfluff#Executable(buffer) abort
|
||||
return ale#Var(a:buffer, 'sql_sqlfluff_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#sql#sqlfluff#Command(buffer) abort
|
||||
let l:executable = ale_linters#sql#sqlfluff#Executable(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'sql_sqlfluff_options')
|
||||
|
||||
let l:cmd =
|
||||
\ ale#Escape(l:executable)
|
||||
\ . ' lint'
|
||||
|
||||
let l:config_file = ale#path#FindNearestFile(a:buffer, '.sqlfluff')
|
||||
|
||||
if !empty(l:config_file)
|
||||
let l:cmd .= ' --config ' . ale#Escape(l:config_file)
|
||||
else
|
||||
let l:cmd .= ' --dialect ansi'
|
||||
endif
|
||||
|
||||
let l:cmd .=
|
||||
\ ' --format json '
|
||||
\ . l:options
|
||||
\ . ' %t'
|
||||
|
||||
return l:cmd
|
||||
endfunction
|
||||
|
||||
function! ale_linters#sql#sqlfluff#Handle(buffer, lines) abort
|
||||
let l:output = []
|
||||
let l:json_lines = ale#util#FuzzyJSONDecode(a:lines, [])
|
||||
|
||||
if empty(l:json_lines)
|
||||
return l:output
|
||||
endif
|
||||
|
||||
let l:json = l:json_lines[0]
|
||||
|
||||
" if there's no warning, 'result' is `null`.
|
||||
if empty(get(l:json, 'violations'))
|
||||
return l:output
|
||||
endif
|
||||
|
||||
for l:violation in get(l:json, 'violations', [])
|
||||
call add(l:output, {
|
||||
\ 'filename': l:json.filepath,
|
||||
\ 'lnum': l:violation.line_no,
|
||||
\ 'col': l:violation.line_pos,
|
||||
\ 'text': l:violation.description,
|
||||
\ 'code': l:violation.code,
|
||||
\ 'type': 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('sql', {
|
||||
\ 'name': 'sqlfluff',
|
||||
\ 'executable': function('ale_linters#sql#sqlfluff#Executable'),
|
||||
\ 'command': function('ale_linters#sql#sqlfluff#Command'),
|
||||
\ 'callback': 'ale_linters#sql#sqlfluff#Handle',
|
||||
\})
|
Reference in New Issue
Block a user