Compare commits

..

19 Commits

Author SHA1 Message Date
w0rp
e1c8d665d6 #3600 Implement pull model with Neovim Client
Implement the diagnostics pull model with the LSP Neovim client. We
must handle messages a little different and tweak client capabilities
for pull diagnostics to work through the Neovim client.
2025-03-23 16:08:18 +00:00
w0rp
fe50a711cb Close #3600 - Implement pull diagnostics in VimL
Implement pull diagnostics in the VimL implementation so ALE is able
to track when servers are busy checking files. Only servers that
support this feature will return diagnostics these ways.
2025-03-23 16:07:46 +00:00
w0rp
19e1b5a9d3 Implement ale.queue for calling ale#Queue in Lua 2025-03-22 01:10:11 +00:00
w0rp
33a902f489 Implement ale.pad in Lua 2025-03-22 00:43:29 +00:00
w0rp
a1c57918ef Implement ale.get_filename_mappings in Lua 2025-03-22 00:35:53 +00:00
w0rp
1aae83497d Add ale.has to mirror ale#Has in Lua 2025-03-22 00:04:46 +00:00
w0rp
f4af0dc84b Add basic Lua ALE functions and test coverage
Ensure that basic ALE functions `ale.var`, `ale.escape`, and `ale.env`
are available in Lua. Cover all Lua code so far with busted tests,
fixing bugs where ALE variables can be set with Boolean values instead
of numbers. Document all functionality so far.
2025-03-21 23:37:35 +00:00
w0rp
7f43666fb3 Detect the Lua project root using .luarc.json 2025-03-21 12:07:10 +00:00
w0rp
bcd1a12949 Implement Lua ALE setup & overhaul documentation
1. Add ale.setup and ale.setup.buffer for pure Lua configuration.
2. Update many global settings to use Booleans instead of numbers to
   make types easiert to work with in Lua.
3. Radically reformat documentation and fix errors to make
   documentation more usable for Neovim users.
2025-03-20 21:52:13 +00:00
w0rp
53f036fe9f Support g:ale_shell with the Neovim LSP client 2025-03-20 21:45:19 +00:00
w0rp
3dfebe45c6 Add Neovim TCP connections to language servers
Support TCP connections to language servers through Neovim's built in
client. In all but what is currently the nightly builds of Neovim
connections via a hostname will fail, but connections via an IP address
should function. We will still enable the built in Neovim client by
default anyway, as LSP clients very rarely connect over TCP.
2025-03-20 21:45:19 +00:00
w0rp
964e0a2e39 Supply language_id values to Neovim LSP API
Change logic so ALE's LSP implementation and the Neovim LSP client
retrieve the language_id for language clients at roughly the same time
via the same means. This makes ALE inform the language server what the
language for the language is for clients.
2025-03-20 21:45:19 +00:00
w0rp
ee975196ff Fix tests for Neovim LSP integration 2025-03-20 21:45:19 +00:00
w0rp
3f7ea86ae1 Update documentation for Neovim LSP integration
Update documentation to advertise ALE's integration with Neovim's native
LSP client, and explain how functionality is integrated with ALE,
Neovim's native tools, and other plugins.
2025-03-20 21:45:18 +00:00
w0rp
dd8d7cb4b4 Clean up message handling for LSP integration
Now we ought to be able to handle any kind of response for any request
we send, clean up message handling so there are fewer changes to make
to LSP code to adjust for Neovim integration.
2025-03-20 21:45:18 +00:00
w0rp
8216ee4a65 Handle other LSP capabilities via ALE
Save capabilities from language servers ALE connects to via Neovim's LSP
client and handle responses to requests ALE sends to language servers.
This enables ALE to work with Neovim's language client for its commands
while also letting users directly use the connected clients for native
Neovim keybinds and so on.
2025-03-20 21:45:18 +00:00
w0rp
9a251b2865 Remove the log_level line from Lua code 2025-03-20 21:45:18 +00:00
w0rp
61a1fcc92f Handle Neovim LSP diagnostics via ALE's functions 2025-03-20 21:45:18 +00:00
w0rp
c9eb8f9d15 Start up language servers with Neovim's API
Get language servers starting and displaying diagnostics with Neovim's
API in Neovim 0.8 and up. With this set up, now ALE needs to take over
handling diagnostics returned by the language servers.
2025-03-20 21:45:18 +00:00
20 changed files with 28 additions and 98 deletions

View File

