From 38ddab01a73c2e5584b91e7fe529e9f902dc59de Mon Sep 17 00:00:00 2001 From: Cesar Saez <2292742+csaez@users.noreply.github.com> Date: Fri, 9 Apr 2021 15:09:40 +0100 Subject: Fix conditional keymap The recommended configuration in the `README.md` doesn't setup the keymap for range formatting correctly: this needs to be done independent from the full document formatting and making sure the keymap is set in visual mode as it's meant to work in the selection. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6b6141ed..259f304b 100644 --- a/README.md +++ b/README.md @@ -186,8 +186,9 @@ local on_attach = function(client, bufnr) -- Set some keybinds conditional on server capabilities if client.resolved_capabilities.document_formatting then buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) - elseif client.resolved_capabilities.document_range_formatting then - buf_set_keymap("n", "f", "lua vim.lsp.buf.range_formatting()", opts) + end + if client.resolved_capabilities.document_range_formatting then + buf_set_keymap("v", "f", "lua vim.lsp.buf.range_formatting()", opts) end -- Set autocommands conditional on server_capabilities -- cgit v1.2.3-70-g09d2