Skip to content

Commit

Permalink
feat(ignore_stdout): option to ignore stdout (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfOne authored Oct 1, 2023
1 parent 68645e5 commit b3b530e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/HELPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ with the following changes:

- `ignore_stderr`: set to `true` by default.

- `ignore_stdout`: set to `false` by default.

- `on_output`: will always return an edit that will replace the current buffer's
content with formatter output. As a result, other options that depend on
`on_output`, such as `format`, will not have an effect.
Expand Down
10 changes: 9 additions & 1 deletion lua/null-ls/helpers/generator_factory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,14 @@ local line_output_wrapper = function(params, done, on_output)
end

return function(opts)
local command, args, env, on_output, format, ignore_stderr, from_stderr, to_stdin, check_exit_code, timeout, to_temp_file, from_temp_file, use_cache, runtime_condition, cwd, dynamic_command, multiple_files, temp_dir, prepend_extra_args =
local command, args, env, on_output, format, ignore_stderr, ignore_stdout, from_stderr, to_stdin, check_exit_code, timeout, to_temp_file, from_temp_file, use_cache, runtime_condition, cwd, dynamic_command, multiple_files, temp_dir, prepend_extra_args =
opts.command,
opts.args,
opts.env,
opts.on_output,
opts.format,
opts.ignore_stderr,
opts.ignore_stdout,
opts.from_stderr,
opts.to_stdin,
opts.check_exit_code,
Expand Down Expand Up @@ -148,6 +149,7 @@ return function(opts)
},
from_stderr = { from_stderr, "boolean", true },
ignore_stderr = { ignore_stderr, "boolean", true },
ignore_stdout = { ignore_stdout, "boolean", true },
to_stdin = { to_stdin, "boolean", true },
check_exit_code = { check_exit_code, "function", true },
timeout = { timeout, "number", true },
Expand Down Expand Up @@ -205,6 +207,12 @@ return function(opts)
log:trace("error output: " .. (error_output or "nil"))
log:trace("output: " .. (output or "nil"))

if ignore_stdout then
if error_output then
log:trace("ignoring stdout due to generator options")
end
output = nil
end
if ignore_stderr then
if error_output then
log:trace("ignoring stderr due to generator options")
Expand Down
1 change: 1 addition & 0 deletions lua/null-ls/helpers/make_builtin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ local function make_builtin(opts)
diagnostics_postprocess = opts.diagnostics_postprocess,
dynamic_command = opts.dynamic_command,
ignore_stderr = opts.ignore_stderr,
ignore_stdout = opts.ignore_stdout,
runtime_condition = opts.runtime_condition,
timeout = opts.timeout,
to_temp_file = opts.to_temp_file,
Expand Down

0 comments on commit b3b530e

Please sign in to comment.