Formatting and Code Actions

Format on save

conform.nvim runs a real formatter per filetype and gets out of the way:

require("conform").setup({
  formatters_by_ft = {
    lua = { "stylua" },
    python = { "black" },
    javascript = { "prettier" },
  },
  format_on_save = { timeout_ms = 500, lsp_fallback = true },
})

lsp_fallback means that if no formatter is configured, the language server’s own formatting is used instead.

Code actions

When the language server underlines something, it often knows the fix:

gra

That is the built-in code-action map in Neovim 0.11+. It offers things like import this, remove unused, convert to arrow function — an edit you would otherwise type by hand.