From 72c4e61a6d69e9907c271893a0822142fda1facf Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 20 May 2021 07:52:13 +0200 Subject: [PATCH] fix: sort functions before writing --- lua/lua-dev/parser.lua | 58 ++--- types/api.1.lua | 254 +++++++++++----------- types/api.2.lua | 465 +++++++++++++++++++---------------------- types/api.3.lua | 249 ++++++++++------------ types/api.4.lua | 397 ++++++++++++++++------------------- types/api.5.lua | 178 +++++++++++++--- types/api.lua | 253 +++++++++++----------- types/lsp.1.lua | 442 +++++++++++++++++++-------------------- types/lsp.2.lua | 351 ++++++++++++++++--------------- types/lsp.3.lua | 8 + types/lsp.lua | 388 ++++++++++++++++------------------ types/lua.lua | 10 +- types/treesitter.lua | 150 ++++++------- 13 files changed, 1607 insertions(+), 1596 deletions(-) create mode 100644 types/lsp.3.lua diff --git a/lua/lua-dev/parser.lua b/lua/lua-dev/parser.lua index 05bb96f..ad588d5 100644 --- a/lua/lua-dev/parser.lua +++ b/lua/lua-dev/parser.lua @@ -87,6 +87,21 @@ function M.intro(fd) ]], -1) end +function M.get_functions(mpack) + mpack = "mpack/" .. mpack + local data = vim.fn.msgpackparse(vim.fn.readfile(mpack, "b")) + local ret = {} + for _, functions in pairs(data) do + for name, fun in pairs(functions) do + table.insert(ret, { name, fun }) + end + end + table.sort(ret, function(a, b) + return a[1] < b[1] + end) + return ret +end + function M.parse(mpack, prefix, exclude) -- exclude signatures for functions that are existing lua sources local skip = {} @@ -96,9 +111,7 @@ function M.parse(mpack, prefix, exclude) end end prefix = prefix or "vim" - mpack = "mpack/" .. mpack local fname = vim.fn.fnamemodify(mpack, ":t:r") - local data = vim.fn.msgpackparse(vim.fn.readfile(mpack, "b")) local fnum = 0 local fd = uv.fs_open("types/" .. fname .. ".lua", "w+", 420) @@ -106,33 +119,28 @@ function M.parse(mpack, prefix, exclude) local size = 0 local classes = {} - for _, functions in pairs(data) do - for name, fun in pairs(functions) do - if not skip[name] then - local parts = vim.fn.split(name, ":") - if #parts > 1 and not classes[parts[1]] then - uv.fs_write( - fd, - ([[ + for _, f in pairs(M.get_functions(mpack)) do + local name, fun = unpack(f) + if not skip[name] then + local parts = vim.fn.split(name, ":") + if #parts > 1 and not classes[parts[1]] then + uv.fs_write(fd, ([[ --- @class %s %s = {} -]]):format(prefix .. "." .. parts[1], prefix .. "." .. parts[1]), - -1 - ) - classes[parts[1]] = true - end - local emmy = M.emmy(name, fun, prefix) - size = size + #emmy - uv.fs_write(fd, emmy, -1) +]]):format(prefix .. "." .. parts[1], prefix .. "." .. parts[1]), -1) + classes[parts[1]] = true + end + local emmy = M.emmy(name, fun, prefix) + size = size + #emmy + uv.fs_write(fd, emmy, -1) - if size > 1024 * 10 then - uv.fs_close(fd) - fnum = fnum + 1 - size = 0 - fd = uv.fs_open("types/" .. fname .. "." .. fnum .. ".lua", "w+", 420) - M.intro(fd) - end + if size > 1024 * 10 then + uv.fs_close(fd) + fnum = fnum + 1 + size = 0 + fd = uv.fs_open("types/" .. fname .. "." .. fnum .. ".lua", "w+", 420) + M.intro(fd) end end end diff --git a/types/api.1.lua b/types/api.1.lua index 52ac5fa..c93f88a 100644 --- a/types/api.1.lua +++ b/types/api.1.lua @@ -1,26 +1,54 @@ --# selene: allow(unused_variable) ---@diagnostic disable: unused-local --- Gets extmarks in "traversal order" from a |charwise| region --- defined by buffer positions (inclusive, 0-indexed --- |api-indexing|). +-- Return a tuple (row,col) representing the position of the +-- named mark. --- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @param _end object #End of range, given as (row, col) or valid ---- extmark id (whose position defines the bound) ---- @param start object #Start of range, given as (row, col) or valid ---- extmark id (whose position defines the bound) ---- @param opts dictionary #Optional parameters. Keys: ---- • limit: Maximum number of marks to return ---- • details Whether to include the details dict ---- @param ns_id integer #Namespace id from |nvim_create_namespace()| ---- @return any #List of [extmark_id, row, col] tuples in "traversal ---- order". -function vim.api.nvim_buf_get_extmarks(buffer, ns_id, start, _end, opts) end +--- @param name string #Mark name +--- @return any #(row, col) tuple +function vim.api.nvim_buf_get_mark(buffer, name) end + +-- Gets the full file name for the buffer +--- @param buffer buffer #Buffer handle, or 0 for current buffer +--- @return any #Buffer name +function vim.api.nvim_buf_get_name(buffer) end + +-- Returns the byte offset of a line (0-indexed). |api-indexing| +--- @param index integer #Line index +--- @param buffer buffer #Buffer handle, or 0 for current buffer +--- @return any #Integer byte offset, or -1 for unloaded buffer. +function vim.api.nvim_buf_get_offset(buffer, index) end + +-- Gets a buffer option value +--- @param buffer buffer #Buffer handle, or 0 for current buffer +--- @param name string #Option name +--- @return any #Option value +function vim.api.nvim_buf_get_option(buffer, name) end + +-- Gets a buffer-scoped (b:) variable. +--- @param buffer buffer #Buffer handle, or 0 for current buffer +--- @param name string #Variable name +--- @return any #Variable value +function vim.api.nvim_buf_get_var(buffer, name) end + +-- Checks if a buffer is valid and loaded. See |api-buffer| for +-- more info about unloaded buffers. +--- @param buffer buffer #Buffer handle, or 0 for current buffer +--- @return any #true if the buffer is valid and loaded, false otherwise. +function vim.api.nvim_buf_is_loaded(buffer) end + +-- Checks if a buffer is valid. +--- @param buffer buffer #Buffer handle, or 0 for current buffer +--- @return any #true if the buffer is valid, false otherwise. +function vim.api.nvim_buf_is_valid(buffer) end + +-- Gets the buffer line count +--- @param buffer buffer #Buffer handle, or 0 for current buffer +--- @return any #Line count, or 0 for unloaded buffer. |api-buffer| +function vim.api.nvim_buf_line_count(buffer) end -- Creates or updates an extmark. --- @param ns_id integer #Namespace id from |nvim_create_namespace()| ---- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @param line integer #Line number where to place the mark --- @param opts dictionary #Optional parameters. --- • id : id of the extmark to edit. --- • end_line : ending line of the mark, 0-based @@ -77,43 +105,54 @@ function vim.api.nvim_buf_get_extmarks(buffer, ns_id, start, _end, opts) end --- group. For example treesitter highlighting --- uses a value of 100. --- @param col integer #Column where to place the mark +--- @param line integer #Line number where to place the mark +--- @param buffer buffer #Buffer handle, or 0 for current buffer --- @return any #Id of the created/updated extmark function vim.api.nvim_buf_set_extmark(buffer, ns_id, line, col, opts) end --- Removes an extmark. ---- @param id integer #Extmark id ---- @param ns_id integer #Namespace id from |nvim_create_namespace()| +-- Sets a buffer-local |mapping| for the given mode. --- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @return any #true if the extmark was found, else false -function vim.api.nvim_buf_del_extmark(buffer, ns_id, id) end +function vim.api.nvim_buf_set_keymap(buffer, mode, lhs, rhs, opts) end --- Adds a highlight to buffer. ---- @param ns_id integer #namespace to use or -1 for ungrouped ---- highlight ---- @param hl_group string #Name of the highlight group to use +-- Sets (replaces) a line-range in the buffer. +--- @param replacement string[] #Array of lines to use as replacement --- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @param col_start integer #Start of (byte-indexed) column range to ---- highlight ---- @param col_end integer #End of (byte-indexed) column range to ---- highlight, or -1 to highlight to end of line ---- @param line integer #Line to highlight (zero-indexed) ---- @return any #The ns_id that was used -function vim.api.nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start, col_end) end +--- @param _end integer #Last line index (exclusive) +--- @param strict_indexing boolean #Whether out-of-bounds should be an +--- error. +--- @param start integer #First line index +function vim.api.nvim_buf_set_lines(buffer, start, _end, strict_indexing, replacement) end --- Clears namespaced objects (highlights, extmarks, virtual text) --- from a region. +-- Sets the full file name for a buffer --- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @param ns_id integer #Namespace to clear, or -1 to clear all ---- namespaces. ---- @param line_start integer #Start of range of lines to clear ---- @param line_end integer #End of range of lines to clear (exclusive) ---- or -1 to clear to end of buffer. -function vim.api.nvim_buf_clear_namespace(buffer, ns_id, line_start, line_end) end +--- @param name string #Buffer name +function vim.api.nvim_buf_set_name(buffer, name) end + +-- Sets a buffer option value. Passing 'nil' as value deletes the +-- option (only works if there's a global fallback) +--- @param name string #Option name +--- @param buffer buffer #Buffer handle, or 0 for current buffer +--- @param value object #Option value +function vim.api.nvim_buf_set_option(buffer, name, value) end + +-- Sets (replaces) a range in the buffer +--- @param replacement string[] #Array of lines to use as replacement +--- @param end_row integer #Last line index +--- @param buffer buffer #Buffer handle, or 0 for current buffer +--- @param start_column any #Last column +--- @param end_column any #Last column +--- @param start_row integer #First line index +function vim.api.nvim_buf_set_text(buffer, start_row, start_col, end_row, end_col, replacement) end + +-- Sets a buffer-scoped (b:) variable +--- @param name string #Variable name +--- @param buffer buffer #Buffer handle, or 0 for current buffer +--- @param value object #Variable value +function vim.api.nvim_buf_set_var(buffer, name, value) end -- Set the virtual text (annotation) for a buffer line. --- @param ns_id any #Namespace to use or 0 to create a namespace, or --- -1 for a ungrouped annotation ---- @param buffer buffer #Buffer handle, or 0 for current buffer --- @param opts dictionary #Optional parameters. Currently not used. --- @param chunks array #A list of [text, hl_group] arrays, each --- representing a text chunk with specified @@ -121,105 +160,60 @@ function vim.api.nvim_buf_clear_namespace(buffer, ns_id, line_start, line_end) e --- no highlight. --- @param line integer #Line to annotate with virtual text --- (zero-indexed) +--- @param buffer buffer #Buffer handle, or 0 for current buffer --- @return any #The ns_id that was used function vim.api.nvim_buf_set_virtual_text(buffer, src_id, line, chunks, opts) end --- call a function with buffer as temporary current buffer ---- @param fun luaref #Function to call inside the buffer (currently ---- lua callable only) ---- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @return any #Return value of function. NB: will deepcopy lua values ---- currently, use upvalues to send lua references in and out. -function vim.api.nvim_buf_call(buffer, fun) end +-- Calls many API methods atomically. +--- @param calls array #an array of calls, where each call is described +--- by an array with two elements: the request name, +--- and an array of arguments. +--- @return any #Array of two elements. The first is an array of return +--- values. The second is NIL if all calls succeeded. If a +--- call resulted in an error, it is a three-element array +--- with the zero-based index of the call which resulted in an +--- error, the error type and the error message. If an error +--- occurred, the values from all preceding calls will still +--- be returned. +function vim.api.nvim_call_atomic(calls) end -function vim.api.nvim__buf_stats(buffer) end +-- Calls a VimL |Dictionary-function| with the given arguments. +--- @param dict dictionary #Dictionary, or String evaluating to a VimL |self| +--- dict +--- @param args any[] #Function arguments packed in an Array +--- @param fn fun(...) #Name of the function defined on the VimL dict +--- @return any #Result of the function call +function vim.api.nvim_call_dict_function(dict, fn, args) end --- Gets the windows in a tabpage ---- @param tabpage tabpage #Tabpage handle, or 0 for current tabpage ---- @return any #List of windows in `tabpage` -function vim.api.nvim_tabpage_list_wins(tabpage) end +-- Calls a VimL function with the given arguments. +--- @param args any[] #Function arguments packed in an Array +--- @param fn fun(...) #Function to call +--- @return any #Result of the function call +function vim.api.nvim_call_function(fn, args) end --- Gets a tab-scoped (t:) variable ---- @param name string #Variable name ---- @param tabpage tabpage #Tabpage handle, or 0 for current tabpage ---- @return any #Variable value -function vim.api.nvim_tabpage_get_var(tabpage, name) end - --- Sets a tab-scoped (t:) variable ---- @param value object #Variable value ---- @param name string #Variable name ---- @param tabpage tabpage #Tabpage handle, or 0 for current tabpage -function vim.api.nvim_tabpage_set_var(tabpage, name, value) end - --- Removes a tab-scoped (t:) variable ---- @param name string #Variable name ---- @param tabpage tabpage #Tabpage handle, or 0 for current tabpage -function vim.api.nvim_tabpage_del_var(tabpage, name) end - --- Gets the current window in a tabpage ---- @param tabpage tabpage #Tabpage handle, or 0 for current tabpage ---- @return any #Window handle -function vim.api.nvim_tabpage_get_win(tabpage) end - --- Gets the tabpage number ---- @param tabpage tabpage #Tabpage handle, or 0 for current tabpage ---- @return any #Tabpage number -function vim.api.nvim_tabpage_get_number(tabpage) end - --- Checks if a tabpage is valid ---- @param tabpage tabpage #Tabpage handle, or 0 for current tabpage ---- @return any #true if the tabpage is valid, false otherwise -function vim.api.nvim_tabpage_is_valid(tabpage) end - --- Executes Vimscript (multiline block of Ex-commands), like --- anonymous |:source|. ---- @param output boolean #Capture and return all (non-error, non-shell ---- |:!|) output ---- @param src string #Vimscript code ---- @return any #Output (non-error, non-shell |:!|) if `output` is true, ---- else empty string. -function vim.api.nvim_exec(src, output) end +-- Send data to channel `id` . For a job, it writes it to the +-- stdin of the process. For the stdio channel |channel-stdio|, +-- it writes to Nvim's stdout. For an internal terminal instance +-- (|nvim_open_term()|) it writes directly to terimal output. See +-- |channel-bytes| for more information. +--- @param chan integer #id of the channel +--- @param data string #data to write. 8-bit clean: can contain NUL bytes. +function vim.api.nvim_chan_send(chan, data) end -- Executes an ex-command. --- @param command string #Ex-command string function vim.api.nvim_command(command) end --- Activates UI events on the channel. ---- @param width integer #Requested screen columns ---- @param options dictionary #|ui-option| map ---- @param height integer #Requested screen rows -function vim.api.nvim_ui_attach(width, height, options) end +-- Creates a new, empty, unnamed buffer. +--- @param scratch boolean #Creates a "throwaway" |scratch-buffer| for +--- temporary work (always 'nomodified'). Also sets +--- 'nomodeline' on the buffer. +--- @param listed boolean #Sets 'buflisted' +--- @return any #Buffer handle, or 0 on error +function vim.api.nvim_create_buf(listed, scratch) end --- Gets a highlight definition by id. |hlID()| ---- @param hl_id integer #Highlight id as returned by |hlID()| ---- @param rgb boolean #Export RGB colors ---- @return any #Highlight definition map -function vim.api.nvim_get_hl_by_id(hl_id, rgb) end - --- Gets a highlight group by name -function vim.api.nvim_get_hl_id_by_name(name) end - -function vim.api.nvim__get_hl_defs(ns_id) end - --- Set a highlight group. ---- @param val dictionary #highlight definiton map, like ---- |nvim_get_hl_by_name|. in addition the following ---- keys are also recognized: `default` : don't ---- override existing definition, like `hi default` ---- @param name string #highlight group name, like ErrorMsg ---- @param ns_id integer #number of namespace for this highlight -function vim.api.nvim_set_hl(ns_id, name, val) end - --- Set active namespace for highlights. ---- @param ns_id integer #the namespace to activate -function vim.api.nvim__set_hl_ns(ns_id) end - --- Sends input-keys to Nvim, subject to various quirks controlled --- by `mode` flags. This is a blocking call, unlike --- |nvim_input()|. ---- @param escape_csi boolean #If true, escape K_SPECIAL/CSI bytes in ---- `keys` ---- @param mode string #behavior flags, see |feedkeys()| ---- @param keys string #to be typed -function vim.api.nvim_feedkeys(keys, mode, escape_csi) end +-- Creates a new namespace, or gets an existing one. +--- @param name string #Namespace name or empty string +--- @return any #Namespace id +function vim.api.nvim_create_namespace(name) end diff --git a/types/api.2.lua b/types/api.2.lua index f4abf57..9db6b90 100644 --- a/types/api.2.lua +++ b/types/api.2.lua @@ -1,157 +1,25 @@ --# selene: allow(unused_variable) ---@diagnostic disable: unused-local --- Queues raw user-input. Unlike |nvim_feedkeys()|, this uses a --- low-level input buffer and the call is non-blocking (input is --- processed asynchronously by the eventloop). ---- @param keys string #to be typed ---- @return any #Number of bytes actually written (can be fewer than ---- requested if the buffer becomes full). -function vim.api.nvim_input(keys) end - --- Send mouse event from GUI. ---- @param action string #For ordinary buttons, one of "press", "drag", ---- "release". For the wheel, one of "up", "down", ---- "left", "right". ---- @param button string #Mouse button: one of "left", "right", ---- "middle", "wheel". ---- @param modifier string #String of modifiers each represented by a ---- single char. The same specifiers are used as ---- for a key press, except that the "-" separator ---- is optional, so "C-A-", "c-a" and "CA" can all ---- be used to specify Ctrl+Alt+click. ---- @param grid integer #Grid number if the client uses |ui-multigrid|, ---- else 0. ---- @param row integer #Mouse row-position (zero-based, like redraw ---- events) ---- @param col integer #Mouse column-position (zero-based, like redraw ---- events) -function vim.api.nvim_input_mouse(button, action, modifier, grid, row, col) end - --- Replaces terminal codes and |keycodes| (, , ...) in a --- string with the internal representation. ---- @param str string #String to be converted. ---- @param from_part boolean #Legacy Vim parameter. Usually true. ---- @param do_lt boolean #Also translate . Ignored if `special` is ---- false. ---- @param special boolean #Replace |keycodes|, e.g. becomes a "\n" ---- char. -function vim.api.nvim_replace_termcodes(str, from_part, do_lt, special) end - --- Evaluates a VimL |expression|. Dictionaries and Lists are --- recursively expanded. ---- @param expr string #VimL expression string ---- @return any #Evaluation result or expanded object -function vim.api.nvim_eval(expr) end - --- Notify the user with a message ---- @param opts dictionary #Reserved for future use. ---- @param log_level integer #The log level ---- @param msg string #Message to display to the user -function vim.api.nvim_notify(msg, log_level, opts) end - --- Calls a VimL function with the given arguments. ---- @param args any[] #Function arguments packed in an Array ---- @param fn fun(...) #Function to call ---- @return any #Result of the function call -function vim.api.nvim_call_function(fn, args) end - --- Calls a VimL |Dictionary-function| with the given arguments. ---- @param dict dictionary #Dictionary, or String evaluating to a VimL |self| ---- dict ---- @param args any[] #Function arguments packed in an Array ---- @param fn fun(...) #Name of the function defined on the VimL dict ---- @return any #Result of the function call -function vim.api.nvim_call_dict_function(dict, fn, args) end - --- Calculates the number of display cells occupied by `text` . --- counts as one cell. ---- @param text string #Some text ---- @return any #Number of cells -function vim.api.nvim_strwidth(text) end - --- Gets the paths contained in 'runtimepath'. ---- @return any #List of paths -function vim.api.nvim_list_runtime_paths() end - --- Find files in runtime directories ---- @param all boolean #whether to return all matches or only the first ---- @param name string #pattern of files to search for ---- @return any #list of absolute paths to the found files -function vim.api.nvim_get_runtime_file(name, all) end - -function vim.api.nvim__get_lib_dir() end - --- Changes the global working directory. ---- @param dir string #Directory path -function vim.api.nvim_set_current_dir(dir) end - --- Gets the current line. ---- @return any #Current line string -function vim.api.nvim_get_current_line() end - --- Sets the current line. ---- @param line string #Line contents -function vim.api.nvim_set_current_line(line) end - -- Deletes the current line. function vim.api.nvim_del_current_line() end --- Gets a global (g:) variable. ---- @param name string #Variable name ---- @return any #Variable value -function vim.api.nvim_get_var(name) end - -function vim.api.nvim_ui_set_option(name, value, error) end +-- Unmaps a global |mapping| for the given mode. +function vim.api.nvim_del_keymap(mode, lhs) end -- Removes a global (g:) variable. --- @param name string #Variable name function vim.api.nvim_del_var(name) end --- Gets a v: variable. ---- @param name string #Variable name ---- @return any #Variable value -function vim.api.nvim_get_vvar(name) end - --- Sets a v: variable, if it is not readonly. ---- @param name string #Variable name ---- @param value object #Variable value -function vim.api.nvim_set_vvar(name, value) end - --- Gets an option value string. ---- @param name string #Option name ---- @return any #Option value (global) -function vim.api.nvim_get_option(name) end - --- Gets the option information for all options. ---- @return any #dictionary of all options -function vim.api.nvim_get_all_options_info() end - --- Gets the option information for one option ---- @param name string #Option name ---- @return any #Option Information -function vim.api.nvim_get_option_info(name) end - --- Sets an option value. ---- @param name string #Option name ---- @param value object #New option value -function vim.api.nvim_set_option(name, value) end - -- Echo a message. ---- @param opts dictionary #Optional parameters. Reserved for future use. --- @param chunks array #A list of [text, hl_group] arrays, each --- representing a text chunk with specified --- highlight. `hl_group` element can be omitted --- for no highlight. --- @param history boolean #if true, add to |message-history|. +--- @param opts dictionary #Optional parameters. Reserved for future use. function vim.api.nvim_echo(chunks, history, opts) end --- Writes a message to the Vim output buffer. Does not append --- "\n", the message is buffered (won't display) until a linefeed --- is written. ---- @param str string #Message -function vim.api.nvim_out_write(str) end - -- Writes a message to the Vim error buffer. Does not append -- "\n", the message is buffered (won't display) until a linefeed -- is written. @@ -163,137 +31,230 @@ function vim.api.nvim_err_write(str) end --- @param str string #Message function vim.api.nvim_err_writeln(str) end --- Gets the current list of buffer handles ---- @return any #List of buffer handles -function vim.api.nvim_list_bufs() end +-- Evaluates a VimL |expression|. Dictionaries and Lists are +-- recursively expanded. +--- @param expr string #VimL expression string +--- @return any #Evaluation result or expanded object +function vim.api.nvim_eval(expr) end + +-- Executes Vimscript (multiline block of Ex-commands), like +-- anonymous |:source|. +--- @param output boolean #Capture and return all (non-error, non-shell +--- |:!|) output +--- @param src string #Vimscript code +--- @return any #Output (non-error, non-shell |:!|) if `output` is true, +--- else empty string. +function vim.api.nvim_exec(src, output) end + +-- Execute Lua code. Parameters (if any) are available as `...` +-- inside the chunk. The chunk can return a value. +--- @param args any[] #Arguments to the code +--- @param code string #Lua code to execute +--- @return any #Return value of Lua code if present or NIL. +function vim.api.nvim_exec_lua(code, args) end + +-- Sends input-keys to Nvim, subject to various quirks controlled +-- by `mode` flags. This is a blocking call, unlike +-- |nvim_input()|. +--- @param mode string #behavior flags, see |feedkeys()| +--- @param escape_csi boolean #If true, escape K_SPECIAL/CSI bytes in +--- `keys` +--- @param keys string #to be typed +function vim.api.nvim_feedkeys(keys, mode, escape_csi) end + +-- Gets the option information for all options. +--- @return any #dictionary of all options +function vim.api.nvim_get_all_options_info() end + +-- Returns a 2-tuple (Array), where item 0 is the current channel +-- id and item 1 is the |api-metadata| map (Dictionary). +--- @return any #2-tuple [{channel-id}, {api-metadata}] +function vim.api.nvim_get_api_info() end + +-- Get information about a channel. +--- @return any #Dictionary describing a channel, with these keys: +--- • "stream" the stream underlying the channel +--- • "stdio" stdin and stdout of this Nvim instance +--- • "stderr" stderr of this Nvim instance +--- • "socket" TCP/IP socket or named pipe +--- • "job" job with communication over its stdio +--- +--- • "mode" how data received on the channel is interpreted +--- • "bytes" send and receive raw bytes +--- • "terminal" a |terminal| instance interprets ASCII +--- sequences +--- • "rpc" |RPC| communication on the channel is active +--- +--- • "pty" Name of pseudoterminal, if one is used (optional). +--- On a POSIX system, this will be a device path like +--- /dev/pts/1. Even if the name is unknown, the key will +--- still be present to indicate a pty is used. This is +--- currently the case when using winpty on windows. +--- • "buffer" buffer with connected |terminal| instance +--- (optional) +--- • "client" information about the client on the other end +--- of the RPC channel, if it has added it using +--- |nvim_set_client_info()|. (optional) +--- +function vim.api.nvim_get_chan_info(chan) end + +-- Returns the 24-bit RGB value of a |nvim_get_color_map()| color +-- name or "#rrggbb" hexadecimal string. +--- @param name string #Color name or "#rrggbb" string +--- @return any #24-bit RGB value, or -1 for invalid argument. +function vim.api.nvim_get_color_by_name(name) end + +-- Returns a map of color names and RGB values. +--- @return any #Map of color names and RGB values. +function vim.api.nvim_get_color_map() end + +-- Gets a map of global (non-buffer-local) Ex commands. +--- @param opts dictionary #Optional parameters. Currently only supports +--- {"builtin":false} +--- @return any #Map of maps describing commands. +function vim.api.nvim_get_commands(opts) end + +-- Gets a map of the current editor state. +--- @param opts dictionary #Optional parameters. +--- • types: List of |context-types| ("regs", "jumps", +--- "bufs", "gvars", …) to gather, or empty for +--- "all". +--- @return any #map of global |context|. +function vim.api.nvim_get_context(opts) end -- Gets the current buffer. --- @return any #Buffer handle function vim.api.nvim_get_current_buf() end --- Sets the current buffer. ---- @param buffer buffer #Buffer handle -function vim.api.nvim_set_current_buf(buffer) end +-- Gets the current line. +--- @return any #Current line string +function vim.api.nvim_get_current_line() end --- Gets the current list of window handles. ---- @return any #List of window handles -function vim.api.nvim_list_wins() end +-- Gets the current tabpage. +--- @return any #Tabpage handle +function vim.api.nvim_get_current_tabpage() end -- Gets the current window. --- @return any #Window handle function vim.api.nvim_get_current_win() end --- Sets the current window. ---- @param window window #Window handle -function vim.api.nvim_set_current_win(window) end +-- Gets a highlight definition by id. |hlID()| +--- @param rgb boolean #Export RGB colors +--- @param hl_id integer #Highlight id as returned by |hlID()| +--- @return any #Highlight definition map +function vim.api.nvim_get_hl_by_id(hl_id, rgb) end --- Creates a new, empty, unnamed buffer. ---- @param scratch boolean #Creates a "throwaway" |scratch-buffer| for ---- temporary work (always 'nomodified'). Also sets ---- 'nomodeline' on the buffer. ---- @param listed boolean #Sets 'buflisted' ---- @return any #Buffer handle, or 0 on error -function vim.api.nvim_create_buf(listed, scratch) end +-- Gets a highlight definition by name. +--- @param rgb boolean #Export RGB colors +--- @param name string #Highlight group name +--- @return any #Highlight definition map +function vim.api.nvim_get_hl_by_name(name, rgb) end --- Open a terminal instance in a buffer ---- @param opts dictionary #Optional parameters. Reserved for future use. ---- @param buffer buffer #the buffer to use (expected to be empty) ---- @return any #Channel id, or 0 on error -function vim.api.nvim_open_term(buffer, opts) end +-- Gets a highlight group by name +function vim.api.nvim_get_hl_id_by_name(name) end --- Send data to channel `id` . For a job, it writes it to the --- stdin of the process. For the stdio channel |channel-stdio|, --- it writes to Nvim's stdout. For an internal terminal instance --- (|nvim_open_term()|) it writes directly to terimal output. See --- |channel-bytes| for more information. ---- @param chan integer #id of the channel ---- @param data string #data to write. 8-bit clean: can contain NUL bytes. -function vim.api.nvim_chan_send(chan, data) end +-- Gets a list of global (non-buffer-local) |mapping| +-- definitions. +--- @param mode string #Mode short-name ("n", "i", "v", ...) +--- @return any #Array of maparg()-like dictionaries describing mappings. +--- The "buffer" key is always zero. +function vim.api.nvim_get_keymap(mode) end --- Open a new window. ---- @param config dictionary #Map defining the window configuration. Keys: ---- • `relative`: Sets the window layout to "floating", placed ---- at (row,col) coordinates relative to: ---- • "editor" The global editor grid ---- • "win" Window given by the `win` field, or ---- current window. ---- • "cursor" Cursor position in current window. +-- Gets the current mode. |mode()| "blocking" is true if Nvim is +-- waiting for input. +--- @return any #Dictionary { "mode": String, "blocking": Boolean } +function vim.api.nvim_get_mode() end + +-- Gets existing, non-anonymous namespaces. +--- @return any #dict that maps from names to namespace ids. +function vim.api.nvim_get_namespaces() end + +-- Gets an option value string. +--- @param name string #Option name +--- @return any #Option value (global) +function vim.api.nvim_get_option(name) end + +-- Gets the option information for one option +--- @param name string #Option name +--- @return any #Option Information +function vim.api.nvim_get_option_info(name) end + +-- Gets info describing process `pid` . +--- @return any #Map of process properties, or NIL if process not found. +function vim.api.nvim_get_proc(pid) end + +-- Gets the immediate children of process `pid` . +--- @return any #Array of child process ids, empty if process not found. +function vim.api.nvim_get_proc_children(pid) end + +-- Find files in runtime directories +--- @param name string #pattern of files to search for +--- @param all boolean #whether to return all matches or only the first +--- @return any #list of absolute paths to the found files +function vim.api.nvim_get_runtime_file(name, all) end + +-- Gets a global (g:) variable. +--- @param name string #Variable name +--- @return any #Variable value +function vim.api.nvim_get_var(name) end + +-- Gets a v: variable. +--- @param name string #Variable name +--- @return any #Variable value +function vim.api.nvim_get_vvar(name) end + +-- Queues raw user-input. Unlike |nvim_feedkeys()|, this uses a +-- low-level input buffer and the call is non-blocking (input is +-- processed asynchronously by the eventloop). +--- @param keys string #to be typed +--- @return any #Number of bytes actually written (can be fewer than +--- requested if the buffer becomes full). +function vim.api.nvim_input(keys) end + +-- Send mouse event from GUI. +--- @param modifier string #String of modifiers each represented by a +--- single char. The same specifiers are used as +--- for a key press, except that the "-" separator +--- is optional, so "C-A-", "c-a" and "CA" can all +--- be used to specify Ctrl+Alt+click. +--- @param action string #For ordinary buttons, one of "press", "drag", +--- "release". For the wheel, one of "up", "down", +--- "left", "right". +--- @param row integer #Mouse row-position (zero-based, like redraw +--- events) +--- @param col integer #Mouse column-position (zero-based, like redraw +--- events) +--- @param grid integer #Grid number if the client uses |ui-multigrid|, +--- else 0. +--- @param button string #Mouse button: one of "left", "right", +--- "middle", "wheel". +function vim.api.nvim_input_mouse(button, action, modifier, grid, row, col) end + +-- Gets the current list of buffer handles +--- @return any #List of buffer handles +function vim.api.nvim_list_bufs() end + +-- Get information about all open channels. +--- @return any #Array of Dictionaries, each describing a channel with the +--- format specified at |nvim_get_chan_info()|. +function vim.api.nvim_list_chans() end + +-- Gets the paths contained in 'runtimepath'. +--- @return any #List of paths +function vim.api.nvim_list_runtime_paths() end + +-- Gets the current list of tabpage handles. +--- @return any #List of tabpage handles +function vim.api.nvim_list_tabpages() end + +-- Gets a list of dictionaries representing attached UIs. +--- @return any #Array of UI dictionaries, each with these keys: +--- • "height" Requested height of the UI +--- • "width" Requested width of the UI +--- • "rgb" true if the UI uses RGB colors (false implies +--- |cterm-colors|) +--- • "ext_..." Requested UI extensions, see |ui-option| +--- • "chan" Channel id of remote UI (not present for TUI) --- ---- • `win` : |window-ID| for relative="win". ---- • `anchor`: Decides which corner of the float to place ---- at (row,col): ---- • "NW" northwest (default) ---- • "NE" northeast ---- • "SW" southwest ---- • "SE" southeast ---- ---- • `width` : Window width (in character cells). ---- Minimum of 1. ---- • `height` : Window height (in character cells). ---- Minimum of 1. ---- • `bufpos` : Places float relative to buffer ---- text (only when relative="win"). Takes a tuple ---- of zero-indexed [line, column]. `row` and ---- `col` if given are applied relative to this ---- position, else they default to `row=1` and ---- `col=0` (thus like a tooltip near the buffer ---- text). ---- • `row` : Row position in units of "screen cell ---- height", may be fractional. ---- • `col` : Column position in units of "screen ---- cell width", may be fractional. ---- • `focusable` : Enable focus by user actions ---- (wincmds, mouse events). Defaults to true. ---- Non-focusable windows can be entered by ---- |nvim_set_current_win()|. ---- • `external` : GUI should display the window as ---- an external top-level window. Currently ---- accepts no other positioning configuration ---- together with this. ---- • `style`: Configure the appearance of the window. ---- Currently only takes one non-empty value: ---- • "minimal" Nvim will display the window with ---- many UI options disabled. This is useful ---- when displaying a temporary float where the ---- text should not be edited. Disables ---- 'number', 'relativenumber', 'cursorline', ---- 'cursorcolumn', 'foldcolumn', 'spell' and ---- 'list' options. 'signcolumn' is changed to ---- `auto` and 'colorcolumn' is cleared. The ---- end-of-buffer region is hidden by setting ---- `eob` flag of 'fillchars' to a space char, ---- and clearing the |EndOfBuffer| region in ---- 'winhighlight'. ---- ---- • `border`: style of (optional) window border. This can ---- either be a string or an array. the string ---- values are: ---- • "none" No border. This is the default ---- • "single" a single line box ---- • "double" a double line box ---- • "shadow" a drop shadow effect by blending ---- with the background. If it is an array it ---- should be an array of eight items or any ---- divisor of eight. The array will specifify ---- the eight chars building up the border in a ---- clockwise fashion starting with the top-left ---- corner. As, an example, the double box style ---- could be specified as: [ "╔", "═" ,"╗", "║", ---- "╝", "═", "╚", "║" ] if the number of chars ---- are less than eight, they will be repeated. ---- Thus an ASCII border could be specified as: ---- [ "/", "-", "\\", "|" ] or all chars the ---- same as: [ "x" ] An empty string can be used ---- to turn off a specific border, for instance: ---- [ "", "", "", ">", "", "", "", "<" ] will ---- only make vertical borders but not ---- horizontal ones. By default `FloatBorder` ---- highlight is used which links to `VertSplit` ---- when not defined. It could also be specified ---- by character: [ {"+", "MyCorner"}, {"x", ---- "MyBorder"} ] ---- @param buffer buffer #Buffer to display, or 0 for current buffer ---- @param enter boolean #Enter the window (make it the current window) ---- @return any #Window handle, or 0 on error -function vim.api.nvim_open_win(buffer, enter, config) end +function vim.api.nvim_list_uis() end diff --git a/types/api.3.lua b/types/api.3.lua index 70670c4..8b947e7 100644 --- a/types/api.3.lua +++ b/types/api.3.lua @@ -1,145 +1,128 @@ --# selene: allow(unused_variable) ---@diagnostic disable: unused-local --- Gets the current list of tabpage handles. ---- @return any #List of tabpage handles -function vim.api.nvim_list_tabpages() end +-- Gets the current list of window handles. +--- @return any #List of window handles +function vim.api.nvim_list_wins() end --- Gets the current tabpage. ---- @return any #Tabpage handle -function vim.api.nvim_get_current_tabpage() end +-- Sets the current editor state from the given |context| map. +--- @param dict dictionary #|Context| map. +function vim.api.nvim_load_context(dict) end --- Sets the current tabpage. ---- @param tabpage tabpage #Tabpage handle -function vim.api.nvim_set_current_tabpage(tabpage) end +-- Notify the user with a message +--- @param log_level integer #The log level +--- @param msg string #Message to display to the user +--- @param opts dictionary #Reserved for future use. +function vim.api.nvim_notify(msg, log_level, opts) end --- Creates a new namespace, or gets an existing one. ---- @param name string #Namespace name or empty string ---- @return any #Namespace id -function vim.api.nvim_create_namespace(name) end +-- Open a terminal instance in a buffer +--- @param buffer buffer #the buffer to use (expected to be empty) +--- @param opts dictionary #Optional parameters. Reserved for future use. +--- @return any #Channel id, or 0 on error +function vim.api.nvim_open_term(buffer, opts) end --- Gets existing, non-anonymous namespaces. ---- @return any #dict that maps from names to namespace ids. -function vim.api.nvim_get_namespaces() end - --- Pastes at cursor, in any mode. ---- @param phase integer #-1: paste in a single call (i.e. without ---- streaming). To "stream" a paste, call `nvim_paste` sequentially with these `phase` values: ---- • 1: starts the paste (exactly once) ---- • 2: continues the paste (zero or more times) ---- • 3: ends the paste (exactly once) ---- @param data string #Multiline input. May be binary (containing NUL ---- bytes). ---- @param crlf boolean #Also break lines at CR and CRLF. ---- @return any # ---- • true: Client may continue pasting. ---- • false: Client must cancel the paste. +-- Open a new window. +--- @param enter boolean #Enter the window (make it the current window) +--- @param config dictionary #Map defining the window configuration. Keys: +--- • `relative`: Sets the window layout to "floating", placed +--- at (row,col) coordinates relative to: +--- • "editor" The global editor grid +--- • "win" Window given by the `win` field, or +--- current window. +--- • "cursor" Cursor position in current window. --- -function vim.api.nvim_paste(data, crlf, phase) end - --- Puts text at cursor, in any mode. ---- @param lines string[] #|readfile()|-style list of lines. ---- |channel-lines| ---- @param type string #Edit behavior: any |getregtype()| result, or: ---- • "b" |blockwise-visual| mode (may include ---- width, e.g. "b3") ---- • "c" |charwise| mode ---- • "l" |linewise| mode ---- • "" guess by contents, see |setreg()| ---- @param after boolean #If true insert after cursor (like |p|), or ---- before (like |P|). ---- @param follow boolean #If true place cursor at end of inserted text. -function vim.api.nvim_put(lines, type, after, follow) end - --- Returns the 24-bit RGB value of a |nvim_get_color_map()| color --- name or "#rrggbb" hexadecimal string. ---- @param name string #Color name or "#rrggbb" string ---- @return any #24-bit RGB value, or -1 for invalid argument. -function vim.api.nvim_get_color_by_name(name) end - --- Returns a map of color names and RGB values. ---- @return any #Map of color names and RGB values. -function vim.api.nvim_get_color_map() end - --- Gets a map of the current editor state. ---- @param opts dictionary #Optional parameters. ---- • types: List of |context-types| ("regs", "jumps", ---- "bufs", "gvars", …) to gather, or empty for ---- "all". ---- @return any #map of global |context|. -function vim.api.nvim_get_context(opts) end - --- Tells Nvim the number of elements displaying in the popumenu, --- to decide and movement. ---- @param height integer #Popupmenu height, must be greater than zero. -function vim.api.nvim_ui_pum_set_height(height) end - --- Gets the current mode. |mode()| "blocking" is true if Nvim is --- waiting for input. ---- @return any #Dictionary { "mode": String, "blocking": Boolean } -function vim.api.nvim_get_mode() end - --- Gets a list of global (non-buffer-local) |mapping| --- definitions. ---- @param mode string #Mode short-name ("n", "i", "v", ...) ---- @return any #Array of maparg()-like dictionaries describing mappings. ---- The "buffer" key is always zero. -function vim.api.nvim_get_keymap(mode) end - --- Sets a global |mapping| for the given mode. ---- @param opts dictionary #Optional parameters map. Accepts all ---- |:map-arguments| as keys excluding || but ---- including |noremap|. Values are Booleans. Unknown ---- key is an error. ---- @param rhs string #Right-hand-side |{rhs}| of the mapping. ---- @param lhs string #Left-hand-side |{lhs}| of the mapping. ---- @param mode string #Mode short-name (map command prefix: "n", "i", ---- "v", "x", …) or "!" for |:map!|, or empty string ---- for |:map|. -function vim.api.nvim_set_keymap(mode, lhs, rhs, opts) end - --- Unmaps a global |mapping| for the given mode. -function vim.api.nvim_del_keymap(mode, lhs) end - --- Gets a map of global (non-buffer-local) Ex commands. ---- @param opts dictionary #Optional parameters. Currently only supports ---- {"builtin":false} ---- @return any #Map of maps describing commands. -function vim.api.nvim_get_commands(opts) end - --- Get information about a channel. ---- @return any #Dictionary describing a channel, with these keys: ---- • "stream" the stream underlying the channel ---- • "stdio" stdin and stdout of this Nvim instance ---- • "stderr" stderr of this Nvim instance ---- • "socket" TCP/IP socket or named pipe ---- • "job" job with communication over its stdio +--- • `win` : |window-ID| for relative="win". +--- • `anchor`: Decides which corner of the float to place +--- at (row,col): +--- • "NW" northwest (default) +--- • "NE" northeast +--- • "SW" southwest +--- • "SE" southeast --- ---- • "mode" how data received on the channel is interpreted ---- • "bytes" send and receive raw bytes ---- • "terminal" a |terminal| instance interprets ASCII ---- sequences ---- • "rpc" |RPC| communication on the channel is active +--- • `width` : Window width (in character cells). +--- Minimum of 1. +--- • `height` : Window height (in character cells). +--- Minimum of 1. +--- • `bufpos` : Places float relative to buffer +--- text (only when relative="win"). Takes a tuple +--- of zero-indexed [line, column]. `row` and +--- `col` if given are applied relative to this +--- position, else they default to `row=1` and +--- `col=0` (thus like a tooltip near the buffer +--- text). +--- • `row` : Row position in units of "screen cell +--- height", may be fractional. +--- • `col` : Column position in units of "screen +--- cell width", may be fractional. +--- • `focusable` : Enable focus by user actions +--- (wincmds, mouse events). Defaults to true. +--- Non-focusable windows can be entered by +--- |nvim_set_current_win()|. +--- • `external` : GUI should display the window as +--- an external top-level window. Currently +--- accepts no other positioning configuration +--- together with this. +--- • `style`: Configure the appearance of the window. +--- Currently only takes one non-empty value: +--- • "minimal" Nvim will display the window with +--- many UI options disabled. This is useful +--- when displaying a temporary float where the +--- text should not be edited. Disables +--- 'number', 'relativenumber', 'cursorline', +--- 'cursorcolumn', 'foldcolumn', 'spell' and +--- 'list' options. 'signcolumn' is changed to +--- `auto` and 'colorcolumn' is cleared. The +--- end-of-buffer region is hidden by setting +--- `eob` flag of 'fillchars' to a space char, +--- and clearing the |EndOfBuffer| region in +--- 'winhighlight'. --- ---- • "pty" Name of pseudoterminal, if one is used (optional). ---- On a POSIX system, this will be a device path like ---- /dev/pts/1. Even if the name is unknown, the key will ---- still be present to indicate a pty is used. This is ---- currently the case when using winpty on windows. ---- • "buffer" buffer with connected |terminal| instance ---- (optional) ---- • "client" information about the client on the other end ---- of the RPC channel, if it has added it using ---- |nvim_set_client_info()|. (optional) ---- -function vim.api.nvim_get_chan_info(chan) end +--- • `border`: style of (optional) window border. This can +--- either be a string or an array. the string +--- values are: +--- • "none" No border. This is the default +--- • "single" a single line box +--- • "double" a double line box +--- • "shadow" a drop shadow effect by blending +--- with the background. If it is an array it +--- should be an array of eight items or any +--- divisor of eight. The array will specifify +--- the eight chars building up the border in a +--- clockwise fashion starting with the top-left +--- corner. As, an example, the double box style +--- could be specified as: [ "╔", "═" ,"╗", "║", +--- "╝", "═", "╚", "║" ] if the number of chars +--- are less than eight, they will be repeated. +--- Thus an ASCII border could be specified as: +--- [ "/", "-", "\\", "|" ] or all chars the +--- same as: [ "x" ] An empty string can be used +--- to turn off a specific border, for instance: +--- [ "", "", "", ">", "", "", "", "<" ] will +--- only make vertical borders but not +--- horizontal ones. By default `FloatBorder` +--- highlight is used which links to `VertSplit` +--- when not defined. It could also be specified +--- by character: [ {"+", "MyCorner"}, {"x", +--- "MyBorder"} ] +--- @param buffer buffer #Buffer to display, or 0 for current buffer +--- @return any #Window handle, or 0 on error +function vim.api.nvim_open_win(buffer, enter, config) end --- Get information about all open channels. ---- @return any #Array of Dictionaries, each describing a channel with the ---- format specified at |nvim_get_chan_info()|. -function vim.api.nvim_list_chans() end +-- Writes a message to the Vim output buffer. Does not append +-- "\n", the message is buffered (won't display) until a linefeed +-- is written. +--- @param str string #Message +function vim.api.nvim_out_write(str) end -- Parse a VimL expression. +--- @param highlight boolean #If true, return value will also include +--- "highlight" key containing array of 4-tuples +--- (arrays) (Integer, Integer, Integer, String), +--- where first three numbers define the +--- highlighted region and represent line, +--- starting column and ending column (latter +--- exclusive: one should highlight region +--- [start_col, end_col)). --- @param flags string #Flags: --- • "m" if multiple expressions in a row are --- allowed (only the first one will be @@ -156,14 +139,6 @@ function vim.api.nvim_list_chans() end --- • "E" to parse like for "=". --- • empty string for ":call". --- • "lm" to parse for ":let". ---- @param highlight boolean #If true, return value will also include ---- "highlight" key containing array of 4-tuples ---- (arrays) (Integer, Integer, Integer, String), ---- where first three numbers define the ---- highlighted region and represent line, ---- starting column and ending column (latter ---- exclusive: one should highlight region ---- [start_col, end_col)). --- @param expr string #Expression to parse. Always treated as a --- single line. --- @return any # diff --git a/types/api.4.lua b/types/api.4.lua index 1c86fde..9e6848c 100644 --- a/types/api.4.lua +++ b/types/api.4.lua @@ -1,237 +1,57 @@ --# selene: allow(unused_variable) ---@diagnostic disable: unused-local --- Returns object given as argument. ---- @param obj object #Object to return. ---- @return any #its argument. -function vim.api.nvim__id(obj) end +-- Pastes at cursor, in any mode. +--- @param data string #Multiline input. May be binary (containing NUL +--- bytes). +--- @param phase integer #-1: paste in a single call (i.e. without +--- streaming). To "stream" a paste, call `nvim_paste` sequentially with these `phase` values: +--- • 1: starts the paste (exactly once) +--- • 2: continues the paste (zero or more times) +--- • 3: ends the paste (exactly once) +--- @param crlf boolean #Also break lines at CR and CRLF. +--- @return any # +--- • true: Client may continue pasting. +--- • false: Client must cancel the paste. +--- +function vim.api.nvim_paste(data, crlf, phase) end --- Returns array given as argument. ---- @param arr array #Array to return. ---- @return any #its argument. -function vim.api.nvim__id_array(arr) end +-- Puts text at cursor, in any mode. +--- @param after boolean #If true insert after cursor (like |p|), or +--- before (like |P|). +--- @param type string #Edit behavior: any |getregtype()| result, or: +--- • "b" |blockwise-visual| mode (may include +--- width, e.g. "b3") +--- • "c" |charwise| mode +--- • "l" |linewise| mode +--- • "" guess by contents, see |setreg()| +--- @param lines string[] #|readfile()|-style list of lines. +--- |channel-lines| +--- @param follow boolean #If true place cursor at end of inserted text. +function vim.api.nvim_put(lines, type, after, follow) end --- Returns dictionary given as argument. ---- @param dct dictionary #Dictionary to return. ---- @return any #its argument. -function vim.api.nvim__id_dictionary(dct) end - --- Returns floating-point value given as argument. ---- @param flt float #Value to return. ---- @return any #its argument. -function vim.api.nvim__id_float(flt) end - --- Gets internal stats. ---- @return any #Map of various internal stats. -function vim.api.nvim__stats() end - --- Deactivates UI events on the channel. -function vim.api.nvim_ui_detach() end - --- Gets the immediate children of process `pid` . ---- @return any #Array of child process ids, empty if process not found. -function vim.api.nvim_get_proc_children(pid) end - --- Gets info describing process `pid` . ---- @return any #Map of process properties, or NIL if process not found. -function vim.api.nvim_get_proc(pid) end +-- Replaces terminal codes and |keycodes| (, , ...) in a +-- string with the internal representation. +--- @param str string #String to be converted. +--- @param special boolean #Replace |keycodes|, e.g. becomes a "\n" +--- char. +--- @param from_part boolean #Legacy Vim parameter. Usually true. +--- @param do_lt boolean #Also translate . Ignored if `special` is +--- false. +function vim.api.nvim_replace_termcodes(str, from_part, do_lt, special) end -- Selects an item in the completion popupmenu. ---- @param finish boolean #Finish the completion and dismiss the popupmenu. ---- Implies `insert` . +--- @param insert boolean #Whether the selection should be inserted in the +--- buffer. --- @param item integer #Index (zero-based) of the item to select. Value --- of -1 selects nothing and restores the original --- text. +--- @param finish boolean #Finish the completion and dismiss the popupmenu. +--- Implies `insert` . --- @param opts dictionary #Optional parameters. Reserved for future use. ---- @param insert boolean #Whether the selection should be inserted in the ---- buffer. function vim.api.nvim_select_popupmenu_item(item, insert, finish, opts) end --- NB: if your UI doesn't use hlstate, this will not return --- hlstate first time. -function vim.api.nvim__inspect_cell(grid, row, col) end - -function vim.api.nvim__screenshot(path) end - --- Set or change decoration provider for a namespace ---- @param opts dictionaryof(luaref) #Callbacks invoked during redraw: ---- • on_start: called first on each screen redraw ---- ["start", tick] ---- • on_buf: called for each buffer being redrawn ---- (before window callbacks) ["buf", bufnr, tick] ---- • on_win: called when starting to redraw a ---- specific window. ["win", winid, bufnr, topline, ---- botline_guess] ---- • on_line: called for each buffer line being ---- redrawn. (The interation with fold lines is ---- subject to change) ["win", winid, bufnr, row] ---- • on_end: called at the end of a redraw cycle ---- ["end", tick] ---- @param ns_id integer #Namespace id from |nvim_create_namespace()| -function vim.api.nvim_set_decoration_provider(ns_id, opts) end - --- Returns a 2-tuple (Array), where item 0 is the current channel --- id and item 1 is the |api-metadata| map (Dictionary). ---- @return any #2-tuple [{channel-id}, {api-metadata}] -function vim.api.nvim_get_api_info() end - --- Sets the current buffer in a window, without side-effects ---- @param window window #Window handle, or 0 for current window ---- @param buffer buffer #Buffer handle -function vim.api.nvim_win_set_buf(window, buffer) end - --- Gets the (1,0)-indexed cursor position in the window. --- |api-indexing| ---- @param window window #Window handle, or 0 for current window ---- @return any #(row, col) tuple -function vim.api.nvim_win_get_cursor(window) end - --- Sets the (1,0)-indexed cursor position in the window. --- |api-indexing| ---- @param window window #Window handle, or 0 for current window ---- @param pos arrayof(integer, 2) #(row, col) tuple representing the new position -function vim.api.nvim_win_set_cursor(window, pos) end - --- Gets the window height ---- @param window window #Window handle, or 0 for current window ---- @return any #Height as a count of rows -function vim.api.nvim_win_get_height(window) end - --- Sets the window height. This will only succeed if the screen --- is split horizontally. ---- @param window window #Window handle, or 0 for current window ---- @param height integer #Height as a count of rows -function vim.api.nvim_win_set_height(window, height) end - --- Gets the window width ---- @param window window #Window handle, or 0 for current window ---- @return any #Width as a count of columns -function vim.api.nvim_win_get_width(window) end - --- Sets the window width. This will only succeed if the screen is --- split vertically. ---- @param window window #Window handle, or 0 for current window ---- @param width integer #Width as a count of columns -function vim.api.nvim_win_set_width(window, width) end - --- Gets a window-scoped (w:) variable ---- @param name string #Variable name ---- @param window window #Window handle, or 0 for current window ---- @return any #Variable value -function vim.api.nvim_win_get_var(window, name) end - --- Sets a window-scoped (w:) variable ---- @param window window #Window handle, or 0 for current window ---- @param name string #Variable name ---- @param value object #Variable value -function vim.api.nvim_win_set_var(window, name, value) end - --- Removes a window-scoped (w:) variable ---- @param name string #Variable name ---- @param window window #Window handle, or 0 for current window -function vim.api.nvim_win_del_var(window, name) end - --- Gets a window option value ---- @param name string #Option name ---- @param window window #Window handle, or 0 for current window ---- @return any #Option value -function vim.api.nvim_win_get_option(window, name) end - --- Sets a window option value. Passing 'nil' as value deletes the --- option(only works if there's a global fallback) ---- @param window window #Window handle, or 0 for current window ---- @param name string #Option name ---- @param value object #Option value -function vim.api.nvim_win_set_option(window, name, value) end - --- Gets the window position in display cells. First position is --- zero. ---- @param window window #Window handle, or 0 for current window ---- @return any #(row, col) tuple with the window position -function vim.api.nvim_win_get_position(window) end - --- Gets the window tabpage ---- @param window window #Window handle, or 0 for current window ---- @return any #Tabpage that contains the window -function vim.api.nvim_win_get_tabpage(window) end - --- Gets the window number ---- @param window window #Window handle, or 0 for current window ---- @return any #Window number -function vim.api.nvim_win_get_number(window) end - --- Checks if a window is valid ---- @param window window #Window handle, or 0 for current window ---- @return any #true if the window is valid, false otherwise -function vim.api.nvim_win_is_valid(window) end - -function vim.api.nvim_ui_try_resize(width, height) end - --- Subscribes to event broadcasts. ---- @param event string #Event type string -function vim.api.nvim_subscribe(event) end - --- Calls many API methods atomically. ---- @param calls array #an array of calls, where each call is described ---- by an array with two elements: the request name, ---- and an array of arguments. ---- @return any #Array of two elements. The first is an array of return ---- values. The second is NIL if all calls succeeded. If a ---- call resulted in an error, it is a three-element array ---- with the zero-based index of the call which resulted in an ---- error, the error type and the error message. If an error ---- occurred, the values from all preceding calls will still ---- be returned. -function vim.api.nvim_call_atomic(calls) end - --- Tells Nvim the geometry of the popumenu, to align floating --- windows with an external popup menu. ---- @param width float #Popupmenu width. ---- @param height float #Popupmenu height. ---- @param row float #Popupmenu row. ---- @param col float #Popupmenu height. -function vim.api.nvim_ui_pum_set_bounds(width, height, row, col) end - --- Unsubscribes to event broadcasts. ---- @param event string #Event type string -function vim.api.nvim_unsubscribe(event) end - --- Execute Lua code. Parameters (if any) are available as `...` --- inside the chunk. The chunk can return a value. ---- @param args any[] #Arguments to the code ---- @param code string #Lua code to execute ---- @return any #Return value of Lua code if present or NIL. -function vim.api.nvim_exec_lua(code, args) end - --- Configures window layout. Currently only for floating and --- external windows (including changing a split window to those --- layouts). ---- @param window window #Window handle, or 0 for current window ---- @param config dictionary #Map defining the window configuration, see ---- |nvim_open_win()| -function vim.api.nvim_win_set_config(window, config) end - --- Deletes the buffer. See |:bwipeout| ---- @param opts dictionary #Optional parameters. Keys: ---- • force: Force deletion and ignore unsaved ---- changes. ---- • unload: Unloaded only, do not delete. See ---- |:bunload| ---- @param buffer buffer #Buffer handle, or 0 for current buffer -function vim.api.nvim_buf_delete(buffer, opts) end - -- Self-identifies the client. ---- @param version dictionary #Dictionary describing the version, with ---- these (optional) keys: ---- • "major" major version (defaults to 0 if ---- not set, for no release yet) ---- • "minor" minor version ---- • "patch" patch number ---- • "prerelease" string describing a ---- prerelease, like "dev" or "beta1" ---- • "commit" hash or similar identifier of ---- commit ---- @param name string #Short name for the connected client --- @param methods dictionary #Builtin methods in the client. For a host, --- this does not include plugin methods which --- will be discovered later. The key should be @@ -247,6 +67,17 @@ function vim.api.nvim_buf_delete(buffer, opts) end --- • "nargs" Number of arguments. Could be a --- single integer or an array of two --- integers, minimum and maximum inclusive. +--- @param name string #Short name for the connected client +--- @param version dictionary #Dictionary describing the version, with +--- these (optional) keys: +--- • "major" major version (defaults to 0 if +--- not set, for no release yet) +--- • "minor" minor version +--- • "patch" patch number +--- • "prerelease" string describing a +--- prerelease, like "dev" or "beta1" +--- • "commit" hash or similar identifier of +--- commit --- @param attributes dictionary #Arbitrary string:string map of informal --- client properties. Suggested keys: --- • "website": Client homepage URL (e.g. @@ -269,3 +100,129 @@ function vim.api.nvim_buf_delete(buffer, opts) end --- • "plugin" single plugin, started by nvim function vim.api.nvim_set_client_info(name, version, type, methods, attributes) end +-- Sets the current buffer. +--- @param buffer buffer #Buffer handle +function vim.api.nvim_set_current_buf(buffer) end + +-- Changes the global working directory. +--- @param dir string #Directory path +function vim.api.nvim_set_current_dir(dir) end + +-- Sets the current line. +--- @param line string #Line contents +function vim.api.nvim_set_current_line(line) end + +-- Sets the current tabpage. +--- @param tabpage tabpage #Tabpage handle +function vim.api.nvim_set_current_tabpage(tabpage) end + +-- Sets the current window. +--- @param window window #Window handle +function vim.api.nvim_set_current_win(window) end + +-- Set or change decoration provider for a namespace +--- @param ns_id integer #Namespace id from |nvim_create_namespace()| +--- @param opts dictionaryof(luaref) #Callbacks invoked during redraw: +--- • on_start: called first on each screen redraw +--- ["start", tick] +--- • on_buf: called for each buffer being redrawn +--- (before window callbacks) ["buf", bufnr, tick] +--- • on_win: called when starting to redraw a +--- specific window. ["win", winid, bufnr, topline, +--- botline_guess] +--- • on_line: called for each buffer line being +--- redrawn. (The interation with fold lines is +--- subject to change) ["win", winid, bufnr, row] +--- • on_end: called at the end of a redraw cycle +--- ["end", tick] +function vim.api.nvim_set_decoration_provider(ns_id, opts) end + +-- Set a highlight group. +--- @param name string #highlight group name, like ErrorMsg +--- @param val dictionary #highlight definiton map, like +--- |nvim_get_hl_by_name|. in addition the following +--- keys are also recognized: `default` : don't +--- override existing definition, like `hi default` +--- @param ns_id integer #number of namespace for this highlight +function vim.api.nvim_set_hl(ns_id, name, val) end + +-- Sets a global |mapping| for the given mode. +--- @param lhs string #Left-hand-side |{lhs}| of the mapping. +--- @param rhs string #Right-hand-side |{rhs}| of the mapping. +--- @param mode string #Mode short-name (map command prefix: "n", "i", +--- "v", "x", …) or "!" for |:map!|, or empty string +--- for |:map|. +--- @param opts dictionary #Optional parameters map. Accepts all +--- |:map-arguments| as keys excluding || but +--- including |noremap|. Values are Booleans. Unknown +--- key is an error. +function vim.api.nvim_set_keymap(mode, lhs, rhs, opts) end + +-- Sets an option value. +--- @param value object #New option value +--- @param name string #Option name +function vim.api.nvim_set_option(name, value) end + +-- Sets a global (g:) variable. +--- @param value object #Variable value +--- @param name string #Variable name +function vim.api.nvim_set_var(name, value) end + +-- Sets a v: variable, if it is not readonly. +--- @param value object #Variable value +--- @param name string #Variable name +function vim.api.nvim_set_vvar(name, value) end + +-- Calculates the number of display cells occupied by `text` . +-- counts as one cell. +--- @param text string #Some text +--- @return any #Number of cells +function vim.api.nvim_strwidth(text) end + +-- Subscribes to event broadcasts. +--- @param event string #Event type string +function vim.api.nvim_subscribe(event) end + +-- Removes a tab-scoped (t:) variable +--- @param tabpage tabpage #Tabpage handle, or 0 for current tabpage +--- @param name string #Variable name +function vim.api.nvim_tabpage_del_var(tabpage, name) end + +-- Gets the tabpage number +--- @param tabpage tabpage #Tabpage handle, or 0 for current tabpage +--- @return any #Tabpage number +function vim.api.nvim_tabpage_get_number(tabpage) end + +-- Gets a tab-scoped (t:) variable +--- @param tabpage tabpage #Tabpage handle, or 0 for current tabpage +--- @param name string #Variable name +--- @return any #Variable value +function vim.api.nvim_tabpage_get_var(tabpage, name) end + +-- Gets the current window in a tabpage +--- @param tabpage tabpage #Tabpage handle, or 0 for current tabpage +--- @return any #Window handle +function vim.api.nvim_tabpage_get_win(tabpage) end + +-- Checks if a tabpage is valid +--- @param tabpage tabpage #Tabpage handle, or 0 for current tabpage +--- @return any #true if the tabpage is valid, false otherwise +function vim.api.nvim_tabpage_is_valid(tabpage) end + +-- Gets the windows in a tabpage +--- @param tabpage tabpage #Tabpage handle, or 0 for current tabpage +--- @return any #List of windows in `tabpage` +function vim.api.nvim_tabpage_list_wins(tabpage) end + +-- Sets a tab-scoped (t:) variable +--- @param name string #Variable name +--- @param tabpage tabpage #Tabpage handle, or 0 for current tabpage +--- @param value object #Variable value +function vim.api.nvim_tabpage_set_var(tabpage, name, value) end + +-- Activates UI events on the channel. +--- @param height integer #Requested screen rows +--- @param options dictionary #|ui-option| map +--- @param width integer #Requested screen columns +function vim.api.nvim_ui_attach(width, height, options) end + diff --git a/types/api.5.lua b/types/api.5.lua index d7103c3..900e14c 100644 --- a/types/api.5.lua +++ b/types/api.5.lua @@ -1,45 +1,157 @@ --# selene: allow(unused_variable) ---@diagnostic disable: unused-local --- Sets the current editor state from the given |context| map. ---- @param dict dictionary #|Context| map. -function vim.api.nvim_load_context(dict) end +-- Deactivates UI events on the channel. +function vim.api.nvim_ui_detach() end --- Checks if a buffer is valid. ---- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @return any #true if the buffer is valid, false otherwise. -function vim.api.nvim_buf_is_valid(buffer) end +-- Tells Nvim the geometry of the popumenu, to align floating +-- windows with an external popup menu. +--- @param row float #Popupmenu row. +--- @param col float #Popupmenu height. +--- @param width float #Popupmenu width. +--- @param height float #Popupmenu height. +function vim.api.nvim_ui_pum_set_bounds(width, height, row, col) end --- Sets a global (g:) variable. +-- Tells Nvim the number of elements displaying in the popumenu, +-- to decide and movement. +--- @param height integer #Popupmenu height, must be greater than zero. +function vim.api.nvim_ui_pum_set_height(height) end + +function vim.api.nvim_ui_set_option(name, value, error) end + +function vim.api.nvim_ui_try_resize(width, height) end + +-- Tell Nvim to resize a grid. Triggers a grid_resize event with +-- the requested grid size or the maximum size if it exceeds size +-- limits. +--- @param height integer #The new requested height. +--- @param width integer #The new requested width. +--- @param grid integer #The handle of the grid to be changed. +function vim.api.nvim_ui_try_resize_grid(grid, width, height) end + +-- Unsubscribes to event broadcasts. +--- @param event string #Event type string +function vim.api.nvim_unsubscribe(event) end + +-- Closes the window (like |:close| with a |window-ID|). +--- @param force boolean #Behave like `:close!` The last window of a +--- buffer with unwritten changes can be closed. The +--- buffer will become hidden, even if 'hidden' is +--- not set. +--- @param window window #Window handle, or 0 for current window +function vim.api.nvim_win_close(window, force) end + +-- Removes a window-scoped (w:) variable +--- @param window window #Window handle, or 0 for current window --- @param name string #Variable name ---- @param value object #Variable value -function vim.api.nvim_set_var(name, value) end - --- Checks if a buffer is valid and loaded. See |api-buffer| for --- more info about unloaded buffers. ---- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @return any #true if the buffer is valid and loaded, false otherwise. -function vim.api.nvim_buf_is_loaded(buffer) end - --- Gets a highlight definition by name. ---- @param name string #Highlight group name ---- @param rgb boolean #Export RGB colors ---- @return any #Highlight definition map -function vim.api.nvim_get_hl_by_name(name, rgb) end - --- Gets a list of dictionaries representing attached UIs. ---- @return any #Array of UI dictionaries, each with these keys: ---- • "height" Requested height of the UI ---- • "width" Requested width of the UI ---- • "rgb" true if the UI uses RGB colors (false implies ---- |cterm-colors|) ---- • "ext_..." Requested UI extensions, see |ui-option| ---- • "chan" Channel id of remote UI (not present for TUI) ---- -function vim.api.nvim_list_uis() end +function vim.api.nvim_win_del_var(window, name) end -- Gets the current buffer in a window --- @param window window #Window handle, or 0 for current window --- @return any #Buffer handle function vim.api.nvim_win_get_buf(window) end +-- Gets window configuration. +--- @param window window #Window handle, or 0 for current window +--- @return any #Map defining the window configuration, see +--- |nvim_open_win()| +function vim.api.nvim_win_get_config(window) end + +-- Gets the (1,0)-indexed cursor position in the window. +-- |api-indexing| +--- @param window window #Window handle, or 0 for current window +--- @return any #(row, col) tuple +function vim.api.nvim_win_get_cursor(window) end + +-- Gets the window height +--- @param window window #Window handle, or 0 for current window +--- @return any #Height as a count of rows +function vim.api.nvim_win_get_height(window) end + +-- Gets the window number +--- @param window window #Window handle, or 0 for current window +--- @return any #Window number +function vim.api.nvim_win_get_number(window) end + +-- Gets a window option value +--- @param window window #Window handle, or 0 for current window +--- @param name string #Option name +--- @return any #Option value +function vim.api.nvim_win_get_option(window, name) end + +-- Gets the window position in display cells. First position is +-- zero. +--- @param window window #Window handle, or 0 for current window +--- @return any #(row, col) tuple with the window position +function vim.api.nvim_win_get_position(window) end + +-- Gets the window tabpage +--- @param window window #Window handle, or 0 for current window +--- @return any #Tabpage that contains the window +function vim.api.nvim_win_get_tabpage(window) end + +-- Gets a window-scoped (w:) variable +--- @param window window #Window handle, or 0 for current window +--- @param name string #Variable name +--- @return any #Variable value +function vim.api.nvim_win_get_var(window, name) end + +-- Gets the window width +--- @param window window #Window handle, or 0 for current window +--- @return any #Width as a count of columns +function vim.api.nvim_win_get_width(window) end + +-- Closes the window and hide the buffer it contains (like +-- |:hide| with a |window-ID|). +--- @param window window #Window handle, or 0 for current window +function vim.api.nvim_win_hide(window) end + +-- Checks if a window is valid +--- @param window window #Window handle, or 0 for current window +--- @return any #true if the window is valid, false otherwise +function vim.api.nvim_win_is_valid(window) end + +-- Sets the current buffer in a window, without side-effects +--- @param buffer buffer #Buffer handle +--- @param window window #Window handle, or 0 for current window +function vim.api.nvim_win_set_buf(window, buffer) end + +-- Configures window layout. Currently only for floating and +-- external windows (including changing a split window to those +-- layouts). +--- @param config dictionary #Map defining the window configuration, see +--- |nvim_open_win()| +--- @param window window #Window handle, or 0 for current window +function vim.api.nvim_win_set_config(window, config) end + +-- Sets the (1,0)-indexed cursor position in the window. +-- |api-indexing| +--- @param pos arrayof(integer, 2) #(row, col) tuple representing the new position +--- @param window window #Window handle, or 0 for current window +function vim.api.nvim_win_set_cursor(window, pos) end + +-- Sets the window height. This will only succeed if the screen +-- is split horizontally. +--- @param height integer #Height as a count of rows +--- @param window window #Window handle, or 0 for current window +function vim.api.nvim_win_set_height(window, height) end + +-- Sets a window option value. Passing 'nil' as value deletes the +-- option(only works if there's a global fallback) +--- @param name string #Option name +--- @param window window #Window handle, or 0 for current window +--- @param value object #Option value +function vim.api.nvim_win_set_option(window, name, value) end + +-- Sets a window-scoped (w:) variable +--- @param name string #Variable name +--- @param window window #Window handle, or 0 for current window +--- @param value object #Variable value +function vim.api.nvim_win_set_var(window, name, value) end + +-- Sets the window width. This will only succeed if the screen is +-- split vertically. +--- @param width integer #Width as a count of columns +--- @param window window #Window handle, or 0 for current window +function vim.api.nvim_win_set_width(window, width) end + diff --git a/types/api.lua b/types/api.lua index 1c3ab1a..4f53c64 100644 --- a/types/api.lua +++ b/types/api.lua @@ -1,24 +1,60 @@ --# selene: allow(unused_variable) ---@diagnostic disable: unused-local --- Tell Nvim to resize a grid. Triggers a grid_resize event with --- the requested grid size or the maximum size if it exceeds size --- limits. ---- @param width integer #The new requested width. ---- @param grid integer #The handle of the grid to be changed. ---- @param height integer #The new requested height. -function vim.api.nvim_ui_try_resize_grid(grid, width, height) end +function vim.api.nvim__buf_redraw_range(buffer, first, last) end --- Deactivates buffer-update events on the channel. ---- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @return any #False if detach failed (because the buffer isn't loaded); ---- otherwise True. -function vim.api.nvim_buf_detach(buffer) end +function vim.api.nvim__buf_stats(buffer) end --- Gets the buffer line count +function vim.api.nvim__get_hl_defs(ns_id) end + +function vim.api.nvim__get_lib_dir() end + +-- Returns object given as argument. +--- @param obj object #Object to return. +--- @return any #its argument. +function vim.api.nvim__id(obj) end + +-- Returns array given as argument. +--- @param arr array #Array to return. +--- @return any #its argument. +function vim.api.nvim__id_array(arr) end + +-- Returns dictionary given as argument. +--- @param dct dictionary #Dictionary to return. +--- @return any #its argument. +function vim.api.nvim__id_dictionary(dct) end + +-- Returns floating-point value given as argument. +--- @param flt float #Value to return. +--- @return any #its argument. +function vim.api.nvim__id_float(flt) end + +-- NB: if your UI doesn't use hlstate, this will not return +-- hlstate first time. +function vim.api.nvim__inspect_cell(grid, row, col) end + +function vim.api.nvim__screenshot(path) end + +-- Set active namespace for highlights. +--- @param ns_id integer #the namespace to activate +function vim.api.nvim__set_hl_ns(ns_id) end + +-- Gets internal stats. +--- @return any #Map of various internal stats. +function vim.api.nvim__stats() end + +-- Adds a highlight to buffer. +--- @param col_start integer #Start of (byte-indexed) column range to +--- highlight +--- @param col_end integer #End of (byte-indexed) column range to +--- highlight, or -1 to highlight to end of line +--- @param ns_id integer #namespace to use or -1 for ungrouped +--- highlight +--- @param hl_group string #Name of the highlight group to use +--- @param line integer #Line to highlight (zero-indexed) --- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @return any #Line count, or 0 for unloaded buffer. |api-buffer| -function vim.api.nvim_buf_line_count(buffer) end +--- @return any #The ns_id that was used +function vim.api.nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start, col_end) end -- Activates buffer-update events on a channel, or as Lua -- callbacks. @@ -90,52 +126,91 @@ function vim.api.nvim_buf_line_count(buffer) end --- loaded); otherwise True. TODO: LUA_API_NO_EVAL function vim.api.nvim_buf_attach(buffer, send_buffer, opts) end -function vim.api.nvim__buf_redraw_range(buffer, first, last) end - --- Gets a line-range from the buffer. ---- @param _end integer #Last line index (exclusive) ---- @param start integer #First line index ---- @param strict_indexing boolean #Whether out-of-bounds should be an ---- error. +-- call a function with buffer as temporary current buffer --- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @return any #Array of lines, or empty array for unloaded buffer. -function vim.api.nvim_buf_get_lines(buffer, start, _end, strict_indexing) end +--- @param fun luaref #Function to call inside the buffer (currently +--- lua callable only) +--- @return any #Return value of function. NB: will deepcopy lua values +--- currently, use upvalues to send lua references in and out. +function vim.api.nvim_buf_call(buffer, fun) end --- Sets (replaces) a line-range in the buffer. ---- @param strict_indexing boolean #Whether out-of-bounds should be an ---- error. ---- @param replacement string[] #Array of lines to use as replacement ---- @param start integer #First line index +-- Clears namespaced objects (highlights, extmarks, virtual text) +-- from a region. --- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @param _end integer #Last line index (exclusive) -function vim.api.nvim_buf_set_lines(buffer, start, _end, strict_indexing, replacement) end +--- @param line_start integer #Start of range of lines to clear +--- @param line_end integer #End of range of lines to clear (exclusive) +--- or -1 to clear to end of buffer. +--- @param ns_id integer #Namespace to clear, or -1 to clear all +--- namespaces. +function vim.api.nvim_buf_clear_namespace(buffer, ns_id, line_start, line_end) end --- Sets (replaces) a range in the buffer ---- @param start_row integer #First line index ---- @param start_column any #Last column ---- @param end_row integer #Last line index ---- @param replacement string[] #Array of lines to use as replacement +-- Removes an extmark. +--- @param id integer #Extmark id +--- @param ns_id integer #Namespace id from |nvim_create_namespace()| --- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @param end_column any #Last column -function vim.api.nvim_buf_set_text(buffer, start_row, start_col, end_row, end_col, replacement) end +--- @return any #true if the extmark was found, else false +function vim.api.nvim_buf_del_extmark(buffer, ns_id, id) end --- Returns the byte offset of a line (0-indexed). |api-indexing| ---- @param index integer #Line index +-- Unmaps a buffer-local |mapping| for the given mode. --- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @return any #Integer byte offset, or -1 for unloaded buffer. -function vim.api.nvim_buf_get_offset(buffer, index) end +function vim.api.nvim_buf_del_keymap(buffer, mode, lhs) end --- Gets a buffer-scoped (b:) variable. +-- Removes a buffer-scoped (b:) variable +--- @param buffer buffer #Buffer handle, or 0 for current buffer --- @param name string #Variable name +function vim.api.nvim_buf_del_var(buffer, name) end + +-- Deletes the buffer. See |:bwipeout| --- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @return any #Variable value -function vim.api.nvim_buf_get_var(buffer, name) end +--- @param opts dictionary #Optional parameters. Keys: +--- • force: Force deletion and ignore unsaved +--- changes. +--- • unload: Unloaded only, do not delete. See +--- |:bunload| +function vim.api.nvim_buf_delete(buffer, opts) end + +-- Deactivates buffer-update events on the channel. +--- @param buffer buffer #Buffer handle, or 0 for current buffer +--- @return any #False if detach failed (because the buffer isn't loaded); +--- otherwise True. +function vim.api.nvim_buf_detach(buffer) end -- Gets a changed tick of a buffer --- @param buffer buffer #Buffer handle, or 0 for current buffer --- @return any #`b:changedtick` value. function vim.api.nvim_buf_get_changedtick(buffer) end +-- Gets a map of buffer-local |user-commands|. +--- @param buffer buffer #Buffer handle, or 0 for current buffer +--- @param opts dictionary #Optional parameters. Currently not used. +--- @return any #Map of maps describing commands. +function vim.api.nvim_buf_get_commands(buffer, opts) end + +-- Returns position for a given extmark id +--- @param id integer #Extmark id +--- @param buffer buffer #Buffer handle, or 0 for current buffer +--- @param ns_id integer #Namespace id from |nvim_create_namespace()| +--- @param opts dictionary #Optional parameters. Keys: +--- • details: Whether to include the details dict +--- @return any #(row, col) tuple or empty list () if extmark id was absent +function vim.api.nvim_buf_get_extmark_by_id(buffer, ns_id, id, opts) end + +-- Gets extmarks in "traversal order" from a |charwise| region +-- defined by buffer positions (inclusive, 0-indexed +-- |api-indexing|). +--- @param start object #Start of range, given as (row, col) or valid +--- extmark id (whose position defines the bound) +--- @param ns_id integer #Namespace id from |nvim_create_namespace()| +--- @param opts dictionary #Optional parameters. Keys: +--- • limit: Maximum number of marks to return +--- • details Whether to include the details dict +--- @param buffer buffer #Buffer handle, or 0 for current buffer +--- @param _end object #End of range, given as (row, col) or valid +--- extmark id (whose position defines the bound) +--- @return any #List of [extmark_id, row, col] tuples in "traversal +--- order". +function vim.api.nvim_buf_get_extmarks(buffer, ns_id, start, _end, opts) end + -- Gets a list of buffer-local |mapping| definitions. --- @param mode string #Mode short-name ("n", "i", "v", ...) --- @param buffer buffer #Buffer handle, or 0 for current buffer @@ -143,86 +218,12 @@ function vim.api.nvim_buf_get_changedtick(buffer) end --- The "buffer" key holds the associated buffer handle. function vim.api.nvim_buf_get_keymap(buffer, mode) end --- Sets a buffer-local |mapping| for the given mode. +-- Gets a line-range from the buffer. +--- @param start integer #First line index --- @param buffer buffer #Buffer handle, or 0 for current buffer -function vim.api.nvim_buf_set_keymap(buffer, mode, lhs, rhs, opts) end - --- Unmaps a buffer-local |mapping| for the given mode. ---- @param buffer buffer #Buffer handle, or 0 for current buffer -function vim.api.nvim_buf_del_keymap(buffer, mode, lhs) end - --- Gets a map of buffer-local |user-commands|. ---- @param opts dictionary #Optional parameters. Currently not used. ---- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @return any #Map of maps describing commands. -function vim.api.nvim_buf_get_commands(buffer, opts) end - --- Sets a buffer-scoped (b:) variable ---- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @param name string #Variable name ---- @param value object #Variable value -function vim.api.nvim_buf_set_var(buffer, name, value) end - --- Removes a buffer-scoped (b:) variable ---- @param name string #Variable name ---- @param buffer buffer #Buffer handle, or 0 for current buffer -function vim.api.nvim_buf_del_var(buffer, name) end - --- Gets a buffer option value ---- @param name string #Option name ---- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @return any #Option value -function vim.api.nvim_buf_get_option(buffer, name) end - --- Sets a buffer option value. Passing 'nil' as value deletes the --- option (only works if there's a global fallback) ---- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @param name string #Option name ---- @param value object #Option value -function vim.api.nvim_buf_set_option(buffer, name, value) end - --- Gets the full file name for the buffer ---- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @return any #Buffer name -function vim.api.nvim_buf_get_name(buffer) end - --- Sets the full file name for a buffer ---- @param name string #Buffer name ---- @param buffer buffer #Buffer handle, or 0 for current buffer -function vim.api.nvim_buf_set_name(buffer, name) end - --- Gets window configuration. ---- @param window window #Window handle, or 0 for current window ---- @return any #Map defining the window configuration, see ---- |nvim_open_win()| -function vim.api.nvim_win_get_config(window) end - --- Closes the window and hide the buffer it contains (like --- |:hide| with a |window-ID|). ---- @param window window #Window handle, or 0 for current window -function vim.api.nvim_win_hide(window) end - --- Closes the window (like |:close| with a |window-ID|). ---- @param window window #Window handle, or 0 for current window ---- @param force boolean #Behave like `:close!` The last window of a ---- buffer with unwritten changes can be closed. The ---- buffer will become hidden, even if 'hidden' is ---- not set. -function vim.api.nvim_win_close(window, force) end - --- Return a tuple (row,col) representing the position of the --- named mark. ---- @param name string #Mark name ---- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @return any #(row, col) tuple -function vim.api.nvim_buf_get_mark(buffer, name) end - --- Returns position for a given extmark id ---- @param id integer #Extmark id ---- @param buffer buffer #Buffer handle, or 0 for current buffer ---- @param opts dictionary #Optional parameters. Keys: ---- • details: Whether to include the details dict ---- @param ns_id integer #Namespace id from |nvim_create_namespace()| ---- @return any #(row, col) tuple or empty list () if extmark id was absent -function vim.api.nvim_buf_get_extmark_by_id(buffer, ns_id, id, opts) end +--- @param strict_indexing boolean #Whether out-of-bounds should be an +--- error. +--- @param _end integer #Last line index (exclusive) +--- @return any #Array of lines, or empty array for unloaded buffer. +function vim.api.nvim_buf_get_lines(buffer, start, _end, strict_indexing) end diff --git a/types/lsp.1.lua b/types/lsp.1.lua index e1cbdd6..a82a1ab 100644 --- a/types/lsp.1.lua +++ b/types/lsp.1.lua @@ -1,215 +1,42 @@ --# selene: allow(unused_variable) ---@diagnostic disable: unused-local --- Applies a list of text edits to a buffer. ---- @param text_edits any #(table) list of `TextEdit` objects ---- @param buf_nr any #(number) Buffer id -function vim.lsp.apply_text_edits(text_edits, bufnr) end - -- Get all diagnostics for all clients --- @return any #{bufnr:Diagnostic[]} function vim.lsp.get_all() end --- Creates a `TextDocumentIdentifier` object for the current --- buffer. ---- @return any #`TextDocumentIdentifier` -function vim.lsp.make_text_document_params() end - --- Formats the current buffer. ---- @param options any #(optional, table) Can be used to specify ---- FormattingOptions. Some unspecified options ---- will be automatically derived from the current ---- Neovim options. -function vim.lsp.formatting(options) end - --- Performs |vim.lsp.buf.formatting()| synchronously. ---- @param options any #Table with valid `FormattingOptions` entries ---- @param timeout_ms any #(number) Request timeout -function vim.lsp.formatting_sync(options, timeout_ms) end - --- Converts `textDocument/SignatureHelp` response to markdown --- lines. ---- @param signature_help any #Response of `textDocument/SignatureHelp` ---- @return any #list of lines of converted markdown. -function vim.lsp.convert_signature_help_to_markdown_lines(signature_help) end - --- Jumps to the definition of the symbol under the cursor. -function vim.lsp.definition() end - --- Formats the current buffer by sequentially requesting --- formatting from attached clients. ---- @param order any #(optional, table) List of client names. ---- Formatting is requested from clients in the ---- following order: first all clients that are ---- not in the `order` list, then the remaining ---- clients in the order as they occur in the ---- `order` list. ---- @param options any #(optional, table) `FormattingOptions` ---- entries ---- @param timeout_ms any #(optional, number) Request timeout -function vim.lsp.formatting_seq_sync(options, timeout_ms, order) end - --- Gets a new ClientCapabilities object describing the LSP client --- capabilities. -function vim.lsp.make_client_capabilities() end - --- Shows contents in a floating window. ---- @param contents any #table of lines to show in window ---- @param opts any #dictionary with optional fields ---- @param syntax any #string of syntax to set for opened buffer ---- @return any #bufnr,winnr buffer and window number of the newly created ---- floating preview window -function vim.lsp.open_floating_preview(contents, syntax, opts) end - --- Formats a given range. ---- @param start_pos any #({number, number}, optional) mark-indexed ---- position. Defaults to the start of the last ---- visual selection. ---- @param options any #Table with valid `FormattingOptions` entries. ---- @param end_pos any #({number, number}, optional) mark-indexed ---- position. Defaults to the end of the last ---- visual selection. -function vim.lsp.range_formatting(options, start_pos, end_pos) end - --- client_id → state -function vim.lsp.init(client, bufnr) end - --- Returns the range table for the difference between old and new --- lines ---- @param new_lines any #table list of lines ---- @param old_lines any #table list of lines ---- @param start_line_idx any #int line to begin search for first ---- difference ---- @param end_line_idx any #int line to begin search for last ---- difference ---- @param offset_encoding any #string encoding requested by language ---- server ---- @return any #table start_line_idx and start_col_idx of range -function vim.lsp.compute_diff(old_lines, new_lines, start_line_idx, end_line_idx, offset_encoding) end - --- Lists all symbols in the current buffer in the quickfix --- window. -function vim.lsp.document_symbol() end - --- Displays hover information about the symbol under the cursor --- in a floating window. Calling the function twice will jump --- into the floating window. -function vim.lsp.hover() end - --- Returns the items with the byte position calculated correctly --- and in sorted order, for display in quickfix and location --- lists. ---- @param locations any #(table) list of `Location` s or ---- `LocationLink` s ---- @return any #(table) list of items -function vim.lsp.locations_to_items(locations) end - --- Parses snippets in a completion entry. ---- @param input any #(string) unparsed snippet ---- @return any #(string) parsed snippet -function vim.lsp.parse_snippet(input) end - --- Set signs for given diagnostics ---- @param sign_ns any #number|nil ---- @param client_id any #number the client id +-- Get the counts for a particular severity +--- @param severity any #DiagnosticSeverity --- @param bufnr any #number The buffer number ---- @param diagnostics any #Diagnostic [] ---- @param opts any #table Configuration for signs. Keys: ---- • priority: Set the priority of the signs. ---- • severity_limit (DiagnosticSeverity): ---- • Limit severity of diagnostics found. ---- E.g. "Warning" means { "Error", ---- "Warning" } will be valid. -function vim.lsp.set_signs(diagnostics, bufnr, client_id, sign_ns, opts) end - --- Clears the currently displayed diagnostics ---- @param diagnostic_ns any #number|nil Associated diagnostic ---- namespace ---- @param sign_ns any #number|nil Associated sign namespace --- @param client_id any #number the client id ---- @param bufnr any #number The buffer number -function vim.lsp.clear(bufnr, client_id, diagnostic_ns, sign_ns) end +function vim.lsp.get_count(bufnr, severity, client_id) end --- Lists all the call sites of the symbol under the cursor in the --- |quickfix| window. If the symbol can resolve to multiple --- items, the user can pick one in the |inputlist|. -function vim.lsp.incoming_calls() end +-- Returns visual width of tabstop. +--- @param bufnr any #(optional, number): Buffer handle, defaults to +--- current +--- @return any #(number) tabstop visual width +function vim.lsp.get_effective_tabstop(bufnr) end --- Turns the result of a `textDocument/completion` request into --- vim-compatible |complete-items|. ---- @param prefix any #(string) the prefix to filter the completion ---- items ---- @param result any #The result of a `textDocument/completion` call, ---- e.g. from |vim.lsp.buf.completion()|, which may ---- be one of `CompletionItem[]` , `CompletionList` ---- or `null` ---- @return any #{ matches = complete-items table, incomplete = bool } -function vim.lsp.text_document_completion_list_to_complete_items(result, prefix) end +-- Returns the log filename. +--- @return any #(string) log filename +function vim.lsp.get_filename() end --- Lists all the items that are called by the symbol under the --- cursor in the |quickfix| window. If the symbol can resolve to --- multiple items, the user can pick one in the |inputlist|. -function vim.lsp.outgoing_calls() end - --- List workspace folders. -function vim.lsp.list_workspace_folders() end - --- Returns the UTF-32 and UTF-16 offsets for a position in a --- certain buffer. ---- @param row any #0-indexed line ---- @param buf any #buffer id (0 for current) ---- @param col any #0-indexed byte offset in line ---- @return any #(number, number) UTF-32 and UTF-16 index of the character ---- in line {row} column {col} in buffer {buf} -function vim.lsp.character_offset(buf, row, col) end - --- Open a floating window with the diagnostics from {line_nr} ---- @param opts any #table Configuration table ---- • show_header (boolean, default true): Show ---- "Diagnostics:" header. +-- Get the diagnostics by line +--- @param opts any #table|nil Configuration keys +--- • severity: (DiagnosticSeverity, default nil) +--- • Only return diagnostics with this +--- severity. Overrides severity_limit +--- +--- • severity_limit: (DiagnosticSeverity, default nil) +--- • Limit severity of diagnostics found. E.g. +--- "Warning" means { "Error", "Warning" } +--- will be valid. --- @param line_nr any #number The line number ---- @param client_id any #number|nil the client id --- @param bufnr any #number The buffer number ---- @return any #table {popup_bufnr, win_id} -function vim.lsp.show_line_diagnostics(opts, bufnr, line_nr, client_id) end - --- Add the folder at path to the workspace folders. If {path} is --- not provided, the user will be prompted for a path using --- |input()|. -function vim.lsp.add_workspace_folder(workspace_folder) end - --- Get the previous diagnostic closest to the cursor_position ---- @param opts any #table See |vim.lsp.diagnostic.goto_next()| ---- @return any #table Previous diagnostic -function vim.lsp.get_prev(opts) end - --- Converts any of `MarkedString` | `MarkedString[]` | --- `MarkupContent` into a list of lines containing valid --- markdown. Useful to populate the hover window for --- `textDocument/hover` , for parsing the result of --- `textDocument/signatureHelp` , and potentially others. ---- @param contents any #(table, optional, default `{}` ) List of ---- strings to extend with converted lines ---- @param input any #( `MarkedString` | `MarkedString[]` | ---- `MarkupContent` ) ---- @return any #{contents}, extended with lines of converted markdown. -function vim.lsp.convert_input_to_markdown_lines(input, contents) end - --- Return the pos, {row, col}, for the prev diagnostic in the --- current buffer. ---- @param opts any #table See |vim.lsp.diagnostic.goto_next()| ---- @return any #table Previous diagnostic position -function vim.lsp.get_prev_pos(opts) end - --- Move to the previous diagnostic ---- @param opts any #table See |vim.lsp.diagnostic.goto_next()| -function vim.lsp.goto_prev(opts) end - --- Shows a list of document highlights for a certain buffer. ---- @param references any #List of `DocumentHighlight` objects to ---- highlight ---- @param bufnr any #buffer id -function vim.lsp.buf_highlight_references(bufnr, references) end +--- @param client_id any #number the client id +--- @return any #table Table with map of line number to list of +--- diagnostics. +function vim.lsp.get_line_diagnostics(bufnr, line_nr, opts, client_id) end -- Get the next diagnostic closest to the cursor_position --- @param opts any #table See |vim.lsp.diagnostic.goto_next()| @@ -222,29 +49,202 @@ function vim.lsp.get_next(opts) end --- @return any #table Next diagnostic position function vim.lsp.get_next_pos(opts) end --- Sends a request to the LSP server and runs {callback} upon --- response. ---- @param params any #(table) Parameters for the invoked LSP method +-- Get the previous diagnostic closest to the cursor_position +--- @param opts any #table See |vim.lsp.diagnostic.goto_next()| +--- @return any #table Previous diagnostic +function vim.lsp.get_prev(opts) end + +-- Return the pos, {row, col}, for the prev diagnostic in the +-- current buffer. +--- @param opts any #table See |vim.lsp.diagnostic.goto_next()| +--- @return any #table Previous diagnostic position +function vim.lsp.get_prev_pos(opts) end + +-- Process and return progress reports from lsp server. +function vim.lsp.get_progress_messages() end + +-- Default function to get text chunks to display using `nvim_buf_set_virtual_text` . +--- @param line_diags any #Diagnostic [] The diagnostics associated with the line +--- @param line any #number The line number to display the +--- virtual text on +--- @param bufnr any #number The buffer to display the virtual +--- text in +--- @param opts any #table See {opts} from +--- |vim.lsp.diagnostic.set_virtual_text()| +--- @return any #table chunks, as defined by |nvim_buf_set_virtual_text()| +function vim.lsp.get_virtual_text_chunks_for_line(bufnr, line, line_diags, opts) end + +-- Move to the next diagnostic +--- @param opts any #table|nil Configuration table. Keys: +--- • {client_id}: (number) +--- • If nil, will consider all clients attached to +--- buffer. +--- +--- • {cursor_position}: (Position, default current +--- position) +--- • See |nvim_win_get_cursor()| +--- +--- • {wrap}: (boolean, default true) +--- • Whether to loop around file or not. Similar to +--- 'wrapscan' +--- +--- • {severity}: (DiagnosticSeverity) +--- • Exclusive severity to consider. Overrides +--- {severity_limit} +--- +--- • {severity_limit}: (DiagnosticSeverity) +--- • Limit severity of diagnostics found. E.g. +--- "Warning" means { "Error", "Warning" } will be +--- valid. +--- +--- • {enable_popup}: (boolean, default true) +--- • Call +--- |vim.lsp.diagnostic.show_line_diagnostics()| +--- on jump +--- +--- • {popup_opts}: (table) +--- • Table to pass as {opts} parameter to +--- |vim.lsp.diagnostic.show_line_diagnostics()| +--- +--- • {win_id}: (number, default 0) +--- • Window ID +function vim.lsp.goto_next(opts) end + +-- Move to the previous diagnostic +--- @param opts any #table See |vim.lsp.diagnostic.goto_next()| +function vim.lsp.goto_prev(opts) end + +-- Displays hover information about the symbol under the cursor +-- in a floating window. Calling the function twice will jump +-- into the floating window. +function vim.lsp.hover() end + +-- Lists all the implementations for the symbol under the cursor +-- in the quickfix window. +function vim.lsp.implementation() end + +-- Lists all the call sites of the symbol under the cursor in the +-- |quickfix| window. If the symbol can resolve to multiple +-- items, the user can pick one in the |inputlist|. +function vim.lsp.incoming_calls() end + +-- client_id → state +function vim.lsp.init(client, bufnr) end + +-- Jumps to a location. +--- @param location any #( `Location` | `LocationLink` ) +--- @return any #`true` if the jump succeeded +function vim.lsp.jump_to_location(location) end + +-- List workspace folders. +function vim.lsp.list_workspace_folders() end + +-- Returns the items with the byte position calculated correctly +-- and in sorted order, for display in quickfix and location +-- lists. +--- @param locations any #(table) list of `Location` s or +--- `LocationLink` s +--- @return any #(table) list of items +function vim.lsp.locations_to_items(locations) end + +-- Helper function to return nested values in language server +-- settings +--- @param section any #a string indicating the field of the settings +--- table +--- @param settings any #a table of language server settings +--- @return any #(table or string) The value of settings accessed via +--- section +function vim.lsp.lookup_section(settings, section) end + +-- Gets a new ClientCapabilities object describing the LSP client +-- capabilities. +function vim.lsp.make_client_capabilities() end + +-- Creates a table with sensible default options for a floating +-- window. The table can be passed to |nvim_open_win()|. +--- @param height any #(number) window height (in character cells) +--- @param width any #(number) window width (in character cells) +--- @param opts any #(table, optional) +--- @return any #(table) Options +function vim.lsp.make_floating_popup_options(width, height, opts) end + +-- Creates a `FormattingOptions` object for the current buffer +-- and cursor position. +--- @param options any #Table with valid `FormattingOptions` entries +--- @return any #`FormattingOptions object +function vim.lsp.make_formatting_params(options) end + +-- Using the given range in the current buffer, creates an object +-- that is similar to |vim.lsp.util.make_range_params()|. +--- @param start_pos any #({number, number}, optional) mark-indexed +--- position. Defaults to the start of the last +--- visual selection. +--- @param end_pos any #({number, number}, optional) mark-indexed +--- position. Defaults to the end of the last +--- visual selection. +--- @return any #{ textDocument = { uri = `current_file_uri` }, range = { +--- start = `start_position` , end = `end_position` } } +function vim.lsp.make_given_range_params(start_pos, end_pos) end + +-- Creates a `TextDocumentPositionParams` object for the current +-- buffer and cursor position. +--- @return any #`TextDocumentPositionParams` object +function vim.lsp.make_position_params() end + +-- Using the current position in the current buffer, creates an +-- object that can be used as a building block for several LSP +-- requests, such as `textDocument/codeAction` , +-- `textDocument/colorPresentation` , +-- `textDocument/rangeFormatting` . +--- @return any #{ textDocument = { uri = `current_file_uri` }, range = { +--- start = `current_position` , end = `current_position` } } +function vim.lsp.make_range_params() end + +-- Creates a `TextDocumentIdentifier` object for the current +-- buffer. +--- @return any #`TextDocumentIdentifier` +function vim.lsp.make_text_document_params() end + +-- Create the workspace params +--- @param removed any # +--- @param added any # +function vim.lsp.make_workspace_params(added, removed) end + +-- Sends a notification to the LSP server. +--- @param params any #(table): Parameters for the invoked LSP method --- @param method any #(string) The invoked LSP method ---- @param callback any #(function) Callback to invoke ---- @return any #(bool, number) `(true, message_id)` if request could be ---- sent, `false` if not -function vim.lsp.request(method, params, callback) end +--- @return any #(bool) `true` if notification could be sent, `false` if +--- not +function vim.lsp.notify(method, params) end --- Set virtual text given diagnostics ---- @param client_id any #number ---- @param bufnr any #number ---- @param opts any #table Options on how to display virtual ---- text. Keys: ---- • prefix (string): Prefix to display ---- before virtual text on line ---- • spacing (number): Number of spaces to ---- insert before virtual text ---- • severity_limit (DiagnosticSeverity): ---- • Limit severity of diagnostics found. ---- E.g. "Warning" means { "Error", ---- "Warning" } will be valid. ---- @param diagnostics any #Diagnostic [] ---- @param diagnostic_ns any #number -function vim.lsp.set_virtual_text(diagnostics, bufnr, client_id, diagnostic_ns, opts) end +-- |lsp-handler| for the method "textDocument/publishDiagnostics" +--- @param config any #table Configuration table. +--- • underline: (default=true) +--- • Apply underlines to diagnostics. +--- • See |vim.lsp.diagnostic.set_underline()| +--- +--- • virtual_text: (default=true) +--- • Apply virtual text to line endings. +--- • See |vim.lsp.diagnostic.set_virtual_text()| +--- +--- • signs: (default=true) +--- • Apply signs for diagnostics. +--- • See |vim.lsp.diagnostic.set_signs()| +--- +--- • update_in_insert: (default=false) +--- • Update diagnostics in InsertMode or wait +--- until InsertLeave +--- +--- • severity_sort: (default=false) +--- • Sort diagnostics (and thus signs and virtual +--- text) +function vim.lsp.on_publish_diagnostics(_, _, params, client_id, _, config) end + +-- Shows contents in a floating window. +--- @param contents any #table of lines to show in window +--- @param syntax any #string of syntax to set for opened buffer +--- @param opts any #dictionary with optional fields +--- @return any #bufnr,winnr buffer and window number of the newly created +--- floating preview window +function vim.lsp.open_floating_preview(contents, syntax, opts) end diff --git a/types/lsp.2.lua b/types/lsp.2.lua index 4e5ea2a..49aa614 100644 --- a/types/lsp.2.lua +++ b/types/lsp.2.lua @@ -1,85 +1,174 @@ --# selene: allow(unused_variable) ---@diagnostic disable: unused-local --- Removes document highlights from current buffer. -function vim.lsp.clear_references() end +-- Lists all the items that are called by the symbol under the +-- cursor in the |quickfix| window. If the symbol can resolve to +-- multiple items, the user can pick one in the |inputlist|. +function vim.lsp.outgoing_calls() end --- Get the diagnostics by line ---- @param opts any #table|nil Configuration keys ---- • severity: (DiagnosticSeverity, default nil) ---- • Only return diagnostics with this ---- severity. Overrides severity_limit ---- ---- • severity_limit: (DiagnosticSeverity, default nil) ---- • Limit severity of diagnostics found. E.g. ---- "Warning" means { "Error", "Warning" } ---- will be valid. ---- @param line_nr any #number The line number ---- @param client_id any #number the client id ---- @param bufnr any #number The buffer number ---- @return any #table Table with map of line number to list of ---- diagnostics. -function vim.lsp.get_line_diagnostics(bufnr, line_nr, opts, client_id) end +-- Parses snippets in a completion entry. +--- @param input any #(string) unparsed snippet +--- @return any #(string) parsed snippet +function vim.lsp.parse_snippet(input) end + +function vim.lsp.prepare(bufnr, firstline, new_lastline, changedtick) end + +-- Jump to new location (adjusting for UTF-16 encoding of +-- characters) +--- @param location any #a single `Location` or `LocationLink` +--- @return any #(bufnr,winnr) buffer and window number of floating window +--- or nil +function vim.lsp.preview_location(location) end + +function vim.lsp.progress_handler(_, _, params, client_id) end -- Performs |vim.lsp.buf.code_action()| for a given range. +--- @param start_pos any #({number, number}, optional) mark-indexed +--- position. Defaults to the start of the last +--- visual selection. --- @param context any #(table, optional) Valid `CodeActionContext` --- object --- @param end_pos any #({number, number}, optional) mark-indexed --- position. Defaults to the end of the last --- visual selection. +function vim.lsp.range_code_action(context, start_pos, end_pos) end + +-- Formats a given range. +--- @param options any #Table with valid `FormattingOptions` entries. --- @param start_pos any #({number, number}, optional) mark-indexed --- position. Defaults to the start of the last --- visual selection. -function vim.lsp.range_code_action(context, start_pos, end_pos) end +--- @param end_pos any #({number, number}, optional) mark-indexed +--- position. Defaults to the end of the last +--- visual selection. +function vim.lsp.range_formatting(options, start_pos, end_pos) end + +-- Lists all the references to the symbol under the cursor in the +-- quickfix window. +--- @param context any #(table) Context for the request +function vim.lsp.references(context) end + +-- Remove the folder at path from the workspace folders. If +-- {path} is not provided, the user will be prompted for a path +-- using |input()|. +function vim.lsp.remove_workspace_folder(workspace_folder) end + +-- Rename old_fname to new_fname. +--- @param opts any #(table) +function vim.lsp.rename(old_fname, new_fname, opts) end + +-- Sends a request to the LSP server and runs {callback} upon +-- response. +--- @param callback any #(function) Callback to invoke +--- @param params any #(table) Parameters for the invoked LSP method +--- @param method any #(string) The invoked LSP method +--- @return any #(bool, number) `(true, message_id)` if request could be +--- sent, `false` if not +function vim.lsp.request(method, params, callback) end + +-- Clear diagnotics and diagnostic cache +--- @param buffer_client_map any #table map of buffers to active +--- clients +--- @param client_id any #number +function vim.lsp.reset(client_id, buffer_client_map) end + +function vim.lsp.reset_buf(client, bufnr) end + +-- Creates a normalized object describing LSP server +-- capabilities. +function vim.lsp.resolve_capabilities(server_capabilities) end + +-- Save diagnostics to the current buffer. +--- @param diagnostics any #Diagnostic [] +--- @param bufnr any #number +--- @param client_id any #number +function vim.lsp.save(diagnostics, bufnr, client_id) end + +-- Checks whether the language servers attached to the current +-- buffer are ready. +--- @return any #`true` if server responds. +function vim.lsp.server_ready() end + +-- Sets the current log level. +--- @param level any #(string or number) One of `vim.lsp.log.levels` +function vim.lsp.set_level(level) end + +-- Replaces text in a range with new text. +--- @param lines any #(table) Original list of strings +--- @param new_lines any #A list of strings to replace the original +--- @param B any #(table) End position; a 2-tuple of {line, +--- col} numbers +--- @param A any #(table) Start position; a 2-tuple of {line, +--- col} numbers +--- @return any #(table) The modified {lines} object +function vim.lsp.set_lines(lines, A, B, new_lines) end + +-- Fills current window's location list with given list of items. +-- Can be obtained with e.g. |vim.lsp.util.locations_to_items()|. +--- @param items any #(table) list of items +function vim.lsp.set_loclist(items) end + +-- Fills quickfix list with given list of items. Can be obtained +-- with e.g. |vim.lsp.util.locations_to_items()|. +--- @param items any #(table) list of items +function vim.lsp.set_qflist(items) end + +-- Set signs for given diagnostics +--- @param diagnostics any #Diagnostic [] +--- @param bufnr any #number The buffer number +--- @param opts any #table Configuration for signs. Keys: +--- • priority: Set the priority of the signs. +--- • severity_limit (DiagnosticSeverity): +--- • Limit severity of diagnostics found. +--- E.g. "Warning" means { "Error", +--- "Warning" } will be valid. +--- @param sign_ns any #number|nil +--- @param client_id any #number the client id +function vim.lsp.set_signs(diagnostics, bufnr, client_id, sign_ns, opts) end -- Set underline for given diagnostics ---- @param client_id any #number: The client id +--- @param diagnostics any #Diagnostic [] --- @param bufnr any #number: The buffer number --- @param opts any #table: Configuration table: --- • severity_limit (DiagnosticSeverity): --- • Limit severity of diagnostics found. --- E.g. "Warning" means { "Error", --- "Warning" } will be valid. ---- @param diagnostics any #Diagnostic [] --- @param diagnostic_ns any #number|nil: The namespace +--- @param client_id any #number: The client id function vim.lsp.set_underline(diagnostics, bufnr, client_id, diagnostic_ns, opts) end --- Creates a normalized object describing LSP server --- capabilities. -function vim.lsp.resolve_capabilities(server_capabilities) end +-- Set virtual text given diagnostics +--- @param diagnostics any #Diagnostic [] +--- @param bufnr any #number +--- @param opts any #table Options on how to display virtual +--- text. Keys: +--- • prefix (string): Prefix to display +--- before virtual text on line +--- • spacing (number): Number of spaces to +--- insert before virtual text +--- • severity_limit (DiagnosticSeverity): +--- • Limit severity of diagnostics found. +--- E.g. "Warning" means { "Error", +--- "Warning" } will be valid. +--- @param diagnostic_ns any #number +--- @param client_id any #number +function vim.lsp.set_virtual_text(diagnostics, bufnr, client_id, diagnostic_ns, opts) end --- Using the current position in the current buffer, creates an --- object that can be used as a building block for several LSP --- requests, such as `textDocument/codeAction` , --- `textDocument/colorPresentation` , --- `textDocument/rangeFormatting` . ---- @return any #{ textDocument = { uri = `current_file_uri` }, range = { ---- start = `current_position` , end = `current_position` } } -function vim.lsp.make_range_params() end +-- Checks whether the level is sufficient for logging. +--- @param level any #number log level +--- @return any #(bool) true if would log, false if not +function vim.lsp.should_log(level) end --- Get the counts for a particular severity ---- @param severity any #DiagnosticSeverity ---- @param client_id any #number the client id +-- Open a floating window with the diagnostics from {line_nr} +--- @param opts any #table Configuration table +--- • show_header (boolean, default true): Show +--- "Diagnostics:" header. +--- @param line_nr any #number The line number --- @param bufnr any #number The buffer number -function vim.lsp.get_count(bufnr, severity, client_id) end - --- Default function to get text chunks to display using `nvim_buf_set_virtual_text` . ---- @param line_diags any #Diagnostic [] The diagnostics associated with the line ---- @param line any #number The line number to display the ---- virtual text on ---- @param opts any #table See {opts} from ---- |vim.lsp.diagnostic.set_virtual_text()| ---- @param bufnr any #number The buffer to display the virtual ---- text in ---- @return any #table chunks, as defined by |nvim_buf_set_virtual_text()| -function vim.lsp.get_virtual_text_chunks_for_line(bufnr, line, line_diags, opts) end - --- Sends a notification to the LSP server. ---- @param params any #(table): Parameters for the invoked LSP method ---- @param method any #(string) The invoked LSP method ---- @return any #(bool) `true` if notification could be sent, `false` if ---- not -function vim.lsp.notify(method, params) end +--- @param client_id any #number|nil the client id +--- @return any #table {popup_bufnr, win_id} +function vim.lsp.show_line_diagnostics(opts, bufnr, line_nr, client_id) end --- @param config any #table Configuration table. --- • border: (default=nil) @@ -87,129 +176,57 @@ function vim.lsp.notify(method, params) end --- • See |vim.api.nvim_open_win()| function vim.lsp.signature_help(_, method, result, _, bufnr, config) end --- Removes document highlights from a buffer. ---- @param bufnr any #buffer id -function vim.lsp.buf_clear_references(bufnr) end +-- Starts an LSP server process and create an LSP RPC client +-- object to interact with it. +--- @param cmd any #(string) Command to start the LSP +--- server. +--- @param dispatchers any #(table, optional) Dispatchers for +--- LSP message types. Valid dispatcher +--- names are: +--- • `"notification"` +--- • `"server_request"` +--- • `"on_error"` +--- • `"on_exit"` +--- @param extra_spawn_params any #(table, optional) Additional context +--- for the LSP server process. May +--- contain: +--- • {cwd} (string) Working directory +--- for the LSP server process +--- • {env} (table) Additional +--- environment variables for LSP +--- server process +--- @param cmd_args any #(table) List of additional string +--- arguments to pass to {cmd}. +--- @return any #Client RPC object. +function vim.lsp.start(cmd, cmd_args, dispatchers, extra_spawn_params) end -- Converts symbols to quickfix list items. --- @param symbols any #DocumentSymbol[] or SymbolInformation[] function vim.lsp.symbols_to_items(symbols, bufnr) end --- Process and return progress reports from lsp server. -function vim.lsp.get_progress_messages() end - --- Helper function to return nested values in language server --- settings ---- @param section any #a string indicating the field of the settings ---- table ---- @param settings any #a table of language server settings ---- @return any #(table or string) The value of settings accessed via ---- section -function vim.lsp.lookup_section(settings, section) end - --- Jumps to the declaration of the symbol under the cursor. --- Note: --- Many servers do not implement this method. Generally, see --- |vim.lsp.buf.definition()| instead. --- -function vim.lsp.declaration() end - --- Fills quickfix list with given list of items. Can be obtained --- with e.g. |vim.lsp.util.locations_to_items()|. ---- @param items any #(table) list of items -function vim.lsp.set_qflist(items) end - --- Jumps to the definition of the type of the symbol under the --- cursor. -function vim.lsp.type_definition() end - --- Return associated diagnostics for bufnr ---- @param client_id any #number|nil If nil, then return all of the ---- diagnostics. Else, return just the ---- diagnostics associated with the client_id. ---- @param bufnr any #number -function vim.lsp.get(bufnr, client_id) end - --- Fills current window's location list with given list of items. --- Can be obtained with e.g. |vim.lsp.util.locations_to_items()|. ---- @param items any #(table) list of items -function vim.lsp.set_loclist(items) end - --- Can be used to extract the completion items from a `textDocument/completion` request, which may return one of `CompletionItem[]` , `CompletionList` or null. ---- @param result any #(table) The result of a ---- `textDocument/completion` request ---- @return any #(table) List of completion items -function vim.lsp.extract_completion_items(result) end - --- Applies a `TextDocumentEdit` , which is a list of changes to a --- single document. ---- @param text_document_edit any #table: a `TextDocumentEdit` object ---- @param index any #number: Optional index of the edit, ---- if from a list of edits (or nil, if ---- not from a list) -function vim.lsp.apply_text_document_edit(text_document_edit, index) end - --- Applies a `WorkspaceEdit` . ---- @param workspace_edit any #(table) `WorkspaceEdit` -function vim.lsp.apply_workspace_edit(workspace_edit) end - --- Enters/leaves the focusable window associated with the current --- buffer via the. ---- @param unique_name any #(string) Window variable ---- @param fn fun(...) #(function) should return create a new ---- window and return a tuple of ---- ({focusable_buffer_id}, {window_id}). if ---- {focusable_buffer_id} is a valid buffer id, ---- the newly created window will be the new ---- focus associated with the current buffer ---- via the tag `unique_name` . ---- @return any #(pbufnr, pwinnr) if `fn()` has created a new window; nil ---- otherwise -function vim.lsp.focusable_float(unique_name, fn) end - --- Selects a code action from the input list that is available at --- the current cursor position. ---- @param context any #(table, optional) Valid `CodeActionContext` ---- object -function vim.lsp.code_action(context) end +-- Turns the result of a `textDocument/completion` request into +-- vim-compatible |complete-items|. +--- @param prefix any #(string) the prefix to filter the completion +--- items +--- @param result any #The result of a `textDocument/completion` call, +--- e.g. from |vim.lsp.buf.completion()|, which may +--- be one of `CompletionItem[]` , `CompletionList` +--- or `null` +--- @return any #{ matches = complete-items table, incomplete = bool } +function vim.lsp.text_document_completion_list_to_complete_items(result, prefix) end -- Removes empty lines from the beginning and end. --- @param lines any #(table) list of lines to trim --- @return any #(table) trimmed list of lines function vim.lsp.trim_empty_lines(lines) end --- Converts markdown into syntax highlighted regions by stripping --- the code blocks and converting them into highlighted code. --- This will by default insert a blank line separator after those --- code block regions to improve readability. The result is shown --- in a floating preview. ---- @param opts any #dictionary with optional fields ---- • height of floating window ---- • width of floating window ---- • wrap_at character to wrap at for computing ---- height ---- • max_width maximal width of floating window ---- • max_height maximal height of floating window ---- • pad_left number of columns to pad contents ---- at left ---- • pad_right number of columns to pad contents ---- at right ---- • pad_top number of lines to pad contents at ---- top ---- • pad_bottom number of lines to pad contents ---- at bottom ---- • separator insert separator after code block ---- @param contents any #table of lines to show in window ---- @return any #width,height size of float -function vim.lsp.fancy_floating_markdown(contents, opts) end +-- Accepts markdown lines and tries to reduce them to a filetype +-- if they comprise just a single code block. +--- @param lines any #(table) list of lines +--- @return any #(string) filetype or 'markdown' if it was unchanged. +function vim.lsp.try_trim_markdown_code_blocks(lines) end --- Creates autocommands to close a preview window when events --- happen. ---- @param events any #(table) list of events ---- @param winnr any #(number) window id of preview window -function vim.lsp.close_preview_autocmd(events, winnr) end - --- Executes an LSP server command. ---- @param command any #A valid `ExecuteCommandParams` object -function vim.lsp.execute_command(command) end +-- Jumps to the definition of the type of the symbol under the +-- cursor. +function vim.lsp.type_definition() end diff --git a/types/lsp.3.lua b/types/lsp.3.lua new file mode 100644 index 0000000..b009332 --- /dev/null +++ b/types/lsp.3.lua @@ -0,0 +1,8 @@ +--# selene: allow(unused_variable) +---@diagnostic disable: unused-local + +-- Lists all symbols in the current workspace in the quickfix +-- window. +--- @param query any #(string, optional) +function vim.lsp.workspace_symbol(query) end + diff --git a/types/lsp.lua b/types/lsp.lua index aca742f..8973b4a 100644 --- a/types/lsp.lua +++ b/types/lsp.lua @@ -1,33 +1,69 @@ --# selene: allow(unused_variable) ---@diagnostic disable: unused-local --- Jump to new location (adjusting for UTF-16 encoding of --- characters) ---- @param location any #a single `Location` or `LocationLink` ---- @return any #(bufnr,winnr) buffer and window number of floating window ---- or nil -function vim.lsp.preview_location(location) end +-- Add the folder at path to the workspace folders. If {path} is +-- not provided, the user will be prompted for a path using +-- |input()|. +function vim.lsp.add_workspace_folder(workspace_folder) end --- Flushes any outstanding change notification. -function vim.lsp.flush(client) end +-- Applies a `TextDocumentEdit` , which is a list of changes to a +-- single document. +--- @param text_document_edit any #table: a `TextDocumentEdit` object +--- @param index any #number: Optional index of the edit, +--- if from a list of edits (or nil, if +--- not from a list) +function vim.lsp.apply_text_document_edit(text_document_edit, index) end -function vim.lsp.delete_file(change) end +-- Applies a list of text edits to a buffer. +--- @param text_edits any #(table) list of `TextEdit` objects +--- @param buf_nr any #(number) Buffer id +function vim.lsp.apply_text_edits(text_edits, bufnr) end --- Clear diagnotics and diagnostic cache ---- @param client_id any #number ---- @param buffer_client_map any #table map of buffers to active ---- clients -function vim.lsp.reset(client_id, buffer_client_map) end +-- Applies a `WorkspaceEdit` . +--- @param workspace_edit any #(table) `WorkspaceEdit` +function vim.lsp.apply_workspace_edit(workspace_edit) end --- Jumps to a location. ---- @param location any #( `Location` | `LocationLink` ) ---- @return any #`true` if the jump succeeded -function vim.lsp.jump_to_location(location) end +-- Removes document highlights from a buffer. +--- @param bufnr any #buffer id +function vim.lsp.buf_clear_references(bufnr) end --- Create the workspace params ---- @param added any # ---- @param removed any # -function vim.lsp.make_workspace_params(added, removed) end +-- Shows a list of document highlights for a certain buffer. +--- @param bufnr any #buffer id +--- @param references any #List of `DocumentHighlight` objects to +--- highlight +function vim.lsp.buf_highlight_references(bufnr, references) end + +-- Returns the UTF-32 and UTF-16 offsets for a position in a +-- certain buffer. +--- @param row any #0-indexed line +--- @param col any #0-indexed byte offset in line +--- @param buf any #buffer id (0 for current) +--- @return any #(number, number) UTF-32 and UTF-16 index of the character +--- in line {row} column {col} in buffer {buf} +function vim.lsp.character_offset(buf, row, col) end + +-- Clears the currently displayed diagnostics +--- @param diagnostic_ns any #number|nil Associated diagnostic +--- namespace +--- @param sign_ns any #number|nil Associated sign namespace +--- @param bufnr any #number The buffer number +--- @param client_id any #number the client id +function vim.lsp.clear(bufnr, client_id, diagnostic_ns, sign_ns) end + +-- Removes document highlights from current buffer. +function vim.lsp.clear_references() end + +-- Creates autocommands to close a preview window when events +-- happen. +--- @param winnr any #(number) window id of preview window +--- @param events any #(table) list of events +function vim.lsp.close_preview_autocmd(events, winnr) end + +-- Selects a code action from the input list that is available at +-- the current cursor position. +--- @param context any #(table, optional) Valid `CodeActionContext` +--- object +function vim.lsp.code_action(context) end -- Retrieves the completion items at the current cursor position. -- Can only be called in Insert mode. @@ -38,11 +74,50 @@ function vim.lsp.make_workspace_params(added, removed) end --- applicable) function vim.lsp.completion(context) end --- Accepts markdown lines and tries to reduce them to a filetype --- if they comprise just a single code block. ---- @param lines any #(table) list of lines ---- @return any #(string) filetype or 'markdown' if it was unchanged. -function vim.lsp.try_trim_markdown_code_blocks(lines) end +-- Returns the range table for the difference between old and new +-- lines +--- @param old_lines any #table list of lines +--- @param offset_encoding any #string encoding requested by language +--- server +--- @param end_line_idx any #int line to begin search for last +--- difference +--- @param new_lines any #table list of lines +--- @param start_line_idx any #int line to begin search for first +--- difference +--- @return any #table start_line_idx and start_col_idx of range +function vim.lsp.compute_diff(old_lines, new_lines, start_line_idx, end_line_idx, offset_encoding) end + +-- Converts any of `MarkedString` | `MarkedString[]` | +-- `MarkupContent` into a list of lines containing valid +-- markdown. Useful to populate the hover window for +-- `textDocument/hover` , for parsing the result of +-- `textDocument/signatureHelp` , and potentially others. +--- @param contents any #(table, optional, default `{}` ) List of +--- strings to extend with converted lines +--- @param input any #( `MarkedString` | `MarkedString[]` | +--- `MarkupContent` ) +--- @return any #{contents}, extended with lines of converted markdown. +function vim.lsp.convert_input_to_markdown_lines(input, contents) end + +-- Converts `textDocument/SignatureHelp` response to markdown +-- lines. +--- @param signature_help any #Response of `textDocument/SignatureHelp` +--- @return any #list of lines of converted markdown. +function vim.lsp.convert_signature_help_to_markdown_lines(signature_help) end + +function vim.lsp.create_file(change) end + +-- Jumps to the declaration of the symbol under the cursor. +-- Note: +-- Many servers do not implement this method. Generally, see +-- |vim.lsp.buf.definition()| instead. +-- +function vim.lsp.declaration() end + +-- Jumps to the definition of the symbol under the cursor. +function vim.lsp.definition() end + +function vim.lsp.delete_file(change) end -- Send request to the server to resolve document highlights for -- the current text document position. This request can be @@ -50,76 +125,61 @@ function vim.lsp.try_trim_markdown_code_blocks(lines) end -- eg: function vim.lsp.document_highlight() end --- Creates a `FormattingOptions` object for the current buffer --- and cursor position. ---- @param options any #Table with valid `FormattingOptions` entries ---- @return any #`FormattingOptions object -function vim.lsp.make_formatting_params(options) end +-- Lists all symbols in the current buffer in the quickfix +-- window. +function vim.lsp.document_symbol() end --- Rename old_fname to new_fname. ---- @param opts any #(table) -function vim.lsp.rename(old_fname, new_fname, opts) end +-- Executes an LSP server command. +--- @param command any #A valid `ExecuteCommandParams` object +function vim.lsp.execute_command(command) end --- Constructs an error message from an LSP error object. ---- @param err any #(table) The error object ---- @return any #(string) The formatted error message -function vim.lsp.format_rpc_error(err) end +-- Can be used to extract the completion items from a `textDocument/completion` request, which may return one of `CompletionItem[]` , `CompletionList` or null. +--- @param result any #(table) The result of a +--- `textDocument/completion` request +--- @return any #(table) List of completion items +function vim.lsp.extract_completion_items(result) end -function vim.lsp.progress_handler(_, _, params, client_id) end +-- Converts markdown into syntax highlighted regions by stripping +-- the code blocks and converting them into highlighted code. +-- This will by default insert a blank line separator after those +-- code block regions to improve readability. The result is shown +-- in a floating preview. +--- @param contents any #table of lines to show in window +--- @param opts any #dictionary with optional fields +--- • height of floating window +--- • width of floating window +--- • wrap_at character to wrap at for computing +--- height +--- • max_width maximal width of floating window +--- • max_height maximal height of floating window +--- • pad_left number of columns to pad contents +--- at left +--- • pad_right number of columns to pad contents +--- at right +--- • pad_top number of lines to pad contents at +--- top +--- • pad_bottom number of lines to pad contents +--- at bottom +--- • separator insert separator after code block +--- @return any #width,height size of float +function vim.lsp.fancy_floating_markdown(contents, opts) end --- Lists all the references to the symbol under the cursor in the --- quickfix window. ---- @param context any #(table) Context for the request -function vim.lsp.references(context) end +-- Flushes any outstanding change notification. +function vim.lsp.flush(client) end --- Remove the folder at path from the workspace folders. If --- {path} is not provided, the user will be prompted for a path --- using |input()|. -function vim.lsp.remove_workspace_folder(workspace_folder) end - --- |lsp-handler| for the method "textDocument/publishDiagnostics" ---- @param config any #table Configuration table. ---- • underline: (default=true) ---- • Apply underlines to diagnostics. ---- • See |vim.lsp.diagnostic.set_underline()| ---- ---- • virtual_text: (default=true) ---- • Apply virtual text to line endings. ---- • See |vim.lsp.diagnostic.set_virtual_text()| ---- ---- • signs: (default=true) ---- • Apply signs for diagnostics. ---- • See |vim.lsp.diagnostic.set_signs()| ---- ---- • update_in_insert: (default=false) ---- • Update diagnostics in InsertMode or wait ---- until InsertLeave ---- ---- • severity_sort: (default=false) ---- • Sort diagnostics (and thus signs and virtual ---- text) -function vim.lsp.on_publish_diagnostics(_, _, params, client_id, _, config) end - -function vim.lsp.reset_buf(client, bufnr) end - -function vim.lsp.prepare(bufnr, firstline, new_lastline, changedtick) end - --- Creates a `TextDocumentPositionParams` object for the current --- buffer and cursor position. ---- @return any #`TextDocumentPositionParams` object -function vim.lsp.make_position_params() end - --- Using the given range in the current buffer, creates an object --- that is similar to |vim.lsp.util.make_range_params()|. ---- @param end_pos any #({number, number}, optional) mark-indexed ---- position. Defaults to the end of the last ---- visual selection. ---- @param start_pos any #({number, number}, optional) mark-indexed ---- position. Defaults to the start of the last ---- visual selection. ---- @return any #{ textDocument = { uri = `current_file_uri` }, range = { ---- start = `start_position` , end = `end_position` } } -function vim.lsp.make_given_range_params(start_pos, end_pos) end +-- Enters/leaves the focusable window associated with the current +-- buffer via the. +--- @param unique_name any #(string) Window variable +--- @param fn fun(...) #(function) should return create a new +--- window and return a tuple of +--- ({focusable_buffer_id}, {window_id}). if +--- {focusable_buffer_id} is a valid buffer id, +--- the newly created window will be the new +--- focus associated with the current buffer +--- via the tag `unique_name` . +--- @return any #(pbufnr, pwinnr) if `fn()` has created a new window; nil +--- otherwise +function vim.lsp.focusable_float(unique_name, fn) end -- Focuses/unfocuses the floating preview window associated with -- the current buffer via the window variable `unique_name` . If @@ -132,122 +192,40 @@ function vim.lsp.make_given_range_params(start_pos, end_pos) end --- be created function vim.lsp.focusable_preview(unique_name, fn) end -function vim.lsp.create_file(change) end +-- Constructs an error message from an LSP error object. +--- @param err any #(table) The error object +--- @return any #(string) The formatted error message +function vim.lsp.format_rpc_error(err) end --- Lists all symbols in the current workspace in the quickfix --- window. ---- @param query any #(string, optional) -function vim.lsp.workspace_symbol(query) end +-- Formats the current buffer. +--- @param options any #(optional, table) Can be used to specify +--- FormattingOptions. Some unspecified options +--- will be automatically derived from the current +--- Neovim options. +function vim.lsp.formatting(options) end --- Sets the current log level. ---- @param level any #(string or number) One of `vim.lsp.log.levels` -function vim.lsp.set_level(level) end +-- Formats the current buffer by sequentially requesting +-- formatting from attached clients. +--- @param options any #(optional, table) `FormattingOptions` +--- entries +--- @param order any #(optional, table) List of client names. +--- Formatting is requested from clients in the +--- following order: first all clients that are +--- not in the `order` list, then the remaining +--- clients in the order as they occur in the +--- `order` list. +--- @param timeout_ms any #(optional, number) Request timeout +function vim.lsp.formatting_seq_sync(options, timeout_ms, order) end --- Lists all the implementations for the symbol under the cursor --- in the quickfix window. -function vim.lsp.implementation() end +-- Performs |vim.lsp.buf.formatting()| synchronously. +--- @param timeout_ms any #(number) Request timeout +--- @param options any #Table with valid `FormattingOptions` entries +function vim.lsp.formatting_sync(options, timeout_ms) end --- Returns the log filename. ---- @return any #(string) log filename -function vim.lsp.get_filename() end - --- Checks whether the level is sufficient for logging. ---- @param level any #number log level ---- @return any #(bool) true if would log, false if not -function vim.lsp.should_log(level) end - --- Replaces text in a range with new text. ---- @param A any #(table) Start position; a 2-tuple of {line, ---- col} numbers ---- @param lines any #(table) Original list of strings ---- @param B any #(table) End position; a 2-tuple of {line, ---- col} numbers ---- @param new_lines any #A list of strings to replace the original ---- @return any #(table) The modified {lines} object -function vim.lsp.set_lines(lines, A, B, new_lines) end - --- Starts an LSP server process and create an LSP RPC client --- object to interact with it. ---- @param extra_spawn_params any #(table, optional) Additional context ---- for the LSP server process. May ---- contain: ---- • {cwd} (string) Working directory ---- for the LSP server process ---- • {env} (table) Additional ---- environment variables for LSP ---- server process ---- @param cmd any #(string) Command to start the LSP ---- server. ---- @param cmd_args any #(table) List of additional string ---- arguments to pass to {cmd}. ---- @param dispatchers any #(table, optional) Dispatchers for ---- LSP message types. Valid dispatcher ---- names are: ---- • `"notification"` ---- • `"server_request"` ---- • `"on_error"` ---- • `"on_exit"` ---- @return any #Client RPC object. -function vim.lsp.start(cmd, cmd_args, dispatchers, extra_spawn_params) end - --- Save diagnostics to the current buffer. ---- @param client_id any #number ---- @param diagnostics any #Diagnostic [] +-- Return associated diagnostics for bufnr --- @param bufnr any #number -function vim.lsp.save(diagnostics, bufnr, client_id) end - --- Checks whether the language servers attached to the current --- buffer are ready. ---- @return any #`true` if server responds. -function vim.lsp.server_ready() end - --- Returns visual width of tabstop. ---- @param bufnr any #(optional, number): Buffer handle, defaults to ---- current ---- @return any #(number) tabstop visual width -function vim.lsp.get_effective_tabstop(bufnr) end - --- Move to the next diagnostic ---- @param opts any #table|nil Configuration table. Keys: ---- • {client_id}: (number) ---- • If nil, will consider all clients attached to ---- buffer. ---- ---- • {cursor_position}: (Position, default current ---- position) ---- • See |nvim_win_get_cursor()| ---- ---- • {wrap}: (boolean, default true) ---- • Whether to loop around file or not. Similar to ---- 'wrapscan' ---- ---- • {severity}: (DiagnosticSeverity) ---- • Exclusive severity to consider. Overrides ---- {severity_limit} ---- ---- • {severity_limit}: (DiagnosticSeverity) ---- • Limit severity of diagnostics found. E.g. ---- "Warning" means { "Error", "Warning" } will be ---- valid. ---- ---- • {enable_popup}: (boolean, default true) ---- • Call ---- |vim.lsp.diagnostic.show_line_diagnostics()| ---- on jump ---- ---- • {popup_opts}: (table) ---- • Table to pass as {opts} parameter to ---- |vim.lsp.diagnostic.show_line_diagnostics()| ---- ---- • {win_id}: (number, default 0) ---- • Window ID -function vim.lsp.goto_next(opts) end - --- Creates a table with sensible default options for a floating --- window. The table can be passed to |nvim_open_win()|. ---- @param width any #(number) window width (in character cells) ---- @param opts any #(table, optional) ---- @param height any #(number) window height (in character cells) ---- @return any #(table) Options -function vim.lsp.make_floating_popup_options(width, height, opts) end +--- @param client_id any #number|nil If nil, then return all of the +--- diagnostics. Else, return just the +--- diagnostics associated with the client_id. +function vim.lsp.get(bufnr, client_id) end diff --git a/types/lua.lua b/types/lua.lua index 7ac39cf..8882da0 100644 --- a/types/lua.lua +++ b/types/lua.lua @@ -1,15 +1,15 @@ --# selene: allow(unused_variable) ---@diagnostic disable: unused-local -function vim.pcall_ret(status, ...) end - function vim.getenv(k) end +function vim.insert_keys(obj) end + +function vim.is_valid(opt) end + function vim.make_meta_accessor(get, set, del) end function vim.nil_wrap(fn) end -function vim.is_valid(opt) end - -function vim.insert_keys(obj) end +function vim.pcall_ret(status, ...) end diff --git a/types/treesitter.lua b/types/treesitter.lua index 3773047..f98964c 100644 --- a/types/treesitter.lua +++ b/types/treesitter.lua @@ -4,57 +4,20 @@ --- @class vim.treesitter.LanguageTree vim.treesitter.LanguageTree = {} --- Invokes the callback for each treesitter trees recursively. ---- @param fn fun(...) #The callback to invoke. The callback is invoked ---- with arguments (tree: TSTree, languageTree: ---- LanguageTree) -function vim.treesitter.LanguageTree:for_each_tree(fn) end +-- Adds a child language to this tree. +--- @param lang any #The language to add. +function vim.treesitter.LanguageTree:add_child(lang) end --- Determines whether this tree is valid. If the tree is invalid, `parse()` must be called to get the an updated tree. -function vim.treesitter.LanguageTree:is_valid() end +-- Returns a map of language to child tree. +function vim.treesitter.LanguageTree:children() end ---- @class vim.treesitter.Query -vim.treesitter.Query = {} +-- Determines wether This goes down the tree to recursively check childs. +--- @param range any #A range, that is a `{ start_line, start_col, +--- end_line, end_col }` table. +function vim.treesitter.LanguageTree:contains(range) end --- Iterate over all captures from all matches inside {node} ---- @param node any #The node under which the search will occur ---- @param source any #The source buffer or string to exctract text ---- from ---- @param stop any #The stopping line of the search (end-exclusive) ---- @param start any #The starting line of the search ---- @return any #The matching capture id -function vim.treesitter.Query:iter_captures(node, source, start, stop) end - --- Removes a child language from this tree. ---- @param lang any #The language to remove. -function vim.treesitter.LanguageTree:remove_child(lang) end - --- Gets the language of this tree node. -function vim.treesitter.LanguageTree:lang() end - --- Gets the appropriate language that contains ---- @param range any #A text range, see |LanguageTree:contains| -function vim.treesitter.LanguageTree:language_for_range(range) end - --- Registers callbacks for the parser ---- @param cbs any #An `nvim_buf_attach` -like table argument with the following keys : `on_bytes` : see `nvim_buf_attach` , but this will be called after the parsers callback. `on_changedtree` : a callback that will be called every time the ---- tree has syntactical changes. it will only be ---- passed one argument, that is a table of the ranges ---- (as node ranges) that changed. `on_child_added` : emitted when a child is added to the tree. `on_child_removed` : emitted when a child is removed from the tree. -function vim.treesitter.LanguageTree:register_cbs(cbs) end - --- Parses all defined regions using a treesitter parser for the --- language this tree represents. This will run the injection --- query for this language to determine if any child languages --- should be created. -function vim.treesitter.LanguageTree:parse() end - ---- @class vim.treesitter.TSHighlighter -vim.treesitter.TSHighlighter = {} - --- Gets the query used for ---- @param lang any #A language used by the highlighter. -function vim.treesitter.TSHighlighter:get_query(lang) end +-- Destroys this language tree and all its children. +function vim.treesitter.LanguageTree:destroy() end -- Invokes the callback for each LanguageTree and it's children -- recursively @@ -65,12 +28,44 @@ function vim.treesitter.TSHighlighter:get_query(lang) end --- string) function vim.treesitter.LanguageTree:for_each_child(fn, include_self) end --- Adds a child language to this tree. ---- @param lang any #The language to add. -function vim.treesitter.LanguageTree:add_child(lang) end +-- Invokes the callback for each treesitter trees recursively. +--- @param fn fun(...) #The callback to invoke. The callback is invoked +--- with arguments (tree: TSTree, languageTree: +--- LanguageTree) +function vim.treesitter.LanguageTree:for_each_tree(fn) end --- Removes all internal references to the highlighter -function vim.treesitter.TSHighlighter:destroy() end +-- Gets the set of included regions +function vim.treesitter.LanguageTree:included_regions() end + +-- Invalidates this parser and all its children +function vim.treesitter.LanguageTree:invalidate(reload) end + +-- Determines whether this tree is valid. If the tree is invalid, `parse()` must be called to get the an updated tree. +function vim.treesitter.LanguageTree:is_valid() end + +-- Gets the language of this tree node. +function vim.treesitter.LanguageTree:lang() end + +-- Gets the appropriate language that contains +--- @param range any #A text range, see |LanguageTree:contains| +function vim.treesitter.LanguageTree:language_for_range(range) end + +-- Parses all defined regions using a treesitter parser for the +-- language this tree represents. This will run the injection +-- query for this language to determine if any child languages +-- should be created. +function vim.treesitter.LanguageTree:parse() end + +-- Registers callbacks for the parser +--- @param cbs any #An `nvim_buf_attach` -like table argument with the following keys : `on_bytes` : see `nvim_buf_attach` , but this will be called after the parsers callback. `on_changedtree` : a callback that will be called every time the +--- tree has syntactical changes. it will only be +--- passed one argument, that is a table of the ranges +--- (as node ranges) that changed. `on_child_added` : emitted when a child is added to the tree. `on_child_removed` : emitted when a child is removed from the tree. +function vim.treesitter.LanguageTree:register_cbs(cbs) end + +-- Removes a child language from this tree. +--- @param lang any #The language to remove. +function vim.treesitter.LanguageTree:remove_child(lang) end -- Sets the included regions that should be parsed by this -- parser. A region is a set of nodes and/or ranges that will be @@ -79,42 +74,47 @@ function vim.treesitter.TSHighlighter:destroy() end --- parse. function vim.treesitter.LanguageTree:set_included_regions(regions) end --- Gets the set of included regions -function vim.treesitter.LanguageTree:included_regions() end +-- Returns the source content of the language tree (bufnr or +-- string). +function vim.treesitter.LanguageTree:source() end -- Returns all trees this language tree contains. Does not -- include child languages. function vim.treesitter.LanguageTree:trees() end --- Iterates the matches of self on a given range. ---- @param node any #The node under which the search will occur ---- @param source any #The source buffer or string to search +--- @class vim.treesitter.Query +vim.treesitter.Query = {} + +-- Iterate over all captures from all matches inside {node} --- @param stop any #The stopping line of the search (end-exclusive) --- @param start any #The starting line of the search +--- @param node any #The node under which the search will occur +--- @param source any #The source buffer or string to exctract text +--- from +--- @return any #The matching capture id +function vim.treesitter.Query:iter_captures(node, source, start, stop) end + +-- Iterates the matches of self on a given range. +--- @param stop any #The stopping line of the search (end-exclusive) +--- @param start any #The starting line of the search +--- @param node any #The node under which the search will occur +--- @param source any #The source buffer or string to search --- @return any #The matching pattern id function vim.treesitter.Query:iter_matches(node, source, start, stop) end --- Determines wether This goes down the tree to recursively check childs. ---- @param range any #A range, that is a `{ start_line, start_col, ---- end_line, end_col }` table. -function vim.treesitter.LanguageTree:contains(range) end +--- @class vim.treesitter.TSHighlighter +vim.treesitter.TSHighlighter = {} --- Destroys this language tree and all its children. -function vim.treesitter.LanguageTree:destroy() end +-- Removes all internal references to the highlighter +function vim.treesitter.TSHighlighter:destroy() end --- Invalidates this parser and all its children -function vim.treesitter.LanguageTree:invalidate(reload) end +-- Gets the query used for +--- @param lang any #A language used by the highlighter. +function vim.treesitter.TSHighlighter:get_query(lang) end -- Performs a healthcheck for treesitter integration. function vim.treesitter.check_health() end --- Returns a map of language to child tree. -function vim.treesitter.LanguageTree:children() end - --- Returns the source content of the language tree (bufnr or --- string). -function vim.treesitter.LanguageTree:source() end - -- Lists the parsers currently installed --- @return any #A list of parsers function vim.treesitter.list_parsers() end @@ -122,14 +122,14 @@ function vim.treesitter.list_parsers() end -- Represents a single treesitter parser for a language. The -- language can contain child languages with in its range, hence -- the tree. ---- @param lang any #The language this tree represents +--- @param opts any #Options table --- @param opts.injections any #A table of language to injection query --- strings. This is useful for overriding --- the built-in runtime file searching for --- the injection language query per --- language. +--- @param lang any #The language this tree represents --- @param source any #Can be a bufnr or a string of text to --- parse ---- @param opts any #Options table function vim.treesitter.new(source, lang, opts) end