summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorHoracio Sanson <hsanson@gmail.com>2021-01-23 00:13:40 +0900
committerGitHub <noreply@github.com>2021-01-23 00:13:40 +0900
commitdb816b5c3fcf032e8053d23e6d48447eb9b08bb6 (patch)
tree970d8a2062372ee662b0e25c7538f4fc1135fcce /autoload
parenta1e6df987c28dd3e0efb7422f4ad85ee3bb3bebc (diff)
parent9bc4b468c20e91350cf1a6d3739f91f504e230ed (diff)
downloadale-db816b5c3fcf032e8053d23e6d48447eb9b08bb6.zip
Merge pull request #2782 from hsanson/2777-add-ibm-openapi-validator
Fix 2777 - Add IBM openapi validator
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim2
-rw-r--r--autoload/ale/fixers/prettier.vim1
-rw-r--r--autoload/ale/handlers/yamllint.vim39
3 files changed, 41 insertions, 1 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index f514466e..4564954b 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -102,7 +102,7 @@ let s:default_registry = {
\ },
\ 'prettier': {
\ 'function': 'ale#fixers#prettier#Fix',
-\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'html', 'yaml'],
+\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'html', 'yaml', 'openapi'],
\ 'description': 'Apply prettier to a file.',
\ },
\ 'prettier_eslint': {
diff --git a/autoload/ale/fixers/prettier.vim b/autoload/ale/fixers/prettier.vim
index e0f4972e..12c018af 100644
--- a/autoload/ale/fixers/prettier.vim
+++ b/autoload/ale/fixers/prettier.vim
@@ -83,6 +83,7 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort
\ 'markdown': 'markdown',
\ 'vue': 'vue',
\ 'yaml': 'yaml',
+ \ 'openapi': 'yaml',
\ 'html': 'html',
\}
diff --git a/autoload/ale/handlers/yamllint.vim b/autoload/ale/handlers/yamllint.vim
new file mode 100644
index 00000000..5e04577d
--- /dev/null
+++ b/autoload/ale/handlers/yamllint.vim
@@ -0,0 +1,39 @@
+function! ale#handlers#yamllint#GetCommand(buffer) abort
+ return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_yamllint_options'))
+ \ . ' -f parsable %t'
+endfunction
+
+function! ale#handlers#yamllint#Handle(buffer, lines) abort
+ " Matches patterns line the following:
+ " something.yaml:1:1: [warning] missing document start "---" (document-start)
+ " something.yml:2:1: [error] syntax error: expected the node content, but found '<stream end>'
+ let l:pattern = '\v^.*:(\d+):(\d+): \[(error|warning)\] (.+)$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ let l:item = {
+ \ 'lnum': l:match[1] + 0,
+ \ 'col': l:match[2] + 0,
+ \ 'text': l:match[4],
+ \ 'type': l:match[3] is# 'error' ? 'E' : 'W',
+ \}
+
+ let l:code_match = matchlist(l:item.text, '\v^(.+) \(([^)]+)\)$')
+
+ if !empty(l:code_match)
+ if l:code_match[2] is# 'trailing-spaces'
+ \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
+ " Skip warnings for trailing whitespace if the option is off.
+ continue
+ endif
+
+ let l:item.text = l:code_match[1]
+ let l:item.code = l:code_match[2]
+ endif
+
+ call add(l:output, l:item)
+ endfor
+
+ return l:output
+endfunction
+