I’m using NvChad and in ~/.config/nvim/lua/core/mappings.lua there is a keybinding for LSP code action:

  ["<leader>ca"] = {
    function()
      vim.lsp.buf.code_action()
      -- TODO: write buffer to file
    end,
    "LSP code action",
},

this keybinding applies the code action, but does not write to file. I want to write changes to file as soon as I’ve applied the code action.

How can I use the documentation at https://neovim.io/doc/ to find the correct function? I’ve tried looking for a write() function but I could not find anything I can call from lua.