diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2022-07-29 20:41:35 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2022-07-29 20:41:35 +0200 |
| commit | 5b933613cc741026263825e8ae79876d19643239 (patch) | |
| tree | 476827e8702515e7e68e0ccea84e43dea5730839 | |
| parent | 02f4a4c32be08da12d046d4c155ac7e0923ccd98 (diff) | |
| download | vis-lspc-5b933613cc741026263825e8ae79876d19643239.tar.gz vis-lspc-5b933613cc741026263825e8ae79876d19643239.zip | |
support window/showMessage notifications
Introduce a new configuration message_level to control the messages
displayed.
The option message_level ranges from 1 - 4 (Error - Log) and corresponds
to LSP's MessageType namespace.
| -rw-r--r-- | init.lua | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -75,6 +75,10 @@ local lspc = { -- style used by lspc to highlight the diagnostic range -- 60% solarized red diagnostic_style = 'back:#e3514f', + + -- message level to show in the UI when eceiving messages from the server + -- Error = 1, Warning = 2, Info = 3, Log = 4 + message_level = 3, } -- Forward declaration of lspc_err to use it in capture_cmd @@ -935,11 +939,25 @@ local function lspc_handle_publish_diagnostics(ls, uri, diagnostics) end end +local lsp_message_types = {'Error', 'Warning', 'Info', 'Log'} +-- show a message from the server in the UI +local function lspc_handle_show_message(show_message_params) + if show_message_params.type > lspc.message_level then + return + end + + vis:message('--- language server message ---') + local level = lsp_message_types[show_message_params.type] or 'Unknown' + vis:message(level .. ': ' .. show_message_params.message) +end + local function ls_handle_notification(ls, notification) -- luacheck: no unused args local method = notification.method if method == 'textDocument/publishDiagnostics' then lspc_handle_publish_diagnostics(ls, notification.params.uri, notification.params.diagnostics) + elseif method == 'window/showMessage' then + lspc_handle_show_message(notification.params) end end |
