emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.76k stars 873 forks source link

Feature request: make lsp-extend-selection fallback to `expand-region.el` or something like that when the language server doesn't support `selectionRangeProvider` #1880

Open bbigras opened 4 years ago

bbigras commented 4 years ago

I would like a keybinding for lsp-extend-selection but with a fallback in case the language server doesn't support it.

ileixe commented 2 years ago

Any progress for this issue? Is there any way to keep same keystroke with expand-region ? I'd like to use expand-region-contract-fast-key to use lsp-extend-selection but did not find where to integrate.

Dima-369 commented 2 years ago

Is there any way to keep same keystroke with expand-region ? I'd like to use expand-region-contract-fast-key to use lsp-extend-selection but did not find where to integrate.

I just tested and this works for me:

(setq-local er/try-expand-list (append
                                er/try-expand-list
                                '(lsp-extend-selection)))

I would like a keybinding for lsp-extend-selection but with a fallback in case the language server doesn't support it.

You can check if the server supports it via (lsp--capability :selectionRangeProvider) and define an own interactive defun based on that to either use (lsp-extend-selection) or invoke (er/expand-region).