nvim: lsp: Fix enabling of range format support

If range formatting is supported we should check that first to enable
it else since most LSP servers support formatting, without range
formatting check being first, it would never be enabled.
This commit is contained in:
Sanchayan Maity 2021-09-25 18:18:12 +05:30
parent 8801b26fa9
commit 47b157805d

View file

@ -68,10 +68,10 @@ local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'do', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>' , opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', ',d', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>' , opts)
if client.resolved_capabilities.document_formatting then
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gq', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
elseif client.resolved_capabilities.document_range_formatting then
if client.resolved_capabilities.document_range_formatting then
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gq', '<cmd>lua format_range_operator()<CR>', opts)
elseif client.resolved_capabilities.document_formatting then
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gq', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
if client.resolved_capabilities.code_lens then