mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Compare commits
11 Commits
neovim-lsp
...
baaca9a5d7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
baaca9a5d7 | ||
|
|
aac34cd45a | ||
|
|
366de225fd | ||
|
|
22185c4c5c | ||
|
|
2883260ade | ||
|
|
090d31b79a | ||
|
|
067e74fee8 | ||
|
|
ff8fe94494 | ||
|
|
6433d31f47 | ||
|
|
f3f0b05240 | ||
|
|
add538213f |
@@ -7,7 +7,8 @@
|
||||
"test"
|
||||
],
|
||||
"workspace.library": [
|
||||
"/usr/share/nvim/runtime/lua"
|
||||
"/usr/share/nvim/runtime/lua",
|
||||
"/opt/homebrew/share/nvim/runtime/lua"
|
||||
],
|
||||
"runtime.pathStrict": true,
|
||||
"runtime.path": [
|
||||
|
||||
@@ -49,7 +49,6 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
|
||||
if l:match[5] isnot# ''
|
||||
let l:code = l:match[4] . l:match[5]
|
||||
let l:link = ' ( ' . l:domain . l:code . ' )'
|
||||
let l:text = l:code . ': ' . l:detail
|
||||
let l:detail = l:code . l:link . "\n\n" . l:detail
|
||||
else
|
||||
let l:type = 'E'
|
||||
|
||||
@@ -5,26 +5,38 @@ call ale#Set('go_golangci_lint_options', '')
|
||||
call ale#Set('go_golangci_lint_executable', 'golangci-lint')
|
||||
call ale#Set('go_golangci_lint_package', 1)
|
||||
|
||||
function! ale_linters#go#golangci_lint#GetCommand(buffer) abort
|
||||
function! ale_linters#go#golangci_lint#GetExecutable(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'go_golangci_lint_executable')
|
||||
|
||||
return l:executable
|
||||
endfunction
|
||||
|
||||
function! ale_linters#go#golangci_lint#GetCommand(buffer, version) abort
|
||||
let l:filename = expand('#' . a:buffer . ':t')
|
||||
let l:options = ale#Var(a:buffer, 'go_golangci_lint_options')
|
||||
let l:lint_package = ale#Var(a:buffer, 'go_golangci_lint_package')
|
||||
|
||||
if ale#semver#GTE(a:version, [2, 0, 0])
|
||||
let l:options = l:options
|
||||
\ . ' --output.json.path stdout'
|
||||
\ . ' --output.text.path stderr'
|
||||
\ . ' --show-stats=0'
|
||||
else
|
||||
let l:options = l:options
|
||||
\ . ' --out-format=json'
|
||||
\ . ' --show-stats=0'
|
||||
endif
|
||||
|
||||
if l:lint_package
|
||||
return ale#go#EnvString(a:buffer)
|
||||
\ . '%e run '
|
||||
\ . l:options
|
||||
\ . ' --out-format=json'
|
||||
\ . ' --show-stats=0'
|
||||
endif
|
||||
|
||||
return ale#go#EnvString(a:buffer)
|
||||
\ . '%e run '
|
||||
\ . ale#Escape(l:filename)
|
||||
\ . ' ' . l:options
|
||||
\ . ' --out-format=json'
|
||||
\ . ' --show-stats=0'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#go#golangci_lint#Handler(buffer, lines) abort
|
||||
@@ -58,9 +70,14 @@ endfunction
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'golangci-lint',
|
||||
\ 'executable': {b -> ale#Var(b, 'go_golangci_lint_executable')},
|
||||
\ 'executable': function('ale_linters#go#golangci_lint#GetExecutable'),
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#go#golangci_lint#GetCommand'),
|
||||
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
|
||||
\ buffer,
|
||||
\ ale_linters#go#golangci_lint#GetExecutable(buffer),
|
||||
\ '%e --version',
|
||||
\ function('ale_linters#go#golangci_lint#GetCommand'),
|
||||
\ )},
|
||||
\ 'callback': 'ale_linters#go#golangci_lint#Handler',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
|
||||
@@ -29,7 +29,7 @@ function! ale_linters#nix#nix#Handle(buffer, lines) abort
|
||||
\ 'type': 'E',
|
||||
\ 'lnum': l:result.line,
|
||||
\ 'col': l:result.column,
|
||||
\ 'text': l:result.raw_msg
|
||||
\ 'text': substitute(l:result.raw_msg, '\e\[[0-9;]*m', '', 'g'),
|
||||
\})
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -78,7 +78,7 @@ function! ale#fix#ApplyFixes(buffer, output) abort
|
||||
|
||||
if !l:data.ignore_file_changed_errors
|
||||
" no-custom-checks
|
||||
echoerr 'The file was changed before fixing finished'
|
||||
echom 'The file was changed before fixing finished'
|
||||
endif
|
||||
|
||||
return
|
||||
|
||||
@@ -22,7 +22,7 @@ function! ale#fixers#clangformat#Fix(buffer) abort
|
||||
let l:use_local_file = ale#Var(a:buffer, 'c_clangformat_use_local_file')
|
||||
|
||||
if l:style_option isnot# ''
|
||||
let l:style_option = '-style=' . "'" . l:style_option . "'"
|
||||
let l:style_option = '-style=' . ale#Escape(l:style_option)
|
||||
endif
|
||||
|
||||
if l:use_local_file
|
||||
|
||||
@@ -17,10 +17,11 @@ let s:variables = {
|
||||
\}
|
||||
|
||||
function! ale#fixers#erlang_mode#Fix(buffer) abort
|
||||
let emacs_executable =
|
||||
let l:emacs_executable =
|
||||
\ ale#Var(a:buffer, 'erlang_erlang_mode_emacs_executable')
|
||||
|
||||
let l:exprs = [
|
||||
\ '(setq enable-local-variables :safe)',
|
||||
\ s:SetqDefault(a:buffer, s:variables),
|
||||
\ '(erlang-mode)',
|
||||
\ '(font-lock-fontify-region (point-min) (point-max))',
|
||||
|
||||
@@ -11,6 +11,7 @@ let s:linters = {}
|
||||
" NOTE: Update the g:ale_linter_aliases documentation when modifying this.
|
||||
let s:default_ale_linter_aliases = {
|
||||
\ 'Dockerfile': 'dockerfile',
|
||||
\ 'bash': 'sh',
|
||||
\ 'csh': 'sh',
|
||||
\ 'javascriptreact': ['javascript', 'jsx'],
|
||||
\ 'plaintex': 'tex',
|
||||
|
||||
@@ -706,7 +706,7 @@ function! ale#lsp#Send(conn_id, message) abort
|
||||
throw 'LSP server not initialized yet!'
|
||||
endif
|
||||
|
||||
if g:ale_use_neovim_lsp_api
|
||||
if g:ale_use_neovim_lsp_api && !l:conn.is_tsserver
|
||||
return luaeval('require("ale.lsp").send_message(_A)', {
|
||||
\ 'client_id': l:conn.client_id,
|
||||
\ 'is_notification': a:message[0] == 1 ? v:true : v:false,
|
||||
|
||||
@@ -124,11 +124,16 @@ function! ale#path#IsAbsolute(filename) abort
|
||||
endfunction
|
||||
|
||||
let s:temp_dir = ale#path#Simplify(fnamemodify(ale#util#Tempname(), ':h:h'))
|
||||
let s:resolved_temp_dir = resolve(s:temp_dir)
|
||||
|
||||
" Given a filename, return 1 if the file represents some temporary file
|
||||
" created by Vim.
|
||||
" created by Vim. If the temporary location is symlinked (e.g. macOS), some
|
||||
" linters may report the resolved version of the path, so both are checked.
|
||||
function! ale#path#IsTempName(filename) abort
|
||||
return ale#path#Simplify(a:filename)[:len(s:temp_dir) - 1] is# s:temp_dir
|
||||
let l:filename = ale#path#Simplify(a:filename)
|
||||
|
||||
return l:filename[:len(s:temp_dir) - 1] is# s:temp_dir
|
||||
\|| l:filename[:len(s:resolved_temp_dir) - 1] is# s:resolved_temp_dir
|
||||
endfunction
|
||||
|
||||
" Given a base directory, which must not have a trailing slash, and a
|
||||
|
||||
@@ -1192,13 +1192,13 @@ g:ale_detail_to_floating_preview
|
||||
*b:ale_disable_lsp*
|
||||
disable_lsp
|
||||
g:ale_disable_lsp
|
||||
Type: |Number| OR |String|
|
||||
Type: |Boolean| OR |Number| OR |String|
|
||||
Default: `'auto'`
|
||||
|
||||
When this option is set to `'auto'`, ALE will automatically disable linters
|
||||
that it detects as having already been configured with the `nvim-lspconfig`
|
||||
plugin. When this option is set to `1`, ALE ignores all linters powered by
|
||||
LSP, and also `tsserver`.
|
||||
plugin. When this option is set to `true` or `1`, ALE ignores all linters
|
||||
powered by LSP, and also `tsserver`.
|
||||
|
||||
Any linters that are disabled will also not be usable for LSP functionality
|
||||
other than just linting.
|
||||
@@ -1735,6 +1735,7 @@ g:ale_linter_aliases
|
||||
|
||||
{
|
||||
\ 'Dockerfile': 'dockerfile',
|
||||
\ 'bash': 'sh',
|
||||
\ 'csh': 'sh',
|
||||
\ 'javascriptreact': ['javascript', 'jsx'],
|
||||
\ 'plaintex': 'tex',
|
||||
|
||||
@@ -67,7 +67,7 @@ module.send = function(buffer, loclist)
|
||||
local local_cfg = { priority = sign_priority }
|
||||
local global_cfg = vim.diagnostic.config().signs
|
||||
|
||||
if type(global_cfg) == "boolean" then
|
||||
if global_cfg == false or global_cfg == true or global_cfg == nil then
|
||||
signs = local_cfg
|
||||
elseif type(global_cfg) == "table" then
|
||||
signs = vim.tbl_extend("force", global_cfg, local_cfg)
|
||||
|
||||
@@ -150,12 +150,14 @@ module.send_message = function(args)
|
||||
success, request_id = client.request(
|
||||
args.method,
|
||||
args.params,
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
function(_, result, _, _)
|
||||
vim.fn["ale#lsp#HandleResponse"](client.name, {
|
||||
id = request_id,
|
||||
result = result,
|
||||
})
|
||||
end,
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
-1
|
||||
)
|
||||
|
||||
|
||||
@@ -45,7 +45,8 @@ Execute(The clangformat callback should include style options as well):
|
||||
\ {
|
||||
\ 'command': ale#Escape(g:ale_c_clangformat_executable)
|
||||
\ . ' --assume-filename=' . ale#Escape(bufname(bufnr('')))
|
||||
\ . ' --some-option' . " -style='{BasedOnStyle: Microsoft, ColumnLimit:80,}'",
|
||||
\ . ' --some-option'
|
||||
\ . ' -style=' . ale#Escape(g:ale_c_clangformat_style_option)
|
||||
\ },
|
||||
\ ale#fixers#clangformat#Fix(bufnr(''))
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ Execute(Emacs executable should be configurable):
|
||||
let b:ale_erlang_erlang_mode_emacs_executable = '/path/to/emacs'
|
||||
AssertEqual 0, stridx(Fixer('command'), ale#Escape('/path/to/emacs'))
|
||||
|
||||
Execute(enable-local-variables should be :safe):
|
||||
Assert Fixer('command') =~# '\m\<enable-local-variables :safe\>'
|
||||
|
||||
Execute(erlang-indent-level should be 4 by default):
|
||||
Assert Fixer('command') =~# '\m\<erlang-indent-level 4\>'
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ Execute(The hadolint handler should handle a normal example):
|
||||
\ 'col': 0,
|
||||
\ 'type': 'W',
|
||||
\ 'code': 'DL3006',
|
||||
\ 'text': "DL3006: Always tag the version of an image explicitly",
|
||||
\ 'text': 'Always tag the version of an image explicitly',
|
||||
\ 'detail': "DL3006 ( https://github.com/hadolint/hadolint/wiki/DL3006 )\n\nAlways tag the version of an image explicitly",
|
||||
\ },
|
||||
\ {
|
||||
@@ -25,7 +25,7 @@ Execute(The hadolint handler should handle a normal example):
|
||||
\ 'col': 0,
|
||||
\ 'type': 'W',
|
||||
\ 'code': 'DL3033',
|
||||
\ 'text': "DL3033: Specify version with `yum install -y <package>-<version>`.",
|
||||
\ 'text': 'Specify version with `yum install -y <package>-<version>`.',
|
||||
\ 'detail': "DL3033 ( https://github.com/hadolint/hadolint/wiki/DL3033 )\n\nSpecify version with `yum install -y <package>-<version>`.",
|
||||
\ },
|
||||
\ {
|
||||
@@ -33,7 +33,7 @@ Execute(The hadolint handler should handle a normal example):
|
||||
\ 'col': 0,
|
||||
\ 'type': 'W',
|
||||
\ 'code': 'SC2039',
|
||||
\ 'text': "SC2039: In POSIX sh, brace expansion is undefined.",
|
||||
\ 'text': 'In POSIX sh, brace expansion is undefined.',
|
||||
\ 'detail': "SC2039 ( https://github.com/koalaman/shellcheck/wiki/SC2039 )\n\nIn POSIX sh, brace expansion is undefined.",
|
||||
\ },
|
||||
\ ],
|
||||
|
||||
@@ -27,6 +27,22 @@ Execute(The nix handler should parse nix-instantiate error messages correctly):
|
||||
\ "@nix {\"unrelated\":\"message\"}"
|
||||
\ ])
|
||||
|
||||
Execute(The nix handler should parse nix-instantiate error messages with ANSI color codes correctly):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 5,
|
||||
\ 'type': 'E',
|
||||
\ 'text': "undefined variable 'foo'",
|
||||
\ },
|
||||
\
|
||||
\ ],
|
||||
\ ale_linters#nix#nix#Handle(bufnr(''), [
|
||||
\ "@nix {\"line\":3,\"column\":5,\"raw_msg\":\"undefined variable '\\u001b[35;1mfoo\\u001b[0m'\"}",
|
||||
\ "@nix {\"unrelated\":\"message\"}"
|
||||
\ ])
|
||||
|
||||
Execute(The nix handler should parse message from old nix-instantiate correctly):
|
||||
AssertEqual
|
||||
\ [
|
||||
|
||||
@@ -4,6 +4,9 @@ Before:
|
||||
call ale#assert#SetUpLinterTest('go', 'golangci_lint')
|
||||
call ale#test#SetFilename('test.go')
|
||||
|
||||
" Test with version 1.64.8 by default
|
||||
GivenCommandOutput ['golangci-lint has version 1.64.8 built with go1.23.0']
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
@@ -16,6 +19,18 @@ Execute(The golangci-lint defaults should be correct):
|
||||
AssertLinter 'golangci-lint',
|
||||
\ ale#Escape('golangci-lint') . ' run --out-format=json --show-stats=0'
|
||||
|
||||
Execute(The golangci-lint defaults should be correct with no version info):
|
||||
GivenCommandOutput []
|
||||
AssertLinterCwd '%s:h',
|
||||
AssertLinter 'golangci-lint',
|
||||
\ ale#Escape('golangci-lint') . ' run --out-format=json --show-stats=0'
|
||||
|
||||
Execute(The golangci-lint defaults should be correct with version 2):
|
||||
GivenCommandOutput ['golangci-lint has version 2.0.2 built with go1.24.0']
|
||||
AssertLinterCwd '%s:h',
|
||||
AssertLinter 'golangci-lint',
|
||||
\ ale#Escape('golangci-lint') . ' run --output.json.path stdout --output.text.path stderr --show-stats=0'
|
||||
|
||||
Execute(The golangci-lint callback should use a configured executable):
|
||||
let b:ale_go_golangci_lint_executable = 'something else'
|
||||
|
||||
@@ -23,6 +38,14 @@ Execute(The golangci-lint callback should use a configured executable):
|
||||
\ ale#Escape('something else')
|
||||
\ . ' run --out-format=json --show-stats=0'
|
||||
|
||||
Execute(The golangci-lint callback should use a configured version 2 executable):
|
||||
GivenCommandOutput ['golangci-lint has version 2.0.0 built with go1.22.0']
|
||||
let b:ale_go_golangci_lint_executable = 'something else'
|
||||
|
||||
AssertLinter 'something else',
|
||||
\ ale#Escape('something else')
|
||||
\ . ' run --output.json.path stdout --output.text.path stderr --show-stats=0'
|
||||
|
||||
Execute(The golangci-lint callback should use configured options):
|
||||
let b:ale_go_golangci_lint_options = '--foobar'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user