aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/api.txt24
-rw-r--r--runtime/doc/change.txt8
-rw-r--r--runtime/doc/index.txt2
-rw-r--r--runtime/doc/lsp.txt166
-rw-r--r--runtime/doc/lua.txt112
-rw-r--r--runtime/lua/vim/lsp/util.lua67
6 files changed, 271 insertions, 108 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 0d85d6b539..fe69d9076f 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -993,7 +993,7 @@ nvim_get_option_info({name}) *nvim_get_option_info()*
Resulting dictionary has keys:
• name: Name of the option (like 'filetype')
• shortname: Shortened name of the option (like 'ft')
- • type: type of option ("string", "integer" or "boolean")
+ • type: type of option ("string", "number" or "boolean")
• default: The default value for the option
• was_set: Whether the option was set.
• last_set_sid: Last set script id (if any)
@@ -1299,6 +1299,17 @@ nvim_open_win({buffer}, {enter}, {config}) *nvim_open_win()*
an external top-level window. Currently
accepts no other positioning configuration
together with this.
+ • `zindex`: Stacking order. floats with higher`zindex`go on top on floats with lower indices. Must
+ be larger than zero. The following screen
+ elements have hard-coded z-indices:
+ • 100: insert completion popupmenu
+ • 200: message scrollback
+ • 250: cmdline completion popupmenu (when
+ wildoptions+=pum) The default value for
+ floats are 50. In general, values below 100
+ are recommended, unless there is a good
+ reason to overshadow builtin elements.
+
• `style`: Configure the appearance of the window.
Currently only takes one non-empty value:
• "minimal" Nvim will display the window with
@@ -1705,6 +1716,12 @@ nvim_set_hl({ns_id}, {name}, {val}) *nvim_set_hl()*
|nvim_get_hl_by_name|. in addition the following
keys are also recognized: `default` : don't
override existing definition, like `hi default`
+ `ctermfg` : sets foreground of cterm color
+ `ctermbg` : sets background of cterm color
+ `cterm` : cterm attribute map. sets attributed
+ for cterm colors. similer to `hi cterm` Note: by
+ default cterm attributes are same as attributes
+ of gui color
nvim_set_keymap({mode}, {lhs}, {rhs}, {opts}) *nvim_set_keymap()*
Sets a global |mapping| for the given mode.
@@ -2269,7 +2286,12 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {opts})
• "overlay": display over the specified
column, without shifting the underlying
text.
+ • "right_align": display right aligned in the
+ window.
+ • virt_text_win_col : position the virtual text
+ at a fixed window column (starting from the
+ first text column)
• virt_text_hide : hide the virtual text when
the background text is selected or hidden due
to horizontal scroll 'nowrap'
diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt
index b2e910a834..924401be74 100644
--- a/runtime/doc/change.txt
+++ b/runtime/doc/change.txt
@@ -1091,6 +1091,11 @@ inside of strings can change! Also see 'softtabstop' option. >
Using the mouse only works when 'mouse' contains 'n'
or 'a'.
+["x]zp or *zp* *zP*
+["x]zP Like "p" and "P", except without adding trailing spaces
+ when pasting a block. Thus the inserted text will not
+ always be a rectangle.
+
You can use these commands to copy text from one place to another. Do this
by first getting the text into a register with a yank, delete or change
command, then inserting the register contents with a put command. You can
@@ -1130,6 +1135,9 @@ a register, a paste on a visual selected area will paste that single line on
each of the selected lines (thus replacing the blockwise selected region by a
block of the pasted line).
+Use |zP|/|zp| to paste a blockwise yanked register without appending trailing
+spaces.
+
*blockwise-register*
If you use a blockwise Visual mode command to get the text into the register,
the block of text will be inserted before ("P") or after ("p") the cursor
diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt
index e7d891bc33..17258f896d 100644
--- a/runtime/doc/index.txt
+++ b/runtime/doc/index.txt
@@ -851,6 +851,8 @@ tag char note action in Normal mode ~
|zm| zm subtract one from 'foldlevel'
|zn| zn reset 'foldenable'
|zo| zo open fold
+|zp| zp paste in block-mode without trailing spaces
+|zP| zP paste in block-mode without trailing spaces
|zr| zr add one to 'foldlevel'
|zs| zs when 'wrap' off scroll horizontally to
position the cursor at the start (left
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index 5c2ee568c5..d5e8db4dd7 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -619,15 +619,15 @@ buf_request_sync({bufnr}, {method}, {params}, {timeout_ms})
Calls |vim.lsp.buf_request_all()| but blocks Nvim while
awaiting the result. Parameters are the same as
|vim.lsp.buf_request()| but the return result is different.
- Wait maximum of {timeout_ms} (default 100) ms.
+ Wait maximum of {timeout_ms} (default 1000) ms.
Parameters: ~
{bufnr} (number) Buffer handle, or 0 for current.
{method} (string) LSP method name
{params} (optional, table) Parameters to send to the
server
- {timeout_ms} (optional, number, default=100) Maximum time
- in milliseconds to wait for a result.
+ {timeout_ms} (optional, number, default=1000) Maximum
+ time in milliseconds to wait for a result.
Return: ~
Map of client_id:request_result. On timeout, cancel or
@@ -651,6 +651,14 @@ client() *vim.lsp.client*
{status} is `true` , the function returns {request_id} as
the second result. You can use this with
`client.cancel_request(request_id)` to cancel the request.
+ • request_sync(method, params, timeout_ms, bufnr) Sends a
+ request to the server and synchronously waits for the
+ response. This is a wrapper around {client.request}
+ Returns: { err=err, result=result }, a dictionary, where
+ `err` and `result` come from the |lsp-handler|. On
+ timeout, cancel or error, returns `(nil, err)` where `err`
+ is a string describing the failure reason. If the request
+ was unsuccessful returns `nil` .
• notify(method, params) Sends a notification to an LSP
server. Returns: a boolean to indicate if the notification
was successful. If it is false, then it will always be
@@ -939,6 +947,9 @@ add_workspace_folder({workspace_folder})
not provided, the user will be prompted for a path using
|input()|.
+call_hierarchy({method}) *vim.lsp.buf.call_hierarchy()*
+ TODO: Documentation
+
clear_references() *vim.lsp.buf.clear_references()*
Removes document highlights from current buffer.
@@ -1017,6 +1028,32 @@ formatting({options}) *vim.lsp.buf.formatting()*
See also: ~
https://microsoft.github.io/language-server-protocol/specification#textDocument_formatting
+ *vim.lsp.buf.formatting_seq_sync()*
+formatting_seq_sync({options}, {timeout_ms}, {order})
+ Formats the current buffer by sequentially requesting
+ formatting from attached clients.
+
+ Useful when multiple clients with formatting capability are
+ attached.
+
+ Since it's synchronous, can be used for running on save, to
+ make sure buffer is formatted prior to being saved.
+ {timeout_ms} is passed on to the |vim.lsp.client| `request_sync` method. Example: >
+
+ vim.api.nvim_command[[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()]]
+<
+
+ Parameters: ~
+ {options} (optional, table) `FormattingOptions`
+ entries
+ {timeout_ms} (optional, number) Request timeout
+ {order} (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.
+
*vim.lsp.buf.formatting_sync()*
formatting_sync({options}, {timeout_ms})
Performs |vim.lsp.buf.formatting()| synchronously.
@@ -1033,6 +1070,9 @@ formatting_sync({options}, {timeout_ms})
{options} Table with valid `FormattingOptions` entries
{timeout_ms} (number) Request timeout
+ See also: ~
+ |vim.lsp.buf.formatting_seq_sync|
+
hover() *vim.lsp.buf.hover()*
Displays hover information about the symbol under the cursor
in a floating window. Calling the function twice will jump
@@ -1585,6 +1625,9 @@ buf_highlight_references({bufnr}, {references})
{references} List of `DocumentHighlight` objects to
highlight
+buf_lines({bufnr}) *vim.lsp.util.buf_lines()*
+ TODO: Documentation
+
character_offset({buf}, {row}, {col}) *vim.lsp.util.character_offset()*
Returns the UTF-32 and UTF-16 offsets for a position in a
certain buffer.
@@ -1650,12 +1693,15 @@ convert_input_to_markdown_lines({input}, {contents})
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_hover
*vim.lsp.util.convert_signature_help_to_markdown_lines()*
-convert_signature_help_to_markdown_lines({signature_help})
+convert_signature_help_to_markdown_lines({signature_help}, {ft})
Converts `textDocument/SignatureHelp` response to markdown
lines.
Parameters: ~
{signature_help} Response of `textDocument/SignatureHelp`
+ {ft} optional filetype that will be use as
+ the `lang` for the label markdown code
+ block
Return: ~
list of lines of converted markdown.
@@ -1683,65 +1729,6 @@ extract_completion_items({result})
See also: ~
https://microsoft.github.io/language-server-protocol/specification#textDocument_completion
- *vim.lsp.util.fancy_floating_markdown()*
-fancy_floating_markdown({contents}, {opts})
- 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.
-
- Parameters: ~
- {contents} table of lines to show in window
- {opts} 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: ~
- width,height size of float
-
-focusable_float({unique_name}, {fn}) *vim.lsp.util.focusable_float()*
- Parameters: ~
- {unique_name} (string) Window variable
- {fn} (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: ~
- (pbufnr, pwinnr) if `fn()` has created a new window; nil
- otherwise
-
- *vim.lsp.util.focusable_preview()*
-focusable_preview({unique_name}, {fn})
- Focuses/unfocuses the floating preview window associated with
- the current buffer via the window variable `unique_name` . If
- no such preview window exists, makes a new one.
-
- Parameters: ~
- {unique_name} (string) Window variable
- {fn} (function) The return values of this
- function will be passed directly to
- |vim.lsp.util.open_floating_preview()|, in
- the case that a new floating window should
- be created
-
get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()*
Returns visual width of tabstop.
@@ -1755,6 +1742,22 @@ get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()*
See also: ~
|softtabstop|
+get_line({uri}, {row}) *vim.lsp.util.get_line()*
+ Parameters: ~
+ {uri} string uri of the resource to get the line from
+ {row} number zero-indexed line number
+
+ Return: ~
+ string the line at row in filename
+
+get_lines({uri}, {rows}) *vim.lsp.util.get_lines()*
+ Parameters: ~
+ {uri} string uri of the resource to get the lines from
+ {rows} number[] zero-indexed line numbers
+
+ Return: ~
+ table<number string> a table mapping rows to lines
+
get_progress_messages() *vim.lsp.util.get_progress_messages()*
TODO: Documentation
@@ -1897,7 +1900,7 @@ parse_snippet({input}) *vim.lsp.util.parse_snippet()*
Return: ~
(string) parsed snippet
-preview_location({location}) *vim.lsp.util.preview_location()*
+preview_location({location}, {opts}) *vim.lsp.util.preview_location()*
Previews a location in a floating window
behavior depends on type of location:
@@ -1946,6 +1949,41 @@ set_qflist({items}) *vim.lsp.util.set_qflist()*
Parameters: ~
{items} (table) list of items
+ *vim.lsp.util.stylize_markdown()*
+stylize_markdown({bufnr}, {contents}, {opts})
+ 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.
+
+ This method configures the given buffer and returns the lines
+ to set.
+
+ If you want to open a popup with fancy markdown, use
+ `open_floating_preview` instead
+
+ Parameters: ~
+ {contents} table of lines to show in window
+ {opts} 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: ~
+ width,height size of float
+
symbols_to_items({symbols}, {bufnr}) *vim.lsp.util.symbols_to_items()*
Converts symbols to quickfix list items.
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index c3893d05c0..05404a2e35 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -650,42 +650,6 @@ vim.empty_dict() *vim.empty_dict()*
Note: if numeric keys are added to the table, the metatable will be
ignored and the dict converted to a list/array anyway.
-vim.region({bufnr}, {pos1}, {pos2}, {type}, {inclusive}) *vim.region()*
- Converts a selection specified by the buffer ({bufnr}), starting
- position ({pos1}, a zero-indexed pair `{line1,column1}`), ending
- position ({pos2}, same format as {pos1}), the type of the register
- for the selection ({type}, see |regtype|), and a boolean indicating
- whether the selection is inclusive or not, into a zero-indexed table
- of linewise selections of the form `{linenr = {startcol, endcol}}` .
-
- *vim.register_keystroke_callback()*
-vim.register_keystroke_callback({fn}, {ns_id})
- Register a lua {fn} with an {ns_id} to be run after every keystroke.
-
- Parameters: ~
- {fn}: (function): Function to call on keystroke.
- It should take one argument, which is a string.
- The string will contain the literal keys typed.
- See |i_CTRL-V|
-
- If {fn} is `nil`, it removes the callback for the
- associated {ns_id}.
-
- {ns_id}: (number) Namespace ID. If not passed or 0, will generate
- and return a new namespace ID from |nvim_create_namespace()|
-
- Return: ~
- (number) Namespace ID associated with {fn}
-
- NOTE: {fn} will be automatically removed if an error occurs while
- calling. This is to prevent the annoying situation of every keystroke
- erroring while trying to remove a broken callback.
-
- NOTE: {fn} will receive the keystrokes after mappings have been
- evaluated
-
- NOTE: {fn} will *NOT* be cleared from |nvim_buf_clear_namespace()|
-
vim.rpcnotify({channel}, {method}[, {args}...]) *vim.rpcnotify()*
Sends {event} to {channel} via |RPC| and returns immediately.
If {channel} is 0, the event is broadcast to all channels.
@@ -1118,6 +1082,23 @@ vim.wo *vim.wo*
==============================================================================
Lua module: vim *lua-vim*
+defer_fn({fn}, {timeout}) *vim.defer_fn()*
+ Defers calling `fn` until `timeout` ms passes.
+
+ Use to do a one-shot timer that calls `fn` Note: The {fn} is |schedule_wrap|ped automatically, so API
+ functions are safe to call.
+
+ Parameters: ~
+ {fn} Callback to call once `timeout` expires
+ {timeout} Number of milliseconds to wait before calling
+ `fn`
+
+ Return: ~
+ timer luv timer object
+
+insert_keys({obj}) *vim.insert_keys()*
+ TODO: Documentation
+
inspect({object}, {options}) *vim.inspect()*
Return a human-readable representation of the given object.
@@ -1125,9 +1106,19 @@ inspect({object}, {options}) *vim.inspect()*
https://github.com/kikito/inspect.lua
https://github.com/mpeterv/vinspect
-make_meta_accessor({get}, {set}, {del}) *vim.make_meta_accessor()*
+make_dict_accessor({scope}) *vim.make_dict_accessor()*
TODO: Documentation
+notify({msg}, {log_level}, {_opts}) *vim.notify()*
+ Notification provider without a runtime, writes to :Messages
+
+ Parameters: ~
+ {msg} Content of the notification to show to the
+ user
+ {log_level} Optional log level
+ {opts} Dictionary with optional options (timeout,
+ etc)
+
paste({lines}, {phase}) *vim.paste()*
Paste handler, invoked by |nvim_paste()| when a conforming UI
(such as the |TUI|) pastes text into the editor.
@@ -1160,6 +1151,53 @@ paste({lines}, {phase}) *vim.paste()*
See also: ~
|paste|
+region({bufnr}, {pos1}, {pos2}, {regtype}, {inclusive}) *vim.region()*
+ Get a table of lines with start, end columns for a region
+ marked by two points
+
+ Parameters: ~
+ {bufnr} number of buffer
+ {pos1} (line, column) tuple marking beginning of
+ region
+ {pos2} (line, column) tuple marking end of region
+ {regtype} type of selection (:help setreg)
+ {inclusive} boolean indicating whether the selection is
+ end-inclusive
+
+ Return: ~
+ region lua table of the form {linenr = {startcol,endcol}}
+
+ *vim.register_keystroke_callback()*
+register_keystroke_callback({fn}, {ns_id})
+ Register a lua {fn} with an {id} to be run after every
+ keystroke.
+
+ If {fn} is nil, it removes the callback for the associated
+ {ns_id}
+ Note:
+ {fn} will not be cleared from |nvim_buf_clear_namespace()|
+
+ Note:
+ {fn} will receive the keystrokes after mappings have been
+ evaluated
+
+ Parameters: ~
+ {fn} function: Function to call. It should take one
+ argument, which is a string. The string will contain
+ the literal keys typed. See |i_CTRL-V|
+ {ns_id} number? Namespace ID. If not passed or 0, will
+ generate and return a new namespace ID from
+ |nvim_create_namesapce()|
+
+ Return: ~
+ number Namespace ID associated with {fn}
+
+ Note:
+ {fn} will be automatically removed if an error occurs
+ while calling. This is to prevent the annoying situation
+ of every keystroke erroring while trying to remove a
+ broken callback.
+
schedule_wrap({cb}) *vim.schedule_wrap()*
Defers callback `cb` until the Nvim API is safe to call.
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index a7b43cfa6b..0fa6518c0b 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1462,12 +1462,33 @@ end)
--@param row number zero-indexed line number
--@return string the line at row in filename
function M.get_line(uri, row)
+ return M.get_lines(uri, { row })[row]
+end
+
+-- Gets the zero-indexed lines from the given uri.
+-- For non-file uris, we load the buffer and get the lines.
+-- If a loaded buffer exists, then that is used.
+-- Otherwise we get the lines using libuv which is a lot faster than loading the buffer.
+--@param uri string uri of the resource to get the lines from
+--@param rows number[] zero-indexed line numbers
+--@return table<number string> a table mapping rows to lines
+function M.get_lines(uri, rows)
+ rows = type(rows) == "table" and rows or { rows }
+
+ local function buf_lines(bufnr)
+ local lines = {}
+ for _, row in pairs(rows) do
+ lines[row] = (vim.api.nvim_buf_get_lines(bufnr, row, row + 1, false) or { "" })[1]
+ end
+ return lines
+ end
+
-- load the buffer if this is not a file uri
-- Custom language server protocol extensions can result in servers sending URIs with custom schemes. Plugins are able to load these via `BufReadCmd` autocmds.
if uri:sub(1, 4) ~= "file" then
local bufnr = vim.uri_to_bufnr(uri)
vim.fn.bufload(bufnr)
- return (vim.api.nvim_buf_get_lines(bufnr, row, row + 1, false) or { "" })[1]
+ return buf_lines(bufnr)
end
local filename = vim.uri_to_fname(uri)
@@ -1475,22 +1496,44 @@ function M.get_line(uri, row)
-- use loaded buffers if available
if vim.fn.bufloaded(filename) == 1 then
local bufnr = vim.fn.bufnr(filename, false)
- return (vim.api.nvim_buf_get_lines(bufnr, row, row + 1, false) or { "" })[1]
+ return buf_lines(bufnr)
end
+ -- get the data from the file
local fd = uv.fs_open(filename, "r", 438)
- -- TODO: what should we do in this case?
if not fd then return "" end
local stat = uv.fs_fstat(fd)
local data = uv.fs_read(fd, stat.size, 0)
uv.fs_close(fd)
+ local lines = {} -- rows we need to retrieve
+ local need = 0 -- keep track of how many unique rows we need
+ for _, row in pairs(rows) do
+ if not lines[row] then
+ need = need + 1
+ end
+ lines[row] = true
+ end
+
+ local found = 0
local lnum = 0
+
for line in string.gmatch(data, "([^\n]*)\n?") do
- if lnum == row then return line end
+ if lines[lnum] == true then
+ lines[lnum] = line
+ found = found + 1
+ if found == need then break end
+ end
lnum = lnum + 1
end
- return ""
+
+ -- change any lines we didn't find to the empty string
+ for i, line in pairs(lines) do
+ if line == true then
+ lines[i] = ""
+ end
+ end
+ return lines
end
--- Returns the items with the byte position calculated correctly and in sorted
@@ -1522,10 +1565,22 @@ function M.locations_to_items(locations)
local rows = grouped[uri]
table.sort(rows, position_sort)
local filename = vim.uri_to_fname(uri)
+
+ -- list of row numbers
+ local uri_rows = {}
+ for _, temp in ipairs(rows) do
+ local pos = temp.start
+ local row = pos.line
+ table.insert(uri_rows, row)
+ end
+
+ -- get all the lines for this uri
+ local lines = M.get_lines(uri, uri_rows)
+
for _, temp in ipairs(rows) do
local pos = temp.start
local row = pos.line
- local line = M.get_line(uri, row)
+ local line = lines[row] or ""
local col = pos.character
table.insert(items, {
filename = filename,