mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-10 09:24:37 +02:00
fix(format): ignore vim.b.autoformat when formatting using key bindings. Fixes #575
This commit is contained in:
parent
a099b2d3ab
commit
bef36bb2fd
2 changed files with 6 additions and 3 deletions
|
@ -18,9 +18,10 @@ function M.toggle()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.format()
|
---@param opts? {force?:boolean}
|
||||||
|
function M.format(opts)
|
||||||
local buf = vim.api.nvim_get_current_buf()
|
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
|
return
|
||||||
end
|
end
|
||||||
local ft = vim.bo[buf].filetype
|
local ft = vim.bo[buf].filetype
|
||||||
|
|
|
@ -5,7 +5,9 @@ M._keys = nil
|
||||||
|
|
||||||
---@return (LazyKeys|{has?:string})[]
|
---@return (LazyKeys|{has?:string})[]
|
||||||
function M.get()
|
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
|
if not M._keys then
|
||||||
---@class PluginLspKeys
|
---@class PluginLspKeys
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue