A Neovim plugin to register specific code actions to be run automatically on file save, based on file patterns.
Using lazy.nvim:
{
"fnune/codeactions-on-save.nvim",
config = function()
local cos = require("codeactions-on-save")
cos.register({ "*.py" }, { "source.organizeImports" })
cos.register({ "*.ts", "*.tsx" }, { "source.organizeImports.biome", "source.fixAll" })
end
}
The default timeout for code actions is 100ms. You can pass anything else if necessary, in ms
:
cos.register({ "*.ts" }, { "source.organizeImports" }, 3000)
To find out the action kind of the action you want to run, use this while inside a buffer with an LSP client attached:
:lua require("codeactions-on-save").inspect()