-
Notifications
You must be signed in to change notification settings - Fork 244
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Did you check existing requests?
- I have searched the existing issues
Describe the feature
I would like to be able to pass a lua function to the formatter list by filetype. Either that or configure a custom formatter that is a lua function instead of an external command.
Provide background
I would like to run the following lua command when formatting go
files:
vim.lsp.buf.code_action({
filter = function(a)
return a.kind == 'source.organizeImports'
end,
apply = true,
})
At the moment I can do this by having an extra check in my key binding but it would be nice to be able to run custom lua code as a formatter.
Current lazy.nvim
solution:
return {
'stevearc/conform.nvim',
...
keys = {
{
'<leader>cf',
function()
if vim.api.nvim_buf_get_option(0, 'filetype') == 'go' then
vim.lsp.buf.code_action({
filter = function(a)
return a.kind == 'source.organizeImports'
end,
apply = true,
})
end
require('conform').format({ bufnr = 0, timeout_ms = 10000 })
end,
desc = 'Conform format',
},
},
}
What is the significance of this feature?
nice to have
Additional details
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request