aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp.lua
diff options
context:
space:
mode:
authorAshkan Kiani <ashkan.k.kiani@gmail.com>2019-11-21 15:19:06 -0800
committerAshkan Kiani <ashkan.k.kiani@gmail.com>2019-11-21 15:19:06 -0800
commitbcae04f6c62b23104e85bb08c54a16d0cdc33852 (patch)
tree0c72ba8eea422833e3f0a295d08a6b4bc6b37c87 /runtime/lua/vim/lsp.lua
parent6a5140137865025dee68e75a4e8feb2d20a430cf (diff)
downloadrneovim-bcae04f6c62b23104e85bb08c54a16d0cdc33852.tar.gz
rneovim-bcae04f6c62b23104e85bb08c54a16d0cdc33852.tar.bz2
rneovim-bcae04f6c62b23104e85bb08c54a16d0cdc33852.zip
Updates
- Use correct implementation of text_edits. - Send indent options to rangeFormatting and formatting. - Remove references to vim bindings and filetype from lsp.txt - Add more examples to docs. - Add before_init to allow changing initialize_params.
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r--runtime/lua/vim/lsp.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 5a0b320f4c..790f8f8a9d 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -160,13 +160,13 @@ local function validate_client_config(config)
root_dir = { config.root_dir, is_dir, "directory" };
callbacks = { config.callbacks, "t", true };
capabilities = { config.capabilities, "t", true };
- -- cmd = { config.cmd, "s", false };
cmd_cwd = { config.cmd_cwd, optional_validator(is_dir), "directory" };
cmd_env = { config.cmd_env, "f", true };
name = { config.name, 's', true };
on_error = { config.on_error, "f", true };
on_exit = { config.on_exit, "f", true };
on_init = { config.on_init, "f", true };
+ before_init = { config.before_init, "f", true };
offset_encoding = { config.offset_encoding, "s", true };
}
local cmd, cmd_args = validate_command(config.cmd)
@@ -267,6 +267,12 @@ end
-- possible errors. `vim.lsp.client_errors[code]` can be used to retrieve a
-- human understandable string.
--
+-- before_init(initialize_params, config): A function which is called *before*
+-- the request `initialize` is completed. `initialize_params` contains
+-- the parameters we are sending to the server and `config` is the config that
+-- was passed to `start_client()` for convenience. You can use this to modify
+-- parameters before they are sent.
+--
-- on_init(client, initialize_result): A function which is called after the
-- request `initialize` is completed. `initialize_result` contains
-- `capabilities` and anything else the server may send. For example, `clangd`
@@ -385,7 +391,6 @@ function lsp.start_client(config)
-- The rootUri of the workspace. Is null if no folder is open. If both
-- `rootPath` and `rootUri` are set `rootUri` wins.
rootUri = vim.uri_from_fname(config.root_dir);
--- rootUri = vim.uri_from_fname(vim.fn.expand("%:p:h"));
-- User provided initialization options.
initializationOptions = config.init_options;
-- The capabilities provided by the client (editor or tool)
@@ -409,6 +414,10 @@ function lsp.start_client(config)
-- }
workspaceFolders = nil;
}
+ if config.before_init then
+ -- TODO(ashkan) handle errors here.
+ pcall(config.before_init, initialize_params, config)
+ end
local _ = log.debug() and log.debug(log_prefix, "initialize_params", initialize_params)
rpc.request('initialize', initialize_params, function(init_err, result)
assert(not init_err, tostring(init_err))