aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/default_callbacks.lua
diff options
context:
space:
mode:
authorAshkan Kiani <ashkan.k.kiani@gmail.com>2019-11-26 05:59:40 -0800
committerGitHub <noreply@github.com>2019-11-26 05:59:40 -0800
commit6e8c5779cf960893850501e4871dc9be671db298 (patch)
tree7712e1fcb69ca8167cea7ad0deb15c280196038b /runtime/lua/vim/lsp/default_callbacks.lua
parent36d1335a667d54c26ab7cca23bc60998cb8e0fb2 (diff)
downloadrneovim-6e8c5779cf960893850501e4871dc9be671db298.tar.gz
rneovim-6e8c5779cf960893850501e4871dc9be671db298.tar.bz2
rneovim-6e8c5779cf960893850501e4871dc9be671db298.zip
LSP: Move default buf callbacks to vim.lsp.callbacks (#11452)
- In the process, refactored focusable_preview to a util function. - Add text for locations_to_items of the current line. - Improve location callback to handle multiple return values by using set_qflist. - Remove update_tagstack and leave note for future travelers.
Diffstat (limited to 'runtime/lua/vim/lsp/default_callbacks.lua')
-rw-r--r--runtime/lua/vim/lsp/default_callbacks.lua69
1 files changed, 0 insertions, 69 deletions
diff --git a/runtime/lua/vim/lsp/default_callbacks.lua b/runtime/lua/vim/lsp/default_callbacks.lua
deleted file mode 100644
index 2a891e7d1d..0000000000
--- a/runtime/lua/vim/lsp/default_callbacks.lua
+++ /dev/null
@@ -1,69 +0,0 @@
-local log = require 'vim.lsp.log'
-local protocol = require 'vim.lsp.protocol'
-local util = require 'vim.lsp.util'
-local api = vim.api
-
-local M = {}
-
-local function err_message(...)
- api.nvim_err_writeln(table.concat(vim.tbl_flatten{...}))
- api.nvim_command("redraw")
-end
-
-M['workspace/applyEdit'] = function(_, _, workspace_edit)
- if not workspace_edit then return end
- -- TODO(ashkan) Do something more with label?
- if workspace_edit.label then
- print("Workspace edit", workspace_edit.label)
- end
- util.apply_workspace_edit(workspace_edit.edit)
-end
-
-M['textDocument/publishDiagnostics'] = function(_, _, result)
- if not result then return end
- local uri = result.uri
- local bufnr = vim.uri_to_bufnr(uri)
- if not bufnr then
- err_message("LSP.publishDiagnostics: Couldn't find buffer for ", uri)
- return
- end
- util.buf_clear_diagnostics(bufnr)
- util.buf_diagnostics_save_positions(bufnr, result.diagnostics)
- util.buf_diagnostics_underline(bufnr, result.diagnostics)
- util.buf_diagnostics_virtual_text(bufnr, result.diagnostics)
- -- util.set_loclist(result.diagnostics)
-end
-
-local function log_message(_, _, result, client_id)
- local message_type = result.type
- local message = result.message
- local client = vim.lsp.get_client_by_id(client_id)
- local client_name = client and client.name or string.format("id=%d", client_id)
- if not client then
- err_message("LSP[", client_name, "] client has shut down after sending the message")
- end
- if message_type == protocol.MessageType.Error then
- err_message("LSP[", client_name, "] ", message)
- else
- local message_type_name = protocol.MessageType[message_type]
- api.nvim_out_write(string.format("LSP[%s][%s] %s\n", client_name, message_type_name, message))
- end
- return result
-end
-
-M['window/showMessage'] = log_message
-M['window/logMessage'] = log_message
-
--- Add boilerplate error validation and logging for all of these.
-for k, fn in pairs(M) do
- M[k] = function(err, method, params, client_id)
- local _ = log.debug() and log.debug('default_callback', method, { params = params, client_id = client_id, err = err })
- if err then
- error(tostring(err))
- end
- return fn(err, method, params, client_id)
- end
-end
-
-return M
--- vim:sw=2 ts=2 et