Compare commits

...

11 Commits

Author SHA1 Message Date
Mikhail Velikikh
baaca9a5d7 Use ale#Escape in c_clangformat_style_option (#4949)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
* Use ale#Escape in c_clangformat_style_option
* Update Vader test
2025-04-16 02:29:57 +00:00
Jean-Philippe Guérard
aac34cd45a Add bash to the linter aliases (#4948) 2025-04-16 02:28:32 +00:00
w0rp
366de225fd Mention, but do not scream when a file changes before it is fixed
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
2025-04-10 15:17:35 +01:00
PizZaKatZe
22185c4c5c Remove ANSI color codes from nix linter messages (#4944)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
* Remove ANSI color codes from nix linter messages

* Add test for color-coded nix linter findings

* Fix test: Escape backslashes

---------

Co-authored-by: Sebastian Neuser <sebastian.neuser@fnordkollektiv.de>
Co-authored-by: Sebastian Neuser <haggl@sineband.de>
2025-04-07 20:23:13 +09:00
Josh Pencheon
2883260ade Correctly identify tempfiles once symlinks are resolved (#3726)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
Some linters will expand the paths of symlinked tempfiles when
reporting them back to ALE. This ensures that if they do, the filename
is still flagged appropriately as being temporary.
2025-04-02 21:48:32 +09:00
Dmitri Vereshchagin
090d31b79a Always use safe file local variables for erlang-mode fixer (#4942)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
File local variables in Emacs are used in a way similar to Vim
modelines.  For example, at the end of the file you might find something
like the following:

    %% Local Variables:
    %% erlang-indent-level: 2
    %% something-weird: t
    %% End:

The `erlang-indent-level' variable in this list instructs the Erlang
mode to use two columns per indentation level.  But since the
`something-weird' variable is likely unknown, both may be ignored.

By default, Emacs in batch mode ignores all variable/value pairs if it
encounters at least one that is not known to be safe.  Setting
`enable-local-variables' to `:safe' tells Emacs to use only safe values
and ignore the rest.
2025-04-01 20:44:57 +09:00
Horacio Sanson
067e74fee8 Add support for glnagci-lint v2 (#4936)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
Version 2 of golangci-lint introduces several breaking changes to the
command line arguments and the configuration file.

Thi PR updates ale integration to support both version 1.6x.x and 2.x.x
of golangci-lint.
2025-03-31 11:46:42 +01:00
Dmitri Vereshchagin
ff8fe94494 Remove hadolint rule code from location list entry text (#4939)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
The code is already passed with the code key of location list entry.
Before this change, when using the default message format, it appeared
twice in the description of each location list entry and twice in each
echo message.
2025-03-30 13:58:04 +09:00
w0rp
6433d31f47 Update ale_disable_lsp documentation to clarify options
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
2025-03-29 13:34:22 +00:00
w0rp
f3f0b05240 Fix #4935 - Send tsserver messsages to tsserver in Neovim 2025-03-29 13:25:49 +00:00
w0rp
add538213f Set up Lua development for Macs with Homebrew
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
2025-03-28 16:20:18 +00:00
18 changed files with 94 additions and 24 deletions

View File

@@ -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": [

View File

@@ -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'

View File

@@ -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,
\})

View File

@@ -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

View File

@@ -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

View File

@@ -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

View 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))',

View File

@@ -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',

View File

@@ -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,

View File

@@ -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

View File

@@ -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',

View File

@@ -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)

View File

@@ -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
)

View File

@@ -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(''))

View File

@@ -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\>'

View File

@@ -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.",
\ },
\ ],

View File

@@ -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
\ [

View File

@@ -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'