Compare commits

..

6 Commits

Author SHA1 Message Date
w0rp
0c6370f41a Fix #2276 - Replace a potentially infinite loop for hie 2019-02-07 16:26:04 +00:00
w0rp
0ed3fbc596 Fix #2263 - detailed Flow errors should show the original message 2019-02-01 13:04:18 +00:00
w0rp
b315667ebe Fix #2192 - Handle more ignore-pattern messages for ESLint 2019-01-27 12:10:03 +00:00
w0rp
0495a8be20 Merge pull request #2153 from deltaskelta/gqlint-fix
changed gqlint to lint the file on disk
2018-12-18 10:20:44 +00:00
w0rp
6ef54842de Merge pull request #2136 from hsanson/368-chktex-latex-report-errors-from-wrong-file
Fix 368 - Lacheck reports errors from input{} files.
2018-12-16 13:18:51 +00:00
w0rp
df76d8a51c Revert "Merge pull request #2083 from zackhsi/scalac-until-jvm"
This reverts commit 1c89495d77, reversing
changes made to 4b4b09593b.
2018-12-03 20:42:06 +00:00
2116 changed files with 12977 additions and 71762 deletions

View File

@@ -5,25 +5,6 @@ clone_depth: 10
# Use the directory C:\testplugin so test directories will mostly work. # Use the directory C:\testplugin so test directories will mostly work.
clone_folder: C:\testplugin clone_folder: C:\testplugin
branches:
only:
- master
- /v\d+\.\d+\.(x|\d+)/
# Skip running Windows tests if we only change files that can't impact
# Windows tests.
skip_commits:
files:
- '.github/**/*'
- .gitattributes
- Dockerfile
- README.md
- doc/*
- lua/*
- run-tests
- supported-tools.md
- syntax/*
# Cache the vim and vader directories between builds. # Cache the vim and vader directories between builds.
cache: cache:
- C:\vim -> .appveyor.yml - C:\vim -> .appveyor.yml
@@ -33,9 +14,6 @@ init:
# Stop git from changing newlines # Stop git from changing newlines
- git config --global core.autocrlf input - git config --global core.autocrlf input
# NOTE: If you change the Vim or Vader versions here, please also update the
# instructions for running tests on Windows in ale-development.txt
install: install:
# Download and unpack Vim # Download and unpack Vim
- ps: >- - ps: >-

View File

@@ -12,7 +12,3 @@ insert_final_newline = true
indent_style = space indent_style = space
indent_size = 4 indent_size = 4
trim_trailing_whitespace = true trim_trailing_whitespace = true
[*.vader]
indent_style = space
indent_size = 2

View File

@@ -1,6 +0,0 @@
---
blank_issues_enabled: false
contact_links:
- name: Ask for Help
url: https://github.com/dense-analysis/ale/discussions/new?category=q-a-ask-for-help-with-problems
about: Ask for Help in ALE Discussions

View File

@@ -1,6 +1,5 @@
--- ---
name: Report a bug name: Report a bug
labels: bug
about: Report a bug with ALE. about: Report a bug with ALE.
--- ---
@@ -28,9 +27,8 @@ Operating System: <!-- Describe your operating system version. -->
<!-- Describe what went wrong here. Be specific. --> <!-- Describe what went wrong here. Be specific. -->
Something went wrong in specifically this place, and I also searched through both open and closed issues for the same problem before reporting a bug here. Something went wrong in specifically this place, and I also searched through
both open and closed issues for the same problem before reporting a bug here.
Are you having trouble configuring ALE? Try asking for help on [Stack Exchange](https://vi.stackexchange.com/) or perhaps on [Reddit](https://www.reddit.com/r/vim/) instead. The GitHub issue tracker should be used for reporting bugs or asking for new features.
## Reproducing the bug ## Reproducing the bug
@@ -40,9 +38,7 @@ Are you having trouble configuring ALE? Try asking for help on [Stack Exchange](
2. Then this happened. 2. Then this happened.
### :ALEInfo ### :ALEInfo
<details>
<summary>Expand</summary> <!-- Paste the output of :ALEInfo here. Try :ALEInfoToClipboard -->
<!-- Paste the output of :ALEInfo here. Try :ALEInfo -clipboard --> <!-- Make sure to run :ALEInfo from the buffer where the bug occurred. -->
<!-- Make sure to run :ALEInfo from the buffer where the bug occurred. --> <!-- Read the output. You might figure out what went wrong yourself. -->
<!-- Read the output. You might figure out what went wrong yourself. -->
</details>

View File

@@ -1,6 +1,5 @@
--- ---
name: Suggest a new linter or fixer name: Suggest a new linter or fixer
labels: new tool
about: Suggest a new tool ALE can officially integrate with. about: Suggest a new tool ALE can officially integrate with.
--- ---

View File

@@ -1,6 +1,5 @@
--- ---
name: Suggest an improvement name: Suggest an improvement
labels: enhancement
about: Suggest some way to improve ALE, or add a new feature. about: Suggest some way to improve ALE, or add a new feature.
--- ---

View File

@@ -2,7 +2,7 @@
Before creating a pull request, do the following. Before creating a pull request, do the following.
* Read the Contributing guide linked above first. * Read the Contributing guide linked above first.
* Read the documentation that comes with ALE with `:help ale-dev`. * Read the documentation that comes with ALE with `:help ale-development`.
Have fun! Have fun!
--> -->
@@ -10,4 +10,4 @@ Have fun!
Where are the tests? Have you added tests? Have you updated the tests? Read the Where are the tests? Have you added tests? Have you updated the tests? Read the
comment above and the documentation referenced in it first. Write tests! comment above and the documentation referenced in it first. Write tests!
Seriously, read `:help ale-dev` and write tests. Seriously, read `:help ale-development` and write tests.

17
.github/stale.yml vendored
View File

@@ -1,17 +0,0 @@
---
# This configuration closes stale PRs after 56 + 7 days.
# That's 8 weeks until stale bot complains, and a week until it closes a PR.
# Issues in ALE are never, ever stale. They are either resolved or not.
only: pulls
daysUntilStale: 56
daysUntilClose: 7
exemptLabels: []
staleLabel: stale
markComment: >
This pull request has been automatically marked as stale because it has not
been updated recently. Make sure to write tests and document your changes.
See `:help ale-dev` for information on writing tests.
If your pull request is good to merge, bother w0rp or another maintainer
again, and get them to merge it.
closeComment: false

View File

@@ -1,38 +0,0 @@
---
name: CI
on: # yamllint disable-line rule:truthy
push:
branches: [ master ] # yamllint disable-line rule:brackets
tags:
- v[0-9]+.[0-9]+.x
- v[0-9]+.[0-9]+.[0-9]+
pull_request:
branches: [ master ] # yamllint disable-line rule:brackets
jobs:
build_image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build docker run image
shell: bash
env:
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_HUB_PASS: ${{ secrets.DOCKER_HUB_PASS }}
run: ./run-tests --build-image
test_ale:
needs: build_image
runs-on: ubuntu-latest
strategy:
matrix:
vim-version:
- '--vim-80-only'
- '--vim-90-only'
- '--neovim-07-only'
- '--neovim-08-only'
- '--lua-only'
- '--linters-only'
steps:
- uses: actions/checkout@v4
- name: Run tests
run: ./run-tests -v ${{ matrix.vim-version }}

5
.gitignore vendored
View File

@@ -1,12 +1,7 @@
!.editorconfig !.editorconfig
*.obj *.obj
*.pyc
# Ignore all hidden files everywhere.
# Use `git add -f` to add hidden files.
.* .*
/doc/tags /doc/tags
/init.vim /init.vim
/test/ale-info-test-file /test/ale-info-test-file
/vader_output
__pycache__
tags tags

View File

@@ -1,19 +0,0 @@
{
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"diagnostics.globals": [
"vim"
],
"workspace.ignoreDir": [
"test"
],
"workspace.library": [
"/usr/share/nvim/runtime/lua"
],
"runtime.pathStrict": true,
"runtime.path": [
"lua/?.lua",
"lua/?/init.lua"
],
"runtime.version": "LuaJIT",
"hint.enable": false
}

12
.travis.yml Normal file
View File

@@ -0,0 +1,12 @@
---
sudo: required
services:
- docker
language: generic
env:
- OPTIONS=--vim-80-only
- OPTIONS=--vim-81-only
- OPTIONS=--neovim-only
- OPTIONS=--linters-only
script: |
./run-tests -v $OPTIONS

View File

@@ -1,5 +0,0 @@
policies:
# Disable a violation that is thrown randomly for reasons I still
# do not understand.
ProhibitMissingScriptEncoding:
enabled: false

View File

@@ -1,32 +1,20 @@
ARG TESTBED_VIM_VERSION=24 FROM tweekmonster/vim-testbed:latest
FROM testbed/vim:${TESTBED_VIM_VERSION} RUN install_vim -tag v8.0.0027 -build \
-tag v8.1.0204 -build \
-tag neovim:v0.2.0 -build \
-tag neovim:v0.3.0 -build
ENV PACKAGES="\ ENV PACKAGES="\
lua5.1 \
lua5.1-dev \
lua5.1-busted \
bash \ bash \
git \ git \
python2 \ python \
python3 \ py-pip \
py3-pip \
grep \
sed \
" "
RUN apk --update add $PACKAGES && \ RUN apk --update add $PACKAGES && \
rm -rf /var/cache/apk/* /tmp/* /var/tmp/* rm -rf /var/cache/apk/* /tmp/* /var/tmp/*
RUN install_vim -tag v8.0.0027 -build \ RUN pip install vim-vint==0.3.15
-tag v9.0.0297 -build \
-tag neovim:v0.7.0 -build \
-tag neovim:v0.8.0 -build
RUN pip install vim-vint==0.3.21
RUN git clone https://github.com/junegunn/vader.vim vader && \ RUN git clone https://github.com/junegunn/vader.vim vader && \
cd vader && git checkout c6243dd81c98350df4dec608fa972df98fa2a3af cd vader && git checkout c6243dd81c98350df4dec608fa972df98fa2a3af
ARG GIT_VERSION
LABEL Version=${GIT_VERSION}
LABEL Name=denseanalysis/ale

View File

@@ -1,4 +1,4 @@
Copyright (c) 2016-2023, Dense Analysis Copyright (c) 2016-2018, w0rp <devw0rp@gmail.com>
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without

807
README.md

File diff suppressed because it is too large Load Diff

View File

@@ -1,26 +0,0 @@
" Author: Bartek Jasicki http://github.com/thindil
" Description: Support for Ada Language Server
call ale#Set('ada_adals_executable', 'ada_language_server')
call ale#Set('ada_adals_project', 'default.gpr')
call ale#Set('ada_adals_encoding', 'utf-8')
function! ale_linters#ada#adals#GetAdaLSConfig(buffer) abort
return {
\ 'ada.projectFile': ale#Var(a:buffer, 'ada_adals_project'),
\ 'ada.defaultCharset': ale#Var(a:buffer, 'ada_adals_encoding')
\}
endfunction
function! ale_linters#ada#adals#GetRootDirectory(buffer) abort
return fnamemodify(bufname(a:buffer), ':p:h')
endfunction
call ale#linter#Define('ada', {
\ 'name': 'adals',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'ada_adals_executable')},
\ 'command': '%e',
\ 'project_root': function('ale_linters#ada#adals#GetRootDirectory'),
\ 'lsp_config': function('ale_linters#ada#adals#GetAdaLSConfig')
\})

View File

@@ -1,5 +0,0 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for Ada files.
call ale#handlers#cspell#DefineLinter('ada')

View File

@@ -12,13 +12,13 @@ function! ale_linters#ada#gcc#GetCommand(buffer) abort
" the .ali file may be created even if no code generation is attempted. " the .ali file may be created even if no code generation is attempted.
" The output file name must match the source file name (except for the " The output file name must match the source file name (except for the
" extension), so here we cannot use the null file as output. " extension), so here we cannot use the null file as output.
let l:tmp_dir = fnamemodify(ale#command#CreateDirectory(a:buffer), ':p') let l:tmp_dir = fnamemodify(ale#engine#CreateDirectory(a:buffer), ':p')
let l:out_file = l:tmp_dir . fnamemodify(bufname(a:buffer), ':t:r') . '.o' let l:out_file = l:tmp_dir . fnamemodify(bufname(a:buffer), ':t:r') . '.o'
" -gnatc: Check syntax and semantics only (no code generation attempted) " -gnatc: Check syntax and semantics only (no code generation attempted)
return '%e -x ada -c -gnatc' return '%e -x ada -c -gnatc'
\ . ' -o ' . ale#Escape(l:out_file) \ . ' -o ' . ale#Escape(l:out_file)
\ . ' -I %s:h' \ . ' -I ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(ale#Var(a:buffer, 'ada_gcc_options')) \ . ale#Pad(ale#Var(a:buffer, 'ada_gcc_options'))
\ . ' %t' \ . ' %t'
endfunction endfunction
@@ -48,7 +48,7 @@ endfunction
call ale#linter#Define('ada', { call ale#linter#Define('ada', {
\ 'name': 'gcc', \ 'name': 'gcc',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'ada_gcc_executable')}, \ 'executable_callback': ale#VarFunc('ada_gcc_executable'),
\ 'command': function('ale_linters#ada#gcc#GetCommand'), \ 'command_callback': 'ale_linters#ada#gcc#GetCommand',
\ 'callback': 'ale_linters#ada#gcc#Handle', \ 'callback': 'ale_linters#ada#gcc#Handle',
\}) \})

View File

@@ -1,4 +1,4 @@
" Authors: Bjorn Neergaard <bjorn@neersighted.com>, Vytautas Macionis <vytautas.macionis@manomail.de> " Author: Bjorn Neergaard <bjorn@neersighted.com>
" Description: ansible-lint for ansible-yaml files " Description: ansible-lint for ansible-yaml files
call ale#Set('ansible_ansible_lint_executable', 'ansible-lint') call ale#Set('ansible_ansible_lint_executable', 'ansible-lint')
@@ -7,7 +7,7 @@ function! ale_linters#ansible#ansible_lint#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'ansible_ansible_lint_executable') return ale#Var(a:buffer, 'ansible_ansible_lint_executable')
endfunction endfunction
function! ale_linters#ansible#ansible_lint#Handle(buffer, version, lines) abort function! ale_linters#ansible#ansible_lint#Handle(buffer, lines) abort
for l:line in a:lines[:10] for l:line in a:lines[:10]
if match(l:line, '^Traceback') >= 0 if match(l:line, '^Traceback') >= 0
return [{ return [{
@@ -18,121 +18,39 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, version, lines) abort
endif endif
endfor endfor
let l:version_group = ale#semver#GTE(a:version, [6, 0, 0]) ? '>=6.0.0' : " Matches patterns line the following:
\ ale#semver#GTE(a:version, [5, 0, 0]) ? '>=5.0.0' : "
\ '<5.0.0' " test.yml:35: [EANSIBLE0002] Trailing whitespace
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: \[?([[:alnum:]]+)\]? (.*)$'
let l:output = [] let l:output = []
if '>=6.0.0' is# l:version_group for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:error_codes = { 'blocker': 'E', 'critical': 'E', 'major': 'W', 'minor': 'W', 'info': 'I' } let l:code = l:match[4]
let l:linter_issues = ale#util#FuzzyJSONDecode(a:lines, [])
for l:issue in l:linter_issues if l:code is# 'EANSIBLE0002'
if ale#path#IsBufferPath(a:buffer, l:issue.location.path) \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
if exists('l:issue.location.positions') " Skip warnings for trailing whitespace if the option is off.
let l:coord_keyname = 'positions' continue
else endif
let l:coord_keyname = 'lines'
endif
let l:column_member = printf( if ale#path#IsBufferPath(a:buffer, l:match[1])
\ 'l:issue.location.%s.begin.column', l:coord_keyname call add(l:output, {
\) \ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
call add(l:output, { \ 'text': l:match[5],
\ 'lnum': exists(l:column_member) ? l:issue.location[l:coord_keyname].begin.line : \ 'code': l:code,
\ l:issue.location[l:coord_keyname].begin, \ 'type': l:code[:0] is# 'E' ? 'E' : 'W',
\ 'col': exists(l:column_member) ? l:issue.location[l:coord_keyname].begin.column : 0, \})
\ 'text': l:issue.check_name, endif
\ 'detail': l:issue.description, endfor
\ 'code': l:issue.severity,
\ 'type': l:error_codes[l:issue.severity],
\})
endif
endfor
endif
if '>=5.0.0' is# l:version_group
" Matches patterns line the following:
" test.yml:3:148: syntax-check 'var' is not a valid attribute for a Play
" roles/test/tasks/test.yml:8: [package-latest] [VERY_LOW] Package installs should not use latest
" D:\test\tasks\test.yml:8: [package-latest] [VERY_LOW] package installs should not use latest
let l:pattern = '\v^(%([a-zA-Z]:)?[^:]+):(\d+):%((\d+):)? %(\[([-[:alnum:]]+)\]) %(\[([_[:alnum:]]+)\]) (.*)$'
let l:error_codes = { 'VERY_HIGH': 'E', 'HIGH': 'E', 'MEDIUM': 'W', 'LOW': 'W', 'VERY_LOW': 'W', 'INFO': 'I' }
for l:match in ale#util#GetMatches(a:lines, l:pattern)
if ale#path#IsBufferPath(a:buffer, l:match[1])
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'text': l:match[6],
\ 'code': l:match[4],
\ 'type': l:error_codes[l:match[5]],
\})
endif
endfor
endif
if '<5.0.0' is# l:version_group
" Matches patterns line the following:
" test.yml:35: [EANSIBLE0002] Trailing whitespace
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: \[?([[:alnum:]]+)\]? (.*)$'
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:code = l:match[4]
if l:code is# 'EANSIBLE0002'
\&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
" Skip warnings for trailing whitespace if the option is off.
continue
endif
if ale#path#IsBufferPath(a:buffer, l:match[1])
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'text': l:match[5],
\ 'code': l:code,
\ 'type': l:code[:0] is# 'E' ? 'E' : 'W',
\})
endif
endfor
endif
return l:output return l:output
endfunction endfunction
function! ale_linters#ansible#ansible_lint#GetCommand(buffer, version) abort
let l:commands = {
\ '>=6.0.0': '%e --nocolor -f json -x yaml %s',
\ '>=5.0.0': '%e --nocolor --parseable-severity -x yaml %s',
\ '<5.0.0': '%e --nocolor -p %t'
\}
let l:command = ale#semver#GTE(a:version, [6, 0]) ? l:commands['>=6.0.0'] :
\ ale#semver#GTE(a:version, [5, 0]) ? l:commands['>=5.0.0'] :
\ l:commands['<5.0.0']
return l:command
endfunction
call ale#linter#Define('ansible', { call ale#linter#Define('ansible', {
\ 'name': 'ansible_lint', \ 'name': 'ansible_lint',
\ 'aliases': ['ansible', 'ansible-lint'], \ 'aliases': ['ansible', 'ansible-lint'],
\ 'executable': function('ale_linters#ansible#ansible_lint#GetExecutable'), \ 'executable_callback': 'ale_linters#ansible#ansible_lint#GetExecutable',
\ 'command': {buffer -> ale#semver#RunWithVersionCheck( \ 'command': '%e -p %t',
\ buffer, \ 'callback': 'ale_linters#ansible#ansible_lint#Handle',
\ ale_linters#ansible#ansible_lint#GetExecutable(buffer),
\ '%e --version',
\ function('ale_linters#ansible#ansible_lint#GetCommand'),
\ )},
\ 'lint_file': 1,
\ 'callback': {buffer, lines -> ale#semver#RunWithVersionCheck(
\ buffer,
\ ale_linters#ansible#ansible_lint#GetExecutable(buffer),
\ '%e --version',
\ {buffer, version -> ale_linters#ansible#ansible_lint#Handle(
\ buffer,
\ l:version,
\ lines)},
\ )},
\}) \})

View File

@@ -1,47 +0,0 @@
" 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#language_server#Executable(buffer) abort
return ale#Var(a:buffer, 'ansible_language_server_executable')
endfunction
function! ale_linters#ansible#language_server#GetCommand(buffer) abort
let l:executable = ale_linters#ansible#language_server#Executable(a:buffer)
return ale#Escape(l:executable) . ' --stdio'
endfunction
function! ale_linters#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': 'language_server',
\ 'aliases': ['ansible_language_server', 'ansible-language-server'],
\ 'lsp': 'stdio',
\ 'executable': function('ale_linters#ansible#language_server#Executable'),
\ 'command': function('ale_linters#ansible#language_server#GetCommand'),
\ 'project_root': function('ale_linters#ansible#language_server#FindProjectRoot'),
\ 'lsp_config': {b -> ale#Var(b, 'ansible_language_server_config')}
\})

View File

@@ -1,12 +0,0 @@
" Author: Leo <thinkabit.ukim@gmail.com>
" Description: apkbuild-lint from atools linter for APKBUILDs
call ale#Set('apkbuild_apkbuild_lint_executable', 'apkbuild-lint')
call ale#linter#Define('apkbuild', {
\ 'name': 'apkbuild_lint',
\ 'output_stream': 'stdout',
\ 'executable': {b -> ale#Var(b, 'apkbuild_apkbuild_lint_executable')},
\ 'command': '%e %t',
\ 'callback': 'ale#handlers#atools#Handle',
\})

View File

@@ -1,12 +0,0 @@
" Author: Leo <thinkabit.ukim@gmail.com>
" Description: secfixes-check from atools linter for APKBUILDs
call ale#Set('apkbuild_secfixes_check_executable', 'secfixes-check')
call ale#linter#Define('apkbuild', {
\ 'name': 'secfixes_check',
\ 'output_stream': 'stdout',
\ 'executable': {b -> ale#Var(b, 'apkbuild_secfixes_check_executable')},
\ 'command': '%e %t',
\ 'callback': 'ale#handlers#atools#Handle',
\})

View File

@@ -1,4 +1,11 @@
" Author: Johannes Wienke <languitar@semipol.de> " Author: Johannes Wienke <languitar@semipol.de>
" Description: alex for asciidoc files " Description: alex for asciidoc files
call ale#handlers#alex#DefineLinter('asciidoc', '--text') call ale#linter#Define('help', {
\ 'name': 'alex',
\ 'executable': 'alex',
\ 'command': 'alex %s -t',
\ 'output_stream': 'stderr',
\ 'callback': 'ale#handlers#alex#Handle',
\ 'lint_file': 1,
\})

View File

@@ -1,5 +0,0 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for ASCIIDoc files.
call ale#handlers#cspell#DefineLinter('asciidoc')

View File

@@ -1,5 +0,0 @@
" Author: Horacio Sanson (hsanson [ät] gmail.com)
" Description: languagetool for asciidoc files, copied from markdown.
call ale#handlers#languagetool#DefineLinter('asciidoc')

View File

@@ -1,9 +0,0 @@
" Author: TANIGUCHI Masaya <ta2gch@gmail.com>
" Description: textlint for AsciiDoc files
call ale#linter#Define('asciidoc', {
\ 'name': 'textlint',
\ 'executable': function('ale#handlers#textlint#GetExecutable'),
\ 'command': function('ale#handlers#textlint#GetCommand'),
\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput',
\})

View File

@@ -5,11 +5,8 @@ call ale#Set('asm_gcc_executable', 'gcc')
call ale#Set('asm_gcc_options', '-Wall') call ale#Set('asm_gcc_options', '-Wall')
function! ale_linters#asm#gcc#GetCommand(buffer) abort function! ale_linters#asm#gcc#GetCommand(buffer) abort
" `-o /dev/null` or `-o null` is needed to catch all errors, return '%e -x assembler -fsyntax-only '
" -fsyntax-only doesn't catch everything. \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
return '%e -x assembler'
\ . ' -o ' . g:ale#util#nul_file
\ . '-iquote %s:h'
\ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -' \ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -'
endfunction endfunction
@@ -31,7 +28,7 @@ endfunction
call ale#linter#Define('asm', { call ale#linter#Define('asm', {
\ 'name': 'gcc', \ 'name': 'gcc',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'asm_gcc_executable')}, \ 'executable_callback': ale#VarFunc('asm_gcc_executable'),
\ 'command': function('ale_linters#asm#gcc#GetCommand'), \ 'command_callback': 'ale_linters#asm#gcc#GetCommand',
\ 'callback': 'ale_linters#asm#gcc#Handle', \ 'callback': 'ale_linters#asm#gcc#Handle',
\}) \})

View File

@@ -1,37 +0,0 @@
" Author: uidops <uidops@protonmail.com>
" Description: llvm-mc linter for asm files
call ale#Set('asm_llvm_mc_executable', 'llvm-mc')
call ale#Set('asm_llvm_mc_options', '')
function! ale_linters#asm#llvm_mc#GetCommand(buffer) abort
return '%e --assemble'
\ . ' --filetype=asm'
\ . ' -o ' . g:ale#util#nul_file
\ . ' ' . ale#Var(a:buffer, 'asm_llvm_mc_options')
endfunction
function! ale_linters#asm#llvm_mc#Handle(buffer, lines) abort
let l:pattern = '^.\+:\(\d\+\):\(\d\+\): \([^:]\+\): \(.\+\)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'type': l:match[3] =~? 'error' ? 'E' : 'W',
\ 'text': l:match[4],
\})
endfor
return l:output
endfunction
call ale#linter#Define('asm', {
\ 'name': 'llvm_mc',
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'asm_llvm_mc_executable')},
\ 'command': function('ale_linters#asm#llvm_mc#GetCommand'),
\ 'callback': 'ale_linters#asm#llvm_mc#Handle',
\})

View File

@@ -1,11 +0,0 @@
" Author: Hyuksang Kwon <gwonhyuksang@gmail.com>
" Description: eslint for astro files
call ale#linter#Define('astro', {
\ 'name': 'eslint',
\ 'output_stream': 'both',
\ 'executable': function('ale#handlers#eslint#GetExecutable'),
\ 'cwd': function('ale#handlers#eslint#GetCwd'),
\ 'command': function('ale#handlers#eslint#GetCommand'),
\ 'callback': 'ale#handlers#eslint#HandleJSON',
\})

View File

@@ -1,36 +0,0 @@
" Author: Utkarsh Verma <utkarshverma@protonmail.com>
" Description: AVRA linter for avra syntax.
call ale#Set('avra_avra_executable', 'avra')
call ale#Set('avra_avra_options', '')
function! ale_linters#avra#avra#GetCommand(buffer) abort
return '%e'
\ . ' %t'
\ . ale#Pad(ale#Var(a:buffer, 'avra_avra_options'))
\ . ' -o ' . g:ale#util#nul_file
endfunction
function! ale_linters#avra#avra#Handle(buffer, lines) abort
" Note that we treat 'fatal' as errors.
let l:pattern = '^\S\+(\(\d\+\))\s\+:\s\+\(\S\+\)\s\+:\s\+\(.\+\)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'type': l:match[2] =~? 'Error' ? 'E' : 'W',
\ 'text': l:match[3],
\})
endfor
return l:output
endfunction
call ale#linter#Define('avra', {
\ 'name': 'avra',
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'avra_avra_executable')},
\ 'command': function('ale_linters#avra#avra#GetCommand'),
\ 'callback': 'ale_linters#avra#avra#Handle',
\})

View File

@@ -1,5 +1,5 @@
" Author: kmarc <korondi.mark@gmail.com> " Author: kmarc <korondi.mark@gmail.com>
" Description: This file adds support for using GNU awk with scripts. " Description: This file adds support for using GNU awk with sripts.
call ale#Set('awk_gawk_executable', 'gawk') call ale#Set('awk_gawk_executable', 'gawk')
call ale#Set('awk_gawk_options', '') call ale#Set('awk_gawk_options', '')
@@ -9,15 +9,14 @@ function! ale_linters#awk#gawk#GetCommand(buffer) abort
" gawk from attempting to execute the body of the script " gawk from attempting to execute the body of the script
" it is linting. " it is linting.
return '%e --source ' . ale#Escape('BEGIN { exit } END { exit 1 }') return '%e --source ' . ale#Escape('BEGIN { exit } END { exit 1 }')
\ . ' --lint'
\ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options')) \ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options'))
\ . ' -f %t /dev/null' \ . ' -f %t --lint /dev/null'
endfunction endfunction
call ale#linter#Define('awk', { call ale#linter#Define('awk', {
\ 'name': 'gawk', \ 'name': 'gawk',
\ 'executable': {b -> ale#Var(b, 'awk_gawk_executable')}, \ 'executable_callback': ale#VarFunc('awk_gawk_executable'),
\ 'command': function('ale_linters#awk#gawk#GetCommand'), \ 'command_callback': 'ale_linters#awk#gawk#GetCommand',
\ 'callback': 'ale#handlers#gawk#HandleGawkFormat', \ 'callback': 'ale#handlers#gawk#HandleGawkFormat',
\ 'output_stream': 'both' \ 'output_stream': 'both'
\}) \})

View File

@@ -1,4 +0,0 @@
" Author: Ian2020 <https://github.com/Ian2020>
" Description: shellcheck linter for bats scripts.
call ale#handlers#shellcheck#DefineLinter('bats')

View File

@@ -1,80 +0,0 @@
" Author: Horacio Sanson - https://github.com/hsanson
" Description: Support for bibclean linter for BibTeX files.
call ale#Set('bib_bibclean_executable', 'bibclean')
function! ale_linters#bib#bibclean#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'bib_bibclean_executable')
return ale#Escape(l:executable) . ' -file-position '
endfunction
function! ale_linters#bib#bibclean#get_type(str) abort
if a:str is# '??'
return 'E'
else
return 'W'
endif
endfunction
function! ale_linters#bib#bibclean#match_msg(line) abort
" Legacy message pattern works for bibclean <= v2.11.4. If empty, try
" the new message pattern for bibtex > v2.11.4
let l:matches_legacy = matchlist(a:line, '^\(.*\) "stdin", line \(\d\+\): \(.*\)$')
return ! empty(l:matches_legacy) ? l:matches_legacy
\ : matchlist(a:line, '^\(.*\) stdin:\(\d\+\):\(.*\)$')
endfunction
function! ale_linters#bib#bibclean#match_entry(line) abort
return matchlist(a:line, 'Entry input byte=.* line=\(.*\) column=\(.*\) output .*$')
endfunction
function! ale_linters#bib#bibclean#match_value(line) abort
return matchlist(a:line, 'Value input byte=.* line=\(.*\) column=\(.*\) output .*$')
endfunction
function! ale_linters#bib#bibclean#Handle(buffer, lines) abort
let l:output = []
let l:type = 'E'
let l:msg = ''
for l:line in a:lines
if empty(l:msg)
let l:mlist = ale_linters#bib#bibclean#match_msg(l:line)
if !empty(l:mlist)
let l:msg = l:mlist[3]
let l:type = ale_linters#bib#bibclean#get_type(l:mlist[1])
endif
else
if l:type is# 'E'
let l:mlist = ale_linters#bib#bibclean#match_entry(l:line)
else
let l:mlist = ale_linters#bib#bibclean#match_value(l:line)
endif
if !empty(l:mlist)
call add(l:output, {
\ 'lnum': l:mlist[1],
\ 'col': l:mlist[2],
\ 'text': l:msg,
\ 'type': l:type
\})
let l:msg = ''
endif
endif
endfor
return l:output
endfunction
call ale#linter#Define('bib', {
\ 'name': 'bibclean',
\ 'executable': {b -> ale#Var(b, 'bib_bibclean_executable')},
\ 'command': function('ale_linters#bib#bibclean#GetCommand'),
\ 'output_stream': 'stderr',
\ 'callback': 'ale_linters#bib#bibclean#Handle',
\})

View File

@@ -1,69 +0,0 @@
" Author: Carl Smedstad <carl.smedstad at protonmail dot com>
" Description: az_bicep for bicep files
let g:ale_bicep_az_bicep_executable =
\ get(g:, 'ale_bicep_az_bicep_executable', 'az')
let g:ale_bicep_az_bicep_options =
\ get(g:, 'ale_bicep_az_bicep_options', '')
function! ale_linters#bicep#az_bicep#Executable(buffer) abort
return ale#Var(a:buffer, 'bicep_az_bicep_executable')
endfunction
function! ale_linters#bicep#az_bicep#Command(buffer) abort
let l:executable = ale_linters#bicep#az_bicep#Executable(a:buffer)
let l:options = ale#Var(a:buffer, 'bicep_az_bicep_options')
if has('win32')
let l:nullfile = 'NUL'
else
let l:nullfile = '/dev/null'
endif
return ale#Escape(l:executable)
\ . ' bicep build --outfile '
\ . l:nullfile
\ . ' --file '
\ . '%s '
\ . l:options
endfunction
function! ale_linters#bicep#az_bicep#Handle(buffer, lines) abort
let l:pattern = '\v^([A-Z]+)?(:\s)?(.*)\((\d+),(\d+)\)\s:\s([a-zA-Z]*)\s([-a-zA-Z0-9]*):\s(.*)'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
if l:match[1] is# 'ERROR'
let l:type = 'E'
elseif l:match[1] is# 'WARNING'
let l:type = 'W'
elseif l:match[6] is# 'Error'
let l:type = 'E'
elseif l:match[6] is# 'Warning'
let l:type = 'W'
else
let l:type = 'I'
endif
call add(l:output, {
\ 'filename': l:match[3],
\ 'lnum': l:match[4] + 0,
\ 'col': l:match[5] + 0,
\ 'type': l:type,
\ 'code': l:match[7],
\ 'text': l:match[8],
\})
endfor
return l:output
endfunction
call ale#linter#Define('bicep', {
\ 'name': 'az_bicep',
\ 'executable': function('ale_linters#bicep#az_bicep#Executable'),
\ 'command': function('ale_linters#bicep#az_bicep#Command'),
\ 'callback': 'ale_linters#bicep#az_bicep#Handle',
\ 'output_stream': 'stderr',
\ 'lint_file': 1,
\})

View File

@@ -1,65 +0,0 @@
" Author: Carl Smedstad <carl.smedstad at protonmail dot com>
" Description: bicep for bicep files
let g:ale_bicep_bicep_executable =
\ get(g:, 'ale_bicep_bicep_executable', 'bicep')
let g:ale_bicep_bicep_options =
\ get(g:, 'ale_bicep_bicep_options', '')
function! ale_linters#bicep#bicep#Executable(buffer) abort
return ale#Var(a:buffer, 'bicep_bicep_executable')
endfunction
function! ale_linters#bicep#bicep#Command(buffer) abort
let l:executable = ale_linters#bicep#bicep#Executable(a:buffer)
let l:options = ale#Var(a:buffer, 'bicep_bicep_options')
if has('win32')
let l:nullfile = 'NUL'
else
let l:nullfile = '/dev/null'
endif
return ale#Escape(l:executable)
\ . ' build --outfile '
\ . l:nullfile
\ . ' '
\ . l:options
\ . ' %s'
endfunction
function! ale_linters#bicep#bicep#Handle(buffer, lines) abort
let l:pattern = '\v^(.*)\((\d+),(\d+)\)\s:\s([a-zA-Z]*)\s([-a-zA-Z0-9]*):\s(.*)'
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# 'Warning'
let l:type = 'W'
else
let l:type = 'I'
endif
call add(l:output, {
\ 'filename': l:match[1],
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'type': l:type,
\ 'code': l:match[5],
\ 'text': l:match[6],
\})
endfor
return l:output
endfunction
call ale#linter#Define('bicep', {
\ 'name': 'bicep',
\ 'executable': function('ale_linters#bicep#bicep#Executable'),
\ 'command': function('ale_linters#bicep#bicep#Command'),
\ 'callback': 'ale_linters#bicep#bicep#Handle',
\ 'output_stream': 'both',
\ 'lint_file': 1,
\})

View File

@@ -1,47 +0,0 @@
" Author: offa
" Description: oelint-adv for BitBake files
call ale#Set('bitbake_oelint_adv_executable', 'oelint-adv')
call ale#Set('bitbake_oelint_adv_options', '')
call ale#Set('bitbake_oelint_adv_config', '.oelint.cfg')
function! ale_linters#bitbake#oelint_adv#Command(buffer) abort
let l:config_file = ale#path#FindNearestFile(a:buffer,
\ ale#Var(a:buffer, 'bitbake_oelint_adv_config'))
return ((!empty(l:config_file))
\ ? 'OELINT_CONFIG=' . ale#Escape(l:config_file) . ' '
\ : '')
\ . '%e --quiet '
\ . ale#Pad(ale#Var(a:buffer, 'bitbake_oelint_adv_options')) . '%s'
endfunction
function! ale_linters#bitbake#oelint_adv#Handle(buffer, lines) abort
let l:pattern = '\v^(.+):(.+):(.+):(.+):(.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': str2nr(l:match[2]),
\ 'type': l:match[3] is# 'error'
\ ? 'E' : (l:match[3] is# 'warning' ? 'W' : 'I'),
\ 'text': StripAnsiCodes(l:match[5]),
\ 'code': l:match[4]
\ })
endfor
return l:output
endfunction
function! StripAnsiCodes(line) abort
return substitute(a:line, '\e\[[0-9;]\+[mK]', '', 'g')
endfunction
call ale#linter#Define('bitbake', {
\ 'name': 'oelint_adv',
\ 'output_stream': 'both',
\ 'executable': {b -> ale#Var(b, 'bitbake_oelint_adv_executable')},
\ 'cwd': '%s:h',
\ 'command': function('ale_linters#bitbake#oelint_adv#Command'),
\ 'callback': 'ale_linters#bitbake#oelint_adv#Handle',
\ })

View File

@@ -1,40 +0,0 @@
" Author: Chuck Grindel <chuck.grindel@gmail.com>
" Description: Bazel Starlark lint support using buildifier.
function! ale_linters#bzl#buildifier#GetCommand(buffer) abort
let l:executable = ale#Escape(ale#fixers#buildifier#GetExecutable(a:buffer))
let l:options = ale#Var(a:buffer, 'bazel_buildifier_options')
let l:filename = ale#Escape(bufname(a:buffer))
let l:command = l:executable . ' -mode check -lint warn -path %s'
if l:options isnot# ''
let l:command .= ' ' . l:options
endif
return l:command
endfunction
function! ale_linters#bzl#buildifier#Handle(buffer, lines) abort
let l:pattern = '\v^[^:]+:(\d+):(\d+)?:?\s+(syntax error near)?(.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[3] . l:match[4],
\ 'type': l:match[3] is# 'syntax error near' ? 'E' : 'W',
\})
endfor
return l:output
endfunction
call ale#linter#Define('bzl', {
\ 'name': 'buildifier',
\ 'output_stream': 'both',
\ 'executable': function('ale#fixers#buildifier#GetExecutable'),
\ 'command': function('ale_linters#bzl#buildifier#GetCommand'),
\ 'callback': function('ale_linters#bzl#buildifier#Handle'),
\})

View File

@@ -1,67 +0,0 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: A C compiler linter for C files with gcc/clang, etc.
call ale#Set('c_cc_executable', '<auto>')
call ale#Set('c_cc_options', '-std=c11 -Wall')
call ale#Set('c_cc_use_header_lang_flag', -1)
call ale#Set('c_cc_header_exts', ['h'])
function! ale_linters#c#cc#GetExecutable(buffer) abort
let l:executable = ale#Var(a:buffer, 'c_cc_executable')
" Default to either clang or gcc.
if l:executable is# '<auto>'
if ale#engine#IsExecutable(a:buffer, 'clang')
let l:executable = 'clang'
else
let l:executable = 'gcc'
endif
endif
return l:executable
endfunction
function! ale_linters#c#cc#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
let l:ale_flags = ale#Var(a:buffer, 'c_cc_options')
if l:cflags =~# '-std='
let l:ale_flags = substitute(
\ l:ale_flags,
\ '-std=\(c\|gnu\)[0-9]\{2\}',
\ '',
\ 'g')
endif
" Select the correct language flag depending on the executable, options
" and file extension
let l:executable = ale_linters#c#cc#GetExecutable(a:buffer)
let l:use_header_lang_flag = ale#Var(a:buffer, 'c_cc_use_header_lang_flag')
let l:header_exts = ale#Var(a:buffer, 'c_cc_header_exts')
let l:lang_flag = ale#c#GetLanguageFlag(
\ a:buffer,
\ l:executable,
\ l:use_header_lang_flag,
\ l:header_exts,
\ 'c')
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
"
" `-o /dev/null` or `-o null` is needed to catch all errors,
" -fsyntax-only doesn't catch everything.
return '%e -S -x ' . l:lang_flag
\ . ' -o ' . g:ale#util#nul_file
\ . ' -iquote %s:h'
\ . ale#Pad(l:cflags)
\ . ale#Pad(l:ale_flags) . ' -'
endfunction
call ale#linter#Define('c', {
\ 'name': 'cc',
\ 'aliases': ['gcc', 'clang'],
\ 'output_stream': 'stderr',
\ 'executable': function('ale_linters#c#cc#GetExecutable'),
\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#cc#GetCommand'))},
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})

View File

@@ -3,13 +3,12 @@
call ale#Set('c_ccls_executable', 'ccls') call ale#Set('c_ccls_executable', 'ccls')
call ale#Set('c_ccls_init_options', {}) call ale#Set('c_ccls_init_options', {})
call ale#Set('c_build_dir', '')
call ale#linter#Define('c', { call ale#linter#Define('c', {
\ 'name': 'ccls', \ 'name': 'ccls',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'c_ccls_executable')}, \ 'executable_callback': ale#VarFunc('c_ccls_executable'),
\ 'command': '%e', \ 'command': '%e',
\ 'project_root': function('ale#handlers#ccls#GetProjectRoot'), \ 'project_root_callback': 'ale#handlers#ccls#GetProjectRoot',
\ 'initialization_options': {b -> ale#handlers#ccls#GetInitOpts(b, 'c_ccls_init_options')}, \ 'initialization_options_callback':ale#VarFunc('c_ccls_init_options'),
\}) \})

27
ale_linters/c/clang.vim Normal file
View File

@@ -0,0 +1,27 @@
" Author: Masahiro H https://github.com/mshr-h
" Description: clang linter for c files
call ale#Set('c_clang_executable', 'clang')
call ale#Set('c_clang_options', '-std=c11 -Wall')
function! ale_linters#c#clang#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
return '%e -S -x c -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'c_clang_options')) . ' -'
endfunction
call ale#linter#Define('c', {
\ 'name': 'clang',
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('c_clang_executable'),
\ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#c#clang#GetCommand'}
\ ],
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})

View File

@@ -1,38 +0,0 @@
" Author: gagbo <gagbobada@gmail.com>
" : luibo <ng.akhoa98@gmail.com>
" : Jorengarenar <jorengarenar@outlook.com>
" Description: clang-check linter for C files
" modified from cpp/clangcheck.vim to match for C
call ale#Set('c_clangcheck_executable', 'clang-check')
call ale#Set('c_clangcheck_options', '')
call ale#Set('c_build_dir', '')
function! ale_linters#c#clangcheck#GetCommand(buffer) abort
let l:user_options = ale#Var(a:buffer, 'c_clangcheck_options')
" Try to find compilation database to link automatically
let l:build_dir = ale#Var(a:buffer, 'c_build_dir')
if empty(l:build_dir)
let [l:root, l:json_file] = ale#c#FindCompileCommands(a:buffer)
let l:build_dir = ale#path#Dirname(l:json_file)
endif
" The extra arguments in the command are used to prevent .plist files from
" being generated. These are only added if no build directory can be
" detected.
return '%e -analyze %s'
\ . (empty(l:build_dir) ? ' --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics': '')
\ . ale#Pad(l:user_options)
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
endfunction
call ale#linter#Define('c', {
\ 'name': 'clangcheck',
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'c_clangcheck_executable')},
\ 'command': function('ale_linters#c#clangcheck#GetCommand'),
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1,
\})

View File

@@ -3,20 +3,21 @@
call ale#Set('c_clangd_executable', 'clangd') call ale#Set('c_clangd_executable', 'clangd')
call ale#Set('c_clangd_options', '') call ale#Set('c_clangd_options', '')
call ale#Set('c_build_dir', '')
function! ale_linters#c#clangd#GetProjectRoot(buffer) abort
let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
endfunction
function! ale_linters#c#clangd#GetCommand(buffer) abort function! ale_linters#c#clangd#GetCommand(buffer) abort
let l:build_dir = ale#c#GetBuildDirectory(a:buffer) return '%e' . ale#Pad(ale#Var(a:buffer, 'c_clangd_options'))
return '%e'
\ . ale#Pad(ale#Var(a:buffer, 'c_clangd_options'))
\ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '')
endfunction endfunction
call ale#linter#Define('c', { call ale#linter#Define('c', {
\ 'name': 'clangd', \ 'name': 'clangd',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'c_clangd_executable')}, \ 'executable_callback': ale#VarFunc('c_clangd_executable'),
\ 'command': function('ale_linters#c#clangd#GetCommand'), \ 'command_callback': 'ale_linters#c#clangd#GetCommand',
\ 'project_root': function('ale#c#FindProjectRoot'), \ 'project_root_callback': 'ale_linters#c#clangd#GetProjectRoot',
\}) \})

View File

@@ -11,32 +11,22 @@ call ale#Set('c_clangtidy_executable', 'clang-tidy')
" http://clang.llvm.org/extra/clang-tidy/checks/list.html " http://clang.llvm.org/extra/clang-tidy/checks/list.html
call ale#Set('c_clangtidy_checks', []) call ale#Set('c_clangtidy_checks', [])
" Set this option to manually set some options for clang-tidy to use as compile " Set this option to manually set some options for clang-tidy.
" flags.
" This will disable compile_commands.json detection. " This will disable compile_commands.json detection.
call ale#Set('c_clangtidy_options', '') call ale#Set('c_clangtidy_options', '')
" Set this option to manually set options for clang-tidy directly.
call ale#Set('c_clangtidy_extra_options', '')
call ale#Set('c_build_dir', '') call ale#Set('c_build_dir', '')
function! ale_linters#c#clangtidy#GetCommand(buffer, output) abort function! ale_linters#c#clangtidy#GetCommand(buffer) abort
let l:checks = join(ale#Var(a:buffer, 'c_clangtidy_checks'), ',') let l:checks = join(ale#Var(a:buffer, 'c_clangtidy_checks'), ',')
let l:build_dir = ale#c#GetBuildDirectory(a:buffer) let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
let l:options = ''
" Get the extra options if we couldn't find a build directory. " Get the extra options if we couldn't find a build directory.
if empty(l:build_dir) let l:options = empty(l:build_dir)
let l:options = ale#Var(a:buffer, 'c_clangtidy_options') \ ? ale#Var(a:buffer, 'c_clangtidy_options')
let l:cflags = ale#c#GetCFlags(a:buffer, a:output) \ : ''
let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags
endif
" Get the options to pass directly to clang-tidy
let l:extra_options = ale#Var(a:buffer, 'c_clangtidy_extra_options')
return '%e' return '%e'
\ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '') \ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
\ . (!empty(l:extra_options) ? ' ' . ale#Escape(l:extra_options) : '')
\ . ' %s' \ . ' %s'
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
\ . (!empty(l:options) ? ' -- ' . l:options : '') \ . (!empty(l:options) ? ' -- ' . l:options : '')
@@ -45,8 +35,8 @@ endfunction
call ale#linter#Define('c', { call ale#linter#Define('c', {
\ 'name': 'clangtidy', \ 'name': 'clangtidy',
\ 'output_stream': 'stdout', \ 'output_stream': 'stdout',
\ 'executable': {b -> ale#Var(b, 'c_clangtidy_executable')}, \ 'executable_callback': ale#VarFunc('c_clangtidy_executable'),
\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#clangtidy#GetCommand'))}, \ 'command_callback': 'ale_linters#c#clangtidy#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1, \ 'lint_file': 1,
\}) \})

View File

@@ -5,25 +5,30 @@ call ale#Set('c_cppcheck_executable', 'cppcheck')
call ale#Set('c_cppcheck_options', '--enable=style') call ale#Set('c_cppcheck_options', '--enable=style')
function! ale_linters#c#cppcheck#GetCommand(buffer) abort function! ale_linters#c#cppcheck#GetCommand(buffer) abort
let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer) " Search upwards from the file for compile_commands.json.
let l:buffer_path_include = empty(l:compile_commands_option) "
\ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer) " If we find it, we'll `cd` to where the compile_commands.json file is,
\ : '' " then use the file to set up import paths, etc.
let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}') let l:compile_commmands_path = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
return '%e -q --language=c' let l:cd_command = !empty(l:compile_commmands_path)
\ . l:template \ ? ale#path#CdString(fnamemodify(l:compile_commmands_path, ':h'))
\ . ale#Pad(l:compile_commands_option) \ : ''
\ . ale#Pad(ale#Var(a:buffer, 'c_cppcheck_options')) let l:compile_commands_option = !empty(l:compile_commmands_path)
\ . l:buffer_path_include \ ? '--project=compile_commands.json '
\ : ''
return l:cd_command
\ . '%e -q --language=c '
\ . l:compile_commands_option
\ . ale#Var(a:buffer, 'c_cppcheck_options')
\ . ' %t' \ . ' %t'
endfunction endfunction
call ale#linter#Define('c', { call ale#linter#Define('c', {
\ 'name': 'cppcheck', \ 'name': 'cppcheck',
\ 'output_stream': 'both', \ 'output_stream': 'both',
\ 'executable': {b -> ale#Var(b, 'c_cppcheck_executable')}, \ 'executable_callback': ale#VarFunc('c_cppcheck_executable'),
\ 'cwd': function('ale#handlers#cppcheck#GetCwd'), \ 'command_callback': 'ale_linters#c#cppcheck#GetCommand',
\ 'command': function('ale_linters#c#cppcheck#GetCommand'),
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', \ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
\}) \})

View File

@@ -1,20 +0,0 @@
" Author: Justin Huang <justin.y.huang@live.com>
" Description: cpplint for c files
call ale#Set('c_cpplint_executable', 'cpplint')
call ale#Set('c_cpplint_options', '')
function! ale_linters#c#cpplint#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'c_cpplint_options')
return '%e' . ale#Pad(l:options) . ' %s'
endfunction
call ale#linter#Define('c', {
\ 'name': 'cpplint',
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'c_cpplint_executable')},
\ 'command': function('ale_linters#c#cpplint#GetCommand'),
\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat',
\ 'lint_file': 1,
\})

View File

@@ -5,15 +5,13 @@ call ale#Set('c_cquery_executable', 'cquery')
call ale#Set('c_cquery_cache_directory', expand('~/.cache/cquery')) call ale#Set('c_cquery_cache_directory', expand('~/.cache/cquery'))
function! ale_linters#c#cquery#GetProjectRoot(buffer) abort function! ale_linters#c#cquery#GetProjectRoot(buffer) abort
" Try to find cquery configuration files first. let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
let l:config = ale#path#FindNearestFile(a:buffer, '.cquery')
if !empty(l:config) if empty(l:project_root)
return fnamemodify(l:config, ':h') let l:project_root = ale#path#FindNearestFile(a:buffer, '.cquery')
endif endif
" Fall back on default project root detection. return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
return ale#c#FindProjectRoot(a:buffer)
endfunction endfunction
function! ale_linters#c#cquery#GetInitializationOptions(buffer) abort function! ale_linters#c#cquery#GetInitializationOptions(buffer) abort
@@ -23,8 +21,8 @@ endfunction
call ale#linter#Define('c', { call ale#linter#Define('c', {
\ 'name': 'cquery', \ 'name': 'cquery',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'c_cquery_executable')}, \ 'executable_callback': ale#VarFunc('c_cquery_executable'),
\ 'command': '%e', \ 'command': '%e',
\ 'project_root': function('ale_linters#c#cquery#GetProjectRoot'), \ 'project_root_callback': 'ale_linters#c#cquery#GetProjectRoot',
\ 'initialization_options': function('ale_linters#c#cquery#GetInitializationOptions'), \ 'initialization_options_callback': 'ale_linters#c#cquery#GetInitializationOptions',
\}) \})

View File

@@ -1,5 +0,0 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for C files.
call ale#handlers#cspell#DefineLinter('c')

View File

@@ -7,19 +7,19 @@ call ale#Set('c_flawfinder_minlevel', 1)
call ale#Set('c_flawfinder_error_severity', 6) call ale#Set('c_flawfinder_error_severity', 6)
function! ale_linters#c#flawfinder#GetCommand(buffer) abort function! ale_linters#c#flawfinder#GetCommand(buffer) abort
" Set the minimum vulnerability level for flawfinder to bother with " Set the minimum vulnerability level for flawfinder to bother with
let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'c_flawfinder_minlevel') let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'c_flawfinder_minlevel')
return '%e -CDQS' return '%e -CDQS'
\ . ale#Pad(ale#Var(a:buffer, 'c_flawfinder_options')) \ . ale#Pad(ale#Var(a:buffer, 'c_flawfinder_options'))
\ . l:minlevel \ . l:minlevel
\ . ' %t' \ . ' %t'
endfunction endfunction
call ale#linter#Define('c', { call ale#linter#Define('c', {
\ 'name': 'flawfinder', \ 'name': 'flawfinder',
\ 'output_stream': 'stdout', \ 'output_stream': 'stdout',
\ 'executable': {b -> ale#Var(b, 'c_flawfinder_executable')}, \ 'executable_callback': ale#VarFunc('c_flawfinder_executable'),
\ 'command': function('ale_linters#c#flawfinder#GetCommand'), \ 'command_callback': 'ale_linters#c#flawfinder#GetCommand',
\ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat', \ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat',
\}) \})

27
ale_linters/c/gcc.vim Normal file
View File

@@ -0,0 +1,27 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: gcc linter for c files
call ale#Set('c_gcc_executable', 'gcc')
call ale#Set('c_gcc_options', '-std=c11 -Wall')
function! ale_linters#c#gcc#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
return '%e -S -x c -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'c_gcc_options')) . ' -'
endfunction
call ale#linter#Define('c', {
\ 'name': 'gcc',
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('c_gcc_executable'),
\ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#c#gcc#GetCommand'}
\ ],
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})

View File

@@ -1,22 +0,0 @@
" Author: Koni Marti <koni.marti@gmail.com>
" Description: A Language Server implementation for C3
call ale#Set('c3_c3lsp_executable', 'c3lsp')
call ale#Set('c3_c3lsp_options', '')
call ale#Set('c3_c3lsp_init_options', {})
function! ale_linters#c3#c3lsp#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'c3_c3lsp_executable')
return ale#Escape(l:executable) . ale#Pad(ale#Var(a:buffer, 'c3_c3lsp_options'))
endfunction
call ale#linter#Define('c3', {
\ 'name': 'c3lsp',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'c3_c3lsp_executable')},
\ 'command': function('ale_linters#c3#c3lsp#GetCommand'),
\ 'project_root': function('ale#handlers#c3lsp#GetProjectRoot'),
\ 'lsp_config': {b -> ale#handlers#c3lsp#GetInitOpts(b, 'c3_c3lsp_init_options')},
\})

View File

@@ -1,31 +0,0 @@
" Author: 0xhyoga <0xhyoga@gmx.com>,
" Description: scarb for cairo files
function! ale_linters#cairo#scarb#GetScarbExecutable(bufnr) abort
if ale#path#FindNearestFile(a:bufnr, 'Scarb.toml') isnot# ''
return 'scarb'
else
" if there is no Scarb.toml file, we don't use scarb even if it exists,
" so we return '', because executable('') apparently always fails
return ''
endif
endfunction
function! ale_linters#cairo#scarb#GetCommand(buffer, version) abort
return 'scarb build'
endfunction
call ale#linter#Define('cairo', {
\ 'name': 'scarb',
\ 'executable': function('ale_linters#cairo#scarb#GetScarbExecutable'),
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
\ buffer,
\ ale_linters#cairo#scarb#GetScarbExecutable(buffer),
\ '%e --version',
\ function('ale_linters#cairo#scarb#GetCommand'),
\ )},
\ 'callback': 'ale#handlers#cairo#HandleCairoErrors',
\ 'output_stream': 'both',
\ 'lint_file': 1,
\})

View File

@@ -1,54 +0,0 @@
" Author: 0xHyoga <0xHyoga@gmx.com>
" Description: Report Starknet compile to sierra errors in cairo 1.0 code
call ale#Set('cairo_sierra_executable', 'starknet-compile')
call ale#Set('cairo_sierra_options', '')
function! ale_linters#cairo#sierra#Handle(buffer, lines) abort
" Matches patterns like the following:
" Error: Expected ';' but got '('
" --> /path/to/file/file.cairo:1:10:)
let l:pattern = '\v(error|warning): (.*)$'
let l:line_and_column_pattern = '\v\.cairo:(\d+):(\d+)'
let l:output = []
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
if len(l:match) == 0
let l:match = matchlist(l:line, l:line_and_column_pattern)
if len(l:match) > 0
let l:index = len(l:output) - 1
let l:output[l:index]['lnum'] = l:match[1] + 0
let l:output[l:index]['col'] = l:match[2] + 0
endif
else
let l:isError = l:match[1] is? 'Error'
call add(l:output, {
\ 'lnum': 0,
\ 'col': 0,
\ 'text': l:match[2],
\ 'type': l:isError ? 'E' : 'W',
\})
endif
endfor
return l:output
endfunction
function! ale_linters#cairo#sierra#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'cairo_sierra_executable')
return l:executable . ale#Pad(ale#Var(a:buffer, 'cairo_sierra_options')) . ' %s'
endfunction
call ale#linter#Define('cairo', {
\ 'name': 'sierra',
\ 'executable': {b -> ale#Var(b, 'cairo_sierra_executable')},
\ 'command': function('ale_linters#cairo#sierra#GetCommand'),
\ 'callback': 'ale_linters#cairo#sierra#Handle',
\ 'output_stream': 'stderr',
\})

View File

@@ -1,39 +0,0 @@
" Author: 0xHyoga <0xHyoga@gmx.com>
" Description: Report starknet-compile errors in cairo code (pre-starknet
" 1.0). This is deprecated but kept for backwards compatability.
call ale#Set('cairo_starknet_executable', 'starknet-compile')
call ale#Set('cairo_starknet_options', '')
function! ale_linters#cairo#starknet#Handle(buffer, lines) abort
" Error always on the first line
" e.g ex01.cairo:20:6: Could not find module 'contracts.utils.ex00_base'. Searched in the following paths:
let l:pattern = '\v\.cairo:(\d+):(\d+):+ (.*)'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': str2nr(l:match[1]),
\ 'col': str2nr(l:match[2]),
\ 'type': 'E',
\ 'text': l:match[3],
\})
endfor
return l:output
endfunction
function! ale_linters#cairo#starknet#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'cairo_starknet_executable')
return l:executable . ale#Pad(ale#Var(a:buffer, 'cairo_starknet_options')) . ' %s'
endfunction
call ale#linter#Define('cairo', {
\ 'name': 'starknet',
\ 'executable': {b -> ale#Var(b, 'cairo_starknet_executable')},
\ 'command': function('ale_linters#cairo#starknet#GetCommand'),
\ 'callback': 'ale_linters#cairo#starknet#Handle',
\ 'output_stream': 'stderr',
\})

View File

@@ -1,54 +0,0 @@
" Author: Raphael Hoegger - https://github.com/pfuender
" Description: Cookstyle (RuboCop based), a code style analyzer for Ruby files
call ale#Set('chef_cookstyle_executable', 'cookstyle')
call ale#Set('chef_cookstyle_options', '')
function! ale_linters#chef#cookstyle#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'chef_cookstyle_options')
return '%e' . ale#Pad(escape(l:options, '~')) . ' --force-exclusion --format json --stdin ' . ' %s'
endfunction
function! ale_linters#chef#cookstyle#Handle(buffer, lines) abort
if len(a:lines) == 0
return []
endif
let l:errors = ale#util#FuzzyJSONDecode(a:lines[0], {})
if !has_key(l:errors, 'summary')
\|| l:errors['summary']['offense_count'] == 0
\|| empty(l:errors['files'])
return []
endif
let l:output = []
for l:error in l:errors['files'][0]['offenses']
let l:start_col = str2nr(l:error['location']['start_column'])
let l:end_col = str2nr(l:error['location']['last_column'])
if !l:end_col
let l:end_col = l:start_col + 1
endif
call add(l:output, {
\ 'lnum': str2nr(l:error['location']['line']),
\ 'col': l:start_col,
\ 'end_col': l:end_col,
\ 'code': l:error['cop_name'],
\ 'text': l:error['message'],
\ 'type': l:error['severity'] is? 'convention' ? 'W' : 'E',
\})
endfor
return l:output
endfunction
call ale#linter#Define('chef', {
\ 'name': 'cookstyle',
\ 'executable': {b -> ale#Var(b, 'chef_cookstyle_executable')},
\ 'command': function('ale_linters#chef#cookstyle#GetCommand'),
\ 'callback': 'ale_linters#chef#cookstyle#Handle',
\})

View File

@@ -34,8 +34,8 @@ endfunction
call ale#linter#Define('chef', { call ale#linter#Define('chef', {
\ 'name': 'foodcritic', \ 'name': 'foodcritic',
\ 'executable': {b -> ale#Var(b, 'chef_foodcritic_executable')}, \ 'executable_callback': ale#VarFunc('chef_foodcritic_executable'),
\ 'command': function('ale_linters#chef#foodcritic#GetCommand'), \ 'command_callback': 'ale_linters#chef#foodcritic#GetCommand',
\ 'callback': 'ale_linters#chef#foodcritic#Handle', \ 'callback': 'ale_linters#chef#foodcritic#Handle',
\ 'lint_file': 1, \ 'lint_file': 1,
\}) \})

View File

@@ -1,47 +0,0 @@
" Author: Masashi Iizuka <liquidz.uo@gmail.com>
" Description: linter for clojure using clj-kondo https://github.com/borkdude/clj-kondo
call ale#Set('clojure_clj_kondo_options', '--cache')
function! ale_linters#clojure#clj_kondo#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'clojure_clj_kondo_options')
let l:command = 'clj-kondo'
\ . ale#Pad(l:options)
\ . ' --lint -'
\ . ' --filename %s'
return l:command
endfunction
function! ale_linters#clojure#clj_kondo#HandleCljKondoFormat(buffer, lines) abort
" output format
" <filename>:<line>:<column>: <issue type>: <message>
let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+)?:(\d+)?:? ((Exception|error|warning): ?(.+))$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:type = 'E'
if l:match[4] is? 'warning'
let l:type = 'W'
endif
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[3],
\ 'type': l:type,
\})
endfor
return l:output
endfunction
call ale#linter#Define('clojure', {
\ 'name': 'clj-kondo',
\ 'output_stream': 'stdout',
\ 'executable': 'clj-kondo',
\ 'command': function('ale_linters#clojure#clj_kondo#GetCommand'),
\ 'callback': 'ale_linters#clojure#clj_kondo#HandleCljKondoFormat',
\})

View File

@@ -11,7 +11,7 @@ function! ale_linters#clojure#joker#HandleJokerFormat(buffer, lines) abort
let l:type = 'E' let l:type = 'E'
if l:match[4] is? 'Parse warning' if l:match[4] is? 'Parse warning'
let l:type = 'W' let l:type = 'W'
endif endif
call add(l:output, { call add(l:output, {

View File

@@ -29,7 +29,6 @@ endfunction
call ale#linter#Define('cloudformation', { call ale#linter#Define('cloudformation', {
\ 'name': 'cloudformation', \ 'name': 'cloudformation',
\ 'aliases': ['cfn-lint'],
\ 'executable': 'cfn-lint', \ 'executable': 'cfn-lint',
\ 'command': 'cfn-lint --template %t --format parseable', \ 'command': 'cfn-lint --template %t --format parseable',
\ 'callback': 'ale_linters#cloudformation#cfn_python_lint#Handle', \ 'callback': 'ale_linters#cloudformation#cfn_python_lint#Handle',

View File

@@ -1,43 +0,0 @@
" Author: Carl Smedstad <carl.smedstad at protonmail dot com>
" Description: cmake-lint for cmake files
let g:ale_cmake_cmake_lint_executable =
\ get(g:, 'ale_cmake_cmake_lint_executable', 'cmake-lint')
let g:ale_cmake_cmake_lint_options =
\ get(g:, 'ale_cmake_cmake_lint_options', '')
function! ale_linters#cmake#cmake_lint#Executable(buffer) abort
return ale#Var(a:buffer, 'cmake_cmake_lint_executable')
endfunction
function! ale_linters#cmake#cmake_lint#Command(buffer) abort
let l:executable = ale_linters#cmake#cmake_lint#Executable(a:buffer)
let l:options = ale#Var(a:buffer, 'cmake_cmake_lint_options')
return ale#Escape(l:executable) . ' ' . l:options . ' %s'
endfunction
function! ale_linters#cmake#cmake_lint#Handle(buffer, lines) abort
let l:pattern = '\v^[^:]+:(\d+),?(\d+)?:\s\[([A-Z]\d+)\]\s(.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'type': 'W',
\ 'code': l:match[3],
\ 'text': l:match[4],
\})
endfor
return l:output
endfunction
call ale#linter#Define('cmake', {
\ 'name': 'cmake_lint',
\ 'executable': function('ale_linters#cmake#cmake_lint#Executable'),
\ 'command': function('ale_linters#cmake#cmake_lint#Command'),
\ 'callback': 'ale_linters#cmake#cmake_lint#Handle',
\})

View File

@@ -18,7 +18,7 @@ endfunction
call ale#linter#Define('cmake', { call ale#linter#Define('cmake', {
\ 'name': 'cmakelint', \ 'name': 'cmakelint',
\ 'executable': function('ale_linters#cmake#cmakelint#Executable'), \ 'executable_callback': 'ale_linters#cmake#cmakelint#Executable',
\ 'command': function('ale_linters#cmake#cmakelint#Command'), \ 'command_callback': 'ale_linters#cmake#cmakelint#Command',
\ 'callback': 'ale#handlers#unix#HandleAsWarning', \ 'callback': 'ale#handlers#unix#HandleAsWarning',
\}) \})

View File

@@ -16,8 +16,8 @@ endfunction
call ale#linter#Define('coffee', { call ale#linter#Define('coffee', {
\ 'name': 'coffee', \ 'name': 'coffee',
\ 'executable': function('ale_linters#coffee#coffee#GetExecutable'), \ 'executable_callback': 'ale_linters#coffee#coffee#GetExecutable',
\ 'command': function('ale_linters#coffee#coffee#GetCommand'), \ 'command_callback': 'ale_linters#coffee#coffee#GetCommand',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\}) \})

View File

@@ -37,7 +37,7 @@ endfunction
call ale#linter#Define('coffee', { call ale#linter#Define('coffee', {
\ 'name': 'coffeelint', \ 'name': 'coffeelint',
\ 'executable': function('ale_linters#coffee#coffeelint#GetExecutable'), \ 'executable_callback': 'ale_linters#coffee#coffeelint#GetExecutable',
\ 'command': function('ale_linters#coffee#coffeelint#GetCommand'), \ 'command_callback': 'ale_linters#coffee#coffeelint#GetCommand',
\ 'callback': 'ale_linters#coffee#coffeelint#Handle', \ 'callback': 'ale_linters#coffee#coffeelint#Handle',
\}) \})

View File

@@ -1,67 +0,0 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: A C++ compiler linter for C++ files with gcc/clang, etc.
call ale#Set('cpp_cc_executable', '<auto>')
call ale#Set('cpp_cc_options', '-std=c++14 -Wall')
call ale#Set('cpp_cc_use_header_lang_flag', -1)
call ale#Set('cpp_cc_header_exts', ['h', 'hpp'])
function! ale_linters#cpp#cc#GetExecutable(buffer) abort
let l:executable = ale#Var(a:buffer, 'cpp_cc_executable')
" Default to either clang++ or gcc.
if l:executable is# '<auto>'
if ale#engine#IsExecutable(a:buffer, 'clang++')
let l:executable = 'clang++'
else
let l:executable = 'gcc'
endif
endif
return l:executable
endfunction
function! ale_linters#cpp#cc#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
let l:ale_flags = ale#Var(a:buffer, 'cpp_cc_options')
if l:cflags =~# '-std='
let l:ale_flags = substitute(
\ l:ale_flags,
\ '-std=\(c\|gnu\)++[0-9]\{2\}',
\ '',
\ 'g')
endif
" Select the correct language flag depending on the executable, options
" and file extension
let l:executable = ale_linters#cpp#cc#GetExecutable(a:buffer)
let l:use_header_lang_flag = ale#Var(a:buffer, 'cpp_cc_use_header_lang_flag')
let l:header_exts = ale#Var(a:buffer, 'cpp_cc_header_exts')
let l:lang_flag = ale#c#GetLanguageFlag(
\ a:buffer,
\ l:executable,
\ l:use_header_lang_flag,
\ l:header_exts,
\ 'c++')
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
"
" `-o /dev/null` or `-o null` is needed to catch all errors,
" -fsyntax-only doesn't catch everything.
return '%e -S -x ' . l:lang_flag
\ . ' -o ' . g:ale#util#nul_file
\ . ' -iquote %s:h'
\ . ale#Pad(l:cflags)
\ . ale#Pad(l:ale_flags) . ' -'
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'cc',
\ 'aliases': ['gcc', 'clang', 'g++', 'clang++'],
\ 'output_stream': 'stderr',
\ 'executable': function('ale_linters#cpp#cc#GetExecutable'),
\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#cc#GetCommand'))},
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})

View File

@@ -3,13 +3,12 @@
call ale#Set('cpp_ccls_executable', 'ccls') call ale#Set('cpp_ccls_executable', 'ccls')
call ale#Set('cpp_ccls_init_options', {}) call ale#Set('cpp_ccls_init_options', {})
call ale#Set('c_build_dir', '')
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'ccls', \ 'name': 'ccls',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'cpp_ccls_executable')}, \ 'executable_callback': ale#VarFunc('cpp_ccls_executable'),
\ 'command': '%e', \ 'command': '%e',
\ 'project_root': function('ale#handlers#ccls#GetProjectRoot'), \ 'project_root_callback': 'ale#handlers#ccls#GetProjectRoot',
\ 'initialization_options': {b -> ale#handlers#ccls#GetInitOpts(b, 'cpp_ccls_init_options')}, \ 'initialization_options_callback': ale#VarFunc('cpp_ccls_init_options'),
\}) \})

27
ale_linters/cpp/clang.vim Normal file
View File

@@ -0,0 +1,27 @@
" Author: Tomota Nakamura <https://github.com/tomotanakamura>
" Description: clang linter for cpp files
call ale#Set('cpp_clang_executable', 'clang++')
call ale#Set('cpp_clang_options', '-std=c++14 -Wall')
function! ale_linters#cpp#clang#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
return '%e -S -x c++ -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'cpp_clang_options')) . ' -'
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'clang',
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('cpp_clang_executable'),
\ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#cpp#clang#GetCommand'},
\ ],
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})

View File

@@ -12,15 +12,14 @@ function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort
let l:build_dir = ale#Var(a:buffer, 'c_build_dir') let l:build_dir = ale#Var(a:buffer, 'c_build_dir')
if empty(l:build_dir) if empty(l:build_dir)
let [l:root, l:json_file] = ale#c#FindCompileCommands(a:buffer) let l:build_dir = ale#path#Dirname(ale#c#FindCompileCommands(a:buffer))
let l:build_dir = ale#path#Dirname(l:json_file)
endif endif
" The extra arguments in the command are used to prevent .plist files from " The extra arguments in the command are used to prevent .plist files from
" being generated. These are only added if no build directory can be " being generated. These are only added if no build directory can be
" detected. " detected.
return '%e -analyze %s' return '%e -analyze %s'
\ . (empty(l:build_dir) ? ' --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics': '') \ . (empty(l:build_dir) ? ' -extra-arg -Xclang -extra-arg -analyzer-output=text' : '')
\ . ale#Pad(l:user_options) \ . ale#Pad(l:user_options)
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
endfunction endfunction
@@ -28,8 +27,8 @@ endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'clangcheck', \ 'name': 'clangcheck',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'cpp_clangcheck_executable')}, \ 'executable_callback': ale#VarFunc('cpp_clangcheck_executable'),
\ 'command': function('ale_linters#cpp#clangcheck#GetCommand'), \ 'command_callback': 'ale_linters#cpp#clangcheck#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1, \ 'lint_file': 1,
\}) \})

View File

@@ -3,20 +3,21 @@
call ale#Set('cpp_clangd_executable', 'clangd') call ale#Set('cpp_clangd_executable', 'clangd')
call ale#Set('cpp_clangd_options', '') call ale#Set('cpp_clangd_options', '')
call ale#Set('c_build_dir', '')
function! ale_linters#cpp#clangd#GetProjectRoot(buffer) abort
let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
endfunction
function! ale_linters#cpp#clangd#GetCommand(buffer) abort function! ale_linters#cpp#clangd#GetCommand(buffer) abort
let l:build_dir = ale#c#GetBuildDirectory(a:buffer) return '%e' . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options'))
return '%e'
\ . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options'))
\ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '')
endfunction endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'clangd', \ 'name': 'clangd',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'cpp_clangd_executable')}, \ 'executable_callback': ale#VarFunc('cpp_clangd_executable'),
\ 'command': function('ale_linters#cpp#clangd#GetCommand'), \ 'command_callback': 'ale_linters#cpp#clangd#GetCommand',
\ 'project_root': function('ale#c#FindProjectRoot'), \ 'project_root_callback': 'ale_linters#cpp#clangd#GetProjectRoot',
\}) \})

View File

@@ -5,39 +5,22 @@
call ale#Set('cpp_clangtidy_executable', 'clang-tidy') call ale#Set('cpp_clangtidy_executable', 'clang-tidy')
" Set this option to check the checks clang-tidy will apply. " Set this option to check the checks clang-tidy will apply.
call ale#Set('cpp_clangtidy_checks', []) call ale#Set('cpp_clangtidy_checks', [])
" Set this option to manually set some options for clang-tidy to use as compile " Set this option to manually set some options for clang-tidy.
" flags.
" This will disable compile_commands.json detection. " This will disable compile_commands.json detection.
call ale#Set('cpp_clangtidy_options', '') call ale#Set('cpp_clangtidy_options', '')
" Set this option to manually set options for clang-tidy directly.
call ale#Set('cpp_clangtidy_extra_options', '')
call ale#Set('c_build_dir', '') call ale#Set('c_build_dir', '')
function! ale_linters#cpp#clangtidy#GetCommand(buffer, output) abort function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort
let l:checks = join(ale#Var(a:buffer, 'cpp_clangtidy_checks'), ',') let l:checks = join(ale#Var(a:buffer, 'cpp_clangtidy_checks'), ',')
let l:build_dir = ale#c#GetBuildDirectory(a:buffer) let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
let l:options = ''
" Get the extra options if we couldn't find a build directory. " Get the extra options if we couldn't find a build directory.
if empty(l:build_dir) let l:options = empty(l:build_dir)
let l:options = ale#Var(a:buffer, 'cpp_clangtidy_options') \ ? ale#Var(a:buffer, 'cpp_clangtidy_options')
let l:cflags = ale#c#GetCFlags(a:buffer, a:output) \ : ''
let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags
" Tell clang-tidy a .h header with a C++ filetype in Vim is a C++ file
" only when compile-commands.json file is not there. Adding these
" flags makes clang-tidy completely ignore compile commands.
if expand('#' . a:buffer) =~# '\.h$'
let l:options .= !empty(l:options) ? ' -x c++' : '-x c++'
endif
endif
" Get the options to pass directly to clang-tidy
let l:extra_options = ale#Var(a:buffer, 'cpp_clangtidy_extra_options')
return '%e' return '%e'
\ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '') \ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
\ . (!empty(l:extra_options) ? ' ' . ale#Escape(l:extra_options) : '')
\ . ' %s' \ . ' %s'
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
\ . (!empty(l:options) ? ' -- ' . l:options : '') \ . (!empty(l:options) ? ' -- ' . l:options : '')
@@ -46,8 +29,8 @@ endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'clangtidy', \ 'name': 'clangtidy',
\ 'output_stream': 'stdout', \ 'output_stream': 'stdout',
\ 'executable': {b -> ale#Var(b, 'cpp_clangtidy_executable')}, \ 'executable_callback': ale#VarFunc('cpp_clangtidy_executable'),
\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#clangtidy#GetCommand'))}, \ 'command_callback': 'ale_linters#cpp#clangtidy#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1, \ 'lint_file': 1,
\}) \})

View File

@@ -25,8 +25,8 @@ endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'clazy', \ 'name': 'clazy',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'cpp_clazy_executable')}, \ 'executable_callback': ale#VarFunc('cpp_clazy_executable'),
\ 'command': function('ale_linters#cpp#clazy#GetCommand'), \ 'command_callback': 'ale_linters#cpp#clazy#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1, \ 'lint_file': 1,
\}) \})

View File

@@ -5,25 +5,30 @@ call ale#Set('cpp_cppcheck_executable', 'cppcheck')
call ale#Set('cpp_cppcheck_options', '--enable=style') call ale#Set('cpp_cppcheck_options', '--enable=style')
function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer) " Search upwards from the file for compile_commands.json.
let l:buffer_path_include = empty(l:compile_commands_option) "
\ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer) " If we find it, we'll `cd` to where the compile_commands.json file is,
\ : '' " then use the file to set up import paths, etc.
let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}') let l:compile_commmands_path = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
return '%e -q --language=c++' let l:cd_command = !empty(l:compile_commmands_path)
\ . l:template \ ? ale#path#CdString(fnamemodify(l:compile_commmands_path, ':h'))
\ . ale#Pad(l:compile_commands_option) \ : ''
\ . ale#Pad(ale#Var(a:buffer, 'cpp_cppcheck_options')) let l:compile_commands_option = !empty(l:compile_commmands_path)
\ . l:buffer_path_include \ ? '--project=compile_commands.json '
\ : ''
return l:cd_command
\ . '%e -q --language=c++ '
\ . l:compile_commands_option
\ . ale#Var(a:buffer, 'cpp_cppcheck_options')
\ . ' %t' \ . ' %t'
endfunction endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'cppcheck', \ 'name': 'cppcheck',
\ 'output_stream': 'both', \ 'output_stream': 'both',
\ 'executable': {b -> ale#Var(b, 'cpp_cppcheck_executable')}, \ 'executable_callback': ale#VarFunc('cpp_cppcheck_executable'),
\ 'cwd': function('ale#handlers#cppcheck#GetCwd'), \ 'command_callback': 'ale_linters#cpp#cppcheck#GetCommand',
\ 'command': function('ale_linters#cpp#cppcheck#GetCommand'),
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', \ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
\}) \})

View File

@@ -13,8 +13,8 @@ endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'cpplint', \ 'name': 'cpplint',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'cpp_cpplint_executable')}, \ 'executable_callback': ale#VarFunc('cpp_cpplint_executable'),
\ 'command': function('ale_linters#cpp#cpplint#GetCommand'), \ 'command_callback': 'ale_linters#cpp#cpplint#GetCommand',
\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat', \ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat',
\ 'lint_file': 1, \ 'lint_file': 1,
\}) \})

View File

@@ -5,15 +5,13 @@ call ale#Set('cpp_cquery_executable', 'cquery')
call ale#Set('cpp_cquery_cache_directory', expand('~/.cache/cquery')) call ale#Set('cpp_cquery_cache_directory', expand('~/.cache/cquery'))
function! ale_linters#cpp#cquery#GetProjectRoot(buffer) abort function! ale_linters#cpp#cquery#GetProjectRoot(buffer) abort
" Try to find cquery configuration files first. let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
let l:config = ale#path#FindNearestFile(a:buffer, '.cquery')
if !empty(l:config) if empty(l:project_root)
return fnamemodify(l:config, ':h') let l:project_root = ale#path#FindNearestFile(a:buffer, '.cquery')
endif endif
" Fall back on default project root detection. return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
return ale#c#FindProjectRoot(a:buffer)
endfunction endfunction
function! ale_linters#cpp#cquery#GetInitializationOptions(buffer) abort function! ale_linters#cpp#cquery#GetInitializationOptions(buffer) abort
@@ -23,8 +21,8 @@ endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'cquery', \ 'name': 'cquery',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'cpp_cquery_executable')}, \ 'executable_callback': ale#VarFunc('cpp_cquery_executable'),
\ 'command': '%e', \ 'command': '%e',
\ 'project_root': function('ale_linters#cpp#cquery#GetProjectRoot'), \ 'project_root_callback': 'ale_linters#cpp#cquery#GetProjectRoot',
\ 'initialization_options': function('ale_linters#cpp#cquery#GetInitializationOptions'), \ 'initialization_options_callback': 'ale_linters#cpp#cquery#GetInitializationOptions',
\}) \})

View File

@@ -1,5 +0,0 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for C++ files.
call ale#handlers#cspell#DefineLinter('cpp')

View File

@@ -7,19 +7,19 @@ call ale#Set('cpp_flawfinder_minlevel', 1)
call ale#Set('c_flawfinder_error_severity', 6) call ale#Set('c_flawfinder_error_severity', 6)
function! ale_linters#cpp#flawfinder#GetCommand(buffer) abort function! ale_linters#cpp#flawfinder#GetCommand(buffer) abort
" Set the minimum vulnerability level for flawfinder to bother with " Set the minimum vulnerability level for flawfinder to bother with
let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'cpp_flawfinder_minlevel') let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'cpp_flawfinder_minlevel')
return '%e -CDQS' return '%e -CDQS'
\ . ale#Var(a:buffer, 'cpp_flawfinder_options') \ . ale#Var(a:buffer, 'cpp_flawfinder_options')
\ . l:minlevel \ . l:minlevel
\ . ' %t' \ . ' %t'
endfunction endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'flawfinder', \ 'name': 'flawfinder',
\ 'output_stream': 'stdout', \ 'output_stream': 'stdout',
\ 'executable': {b -> ale#Var(b, 'cpp_flawfinder_executable')}, \ 'executable_callback': ale#VarFunc('cpp_flawfinder_executable'),
\ 'command': function('ale_linters#cpp#flawfinder#GetCommand'), \ 'command_callback': 'ale_linters#cpp#flawfinder#GetCommand',
\ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat', \ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat',
\}) \})

28
ale_linters/cpp/gcc.vim Normal file
View File

@@ -0,0 +1,28 @@
" Author: geam <mdelage@student.42.fr>
" Description: gcc linter for cpp files
"
call ale#Set('cpp_gcc_executable', 'gcc')
call ale#Set('cpp_gcc_options', '-std=c++14 -Wall')
function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
return '%e -S -x c++ -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'cpp_gcc_options')) . ' -'
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'gcc',
\ 'aliases': ['g++'],
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('cpp_gcc_executable'),
\ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#cpp#gcc#GetCommand'},
\ ],
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})

View File

@@ -1,57 +0,0 @@
" Author: Harrison Bachrach - https://github.com/HarrisonB
" Description: Ameba, a linter for crystal files
call ale#Set('crystal_ameba_executable', 'bin/ameba')
function! ale_linters#crystal#ameba#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'crystal_ameba_executable')
return ale#Escape(l:executable)
\ . ' --format json '
\ . ale#Escape(expand('#' . a:buffer . ':p'))
endfunction
" Handle output from ameba
function! ale_linters#crystal#ameba#HandleAmebaOutput(buffer, lines) abort
if len(a:lines) == 0
return []
endif
let l:errors = ale#util#FuzzyJSONDecode(a:lines[0], {})
if !has_key(l:errors, 'summary')
\|| l:errors['summary']['issues_count'] == 0
\|| empty(l:errors['sources'])
return []
endif
let l:output = []
for l:error in l:errors['sources'][0]['issues']
let l:start_col = str2nr(l:error['location']['column'])
let l:end_col = str2nr(l:error['end_location']['column'])
if !l:end_col
let l:end_col = l:start_col + 1
endif
call add(l:output, {
\ 'lnum': str2nr(l:error['location']['line']),
\ 'col': l:start_col,
\ 'end_col': l:end_col,
\ 'code': l:error['rule_name'],
\ 'text': l:error['message'],
\ 'type': 'W',
\})
endfor
return l:output
endfunction
call ale#linter#Define('crystal', {
\ 'name': 'ameba',
\ 'executable': {b -> ale#Var(b, 'crystal_ameba_executable')},
\ 'command': function('ale_linters#crystal#ameba#GetCommand'),
\ 'callback': 'ale_linters#crystal#ameba#HandleAmebaOutput',
\ 'lint_file': 1,
\})

View File

@@ -5,10 +5,6 @@ function! ale_linters#crystal#crystal#Handle(buffer, lines) abort
let l:output = [] let l:output = []
for l:error in ale#util#FuzzyJSONDecode(a:lines, []) for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
if !has_key(l:error, 'file')
continue
endif
call add(l:output, { call add(l:output, {
\ 'lnum': l:error.line + 0, \ 'lnum': l:error.line + 0,
\ 'col': l:error.column + 0, \ 'col': l:error.column + 0,
@@ -30,6 +26,6 @@ call ale#linter#Define('crystal', {
\ 'executable': 'crystal', \ 'executable': 'crystal',
\ 'output_stream': 'both', \ 'output_stream': 'both',
\ 'lint_file': 1, \ 'lint_file': 1,
\ 'command': function('ale_linters#crystal#crystal#GetCommand'), \ 'command_callback': 'ale_linters#crystal#crystal#GetCommand',
\ 'callback': 'ale_linters#crystal#crystal#Handle', \ 'callback': 'ale_linters#crystal#crystal#Handle',
\}) \})

View File

@@ -1,90 +0,0 @@
call ale#Set('cs_csc_options', '')
call ale#Set('cs_csc_source', '')
call ale#Set('cs_csc_assembly_path', [])
call ale#Set('cs_csc_assemblies', [])
function! ale_linters#cs#csc#GetCwd(buffer) abort
let l:cwd = ale#Var(a:buffer, 'cs_csc_source')
return !empty(l:cwd) ? l:cwd : expand('#' . a:buffer . ':p:h')
endfunction
function! ale_linters#cs#csc#GetCommand(buffer) abort
" Pass assembly paths via the -lib: parameter.
let l:path_list = ale#Var(a:buffer, 'cs_csc_assembly_path')
let l:lib_option = !empty(l:path_list)
\ ? '/lib:' . join(map(copy(l:path_list), 'ale#Escape(v:val)'), ',')
\ : ''
" Pass paths to DLL files via the -r: parameter.
let l:assembly_list = ale#Var(a:buffer, 'cs_csc_assemblies')
let l:r_option = !empty(l:assembly_list)
\ ? '/r:' . join(map(copy(l:assembly_list), 'ale#Escape(v:val)'), ',')
\ : ''
" register temporary module target file with ale
" register temporary module target file with ALE.
let l:out = ale#command#CreateFile(a:buffer)
" The code is compiled as a module and the output is redirected to a
" temporary file.
return 'csc /unsafe'
\ . ale#Pad(ale#Var(a:buffer, 'cs_csc_options'))
\ . ale#Pad(l:lib_option)
\ . ale#Pad(l:r_option)
\ . ' /out:' . l:out
\ . ' /t:module'
\ . ' /recurse:' . ale#Escape('*.cs')
endfunction
function! ale_linters#cs#csc#Handle(buffer, lines) abort
" Look for lines like the following.
"
" Tests.cs(12,29): error CSXXXX: ; expected
"
" NOTE: pattern also captures file name as linter compiles all
" files within the source tree rooted at the specified source
" path and not just the file loaded in the buffer
let l:patterns = [
\ '^\v(.+\.cs)\((\d+),(\d+)\)\:\s+([^ ]+)\s+([cC][sS][^ ]+):\s(.+)$',
\ '^\v([^ ]+)\s+([Cc][sS][^ ]+):\s+(.+)$',
\]
let l:output = []
let l:dir = ale_linters#cs#csc#GetCwd(a:buffer)
for l:match in ale#util#GetMatches(a:lines, l:patterns)
if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS'
call add(l:output, {
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
\ 'code': l:match[5],
\ 'text': l:match[6] ,
\})
elseif strlen(l:match[2]) > 2 && l:match[2][:1] is? 'CS'
call add(l:output, {
\ 'filename':'<csc>',
\ 'lnum': -1,
\ 'col': -1,
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
\ 'code': l:match[2],
\ 'text': l:match[3],
\})
endif
endfor
return l:output
endfunction
call ale#linter#Define('cs',{
\ 'name': 'csc',
\ 'output_stream': 'stdout',
\ 'executable': 'csc',
\ 'cwd': function('ale_linters#cs#csc#GetCwd'),
\ 'command': function('ale_linters#cs#csc#GetCommand'),
\ 'callback': 'ale_linters#cs#csc#Handle',
\ 'lint_file': 1
\})

View File

@@ -1,5 +0,0 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for C# files.
call ale#handlers#cspell#DefineLinter('cs')

View File

@@ -32,6 +32,6 @@ call ale#linter#Define('cs',{
\ 'name': 'mcs', \ 'name': 'mcs',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable': 'mcs', \ 'executable': 'mcs',
\ 'command': function('ale_linters#cs#mcs#GetCommand'), \ 'command_callback': 'ale_linters#cs#mcs#GetCommand',
\ 'callback': 'ale_linters#cs#mcs#Handle', \ 'callback': 'ale_linters#cs#mcs#Handle',
\}) \})

View File

@@ -3,10 +3,14 @@ call ale#Set('cs_mcsc_source', '')
call ale#Set('cs_mcsc_assembly_path', []) call ale#Set('cs_mcsc_assembly_path', [])
call ale#Set('cs_mcsc_assemblies', []) call ale#Set('cs_mcsc_assemblies', [])
function! ale_linters#cs#mcsc#GetCwd(buffer) abort function! s:GetWorkingDirectory(buffer) abort
let l:cwd = ale#Var(a:buffer, 'cs_mcsc_source') let l:working_directory = ale#Var(a:buffer, 'cs_mcsc_source')
return !empty(l:cwd) ? l:cwd : expand('#' . a:buffer . ':p:h') if !empty(l:working_directory)
return l:working_directory
endif
return expand('#' . a:buffer . ':p:h')
endfunction endfunction
function! ale_linters#cs#mcsc#GetCommand(buffer) abort function! ale_linters#cs#mcsc#GetCommand(buffer) abort
@@ -26,11 +30,12 @@ function! ale_linters#cs#mcsc#GetCommand(buffer) abort
" register temporary module target file with ale " register temporary module target file with ale
" register temporary module target file with ALE. " register temporary module target file with ALE.
let l:out = ale#command#CreateFile(a:buffer) let l:out = ale#engine#CreateFile(a:buffer)
" The code is compiled as a module and the output is redirected to a " The code is compiled as a module and the output is redirected to a
" temporary file. " temporary file.
return 'mcs -unsafe' return ale#path#CdString(s:GetWorkingDirectory(a:buffer))
\ . 'mcs -unsafe'
\ . ale#Pad(ale#Var(a:buffer, 'cs_mcsc_options')) \ . ale#Pad(ale#Var(a:buffer, 'cs_mcsc_options'))
\ . ale#Pad(l:lib_option) \ . ale#Pad(l:lib_option)
\ . ale#Pad(l:r_option) \ . ale#Pad(l:r_option)
@@ -47,34 +52,20 @@ function! ale_linters#cs#mcsc#Handle(buffer, lines) abort
" NOTE: pattern also captures file name as linter compiles all " NOTE: pattern also captures file name as linter compiles all
" files within the source tree rooted at the specified source " files within the source tree rooted at the specified source
" path and not just the file loaded in the buffer " path and not just the file loaded in the buffer
let l:patterns = [ let l:pattern = '^\v(.+\.cs)\((\d+),(\d+)\)\: ([^ ]+) ([^ ]+): (.+)$'
\ '^\v(.+\.cs)\((\d+),(\d+)\)\:\s+([^ ]+)\s+([cC][sS][^ ]+):\s(.+)$',
\ '^\v([^ ]+)\s+([Cc][sS][^ ]+):\s+(.+)$',
\]
let l:output = [] let l:output = []
let l:dir = ale_linters#cs#mcsc#GetCwd(a:buffer) let l:dir = s:GetWorkingDirectory(a:buffer)
for l:match in ale#util#GetMatches(a:lines, l:patterns) for l:match in ale#util#GetMatches(a:lines, l:pattern)
if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS' call add(l:output, {
call add(l:output, { \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), \ 'lnum': l:match[2] + 0,
\ 'lnum': l:match[2] + 0, \ 'col': l:match[3] + 0,
\ 'col': l:match[3] + 0, \ 'type': l:match[4] is# 'error' ? 'E' : 'W',
\ 'type': l:match[4] is# 'error' ? 'E' : 'W', \ 'code': l:match[5],
\ 'code': l:match[5], \ 'text': l:match[6],
\ 'text': l:match[6] , \})
\})
elseif strlen(l:match[2]) > 2 && l:match[2][:1] is? 'CS'
call add(l:output, {
\ 'filename':'<mcs>',
\ 'lnum': -1,
\ 'col': -1,
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
\ 'code': l:match[2],
\ 'text': l:match[3],
\})
endif
endfor endfor
return l:output return l:output
@@ -84,8 +75,7 @@ call ale#linter#Define('cs',{
\ 'name': 'mcsc', \ 'name': 'mcsc',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable': 'mcs', \ 'executable': 'mcs',
\ 'cwd': function('ale_linters#cs#mcsc#GetCwd'), \ 'command_callback': 'ale_linters#cs#mcsc#GetCommand',
\ 'command': function('ale_linters#cs#mcsc#GetCommand'),
\ 'callback': 'ale_linters#cs#mcsc#Handle', \ 'callback': 'ale_linters#cs#mcsc#Handle',
\ 'lint_file': 1 \ 'lint_file': 1
\}) \})

View File

@@ -1,5 +0,0 @@
scriptencoding utf-8
" Author: David Houston <houstdav000>
" Description: cspell support for CSS files.
call ale#handlers#cspell#DefineLinter('css')

View File

@@ -13,6 +13,6 @@ endfunction
call ale#linter#Define('css', { call ale#linter#Define('css', {
\ 'name': 'csslint', \ 'name': 'csslint',
\ 'executable': 'csslint', \ 'executable': 'csslint',
\ 'command': function('ale_linters#css#csslint#GetCommand'), \ 'command_callback': 'ale_linters#css#csslint#GetCommand',
\ 'callback': 'ale#handlers#css#HandleCSSLintFormat', \ 'callback': 'ale#handlers#css#HandleCSSLintFormat',
\}) \})

View File

@@ -1,9 +0,0 @@
" Author: harttle <yangjvn@126.com>
" Description: fecs for CSS files
call ale#linter#Define('css', {
\ 'name': 'fecs',
\ 'executable': function('ale#handlers#fecs#GetExecutable'),
\ 'command': function('ale#handlers#fecs#GetCommand'),
\ 'callback': 'ale#handlers#fecs#Handle',
\})

View File

@@ -11,10 +11,9 @@ endfunction
call ale#linter#Define('css', { call ale#linter#Define('css', {
\ 'name': 'stylelint', \ 'name': 'stylelint',
\ 'output_stream': 'both', \ 'executable_callback': ale#node#FindExecutableFunc('css_stylelint', [
\ 'executable': {b -> ale#path#FindExecutable(b, 'css_stylelint', [
\ 'node_modules/.bin/stylelint', \ 'node_modules/.bin/stylelint',
\ ])}, \ ]),
\ 'command': function('ale_linters#css#stylelint#GetCommand'), \ 'command_callback': 'ale_linters#css#stylelint#GetCommand',
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
\}) \})

View File

@@ -1,16 +0,0 @@
" Author: Dalius Dobravolskas <dalius.dobravolskas@gmail.com>
" Description: VSCode css language server
function! ale_linters#css#vscodecss#GetProjectRoot(buffer) abort
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
endfunction
call ale#linter#Define('css', {
\ 'name': 'vscodecss',
\ 'lsp': 'stdio',
\ 'executable': 'vscode-css-language-server',
\ 'command': '%e --stdio',
\ 'project_root': function('ale_linters#css#vscodecss#GetProjectRoot'),
\})

View File

@@ -41,6 +41,6 @@ endfunction
call ale#linter#Define('cucumber', { call ale#linter#Define('cucumber', {
\ 'name': 'cucumber', \ 'name': 'cucumber',
\ 'executable': 'cucumber', \ 'executable': 'cucumber',
\ 'command': function('ale_linters#cucumber#cucumber#GetCommand'), \ 'command_callback': 'ale_linters#cucumber#cucumber#GetCommand',
\ 'callback': 'ale_linters#cucumber#cucumber#Handle' \ 'callback': 'ale_linters#cucumber#cucumber#Handle'
\}) \})

View File

@@ -1,23 +0,0 @@
" Author: Tommy Chiang <ty1208chiang@gmail.com>
" Description: Clangd language server for CUDA (modified from Andrey
" Melentyev's implementation for C++)
call ale#Set('cuda_clangd_executable', 'clangd')
call ale#Set('cuda_clangd_options', '')
call ale#Set('c_build_dir', '')
function! ale_linters#cuda#clangd#GetCommand(buffer) abort
let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
return '%e'
\ . ale#Pad(ale#Var(a:buffer, 'cuda_clangd_options'))
\ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '')
endfunction
call ale#linter#Define('cuda', {
\ 'name': 'clangd',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'cuda_clangd_executable')},
\ 'command': function('ale_linters#cuda#clangd#GetCommand'),
\ 'project_root': function('ale#c#FindProjectRoot'),
\})

View File

@@ -5,6 +5,9 @@ call ale#Set('cuda_nvcc_executable', 'nvcc')
call ale#Set('cuda_nvcc_options', '-std=c++11') call ale#Set('cuda_nvcc_options', '-std=c++11')
function! ale_linters#cuda#nvcc#GetCommand(buffer) abort function! ale_linters#cuda#nvcc#GetCommand(buffer) abort
" Unused: use ale#util#nul_file
" let l:output_file = ale#util#Tempname() . '.ii'
" call ale#engine#ManageFile(a:buffer, l:output_file)
return '%e -cuda' return '%e -cuda'
\ . ale#Pad(ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer))) \ . ale#Pad(ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer)))
\ . ale#Pad(ale#Var(a:buffer, 'cuda_nvcc_options')) \ . ale#Pad(ale#Var(a:buffer, 'cuda_nvcc_options'))
@@ -39,8 +42,8 @@ endfunction
call ale#linter#Define('cuda', { call ale#linter#Define('cuda', {
\ 'name': 'nvcc', \ 'name': 'nvcc',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'cuda_nvcc_executable')}, \ 'executable_callback': ale#VarFunc('cuda_nvcc_executable'),
\ 'command': function('ale_linters#cuda#nvcc#GetCommand'), \ 'command_callback': 'ale_linters#cuda#nvcc#GetCommand',
\ 'callback': 'ale_linters#cuda#nvcc#HandleNVCCFormat', \ 'callback': 'ale_linters#cuda#nvcc#HandleNVCCFormat',
\ 'lint_file': 1, \ 'lint_file': 1,
\}) \})

View File

@@ -1,26 +0,0 @@
" Author: Francisco Lopes <francisco@oblita.com>
" Description: Linting for Neo4j's Cypher
function! ale_linters#cypher#cypher_lint#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)
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'text': l:match[4],
\ 'type': 'E',
\})
endfor
return l:output
endfunction
call ale#linter#Define('cypher', {
\ 'name': 'cypher_lint',
\ 'executable': 'cypher-lint',
\ 'command': 'cypher-lint',
\ 'output_stream': 'stderr',
\ 'callback': 'ale_linters#cypher#cypher_lint#Handle',
\})

View File

@@ -16,7 +16,7 @@ endfunction
call ale#linter#Define('d', { call ale#linter#Define('d', {
\ 'name': 'dls', \ 'name': 'dls',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable': function('ale_linters#d#dls#GetExecutable'), \ 'executable_callback': 'ale_linters#d#dls#GetExecutable',
\ 'command': function('ale_linters#d#dls#GetExecutable'), \ 'command_callback': 'ale_linters#d#dls#GetExecutable',
\ 'project_root': function('ale_linters#d#dls#FindProjectRoot'), \ 'project_root_callback': 'ale_linters#d#dls#FindProjectRoot',
\}) \})

View File

@@ -1,106 +1,53 @@
" Author: w0rp <devw0rp@gmail.com> " Author: w0rp <devw0rp@gmail.com>
" Description: "dmd for D files" " Description: "dmd for D files"
function! s:GetDUBCommand(buffer) abort function! ale_linters#d#dmd#DUBCommand(buffer) abort
" If we can't run dub, then skip this command. " If we can't run dub, then skip this command.
if executable('dub') if !executable('dub')
" Returning an empty string skips to the DMD command. " Returning an empty string skips to the DMD command.
let l:config = ale#d#FindDUBConfig(a:buffer) return ''
" To support older dub versions, we just change the directory to the
" directory where we found the dub config, and then run `dub describe`
" from that directory.
if !empty(l:config)
return [fnamemodify(l:config, ':h'), 'dub describe --data-list
\ --data=import-paths
\ --data=string-import-paths
\ --data=versions
\ --data=debug-versions
\']
endif
endif endif
return ['', ''] let l:dub_file = ale#d#FindDUBConfig(a:buffer)
endfunction
function! ale_linters#d#dmd#RunDUBCommand(buffer) abort if empty(l:dub_file)
let [l:cwd, l:command] = s:GetDUBCommand(a:buffer) return ''
if empty(l:command)
" If we can't run DUB, just run DMD.
return ale_linters#d#dmd#DMDCommand(a:buffer, [], {})
endif endif
return ale#command#Run( " To support older dub versions, we just change the directory to
\ a:buffer, " the directory where we found the dub config, and then run `dub describe`
\ l:command, " from that directory.
\ function('ale_linters#d#dmd#DMDCommand'), return 'cd ' . ale#Escape(fnamemodify(l:dub_file, ':h'))
\ {'cwd': l:cwd}, \ . ' && dub describe --import-paths'
\)
endfunction endfunction
function! ale_linters#d#dmd#DMDCommand(buffer, dub_output, meta) abort function! ale_linters#d#dmd#DMDCommand(buffer, dub_output) abort
let l:import_list = [] let l:import_list = []
let l:str_import_list = []
let l:versions_list = []
let l:deb_versions_list = []
let l:list_ind = 1
let l:seen_line = 0
" Build a list of options generated from DUB, if available. " Build a list of import paths generated from DUB, if available.
" DUB output each path or version on a single line.
" Each list is separated by a blank line.
" Empty list are represented by a blank line (followed and/or
" preceded by a separation blank line)
for l:line in a:dub_output for l:line in a:dub_output
" line still has end of line char on windows
let l:line = substitute(l:line, '[\r\n]*$', '', '')
if !empty(l:line) if !empty(l:line)
if l:list_ind == 1 " The arguments must be '-Ifilename', not '-I filename'
call add(l:import_list, '-I' . ale#Escape(l:line)) call add(l:import_list, '-I' . ale#Escape(l:line))
elseif l:list_ind == 2
call add(l:str_import_list, '-J' . ale#Escape(l:line))
elseif l:list_ind == 3
call add(l:versions_list, '-version=' . ale#Escape(l:line))
elseif l:list_ind == 4
call add(l:deb_versions_list, '-debug=' . ale#Escape(l:line))
endif
let l:seen_line = 1
elseif !l:seen_line
" if list is empty must skip one empty line
let l:seen_line = 1
else
let l:seen_line = 0
let l:list_ind += 1
endif endif
endfor endfor
return 'dmd ' . join(l:import_list) . ' ' . return 'dmd '. join(l:import_list) . ' -o- -wi -vcolumns -c %t'
\ join(l:str_import_list) . ' ' .
\ join(l:versions_list) . ' ' .
\ join(l:deb_versions_list) . ' -o- -wi -vcolumns -c %t'
endfunction endfunction
function! ale_linters#d#dmd#Handle(buffer, lines) abort function! ale_linters#d#dmd#Handle(buffer, lines) abort
" Matches patterns lines like the following: " Matches patterns lines like the following:
" /tmp/tmp.qclsa7qLP7/file.d(1): Error: function declaration without return type. (Note that constructors are always named 'this') " /tmp/tmp.qclsa7qLP7/file.d(1): Error: function declaration without return type. (Note that constructors are always named 'this')
" /tmp/tmp.G1L5xIizvB.d(8,8): Error: module weak_reference is in file 'dstruct/weak_reference.d' which cannot be read " /tmp/tmp.G1L5xIizvB.d(8,8): Error: module weak_reference is in file 'dstruct/weak_reference.d' which cannot be read
let l:pattern = '\v^(\f+)\((\d+)(,(\d+))?\): (\w+): (.+)$' let l:pattern = '^[^(]\+(\([0-9]\+\)\,\?\([0-9]*\)): \([^:]\+\): \(.\+\)'
let l:output = [] let l:output = []
let l:dir = expand('#' . a:buffer . ':p:h')
for l:match in ale#util#GetMatches(a:lines, l:pattern) for l:match in ale#util#GetMatches(a:lines, l:pattern)
" If dmd was invoked with relative path, match[1] is relative, otherwise it is absolute.
" As we invoke dmd with the buffer path (in /tmp), this will generally be absolute already
let l:fname = ale#path#GetAbsPath(l:dir, l:match[1])
call add(l:output, { call add(l:output, {
\ 'filename': l:fname, \ 'lnum': l:match[1],
\ 'lnum': l:match[2], \ 'col': l:match[2],
\ 'col': l:match[4], \ 'type': l:match[3] is# 'Warning' ? 'W' : 'E',
\ 'type': l:match[5] is# 'Warning' || l:match[5] is# 'Deprecation' ? 'W' : 'E', \ 'text': l:match[4],
\ 'text': l:match[6],
\}) \})
endfor endfor
@@ -110,7 +57,9 @@ endfunction
call ale#linter#Define('d', { call ale#linter#Define('d', {
\ 'name': 'dmd', \ 'name': 'dmd',
\ 'executable': 'dmd', \ 'executable': 'dmd',
\ 'command': function('ale_linters#d#dmd#RunDUBCommand'), \ 'command_chain': [
\ {'callback': 'ale_linters#d#dmd#DUBCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#d#dmd#DMDCommand', 'output_stream': 'stderr'},
\ ],
\ 'callback': 'ale_linters#d#dmd#Handle', \ 'callback': 'ale_linters#d#dmd#Handle',
\ 'output_stream': 'stderr',
\}) \})

View File

@@ -1,5 +1,4 @@
" Author: Taylor Blau <me@ttaylorr.com> " Author: Taylor Blau <me@ttaylorr.com>
call ale#Set('dafny_dafny_timelimit', 10)
function! ale_linters#dafny#dafny#Handle(buffer, lines) abort function! ale_linters#dafny#dafny#Handle(buffer, lines) abort
let l:pattern = '\v(.*)\((\d+),(\d+)\): (.*): (.*)' let l:pattern = '\v(.*)\((\d+),(\d+)\): (.*): (.*)'
@@ -7,7 +6,7 @@ function! ale_linters#dafny#dafny#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern) for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, { call add(l:output, {
\ 'filename': l:match[1], \ 'bufnr': a:buffer,
\ 'col': l:match[3] + 0, \ 'col': l:match[3] + 0,
\ 'lnum': l:match[2] + 0, \ 'lnum': l:match[2] + 0,
\ 'text': l:match[5], \ 'text': l:match[5],
@@ -15,27 +14,13 @@ function! ale_linters#dafny#dafny#Handle(buffer, lines) abort
\ }) \ })
endfor endfor
for l:match in ale#util#GetMatches(a:lines, '\v(.*)\((\d+),(\d+)\): (Verification of .{-} timed out after \d+ seconds)')
call add(l:output, {
\ 'filename': l:match[1],
\ 'col': l:match[3] + 0,
\ 'lnum': l:match[2] + 0,
\ 'text': l:match[4],
\ 'type': 'E',
\ })
endfor
return l:output return l:output
endfunction endfunction
function! ale_linters#dafny#dafny#GetCommand(buffer) abort
return printf('dafny %%s /compile:0 /timeLimit:%d', ale#Var(a:buffer, 'dafny_dafny_timelimit'))
endfunction
call ale#linter#Define('dafny', { call ale#linter#Define('dafny', {
\ 'name': 'dafny', \ 'name': 'dafny',
\ 'executable': 'dafny', \ 'executable': 'dafny',
\ 'command': function('ale_linters#dafny#dafny#GetCommand'), \ 'command': 'dafny %s /compile:0',
\ 'callback': 'ale_linters#dafny#dafny#Handle', \ 'callback': 'ale_linters#dafny#dafny#Handle',
\ 'lint_file': 1, \ 'lint_file': 1,
\ }) \ })

View File

@@ -1,37 +0,0 @@
" Author: Nelson Yeung <nelsyeung@gmail.com>
" Description: Check Dart files with dart analysis server LSP
call ale#Set('dart_analysis_server_enable_language_server', 1)
call ale#Set('dart_analysis_server_executable', 'dart')
function! ale_linters#dart#analysis_server#GetProjectRoot(buffer) abort
" Note: pub only looks for pubspec.yaml, there's no point in adding
" support for pubspec.yml
let l:pubspec = ale#path#FindNearestFile(a:buffer, 'pubspec.yaml')
return !empty(l:pubspec) ? fnamemodify(l:pubspec, ':h:h') : '.'
endfunction
function! ale_linters#dart#analysis_server#GetCommand(buffer) abort
let l:language_server = ale#Var(a:buffer, 'dart_analysis_server_enable_language_server')
let l:executable = ale#Var(a:buffer, 'dart_analysis_server_executable')
let l:dart = resolve(exepath(l:executable))
let l:output = '%e '
\ . fnamemodify(l:dart, ':h') . '/snapshots/analysis_server.dart.snapshot'
\ . ' --lsp'
" Enable new language-server command
if l:language_server == 1
let l:output = '%e language-server --protocol=lsp'
endif
return l:output
endfunction
call ale#linter#Define('dart', {
\ 'name': 'analysis_server',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'dart_analysis_server_executable')},
\ 'command': function('ale_linters#dart#analysis_server#GetCommand'),
\ 'project_root': function('ale_linters#dart#analysis_server#GetProjectRoot'),
\})

View File

@@ -1,29 +0,0 @@
" Author: ghsang <gwonhyuksang@gmail.com>
" Description: Check Dart files with dart analyze
call ale#Set('dart_analyze_executable', 'dart')
function! ale_linters#dart#dart_analyze#Handle(buffer, lines) abort
let l:pattern = '\v([a-z]+) - (.+):(\d+):(\d+) - (.+) - (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let [l:type, l:filename, l:lnum, l:col, l:message, l:code] = l:match[1:6]
call add(l:output, {
\ 'type': l:type is# 'error' ? 'E' : l:type is# 'info' ? 'I' : 'W',
\ 'text': l:code . ': ' . l:message,
\ 'lnum': str2nr(l:lnum),
\ 'col': str2nr(l:col),
\})
endfor
return l:output
endfunction
call ale#linter#Define('dart', {
\ 'name': 'dart_analyze',
\ 'executable': {b -> ale#Var(b, 'dart_analyze_executable')},
\ 'command': '%e analyze --fatal-infos %s',
\ 'callback': 'ale_linters#dart#dart_analyze#Handle',
\ 'lint_file': 1,
\})

View File

@@ -0,0 +1,36 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: Check Dart files with dartanalyzer
call ale#Set('dart_dartanalyzer_executable', 'dartanalyzer')
function! ale_linters#dart#dartanalyzer#GetCommand(buffer) abort
let l:path = ale#path#FindNearestFile(a:buffer, '.packages')
return '%e'
\ . (!empty(l:path) ? ' --packages ' . ale#Escape(l:path) : '')
\ . ' %s'
endfunction
function! ale_linters#dart#dartanalyzer#Handle(buffer, lines) abort
let l:pattern = '\v^ ([a-z]+) . (.+) at (.+):(\d+):(\d+) . (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
\ 'text': l:match[6] . ': ' . l:match[2],
\ 'lnum': str2nr(l:match[4]),
\ 'col': str2nr(l:match[5]),
\})
endfor
return l:output
endfunction
call ale#linter#Define('dart', {
\ 'name': 'dartanalyzer',
\ 'executable_callback': ale#VarFunc('dart_dartanalyzer_executable'),
\ 'command_callback': 'ale_linters#dart#dartanalyzer#GetCommand',
\ 'callback': 'ale_linters#dart#dartanalyzer#Handle',
\ 'lint_file': 1,
\})

View File

@@ -14,7 +14,7 @@ endfunction
call ale#linter#Define('dart', { call ale#linter#Define('dart', {
\ 'name': 'language_server', \ 'name': 'language_server',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'dart_language_server_executable')}, \ 'executable_callback': ale#VarFunc('dart_language_server_executable'),
\ 'command': '%e', \ 'command': '%e',
\ 'project_root': function('ale_linters#dart#language_server#GetProjectRoot'), \ 'project_root_callback': 'ale_linters#dart#language_server#GetProjectRoot',
\}) \})

View File

@@ -1,31 +0,0 @@
call ale#Set('desktop_desktop_file_validate_options', '')
" Example matches for pattern:
"
" foo.desktop: warning: key "TerminalOptions" in group ...
" foo.desktop: error: action "new-private-window" is defined, ...
let s:pattern = '\v^(.+): ([a-z]+): (.+)$'
function! ale_linters#desktop#desktop_file_validate#Handle(buffer, lines) abort
" The error format doesn't specify lines, so we can just put all of the
" errors on line 1.
return ale#util#MapMatches(a:lines, s:pattern, {match -> {
\ 'lnum': 1,
\ 'col': 1,
\ 'type': match[2] is? 'error' ? 'E' : 'W',
\ 'text': match[3],
\}})
endfunction
call ale#linter#Define('desktop', {
\ 'name': 'desktop_file_validate',
\ 'aliases': ['desktop-file-validate'],
\ 'executable': 'desktop-file-validate',
\ 'command': {b ->
\ '%e'
\ . ale#Pad(ale#Var(b, 'desktop_desktop_file_validate_options'))
\ . ' %t'
\ },
\ 'callback': 'ale_linters#desktop#desktop_file_validate#Handle',
\ 'output_stream': 'both',
\})

View File

@@ -32,29 +32,14 @@ function! ale_linters#dockerfile#dockerfile_lint#Handle(buffer, lines) abort
let l:line = get(l:object, 'line', -1) let l:line = get(l:object, 'line', -1)
let l:message = l:object['message'] let l:message = l:object['message']
let l:link = get(l:object, 'reference_url', '')
if type(l:link) == v:t_list
" Somehow, reference_url is returned as two-part list.
" Anchor markers in that list are sometimes duplicated.
" See https://github.com/projectatomic/dockerfile_lint/issues/134
let l:link = join(l:link, '')
let l:link = substitute(l:link, '##', '#', '')
endif
let l:detail = l:message
if get(l:object, 'description', 'None') isnot# 'None' if get(l:object, 'description', 'None') isnot# 'None'
let l:detail .= "\n\n" . l:object['description'] let l:message = l:message . '. ' . l:object['description']
endif endif
let l:detail .= "\n\n" . l:link
call add(l:messages, { call add(l:messages, {
\ 'lnum': l:line, \ 'lnum': l:line,
\ 'text': l:message, \ 'text': l:message,
\ 'type': ale_linters#dockerfile#dockerfile_lint#GetType(l:type), \ 'type': ale_linters#dockerfile#dockerfile_lint#GetType(l:type),
\ 'detail': l:detail,
\}) \})
endfor endfor
endfor endfor
@@ -70,7 +55,7 @@ endfunction
call ale#linter#Define('dockerfile', { call ale#linter#Define('dockerfile', {
\ 'name': 'dockerfile_lint', \ 'name': 'dockerfile_lint',
\ 'executable': {b -> ale#Var(b, 'dockerfile_dockerfile_lint_executable')}, \ 'executable_callback': ale#VarFunc('dockerfile_dockerfile_lint_executable'),
\ 'command': function('ale_linters#dockerfile#dockerfile_lint#GetCommand'), \ 'command_callback': 'ale_linters#dockerfile#dockerfile_lint#GetCommand',
\ 'callback': 'ale_linters#dockerfile#dockerfile_lint#Handle', \ 'callback': 'ale_linters#dockerfile#dockerfile_lint#Handle',
\}) \})

Some files were not shown because too many files have changed in this diff Show More