Skip to content

Commit

Permalink
fix(format): ignore vim.b.autoformat when formatting using key bindin…
Browse files Browse the repository at this point in the history
…gs. Fixes #575
  • Loading branch information
folke committed Apr 16, 2023
1 parent a099b2d commit bef36bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lua/lazyvim/plugins/lsp/format.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ function M.toggle()
end
end

function M.format()
---@param opts? {force?:boolean}
function M.format(opts)
local buf = vim.api.nvim_get_current_buf()
if vim.b.autoformat == false then
if vim.b.autoformat == false and not (opts and opts.force) then
return
end
local ft = vim.bo[buf].filetype
Expand Down
4 changes: 3 additions & 1 deletion lua/lazyvim/plugins/lsp/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ M._keys = nil

---@return (LazyKeys|{has?:string})[]
function M.get()
local format = require("lazyvim.plugins.lsp.format").format
local format = function()
require("lazyvim.plugins.lsp.format").format({ force = true })
end
if not M._keys then
---@class PluginLspKeys
-- stylua: ignore
Expand Down

0 comments on commit bef36bb

Please sign in to comment.