nvim: lsp: Drop custom range formatting function

With commit 11167ab, vim.lsp.buf.format now has a range argument
which defaults to current selection in visual mode.
This commit is contained in:
Sanchayan Maity 2022-09-09 16:33:05 +05:30
parent 6b29743076
commit 108403ca3d

View file

@ -9,20 +9,6 @@ inlay_hint.setup({
}
})
-- https://github.com/neovim/nvim-lspconfig/wiki/User-contributed-tips
function FormatRangeOperator()
local old_func = vim.go.operatorfunc
_G.op_func_formatting = function()
local start = vim.api.nvim_buf_get_mark(0, '[')
local finish = vim.api.nvim_buf_get_mark(0, ']')
vim.lsp.buf.range_formatting({}, start, finish)
vim.go.operatorfunc = old_func
_G.op_func_formatting = nil
end
vim.go.operatorfunc = 'v:lua.op_func_formatting'
vim.api.nvim_feedkeys('g@', 'n', false)
end
local function preview_location_callback(_, result)
if result == nil or vim.tbl_isempty(result) then
return nil
@ -78,7 +64,7 @@ local lsp_key_mappings = {
{ "signatureHelpProvider" , 'n', '<Leader>S', '<cmd>lua vim.lsp.buf.signature_help()<CR>' },
{ "renameProvider" , 'n', 'gR' , '<cmd>lua vim.lsp.buf.rename()<CR>' },
{ "documentRangeFormattingProvider", 'x', 'gq', '<cmd>lua FormatRangeOperator()<CR>' },
{ "documentRangeFormattingProvider", 'x', 'gq', '<cmd>lua vim.lsp.buf.format({async=true})<CR>' },
{ "documentFormattingProvider" , 'n', 'gq', '<cmd>lua vim.lsp.buf.format({async=true})<CR>' },
{ "codeActionProvider", 'n', 'ga' , '<cmd>lua vim.lsp.buf.code_action()<CR>' },