mirror of
https://github.com/neovim/neovim.git
synced 2026-05-05 05:25:10 +00:00
docs: misc #31996
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
--- @brief
|
||||
--- The `vim.lsp.buf_…` functions perform operations for LSP clients attached to the current buffer.
|
||||
|
||||
local api = vim.api
|
||||
local lsp = vim.lsp
|
||||
local validate = vim.validate
|
||||
|
||||
@@ -6,7 +6,7 @@ local ms = lsp.protocol.Methods
|
||||
local changetracking = lsp._changetracking
|
||||
local validate = vim.validate
|
||||
|
||||
--- @alias vim.lsp.client.on_init_cb fun(client: vim.lsp.Client, initialize_result: lsp.InitializeResult)
|
||||
--- @alias vim.lsp.client.on_init_cb fun(client: vim.lsp.Client, init_result: lsp.InitializeResult)
|
||||
--- @alias vim.lsp.client.on_attach_cb fun(client: vim.lsp.Client, bufnr: integer)
|
||||
--- @alias vim.lsp.client.on_exit_cb fun(code: integer, signal: integer, client_id: integer)
|
||||
--- @alias vim.lsp.client.before_init_cb fun(params: lsp.InitializeParams, config: vim.lsp.ClientConfig)
|
||||
@@ -108,11 +108,11 @@ local validate = vim.validate
|
||||
--- You can use this to modify parameters before they are sent.
|
||||
--- @field before_init? fun(params: lsp.InitializeParams, config: vim.lsp.ClientConfig)
|
||||
---
|
||||
--- Callback invoked after LSP "initialize", where `result` is a table of `capabilities`
|
||||
--- and anything else the server may send. For example, clangd sends
|
||||
--- `initialize_result.offsetEncoding` if `capabilities.offsetEncoding` was sent to it.
|
||||
--- You can only modify the `client.offset_encoding` here before any notifications are sent.
|
||||
--- @field on_init? elem_or_list<fun(client: vim.lsp.Client, initialize_result: lsp.InitializeResult)>
|
||||
--- Callback invoked after LSP "initialize", where `result` is a table of `capabilities` and
|
||||
--- anything else the server may send. For example, clangd sends `init_result.offsetEncoding` if
|
||||
--- `capabilities.offsetEncoding` was sent to it. You can only modify the `client.offset_encoding`
|
||||
--- here before any notifications are sent.
|
||||
--- @field on_init? elem_or_list<fun(client: vim.lsp.Client, init_result: lsp.InitializeResult)>
|
||||
---
|
||||
--- Callback invoked on client exit.
|
||||
--- - code: exit code of the process
|
||||
@@ -506,7 +506,7 @@ function Client:initialize()
|
||||
root_path = vim.uri_to_fname(root_uri)
|
||||
end
|
||||
|
||||
local initialize_params = {
|
||||
local init_params = {
|
||||
-- The process Id of the parent process that started the server. Is null if
|
||||
-- the process has not been started by another process. If the parent
|
||||
-- process is not alive then the server should exit (see exit notification)
|
||||
@@ -536,15 +536,15 @@ function Client:initialize()
|
||||
self:_run_callbacks(
|
||||
{ self._before_init_cb },
|
||||
lsp.client_errors.BEFORE_INIT_CALLBACK_ERROR,
|
||||
initialize_params,
|
||||
init_params,
|
||||
config
|
||||
)
|
||||
|
||||
log.trace(self._log_prefix, 'initialize_params', initialize_params)
|
||||
log.trace(self._log_prefix, 'init_params', init_params)
|
||||
|
||||
local rpc = self.rpc
|
||||
|
||||
rpc.request('initialize', initialize_params, function(init_err, result)
|
||||
rpc.request('initialize', init_params, function(init_err, result)
|
||||
assert(not init_err, tostring(init_err))
|
||||
assert(result, 'server sent empty result')
|
||||
rpc.notify('initialized', vim.empty_dict())
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
--- @brief
|
||||
--- The `vim.lsp.completion` module enables insert-mode completion driven by an LSP server. Call
|
||||
--- `enable()` to make it available through Nvim builtin completion (via the |CompleteDone| event).
|
||||
--- Specify `autotrigger=true` to activate "auto-completion" when you type any of the server-defined
|
||||
--- `triggerCharacters`.
|
||||
---
|
||||
--- Example: activate LSP-driven auto-completion:
|
||||
--- ```lua
|
||||
--- vim.lsp.start({
|
||||
--- name = 'ts_ls',
|
||||
--- cmd = …,
|
||||
--- on_attach = function(client, bufnr)
|
||||
--- vim.lsp.completion.enable(true, client.id, bufnr, {
|
||||
--- autotrigger = true,
|
||||
--- convert = function(item)
|
||||
--- return { abbr = item.label:gsub('%b()', '') }
|
||||
--- end,
|
||||
--- })
|
||||
--- end,
|
||||
--- })
|
||||
--- ```
|
||||
|
||||
local M = {}
|
||||
|
||||
local api = vim.api
|
||||
@@ -749,7 +771,7 @@ function M.enable(enable, client_id, bufnr, opts)
|
||||
end
|
||||
end
|
||||
|
||||
--- Trigger LSP completion in the current buffer.
|
||||
--- Triggers LSP completion once in the current buffer.
|
||||
function M.trigger()
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
local clients = (buf_handles[bufnr] or {}).clients or {}
|
||||
|
||||
@@ -1503,6 +1503,7 @@ end
|
||||
--- (default: `'cursor'`)
|
||||
--- @field relative? 'mouse'|'cursor'|'editor'
|
||||
---
|
||||
--- Adjusts placement relative to cursor.
|
||||
--- - "auto": place window based on which side of the cursor has more lines
|
||||
--- - "above": place the window above the cursor unless there are not enough lines
|
||||
--- to display the full window height.
|
||||
|
||||
Reference in New Issue
Block a user