diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2020-12-30 15:09:33 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-31 00:09:33 +0100 |
commit | fd507e2788b93f3d0e5330a5a7b496d15fd38343 (patch) | |
tree | 5fcafe36b540b8c576250cf42bcf27c39ad4b0d6 /runtime/lua/vim/lsp/handlers.lua | |
parent | e256777b5a1b241f965931188ed0b0a9dacefd13 (diff) | |
download | rneovim-fd507e2788b93f3d0e5330a5a7b496d15fd38343.tar.gz rneovim-fd507e2788b93f3d0e5330a5a7b496d15fd38343.tar.bz2 rneovim-fd507e2788b93f3d0e5330a5a7b496d15fd38343.zip |
LSP: window/showMessageRequest (#13641)
Another 3.16 compatibility. Solves Vue crashing currently. Currently not handling the return result, but would allow opening web browser in this case.
Diffstat (limited to 'runtime/lua/vim/lsp/handlers.lua')
-rw-r--r-- | runtime/lua/vim/lsp/handlers.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index 3db62f9dd8..fd23a6a547 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -77,6 +77,30 @@ M['window/workDoneProgress/create'] = function(_, _, params, client_id) return vim.NIL end +--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_showMessageRequest +M['window/showMessageRequest'] = function(_, _, params) + + local actions = params.actions + print(params.message) + local option_strings = {params.message, "\nRequest Actions:"} + for i, action in ipairs(actions) do + local title = action.title:gsub('\r\n', '\\r\\n') + title = title:gsub('\n', '\\n') + table.insert(option_strings, string.format("%d. %s", i, title)) + end + + -- window/showMessageRequest can return either MessageActionItem[] or null. + local choice = vim.fn.inputlist(option_strings) + if choice < 1 or choice > #actions then + return vim.NIL + else + local action_chosen = actions[choice] + return { + title = action_chosen; + } + end +end + --@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction M['textDocument/codeAction'] = function(_, _, actions) if actions == nil or vim.tbl_isempty(actions) then |