-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate Formatter Exit Codes #221
base: main
Are you sure you want to change the base?
Conversation
@mochaaP I can't assign reviewers so please take a look. I know I need to squash commits and a bunch of other stuff but I just wanted to draft the initial API. Let me know everything that can be improved. |
@mochaaP I'm going to start going through the formatters one-by-one (pain) to ensure I'm passing the right exit code.
|
I think (2) is fine. For (1), we could land the changes first and wait for feedback from ones who actually use them if any problem arises. |
Ready for review. |
return function(success_codes, command) | ||
return function(code, stderr) | ||
local success | ||
|
||
if type(success_codes) == "number" then | ||
success = code <= success_codes | ||
else | ||
success = vim.tbl_contains(success_codes, code) | ||
end | ||
|
||
if not success then | ||
vim.schedule(function() | ||
logger:warn(string.format("failed to run formatter %s; see `:NullLsLog`", command)) | ||
logger:add_entry(string.format("failed to run formatter %s: %s", command, stderr), "warn") | ||
end) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -18,5 +18,10 @@ return function(opts) | |||
return done({ { text = output } }) | |||
end | |||
|
|||
if opts.check_exit_code == nil then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set check_exit_code
in the generator factory instead of here.
@mochaaP addressing both comments above: The problem I have with moving the code to the generic factory (and this includes the code duplication comment above) is that I thought this feature only makes sense for formatters. If we added this to generator factory, wouldn't we also be checking linting exit codes as well? |
Resolves #216.
Warns on formatter failures, defaulting to
!= 0
.Create a utility wrapper
helpers.check_exit_code
to maintain backwards compatibility.TODO
logger:warn
spawns a blocking notification (i.e. must press enter) and creates a timeout error if not pressed within the defualt timeout^ this is unavoidable - addressed by using a shorter initial message pointing you to to the log file.