mirror of
https://github.com/neovim/neovim.git
synced 2026-04-23 07:45:32 +00:00
docs: misc #31996
This commit is contained in:
3
runtime/lua/vim/_meta/api.lua
generated
3
runtime/lua/vim/_meta/api.lua
generated
@@ -1152,8 +1152,7 @@ function vim.api.nvim_eval(expr) end
|
||||
--- the "highlights" key in {opts} is true. Each element of the array is a
|
||||
--- |Dict| with these keys:
|
||||
--- - start: (number) Byte index (0-based) of first character that uses the highlight.
|
||||
--- - group: (string) Name of highlight group. May be removed in the future, use
|
||||
--- `groups` instead.
|
||||
--- - group: (string) Deprecated. Use `groups` instead.
|
||||
--- - groups: (array) Names of stacked highlight groups (highest priority last).
|
||||
function vim.api.nvim_eval_statusline(str, opts) end
|
||||
|
||||
|
||||
@@ -223,12 +223,11 @@ function vim.schedule(fn) end
|
||||
--- - If {callback} errors, the error is raised.
|
||||
function vim.wait(time, callback, interval, fast_only) end
|
||||
|
||||
--- Attach to |ui-events|, similar to |nvim_ui_attach()| but receive events
|
||||
--- as Lua callback. Can be used to implement screen elements like
|
||||
--- popupmenu or message handling in Lua.
|
||||
--- Subscribe to |ui-events|, similar to |nvim_ui_attach()| but receive events in a Lua callback.
|
||||
--- Used to implement screen elements like popupmenu or message handling in Lua.
|
||||
---
|
||||
--- {options} should be a dictionary-like table, where `ext_...` options should
|
||||
--- be set to true to receive events for the respective external element.
|
||||
--- {options} is a dict with one or more `ext_…` |ui-option|s set to true to enable events for
|
||||
--- the respective UI element.
|
||||
---
|
||||
--- {callback} receives event name plus additional parameters. See |ui-popupmenu|
|
||||
--- and the sections below for event format for respective events.
|
||||
@@ -250,14 +249,14 @@ function vim.wait(time, callback, interval, fast_only) end
|
||||
--- ns = vim.api.nvim_create_namespace('my_fancy_pum')
|
||||
---
|
||||
--- vim.ui_attach(ns, {ext_popupmenu=true}, function(event, ...)
|
||||
--- if event == "popupmenu_show" then
|
||||
--- if event == 'popupmenu_show' then
|
||||
--- local items, selected, row, col, grid = ...
|
||||
--- print("display pum ", #items)
|
||||
--- elseif event == "popupmenu_select" then
|
||||
--- print('display pum ', #items)
|
||||
--- elseif event == 'popupmenu_select' then
|
||||
--- local selected = ...
|
||||
--- print("selected", selected)
|
||||
--- elseif event == "popupmenu_hide" then
|
||||
--- print("FIN")
|
||||
--- print('selected', selected)
|
||||
--- elseif event == 'popupmenu_hide' then
|
||||
--- print('FIN')
|
||||
--- end
|
||||
--- end)
|
||||
--- ```
|
||||
|
||||
4
runtime/lua/vim/_meta/options.lua
generated
4
runtime/lua/vim/_meta/options.lua
generated
@@ -4381,8 +4381,8 @@ vim.go.mousemodel = vim.o.mousemodel
|
||||
vim.go.mousem = vim.go.mousemodel
|
||||
|
||||
--- When on, mouse move events are delivered to the input queue and are
|
||||
--- available for mapping. The default, off, avoids the mouse movement
|
||||
--- overhead except when needed.
|
||||
--- available for mapping `<MouseMove>`. The default, off, avoids the mouse
|
||||
--- movement overhead except when needed.
|
||||
--- Warning: Setting this option can make pending mappings to be aborted
|
||||
--- when the mouse is moved.
|
||||
---
|
||||
|
||||
21
runtime/lua/vim/_meta/vimfn.lua
generated
21
runtime/lua/vim/_meta/vimfn.lua
generated
@@ -899,12 +899,13 @@ function vim.fn.charidx(string, idx, countcc, utf16) end
|
||||
--- @return string
|
||||
function vim.fn.chdir(dir) end
|
||||
|
||||
--- Get the amount of indent for line {lnum} according the C
|
||||
--- indenting rules, as with 'cindent'.
|
||||
--- Get the amount of indent for line {lnum} according the
|
||||
--- |C-indenting| rules, as with 'cindent'.
|
||||
--- The indent is counted in spaces, the value of 'tabstop' is
|
||||
--- relevant. {lnum} is used just like in |getline()|.
|
||||
--- When {lnum} is invalid -1 is returned.
|
||||
--- See |C-indenting|.
|
||||
---
|
||||
--- To get or set indent of lines in a string, see |vim.text.indent()|.
|
||||
---
|
||||
--- @param lnum integer
|
||||
--- @return integer
|
||||
@@ -4430,6 +4431,8 @@ function vim.fn.id(expr) end
|
||||
--- |getline()|.
|
||||
--- When {lnum} is invalid -1 is returned.
|
||||
---
|
||||
--- To get or set indent of lines in a string, see |vim.text.indent()|.
|
||||
---
|
||||
--- @param lnum integer|string
|
||||
--- @return integer
|
||||
function vim.fn.indent(lnum) end
|
||||
@@ -5335,9 +5338,8 @@ function vim.fn.map(expr1, expr2) end
|
||||
--- When {abbr} is there and it is |TRUE| use abbreviations
|
||||
--- instead of mappings.
|
||||
---
|
||||
--- When {dict} is there and it is |TRUE| return a dictionary
|
||||
--- containing all the information of the mapping with the
|
||||
--- following items: *mapping-dict*
|
||||
--- When {dict} is |TRUE|, return a dictionary describing the
|
||||
--- mapping, with these items: *mapping-dict*
|
||||
--- "lhs" The {lhs} of the mapping as it would be typed
|
||||
--- "lhsraw" The {lhs} of the mapping as raw bytes
|
||||
--- "lhsrawalt" The {lhs} of the mapping as raw bytes, alternate
|
||||
@@ -5389,7 +5391,7 @@ function vim.fn.maparg(name, mode, abbr, dict) end
|
||||
--- @param mode string
|
||||
--- @param abbr boolean
|
||||
--- @param dict true
|
||||
--- @return string|table<string,any>
|
||||
--- @return table<string,any>
|
||||
function vim.fn.maparg(name, mode, abbr, dict) end
|
||||
|
||||
--- Check if there is a mapping that matches with {name} in mode
|
||||
@@ -6821,6 +6823,7 @@ function vim.fn.prompt_getprompt(buf) end
|
||||
--- endif
|
||||
--- endfunc
|
||||
--- call prompt_setcallback(bufnr(), function('s:TextEntered'))
|
||||
--- <
|
||||
---
|
||||
--- @param buf integer|string
|
||||
--- @param expr string|function
|
||||
@@ -9328,7 +9331,9 @@ function vim.fn.state(what) end
|
||||
function vim.fn.stdioopen(opts) end
|
||||
|
||||
--- Returns |standard-path| locations of various default files and
|
||||
--- directories.
|
||||
--- directories. The locations are driven by |base-directories|
|
||||
--- which you can configure via |$NVIM_APPNAME| or the `$XDG_…`
|
||||
--- environment variables.
|
||||
---
|
||||
--- {what} Type Description ~
|
||||
--- cache String Cache directory: arbitrary temporary
|
||||
|
||||
@@ -254,7 +254,7 @@ end
|
||||
--- fully initialized. Use `on_init` to do any actions once
|
||||
--- the client has been initialized.
|
||||
--- @return string? # Error message, if any
|
||||
local function create_and_initialize_client(config)
|
||||
local function create_and_init_client(config)
|
||||
local ok, res = pcall(require('vim.lsp.client').create, config)
|
||||
if not ok then
|
||||
return nil, res --[[@as string]]
|
||||
@@ -601,7 +601,7 @@ function lsp.start(config, opts)
|
||||
end
|
||||
end
|
||||
|
||||
local client_id, err = create_and_initialize_client(config)
|
||||
local client_id, err = create_and_init_client(config)
|
||||
if err then
|
||||
if not opts.silent then
|
||||
vim.notify(err, vim.log.levels.WARN)
|
||||
@@ -716,7 +716,7 @@ end
|
||||
--- @return string? # Error message, if any
|
||||
function lsp.start_client(config)
|
||||
vim.deprecate('vim.lsp.start_client()', 'vim.lsp.start()', '0.13')
|
||||
return create_and_initialize_client(config)
|
||||
return create_and_init_client(config)
|
||||
end
|
||||
|
||||
---Buffer lifecycle handler for textDocument/didSave
|
||||
|
||||
@@ -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