@@ -7,8 +7,7 @@
"test"
],
"workspace.library": [
"/usr/share/nvim/runtime/lua",
"/opt/homebrew/share/nvim/runtime/lua"
"/usr/share/nvim/runtime/lua"
],
"runtime.pathStrict": true,
"runtime.path": [

View File

@@ -49,6 +49,7 @@ 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,38 +5,26 @@ 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#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
function! ale_linters#go#golangci_lint#GetCommand(buffer) 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
@@ -70,14 +58,9 @@ endfunction
call ale#linter#Define('go', {
\ 'name': 'golangci-lint',
\ 'executable': function('ale_linters#go#golangci_lint#GetExecutable'),
\ 'executable': {b -> ale#Var(b, 'go_golangci_lint_executable')},
\ 'cwd': '%s:h',
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
\ buffer,
\ ale_linters#go#golangci_lint#GetExecutable(buffer),
\ '%e --version',
\ function('ale_linters#go#golangci_lint#GetCommand'),
\ )},
\ 'command': 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': substitute(l:result.raw_msg, '\e\[[0-9;]*m', '', 'g'),
\ 'text': l:result.raw_msg
\})
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
echom 'The file was changed before fixing finished'
echoerr 'The file was changed before fixing finished'
endif
return

View File

@@ -1,7 +1,7 @@
function! ale#fixers#biome#Fix(buffer) abort
let l:executable = ale#handlers#biome#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'biome_options')
let l:apply = ale#Var(a:buffer, 'biome_fixer_apply_unsafe') ? '--write --unsafe' : '--write'
let l:apply = ale#Var(a:buffer, 'biome_fixer_apply_unsafe') ? '--apply-unsafe' : '--apply'
return {
\ 'read_temporary_file': 1,

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=' . ale#Escape(l:style_option)
let l:style_option = '-style=' . "'" . l:style_option . "'"
endif
if l:use_local_file

View File

@@ -17,11 +17,10 @@ let s:variables = {
\}
function! ale#fixers#erlang_mode#Fix(buffer) abort
let l:emacs_executable =
let 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,7 +11,6 @@ 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 && !l:conn.is_tsserver
if g:ale_use_neovim_lsp_api
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,16 +124,11 @@ 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. If the temporary location is symlinked (e.g. macOS), some
" linters may report the resolved version of the path, so both are checked.
" created by Vim.
function! ale#path#IsTempName(filename) abort
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
return ale#path#Simplify(a:filename)[:len(s:temp_dir) - 1] is# s: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: |Boolean| OR |Number| OR |String|
Type: |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 `true` or `1`, ALE ignores all linters
powered by LSP, and also `tsserver`.
plugin. When this option is set to `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,7 +1735,6 @@ 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 global_cfg == false or global_cfg == true or global_cfg == nil then
if type(global_cfg) == "boolean" then
signs = local_cfg
elseif type(global_cfg) == "table" then
signs = vim.tbl_extend("force", global_cfg, local_cfg)

View File

@@ -150,14 +150,12 @@ 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

@@ -17,7 +17,7 @@ Execute(The default biome command should be correct):
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('biome')
\ . ' check --write %t'
\ . ' check --apply %t'
\ }
Execute(Unsafe fixes can be applied via an option):
@@ -28,7 +28,7 @@ Execute(Unsafe fixes can be applied via an option):
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('biome')
\ . ' check --write --unsafe %t'
\ . ' check --apply-unsafe %t'
\ }
Execute(The fixer should accept options):
@@ -39,5 +39,5 @@ Execute(The fixer should accept options):
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('biome')
\ . ' check --write --foobar %t',
\ . ' check --apply --foobar %t',
\ }

View File

@@ -45,8 +45,7 @@ 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=' . ale#Escape(g:ale_c_clangformat_style_option)
\ . ' --some-option' . " -style='{BasedOnStyle: Microsoft, ColumnLimit:80,}'",
\ },
\ ale#fixers#clangformat#Fix(bufnr(''))

View File

@@ -33,9 +33,6 @@ 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': 'Always tag the version of an image explicitly',
\ 'text': "DL3006: 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': 'Specify version with `yum install -y <package>-<version>`.',
\ 'text': "DL3033: 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': 'In POSIX sh, brace expansion is undefined.',
\ 'text': "SC2039: 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,22 +27,6 @@ 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,9 +4,6 @@ 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
@@ -19,18 +16,6 @@ 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'
@@ -38,14 +23,6 @@ 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'