-
Notifications
You must be signed in to change notification settings - Fork 176
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
README/use case: describe how to make ['_'] = { 'trim_whitespace', 'trim_newlines' }, play nice with editorconfig autocommands #586
Comments
Feel free to close, if you feel like this is out of scope/user responsibility. I'll leave the config for others inspiration, if they want to do something like this. |
Currently there is no silent mode for lua autocommand and code_action has neither a silent mode to suppress prompt confirmation. So one way or the other one has to spam autocommands to workaround that. See also neovim/neovim#22651. |
Ok, there is a workaround/hack: local user_fmts_by_ft = {
markdown = function() end, -- stub
supermd = function() end, -- stub
zig = function(args)
local original = vim.notify
---@diagnostic disable-next-line: duplicate-set-field
vim.notify = function(msg, level, opts)
if msg == 'No code actions available' then return end
original(msg, level, opts)
end
vim.lsp.buf.code_action {
---@diagnostic disable-next-line: missing-fields
context = { only = { 'source.fixAll' } },
apply = true,
}
conform.format { bufnr = args.buf, formatters = { fmts_by_ft['zig'] } }
end,
--fmts_by_ft[vim.bo[args.buf].filetype]
zon = function(args) conform.format { bufnr = args.buf, formatters = { fmts_by_ft['zig'] } } end,
} This is frustrating. |
How can formatting the code break it for autofix? And how can performing an autofix code action prevent the |
Sorry, the cause of the issue was eventually something else: See
Possible fixes:
|
Did you check existing requests?
Describe the feature
Wanted: Extend the configuration in the usage section to some more low level usage, but probably it is simpler to mention 1. combined actions, 2.
['_']
problems:Provide background
Justification: Running one or multiple code actions to autofix code and then the formatter (because formatter might break code for the autofix) prevents
trim_whitespace
andtrim_newlines
from being usable.For example, I have
What is the significance of this feature?
nice to have
Additional details
Going more low level makes things less error prone, if the options
'*'
and_
or doing lsp actions before formatting (or custom checks) are wanted.The text was updated successfully, but these errors were encountered: