Skip to content

Commit

Permalink
fix: range formatting for LSP formatters (nvim-lua#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc authored and F1lipB committed Dec 17, 2024
1 parent 056ae2a commit f284a45
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lua/conform/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ M.format = function(opts, callback)
lsp_fallback = false,
quiet = false,
})
local mode = vim.api.nvim_get_mode().mode
if not opts.range and mode == "v" or mode == "V" then
opts.range = range_from_selection(opts.bufnr, mode)
end
callback = callback or function(_err) end
local log = require("conform.log")
local lsp_format = require("conform.lsp_format")
Expand All @@ -323,11 +327,6 @@ M.format = function(opts, callback)
end

if any_formatters then
local mode = vim.api.nvim_get_mode().mode
if not opts.range and mode == "v" or mode == "V" then
opts.range = range_from_selection(opts.bufnr, mode)
end

---@param err? conform.Error
local function handle_err(err)
if err then
Expand Down

0 comments on commit f284a45

Please sign in to comment.