nvim: lsp: Fix enabling of range format support again!

47b1578 did not actually fix it. We need to keep using 'gq' but actually
correctly specify whether we want normal or visual mode. Also disable
range formatting explicitly for tsserver.
This commit is contained in:
Sanchayan Maity 2021-09-27 15:17:43 +05:30
parent d7fbe762c5
commit b95a14b8d1

View file

@ -69,8 +69,9 @@ local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_keymap(bufnr, 'n', ',d', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>' , opts)
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, 'x', 'gq', '<cmd>lua format_range_operator()<CR>', opts)
end
if client.resolved_capabilities.document_formatting then
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gq', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
@ -110,6 +111,7 @@ local on_attach = function(client, bufnr)
if client.name == 'tsserver' then
-- Disable tsserver formatting as we plan on formatting via null-ls
client.resolved_capabilities.document_formatting = false
client.resolved_capabilities.document_range_formatting = false
ts_utils.setup {
debug = false,