2017-03-21 09:08:19 -07:00
|
|
|
*api.txt* Nvim
|
2016-02-07 05:05:59 -07:00
|
|
|
|
|
|
|
|
|
|
|
NVIM REFERENCE MANUAL by Thiago de Arruda
|
|
|
|
|
|
|
|
|
2017-03-01 09:18:03 -07:00
|
|
|
Nvim API *API* *api*
|
2016-06-14 20:12:43 -07:00
|
|
|
|
2017-03-01 09:18:03 -07:00
|
|
|
Nvim exposes a powerful API that can be used by plugins and external processes
|
2023-06-22 03:44:51 -07:00
|
|
|
via |RPC|, |Lua| and Vimscript (|eval-api|).
|
2016-02-07 05:05:59 -07:00
|
|
|
|
2017-04-17 14:52:38 -07:00
|
|
|
Applications can also embed libnvim to work with the C API directly.
|
2016-02-07 05:05:59 -07:00
|
|
|
|
2017-10-20 17:33:58 -07:00
|
|
|
Type |gO| to see the table of contents.
|
2017-05-01 08:09:29 -07:00
|
|
|
|
2019-08-25 16:00:58 -07:00
|
|
|
==============================================================================
|
|
|
|
API Usage *api-rpc* *RPC* *rpc*
|
|
|
|
|
|
|
|
*msgpack-rpc*
|
2023-06-19 08:40:33 -07:00
|
|
|
RPC is the main way to control Nvim programmatically. Nvim implements the
|
|
|
|
MessagePack-RPC protocol with these extra (out-of-spec) constraints:
|
|
|
|
|
|
|
|
1. Responses must be given in reverse order of requests (like "unwinding
|
|
|
|
a stack").
|
|
|
|
2. Nvim processes all messages (requests and notifications) in the order they
|
|
|
|
are received.
|
|
|
|
|
|
|
|
MessagePack-RPC specification:
|
2019-11-25 02:08:02 -07:00
|
|
|
https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md
|
2019-08-25 16:00:58 -07:00
|
|
|
https://github.com/msgpack/msgpack/blob/0b8f5ac/spec.md
|
|
|
|
|
|
|
|
Many clients use the API: user interfaces (GUIs), remote plugins, scripts like
|
|
|
|
"nvr" (https://github.com/mhinz/neovim-remote). Even Nvim itself can control
|
|
|
|
other Nvim instances. API clients can:
|
|
|
|
|
|
|
|
- Call any API function
|
|
|
|
- Listen for events
|
|
|
|
- Receive remote calls from Nvim
|
|
|
|
|
|
|
|
The RPC API is like a more powerful version of Vim's "clientserver" feature.
|
|
|
|
|
|
|
|
CONNECTING *rpc-connecting*
|
|
|
|
|
|
|
|
See |channel-intro| for various ways to open a channel. Channel-opening
|
|
|
|
functions take an `rpc` key in the options dictionary. RPC channels can also
|
|
|
|
be opened by other processes connecting to TCP/IP sockets or named pipes
|
|
|
|
listened to by Nvim.
|
|
|
|
|
|
|
|
Nvim creates a default RPC socket at |startup|, given by |v:servername|. To
|
|
|
|
start with a TCP/IP socket instead, use |--listen| with a TCP-style address: >
|
|
|
|
nvim --listen 127.0.0.1:6666
|
|
|
|
More endpoints can be started with |serverstart()|.
|
|
|
|
|
|
|
|
Note that localhost TCP sockets are generally less secure than named pipes,
|
|
|
|
and can lead to vulnerabilities like remote code execution.
|
|
|
|
|
|
|
|
Connecting to the socket is the easiest way a programmer can test the API,
|
|
|
|
which can be done through any msgpack-rpc client library or full-featured
|
|
|
|
|api-client|. Here's a Ruby script that prints "hello world!" in the current
|
|
|
|
Nvim instance:
|
2022-11-22 10:41:00 -07:00
|
|
|
>ruby
|
2019-08-25 16:00:58 -07:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# Requires msgpack-rpc: gem install msgpack-rpc
|
|
|
|
#
|
|
|
|
# To run this script, execute it from a running Nvim instance (notice the
|
|
|
|
# trailing '&' which is required since Nvim won't process events while
|
|
|
|
# running a blocking command):
|
|
|
|
#
|
2022-05-03 06:08:35 -07:00
|
|
|
# :!./hello.rb &
|
2019-08-25 16:00:58 -07:00
|
|
|
#
|
|
|
|
# Or from another shell by setting NVIM_LISTEN_ADDRESS:
|
|
|
|
# $ NVIM_LISTEN_ADDRESS=[address] ./hello.rb
|
|
|
|
|
|
|
|
require 'msgpack/rpc'
|
|
|
|
require 'msgpack/rpc/transport/unix'
|
|
|
|
|
|
|
|
nvim = MessagePack::RPC::Client.new(MessagePack::RPC::UNIXTransport.new, ENV['NVIM_LISTEN_ADDRESS'])
|
|
|
|
result = nvim.call(:nvim_command, 'echo "hello world!"')
|
|
|
|
<
|
2020-08-31 00:51:35 -07:00
|
|
|
A better way is to use the Python REPL with the "pynvim" package, where API
|
2019-08-25 16:00:58 -07:00
|
|
|
functions can be called interactively:
|
|
|
|
>
|
|
|
|
>>> from pynvim import attach
|
|
|
|
>>> nvim = attach('socket', path='[address]')
|
|
|
|
>>> nvim.command('echo "hello world!"')
|
|
|
|
<
|
|
|
|
You can also embed Nvim via |jobstart()|, and communicate using |rpcrequest()|
|
|
|
|
and |rpcnotify()|:
|
2022-11-22 10:41:00 -07:00
|
|
|
>vim
|
2019-08-25 16:00:58 -07:00
|
|
|
let nvim = jobstart(['nvim', '--embed'], {'rpc': v:true})
|
|
|
|
echo rpcrequest(nvim, 'nvim_eval', '"Hello " . "world!"')
|
|
|
|
call jobstop(nvim)
|
2022-09-24 17:20:47 -07:00
|
|
|
<
|
2019-08-25 16:00:58 -07:00
|
|
|
|
2016-02-07 05:05:59 -07:00
|
|
|
==============================================================================
|
2019-05-24 09:07:16 -07:00
|
|
|
API Definitions *api-definitions*
|
2016-02-07 05:05:59 -07:00
|
|
|
|
2019-05-24 09:07:16 -07:00
|
|
|
*api-types*
|
2017-12-27 11:30:23 -07:00
|
|
|
The Nvim C API defines custom types for all function parameters. Some are just
|
|
|
|
typedefs around C99 standard types, others are Nvim-defined data structures.
|
2016-02-07 05:05:59 -07:00
|
|
|
|
2019-08-25 16:00:58 -07:00
|
|
|
Basic types ~
|
2022-09-24 17:20:47 -07:00
|
|
|
>
|
2019-08-25 16:00:58 -07:00
|
|
|
API Type C type
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
Nil
|
|
|
|
Boolean bool
|
|
|
|
Integer (signed 64-bit integer) int64_t
|
|
|
|
Float (IEEE 754 double precision) double
|
|
|
|
String {char* data, size_t size} struct
|
2017-12-27 11:30:23 -07:00
|
|
|
Array
|
2019-08-25 16:00:58 -07:00
|
|
|
Dictionary (msgpack: map)
|
2017-12-27 11:30:23 -07:00
|
|
|
Object
|
2022-09-24 17:20:47 -07:00
|
|
|
<
|
2019-08-25 16:00:58 -07:00
|
|
|
Note: empty Array is accepted as a valid argument for Dictionary parameter.
|
|
|
|
|
|
|
|
Special types (msgpack EXT) ~
|
|
|
|
|
|
|
|
These are integer typedefs discriminated as separate Object subtypes. They
|
|
|
|
can be treated as opaque integers, but are mutually incompatible: Buffer may
|
|
|
|
be passed as an integer but not as Window or Tabpage.
|
|
|
|
|
|
|
|
The EXT object data is the (integer) object handle. The EXT type codes given
|
|
|
|
in the |api-metadata| `types` key are stable: they will not change and are
|
|
|
|
thus forward-compatible.
|
2022-09-24 17:20:47 -07:00
|
|
|
>
|
2019-08-25 16:00:58 -07:00
|
|
|
EXT Type C type Data
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
Buffer enum value kObjectTypeBuffer |bufnr()|
|
|
|
|
Window enum value kObjectTypeWindow |window-ID|
|
|
|
|
Tabpage enum value kObjectTypeTabpage internal handle
|
2022-09-24 17:20:47 -07:00
|
|
|
<
|
2016-02-07 05:05:59 -07:00
|
|
|
|
2019-05-24 09:07:16 -07:00
|
|
|
*api-indexing*
|
|
|
|
Most of the API uses 0-based indices, and ranges are end-exclusive. For the
|
|
|
|
end of a range, -1 denotes the last line/column.
|
|
|
|
|
|
|
|
Exception: the following API functions use "mark-like" indexing (1-based
|
|
|
|
lines, 0-based columns):
|
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
- |nvim_get_mark()|
|
|
|
|
- |nvim_buf_get_mark()|
|
|
|
|
- |nvim_buf_set_mark()|
|
|
|
|
- |nvim_win_get_cursor()|
|
|
|
|
- |nvim_win_set_cursor()|
|
2019-05-24 09:07:16 -07:00
|
|
|
|
2021-09-10 19:10:09 -07:00
|
|
|
Exception: the following API functions use |extmarks| indexing (0-based
|
|
|
|
indices, end-inclusive):
|
2021-08-08 14:17:23 -07:00
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
- |nvim_buf_del_extmark()|
|
|
|
|
- |nvim_buf_get_extmark_by_id()|
|
|
|
|
- |nvim_buf_get_extmarks()|
|
|
|
|
- |nvim_buf_set_extmark()|
|
2021-08-08 14:17:23 -07:00
|
|
|
|
2019-08-25 16:01:01 -07:00
|
|
|
*api-fast*
|
|
|
|
Most API functions are "deferred": they are queued on the main loop and
|
|
|
|
processed sequentially with normal input. So if the editor is waiting for
|
|
|
|
user input in a "modal" fashion (e.g. the |hit-enter-prompt|), the request
|
2022-04-30 16:16:16 -07:00
|
|
|
will block. Non-deferred (fast) functions such as |nvim_get_mode()| and
|
2019-08-25 16:01:01 -07:00
|
|
|
|nvim_input()| are served immediately (i.e. without waiting in the input
|
2022-04-30 16:16:16 -07:00
|
|
|
queue). Lua code can use |vim.in_fast_event()| to detect a fast context.
|
2019-08-25 16:01:01 -07:00
|
|
|
|
2016-02-07 05:05:59 -07:00
|
|
|
==============================================================================
|
2019-08-25 16:00:58 -07:00
|
|
|
API metadata *api-metadata*
|
|
|
|
|
|
|
|
The Nvim C API is automatically exposed to RPC by the build system, which
|
|
|
|
parses headers in src/nvim/api/* and generates dispatch-functions mapping RPC
|
|
|
|
API method names to public C API functions, converting/validating arguments
|
|
|
|
and return values.
|
2016-02-07 05:05:59 -07:00
|
|
|
|
2019-08-25 16:00:58 -07:00
|
|
|
Nvim exposes its API metadata as a Dictionary with these items:
|
2016-10-31 08:16:37 -07:00
|
|
|
|
2022-09-24 17:20:47 -07:00
|
|
|
- version Nvim version, API level/compatibility
|
|
|
|
- version.api_level API version integer *api-level*
|
|
|
|
- version.api_compatible API is backwards-compatible with this level
|
|
|
|
- version.api_prerelease Declares the API as unstable/unreleased
|
|
|
|
`(version.api_prerelease && fn.since == version.api_level)`
|
|
|
|
- functions API function signatures, containing |api-types| info
|
|
|
|
describing the return value and parameters.
|
|
|
|
- ui_events |UI| event signatures
|
|
|
|
- ui_options Supported |ui-option|s
|
|
|
|
- {fn}.since API level where function {fn} was introduced
|
|
|
|
- {fn}.deprecated_since API level where function {fn} was deprecated
|
|
|
|
- types Custom handle types defined by Nvim
|
|
|
|
- error_types Possible error types returned by API functions
|
2016-10-31 08:16:37 -07:00
|
|
|
|
2019-08-25 16:00:58 -07:00
|
|
|
About the `functions` map:
|
|
|
|
|
|
|
|
- Container types may be decorated with type/size constraints, e.g.
|
|
|
|
ArrayOf(Buffer) or ArrayOf(Integer, 2).
|
|
|
|
- Functions considered to be methods that operate on instances of Nvim
|
|
|
|
special types (msgpack EXT) have the "method=true" flag. The receiver type
|
|
|
|
is that of the first argument. Method names are prefixed with `nvim_` plus
|
|
|
|
a type name, e.g. `nvim_buf_get_lines` is the `get_lines` method of
|
|
|
|
a Buffer instance. |dev-api|
|
|
|
|
- Global functions have the "method=false" flag and are prefixed with just
|
|
|
|
`nvim_`, e.g. `nvim_list_bufs`.
|
|
|
|
|
|
|
|
*api-mapping*
|
|
|
|
External programs (clients) can use the metadata to discover the API, using
|
|
|
|
any of these approaches:
|
|
|
|
|
|
|
|
1. Connect to a running Nvim instance and call |nvim_get_api_info()| via
|
2020-01-13 00:41:55 -07:00
|
|
|
msgpack-RPC. This is best for clients written in dynamic languages which
|
2019-08-25 16:00:58 -07:00
|
|
|
can define functions at runtime.
|
|
|
|
|
2020-01-13 00:41:55 -07:00
|
|
|
2. Start Nvim with |--api-info|. Useful for statically-compiled clients.
|
|
|
|
Example (requires Python "pyyaml" and "msgpack-python" modules): >
|
|
|
|
nvim --api-info | python -c 'import msgpack, sys, yaml; yaml.dump(msgpack.unpackb(sys.stdin.buffer.read()), sys.stdout)'
|
2019-08-25 16:00:58 -07:00
|
|
|
<
|
2022-11-22 10:41:00 -07:00
|
|
|
3. Use the |api_info()| Vimscript function. >vim
|
2023-06-23 03:16:55 -07:00
|
|
|
:lua vim.print(vim.fn.api_info())
|
2022-11-22 10:41:00 -07:00
|
|
|
< Example using |filter()| to exclude non-deprecated API functions: >vim
|
2020-01-13 00:41:55 -07:00
|
|
|
:new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val.name')
|
2016-02-07 05:05:59 -07:00
|
|
|
|
2017-04-17 14:52:38 -07:00
|
|
|
==============================================================================
|
|
|
|
API contract *api-contract*
|
|
|
|
|
2017-12-27 11:30:23 -07:00
|
|
|
The Nvim API is composed of functions and events.
|
|
|
|
|
|
|
|
- Clients call functions like those described at |api-global|.
|
|
|
|
- Clients can subscribe to |ui-events|, |api-buffer-updates|, etc.
|
|
|
|
- API function names are prefixed with "nvim_".
|
|
|
|
- API event names are prefixed with "nvim_" and suffixed with "_event".
|
2017-04-17 14:52:38 -07:00
|
|
|
|
2017-12-27 11:30:23 -07:00
|
|
|
As Nvim evolves the API may change in compliance with this CONTRACT:
|
2017-04-17 14:52:38 -07:00
|
|
|
|
|
|
|
- New functions and events may be added.
|
|
|
|
- Any such extensions are OPTIONAL: old clients may ignore them.
|
|
|
|
- Function signatures will NOT CHANGE (after release).
|
|
|
|
- Functions introduced in the development (unreleased) version MAY CHANGE.
|
|
|
|
(Clients can dynamically check `api_prerelease`, etc. |api-metadata|)
|
|
|
|
- Event parameters will not be removed or reordered (after release).
|
|
|
|
- Events may be EXTENDED: new parameters may be added.
|
|
|
|
- New items may be ADDED to map/list parameters/results of functions and
|
|
|
|
events.
|
|
|
|
- Any such new items are OPTIONAL: old clients may ignore them.
|
|
|
|
- Existing items will not be removed (after release).
|
|
|
|
- Deprecated functions will not be removed until Nvim version 2.0
|
|
|
|
|
2022-10-09 05:21:52 -07:00
|
|
|
"Private" interfaces are NOT covered by this contract:
|
|
|
|
|
|
|
|
- Undocumented (not in :help) functions or events of any kind
|
|
|
|
- nvim__x ("double underscore") functions
|
|
|
|
|
|
|
|
The idea is "versionless evolution", in the words of Rich Hickey:
|
|
|
|
- Relaxing a requirement should be a compatible change.
|
|
|
|
- Strengthening a promise should be a compatible change.
|
|
|
|
|
2018-12-01 08:44:36 -07:00
|
|
|
==============================================================================
|
|
|
|
Global events *api-global-events*
|
|
|
|
|
|
|
|
When a client invokes an API request as an async notification, it is not
|
|
|
|
possible for Nvim to send an error response. Instead, in case of error, the
|
|
|
|
following notification will be sent to the client:
|
|
|
|
|
|
|
|
*nvim_error_event*
|
|
|
|
nvim_error_event[{type}, {message}]
|
|
|
|
|
|
|
|
{type} is a numeric id as defined by `api_info().error_types`, and {message} is
|
|
|
|
a string with the error message.
|
|
|
|
|
2016-02-07 05:05:59 -07:00
|
|
|
==============================================================================
|
2018-06-08 01:19:46 -07:00
|
|
|
Buffer update events *api-buffer-updates*
|
|
|
|
|
|
|
|
API clients can "attach" to Nvim buffers to subscribe to buffer update events.
|
|
|
|
This is similar to |TextChanged| but more powerful and granular.
|
|
|
|
|
2018-08-25 07:38:24 -07:00
|
|
|
Call |nvim_buf_attach()| to receive these events on the channel:
|
2018-06-08 01:19:46 -07:00
|
|
|
|
|
|
|
*nvim_buf_lines_event*
|
|
|
|
nvim_buf_lines_event[{buf}, {changedtick}, {firstline}, {lastline}, {linedata}, {more}]
|
|
|
|
|
|
|
|
When the buffer text between {firstline} and {lastline} (end-exclusive,
|
|
|
|
zero-indexed) were changed to the new text in the {linedata} list. The
|
|
|
|
granularity is a line, i.e. if a single character is changed in the
|
|
|
|
editor, the entire line is sent.
|
|
|
|
|
|
|
|
When {changedtick} is |v:null| this means the screen lines (display)
|
|
|
|
changed but not the buffer contents. {linedata} contains the changed
|
2018-11-04 18:47:22 -07:00
|
|
|
screen lines. This happens when 'inccommand' shows a buffer preview.
|
2018-06-08 01:19:46 -07:00
|
|
|
|
2023-06-26 02:16:55 -07:00
|
|
|
Properties: ~
|
2018-06-08 01:19:46 -07:00
|
|
|
{buf} API buffer handle (buffer number)
|
|
|
|
|
|
|
|
{changedtick} value of |b:changedtick| for the buffer. If you send an
|
|
|
|
API command back to nvim you can check the value of |b:changedtick| as
|
|
|
|
part of your request to ensure that no other changes have been made.
|
|
|
|
|
|
|
|
{firstline} integer line number of the first line that was replaced.
|
|
|
|
Zero-indexed: if line 1 was replaced then {firstline} will be 0, not
|
|
|
|
1. {firstline} is always less than or equal to the number of lines
|
|
|
|
that were in the buffer before the lines were replaced.
|
|
|
|
|
|
|
|
{lastline} integer line number of the first line that was not replaced
|
|
|
|
(i.e. the range {firstline}, {lastline} is end-exclusive).
|
|
|
|
Zero-indexed: if line numbers 2 to 5 were replaced, this will be 5
|
|
|
|
instead of 6. {lastline} is always be less than or equal to the number
|
|
|
|
of lines that were in the buffer before the lines were replaced.
|
|
|
|
{lastline} will be -1 if the event is part of the initial update after
|
|
|
|
attaching.
|
|
|
|
|
|
|
|
{linedata} list of strings containing the contents of the new buffer
|
|
|
|
lines. Newline characters are omitted; empty lines are sent as empty
|
|
|
|
strings.
|
|
|
|
|
|
|
|
{more} boolean, true for a "multipart" change notification: the
|
|
|
|
current change was chunked into multiple |nvim_buf_lines_event|
|
|
|
|
notifications (e.g. because it was too big).
|
|
|
|
|
|
|
|
nvim_buf_changedtick_event[{buf}, {changedtick}] *nvim_buf_changedtick_event*
|
|
|
|
|
|
|
|
When |b:changedtick| was incremented but no text was changed. Relevant for
|
|
|
|
undo/redo.
|
|
|
|
|
2023-06-26 02:16:55 -07:00
|
|
|
Properties: ~
|
2018-06-08 01:19:46 -07:00
|
|
|
{buf} API buffer handle (buffer number)
|
|
|
|
{changedtick} new value of |b:changedtick| for the buffer
|
|
|
|
|
|
|
|
nvim_buf_detach_event[{buf}] *nvim_buf_detach_event*
|
|
|
|
|
|
|
|
When buffer is detached (i.e. updates are disabled). Triggered explicitly by
|
2018-11-04 18:47:22 -07:00
|
|
|
|nvim_buf_detach()| or implicitly in these cases:
|
2018-06-08 01:19:46 -07:00
|
|
|
- Buffer was |abandon|ed and 'hidden' is not set.
|
|
|
|
- Buffer was reloaded, e.g. with |:edit| or an external change triggered
|
|
|
|
|:checktime| or 'autoread'.
|
|
|
|
- Generally: whenever the buffer contents are unloaded from memory.
|
|
|
|
|
2023-06-26 02:16:55 -07:00
|
|
|
Properties: ~
|
2018-06-08 01:19:46 -07:00
|
|
|
{buf} API buffer handle (buffer number)
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLE ~
|
|
|
|
|
2018-08-25 07:38:24 -07:00
|
|
|
Calling |nvim_buf_attach()| with send_buffer=true on an empty buffer, emits: >
|
2019-01-21 20:43:44 -07:00
|
|
|
nvim_buf_lines_event[{buf}, {changedtick}, 0, -1, [""], v:false]
|
2018-06-08 01:19:46 -07:00
|
|
|
|
|
|
|
User adds two lines to the buffer, emits: >
|
|
|
|
nvim_buf_lines_event[{buf}, {changedtick}, 0, 0, ["line1", "line2"], v:false]
|
|
|
|
|
|
|
|
User moves to a line containing the text "Hello world" and inserts "!", emits: >
|
|
|
|
nvim_buf_lines_event[{buf}, {changedtick}, {linenr}, {linenr} + 1,
|
|
|
|
["Hello world!"], v:false]
|
|
|
|
|
|
|
|
User moves to line 3 and deletes 20 lines using "20dd", emits: >
|
|
|
|
nvim_buf_lines_event[{buf}, {changedtick}, 2, 22, [], v:false]
|
|
|
|
|
|
|
|
User selects lines 3-5 using |linewise-visual| mode and then types "p" to
|
|
|
|
paste a block of 6 lines, emits: >
|
|
|
|
nvim_buf_lines_event[{buf}, {changedtick}, 2, 5,
|
|
|
|
['pasted line 1', 'pasted line 2', 'pasted line 3', 'pasted line 4',
|
|
|
|
'pasted line 5', 'pasted line 6'],
|
|
|
|
v:false
|
|
|
|
]
|
|
|
|
|
|
|
|
User reloads the buffer with ":edit", emits: >
|
|
|
|
nvim_buf_detach_event[{buf}]
|
2019-08-28 01:17:45 -07:00
|
|
|
<
|
2018-06-08 01:19:46 -07:00
|
|
|
|
2019-08-28 01:17:45 -07:00
|
|
|
LUA ~
|
2019-05-29 01:05:00 -07:00
|
|
|
*api-buffer-updates-lua*
|
2019-08-28 01:17:45 -07:00
|
|
|
In-process Lua plugins can receive buffer updates in the form of Lua
|
|
|
|
callbacks. These callbacks are called frequently in various contexts;
|
|
|
|
|textlock| prevents changing buffer contents and window layout (use
|
2022-09-25 16:58:27 -07:00
|
|
|
|vim.schedule()| to defer such operations to the main loop instead).
|
2023-03-08 19:19:00 -07:00
|
|
|
Moving the cursor is allowed, but it is restored afterwards.
|
2019-05-29 01:05:00 -07:00
|
|
|
|
2020-09-05 22:10:56 -07:00
|
|
|
|nvim_buf_attach()| will take keyword args for the callbacks. "on_lines" will
|
2019-07-15 09:23:11 -07:00
|
|
|
receive parameters ("lines", {buf}, {changedtick}, {firstline}, {lastline},
|
2019-08-04 03:22:22 -07:00
|
|
|
{new_lastline}, {old_byte_size} [, {old_utf32_size}, {old_utf16_size}]).
|
2019-07-15 09:23:11 -07:00
|
|
|
Unlike remote channel events the text contents are not passed. The new text can
|
2022-11-22 10:41:00 -07:00
|
|
|
be accessed inside the callback as >lua
|
2019-07-15 09:23:11 -07:00
|
|
|
|
2022-11-22 10:41:00 -07:00
|
|
|
vim.api.nvim_buf_get_lines(buf, firstline, new_lastline, true)
|
|
|
|
<
|
2019-08-04 03:22:22 -07:00
|
|
|
{old_byte_size} is the total size of the replaced region {firstline} to
|
|
|
|
{lastline} in bytes, including the final newline after {lastline}. if
|
|
|
|
`utf_sizes` is set to true in |nvim_buf_attach()| keyword args, then the
|
|
|
|
UTF-32 and UTF-16 sizes of the deleted region is also passed as additional
|
|
|
|
arguments {old_utf32_size} and {old_utf16_size}.
|
2019-07-15 09:23:11 -07:00
|
|
|
|
2019-05-29 01:05:00 -07:00
|
|
|
"on_changedtick" is invoked when |b:changedtick| was incremented but no text
|
|
|
|
was changed. The parameters received are ("changedtick", {buf}, {changedtick}).
|
|
|
|
|
2019-08-28 01:17:45 -07:00
|
|
|
*api-lua-detach*
|
|
|
|
In-process Lua callbacks can detach by returning `true`. This will detach all
|
2020-09-05 22:10:56 -07:00
|
|
|
callbacks attached with the same |nvim_buf_attach()| call.
|
2019-05-29 01:05:00 -07:00
|
|
|
|
|
|
|
|
2018-06-08 01:19:46 -07:00
|
|
|
==============================================================================
|
2017-03-01 09:18:03 -07:00
|
|
|
Buffer highlighting *api-highlights*
|
2016-02-07 05:05:59 -07:00
|
|
|
|
|
|
|
Nvim allows plugins to add position-based highlights to buffers. This is
|
|
|
|
similar to |matchaddpos()| but with some key differences. The added highlights
|
|
|
|
are associated with a buffer and adapts to line insertions and deletions,
|
|
|
|
similar to signs. It is also possible to manage a set of highlights as a group
|
|
|
|
and delete or replace all at once.
|
|
|
|
|
|
|
|
The intended use case are linter or semantic highlighter plugins that monitor
|
|
|
|
a buffer for changes, and in the background compute highlights to the buffer.
|
|
|
|
Another use case are plugins that show output in an append-only buffer, and
|
|
|
|
want to add highlights to the outputs. Highlight data cannot be preserved
|
|
|
|
on writing and loading a buffer to file, nor in undo/redo cycles.
|
|
|
|
|
2018-08-25 07:38:24 -07:00
|
|
|
Highlights are registered using the |nvim_buf_add_highlight()| function. If an
|
|
|
|
external highlighter plugin wants to add many highlights in a batch,
|
|
|
|
performance can be improved by calling |nvim_buf_add_highlight()| as an
|
2020-12-26 21:49:21 -07:00
|
|
|
asynchronous notification, after first (synchronously) requesting a source id.
|
2019-04-08 14:08:01 -07:00
|
|
|
|
2023-04-30 02:02:38 -07:00
|
|
|
|nvim_buf_add_highlight()| adds highlights as |extmarks|. If highlights need to
|
|
|
|
be tracked or manipulated after adding them, it is better to use
|
|
|
|
|nvim_buf_set_extmark()| directly, as this function returns the placed |extmark|
|
|
|
|
id. Thus, instead of >lua
|
|
|
|
vim.api.nvim_buf_add_highlight(buf, ns_id, hl_group, line, col_start, col_end)
|
|
|
|
<
|
|
|
|
use >lua
|
|
|
|
-- create the highlight through an extmark
|
2023-04-30 05:36:54 -07:00
|
|
|
extid = vim.api.nvim_buf_set_extmark(buf, ns_id, line, col_start, {end_col = col_end, hl_group = hl_group})
|
2023-04-30 02:02:38 -07:00
|
|
|
|
|
|
|
-- example: modify the extmark's highlight group
|
2023-05-11 17:17:38 -07:00
|
|
|
vim.api.nvim_buf_set_extmark(buf, ns_id, line, col_start, {end_col = col_end, hl_group = NEW_HL_GROUP, id = extid})
|
2023-04-30 02:02:38 -07:00
|
|
|
|
|
|
|
-- example: change the highlight's position
|
2023-04-30 05:36:54 -07:00
|
|
|
vim.api.nvim_buf_set_extmark(buf, ns_id, NEW_LINE, col_start, {end_col = col_end, hl_group = NEW_HL_GROUP, id = extid})
|
2023-04-30 02:02:38 -07:00
|
|
|
<
|
|
|
|
|
2019-04-08 14:08:01 -07:00
|
|
|
Example using the Python API client (|pynvim|):
|
2022-11-22 10:41:00 -07:00
|
|
|
>python
|
2016-02-07 05:05:59 -07:00
|
|
|
src = vim.new_highlight_source()
|
|
|
|
buf = vim.current.buffer
|
|
|
|
for i in range(5):
|
|
|
|
buf.add_highlight("String",i,0,-1,src_id=src)
|
2019-04-08 14:08:01 -07:00
|
|
|
# some time later ...
|
|
|
|
buf.clear_namespace(src)
|
2016-02-07 05:05:59 -07:00
|
|
|
<
|
|
|
|
If the highlights don't need to be deleted or updated, just pass -1 as
|
2018-12-01 08:44:36 -07:00
|
|
|
src_id (this is the default in python). Use |nvim_buf_clear_namespace()| to
|
2018-08-25 07:38:24 -07:00
|
|
|
clear highlights from a specific source, in a specific line range or the
|
|
|
|
entire buffer by passing in the line range 0, -1 (the latter is the default in
|
|
|
|
python as used above).
|
2016-02-07 05:05:59 -07:00
|
|
|
|
2022-11-22 10:41:00 -07:00
|
|
|
Example using the API from Vimscript: >vim
|
2016-06-28 12:45:19 -07:00
|
|
|
|
|
|
|
call nvim_buf_set_lines(0, 0, 0, v:true, ["test text"])
|
|
|
|
let src = nvim_buf_add_highlight(0, 0, "String", 1, 0, 4)
|
|
|
|
call nvim_buf_add_highlight(0, src, "Identifier", 0, 5, -1)
|
2019-04-08 14:08:01 -07:00
|
|
|
" some time later ...
|
2018-12-01 08:44:36 -07:00
|
|
|
call nvim_buf_clear_namespace(0, src, 0, -1)
|
2019-03-03 04:38:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
Floating windows *api-floatwin*
|
|
|
|
|
2019-09-09 15:35:30 -07:00
|
|
|
Floating windows ("floats") are displayed on top of normal windows. This is
|
|
|
|
useful to implement simple widgets, such as tooltips displayed next to the
|
|
|
|
cursor. Floats are fully functional windows supporting user editing, common
|
|
|
|
|api-window| calls, and most window options (except 'statusline').
|
|
|
|
|
|
|
|
Two ways to create a floating window:
|
|
|
|
- |nvim_open_win()| creates a new window (needs a buffer, see |nvim_create_buf()|)
|
|
|
|
- |nvim_win_set_config()| reconfigures a normal window into a float
|
|
|
|
|
|
|
|
To close it use |nvim_win_close()| or a command such as |:close|.
|
|
|
|
|
2022-05-11 16:49:19 -07:00
|
|
|
To check whether a window is floating, check whether the `relative` option in
|
2022-11-22 10:41:00 -07:00
|
|
|
its config is non-empty: >lua
|
2022-05-11 16:49:19 -07:00
|
|
|
|
|
|
|
if vim.api.nvim_win_get_config(window_id).relative ~= '' then
|
|
|
|
-- window with this window_id is floating
|
|
|
|
end
|
2022-09-29 04:46:44 -07:00
|
|
|
<
|
2022-05-11 16:49:19 -07:00
|
|
|
|
2019-09-09 15:35:30 -07:00
|
|
|
Buffer text can be highlighted by typical mechanisms (syntax highlighting,
|
|
|
|
|api-highlights|). The |hl-NormalFloat| group highlights normal text;
|
|
|
|
'winhighlight' can be used as usual to override groups locally. Floats inherit
|
|
|
|
options from the current window; specify `style=minimal` in |nvim_open_win()|
|
|
|
|
to disable various visual features such as the 'number' column.
|
|
|
|
|
2023-03-09 02:54:39 -07:00
|
|
|
Other highlight groups specific to floating windows:
|
|
|
|
- |hl-FloatBorder| for window's border
|
|
|
|
- |hl-FloatTitle| for window's title
|
2023-08-25 00:53:39 -07:00
|
|
|
- |hl-FloatFooter| for window's footer
|
2023-03-09 02:54:39 -07:00
|
|
|
|
2021-06-28 17:40:56 -07:00
|
|
|
Currently, floating windows don't support some widgets like scrollbar.
|
2019-09-09 15:35:30 -07:00
|
|
|
|
2022-05-24 10:32:01 -07:00
|
|
|
The output of |:mksession| does not include commands for restoring floating
|
|
|
|
windows.
|
|
|
|
|
2022-11-22 10:41:00 -07:00
|
|
|
Example: create a float with scratch buffer: >vim
|
2019-03-03 04:38:14 -07:00
|
|
|
|
|
|
|
let buf = nvim_create_buf(v:false, v:true)
|
|
|
|
call nvim_buf_set_lines(buf, 0, -1, v:true, ["test", "text"])
|
2019-03-15 10:18:56 -07:00
|
|
|
let opts = {'relative': 'cursor', 'width': 10, 'height': 2, 'col': 0,
|
2019-05-30 08:46:41 -07:00
|
|
|
\ 'row': 1, 'anchor': 'NW', 'style': 'minimal'}
|
2019-03-15 10:18:56 -07:00
|
|
|
let win = nvim_open_win(buf, 0, opts)
|
2019-03-03 04:38:14 -07:00
|
|
|
" optional: change highlight, otherwise Pmenu is used
|
2022-12-19 09:37:45 -07:00
|
|
|
call nvim_set_option_value('winhl', 'Normal:MyHighlight', {'win': win})
|
2022-09-29 04:46:44 -07:00
|
|
|
<
|
2019-08-25 16:00:52 -07:00
|
|
|
|
2017-01-18 05:20:07 -07:00
|
|
|
==============================================================================
|
2022-12-12 08:15:31 -07:00
|
|
|
Extended marks *api-extended-marks* *extmarks* *extmark*
|
2017-01-18 05:20:07 -07:00
|
|
|
|
2019-11-10 17:52:14 -07:00
|
|
|
Extended marks (extmarks) represent buffer annotations that track text changes
|
2021-09-10 19:10:09 -07:00
|
|
|
in the buffer. They can represent cursors, folds, misspelled words, anything
|
|
|
|
that needs to track a logical location in the buffer over time. |api-indexing|
|
2017-01-18 05:20:07 -07:00
|
|
|
|
2021-09-10 19:10:09 -07:00
|
|
|
Extmark position works like "bar" cursor: it exists between characters. Thus,
|
|
|
|
the maximum extmark index on a line is 1 more than the character index: >
|
2021-09-10 17:41:51 -07:00
|
|
|
|
2021-09-10 19:10:09 -07:00
|
|
|
f o o b a r line contents
|
|
|
|
0 1 2 3 4 5 character positions (0-based)
|
|
|
|
0 1 2 3 4 5 6 extmark positions (0-based)
|
2021-09-10 17:41:51 -07:00
|
|
|
|
2021-09-10 19:10:09 -07:00
|
|
|
Extmarks have "forward gravity": if you place the cursor directly on an
|
|
|
|
extmark position and enter some text, the extmark migrates forward. >
|
2021-09-10 17:41:51 -07:00
|
|
|
|
2021-09-10 19:10:09 -07:00
|
|
|
f o o|b a r line (| = cursor)
|
|
|
|
3 extmark
|
2021-09-10 17:41:51 -07:00
|
|
|
|
2021-09-10 19:10:09 -07:00
|
|
|
f o o z|b a r line (| = cursor)
|
|
|
|
4 extmark (after typing "z")
|
2021-09-10 17:41:51 -07:00
|
|
|
|
2021-09-10 19:10:09 -07:00
|
|
|
If an extmark is on the last index of a line and you input a newline at that
|
|
|
|
point, the extmark will accordingly migrate to the next line: >
|
2021-09-10 17:41:51 -07:00
|
|
|
|
2021-09-10 19:10:09 -07:00
|
|
|
f o o z b a r| line (| = cursor)
|
|
|
|
7 extmark
|
2021-09-10 17:41:51 -07:00
|
|
|
|
2021-09-10 19:10:09 -07:00
|
|
|
f o o z b a r first line
|
|
|
|
extmarks (none present)
|
|
|
|
| second line (| = cursor)
|
|
|
|
0 extmark (after typing <CR>)
|
2021-09-10 17:41:51 -07:00
|
|
|
|
|
|
|
|
2017-01-18 05:20:07 -07:00
|
|
|
Example:
|
|
|
|
|
2021-09-10 19:10:09 -07:00
|
|
|
Let's set an extmark at the first row (row=0) and third column (column=2).
|
|
|
|
|api-indexing| Passing id=0 creates a new mark and returns the id: >
|
2017-01-18 05:20:07 -07:00
|
|
|
|
2021-08-08 14:17:23 -07:00
|
|
|
01 2345678
|
|
|
|
0 ex|ample..
|
2022-09-29 04:46:44 -07:00
|
|
|
^ extmark position
|
2022-11-22 10:41:00 -07:00
|
|
|
<
|
|
|
|
>vim
|
2019-11-10 17:52:14 -07:00
|
|
|
let g:mark_ns = nvim_create_namespace('myplugin')
|
2021-08-08 14:17:23 -07:00
|
|
|
let g:mark_id = nvim_buf_set_extmark(0, g:mark_ns, 0, 2, {})
|
|
|
|
<
|
2022-11-22 10:41:00 -07:00
|
|
|
We can get the mark by its id: >vim
|
2017-01-18 05:20:07 -07:00
|
|
|
|
2021-08-08 14:17:23 -07:00
|
|
|
echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id, {})
|
2022-11-22 10:41:00 -07:00
|
|
|
" => [0, 2]
|
2017-01-18 05:20:07 -07:00
|
|
|
|
2022-11-22 10:41:00 -07:00
|
|
|
We can get all marks in a buffer by |namespace| (or by a range): >vim
|
2017-01-18 05:20:07 -07:00
|
|
|
|
2019-11-17 20:06:59 -07:00
|
|
|
echo nvim_buf_get_extmarks(0, g:mark_ns, 0, -1, {})
|
2022-11-22 10:41:00 -07:00
|
|
|
" => [[1, 0, 2]]
|
2017-01-18 05:20:07 -07:00
|
|
|
|
2021-09-10 19:10:09 -07:00
|
|
|
Deleting all surrounding text does NOT remove an extmark! To remove extmarks
|
|
|
|
use |nvim_buf_del_extmark()|. Deleting "x" in our example: >
|
2021-08-08 14:17:23 -07:00
|
|
|
|
|
|
|
0 12345678
|
|
|
|
0 e|ample..
|
2022-09-29 04:46:44 -07:00
|
|
|
^ extmark position
|
2022-11-22 10:41:00 -07:00
|
|
|
<
|
|
|
|
>vim
|
2021-08-08 14:17:23 -07:00
|
|
|
echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id, {})
|
2022-11-22 10:41:00 -07:00
|
|
|
" => [0, 1]
|
2021-08-08 14:17:23 -07:00
|
|
|
<
|
2021-09-10 19:10:09 -07:00
|
|
|
Note: Extmark "gravity" decides how it will shift after a text edit.
|
|
|
|
See |nvim_buf_set_extmark()|
|
2017-01-18 05:20:07 -07:00
|
|
|
|
2021-09-10 19:10:09 -07:00
|
|
|
Namespaces allow any plugin to manage only its own extmarks, ignoring those
|
2019-11-10 17:52:14 -07:00
|
|
|
created by another plugin.
|
|
|
|
|
|
|
|
Extmark positions changed by an edit will be restored on undo/redo. Creating
|
|
|
|
and deleting extmarks is not a buffer change, thus new undo states are not
|
|
|
|
created for extmark changes.
|
2017-01-18 05:20:07 -07:00
|
|
|
|
2016-02-07 05:05:59 -07:00
|
|
|
==============================================================================
|
2017-03-01 09:18:03 -07:00
|
|
|
Global Functions *api-global*
|
|
|
|
|
2021-10-19 06:03:20 -07:00
|
|
|
nvim__get_runtime({pat}, {all}, {*opts}) *nvim__get_runtime()*
|
|
|
|
Find files in runtime directories
|
|
|
|
|
|
|
|
Attributes: ~
|
2022-04-30 16:16:16 -07:00
|
|
|
|api-fast|
|
2021-10-19 06:03:20 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {pat} pattern of files to search for
|
|
|
|
• {all} whether to return all matches or only the first
|
2023-06-22 03:44:51 -07:00
|
|
|
• {opts} is_lua: only search Lua subdirs
|
2021-10-19 06:03:20 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
list of absolute paths to the found files
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim__id({obj}) *nvim__id()*
|
|
|
|
Returns object given as argument.
|
2019-12-01 23:43:16 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
This API function is used for testing. One should not rely on its presence
|
|
|
|
in plugins.
|
2019-12-01 23:43:16 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {obj} Object to return.
|
2019-12-01 23:43:16 -07:00
|
|
|
|
2019-12-02 01:46:46 -07:00
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
its argument.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim__id_array({arr}) *nvim__id_array()*
|
|
|
|
Returns array given as argument.
|
2019-12-01 23:43:16 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
This API function is used for testing. One should not rely on its presence
|
|
|
|
in plugins.
|
2017-11-05 18:00:39 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {arr} Array to return.
|
2017-11-05 18:00:39 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
its argument.
|
2017-11-05 18:00:39 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim__id_dictionary({dct}) *nvim__id_dictionary()*
|
|
|
|
Returns dictionary given as argument.
|
2019-03-03 07:01:16 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
This API function is used for testing. One should not rely on its presence
|
|
|
|
in plugins.
|
2017-11-05 18:00:39 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {dct} Dictionary to return.
|
2017-11-05 18:00:39 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
its argument.
|
2019-12-24 01:04:14 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim__id_float({flt}) *nvim__id_float()*
|
|
|
|
Returns floating-point value given as argument.
|
2018-06-10 15:20:39 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
This API function is used for testing. One should not rely on its presence
|
|
|
|
in plugins.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {flt} Value to return.
|
2019-03-03 07:01:16 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Return: ~
|
|
|
|
its argument.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim__inspect_cell({grid}, {row}, {col}) *nvim__inspect_cell()*
|
2022-03-13 05:36:46 -07:00
|
|
|
NB: if your UI doesn't use hlstate, this will not return hlstate first
|
|
|
|
time.
|
2017-11-05 18:00:39 -07:00
|
|
|
|
2023-11-26 13:07:29 -07:00
|
|
|
nvim__invalidate_glyph_cache() *nvim__invalidate_glyph_cache()*
|
|
|
|
For testing. The condition in schar_cache_clear_if_full is hard to reach,
|
|
|
|
so this function can be used to force a cache clear in a test.
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim__stats() *nvim__stats()*
|
|
|
|
Gets internal stats.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
Map of various internal stats.
|
2019-01-10 17:20:15 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_call_atomic({calls}) *nvim_call_atomic()*
|
|
|
|
Calls many API methods atomically.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
This has two main usages:
|
|
|
|
1. To perform several requests from an async context atomically, i.e.
|
|
|
|
without interleaving redraws, RPC requests from other clients, or user
|
|
|
|
interactions (however API methods may trigger autocommands or event
|
|
|
|
processing which have such side effects, e.g. |:sleep| may wake
|
|
|
|
timers).
|
|
|
|
2. To minimize RPC overhead (roundtrips) of a sequence of many requests.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {calls} an array of calls, where each call is described by an array
|
2019-12-28 04:27:25 -07:00
|
|
|
with two elements: the request name, and an array of
|
|
|
|
arguments.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Return: ~
|
|
|
|
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.
|
2019-03-03 07:01:16 -07:00
|
|
|
|
2021-03-15 01:58:39 -07:00
|
|
|
nvim_chan_send({chan}, {data}) *nvim_chan_send()*
|
2022-03-13 05:48:14 -07:00
|
|
|
Send data to channel `id`. For a job, it writes it to the stdin of the
|
2021-03-15 01:58:39 -07:00
|
|
|
process. For the stdio channel |channel-stdio|, it writes to Nvim's
|
|
|
|
stdout. For an internal terminal instance (|nvim_open_term()|) it writes
|
2022-01-17 11:28:23 -07:00
|
|
|
directly to terminal output. See |channel-bytes| for more information.
|
2021-03-15 01:58:39 -07:00
|
|
|
|
|
|
|
This function writes raw data, not RPC messages. If the channel was
|
|
|
|
created with `rpc=true` then the channel expects RPC messages, use
|
|
|
|
|vim.rpcnotify()| and |vim.rpcrequest()| instead.
|
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
2022-10-09 05:21:52 -07:00
|
|
|
Lua |vim.api| only
|
2022-04-30 16:16:16 -07:00
|
|
|
|
2021-03-15 01:58:39 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {chan} id of the channel
|
|
|
|
• {data} data to write. 8-bit clean: can contain NUL bytes.
|
2021-03-15 01:58:39 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_create_buf({listed}, {scratch}) *nvim_create_buf()*
|
|
|
|
Creates a new, empty, unnamed buffer.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {listed} Sets 'buflisted'
|
|
|
|
• {scratch} Creates a "throwaway" |scratch-buffer| for temporary work
|
2020-07-02 04:09:17 -07:00
|
|
|
(always 'nomodified'). Also sets 'nomodeline' on the
|
|
|
|
buffer.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
Buffer handle, or 0 on error
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• buf_open_scratch
|
2017-03-01 09:18:03 -07:00
|
|
|
|
|
|
|
nvim_del_current_line() *nvim_del_current_line()*
|
2019-01-10 17:20:15 -07:00
|
|
|
Deletes the current line.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2020-11-24 05:37:29 -07:00
|
|
|
Attributes: ~
|
|
|
|
not allowed when |textlock| is active
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_del_keymap({mode}, {lhs}) *nvim_del_keymap()*
|
|
|
|
Unmaps a global |mapping| for the given mode.
|
|
|
|
|
|
|
|
To unmap a buffer-local mapping, use |nvim_buf_del_keymap()|.
|
|
|
|
|
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_set_keymap()|
|
2019-12-28 04:27:25 -07:00
|
|
|
|
2021-10-05 08:49:20 -07:00
|
|
|
nvim_del_mark({name}) *nvim_del_mark()*
|
|
|
|
Deletes an uppercase/file named mark. See |mark-motions|.
|
|
|
|
|
2023-07-06 13:47:27 -07:00
|
|
|
Note: ~
|
|
|
|
• Lowercase name (or other buffer-local mark) is an error.
|
2021-10-05 08:49:20 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Mark name
|
2021-10-05 08:49:20 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
true if the mark was deleted, else false.
|
|
|
|
|
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_buf_del_mark()|
|
|
|
|
• |nvim_get_mark()|
|
2021-10-05 08:49:20 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_del_var({name}) *nvim_del_var()*
|
|
|
|
Removes a global (g:) variable.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Variable name
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2022-12-16 05:50:12 -07:00
|
|
|
nvim_echo({chunks}, {history}, {*opts}) *nvim_echo()*
|
2021-01-10 23:18:51 -07:00
|
|
|
Echo a message.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {chunks} A list of [text, hl_group] arrays, each representing a text
|
2021-01-10 23:18:51 -07:00
|
|
|
chunk with specified highlight. `hl_group` element can be
|
|
|
|
omitted for no highlight.
|
2022-10-05 05:15:55 -07:00
|
|
|
• {history} if true, add to |message-history|.
|
2022-12-16 05:50:12 -07:00
|
|
|
• {opts} Optional parameters.
|
|
|
|
• verbose: Message was printed as a result of 'verbose'
|
|
|
|
option if Nvim was invoked with -V3log_file, the message
|
2023-01-03 16:38:48 -07:00
|
|
|
will be redirected to the log_file and suppressed from
|
2022-12-16 05:50:12 -07:00
|
|
|
direct output.
|
2021-01-10 23:18:51 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_err_write({str}) *nvim_err_write()*
|
|
|
|
Writes a message to the Vim error buffer. Does not append "\n", the
|
|
|
|
message is buffered (won't display) until a linefeed is written.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {str} Message
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_err_writeln({str}) *nvim_err_writeln()*
|
|
|
|
Writes a message to the Vim error buffer. Appends "\n", so the buffer is
|
|
|
|
flushed (and displayed).
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {str} Message
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• nvim_err_write()
|
2019-12-28 04:27:25 -07:00
|
|
|
|
2021-10-19 06:03:20 -07:00
|
|
|
nvim_eval_statusline({str}, {*opts}) *nvim_eval_statusline()*
|
|
|
|
Evaluates statusline string.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-19 06:03:20 -07:00
|
|
|
Attributes: ~
|
2022-04-30 16:16:16 -07:00
|
|
|
|api-fast|
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-19 06:03:20 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {str} Statusline string (see 'statusline').
|
|
|
|
• {opts} Optional parameters.
|
2021-10-19 06:03:20 -07:00
|
|
|
• winid: (number) |window-ID| of the window to use as context
|
|
|
|
for statusline.
|
|
|
|
• maxwidth: (number) Maximum width of statusline.
|
|
|
|
• fillchar: (string) Character to fill blank spaces in the
|
|
|
|
statusline (see 'fillchars'). Treated as single-width even
|
2022-03-20 11:00:30 -07:00
|
|
|
if it isn't.
|
2021-10-19 06:03:20 -07:00
|
|
|
• highlights: (boolean) Return highlight information.
|
2022-05-13 07:47:11 -07:00
|
|
|
• use_winbar: (boolean) Evaluate winbar instead of statusline.
|
2021-10-19 06:03:20 -07:00
|
|
|
• use_tabline: (boolean) Evaluate tabline instead of
|
|
|
|
statusline. When true, {winid} is ignored. Mutually
|
2022-05-13 07:47:11 -07:00
|
|
|
exclusive with {use_winbar}.
|
2023-04-05 18:33:57 -07:00
|
|
|
• use_statuscol_lnum: (number) Evaluate statuscolumn for this
|
|
|
|
line number instead of statusline.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-19 06:03:20 -07:00
|
|
|
Return: ~
|
|
|
|
Dictionary containing statusline information, with these keys:
|
|
|
|
• str: (string) Characters that will be displayed on the statusline.
|
|
|
|
• width: (number) Display width of the statusline.
|
|
|
|
• highlights: Array containing highlight information of the
|
|
|
|
statusline. Only included when the "highlights" key in {opts} is
|
|
|
|
true. Each element of the array is a |Dictionary| with these keys:
|
|
|
|
• start: (number) Byte index (0-based) of first character that uses
|
|
|
|
the highlight.
|
|
|
|
• group: (string) Name of highlight group.
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_exec_lua({code}, {args}) *nvim_exec_lua()*
|
|
|
|
Execute Lua code. Parameters (if any) are available as `...` inside the
|
|
|
|
chunk. The chunk can return a value.
|
|
|
|
|
|
|
|
Only statements are executed. To evaluate an expression, prefix it with
|
2022-03-13 05:48:14 -07:00
|
|
|
`return`: return my_function(...)
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {code} Lua code to execute
|
|
|
|
• {args} Arguments to the code
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Return: ~
|
|
|
|
Return value of Lua code if present or NIL.
|
|
|
|
|
2022-02-13 06:44:51 -07:00
|
|
|
nvim_feedkeys({keys}, {mode}, {escape_ks}) *nvim_feedkeys()*
|
2019-12-28 04:27:25 -07:00
|
|
|
Sends input-keys to Nvim, subject to various quirks controlled by `mode`
|
|
|
|
flags. This is a blocking call, unlike |nvim_input()|.
|
|
|
|
|
|
|
|
On execution error: does not fail, but updates v:errmsg.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2021-09-10 17:41:51 -07:00
|
|
|
To input sequences like <C-o> use |nvim_replace_termcodes()| (typically
|
2022-02-13 06:44:51 -07:00
|
|
|
with escape_ks=false) to replace |keycodes|, then pass the result to
|
2021-09-10 17:41:51 -07:00
|
|
|
nvim_feedkeys().
|
2020-07-01 18:57:03 -07:00
|
|
|
|
2022-11-23 04:31:49 -07:00
|
|
|
Example: >vim
|
2020-08-19 09:17:08 -07:00
|
|
|
:let key = nvim_replace_termcodes("<C-o>", v:true, v:false, v:true)
|
2022-02-13 06:44:51 -07:00
|
|
|
:call nvim_feedkeys(key, 'n', v:false)
|
2020-07-01 18:57:03 -07:00
|
|
|
<
|
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {keys} to be typed
|
|
|
|
• {mode} behavior flags, see |feedkeys()|
|
2022-11-28 18:45:48 -07:00
|
|
|
• {escape_ks} If true, escape K_SPECIAL bytes in `keys`. This should be
|
2022-02-13 06:44:51 -07:00
|
|
|
false if you already used |nvim_replace_termcodes()|, and
|
|
|
|
true otherwise.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• feedkeys()
|
|
|
|
• vim_strsave_escape_ks
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
nvim_get_api_info() *nvim_get_api_info()*
|
|
|
|
Returns a 2-tuple (Array), where item 0 is the current channel id and item
|
|
|
|
1 is the |api-metadata| map (Dictionary).
|
|
|
|
|
|
|
|
Return: ~
|
|
|
|
2-tuple [{channel-id}, {api-metadata}]
|
|
|
|
|
|
|
|
Attributes: ~
|
2022-04-30 16:16:16 -07:00
|
|
|
|api-fast|
|
|
|
|
|RPC| only
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
nvim_get_chan_info({chan}) *nvim_get_chan_info()*
|
2021-10-05 10:48:48 -07:00
|
|
|
Gets information about a channel.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Return: ~
|
|
|
|
Dictionary describing a channel, with these keys:
|
2021-10-05 10:48:48 -07:00
|
|
|
• "id" Channel id.
|
|
|
|
• "argv" (optional) Job arguments list.
|
|
|
|
• "stream" Stream underlying the channel.
|
2019-12-28 04:27:25 -07:00
|
|
|
• "stdio" stdin and stdout of this Nvim instance
|
|
|
|
• "stderr" stderr of this Nvim instance
|
|
|
|
• "socket" TCP/IP socket or named pipe
|
2021-10-05 10:48:48 -07:00
|
|
|
• "job" Job with communication over its stdio.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-05 10:48:48 -07:00
|
|
|
• "mode" How data received on the channel is interpreted.
|
|
|
|
• "bytes" Send and receive raw bytes.
|
|
|
|
• "terminal" |terminal| instance interprets ASCII sequences.
|
|
|
|
• "rpc" |RPC| communication on the channel is active.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-05 10:48:48 -07:00
|
|
|
• "pty" (optional) Name of pseudoterminal. On a POSIX system this is a
|
|
|
|
device path like "/dev/pts/1". If the name is unknown, the key will
|
2022-04-26 21:17:06 -07:00
|
|
|
still be present if a pty is used (e.g. for conpty on Windows).
|
2021-10-05 10:48:48 -07:00
|
|
|
• "buffer" (optional) Buffer with connected |terminal| instance.
|
|
|
|
• "client" (optional) Info about the peer (client on the other end of
|
|
|
|
the RPC channel), if provided by it via |nvim_set_client_info()|.
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
nvim_get_color_by_name({name}) *nvim_get_color_by_name()*
|
|
|
|
Returns the 24-bit RGB value of a |nvim_get_color_map()| color name or
|
|
|
|
"#rrggbb" hexadecimal string.
|
|
|
|
|
2022-11-23 04:31:49 -07:00
|
|
|
Example: >vim
|
2019-12-28 04:27:25 -07:00
|
|
|
:echo nvim_get_color_by_name("Pink")
|
|
|
|
:echo nvim_get_color_by_name("#cbcbcb")
|
|
|
|
<
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Color name or "#rrggbb" string
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Return: ~
|
|
|
|
24-bit RGB value, or -1 for invalid argument.
|
|
|
|
|
|
|
|
nvim_get_color_map() *nvim_get_color_map()*
|
|
|
|
Returns a map of color names and RGB values.
|
|
|
|
|
|
|
|
Keys are color names (e.g. "Aqua") and values are 24-bit RGB color values
|
|
|
|
(e.g. 65535).
|
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Map of color names and RGB values.
|
|
|
|
|
2021-10-05 10:48:48 -07:00
|
|
|
nvim_get_context({*opts}) *nvim_get_context()*
|
2019-12-28 04:27:25 -07:00
|
|
|
Gets a map of the current editor state.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {opts} Optional parameters.
|
2019-12-28 04:27:25 -07:00
|
|
|
• types: List of |context-types| ("regs", "jumps", "bufs",
|
|
|
|
"gvars", …) to gather, or empty for "all".
|
2018-11-15 18:00:04 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
map of global |context|.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
|
|
|
nvim_get_current_buf() *nvim_get_current_buf()*
|
2019-01-10 17:20:15 -07:00
|
|
|
Gets the current buffer.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2017-03-01 09:18:03 -07:00
|
|
|
Buffer handle
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_get_current_line() *nvim_get_current_line()*
|
|
|
|
Gets the current line.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Return: ~
|
|
|
|
Current line string
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_get_current_tabpage() *nvim_get_current_tabpage()*
|
|
|
|
Gets the current tabpage.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
Tabpage handle
|
2017-03-01 09:18:03 -07:00
|
|
|
|
|
|
|
nvim_get_current_win() *nvim_get_current_win()*
|
2019-01-10 17:20:15 -07:00
|
|
|
Gets the current window.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2017-03-01 09:18:03 -07:00
|
|
|
Window handle
|
|
|
|
|
2023-03-23 02:31:39 -07:00
|
|
|
nvim_get_hl({ns_id}, {*opts}) *nvim_get_hl()*
|
|
|
|
Gets all or specific highlight groups in a namespace.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2023-07-06 13:47:27 -07:00
|
|
|
Note: ~
|
|
|
|
• When the `link` attribute is defined in the highlight definition map,
|
2023-07-06 06:32:39 -07:00
|
|
|
other attributes will not be taking effect (see |:hi-link|).
|
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2023-03-23 02:31:39 -07:00
|
|
|
• {ns_id} Get highlight groups for namespace ns_id
|
|
|
|
|nvim_get_namespaces()|. Use 0 to get global highlight groups
|
|
|
|
|:highlight|.
|
|
|
|
• {opts} Options dict:
|
|
|
|
• name: (string) Get a highlight definition by name.
|
|
|
|
• id: (integer) Get a highlight definition by id.
|
|
|
|
• link: (boolean, default true) Show linked group name
|
|
|
|
instead of effective definition |:hi-link|.
|
2023-09-07 03:42:38 -07:00
|
|
|
• create: (boolean, default true) When highlight group
|
|
|
|
doesn't exist create it.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Return: ~
|
2023-03-23 02:31:39 -07:00
|
|
|
Highlight groups as a map from group name to a highlight definition
|
|
|
|
map as in |nvim_set_hl()|, or only a single highlight definition map
|
|
|
|
if requested by name or id.
|
2019-03-03 07:01:16 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_get_hl_id_by_name({name}) *nvim_get_hl_id_by_name()*
|
|
|
|
Gets a highlight group by name
|
2019-03-12 05:46:02 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
similar to |hlID()|, but allocates a new ID if not present.
|
2019-03-12 05:46:02 -07:00
|
|
|
|
2023-07-18 14:02:45 -07:00
|
|
|
nvim_get_hl_ns({*opts}) *nvim_get_hl_ns()*
|
|
|
|
Gets the active highlight namespace.
|
|
|
|
|
|
|
|
Parameters: ~
|
|
|
|
• {opts} Optional parameters
|
|
|
|
• winid: (number) |window-ID| for retrieving a window's
|
|
|
|
highlight namespace. A value of -1 is returned when
|
|
|
|
|nvim_win_set_hl_ns()| has not been called for the window
|
|
|
|
(or was called with a namespace of -1).
|
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Namespace id, or -1
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_get_keymap({mode}) *nvim_get_keymap()*
|
|
|
|
Gets a list of global (non-buffer-local) |mapping| definitions.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {mode} Mode short-name ("n", "i", "v", ...)
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
Return: ~
|
2022-08-01 20:13:22 -07:00
|
|
|
Array of |maparg()|-like dictionaries describing mappings. The
|
2019-12-28 04:27:25 -07:00
|
|
|
"buffer" key is always zero.
|
|
|
|
|
2021-11-01 06:46:26 -07:00
|
|
|
nvim_get_mark({name}, {opts}) *nvim_get_mark()*
|
2023-07-04 10:22:04 -07:00
|
|
|
Returns a `(row, col, buffer, buffername)` tuple representing the position
|
|
|
|
of the uppercase/file named mark. "End of line" column position is
|
|
|
|
returned as |v:maxcol| (big number). See |mark-motions|.
|
2021-10-05 08:49:20 -07:00
|
|
|
|
|
|
|
Marks are (1,0)-indexed. |api-indexing|
|
|
|
|
|
2023-07-06 13:47:27 -07:00
|
|
|
Note: ~
|
|
|
|
• Lowercase name (or other buffer-local mark) is an error.
|
2021-10-05 08:49:20 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Mark name
|
|
|
|
• {opts} Optional parameters. Reserved for future use.
|
2021-10-05 08:49:20 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
4-tuple (row, col, buffer, buffername), (0, 0, 0, '') if the mark is
|
|
|
|
not set.
|
|
|
|
|
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_buf_set_mark()|
|
|
|
|
• |nvim_del_mark()|
|
2021-10-05 08:49:20 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_get_mode() *nvim_get_mode()*
|
|
|
|
Gets the current mode. |mode()| "blocking" is true if Nvim is waiting for
|
|
|
|
input.
|
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Dictionary { "mode": String, "blocking": Boolean }
|
|
|
|
|
|
|
|
Attributes: ~
|
2022-04-30 16:16:16 -07:00
|
|
|
|api-fast|
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
nvim_get_proc({pid}) *nvim_get_proc()*
|
2022-03-13 05:48:14 -07:00
|
|
|
Gets info describing process `pid`.
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Map of process properties, or NIL if process not found.
|
|
|
|
|
|
|
|
nvim_get_proc_children({pid}) *nvim_get_proc_children()*
|
2022-03-13 05:48:14 -07:00
|
|
|
Gets the immediate children of process `pid`.
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Array of child process ids, empty if process not found.
|
|
|
|
|
2020-07-02 04:09:17 -07:00
|
|
|
nvim_get_runtime_file({name}, {all}) *nvim_get_runtime_file()*
|
|
|
|
Find files in runtime directories
|
|
|
|
|
2022-09-25 16:58:27 -07:00
|
|
|
"name" can contain wildcards. For example
|
2020-07-02 04:09:17 -07:00
|
|
|
nvim_get_runtime_file("colors/*.vim", true) will return all color scheme
|
2020-12-03 18:59:36 -07:00
|
|
|
files. Always use forward slashes (/) in the search pattern for
|
|
|
|
subdirectories regardless of platform.
|
2020-07-02 04:09:17 -07:00
|
|
|
|
|
|
|
It is not an error to not find any files. An empty array is returned then.
|
|
|
|
|
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes:
- Deprecated all `vim.lsp.util.{*diagnostics*}()` functions.
- Instead, all functions must be found in vim.lsp.diagnostic
- For now, they issue a warning ONCE per neovim session. In a
"little while" we will remove them completely.
- `vim.lsp.callbacks` has moved to `vim.lsp.handlers`.
- For a "little while" we will just redirect `vim.lsp.callbacks` to
`vim.lsp.handlers`. However, we will remove this at some point, so
it is recommended that you change all of your references to
`callbacks` into `handlers`.
- This also means that for functions like |vim.lsp.start_client()|
and similar, keyword style arguments have moved from "callbacks"
to "handlers". Once again, these are currently being forward, but
will cease to be forwarded in a "little while".
- Changed the highlight groups for LspDiagnostic highlight as they were
inconsistently named.
- For more information, see |lsp-highlight-diagnostics|
- Changed the sign group names as well, to be consistent with
|lsp-highlight-diagnostics|
General Enhancements:
- Rewrote much of the getting started help document for lsp. It also
provides a much nicer configuration strategy, so as to not recommend
globally overwriting builtin neovim mappings.
LSP Enhancements:
- Introduced the concept of |lsp-handlers| which will allow much better
customization for users without having to copy & paste entire files /
functions / etc.
Diagnostic Enhancements:
- "goto next diagnostic" |vim.lsp.diagnostic.goto_next()|
- "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()|
- For each of the gotos, auto open diagnostics is available as a
configuration option
- Configurable diagnostic handling:
- See |vim.lsp.diagnostic.on_publish_diagnostics()|
- Delay display until after insert mode
- Configure signs
- Configure virtual text
- Configure underline
- Set the location list with the buffers diagnostics.
- See |vim.lsp.diagnostic.set_loclist()|
- Better performance for getting counts and line diagnostics
- They are now cached on save, to enhance lookups.
- Particularly useful for checking in statusline, etc.
- Actual testing :)
- See ./test/functional/plugin/lsp/diagnostic_spec.lua
- Added `guisp` for underline highlighting
NOTE: "a little while" means enough time to feel like most plugins and
plugin authors have had a chance to refactor their code to use the
updated calls. Then we will remove them completely. There is no need to
keep them, because we don't have any released version of neovim that
exposes these APIs. I'm trying to be nice to people following HEAD :)
Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
2020-11-12 20:21:34 -07:00
|
|
|
Attributes: ~
|
2022-04-30 16:16:16 -07:00
|
|
|
|api-fast|
|
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes:
- Deprecated all `vim.lsp.util.{*diagnostics*}()` functions.
- Instead, all functions must be found in vim.lsp.diagnostic
- For now, they issue a warning ONCE per neovim session. In a
"little while" we will remove them completely.
- `vim.lsp.callbacks` has moved to `vim.lsp.handlers`.
- For a "little while" we will just redirect `vim.lsp.callbacks` to
`vim.lsp.handlers`. However, we will remove this at some point, so
it is recommended that you change all of your references to
`callbacks` into `handlers`.
- This also means that for functions like |vim.lsp.start_client()|
and similar, keyword style arguments have moved from "callbacks"
to "handlers". Once again, these are currently being forward, but
will cease to be forwarded in a "little while".
- Changed the highlight groups for LspDiagnostic highlight as they were
inconsistently named.
- For more information, see |lsp-highlight-diagnostics|
- Changed the sign group names as well, to be consistent with
|lsp-highlight-diagnostics|
General Enhancements:
- Rewrote much of the getting started help document for lsp. It also
provides a much nicer configuration strategy, so as to not recommend
globally overwriting builtin neovim mappings.
LSP Enhancements:
- Introduced the concept of |lsp-handlers| which will allow much better
customization for users without having to copy & paste entire files /
functions / etc.
Diagnostic Enhancements:
- "goto next diagnostic" |vim.lsp.diagnostic.goto_next()|
- "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()|
- For each of the gotos, auto open diagnostics is available as a
configuration option
- Configurable diagnostic handling:
- See |vim.lsp.diagnostic.on_publish_diagnostics()|
- Delay display until after insert mode
- Configure signs
- Configure virtual text
- Configure underline
- Set the location list with the buffers diagnostics.
- See |vim.lsp.diagnostic.set_loclist()|
- Better performance for getting counts and line diagnostics
- They are now cached on save, to enhance lookups.
- Particularly useful for checking in statusline, etc.
- Actual testing :)
- See ./test/functional/plugin/lsp/diagnostic_spec.lua
- Added `guisp` for underline highlighting
NOTE: "a little while" means enough time to feel like most plugins and
plugin authors have had a chance to refactor their code to use the
updated calls. Then we will remove them completely. There is no need to
keep them, because we don't have any released version of neovim that
exposes these APIs. I'm trying to be nice to people following HEAD :)
Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
2020-11-12 20:21:34 -07:00
|
|
|
|
2020-07-02 04:09:17 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} pattern of files to search for
|
|
|
|
• {all} whether to return all matches or only the first
|
2020-07-02 04:09:17 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
list of absolute paths to the found files
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_get_var({name}) *nvim_get_var()*
|
|
|
|
Gets a global (g:) variable.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Variable name
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Variable value
|
|
|
|
|
|
|
|
nvim_get_vvar({name}) *nvim_get_vvar()*
|
|
|
|
Gets a v: variable.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Variable name
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Variable value
|
|
|
|
|
|
|
|
nvim_input({keys}) *nvim_input()*
|
|
|
|
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).
|
|
|
|
|
|
|
|
On execution error: does not fail, but updates v:errmsg.
|
|
|
|
|
2023-07-06 13:47:27 -07:00
|
|
|
Note: ~
|
|
|
|
• |keycodes| like <CR> are translated, so "<" is special. To input a
|
2019-12-28 04:27:25 -07:00
|
|
|
literal "<", send <LT>.
|
2023-07-06 13:47:27 -07:00
|
|
|
• For mouse events use |nvim_input_mouse()|. The pseudokey form
|
2019-12-28 04:27:25 -07:00
|
|
|
"<LeftMouse><col,row>" is deprecated since |api-level| 6.
|
|
|
|
|
|
|
|
Attributes: ~
|
2022-04-30 16:16:16 -07:00
|
|
|
|api-fast|
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {keys} to be typed
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Number of bytes actually written (can be fewer than requested if the
|
|
|
|
buffer becomes full).
|
|
|
|
|
|
|
|
*nvim_input_mouse()*
|
|
|
|
nvim_input_mouse({button}, {action}, {modifier}, {grid}, {row}, {col})
|
|
|
|
Send mouse event from GUI.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Non-blocking: does not wait on any result, but queues the event to be
|
|
|
|
processed soon by the event loop.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2023-07-06 13:47:27 -07:00
|
|
|
Note: ~
|
|
|
|
• Currently this doesn't support "scripting" multiple mouse events by
|
2019-12-28 04:27:25 -07:00
|
|
|
calling it multiple times in a loop: the intermediate mouse positions
|
|
|
|
will be ignored. It should be used to implement real-time mouse input
|
|
|
|
in a GUI. The deprecated pseudokey form ("<LeftMouse><col,row>") of
|
2021-07-08 08:42:31 -07:00
|
|
|
|nvim_input()| has the same limitation.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Attributes: ~
|
2022-04-30 16:16:16 -07:00
|
|
|
|api-fast|
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {button} Mouse button: one of "left", "right", "middle", "wheel",
|
2022-07-23 22:58:29 -07:00
|
|
|
"move".
|
2022-10-05 05:15:55 -07:00
|
|
|
• {action} For ordinary buttons, one of "press", "drag", "release".
|
2019-12-28 04:27:25 -07:00
|
|
|
For the wheel, one of "up", "down", "left", "right".
|
2022-07-23 22:58:29 -07:00
|
|
|
Ignored for "move".
|
2022-10-05 05:15:55 -07:00
|
|
|
• {modifier} String of modifiers each represented by a single char. The
|
2019-12-28 04:27:25 -07:00
|
|
|
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.
|
2022-10-05 05:15:55 -07:00
|
|
|
• {grid} Grid number if the client uses |ui-multigrid|, else 0.
|
|
|
|
• {row} Mouse row-position (zero-based, like redraw events)
|
|
|
|
• {col} Mouse column-position (zero-based, like redraw events)
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
nvim_list_bufs() *nvim_list_bufs()*
|
|
|
|
Gets the current list of buffer handles
|
|
|
|
|
2022-03-13 05:48:14 -07:00
|
|
|
Includes unlisted (unloaded/deleted) buffers, like `:ls!`. Use
|
|
|
|
|nvim_buf_is_loaded()| to check if a buffer is loaded.
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
List of buffer handles
|
|
|
|
|
|
|
|
nvim_list_chans() *nvim_list_chans()*
|
|
|
|
Get information about all open channels.
|
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Array of Dictionaries, each describing a channel with the format
|
|
|
|
specified at |nvim_get_chan_info()|.
|
|
|
|
|
|
|
|
nvim_list_runtime_paths() *nvim_list_runtime_paths()*
|
2023-06-19 05:40:53 -07:00
|
|
|
Gets the paths contained in |runtime-search-path|.
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
List of paths
|
|
|
|
|
|
|
|
nvim_list_tabpages() *nvim_list_tabpages()*
|
|
|
|
Gets the current list of tabpage handles.
|
|
|
|
|
|
|
|
Return: ~
|
|
|
|
List of tabpage handles
|
|
|
|
|
|
|
|
nvim_list_uis() *nvim_list_uis()*
|
|
|
|
Gets a list of dictionaries representing attached UIs.
|
|
|
|
|
|
|
|
Return: ~
|
|
|
|
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|
|
2023-01-14 14:24:19 -07:00
|
|
|
• "chan" |channel-id| of remote UI
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
nvim_list_wins() *nvim_list_wins()*
|
|
|
|
Gets the current list of window handles.
|
|
|
|
|
|
|
|
Return: ~
|
|
|
|
List of window handles
|
|
|
|
|
|
|
|
nvim_load_context({dict}) *nvim_load_context()*
|
|
|
|
Sets the current editor state from the given |context| map.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {dict} |Context| map.
|
2019-12-28 04:27:25 -07:00
|
|
|
|
2021-02-15 01:26:34 -07:00
|
|
|
nvim_notify({msg}, {log_level}, {opts}) *nvim_notify()*
|
|
|
|
Notify the user with a message
|
|
|
|
|
|
|
|
Relays the call to vim.notify . By default forwards your message in the
|
2021-07-08 08:42:31 -07:00
|
|
|
echo area but can be overridden to trigger desktop notifications.
|
2021-02-15 01:26:34 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {msg} Message to display to the user
|
|
|
|
• {log_level} The log level
|
|
|
|
• {opts} Reserved for future use.
|
2021-02-15 01:26:34 -07:00
|
|
|
|
2021-03-15 01:58:39 -07:00
|
|
|
nvim_open_term({buffer}, {opts}) *nvim_open_term()*
|
|
|
|
Open a terminal instance in a buffer
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-03-15 01:58:39 -07:00
|
|
|
By default (and currently the only option) the terminal will not be
|
|
|
|
connected to an external process. Instead, input send on the channel will
|
|
|
|
be echoed directly by the terminal. This is useful to display ANSI
|
2021-07-08 08:42:31 -07:00
|
|
|
terminal sequences returned as part of a rpc message, or similar.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-03-15 01:58:39 -07:00
|
|
|
Note: to directly initiate the terminal using the right size, display the
|
|
|
|
buffer in a configured window before calling this. For instance, for a
|
|
|
|
floating display, first create an empty buffer using |nvim_create_buf()|,
|
|
|
|
then display it using |nvim_open_win()|, and then call this function. Then
|
2021-10-04 12:09:32 -07:00
|
|
|
|nvim_chan_send()| can be called immediately to process sequences in a
|
2021-03-15 01:58:39 -07:00
|
|
|
virtual terminal having the intended size.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2023-06-23 14:32:07 -07:00
|
|
|
Attributes: ~
|
|
|
|
not allowed when |textlock| is active
|
|
|
|
|
2021-03-15 01:58:39 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} the buffer to use (expected to be empty)
|
|
|
|
• {opts} Optional parameters.
|
2023-06-22 03:44:51 -07:00
|
|
|
• on_input: Lua callback for input sent, i e keypresses in
|
2021-11-18 14:50:55 -07:00
|
|
|
terminal mode. Note: keypresses are sent raw as they would
|
|
|
|
be to the pty master end. For instance, a carriage return
|
|
|
|
is sent as a "\r", not as a "\n". |textlock| applies. It
|
2022-09-25 16:58:27 -07:00
|
|
|
is possible to call |nvim_chan_send()| directly in the
|
2021-11-18 14:50:55 -07:00
|
|
|
callback however. ["input", term, bufnr, data]
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-04-24 03:47:52 -07:00
|
|
|
Return: ~
|
|
|
|
Channel id, or 0 on error
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_out_write({str}) *nvim_out_write()*
|
|
|
|
Writes a message to the Vim output buffer. Does not append "\n", the
|
|
|
|
message is buffered (won't display) until a linefeed is written.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {str} Message
|
2018-11-15 18:00:04 -07:00
|
|
|
|
2019-08-29 15:16:19 -07:00
|
|
|
nvim_paste({data}, {crlf}, {phase}) *nvim_paste()*
|
2019-08-24 04:54:27 -07:00
|
|
|
Pastes at cursor, in any mode.
|
|
|
|
|
|
|
|
Invokes the `vim.paste` handler, which handles each mode appropriately.
|
|
|
|
Sets redo/undo. Faster than |nvim_input()|. Lines break at LF ("\n").
|
|
|
|
|
|
|
|
Errors ('nomodifiable', `vim.paste()` failure, …) are reflected in `err`
|
|
|
|
but do not affect the return value (which is strictly decided by
|
|
|
|
`vim.paste()`). On error, subsequent calls are ignored ("drained") until
|
|
|
|
the next paste is initiated (phase 1 or -1).
|
|
|
|
|
2020-11-24 05:37:29 -07:00
|
|
|
Attributes: ~
|
|
|
|
not allowed when |textlock| is active
|
|
|
|
|
2019-08-24 04:54:27 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {data} Multiline input. May be binary (containing NUL bytes).
|
|
|
|
• {crlf} Also break lines at CR and CRLF.
|
|
|
|
• {phase} -1: paste in a single call (i.e. without streaming). To
|
2019-08-24 04:54:27 -07:00
|
|
|
"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)
|
|
|
|
|
|
|
|
Return: ~
|
|
|
|
|
|
|
|
• true: Client may continue pasting.
|
|
|
|
• false: Client must cancel the paste.
|
|
|
|
|
|
|
|
nvim_put({lines}, {type}, {after}, {follow}) *nvim_put()*
|
|
|
|
Puts text at cursor, in any mode.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-08-24 04:54:27 -07:00
|
|
|
Compare |:put| and |p| which are always linewise.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2020-11-24 05:37:29 -07:00
|
|
|
Attributes: ~
|
|
|
|
not allowed when |textlock| is active
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-08-24 04:54:27 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {lines} |readfile()|-style list of lines. |channel-lines|
|
|
|
|
• {type} Edit behavior: any |getregtype()| result, or:
|
2019-08-31 03:44:42 -07:00
|
|
|
• "b" |blockwise-visual| mode (may include width, e.g. "b3")
|
2019-11-25 02:08:02 -07:00
|
|
|
• "c" |charwise| mode
|
2019-08-24 04:54:27 -07:00
|
|
|
• "l" |linewise| mode
|
2019-08-31 03:44:42 -07:00
|
|
|
• "" guess by contents, see |setreg()|
|
2022-10-05 05:15:55 -07:00
|
|
|
• {after} If true insert after cursor (like |p|), or before (like
|
2021-03-11 08:11:11 -07:00
|
|
|
|P|).
|
2022-10-05 05:15:55 -07:00
|
|
|
• {follow} If true place cursor at end of inserted text.
|
2019-08-24 04:54:27 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
*nvim_replace_termcodes()*
|
|
|
|
nvim_replace_termcodes({str}, {from_part}, {do_lt}, {special})
|
|
|
|
Replaces terminal codes and |keycodes| (<CR>, <Esc>, ...) in a string with
|
|
|
|
the internal representation.
|
API: nvim_set_keymap, nvim_del_keymap #9924
closes #9136
- Treat empty {rhs} like <Nop>
- getchar.c: Pull "repl. MapArg termcodes" into func
The "preprocessing code" surrounding the replace_termcodes calls needs
to invoke replace_termcodes, and also check if RHS is equal to "<Nop>".
To reduce code duplication, factor this out into a helper function.
Also add an rhs_is_noop flag to MapArguments; buf_do_map_explicit
expects an empty {rhs} string for "<Nop>", but also needs to distinguish
that from something like ":map lhs<cr>" where no {rhs} was provided.
- getchar.c: Use allocated buffer for rhs in MapArgs
Since the MAXMAPLEN limit does not apply to the RHS of a mapping (or
else an RHS that calls a really long autoload function from a plugin
would be incorrectly rejected as being too long), use an allocated
buffer for RHS rather than a static buffer of length MAXMAPLEN + 1.
- Mappings LHS and RHS can contain literal space characters, newlines, etc.
- getchar.c: replace_termcodes in str_to_mapargs
It makes sense to do this; str_to_mapargs is, intuitively, supposed to
take a "raw" command string and parse it into a totally "do_map-ready"
struct.
- api/vim.c: Update lhs, rhs len after replace_termcodes
Fixes a bug in which replace_termcodes changes the length of lhs or rhs,
but the later search through the mappings/abbreviations hashtables
still uses the old length value. This would cause the search to fail
erroneously and throw 'E31: No such mapping' errors or 'E24: No such
abbreviation' errors.
- getchar: Create new map_arguments struct
So that a string of map arguments can be parsed into a more useful, more
portable data structure.
- getchar.c: Add buf_do_map function
Exactly the same as the old do_map, but replace the hardcoded references
to the global `buf_T* curbuf` with a function parameter so that we can
invoke it from nvim_buf_set_keymap.
- Remove gettext calls in do_map error handling
2019-05-12 02:44:48 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {str} String to be converted.
|
|
|
|
• {from_part} Legacy Vim parameter. Usually true.
|
|
|
|
• {do_lt} Also translate <lt>. Ignored if `special` is false.
|
|
|
|
• {special} Replace |keycodes|, e.g. <CR> becomes a "\r" char.
|
API: nvim_set_keymap, nvim_del_keymap #9924
closes #9136
- Treat empty {rhs} like <Nop>
- getchar.c: Pull "repl. MapArg termcodes" into func
The "preprocessing code" surrounding the replace_termcodes calls needs
to invoke replace_termcodes, and also check if RHS is equal to "<Nop>".
To reduce code duplication, factor this out into a helper function.
Also add an rhs_is_noop flag to MapArguments; buf_do_map_explicit
expects an empty {rhs} string for "<Nop>", but also needs to distinguish
that from something like ":map lhs<cr>" where no {rhs} was provided.
- getchar.c: Use allocated buffer for rhs in MapArgs
Since the MAXMAPLEN limit does not apply to the RHS of a mapping (or
else an RHS that calls a really long autoload function from a plugin
would be incorrectly rejected as being too long), use an allocated
buffer for RHS rather than a static buffer of length MAXMAPLEN + 1.
- Mappings LHS and RHS can contain literal space characters, newlines, etc.
- getchar.c: replace_termcodes in str_to_mapargs
It makes sense to do this; str_to_mapargs is, intuitively, supposed to
take a "raw" command string and parse it into a totally "do_map-ready"
struct.
- api/vim.c: Update lhs, rhs len after replace_termcodes
Fixes a bug in which replace_termcodes changes the length of lhs or rhs,
but the later search through the mappings/abbreviations hashtables
still uses the old length value. This would cause the search to fail
erroneously and throw 'E31: No such mapping' errors or 'E24: No such
abbreviation' errors.
- getchar: Create new map_arguments struct
So that a string of map arguments can be parsed into a more useful, more
portable data structure.
- getchar.c: Add buf_do_map function
Exactly the same as the old do_map, but replace the hardcoded references
to the global `buf_T* curbuf` with a function parameter so that we can
invoke it from nvim_buf_set_keymap.
- Remove gettext calls in do_map error handling
2019-05-12 02:44:48 -07:00
|
|
|
|
2019-05-12 04:04:48 -07:00
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• replace_termcodes
|
|
|
|
• cpoptions
|
API: nvim_set_keymap, nvim_del_keymap #9924
closes #9136
- Treat empty {rhs} like <Nop>
- getchar.c: Pull "repl. MapArg termcodes" into func
The "preprocessing code" surrounding the replace_termcodes calls needs
to invoke replace_termcodes, and also check if RHS is equal to "<Nop>".
To reduce code duplication, factor this out into a helper function.
Also add an rhs_is_noop flag to MapArguments; buf_do_map_explicit
expects an empty {rhs} string for "<Nop>", but also needs to distinguish
that from something like ":map lhs<cr>" where no {rhs} was provided.
- getchar.c: Use allocated buffer for rhs in MapArgs
Since the MAXMAPLEN limit does not apply to the RHS of a mapping (or
else an RHS that calls a really long autoload function from a plugin
would be incorrectly rejected as being too long), use an allocated
buffer for RHS rather than a static buffer of length MAXMAPLEN + 1.
- Mappings LHS and RHS can contain literal space characters, newlines, etc.
- getchar.c: replace_termcodes in str_to_mapargs
It makes sense to do this; str_to_mapargs is, intuitively, supposed to
take a "raw" command string and parse it into a totally "do_map-ready"
struct.
- api/vim.c: Update lhs, rhs len after replace_termcodes
Fixes a bug in which replace_termcodes changes the length of lhs or rhs,
but the later search through the mappings/abbreviations hashtables
still uses the old length value. This would cause the search to fail
erroneously and throw 'E31: No such mapping' errors or 'E24: No such
abbreviation' errors.
- getchar: Create new map_arguments struct
So that a string of map arguments can be parsed into a more useful, more
portable data structure.
- getchar.c: Add buf_do_map function
Exactly the same as the old do_map, but replace the hardcoded references
to the global `buf_T* curbuf` with a function parameter so that we can
invoke it from nvim_buf_set_keymap.
- Remove gettext calls in do_map error handling
2019-05-12 02:44:48 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
*nvim_select_popupmenu_item()*
|
|
|
|
nvim_select_popupmenu_item({item}, {insert}, {finish}, {opts})
|
2022-10-17 06:00:50 -07:00
|
|
|
Selects an item in the completion popup menu.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-10-17 06:00:50 -07:00
|
|
|
If neither |ins-completion| nor |cmdline-completion| popup menu is active
|
|
|
|
this API call is silently ignored. Useful for an external UI using
|
|
|
|
|ui-popupmenu| to control the popup menu with the mouse. Can also be used
|
|
|
|
in a mapping; use <Cmd> |:map-cmd| or a Lua mapping to ensure the mapping
|
|
|
|
doesn't end completion mode.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {item} Index (zero-based) of the item to select. Value of -1
|
2019-12-28 04:27:25 -07:00
|
|
|
selects nothing and restores the original text.
|
2022-10-17 06:00:50 -07:00
|
|
|
• {insert} For |ins-completion|, whether the selection should be
|
|
|
|
inserted in the buffer. Ignored for |cmdline-completion|.
|
|
|
|
• {finish} Finish the completion and dismiss the popup menu. Implies
|
|
|
|
{insert}.
|
2022-10-05 05:15:55 -07:00
|
|
|
• {opts} Optional parameters. Reserved for future use.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-10 15:20:39 -07:00
|
|
|
*nvim_set_client_info()*
|
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes:
- Deprecated all `vim.lsp.util.{*diagnostics*}()` functions.
- Instead, all functions must be found in vim.lsp.diagnostic
- For now, they issue a warning ONCE per neovim session. In a
"little while" we will remove them completely.
- `vim.lsp.callbacks` has moved to `vim.lsp.handlers`.
- For a "little while" we will just redirect `vim.lsp.callbacks` to
`vim.lsp.handlers`. However, we will remove this at some point, so
it is recommended that you change all of your references to
`callbacks` into `handlers`.
- This also means that for functions like |vim.lsp.start_client()|
and similar, keyword style arguments have moved from "callbacks"
to "handlers". Once again, these are currently being forward, but
will cease to be forwarded in a "little while".
- Changed the highlight groups for LspDiagnostic highlight as they were
inconsistently named.
- For more information, see |lsp-highlight-diagnostics|
- Changed the sign group names as well, to be consistent with
|lsp-highlight-diagnostics|
General Enhancements:
- Rewrote much of the getting started help document for lsp. It also
provides a much nicer configuration strategy, so as to not recommend
globally overwriting builtin neovim mappings.
LSP Enhancements:
- Introduced the concept of |lsp-handlers| which will allow much better
customization for users without having to copy & paste entire files /
functions / etc.
Diagnostic Enhancements:
- "goto next diagnostic" |vim.lsp.diagnostic.goto_next()|
- "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()|
- For each of the gotos, auto open diagnostics is available as a
configuration option
- Configurable diagnostic handling:
- See |vim.lsp.diagnostic.on_publish_diagnostics()|
- Delay display until after insert mode
- Configure signs
- Configure virtual text
- Configure underline
- Set the location list with the buffers diagnostics.
- See |vim.lsp.diagnostic.set_loclist()|
- Better performance for getting counts and line diagnostics
- They are now cached on save, to enhance lookups.
- Particularly useful for checking in statusline, etc.
- Actual testing :)
- See ./test/functional/plugin/lsp/diagnostic_spec.lua
- Added `guisp` for underline highlighting
NOTE: "a little while" means enough time to feel like most plugins and
plugin authors have had a chance to refactor their code to use the
updated calls. Then we will remove them completely. There is no need to
keep them, because we don't have any released version of neovim that
exposes these APIs. I'm trying to be nice to people following HEAD :)
Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
2020-11-12 20:21:34 -07:00
|
|
|
nvim_set_client_info({name}, {version}, {type}, {methods}, {attributes})
|
2019-05-25 01:00:41 -07:00
|
|
|
Self-identifies the client.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-05-25 01:00:41 -07:00
|
|
|
The client/plugin/application should call this after connecting, to
|
|
|
|
provide hints about its identity and purpose, for debugging and
|
|
|
|
orchestration.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-05-25 01:00:41 -07:00
|
|
|
Can be called more than once; the caller should merge old info if
|
|
|
|
appropriate. Example: library first identifies the channel, then a plugin
|
|
|
|
using that library later identifies itself.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2023-07-06 13:47:27 -07:00
|
|
|
Note: ~
|
|
|
|
• "Something is better than nothing". You don't need to include all the
|
2019-05-25 01:00:41 -07:00
|
|
|
fields.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-03-03 07:01:16 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Short name for the connected client
|
|
|
|
• {version} Dictionary describing the version, with these (optional)
|
2019-03-03 07:01:16 -07:00
|
|
|
keys:
|
2019-05-25 01:00:41 -07:00
|
|
|
• "major" major version (defaults to 0 if not set, for
|
2019-03-03 07:01:16 -07:00
|
|
|
no release yet)
|
2019-05-25 01:00:41 -07:00
|
|
|
• "minor" minor version
|
|
|
|
• "patch" patch number
|
|
|
|
• "prerelease" string describing a prerelease, like
|
2019-03-03 07:01:16 -07:00
|
|
|
"dev" or "beta1"
|
2019-05-25 01:00:41 -07:00
|
|
|
• "commit" hash or similar identifier of commit
|
2022-10-05 05:15:55 -07:00
|
|
|
• {type} Must be one of the following values. Client libraries
|
2019-03-03 07:01:16 -07:00
|
|
|
should default to "remote" unless overridden by the
|
|
|
|
user.
|
2023-08-06 08:19:51 -07:00
|
|
|
• "remote" remote client connected "Nvim flavored"
|
|
|
|
MessagePack-RPC (responses must be in reverse order of
|
|
|
|
requests). |msgpack-rpc|
|
|
|
|
• "msgpack-rpc" remote client connected to Nvim via
|
|
|
|
fully MessagePack-RPC compliant protocol.
|
2019-05-25 01:00:41 -07:00
|
|
|
• "ui" gui frontend
|
|
|
|
• "embedder" application using Nvim as a component (for
|
2019-03-03 07:01:16 -07:00
|
|
|
example, IDE/editor implementing a vim mode).
|
2019-05-25 01:00:41 -07:00
|
|
|
• "host" plugin host, typically started by nvim
|
|
|
|
• "plugin" single plugin, started by nvim
|
2022-10-05 05:15:55 -07:00
|
|
|
• {methods} Builtin methods in the client. For a host, this does not
|
2018-06-10 15:20:39 -07:00
|
|
|
include plugin methods which will be discovered later.
|
|
|
|
The key should be the method name, the values are dicts
|
2019-03-03 07:01:16 -07:00
|
|
|
with these (optional) keys (more keys may be added in
|
|
|
|
future versions of Nvim, thus unknown keys are ignored.
|
|
|
|
Clients must only use keys defined in this or later
|
|
|
|
versions of Nvim):
|
2019-05-25 01:00:41 -07:00
|
|
|
• "async" if true, send as a notification. If false or
|
2019-03-03 07:01:16 -07:00
|
|
|
unspecified, use a blocking request
|
2019-05-25 01:00:41 -07:00
|
|
|
• "nargs" Number of arguments. Could be a single integer
|
2019-03-03 07:01:16 -07:00
|
|
|
or an array of two integers, minimum and maximum
|
|
|
|
inclusive.
|
2022-10-05 05:15:55 -07:00
|
|
|
• {attributes} Arbitrary string:string map of informal client
|
2019-03-03 07:01:16 -07:00
|
|
|
properties. Suggested keys:
|
2019-05-25 01:00:41 -07:00
|
|
|
• "website": Client homepage URL (e.g. GitHub
|
2019-03-03 07:01:16 -07:00
|
|
|
repository)
|
2019-05-25 01:00:41 -07:00
|
|
|
• "license": License description ("Apache 2", "GPLv3",
|
2019-03-03 07:01:16 -07:00
|
|
|
"MIT", …)
|
2019-05-25 01:00:41 -07:00
|
|
|
• "logo": URI or path to image, preferably small logo or
|
2019-03-03 07:01:16 -07:00
|
|
|
icon. .png or .svg format is preferred.
|
2018-06-10 15:20:39 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_set_current_buf({buffer}) *nvim_set_current_buf()*
|
|
|
|
Sets the current buffer.
|
2018-06-10 15:20:39 -07:00
|
|
|
|
2020-11-24 05:37:29 -07:00
|
|
|
Attributes: ~
|
2023-04-20 13:17:25 -07:00
|
|
|
not allowed when |textlock| is active or in the |cmdwin|
|
2020-11-24 05:37:29 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle
|
2018-06-10 15:20:39 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_set_current_dir({dir}) *nvim_set_current_dir()*
|
|
|
|
Changes the global working directory.
|
2018-06-10 15:20:39 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {dir} Directory path
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_set_current_line({line}) *nvim_set_current_line()*
|
|
|
|
Sets the current line.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2020-11-24 05:37:29 -07:00
|
|
|
Attributes: ~
|
|
|
|
not allowed when |textlock| is active
|
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {line} Line contents
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_set_current_tabpage({tabpage}) *nvim_set_current_tabpage()*
|
|
|
|
Sets the current tabpage.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2020-11-24 05:37:29 -07:00
|
|
|
Attributes: ~
|
2023-04-20 13:17:25 -07:00
|
|
|
not allowed when |textlock| is active or in the |cmdwin|
|
2020-11-24 05:37:29 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {tabpage} Tabpage handle
|
2017-11-14 02:47:49 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_set_current_win({window}) *nvim_set_current_win()*
|
|
|
|
Sets the current window.
|
2017-11-14 02:47:49 -07:00
|
|
|
|
2020-11-24 05:37:29 -07:00
|
|
|
Attributes: ~
|
2023-04-20 13:17:25 -07:00
|
|
|
not allowed when |textlock| is active or in the |cmdwin|
|
2020-11-24 05:37:29 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle
|
2019-03-03 07:01:16 -07:00
|
|
|
|
2022-02-13 06:44:51 -07:00
|
|
|
nvim_set_hl({ns_id}, {name}, {*val}) *nvim_set_hl()*
|
2022-03-13 05:42:12 -07:00
|
|
|
Sets a highlight group.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2023-07-06 13:47:27 -07:00
|
|
|
Note: ~
|
|
|
|
• Unlike the `:highlight` command which can update a highlight group, this
|
|
|
|
function completely replaces the definition. For example:
|
2022-05-15 14:06:06 -07:00
|
|
|
`nvim_set_hl(0, 'Visual', {})` will clear the highlight group
|
|
|
|
'Visual'.
|
2023-07-06 13:47:27 -07:00
|
|
|
• The fg and bg keys also accept the string values `"fg"` or `"bg"` which
|
|
|
|
act as aliases to the corresponding foreground and background values
|
|
|
|
of the Normal group. If the Normal group has not been defined, using
|
|
|
|
these values results in an error.
|
|
|
|
• If `link` is used in combination with other attributes; only the `link`
|
|
|
|
will take effect (see |:hi-link|).
|
2023-03-31 03:52:53 -07:00
|
|
|
|
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes:
- Deprecated all `vim.lsp.util.{*diagnostics*}()` functions.
- Instead, all functions must be found in vim.lsp.diagnostic
- For now, they issue a warning ONCE per neovim session. In a
"little while" we will remove them completely.
- `vim.lsp.callbacks` has moved to `vim.lsp.handlers`.
- For a "little while" we will just redirect `vim.lsp.callbacks` to
`vim.lsp.handlers`. However, we will remove this at some point, so
it is recommended that you change all of your references to
`callbacks` into `handlers`.
- This also means that for functions like |vim.lsp.start_client()|
and similar, keyword style arguments have moved from "callbacks"
to "handlers". Once again, these are currently being forward, but
will cease to be forwarded in a "little while".
- Changed the highlight groups for LspDiagnostic highlight as they were
inconsistently named.
- For more information, see |lsp-highlight-diagnostics|
- Changed the sign group names as well, to be consistent with
|lsp-highlight-diagnostics|
General Enhancements:
- Rewrote much of the getting started help document for lsp. It also
provides a much nicer configuration strategy, so as to not recommend
globally overwriting builtin neovim mappings.
LSP Enhancements:
- Introduced the concept of |lsp-handlers| which will allow much better
customization for users without having to copy & paste entire files /
functions / etc.
Diagnostic Enhancements:
- "goto next diagnostic" |vim.lsp.diagnostic.goto_next()|
- "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()|
- For each of the gotos, auto open diagnostics is available as a
configuration option
- Configurable diagnostic handling:
- See |vim.lsp.diagnostic.on_publish_diagnostics()|
- Delay display until after insert mode
- Configure signs
- Configure virtual text
- Configure underline
- Set the location list with the buffers diagnostics.
- See |vim.lsp.diagnostic.set_loclist()|
- Better performance for getting counts and line diagnostics
- They are now cached on save, to enhance lookups.
- Particularly useful for checking in statusline, etc.
- Actual testing :)
- See ./test/functional/plugin/lsp/diagnostic_spec.lua
- Added `guisp` for underline highlighting
NOTE: "a little while" means enough time to feel like most plugins and
plugin authors have had a chance to refactor their code to use the
updated calls. Then we will remove them completely. There is no need to
keep them, because we don't have any released version of neovim that
exposes these APIs. I'm trying to be nice to people following HEAD :)
Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
2020-11-12 20:21:34 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {ns_id} Namespace id for this highlight |nvim_create_namespace()|.
|
2022-03-13 05:48:14 -07:00
|
|
|
Use 0 to set a highlight group globally |:highlight|.
|
2023-03-16 01:31:37 -07:00
|
|
|
Highlights from non-global namespaces are not active by
|
|
|
|
default, use |nvim_set_hl_ns()| or |nvim_win_set_hl_ns()| to
|
|
|
|
activate them.
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Highlight group name, e.g. "ErrorMsg"
|
|
|
|
• {val} Highlight definition map, accepts the following keys:
|
2022-05-15 14:06:06 -07:00
|
|
|
• fg (or foreground): color name or "#RRGGBB", see note.
|
|
|
|
• bg (or background): color name or "#RRGGBB", see note.
|
|
|
|
• sp (or special): color name or "#RRGGBB"
|
|
|
|
• blend: integer between 0 and 100
|
|
|
|
• bold: boolean
|
|
|
|
• standout: boolean
|
|
|
|
• underline: boolean
|
|
|
|
• undercurl: boolean
|
2022-06-30 01:57:44 -07:00
|
|
|
• underdouble: boolean
|
|
|
|
• underdotted: boolean
|
|
|
|
• underdashed: boolean
|
2022-05-15 14:06:06 -07:00
|
|
|
• strikethrough: boolean
|
|
|
|
• italic: boolean
|
|
|
|
• reverse: boolean
|
|
|
|
• nocombine: boolean
|
|
|
|
• link: name of another highlight group to link to, see
|
|
|
|
|:hi-link|.
|
2022-03-13 05:48:14 -07:00
|
|
|
• default: Don't override existing definition |:hi-default|
|
2022-09-25 16:58:27 -07:00
|
|
|
• ctermfg: Sets foreground of cterm color |ctermfg|
|
|
|
|
• ctermbg: Sets background of cterm color |ctermbg|
|
2022-05-15 14:06:06 -07:00
|
|
|
• cterm: cterm attribute map, like |highlight-args|. If not
|
|
|
|
set, cterm attributes will match those from the attribute
|
|
|
|
map documented above.
|
2023-09-17 23:50:27 -07:00
|
|
|
• force: if true force update the highlight group when it
|
|
|
|
exists.
|
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes:
- Deprecated all `vim.lsp.util.{*diagnostics*}()` functions.
- Instead, all functions must be found in vim.lsp.diagnostic
- For now, they issue a warning ONCE per neovim session. In a
"little while" we will remove them completely.
- `vim.lsp.callbacks` has moved to `vim.lsp.handlers`.
- For a "little while" we will just redirect `vim.lsp.callbacks` to
`vim.lsp.handlers`. However, we will remove this at some point, so
it is recommended that you change all of your references to
`callbacks` into `handlers`.
- This also means that for functions like |vim.lsp.start_client()|
and similar, keyword style arguments have moved from "callbacks"
to "handlers". Once again, these are currently being forward, but
will cease to be forwarded in a "little while".
- Changed the highlight groups for LspDiagnostic highlight as they were
inconsistently named.
- For more information, see |lsp-highlight-diagnostics|
- Changed the sign group names as well, to be consistent with
|lsp-highlight-diagnostics|
General Enhancements:
- Rewrote much of the getting started help document for lsp. It also
provides a much nicer configuration strategy, so as to not recommend
globally overwriting builtin neovim mappings.
LSP Enhancements:
- Introduced the concept of |lsp-handlers| which will allow much better
customization for users without having to copy & paste entire files /
functions / etc.
Diagnostic Enhancements:
- "goto next diagnostic" |vim.lsp.diagnostic.goto_next()|
- "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()|
- For each of the gotos, auto open diagnostics is available as a
configuration option
- Configurable diagnostic handling:
- See |vim.lsp.diagnostic.on_publish_diagnostics()|
- Delay display until after insert mode
- Configure signs
- Configure virtual text
- Configure underline
- Set the location list with the buffers diagnostics.
- See |vim.lsp.diagnostic.set_loclist()|
- Better performance for getting counts and line diagnostics
- They are now cached on save, to enhance lookups.
- Particularly useful for checking in statusline, etc.
- Actual testing :)
- See ./test/functional/plugin/lsp/diagnostic_spec.lua
- Added `guisp` for underline highlighting
NOTE: "a little while" means enough time to feel like most plugins and
plugin authors have had a chance to refactor their code to use the
updated calls. Then we will remove them completely. There is no need to
keep them, because we don't have any released version of neovim that
exposes these APIs. I'm trying to be nice to people following HEAD :)
Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
2020-11-12 20:21:34 -07:00
|
|
|
|
2022-07-25 01:16:33 -07:00
|
|
|
nvim_set_hl_ns({ns_id}) *nvim_set_hl_ns()*
|
2023-03-16 01:31:37 -07:00
|
|
|
Set active namespace for highlights defined with |nvim_set_hl()|. This can
|
|
|
|
be set for a single window, see |nvim_win_set_hl_ns()|.
|
2022-07-25 01:16:33 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {ns_id} the namespace to use
|
2022-07-25 01:16:33 -07:00
|
|
|
|
|
|
|
nvim_set_hl_ns_fast({ns_id}) *nvim_set_hl_ns_fast()*
|
2023-03-16 01:31:37 -07:00
|
|
|
Set active namespace for highlights defined with |nvim_set_hl()| while
|
|
|
|
redrawing.
|
2022-07-25 01:16:33 -07:00
|
|
|
|
|
|
|
This function meant to be called while redrawing, primarily from
|
2022-09-25 16:58:27 -07:00
|
|
|
|nvim_set_decoration_provider()| on_win and on_line callbacks, which are
|
2022-07-25 01:16:33 -07:00
|
|
|
allowed to change the namespace during a redraw cycle.
|
|
|
|
|
|
|
|
Attributes: ~
|
|
|
|
|api-fast|
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {ns_id} the namespace to activate
|
2022-07-25 01:16:33 -07:00
|
|
|
|
2021-10-05 10:48:48 -07:00
|
|
|
nvim_set_keymap({mode}, {lhs}, {rhs}, {*opts}) *nvim_set_keymap()*
|
2019-12-28 04:27:25 -07:00
|
|
|
Sets a global |mapping| for the given mode.
|
2019-03-03 07:01:16 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
To set a buffer-local mapping, use |nvim_buf_set_keymap()|.
|
2019-03-03 07:01:16 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Unlike |:map|, leading/trailing whitespace is accepted as part of the
|
|
|
|
{lhs} or {rhs}. Empty {rhs} is |<Nop>|. |keycodes| are replaced as usual.
|
2017-11-14 02:47:49 -07:00
|
|
|
|
2022-11-23 04:31:49 -07:00
|
|
|
Example: >vim
|
2019-12-28 04:27:25 -07:00
|
|
|
call nvim_set_keymap('n', ' <NL>', '', {'nowait': v:true})
|
|
|
|
<
|
2017-07-02 04:46:41 -07:00
|
|
|
|
2022-11-23 04:31:49 -07:00
|
|
|
is equivalent to: >vim
|
2019-12-28 04:27:25 -07:00
|
|
|
nmap <nowait> <Space><NL> <Nop>
|
|
|
|
<
|
2017-07-02 04:46:41 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {mode} Mode short-name (map command prefix: "n", "i", "v", "x", …) or
|
2023-05-28 03:09:52 -07:00
|
|
|
"!" for |:map!|, or empty string for |:map|. "ia", "ca" or
|
2023-06-09 19:44:31 -07:00
|
|
|
"!a" for abbreviation in Insert mode, Cmdline mode, or both,
|
2023-05-28 03:09:52 -07:00
|
|
|
respectively
|
2022-10-05 05:15:55 -07:00
|
|
|
• {lhs} Left-hand-side |{lhs}| of the mapping.
|
|
|
|
• {rhs} Right-hand-side |{rhs}| of the mapping.
|
2022-12-14 11:58:18 -07:00
|
|
|
• {opts} Optional parameters map: Accepts all |:map-arguments| as keys
|
|
|
|
except |<buffer>|, values are booleans (default false). Also:
|
2023-09-20 04:15:23 -07:00
|
|
|
• "noremap" disables |recursive_mapping|, like |:noremap|
|
2022-12-14 11:58:18 -07:00
|
|
|
• "desc" human-readable description.
|
2023-06-12 05:08:08 -07:00
|
|
|
• "callback" Lua function called in place of {rhs}.
|
2022-12-14 11:58:18 -07:00
|
|
|
• "replace_keycodes" (boolean) When "expr" is true, replace
|
|
|
|
keycodes in the resulting string (see
|
|
|
|
|nvim_replace_termcodes()|). Returning nil from the Lua
|
|
|
|
"callback" is equivalent to returning an empty string.
|
2017-07-02 04:46:41 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_set_var({name}, {value}) *nvim_set_var()*
|
|
|
|
Sets a global (g:) variable.
|
2017-07-02 04:46:41 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Variable name
|
|
|
|
• {value} Variable value
|
2017-07-02 04:46:41 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_set_vvar({name}, {value}) *nvim_set_vvar()*
|
|
|
|
Sets a v: variable, if it is not readonly.
|
2017-07-02 04:46:41 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Variable name
|
|
|
|
• {value} Variable value
|
2019-01-10 17:20:15 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_strwidth({text}) *nvim_strwidth()*
|
2022-03-13 05:48:14 -07:00
|
|
|
Calculates the number of display cells occupied by `text`. Control
|
2022-05-30 16:06:34 -07:00
|
|
|
characters including <Tab> count as one cell.
|
2019-01-10 17:20:15 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {text} Some text
|
2019-01-10 17:20:15 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Return: ~
|
|
|
|
Number of cells
|
2018-07-24 21:13:51 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_subscribe({event}) *nvim_subscribe()*
|
|
|
|
Subscribes to event broadcasts.
|
2019-12-24 01:04:14 -07:00
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {event} Event type string
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
nvim_unsubscribe({event}) *nvim_unsubscribe()*
|
|
|
|
Unsubscribes to event broadcasts.
|
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {event} Event type string
|
2019-12-24 01:04:14 -07:00
|
|
|
|
2017-03-01 09:18:03 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2021-11-18 14:50:55 -07:00
|
|
|
Vimscript Functions *api-vimscript*
|
2020-07-02 04:09:17 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
*nvim_call_dict_function()*
|
|
|
|
nvim_call_dict_function({dict}, {fn}, {args})
|
2023-06-22 03:44:51 -07:00
|
|
|
Calls a Vimscript |Dictionary-function| with the given arguments.
|
2020-07-02 04:09:17 -07:00
|
|
|
|
2023-06-22 03:44:51 -07:00
|
|
|
On execution error: fails with Vimscript error, updates v:errmsg.
|
2018-07-24 21:13:51 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
Parameters: ~
|
2023-06-22 03:44:51 -07:00
|
|
|
• {dict} Dictionary, or String evaluating to a Vimscript |self| dict
|
|
|
|
• {fn} Name of the function defined on the Vimscript dict
|
2022-10-05 05:15:55 -07:00
|
|
|
• {args} Function arguments packed in an Array
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Result of the function call
|
|
|
|
|
|
|
|
nvim_call_function({fn}, {args}) *nvim_call_function()*
|
2023-06-22 03:44:51 -07:00
|
|
|
Calls a Vimscript function with the given arguments.
|
2021-11-18 14:50:55 -07:00
|
|
|
|
2023-06-22 03:44:51 -07:00
|
|
|
On execution error: fails with Vimscript error, updates v:errmsg.
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {fn} Function to call
|
|
|
|
• {args} Function arguments packed in an Array
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Result of the function call
|
|
|
|
|
2022-05-08 04:39:45 -07:00
|
|
|
nvim_command({command}) *nvim_command()*
|
|
|
|
Executes an Ex command.
|
|
|
|
|
2023-06-22 03:44:51 -07:00
|
|
|
On execution error: fails with Vimscript error, updates v:errmsg.
|
2022-05-08 04:39:45 -07:00
|
|
|
|
2023-03-25 09:58:48 -07:00
|
|
|
Prefer using |nvim_cmd()| or |nvim_exec2()| over this. To evaluate
|
|
|
|
multiple lines of Vim script or an Ex command directly, use
|
|
|
|
|nvim_exec2()|. To construct an Ex command using a structured format and
|
|
|
|
then execute it, use |nvim_cmd()|. To modify an Ex command before
|
|
|
|
evaluating it, use |nvim_parse_cmd()| in conjunction with |nvim_cmd()|.
|
2022-05-08 04:39:45 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {command} Ex command string
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
nvim_eval({expr}) *nvim_eval()*
|
2023-06-22 03:44:51 -07:00
|
|
|
Evaluates a Vimscript |expression|. Dictionaries and Lists are recursively
|
2021-11-18 14:50:55 -07:00
|
|
|
expanded.
|
|
|
|
|
2023-06-22 03:44:51 -07:00
|
|
|
On execution error: fails with Vimscript error, updates v:errmsg.
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2023-06-22 03:44:51 -07:00
|
|
|
• {expr} Vimscript expression string
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Evaluation result or expanded object
|
|
|
|
|
2023-03-25 09:58:48 -07:00
|
|
|
nvim_exec2({src}, {*opts}) *nvim_exec2()*
|
2022-05-08 04:39:45 -07:00
|
|
|
Executes Vimscript (multiline block of Ex commands), like anonymous
|
2021-11-18 14:50:55 -07:00
|
|
|
|:source|.
|
|
|
|
|
|
|
|
Unlike |nvim_command()| this function supports heredocs, script-scope
|
|
|
|
(s:), etc.
|
|
|
|
|
2023-06-22 03:44:51 -07:00
|
|
|
On execution error: fails with Vimscript error, updates v:errmsg.
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2023-03-25 09:58:48 -07:00
|
|
|
• {src} Vimscript code
|
|
|
|
• {opts} Optional parameters.
|
|
|
|
• output: (boolean, default false) Whether to capture and
|
|
|
|
return all (non-error, non-shell |:!|) output.
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
Return: ~
|
2023-03-25 09:58:48 -07:00
|
|
|
Dictionary containing information about execution, with these keys:
|
|
|
|
• output: (string|nil) Output if `opts.output` is true.
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |execute()|
|
|
|
|
• |nvim_command()|
|
|
|
|
• |nvim_cmd()|
|
2021-11-18 14:50:55 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
*nvim_parse_expression()*
|
|
|
|
nvim_parse_expression({expr}, {flags}, {highlight})
|
2023-06-22 03:44:51 -07:00
|
|
|
Parse a Vimscript expression.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Attributes: ~
|
|
|
|
|api-fast|
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {expr} Expression to parse. Always treated as a single line.
|
|
|
|
• {flags} Flags:
|
2022-06-12 10:26:43 -07:00
|
|
|
• "m" if multiple expressions in a row are allowed (only
|
|
|
|
the first one will be parsed),
|
|
|
|
• "E" if EOC tokens are not allowed (determines whether
|
|
|
|
they will stop parsing process or be recognized as an
|
|
|
|
operator/space, though also yielding an error).
|
|
|
|
• "l" when needing to start parsing with lvalues for
|
|
|
|
":let" or ":for". Common flag sets:
|
|
|
|
• "m" to parse like for ":echo".
|
|
|
|
• "E" to parse like for "<C-r>=".
|
|
|
|
• empty string for ":call".
|
|
|
|
• "lm" to parse for ":let".
|
2022-10-05 05:15:55 -07:00
|
|
|
• {highlight} If true, return value will also include "highlight" key
|
2022-06-12 10:26:43 -07:00
|
|
|
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)).
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Return: ~
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
• AST: top-level dictionary with these keys:
|
|
|
|
• "error": Dictionary with error, present only if parser saw some
|
|
|
|
error. Contains the following keys:
|
|
|
|
• "message": String, error message in printf format, translated.
|
|
|
|
Must contain exactly one "%.*s".
|
|
|
|
• "arg": String, error message argument.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
• "len": Amount of bytes successfully parsed. With flags equal to ""
|
|
|
|
that should be equal to the length of expr string. (“Successfully
|
|
|
|
parsed” here means “participated in AST creation”, not “till the
|
|
|
|
first error”.)
|
|
|
|
• "ast": AST, either nil or a dictionary with these keys:
|
|
|
|
• "type": node type, one of the value names from ExprASTNodeType
|
|
|
|
stringified without "kExprNode" prefix.
|
|
|
|
• "start": a pair [line, column] describing where node is
|
|
|
|
"started" where "line" is always 0 (will not be 0 if you will be
|
2023-07-21 01:30:05 -07:00
|
|
|
using this API on e.g. ":let", but that is not present yet).
|
|
|
|
Both elements are Integers.
|
2022-06-12 10:26:43 -07:00
|
|
|
• "len": “length” of the node. This and "start" are there for
|
|
|
|
debugging purposes primary (debugging parser and providing debug
|
|
|
|
information).
|
|
|
|
• "children": a list of nodes described in top/"ast". There always
|
|
|
|
is zero, one or two children, key will not be present if node
|
|
|
|
has no children. Maximum number of children may be found in
|
|
|
|
node_maxchildren array.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
• Local values (present only for certain nodes):
|
|
|
|
• "scope": a single Integer, specifies scope for "Option" and
|
|
|
|
"PlainIdentifier" nodes. For "Option" it is one of ExprOptScope
|
|
|
|
values, for "PlainIdentifier" it is one of ExprVarScope values.
|
|
|
|
• "ident": identifier (without scope, if any), present for "Option",
|
|
|
|
"PlainIdentifier", "PlainKey" and "Environment" nodes.
|
|
|
|
• "name": Integer, register name (one character) or -1. Only present
|
|
|
|
for "Register" nodes.
|
|
|
|
• "cmp_type": String, comparison type, one of the value names from
|
|
|
|
ExprComparisonType, stringified without "kExprCmp" prefix. Only
|
|
|
|
present for "Comparison" nodes.
|
|
|
|
• "ccs_strategy": String, case comparison strategy, one of the value
|
|
|
|
names from ExprCaseCompareStrategy, stringified without
|
|
|
|
"kCCStrategy" prefix. Only present for "Comparison" nodes.
|
|
|
|
• "augmentation": String, augmentation type for "Assignment" nodes.
|
|
|
|
Is either an empty string, "Add", "Subtract" or "Concat" for "=",
|
|
|
|
"+=", "-=" or ".=" respectively.
|
|
|
|
• "invert": Boolean, true if result of comparison needs to be
|
|
|
|
inverted. Only present for "Comparison" nodes.
|
|
|
|
• "ivalue": Integer, integer value for "Integer" nodes.
|
|
|
|
• "fvalue": Float, floating-point value for "Float" nodes.
|
|
|
|
• "svalue": String, value for "SingleQuotedString" and
|
|
|
|
"DoubleQuotedString" nodes.
|
|
|
|
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
Command Functions *api-command*
|
|
|
|
|
|
|
|
*nvim_buf_create_user_command()*
|
|
|
|
nvim_buf_create_user_command({buffer}, {name}, {command}, {*opts})
|
2022-12-14 11:58:18 -07:00
|
|
|
Creates a buffer-local command |user-commands|.
|
2022-06-12 10:26:43 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer.
|
2022-06-12 10:26:43 -07:00
|
|
|
|
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• nvim_create_user_command
|
2022-06-12 10:26:43 -07:00
|
|
|
|
|
|
|
*nvim_buf_del_user_command()*
|
|
|
|
nvim_buf_del_user_command({buffer}, {name})
|
|
|
|
Delete a buffer-local user-defined command.
|
|
|
|
|
|
|
|
Only commands created with |:command-buffer| or
|
|
|
|
|nvim_buf_create_user_command()| can be deleted with this function.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer.
|
|
|
|
• {name} Name of the command to delete.
|
2022-06-12 10:26:43 -07:00
|
|
|
|
|
|
|
nvim_buf_get_commands({buffer}, {*opts}) *nvim_buf_get_commands()*
|
|
|
|
Gets a map of buffer-local |user-commands|.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {opts} Optional parameters. Currently not used.
|
2022-06-12 10:26:43 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Map of maps describing commands.
|
|
|
|
|
|
|
|
nvim_cmd({*cmd}, {*opts}) *nvim_cmd()*
|
|
|
|
Executes an Ex command.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Unlike |nvim_command()| this command takes a structured Dictionary instead
|
|
|
|
of a String. This allows for easier construction and manipulation of an Ex
|
|
|
|
command. This also allows for things such as having spaces inside a
|
|
|
|
command argument, expanding filenames in a command that otherwise doesn't
|
2022-09-28 04:43:18 -07:00
|
|
|
expand filenames, etc. Command arguments may also be Number, Boolean or
|
|
|
|
String.
|
|
|
|
|
|
|
|
The first argument may also be used instead of count for commands that
|
|
|
|
support it in order to make their usage simpler with |vim.cmd()|. For
|
|
|
|
example, instead of `vim.cmd.bdelete{ count = 2 }`, you may do
|
|
|
|
`vim.cmd.bdelete(2)`.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2023-06-22 03:44:51 -07:00
|
|
|
On execution error: fails with Vimscript error, updates v:errmsg.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {cmd} Command to execute. Must be a Dictionary that can contain the
|
2022-06-12 10:26:43 -07:00
|
|
|
same values as the return value of |nvim_parse_cmd()| except
|
|
|
|
"addr", "nargs" and "nextcmd" which are ignored if provided.
|
|
|
|
All values except for "cmd" are optional.
|
2022-10-05 05:15:55 -07:00
|
|
|
• {opts} Optional parameters.
|
2022-06-12 10:26:43 -07:00
|
|
|
• output: (boolean, default false) Whether to return command
|
|
|
|
output.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Return: ~
|
|
|
|
Command output (non-error, non-shell |:!|) if `output` is true, else
|
|
|
|
empty string.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
See also: ~
|
2023-03-25 09:58:48 -07:00
|
|
|
• |nvim_exec2()|
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_command()|
|
2022-06-12 10:26:43 -07:00
|
|
|
|
|
|
|
*nvim_create_user_command()*
|
|
|
|
nvim_create_user_command({name}, {command}, {*opts})
|
2022-12-14 11:58:18 -07:00
|
|
|
Creates a global |user-commands| command.
|
2022-06-12 10:26:43 -07:00
|
|
|
|
2022-12-14 11:58:18 -07:00
|
|
|
For Lua usage see |lua-guide-commands-create|.
|
2022-06-12 10:26:43 -07:00
|
|
|
|
2022-11-23 04:31:49 -07:00
|
|
|
Example: >vim
|
2023-09-14 06:23:01 -07:00
|
|
|
:call nvim_create_user_command('SayHello', 'echo "Hello world!"', {'bang': v:true})
|
|
|
|
:SayHello
|
|
|
|
Hello world!
|
2022-06-12 10:26:43 -07:00
|
|
|
<
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Name of the new user command. Must begin with an uppercase
|
2022-06-12 10:26:43 -07:00
|
|
|
letter.
|
2022-10-05 05:15:55 -07:00
|
|
|
• {command} Replacement command to execute when this user command is
|
2022-06-12 10:26:43 -07:00
|
|
|
executed. When called from Lua, the command can also be a
|
|
|
|
Lua function. The function is called with a single table
|
|
|
|
argument that contains the following keys:
|
2022-11-07 09:27:37 -07:00
|
|
|
• name: (string) Command name
|
2022-06-12 10:26:43 -07:00
|
|
|
• args: (string) The args passed to the command, if any
|
|
|
|
|<args>|
|
|
|
|
• fargs: (table) The args split by unescaped whitespace
|
|
|
|
(when more than one argument is allowed), if any
|
|
|
|
|<f-args>|
|
2023-05-13 12:33:22 -07:00
|
|
|
• nargs: (string) Number of arguments |:command-nargs|
|
2022-06-12 10:26:43 -07:00
|
|
|
• bang: (boolean) "true" if the command was executed with a
|
|
|
|
! modifier |<bang>|
|
|
|
|
• line1: (number) The starting line of the command range
|
|
|
|
|<line1>|
|
|
|
|
• line2: (number) The final line of the command range
|
|
|
|
|<line2>|
|
|
|
|
• range: (number) The number of items in the command range:
|
|
|
|
0, 1, or 2 |<range>|
|
|
|
|
• count: (number) Any count supplied |<count>|
|
|
|
|
• reg: (string) The optional register, if specified |<reg>|
|
|
|
|
• mods: (string) Command modifiers, if any |<mods>|
|
|
|
|
• smods: (table) Command modifiers in a structured format.
|
|
|
|
Has the same structure as the "mods" key of
|
|
|
|
|nvim_parse_cmd()|.
|
2022-12-14 11:58:18 -07:00
|
|
|
• {opts} Optional |command-attributes|.
|
|
|
|
• Set boolean attributes such as |:command-bang| or
|
|
|
|
|:command-bar| to true (but not |:command-buffer|, use
|
|
|
|
|nvim_buf_create_user_command()| instead).
|
|
|
|
• "complete" |:command-complete| also accepts a Lua
|
|
|
|
function which works like
|
|
|
|
|:command-completion-customlist|.
|
|
|
|
• Other parameters:
|
|
|
|
• desc: (string) Used for listing the command when a Lua
|
|
|
|
function is used for {command}.
|
|
|
|
• force: (boolean, default true) Override any previous
|
|
|
|
definition.
|
|
|
|
• preview: (function) Preview callback for 'inccommand'
|
|
|
|
|:command-preview|
|
2022-06-12 10:26:43 -07:00
|
|
|
|
|
|
|
nvim_del_user_command({name}) *nvim_del_user_command()*
|
|
|
|
Delete a user-defined command.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Name of the command to delete.
|
2022-06-12 10:26:43 -07:00
|
|
|
|
|
|
|
nvim_get_commands({*opts}) *nvim_get_commands()*
|
|
|
|
Gets a map of global (non-buffer-local) Ex commands.
|
|
|
|
|
|
|
|
Currently only |user-commands| are supported, not builtin Ex commands.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {opts} Optional parameters. Currently only supports {"builtin":false}
|
2022-06-12 10:26:43 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Map of maps describing commands.
|
|
|
|
|
2023-07-12 10:27:14 -07:00
|
|
|
See also: ~
|
|
|
|
• |nvim_get_all_options_info()|
|
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
nvim_parse_cmd({str}, {opts}) *nvim_parse_cmd()*
|
|
|
|
Parse command line.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Doesn't check the validity of command arguments.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Attributes: ~
|
|
|
|
|api-fast|
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {str} Command line string to parse. Cannot contain "\n".
|
|
|
|
• {opts} Optional parameters. Reserved for future use.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Return: ~
|
|
|
|
Dictionary containing command information, with these keys:
|
|
|
|
• cmd: (string) Command name.
|
2022-09-26 23:40:10 -07:00
|
|
|
• range: (array) (optional) Command range (|<line1>| |<line2>|).
|
|
|
|
Omitted if command doesn't accept a range. Otherwise, has no
|
|
|
|
elements if no range was specified, one element if only a single
|
|
|
|
range item was specified, or two elements if both range items were
|
|
|
|
specified.
|
|
|
|
• count: (number) (optional) Command |<count>|. Omitted if command
|
|
|
|
cannot take a count.
|
|
|
|
• reg: (string) (optional) Command |<register>|. Omitted if command
|
|
|
|
cannot take a register.
|
2022-06-12 10:26:43 -07:00
|
|
|
• bang: (boolean) Whether command contains a |<bang>| (!) modifier.
|
|
|
|
• args: (array) Command arguments.
|
2022-12-05 06:09:31 -07:00
|
|
|
• addr: (string) Value of |:command-addr|. Uses short name or "line"
|
|
|
|
for -addr=lines.
|
2022-06-12 10:26:43 -07:00
|
|
|
• nargs: (string) Value of |:command-nargs|.
|
|
|
|
• nextcmd: (string) Next command if there are multiple commands
|
|
|
|
separated by a |:bar|. Empty if there isn't a next command.
|
|
|
|
• magic: (dictionary) Which characters have special meaning in the
|
|
|
|
command arguments.
|
|
|
|
• file: (boolean) The command expands filenames. Which means
|
|
|
|
characters such as "%", "#" and wildcards are expanded.
|
|
|
|
• bar: (boolean) The "|" character is treated as a command separator
|
|
|
|
and the double quote character (") is treated as the start of a
|
|
|
|
comment.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
• mods: (dictionary) |:command-modifiers|.
|
2022-06-28 03:22:29 -07:00
|
|
|
• filter: (dictionary) |:filter|.
|
|
|
|
• pattern: (string) Filter pattern. Empty string if there is no
|
|
|
|
filter.
|
|
|
|
• force: (boolean) Whether filter is inverted or not.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
• silent: (boolean) |:silent|.
|
|
|
|
• emsg_silent: (boolean) |:silent!|.
|
2022-07-02 04:35:11 -07:00
|
|
|
• unsilent: (boolean) |:unsilent|.
|
2022-06-12 10:26:43 -07:00
|
|
|
• sandbox: (boolean) |:sandbox|.
|
|
|
|
• noautocmd: (boolean) |:noautocmd|.
|
|
|
|
• browse: (boolean) |:browse|.
|
|
|
|
• confirm: (boolean) |:confirm|.
|
|
|
|
• hide: (boolean) |:hide|.
|
2022-09-01 05:32:59 -07:00
|
|
|
• horizontal: (boolean) |:horizontal|.
|
2022-06-12 10:26:43 -07:00
|
|
|
• keepalt: (boolean) |:keepalt|.
|
|
|
|
• keepjumps: (boolean) |:keepjumps|.
|
|
|
|
• keepmarks: (boolean) |:keepmarks|.
|
|
|
|
• keeppatterns: (boolean) |:keeppatterns|.
|
|
|
|
• lockmarks: (boolean) |:lockmarks|.
|
|
|
|
• noswapfile: (boolean) |:noswapfile|.
|
2022-09-01 03:46:34 -07:00
|
|
|
• tab: (integer) |:tab|. -1 when omitted.
|
2022-06-12 10:26:43 -07:00
|
|
|
• verbose: (integer) |:verbose|. -1 when omitted.
|
|
|
|
• vertical: (boolean) |:vertical|.
|
|
|
|
• split: (string) Split modifier string, is an empty string when
|
|
|
|
there's no split modifier. If there is a split modifier it can be
|
|
|
|
one of:
|
|
|
|
• "aboveleft": |:aboveleft|.
|
|
|
|
• "belowright": |:belowright|.
|
|
|
|
• "topleft": |:topleft|.
|
|
|
|
• "botright": |:botright|.
|
|
|
|
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
Options Functions *api-options*
|
|
|
|
|
|
|
|
nvim_get_all_options_info() *nvim_get_all_options_info()*
|
|
|
|
Gets the option information for all options.
|
|
|
|
|
|
|
|
The dictionary has the full option names as keys and option metadata
|
2023-03-29 00:59:01 -07:00
|
|
|
dictionaries as detailed at |nvim_get_option_info2()|.
|
2022-06-12 10:26:43 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
dictionary of all options
|
|
|
|
|
2023-07-12 10:27:14 -07:00
|
|
|
See also: ~
|
|
|
|
• |nvim_get_commands()|
|
|
|
|
|
2023-03-29 00:59:01 -07:00
|
|
|
nvim_get_option_info2({name}, {*opts}) *nvim_get_option_info2()*
|
|
|
|
Gets the option information for one option from arbitrary buffer or window
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Resulting dictionary has keys:
|
|
|
|
• name: Name of the option (like 'filetype')
|
|
|
|
• shortname: Shortened name of the option (like 'ft')
|
|
|
|
• 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)
|
|
|
|
• last_set_linenr: line number where option was set
|
|
|
|
• last_set_chan: Channel where option was set (0 for local)
|
|
|
|
• scope: one of "global", "win", or "buf"
|
|
|
|
• global_local: whether win or buf option has a global value
|
|
|
|
• commalist: List of comma separated values
|
|
|
|
• flaglist: List of single char flags
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2023-03-29 00:59:01 -07:00
|
|
|
When {scope} is not provided, the last set information applies to the
|
|
|
|
local value in the current buffer or window if it is available, otherwise
|
|
|
|
the global value information is returned. This behavior can be disabled by
|
|
|
|
explicitly specifying {scope} in the {opts} table.
|
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Option name
|
2023-03-29 00:59:01 -07:00
|
|
|
• {opts} Optional parameters
|
|
|
|
• scope: One of "global" or "local". Analogous to |:setglobal|
|
|
|
|
and |:setlocal|, respectively.
|
|
|
|
• win: |window-ID|. Used for getting window local options.
|
|
|
|
• buf: Buffer number. Used for getting buffer local options.
|
|
|
|
Implies {scope} is "local".
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Return: ~
|
|
|
|
Option Information
|
|
|
|
|
|
|
|
nvim_get_option_value({name}, {*opts}) *nvim_get_option_value()*
|
|
|
|
Gets the value of an option. The behavior of this function matches that of
|
|
|
|
|:set|: the local value of an option is returned if it exists; otherwise,
|
|
|
|
the global value is returned. Local values always correspond to the
|
2022-06-20 07:20:06 -07:00
|
|
|
current buffer or window, unless "buf" or "win" is set in {opts}.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Option name
|
|
|
|
• {opts} Optional parameters
|
2022-06-20 07:20:06 -07:00
|
|
|
• scope: One of "global" or "local". Analogous to |:setglobal|
|
2022-06-12 10:26:43 -07:00
|
|
|
and |:setlocal|, respectively.
|
2022-06-20 07:20:06 -07:00
|
|
|
• win: |window-ID|. Used for getting window local options.
|
|
|
|
• buf: Buffer number. Used for getting buffer local options.
|
|
|
|
Implies {scope} is "local".
|
2023-03-15 16:30:14 -07:00
|
|
|
• filetype: |filetype|. Used to get the default option for a
|
|
|
|
specific filetype. Cannot be used with any other option.
|
2023-03-11 10:11:02 -07:00
|
|
|
Note: this will trigger |ftplugin| and all |FileType|
|
|
|
|
autocommands for the corresponding filetype.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Return: ~
|
|
|
|
Option value
|
2022-05-04 05:04:01 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
*nvim_set_option_value()*
|
|
|
|
nvim_set_option_value({name}, {value}, {*opts})
|
|
|
|
Sets the value of an option. The behavior of this function matches that of
|
|
|
|
|:set|: for global-local options, both the global and local value are set
|
|
|
|
unless otherwise specified with {scope}.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Note the options {win} and {buf} cannot be used together.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-06-12 10:26:43 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Option name
|
|
|
|
• {value} New option value
|
|
|
|
• {opts} Optional parameters
|
2022-09-25 16:58:27 -07:00
|
|
|
• scope: One of "global" or "local". Analogous to
|
2022-06-12 10:26:43 -07:00
|
|
|
|:setglobal| and |:setlocal|, respectively.
|
|
|
|
• win: |window-ID|. Used for setting window local option.
|
|
|
|
• buf: Buffer number. Used for setting buffer local option.
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
Buffer Functions *api-buffer*
|
|
|
|
|
|
|
|
|
|
|
|
For more information on buffers, see |buffers|.
|
|
|
|
|
2023-06-25 12:29:56 -07:00
|
|
|
Unloaded Buffers: ~
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
Buffers may be unloaded by the |:bunload| command or the buffer's
|
2018-07-24 21:13:51 -07:00
|
|
|
|'bufhidden'| option. When a buffer is unloaded its file contents are
|
|
|
|
freed from memory and vim cannot operate on the buffer lines until it is
|
|
|
|
reloaded (usually by opening the buffer again in a new window). API
|
|
|
|
methods such as |nvim_buf_get_lines()| and |nvim_buf_line_count()| will be
|
|
|
|
affected.
|
|
|
|
|
|
|
|
You can use |nvim_buf_is_loaded()| or |nvim_buf_line_count()| to check
|
|
|
|
whether a buffer is loaded.
|
|
|
|
|
2018-06-10 15:20:39 -07:00
|
|
|
nvim_buf_attach({buffer}, {send_buffer}, {opts}) *nvim_buf_attach()*
|
2019-10-27 15:05:59 -07:00
|
|
|
Activates buffer-update events on a channel, or as Lua callbacks.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2023-09-14 06:23:01 -07:00
|
|
|
Example (Lua): capture buffer updates in a global `events` variable (use
|
|
|
|
"vim.print(events)" to see its contents): >lua
|
|
|
|
events = {}
|
|
|
|
vim.api.nvim_buf_attach(0, false, {
|
|
|
|
on_lines = function(...)
|
|
|
|
table.insert(events, {...})
|
|
|
|
end,
|
|
|
|
})
|
2019-11-17 20:06:59 -07:00
|
|
|
<
|
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {send_buffer} True if the initial notification should contain the
|
2019-10-27 15:05:59 -07:00
|
|
|
whole buffer: first notification will be
|
2022-03-13 05:48:14 -07:00
|
|
|
`nvim_buf_lines_event`. Else the first notification
|
|
|
|
will be `nvim_buf_changedtick_event`. Not for Lua
|
2019-10-27 15:05:59 -07:00
|
|
|
callbacks.
|
2022-10-05 05:15:55 -07:00
|
|
|
• {opts} Optional parameters.
|
2019-10-27 15:05:59 -07:00
|
|
|
• on_lines: Lua callback invoked on change. Return `true` to detach. Args:
|
2020-05-18 22:26:17 -07:00
|
|
|
• the string "lines"
|
2019-10-27 15:05:59 -07:00
|
|
|
• buffer handle
|
|
|
|
• b:changedtick
|
|
|
|
• first line that changed (zero-indexed)
|
|
|
|
• last line that was changed
|
|
|
|
• last line in the updated range
|
|
|
|
• byte count of previous contents
|
|
|
|
• deleted_codepoints (if `utf_sizes` is true)
|
|
|
|
• deleted_codeunits (if `utf_sizes` is true)
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2023-06-22 03:44:51 -07:00
|
|
|
• on_bytes: Lua callback invoked on change. This
|
2021-02-15 01:26:34 -07:00
|
|
|
callback receives more granular information about the
|
2021-10-19 12:55:22 -07:00
|
|
|
change compared to on_lines. Return `true` to detach. Args:
|
2021-02-15 01:26:34 -07:00
|
|
|
• the string "bytes"
|
|
|
|
• buffer handle
|
|
|
|
• b:changedtick
|
|
|
|
• start row of the changed text (zero-indexed)
|
|
|
|
• start column of the changed text
|
|
|
|
• byte offset of the changed text (from the start of
|
|
|
|
the buffer)
|
|
|
|
• old end row of the changed text
|
|
|
|
• old end column of the changed text
|
|
|
|
• old end byte length of the changed text
|
|
|
|
• new end row of the changed text
|
|
|
|
• new end column of the changed text
|
|
|
|
• new end byte length of the changed text
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-10-27 15:05:59 -07:00
|
|
|
• on_changedtick: Lua callback invoked on changedtick
|
|
|
|
increment without text change. Args:
|
2020-05-18 22:26:17 -07:00
|
|
|
• the string "changedtick"
|
2019-10-27 15:05:59 -07:00
|
|
|
• buffer handle
|
|
|
|
• b:changedtick
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-10-27 15:05:59 -07:00
|
|
|
• on_detach: Lua callback invoked on detach. Args:
|
2020-05-18 22:26:17 -07:00
|
|
|
• the string "detach"
|
2019-10-27 15:05:59 -07:00
|
|
|
• buffer handle
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-02-15 01:26:34 -07:00
|
|
|
• on_reload: Lua callback invoked on reload. The entire
|
|
|
|
buffer content should be considered changed. Args:
|
2022-03-20 11:00:30 -07:00
|
|
|
• the string "reload"
|
2021-02-15 01:26:34 -07:00
|
|
|
• buffer handle
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-10-27 15:05:59 -07:00
|
|
|
• utf_sizes: include UTF-32 and UTF-16 size of the
|
|
|
|
replaced region, as args to `on_lines`.
|
2021-01-01 12:24:40 -07:00
|
|
|
• preview: also attach to command preview (i.e.
|
|
|
|
'inccommand') events.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2019-10-27 15:05:59 -07:00
|
|
|
False if attach failed (invalid parameter, or buffer isn't loaded);
|
|
|
|
otherwise True. TODO: LUA_API_NO_EVAL
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-10-27 15:05:59 -07:00
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_buf_detach()|
|
|
|
|
• |api-buffer-updates-lua|
|
2018-06-10 15:20:39 -07:00
|
|
|
|
2020-10-20 12:57:07 -07:00
|
|
|
nvim_buf_call({buffer}, {fun}) *nvim_buf_call()*
|
|
|
|
call a function with buffer as temporary current buffer
|
|
|
|
|
|
|
|
This temporarily switches current buffer to "buffer". If the current
|
|
|
|
window already shows "buffer", the window is not switched If a window
|
|
|
|
inside the current tabpage (including a float) already shows the buffer
|
2022-03-26 05:21:32 -07:00
|
|
|
One of these windows will be set as current window temporarily. Otherwise
|
2021-11-27 09:26:49 -07:00
|
|
|
a temporary scratch window (called the "autocmd window" for historical
|
2020-10-20 12:57:07 -07:00
|
|
|
reasons) will be used.
|
|
|
|
|
2023-07-21 01:30:05 -07:00
|
|
|
This is useful e.g. to call Vimscript functions that only work with the
|
|
|
|
current buffer/window currently, like |termopen()|.
|
2020-10-20 12:57:07 -07:00
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
2022-10-09 05:21:52 -07:00
|
|
|
Lua |vim.api| only
|
2022-04-30 16:16:16 -07:00
|
|
|
|
2020-10-20 12:57:07 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
2023-06-22 03:44:51 -07:00
|
|
|
• {fun} Function to call inside the buffer (currently Lua callable
|
2020-10-20 12:57:07 -07:00
|
|
|
only)
|
|
|
|
|
|
|
|
Return: ~
|
2023-06-22 03:44:51 -07:00
|
|
|
Return value of function. NB: will deepcopy Lua values currently, use
|
|
|
|
upvalues to send Lua references in and out.
|
2020-10-20 12:57:07 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_buf_del_keymap({buffer}, {mode}, {lhs}) *nvim_buf_del_keymap()*
|
|
|
|
Unmaps a buffer-local |mapping| for the given mode.
|
2019-12-24 01:04:14 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
2019-12-24 01:04:14 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_del_keymap()|
|
2019-12-24 01:04:14 -07:00
|
|
|
|
2021-10-05 08:49:20 -07:00
|
|
|
nvim_buf_del_mark({buffer}, {name}) *nvim_buf_del_mark()*
|
|
|
|
Deletes a named mark in the buffer. See |mark-motions|.
|
|
|
|
|
2023-07-06 13:47:27 -07:00
|
|
|
Note: ~
|
|
|
|
• only deletes marks set in the buffer, if the mark is not set in the
|
2021-10-05 08:49:20 -07:00
|
|
|
buffer it will return false.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer to set the mark on
|
|
|
|
• {name} Mark name
|
2021-10-05 08:49:20 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
true if the mark was deleted, else false.
|
|
|
|
|
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_buf_set_mark()|
|
|
|
|
• |nvim_del_mark()|
|
2021-10-05 08:49:20 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_buf_del_var({buffer}, {name}) *nvim_buf_del_var()*
|
|
|
|
Removes a buffer-scoped (b:) variable
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {name} Variable name
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2020-10-09 12:39:59 -07:00
|
|
|
nvim_buf_delete({buffer}, {opts}) *nvim_buf_delete()*
|
|
|
|
Deletes the buffer. See |:bwipeout|
|
|
|
|
|
2020-11-24 05:37:29 -07:00
|
|
|
Attributes: ~
|
2023-04-20 13:17:25 -07:00
|
|
|
not allowed when |textlock| is active or in the |cmdwin|
|
2020-11-24 05:37:29 -07:00
|
|
|
|
2020-10-09 12:39:59 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {opts} Optional parameters. Keys:
|
2020-10-09 12:39:59 -07:00
|
|
|
• force: Force deletion and ignore unsaved changes.
|
|
|
|
• unload: Unloaded only, do not delete. See |:bunload|
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_buf_detach({buffer}) *nvim_buf_detach()*
|
|
|
|
Deactivates buffer-update events on the channel.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
False if detach failed (because the buffer isn't loaded); otherwise
|
|
|
|
True.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_buf_attach()|
|
|
|
|
• |api-lua-detach| for detaching Lua callbacks
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_buf_get_changedtick({buffer}) *nvim_buf_get_changedtick()*
|
|
|
|
Gets a changed tick of a buffer
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
2018-11-04 19:50:22 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Return: ~
|
|
|
|
`b:changedtick` value.
|
2018-11-04 19:50:22 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
nvim_buf_get_keymap({buffer}, {mode}) *nvim_buf_get_keymap()*
|
|
|
|
Gets a list of buffer-local |mapping| definitions.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {mode} Mode short-name ("n", "i", "v", ...)
|
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
2017-07-02 04:46:41 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2022-08-01 20:13:22 -07:00
|
|
|
Array of |maparg()|-like dictionaries describing mappings. The
|
2018-06-10 15:20:39 -07:00
|
|
|
"buffer" key holds the associated buffer handle.
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
*nvim_buf_get_lines()*
|
|
|
|
nvim_buf_get_lines({buffer}, {start}, {end}, {strict_indexing})
|
|
|
|
Gets a line-range from the buffer.
|
|
|
|
|
|
|
|
Indexing is zero-based, end-exclusive. Negative indices are interpreted as
|
|
|
|
length+1+index: -1 refers to the index past the end. So to get the last
|
|
|
|
element use start=-2 and end=-1.
|
|
|
|
|
|
|
|
Out-of-bounds indices are clamped to the nearest valid value, unless
|
|
|
|
`strict_indexing` is set.
|
API: nvim_set_keymap, nvim_del_keymap #9924
closes #9136
- Treat empty {rhs} like <Nop>
- getchar.c: Pull "repl. MapArg termcodes" into func
The "preprocessing code" surrounding the replace_termcodes calls needs
to invoke replace_termcodes, and also check if RHS is equal to "<Nop>".
To reduce code duplication, factor this out into a helper function.
Also add an rhs_is_noop flag to MapArguments; buf_do_map_explicit
expects an empty {rhs} string for "<Nop>", but also needs to distinguish
that from something like ":map lhs<cr>" where no {rhs} was provided.
- getchar.c: Use allocated buffer for rhs in MapArgs
Since the MAXMAPLEN limit does not apply to the RHS of a mapping (or
else an RHS that calls a really long autoload function from a plugin
would be incorrectly rejected as being too long), use an allocated
buffer for RHS rather than a static buffer of length MAXMAPLEN + 1.
- Mappings LHS and RHS can contain literal space characters, newlines, etc.
- getchar.c: replace_termcodes in str_to_mapargs
It makes sense to do this; str_to_mapargs is, intuitively, supposed to
take a "raw" command string and parse it into a totally "do_map-ready"
struct.
- api/vim.c: Update lhs, rhs len after replace_termcodes
Fixes a bug in which replace_termcodes changes the length of lhs or rhs,
but the later search through the mappings/abbreviations hashtables
still uses the old length value. This would cause the search to fail
erroneously and throw 'E31: No such mapping' errors or 'E24: No such
abbreviation' errors.
- getchar: Create new map_arguments struct
So that a string of map arguments can be parsed into a more useful, more
portable data structure.
- getchar.c: Add buf_do_map function
Exactly the same as the old do_map, but replace the hardcoded references
to the global `buf_T* curbuf` with a function parameter so that we can
invoke it from nvim_buf_set_keymap.
- Remove gettext calls in do_map error handling
2019-05-12 02:44:48 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {start} First line index
|
|
|
|
• {end} Last line index, exclusive
|
|
|
|
• {strict_indexing} Whether out-of-bounds should be an error.
|
2019-05-12 04:04:48 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Return: ~
|
|
|
|
Array of lines, or empty array for unloaded buffer.
|
API: nvim_set_keymap, nvim_del_keymap #9924
closes #9136
- Treat empty {rhs} like <Nop>
- getchar.c: Pull "repl. MapArg termcodes" into func
The "preprocessing code" surrounding the replace_termcodes calls needs
to invoke replace_termcodes, and also check if RHS is equal to "<Nop>".
To reduce code duplication, factor this out into a helper function.
Also add an rhs_is_noop flag to MapArguments; buf_do_map_explicit
expects an empty {rhs} string for "<Nop>", but also needs to distinguish
that from something like ":map lhs<cr>" where no {rhs} was provided.
- getchar.c: Use allocated buffer for rhs in MapArgs
Since the MAXMAPLEN limit does not apply to the RHS of a mapping (or
else an RHS that calls a really long autoload function from a plugin
would be incorrectly rejected as being too long), use an allocated
buffer for RHS rather than a static buffer of length MAXMAPLEN + 1.
- Mappings LHS and RHS can contain literal space characters, newlines, etc.
- getchar.c: replace_termcodes in str_to_mapargs
It makes sense to do this; str_to_mapargs is, intuitively, supposed to
take a "raw" command string and parse it into a totally "do_map-ready"
struct.
- api/vim.c: Update lhs, rhs len after replace_termcodes
Fixes a bug in which replace_termcodes changes the length of lhs or rhs,
but the later search through the mappings/abbreviations hashtables
still uses the old length value. This would cause the search to fail
erroneously and throw 'E31: No such mapping' errors or 'E24: No such
abbreviation' errors.
- getchar: Create new map_arguments struct
So that a string of map arguments can be parsed into a more useful, more
portable data structure.
- getchar.c: Add buf_do_map function
Exactly the same as the old do_map, but replace the hardcoded references
to the global `buf_T* curbuf` with a function parameter so that we can
invoke it from nvim_buf_set_keymap.
- Remove gettext calls in do_map error handling
2019-05-12 02:44:48 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_buf_get_mark({buffer}, {name}) *nvim_buf_get_mark()*
|
2023-07-04 10:22:04 -07:00
|
|
|
Returns a `(row,col)` tuple representing the position of the named mark.
|
|
|
|
"End of line" column position is returned as |v:maxcol| (big number). See
|
2021-10-05 08:49:20 -07:00
|
|
|
|mark-motions|.
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
Marks are (1,0)-indexed. |api-indexing|
|
API: nvim_set_keymap, nvim_del_keymap #9924
closes #9136
- Treat empty {rhs} like <Nop>
- getchar.c: Pull "repl. MapArg termcodes" into func
The "preprocessing code" surrounding the replace_termcodes calls needs
to invoke replace_termcodes, and also check if RHS is equal to "<Nop>".
To reduce code duplication, factor this out into a helper function.
Also add an rhs_is_noop flag to MapArguments; buf_do_map_explicit
expects an empty {rhs} string for "<Nop>", but also needs to distinguish
that from something like ":map lhs<cr>" where no {rhs} was provided.
- getchar.c: Use allocated buffer for rhs in MapArgs
Since the MAXMAPLEN limit does not apply to the RHS of a mapping (or
else an RHS that calls a really long autoload function from a plugin
would be incorrectly rejected as being too long), use an allocated
buffer for RHS rather than a static buffer of length MAXMAPLEN + 1.
- Mappings LHS and RHS can contain literal space characters, newlines, etc.
- getchar.c: replace_termcodes in str_to_mapargs
It makes sense to do this; str_to_mapargs is, intuitively, supposed to
take a "raw" command string and parse it into a totally "do_map-ready"
struct.
- api/vim.c: Update lhs, rhs len after replace_termcodes
Fixes a bug in which replace_termcodes changes the length of lhs or rhs,
but the later search through the mappings/abbreviations hashtables
still uses the old length value. This would cause the search to fail
erroneously and throw 'E31: No such mapping' errors or 'E24: No such
abbreviation' errors.
- getchar: Create new map_arguments struct
So that a string of map arguments can be parsed into a more useful, more
portable data structure.
- getchar.c: Add buf_do_map function
Exactly the same as the old do_map, but replace the hardcoded references
to the global `buf_T* curbuf` with a function parameter so that we can
invoke it from nvim_buf_set_keymap.
- Remove gettext calls in do_map error handling
2019-05-12 02:44:48 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {name} Mark name
|
2019-05-12 04:04:48 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Return: ~
|
2021-10-05 08:49:20 -07:00
|
|
|
(row, col) tuple, (0, 0) if the mark is not set, or is an
|
|
|
|
uppercase/file mark set in another buffer.
|
|
|
|
|
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_buf_set_mark()|
|
|
|
|
• |nvim_buf_del_mark()|
|
API: nvim_set_keymap, nvim_del_keymap #9924
closes #9136
- Treat empty {rhs} like <Nop>
- getchar.c: Pull "repl. MapArg termcodes" into func
The "preprocessing code" surrounding the replace_termcodes calls needs
to invoke replace_termcodes, and also check if RHS is equal to "<Nop>".
To reduce code duplication, factor this out into a helper function.
Also add an rhs_is_noop flag to MapArguments; buf_do_map_explicit
expects an empty {rhs} string for "<Nop>", but also needs to distinguish
that from something like ":map lhs<cr>" where no {rhs} was provided.
- getchar.c: Use allocated buffer for rhs in MapArgs
Since the MAXMAPLEN limit does not apply to the RHS of a mapping (or
else an RHS that calls a really long autoload function from a plugin
would be incorrectly rejected as being too long), use an allocated
buffer for RHS rather than a static buffer of length MAXMAPLEN + 1.
- Mappings LHS and RHS can contain literal space characters, newlines, etc.
- getchar.c: replace_termcodes in str_to_mapargs
It makes sense to do this; str_to_mapargs is, intuitively, supposed to
take a "raw" command string and parse it into a totally "do_map-ready"
struct.
- api/vim.c: Update lhs, rhs len after replace_termcodes
Fixes a bug in which replace_termcodes changes the length of lhs or rhs,
but the later search through the mappings/abbreviations hashtables
still uses the old length value. This would cause the search to fail
erroneously and throw 'E31: No such mapping' errors or 'E24: No such
abbreviation' errors.
- getchar: Create new map_arguments struct
So that a string of map arguments can be parsed into a more useful, more
portable data structure.
- getchar.c: Add buf_do_map function
Exactly the same as the old do_map, but replace the hardcoded references
to the global `buf_T* curbuf` with a function parameter so that we can
invoke it from nvim_buf_set_keymap.
- Remove gettext calls in do_map error handling
2019-05-12 02:44:48 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_buf_get_name({buffer}) *nvim_buf_get_name()*
|
|
|
|
Gets the full file name for the buffer
|
2018-06-10 15:20:39 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
2018-06-10 15:20:39 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
Buffer name
|
2017-07-02 04:46:41 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_buf_get_offset({buffer}, {index}) *nvim_buf_get_offset()*
|
|
|
|
Returns the byte offset of a line (0-indexed). |api-indexing|
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte.
|
|
|
|
'fileformat' and 'fileencoding' are ignored. The line index just after the
|
|
|
|
last line gives the total byte-count of the buffer. A final EOL byte is
|
|
|
|
counted if it would be written, see 'eol'.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Unlike |line2byte()|, throws error for out-of-bounds indexing. Returns -1
|
|
|
|
for unloaded buffer.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {index} Line index
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Integer byte offset, or -1 for unloaded buffer.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2022-02-22 13:19:21 -07:00
|
|
|
*nvim_buf_get_text()*
|
|
|
|
nvim_buf_get_text({buffer}, {start_row}, {start_col}, {end_row}, {end_col},
|
|
|
|
{opts})
|
|
|
|
Gets a range from the buffer.
|
|
|
|
|
|
|
|
This differs from |nvim_buf_get_lines()| in that it allows retrieving only
|
|
|
|
portions of a line.
|
|
|
|
|
2022-05-11 17:05:56 -07:00
|
|
|
Indexing is zero-based. Row indices are end-inclusive, and column indices
|
|
|
|
are end-exclusive.
|
2022-02-22 13:19:21 -07:00
|
|
|
|
|
|
|
Prefer |nvim_buf_get_lines()| when retrieving entire lines.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {start_row} First line index
|
|
|
|
• {start_col} Starting column (byte offset) on first line
|
|
|
|
• {end_row} Last line index, inclusive
|
|
|
|
• {end_col} Ending column (byte offset) on last line, exclusive
|
|
|
|
• {opts} Optional parameters. Currently unused.
|
2022-02-22 13:19:21 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Array of lines, or empty array for unloaded buffer.
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_buf_get_var({buffer}, {name}) *nvim_buf_get_var()*
|
|
|
|
Gets a buffer-scoped (b:) variable.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {name} Variable name
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Return: ~
|
|
|
|
Variable value
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-07-24 21:13:51 -07:00
|
|
|
nvim_buf_is_loaded({buffer}) *nvim_buf_is_loaded()*
|
|
|
|
Checks if a buffer is valid and loaded. See |api-buffer| for more info
|
|
|
|
about unloaded buffers.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
2018-07-24 21:13:51 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
true if the buffer is valid and loaded, false otherwise.
|
|
|
|
|
2017-03-01 09:18:03 -07:00
|
|
|
nvim_buf_is_valid({buffer}) *nvim_buf_is_valid()*
|
2018-07-24 21:13:51 -07:00
|
|
|
Checks if a buffer is valid.
|
|
|
|
|
2023-07-06 13:47:27 -07:00
|
|
|
Note: ~
|
|
|
|
• Even if a buffer is valid it may have been unloaded. See |api-buffer|
|
2018-07-24 21:13:51 -07:00
|
|
|
for more info about unloaded buffers.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2018-07-24 21:13:51 -07:00
|
|
|
true if the buffer is valid, false otherwise.
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_buf_line_count({buffer}) *nvim_buf_line_count()*
|
2022-03-18 11:58:00 -07:00
|
|
|
Returns the number of lines in the given buffer.
|
2019-11-09 04:41:50 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
2019-11-09 04:41:50 -07:00
|
|
|
|
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
Line count, or 0 for unloaded buffer. |api-buffer|
|
2019-11-09 04:41:50 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
*nvim_buf_set_keymap()*
|
|
|
|
nvim_buf_set_keymap({buffer}, {mode}, {lhs}, {rhs}, {*opts})
|
|
|
|
Sets a buffer-local |mapping| for the given mode.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_set_keymap()|
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
*nvim_buf_set_lines()*
|
|
|
|
nvim_buf_set_lines({buffer}, {start}, {end}, {strict_indexing}, {replacement})
|
|
|
|
Sets (replaces) a line-range in the buffer.
|
|
|
|
|
|
|
|
Indexing is zero-based, end-exclusive. Negative indices are interpreted as
|
|
|
|
length+1+index: -1 refers to the index past the end. So to change or
|
|
|
|
delete the last element use start=-2 and end=-1.
|
|
|
|
|
|
|
|
To insert lines at a given index, set `start` and `end` to the same index.
|
|
|
|
To delete a range of lines, set `replacement` to an empty array.
|
|
|
|
|
|
|
|
Out-of-bounds indices are clamped to the nearest valid value, unless
|
|
|
|
`strict_indexing` is set.
|
|
|
|
|
|
|
|
Attributes: ~
|
|
|
|
not allowed when |textlock| is active
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {start} First line index
|
|
|
|
• {end} Last line index, exclusive
|
|
|
|
• {strict_indexing} Whether out-of-bounds should be an error.
|
|
|
|
• {replacement} Array of lines to use as replacement
|
2021-11-18 14:50:55 -07:00
|
|
|
|
2022-10-09 05:21:52 -07:00
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_buf_set_text()|
|
2022-10-09 05:21:52 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
*nvim_buf_set_mark()*
|
|
|
|
nvim_buf_set_mark({buffer}, {name}, {line}, {col}, {opts})
|
|
|
|
Sets a named mark in the given buffer, all marks are allowed
|
|
|
|
file/uppercase, visual, last change, etc. See |mark-motions|.
|
|
|
|
|
|
|
|
Marks are (1,0)-indexed. |api-indexing|
|
|
|
|
|
2023-07-06 13:47:27 -07:00
|
|
|
Note: ~
|
|
|
|
• Passing 0 as line deletes the mark
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer to set the mark on
|
|
|
|
• {name} Mark name
|
|
|
|
• {line} Line number
|
|
|
|
• {col} Column/row number
|
|
|
|
• {opts} Optional parameters. Reserved for future use.
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
true if the mark was set, else false.
|
|
|
|
|
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_buf_del_mark()|
|
|
|
|
• |nvim_buf_get_mark()|
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
nvim_buf_set_name({buffer}, {name}) *nvim_buf_set_name()*
|
|
|
|
Sets the full file name for a buffer
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {name} Buffer name
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
*nvim_buf_set_text()*
|
|
|
|
nvim_buf_set_text({buffer}, {start_row}, {start_col}, {end_row}, {end_col},
|
|
|
|
{replacement})
|
|
|
|
Sets (replaces) a range in the buffer
|
|
|
|
|
2022-05-11 17:05:56 -07:00
|
|
|
This is recommended over |nvim_buf_set_lines()| when only modifying parts
|
2021-11-18 14:50:55 -07:00
|
|
|
of a line, as extmarks will be preserved on non-modified parts of the
|
|
|
|
touched lines.
|
|
|
|
|
2022-05-11 17:05:56 -07:00
|
|
|
Indexing is zero-based. Row indices are end-inclusive, and column indices
|
|
|
|
are end-exclusive.
|
2021-11-18 14:50:55 -07:00
|
|
|
|
2022-05-11 17:05:56 -07:00
|
|
|
To insert text at a given `(row, column)` location, use `start_row =
|
|
|
|
end_row = row` and `start_col = end_col = col`. To delete the text in a
|
|
|
|
range, use `replacement = {}`.
|
2021-11-18 14:50:55 -07:00
|
|
|
|
2022-05-11 17:05:56 -07:00
|
|
|
Prefer |nvim_buf_set_lines()| if you are only adding or deleting entire
|
|
|
|
lines.
|
2021-11-18 14:50:55 -07:00
|
|
|
|
2023-09-10 21:16:03 -07:00
|
|
|
Prefer |nvim_put()| if you want to insert text at the cursor position.
|
|
|
|
|
2023-06-23 14:32:07 -07:00
|
|
|
Attributes: ~
|
|
|
|
not allowed when |textlock| is active
|
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {start_row} First line index
|
|
|
|
• {start_col} Starting column (byte offset) on first line
|
|
|
|
• {end_row} Last line index, inclusive
|
|
|
|
• {end_col} Ending column (byte offset) on last line, exclusive
|
|
|
|
• {replacement} Array of lines to use as replacement
|
2021-11-18 14:50:55 -07:00
|
|
|
|
2022-10-09 05:21:52 -07:00
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_buf_set_lines()|
|
2023-09-10 21:16:03 -07:00
|
|
|
• |nvim_put()|
|
2022-10-09 05:21:52 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
nvim_buf_set_var({buffer}, {name}, {value}) *nvim_buf_set_var()*
|
|
|
|
Sets a buffer-scoped (b:) variable
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {name} Variable name
|
|
|
|
• {value} Variable value
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
Extmark Functions *api-extmark*
|
|
|
|
|
|
|
|
*nvim_buf_add_highlight()*
|
|
|
|
nvim_buf_add_highlight({buffer}, {ns_id}, {hl_group}, {line}, {col_start},
|
|
|
|
{col_end})
|
|
|
|
Adds a highlight to buffer.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
Useful for plugins that dynamically generate highlights to a buffer (like
|
|
|
|
a semantic highlighter or linter). The function adds a single highlight to
|
|
|
|
a buffer. Unlike |matchaddpos()| highlights follow changes to line
|
|
|
|
numbering (as lines are inserted/removed above the highlighted line), like
|
|
|
|
signs and marks do.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
Namespaces are used for batch deletion/updating of a set of highlights. To
|
|
|
|
create a namespace, use |nvim_create_namespace()| which returns a
|
|
|
|
namespace id. Pass it in to this function as `ns_id` to add highlights to
|
|
|
|
the namespace. All highlights in the same namespace can then be cleared
|
|
|
|
with single call to |nvim_buf_clear_namespace()|. If the highlight never
|
2022-03-26 05:21:32 -07:00
|
|
|
will be deleted by an API call, pass `ns_id = -1`.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
As a shorthand, `ns_id = 0` can be used to create a new namespace for the
|
|
|
|
highlight, the allocated id is then returned. If `hl_group` is the empty
|
|
|
|
string no highlight is added, but a new `ns_id` is still returned. This is
|
|
|
|
supported for backwards compatibility, new code should use
|
|
|
|
|nvim_create_namespace()| to create a new empty namespace.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {ns_id} namespace to use or -1 for ungrouped highlight
|
|
|
|
• {hl_group} Name of the highlight group to use
|
|
|
|
• {line} Line to highlight (zero-indexed)
|
|
|
|
• {col_start} Start of (byte-indexed) column range to highlight
|
|
|
|
• {col_end} End of (byte-indexed) column range to highlight, or -1 to
|
2021-11-18 14:50:55 -07:00
|
|
|
highlight to end of line
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
Return: ~
|
|
|
|
The ns_id that was used
|
|
|
|
|
|
|
|
*nvim_buf_clear_namespace()*
|
|
|
|
nvim_buf_clear_namespace({buffer}, {ns_id}, {line_start}, {line_end})
|
2022-12-12 08:15:31 -07:00
|
|
|
Clears |namespace|d objects (highlights, |extmarks|, virtual text) from a
|
2021-11-18 14:50:55 -07:00
|
|
|
region.
|
|
|
|
|
|
|
|
Lines are 0-indexed. |api-indexing| To clear the namespace in the entire
|
|
|
|
buffer, specify line_start=0 and line_end=-1.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {ns_id} Namespace to clear, or -1 to clear all namespaces.
|
|
|
|
• {line_start} Start of range of lines to clear
|
|
|
|
• {line_end} End of range of lines to clear (exclusive) or -1 to
|
2021-11-18 14:50:55 -07:00
|
|
|
clear to end of buffer.
|
|
|
|
|
|
|
|
nvim_buf_del_extmark({buffer}, {ns_id}, {id}) *nvim_buf_del_extmark()*
|
2022-12-12 08:15:31 -07:00
|
|
|
Removes an |extmark|.
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {ns_id} Namespace id from |nvim_create_namespace()|
|
|
|
|
• {id} Extmark id
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
true if the extmark was found, else false
|
|
|
|
|
|
|
|
*nvim_buf_get_extmark_by_id()*
|
|
|
|
nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {opts})
|
2022-12-12 08:15:31 -07:00
|
|
|
Gets the position (0-indexed) of an |extmark|.
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {ns_id} Namespace id from |nvim_create_namespace()|
|
|
|
|
• {id} Extmark id
|
|
|
|
• {opts} Optional parameters. Keys:
|
2021-11-18 14:50:55 -07:00
|
|
|
• details: Whether to include the details dict
|
2023-03-24 18:24:24 -07:00
|
|
|
• hl_name: Whether to include highlight group name instead
|
|
|
|
of id, true if omitted
|
2021-11-18 14:50:55 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
0-indexed (row, col) tuple or empty list () if extmark id was absent
|
|
|
|
|
|
|
|
*nvim_buf_get_extmarks()*
|
feat(extmark): support proper multiline ranges
The removes the previous restriction that nvim_buf_set_extmark()
could not be used to highlight arbitrary multi-line regions
The problem can be summarized as follows: let's assume an extmark with a
hl_group is placed covering the region (5,0) to (50,0) Now, consider
what happens if nvim needs to redraw a window covering the lines 20-30.
It needs to be able to ask the marktree what extmarks cover this region,
even if they don't begin or end here.
Therefore the marktree needs to be augmented with the information covers
a point, not just what marks begin or end there. To do this, we augment
each node with a field "intersect" which is a set the ids of the
marks which overlap this node, but only if it is not part of the set of
any parent. This ensures the number of nodes that need to be explicitly
marked grows only logarithmically with the total number of explicitly
nodes (and thus the number of of overlapping marks).
Thus we can quickly iterate all marks which overlaps any query position
by looking up what leaf node contains that position. Then we only need
to consider all "start" marks within that leaf node, and the "intersect"
set of that node and all its parents.
Now, and the major source of complexity is that the tree restructuring
operations (to ensure that each node has T-1 <= size <= 2*T-1) also need
to update these sets. If a full inner node is split in two, one of the
new parents might start to completely overlap some ranges and its ids
will need to be moved from its children's sets to its own set.
Similarly, if two undersized nodes gets joined into one, it might no
longer completely overlap some ranges, and now the children which do
needs to have the have the ids in its set instead. And then there are
the pivots! Yes the pivot operations when a child gets moved from one
parent to another.
2020-11-22 02:10:37 -07:00
|
|
|
nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {*opts})
|
2023-11-10 16:52:50 -07:00
|
|
|
Gets |extmarks| (including |signs|) in "traversal order" from a |charwise|
|
|
|
|
region defined by buffer positions (inclusive, 0-indexed |api-indexing|).
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
Region can be given as (row,col) tuples, or valid extmark ids (whose
|
|
|
|
positions define the bounds). 0 and -1 are understood as (0,0) and (-1,-1)
|
2022-11-23 04:31:49 -07:00
|
|
|
respectively, thus the following are equivalent: >lua
|
2023-09-14 06:23:01 -07:00
|
|
|
vim.api.nvim_buf_get_extmarks(0, my_ns, 0, -1, {})
|
|
|
|
vim.api.nvim_buf_get_extmarks(0, my_ns, {0,0}, {-1,-1}, {})
|
2021-11-18 14:50:55 -07:00
|
|
|
<
|
|
|
|
|
2022-03-13 05:48:14 -07:00
|
|
|
If `end` is less than `start`, traversal works backwards. (Useful with
|
|
|
|
`limit`, to get the first marks prior to a given position.)
|
2021-11-18 14:50:55 -07:00
|
|
|
|
feat(extmark): support proper multiline ranges
The removes the previous restriction that nvim_buf_set_extmark()
could not be used to highlight arbitrary multi-line regions
The problem can be summarized as follows: let's assume an extmark with a
hl_group is placed covering the region (5,0) to (50,0) Now, consider
what happens if nvim needs to redraw a window covering the lines 20-30.
It needs to be able to ask the marktree what extmarks cover this region,
even if they don't begin or end here.
Therefore the marktree needs to be augmented with the information covers
a point, not just what marks begin or end there. To do this, we augment
each node with a field "intersect" which is a set the ids of the
marks which overlap this node, but only if it is not part of the set of
any parent. This ensures the number of nodes that need to be explicitly
marked grows only logarithmically with the total number of explicitly
nodes (and thus the number of of overlapping marks).
Thus we can quickly iterate all marks which overlaps any query position
by looking up what leaf node contains that position. Then we only need
to consider all "start" marks within that leaf node, and the "intersect"
set of that node and all its parents.
Now, and the major source of complexity is that the tree restructuring
operations (to ensure that each node has T-1 <= size <= 2*T-1) also need
to update these sets. If a full inner node is split in two, one of the
new parents might start to completely overlap some ranges and its ids
will need to be moved from its children's sets to its own set.
Similarly, if two undersized nodes gets joined into one, it might no
longer completely overlap some ranges, and now the children which do
needs to have the have the ids in its set instead. And then there are
the pivots! Yes the pivot operations when a child gets moved from one
parent to another.
2020-11-22 02:10:37 -07:00
|
|
|
Note: when using extmark ranges (marks with a end_row/end_col position)
|
|
|
|
the `overlap` option might be useful. Otherwise only the start position of
|
|
|
|
an extmark will be considered.
|
|
|
|
|
2022-11-23 04:31:49 -07:00
|
|
|
Example: >lua
|
2023-09-14 06:23:01 -07:00
|
|
|
local api = vim.api
|
|
|
|
local pos = api.nvim_win_get_cursor(0)
|
|
|
|
local ns = api.nvim_create_namespace('my-plugin')
|
|
|
|
-- Create new extmark at line 1, column 1.
|
|
|
|
local m1 = api.nvim_buf_set_extmark(0, ns, 0, 0, {})
|
|
|
|
-- Create new extmark at line 3, column 1.
|
|
|
|
local m2 = api.nvim_buf_set_extmark(0, ns, 2, 0, {})
|
|
|
|
-- Get extmarks only from line 3.
|
|
|
|
local ms = api.nvim_buf_get_extmarks(0, ns, {2,0}, {2,0}, {})
|
|
|
|
-- Get all marks in this buffer + namespace.
|
|
|
|
local all = api.nvim_buf_get_extmarks(0, ns, 0, -1, {})
|
|
|
|
vim.print(ms)
|
2021-11-18 14:50:55 -07:00
|
|
|
<
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
2023-03-24 18:24:24 -07:00
|
|
|
• {ns_id} Namespace id from |nvim_create_namespace()| or -1 for all
|
|
|
|
namespaces
|
2022-10-05 05:15:55 -07:00
|
|
|
• {start} Start of range: a 0-indexed (row, col) or valid extmark id
|
2021-11-18 14:50:55 -07:00
|
|
|
(whose position defines the bound). |api-indexing|
|
2022-10-05 05:15:55 -07:00
|
|
|
• {end} End of range (inclusive): a 0-indexed (row, col) or valid
|
2021-11-18 14:50:55 -07:00
|
|
|
extmark id (whose position defines the bound).
|
|
|
|
|api-indexing|
|
2022-10-05 05:15:55 -07:00
|
|
|
• {opts} Optional parameters. Keys:
|
2021-11-18 14:50:55 -07:00
|
|
|
• limit: Maximum number of marks to return
|
2023-03-24 18:24:24 -07:00
|
|
|
• details: Whether to include the details dict
|
|
|
|
• hl_name: Whether to include highlight group name instead
|
|
|
|
of id, true if omitted
|
feat(extmark): support proper multiline ranges
The removes the previous restriction that nvim_buf_set_extmark()
could not be used to highlight arbitrary multi-line regions
The problem can be summarized as follows: let's assume an extmark with a
hl_group is placed covering the region (5,0) to (50,0) Now, consider
what happens if nvim needs to redraw a window covering the lines 20-30.
It needs to be able to ask the marktree what extmarks cover this region,
even if they don't begin or end here.
Therefore the marktree needs to be augmented with the information covers
a point, not just what marks begin or end there. To do this, we augment
each node with a field "intersect" which is a set the ids of the
marks which overlap this node, but only if it is not part of the set of
any parent. This ensures the number of nodes that need to be explicitly
marked grows only logarithmically with the total number of explicitly
nodes (and thus the number of of overlapping marks).
Thus we can quickly iterate all marks which overlaps any query position
by looking up what leaf node contains that position. Then we only need
to consider all "start" marks within that leaf node, and the "intersect"
set of that node and all its parents.
Now, and the major source of complexity is that the tree restructuring
operations (to ensure that each node has T-1 <= size <= 2*T-1) also need
to update these sets. If a full inner node is split in two, one of the
new parents might start to completely overlap some ranges and its ids
will need to be moved from its children's sets to its own set.
Similarly, if two undersized nodes gets joined into one, it might no
longer completely overlap some ranges, and now the children which do
needs to have the have the ids in its set instead. And then there are
the pivots! Yes the pivot operations when a child gets moved from one
parent to another.
2020-11-22 02:10:37 -07:00
|
|
|
• overlap: Also include marks which overlap the range, even
|
|
|
|
if their start position is less than `start`
|
2023-03-24 18:24:24 -07:00
|
|
|
• type: Filter marks by type: "highlight", "sign",
|
|
|
|
"virt_text" and "virt_lines"
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
Return: ~
|
|
|
|
List of [extmark_id, row, col] tuples in "traversal order".
|
|
|
|
|
2019-11-09 04:41:50 -07:00
|
|
|
*nvim_buf_set_extmark()*
|
2021-10-05 10:48:48 -07:00
|
|
|
nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts})
|
2022-12-12 08:15:31 -07:00
|
|
|
Creates or updates an |extmark|.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-05-17 06:35:53 -07:00
|
|
|
By default a new extmark is created when no id is passed in, but it is
|
|
|
|
also possible to create a new mark by passing in a previously unused id or
|
|
|
|
move an existing mark by passing in its id. The caller must then keep
|
|
|
|
track of existing and unused ids itself. (Useful over RPC, to avoid
|
|
|
|
waiting for the return value.)
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2020-09-06 16:55:49 -07:00
|
|
|
Using the optional arguments, it is possible to use this to highlight a
|
|
|
|
range of text, and also to associate virtual text to the mark.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
feat(extmark): support proper multiline ranges
The removes the previous restriction that nvim_buf_set_extmark()
could not be used to highlight arbitrary multi-line regions
The problem can be summarized as follows: let's assume an extmark with a
hl_group is placed covering the region (5,0) to (50,0) Now, consider
what happens if nvim needs to redraw a window covering the lines 20-30.
It needs to be able to ask the marktree what extmarks cover this region,
even if they don't begin or end here.
Therefore the marktree needs to be augmented with the information covers
a point, not just what marks begin or end there. To do this, we augment
each node with a field "intersect" which is a set the ids of the
marks which overlap this node, but only if it is not part of the set of
any parent. This ensures the number of nodes that need to be explicitly
marked grows only logarithmically with the total number of explicitly
nodes (and thus the number of of overlapping marks).
Thus we can quickly iterate all marks which overlaps any query position
by looking up what leaf node contains that position. Then we only need
to consider all "start" marks within that leaf node, and the "intersect"
set of that node and all its parents.
Now, and the major source of complexity is that the tree restructuring
operations (to ensure that each node has T-1 <= size <= 2*T-1) also need
to update these sets. If a full inner node is split in two, one of the
new parents might start to completely overlap some ranges and its ids
will need to be moved from its children's sets to its own set.
Similarly, if two undersized nodes gets joined into one, it might no
longer completely overlap some ranges, and now the children which do
needs to have the have the ids in its set instead. And then there are
the pivots! Yes the pivot operations when a child gets moved from one
parent to another.
2020-11-22 02:10:37 -07:00
|
|
|
If present, the position defined by `end_col` and `end_row` should be
|
|
|
|
after the start position in order for the extmark to cover a range. An
|
|
|
|
earlier end position is not an error, but then it behaves like an empty
|
|
|
|
range (no highlighting).
|
|
|
|
|
2019-11-09 04:41:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer handle, or 0 for current buffer
|
|
|
|
• {ns_id} Namespace id from |nvim_create_namespace()|
|
|
|
|
• {line} Line where to place the mark, 0-based. |api-indexing|
|
|
|
|
• {col} Column where to place the mark, 0-based. |api-indexing|
|
|
|
|
• {opts} Optional parameters.
|
2020-09-06 16:55:49 -07:00
|
|
|
• id : id of the extmark to edit.
|
2021-12-08 08:44:48 -07:00
|
|
|
• end_row : ending line of the mark, 0-based inclusive.
|
2020-09-06 16:55:49 -07:00
|
|
|
• end_col : ending col of the mark, 0-based exclusive.
|
|
|
|
• hl_group : name of the highlight group used to highlight
|
|
|
|
this mark.
|
2021-10-05 10:48:48 -07:00
|
|
|
• hl_eol : when true, for a multiline highlight covering the
|
|
|
|
EOL of a line, continue the highlight for the rest of the
|
|
|
|
screen line (just like for diff and cursorline highlight).
|
2020-09-06 16:55:49 -07:00
|
|
|
• virt_text : virtual text to link to this mark. A list of
|
2021-07-31 13:26:57 -07:00
|
|
|
[text, highlight] tuples, each representing a text chunk
|
|
|
|
with specified highlight. `highlight` element can either
|
|
|
|
be a single highlight group, or an array of multiple
|
|
|
|
highlight groups that will be stacked (highest priority
|
|
|
|
last). A highlight group can be supplied either as a
|
|
|
|
string or as an integer, the latter which can be obtained
|
2022-09-25 16:58:27 -07:00
|
|
|
using |nvim_get_hl_id_by_name()|.
|
2021-07-31 13:26:57 -07:00
|
|
|
• virt_text_pos : position of virtual text. Possible values:
|
2023-07-12 16:02:06 -07:00
|
|
|
• "eol": right after eol character (default).
|
2021-02-24 15:44:52 -07:00
|
|
|
• "overlay": display over the specified column, without
|
|
|
|
shifting the underlying text.
|
2021-05-31 10:47:51 -07:00
|
|
|
• "right_align": display right aligned in the window.
|
2023-05-06 06:14:00 -07:00
|
|
|
• "inline": display at the specified column, and shift the
|
2023-07-12 16:02:06 -07:00
|
|
|
buffer text to the right as needed.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-05-31 10:47:51 -07:00
|
|
|
• virt_text_win_col : position the virtual text at a fixed
|
2023-07-12 16:02:06 -07:00
|
|
|
window column (starting from the first text column of the
|
|
|
|
screen line) instead of "virt_text_pos".
|
2021-03-11 08:11:11 -07:00
|
|
|
• virt_text_hide : hide the virtual text when the background
|
2023-05-27 20:09:25 -07:00
|
|
|
text is selected or hidden because of scrolling with
|
|
|
|
'nowrap' or 'smoothscroll'. Currently only affects
|
|
|
|
"overlay" virt_text.
|
2021-03-11 08:11:11 -07:00
|
|
|
• hl_mode : control how highlights are combined with the
|
|
|
|
highlights of the text. Currently only affects virt_text
|
2021-10-19 12:55:22 -07:00
|
|
|
highlights, but might affect `hl_group` in later versions.
|
2021-03-11 08:11:11 -07:00
|
|
|
• "replace": only show the virt_text color. This is the
|
2023-06-22 05:39:35 -07:00
|
|
|
default.
|
|
|
|
• "combine": combine with background text color.
|
|
|
|
• "blend": blend with background text color. Not supported
|
|
|
|
for "inline" virt_text.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-05 10:48:48 -07:00
|
|
|
• virt_lines : virtual lines to add next to this mark This
|
|
|
|
should be an array over lines, where each line in turn is
|
|
|
|
an array over [text, highlight] tuples. In general, buffer
|
|
|
|
and window options do not affect the display of the text.
|
|
|
|
In particular 'wrap' and 'linebreak' options do not take
|
|
|
|
effect, so the number of extra screen lines will always
|
|
|
|
match the size of the array. However the 'tabstop' buffer
|
|
|
|
option is still used for hard tabs. By default lines are
|
|
|
|
placed below the buffer line containing the mark.
|
|
|
|
• virt_lines_above: place virtual lines above instead.
|
|
|
|
• virt_lines_leftcol: Place extmarks in the leftmost column
|
|
|
|
of the window, bypassing sign and number columns.
|
2022-09-25 16:58:27 -07:00
|
|
|
• ephemeral : for use with |nvim_set_decoration_provider()|
|
2020-10-20 12:57:07 -07:00
|
|
|
callbacks. The mark will only be used for the current
|
|
|
|
redraw cycle, and not be permantently stored in the
|
|
|
|
buffer.
|
2021-01-23 11:31:01 -07:00
|
|
|
• right_gravity : boolean that indicates the direction the
|
|
|
|
extmark will be shifted in when new text is inserted (true
|
2023-02-21 09:07:26 -07:00
|
|
|
for right, false for left). Defaults to true.
|
2021-01-23 11:31:01 -07:00
|
|
|
• end_right_gravity : boolean that indicates the direction
|
|
|
|
the extmark end position (if it exists) will be shifted in
|
|
|
|
when new text is inserted (true for right, false for
|
|
|
|
left). Defaults to false.
|
2023-10-24 04:32:00 -07:00
|
|
|
• undo_restore : Restore the exact position of the mark if
|
|
|
|
text around the mark was deleted and then restored by
|
|
|
|
undo. Defaults to true.
|
|
|
|
• invalidate : boolean that indicates whether to hide the
|
|
|
|
extmark if the entirety of its range is deleted. If
|
|
|
|
"undo_restore" is false, the extmark is deleted instead.
|
2022-08-11 09:26:17 -07:00
|
|
|
• priority: a priority value for the highlight group or sign
|
|
|
|
attribute. For example treesitter highlighting uses a
|
|
|
|
value of 100.
|
2022-01-17 11:28:23 -07:00
|
|
|
• strict: boolean that indicates extmark should not be
|
|
|
|
placed if the line or column value is past the end of the
|
|
|
|
buffer or end of the line respectively. Defaults to true.
|
2022-03-20 11:00:30 -07:00
|
|
|
• sign_text: string of length 1-2 used to display in the
|
|
|
|
sign column. Note: ranges are unsupported and decorations
|
|
|
|
are only applied to start_row
|
|
|
|
• sign_hl_group: name of the highlight group used to
|
|
|
|
highlight the sign column text. Note: ranges are
|
|
|
|
unsupported and decorations are only applied to start_row
|
|
|
|
• number_hl_group: name of the highlight group used to
|
|
|
|
highlight the number column. Note: ranges are unsupported
|
|
|
|
and decorations are only applied to start_row
|
|
|
|
• line_hl_group: name of the highlight group used to
|
|
|
|
highlight the whole line. Note: ranges are unsupported and
|
|
|
|
decorations are only applied to start_row
|
|
|
|
• cursorline_hl_group: name of the highlight group used to
|
|
|
|
highlight the line when the cursor is on the same line as
|
|
|
|
the mark and 'cursorline' is enabled. Note: ranges are
|
|
|
|
unsupported and decorations are only applied to start_row
|
|
|
|
• conceal: string which should be either empty or a single
|
|
|
|
character. Enable concealing similar to |:syn-conceal|.
|
|
|
|
When a character is supplied it is used as |:syn-cchar|.
|
|
|
|
"hl_group" is used as highlight for the cchar if provided,
|
|
|
|
otherwise it defaults to |hl-Conceal|.
|
2022-07-18 05:21:40 -07:00
|
|
|
• spell: boolean indicating that spell checking should be
|
|
|
|
performed within this extmark
|
2021-09-15 16:53:56 -07:00
|
|
|
• ui_watched: boolean that indicates the mark should be
|
|
|
|
drawn by a UI. When set, the UI will receive win_extmark
|
|
|
|
events. Note: the mark is positioned by virt_text
|
|
|
|
attributes. Can be used together with virt_text.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2019-11-09 04:41:50 -07:00
|
|
|
Return: ~
|
2019-11-25 02:08:02 -07:00
|
|
|
Id of the created/updated extmark
|
2019-11-09 04:41:50 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
nvim_create_namespace({name}) *nvim_create_namespace()*
|
2022-12-14 02:46:54 -07:00
|
|
|
Creates a new namespace or gets an existing one. *namespace*
|
2021-10-05 08:49:20 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
Namespaces are used for buffer highlights and virtual text, see
|
|
|
|
|nvim_buf_add_highlight()| and |nvim_buf_set_extmark()|.
|
2021-10-05 08:49:20 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
Namespaces can be named or anonymous. If `name` matches an existing
|
|
|
|
namespace, the associated id is returned. If `name` is an empty string a
|
|
|
|
new, anonymous namespace is created.
|
2021-10-05 08:49:20 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} Namespace name or empty string
|
2021-10-05 08:49:20 -07:00
|
|
|
|
|
|
|
Return: ~
|
2021-11-18 14:50:55 -07:00
|
|
|
Namespace id
|
2019-12-28 04:27:25 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
nvim_get_namespaces() *nvim_get_namespaces()*
|
2022-12-12 08:15:31 -07:00
|
|
|
Gets existing, non-anonymous |namespace|s.
|
2021-01-01 12:24:40 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
Return: ~
|
|
|
|
dict that maps from names to namespace ids.
|
2021-01-01 12:24:40 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
*nvim_set_decoration_provider()*
|
2022-07-18 05:21:40 -07:00
|
|
|
nvim_set_decoration_provider({ns_id}, {*opts})
|
2022-12-12 08:15:31 -07:00
|
|
|
Set or change decoration provider for a |namespace|
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2023-06-22 03:44:51 -07:00
|
|
|
This is a very general purpose interface for having Lua callbacks being
|
2021-11-18 14:50:55 -07:00
|
|
|
triggered during the redraw code.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-12-12 08:15:31 -07:00
|
|
|
The expected usage is to set |extmarks| for the currently redrawn buffer.
|
2022-09-25 16:58:27 -07:00
|
|
|
|nvim_buf_set_extmark()| can be called to add marks on a per-window or
|
2021-11-18 14:50:55 -07:00
|
|
|
per-lines basis. Use the `ephemeral` key to only use the mark for the
|
|
|
|
current screen redraw (the callback will be called again for the next
|
2023-10-24 04:32:00 -07:00
|
|
|
redraw).
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
Note: this function should not be called often. Rather, the callbacks
|
|
|
|
themselves can be used to throttle unneeded callbacks. the `on_start`
|
|
|
|
callback can return `false` to disable the provider until the next redraw.
|
|
|
|
Similarly, return `false` in `on_win` will skip the `on_lines` calls for
|
|
|
|
that window (but any extmarks set in `on_win` will still be used). A
|
|
|
|
plugin managing multiple sources of decoration should ideally only set one
|
|
|
|
provider, and merge the sources internally. You can use multiple `ns_id`
|
|
|
|
for the extmarks set/modified inside the callback anyway.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-11-18 14:50:55 -07:00
|
|
|
Note: doing anything other than setting extmarks is considered
|
2023-04-27 09:30:22 -07:00
|
|
|
experimental. Doing things like changing options are not explicitly
|
2021-11-18 14:50:55 -07:00
|
|
|
forbidden, but is likely to have unexpected consequences (such as 100% CPU
|
|
|
|
consumption). doing `vim.rpcnotify` should be OK, but `vim.rpcrequest` is
|
|
|
|
quite dubious for the moment.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2023-04-27 09:30:22 -07:00
|
|
|
Note: It is not allowed to remove or update extmarks in 'on_line'
|
|
|
|
callbacks.
|
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
2022-10-09 05:21:52 -07:00
|
|
|
Lua |vim.api| only
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {ns_id} Namespace id from |nvim_create_namespace()|
|
|
|
|
• {opts} Table of callbacks:
|
2021-11-18 14:50:55 -07:00
|
|
|
• 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.
|
2023-09-11 12:29:39 -07:00
|
|
|
botline_guess is an approximation that does not exceed the
|
|
|
|
last line number. ["win", winid, bufnr, topline,
|
|
|
|
botline_guess]
|
2021-11-18 14:50:55 -07:00
|
|
|
• on_line: called for each buffer line being redrawn. (The
|
2021-11-27 09:26:49 -07:00
|
|
|
interaction with fold lines is subject to change) ["win",
|
2021-11-18 14:50:55 -07:00
|
|
|
winid, bufnr, row]
|
|
|
|
• on_end: called at the end of a redraw cycle ["end", tick]
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-11-10 08:38:04 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
==============================================================================
|
|
|
|
Window Functions *api-window*
|
2019-11-10 08:38:04 -07:00
|
|
|
|
2021-06-10 01:03:28 -07:00
|
|
|
nvim_win_call({window}, {fun}) *nvim_win_call()*
|
|
|
|
Calls a function with window as temporary current window.
|
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
2022-10-09 05:21:52 -07:00
|
|
|
Lua |vim.api| only
|
2022-04-30 16:16:16 -07:00
|
|
|
|
2021-06-10 01:03:28 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
2023-06-22 03:44:51 -07:00
|
|
|
• {fun} Function to call inside the window (currently Lua callable
|
2021-06-10 01:03:28 -07:00
|
|
|
only)
|
|
|
|
|
|
|
|
Return: ~
|
2023-06-22 03:44:51 -07:00
|
|
|
Return value of function. NB: will deepcopy Lua values currently, use
|
|
|
|
upvalues to send Lua references in and out.
|
2021-06-10 01:03:28 -07:00
|
|
|
|
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |win_execute()|
|
|
|
|
• |nvim_buf_call()|
|
2021-06-10 01:03:28 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_win_close({window}, {force}) *nvim_win_close()*
|
|
|
|
Closes the window (like |:close| with a |window-ID|).
|
2019-11-10 08:38:04 -07:00
|
|
|
|
2020-11-24 05:37:29 -07:00
|
|
|
Attributes: ~
|
|
|
|
not allowed when |textlock| is active
|
|
|
|
|
2019-11-10 08:38:04 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
|
|
|
• {force} Behave like `:close!` The last window of a buffer with
|
2019-12-28 04:27:25 -07:00
|
|
|
unwritten changes can be closed. The buffer will become
|
|
|
|
hidden, even if 'hidden' is not set.
|
2019-08-25 16:01:01 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_win_del_var({window}, {name}) *nvim_win_del_var()*
|
|
|
|
Removes a window-scoped (w:) variable
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
|
|
|
• {name} Variable name
|
2017-03-01 09:18:03 -07:00
|
|
|
|
|
|
|
nvim_win_get_buf({window}) *nvim_win_get_buf()*
|
|
|
|
Gets the current buffer in a window
|
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2017-03-01 09:18:03 -07:00
|
|
|
Buffer handle
|
|
|
|
|
|
|
|
nvim_win_get_cursor({window}) *nvim_win_get_cursor()*
|
2022-10-09 05:21:52 -07:00
|
|
|
Gets the (1,0)-indexed, buffer-relative cursor position for a given window
|
|
|
|
(different windows showing the same buffer have independent cursor
|
|
|
|
positions). |api-indexing|
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2017-03-01 09:18:03 -07:00
|
|
|
(row, col) tuple
|
|
|
|
|
2023-06-19 02:24:44 -07:00
|
|
|
See also: ~
|
|
|
|
• |getcurpos()|
|
|
|
|
|
2017-03-01 09:18:03 -07:00
|
|
|
nvim_win_get_height({window}) *nvim_win_get_height()*
|
|
|
|
Gets the window height
|
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2017-03-01 09:18:03 -07:00
|
|
|
Height as a count of rows
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_win_get_number({window}) *nvim_win_get_number()*
|
|
|
|
Gets the window number
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
Window number
|
2017-03-01 09:18:03 -07:00
|
|
|
|
|
|
|
nvim_win_get_position({window}) *nvim_win_get_position()*
|
|
|
|
Gets the window position in display cells. First position is zero.
|
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2017-03-01 09:18:03 -07:00
|
|
|
(row, col) tuple with the window position
|
|
|
|
|
|
|
|
nvim_win_get_tabpage({window}) *nvim_win_get_tabpage()*
|
|
|
|
Gets the window tabpage
|
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2017-03-01 09:18:03 -07:00
|
|
|
Tabpage that contains the window
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_win_get_var({window}, {name}) *nvim_win_get_var()*
|
|
|
|
Gets a window-scoped (w:) variable
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
|
|
|
• {name} Variable name
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
Variable value
|
|
|
|
|
|
|
|
nvim_win_get_width({window}) *nvim_win_get_width()*
|
|
|
|
Gets the window width
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Width as a count of columns
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2021-03-15 23:02:20 -07:00
|
|
|
nvim_win_hide({window}) *nvim_win_hide()*
|
|
|
|
Closes the window and hide the buffer it contains (like |:hide| with a
|
|
|
|
|window-ID|).
|
|
|
|
|
|
|
|
Like |:hide| the buffer becomes hidden unless another window is editing
|
2022-03-13 05:48:14 -07:00
|
|
|
it, or 'bufhidden' is `unload`, `delete` or `wipe` as opposed to |:close|
|
2022-09-25 16:58:27 -07:00
|
|
|
or |nvim_win_close()|, which will close the buffer.
|
2021-03-15 23:02:20 -07:00
|
|
|
|
|
|
|
Attributes: ~
|
2023-07-24 06:19:01 -07:00
|
|
|
not allowed when |textlock| is active
|
2021-03-15 23:02:20 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
2021-03-15 23:02:20 -07:00
|
|
|
|
2017-03-01 09:18:03 -07:00
|
|
|
nvim_win_is_valid({window}) *nvim_win_is_valid()*
|
|
|
|
Checks if a window is valid
|
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2017-03-01 09:18:03 -07:00
|
|
|
true if the window is valid, false otherwise
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_win_set_buf({window}, {buffer}) *nvim_win_set_buf()*
|
|
|
|
Sets the current buffer in a window, without side effects
|
|
|
|
|
2020-11-24 05:37:29 -07:00
|
|
|
Attributes: ~
|
2023-07-23 11:50:20 -07:00
|
|
|
not allowed when |textlock| is active
|
2020-11-24 05:37:29 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
|
|
|
• {buffer} Buffer handle
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
nvim_win_set_cursor({window}, {pos}) *nvim_win_set_cursor()*
|
|
|
|
Sets the (1,0)-indexed cursor position in the window. |api-indexing| This
|
2022-03-20 11:00:30 -07:00
|
|
|
scrolls the window even if it is not the current one.
|
2019-03-15 10:18:56 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
|
|
|
• {pos} (row, col) tuple representing the new position
|
2019-03-15 10:18:56 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_win_set_height({window}, {height}) *nvim_win_set_height()*
|
|
|
|
Sets the window height.
|
2019-03-15 10:18:56 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
|
|
|
• {height} Height as a count of rows
|
2019-03-15 10:18:56 -07:00
|
|
|
|
2022-07-25 01:16:33 -07:00
|
|
|
nvim_win_set_hl_ns({window}, {ns_id}) *nvim_win_set_hl_ns()*
|
2023-03-16 01:31:37 -07:00
|
|
|
Set highlight namespace for a window. This will use highlights defined
|
|
|
|
with |nvim_set_hl()| for this namespace, but fall back to global
|
|
|
|
highlights (ns=0) when missing.
|
2022-07-25 01:16:33 -07:00
|
|
|
|
|
|
|
This takes precedence over the 'winhighlight' option.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {ns_id} the namespace to use
|
2022-07-25 01:16:33 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_win_set_var({window}, {name}, {value}) *nvim_win_set_var()*
|
|
|
|
Sets a window-scoped (w:) variable
|
2019-03-12 05:46:02 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
|
|
|
• {name} Variable name
|
|
|
|
• {value} Variable value
|
2019-12-28 04:27:25 -07:00
|
|
|
|
|
|
|
nvim_win_set_width({window}, {width}) *nvim_win_set_width()*
|
|
|
|
Sets the window width. This will only succeed if the screen is split
|
|
|
|
vertically.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
|
|
|
• {width} Width as a count of columns
|
2019-03-12 05:46:02 -07:00
|
|
|
|
2023-07-10 16:15:46 -07:00
|
|
|
nvim_win_text_height({window}, {*opts}) *nvim_win_text_height()*
|
|
|
|
Computes the number of screen lines occupied by a range of text in a given
|
|
|
|
window. Works for off-screen text and takes folds into account.
|
|
|
|
|
|
|
|
Diff filler or virtual lines above a line are counted as a part of that
|
|
|
|
line, unless the line is on "start_row" and "start_vcol" is specified.
|
|
|
|
|
|
|
|
Diff filler or virtual lines below the last buffer line are counted in the
|
|
|
|
result when "end_row" is omitted.
|
|
|
|
|
|
|
|
Line indexing is similar to |nvim_buf_get_text()|.
|
|
|
|
|
|
|
|
Parameters: ~
|
|
|
|
• {window} Window handle, or 0 for current window.
|
|
|
|
• {opts} Optional parameters:
|
|
|
|
• start_row: Starting line index, 0-based inclusive. When
|
|
|
|
omitted start at the very top.
|
|
|
|
• end_row: Ending line index, 0-based inclusive. When
|
|
|
|
omitted end at the very bottom.
|
|
|
|
• start_vcol: Starting virtual column index on "start_row",
|
|
|
|
0-based inclusive, rounded down to full screen lines. When
|
|
|
|
omitted include the whole line.
|
|
|
|
• end_vcol: Ending virtual column index on "end_row",
|
|
|
|
0-based exclusive, rounded up to full screen lines. When
|
|
|
|
omitted include the whole line.
|
|
|
|
|
|
|
|
Return: ~
|
2023-07-16 03:02:53 -07:00
|
|
|
Dictionary containing text height information, with these keys:
|
|
|
|
• all: The total number of screen lines occupied by the range.
|
|
|
|
• fill: The number of diff filler or virtual lines among them.
|
2023-07-10 16:15:46 -07:00
|
|
|
|
|
|
|
See also: ~
|
|
|
|
• |virtcol()| for text width.
|
|
|
|
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2021-10-05 10:48:48 -07:00
|
|
|
==============================================================================
|
|
|
|
Win_Config Functions *api-win_config*
|
|
|
|
|
|
|
|
nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()*
|
|
|
|
Open a new window.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-05 10:48:48 -07:00
|
|
|
Currently this is used to open floating and external windows. Floats are
|
|
|
|
windows that are drawn above the split layout, at some anchor position in
|
|
|
|
some other window. Floats can be drawn internally or by external GUI with
|
|
|
|
the |ui-multigrid| extension. External windows are only supported with
|
|
|
|
multigrid GUIs, and are displayed as separate top-level windows.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-05 10:48:48 -07:00
|
|
|
For a general overview of floats, see |api-floatwin|.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-05 10:48:48 -07:00
|
|
|
Exactly one of `external` and `relative` must be specified. The `width`
|
|
|
|
and `height` of the new window must be specified.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-05 10:48:48 -07:00
|
|
|
With relative=editor (row=0,col=0) refers to the top-left corner of the
|
|
|
|
screen-grid and (row=Lines-1,col=Columns-1) refers to the bottom-right
|
|
|
|
corner. Fractional values are allowed, but the builtin implementation
|
|
|
|
(used by non-multigrid UIs) will always round down to nearest integer.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-05 10:48:48 -07:00
|
|
|
Out-of-bounds values, and configurations that make the float not fit
|
|
|
|
inside the main editor, are allowed. The builtin implementation truncates
|
|
|
|
values so floats are fully within the main screen grid. External GUIs
|
|
|
|
could let floats hover outside of the main window like a tooltip, but this
|
|
|
|
should not be used to specify arbitrary WM screen positions.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-11-23 04:31:49 -07:00
|
|
|
Example (Lua): window-relative float >lua
|
2021-10-05 10:48:48 -07:00
|
|
|
vim.api.nvim_open_win(0, false,
|
|
|
|
{relative='win', row=3, col=3, width=12, height=3})
|
|
|
|
<
|
|
|
|
|
2022-11-23 04:31:49 -07:00
|
|
|
Example (Lua): buffer-relative float (travels as buffer is scrolled) >lua
|
2021-10-05 10:48:48 -07:00
|
|
|
vim.api.nvim_open_win(0, false,
|
|
|
|
{relative='win', width=12, height=3, bufpos={100,10}})
|
2023-09-14 06:23:01 -07:00
|
|
|
})
|
2021-10-05 10:48:48 -07:00
|
|
|
<
|
|
|
|
|
|
|
|
Attributes: ~
|
2023-07-23 11:50:20 -07:00
|
|
|
not allowed when |textlock| is active
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-05 10:48:48 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {buffer} Buffer to display, or 0 for current buffer
|
|
|
|
• {enter} Enter the window (make it the current window)
|
|
|
|
• {config} Map defining the window configuration. Keys:
|
2021-10-19 12:55:22 -07:00
|
|
|
• relative: Sets the window layout to "floating", placed at
|
|
|
|
(row,col) coordinates relative to:
|
2021-10-05 10:48:48 -07:00
|
|
|
• "editor" The global editor grid
|
|
|
|
• "win" Window given by the `win` field, or current
|
|
|
|
window.
|
|
|
|
• "cursor" Cursor position in current window.
|
feat(float): open float relative to mouse #21531
Problem:
No easy way to position a LSP hover window relative to mouse.
Solution:
Introduce another option to the `relative` key in `nvim_open_win()`.
With this PR it should be possible to override the handler and do something
similar to this https://github.com/neovim/neovim/pull/19481#issuecomment-1193248674
to have hover information displayed from the mouse.
Test case:
```lua
local util = require('vim.lsp.util')
local function make_position_param(window, offset_encoding)
window = window or 0
local buf = vim.api.nvim_win_get_buf(window)
local row, col
local mouse = vim.fn.getmousepos()
row = mouse.line
col = mouse.column
offset_encoding = offset_encoding or util._get_offset_encoding(buf)
row = row - 1
local line = vim.api.nvim_buf_get_lines(buf, row, row + 1, true)[1]
if not line then
return { line = 0, character = 0 }
end
if #line < col then
return { line = 0, character = 0 }
end
col = util._str_utfindex_enc(line, col, offset_encoding)
return { line = row, character = col }
end
local make_params = function(window, offset_encoding)
window = window or 0
local buf = vim.api.nvim_win_get_buf(window)
offset_encoding = offset_encoding or util._get_offset_encoding(buf)
return {
textDocument = util.make_text_document_params(buf),
position = make_position_param(window, offset_encoding),
}
end
local hover_timer = nil
vim.o.mousemoveevent = true
vim.keymap.set({ '', 'i' }, '<MouseMove>', function()
if hover_timer then
hover_timer:close()
end
hover_timer = vim.defer_fn(function()
hover_timer = nil
local params = make_params()
vim.lsp.buf_request(
0,
'textDocument/hover',
params,
vim.lsp.with(vim.lsp.handlers.hover, {
silent = true,
focusable = false,
relative = 'mouse',
})
)
end, 500)
return '<MouseMove>'
end, { expr = true })
```
2023-01-10 03:22:41 -07:00
|
|
|
• "mouse" Mouse position
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-19 12:55:22 -07:00
|
|
|
• win: |window-ID| for relative="win".
|
|
|
|
• anchor: Decides which corner of the float to place at
|
|
|
|
(row,col):
|
2021-10-05 10:48:48 -07:00
|
|
|
• "NW" northwest (default)
|
|
|
|
• "NE" northeast
|
|
|
|
• "SW" southwest
|
|
|
|
• "SE" southeast
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-19 12:55:22 -07:00
|
|
|
• 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
|
2021-10-05 10:48:48 -07:00
|
|
|
default to:
|
|
|
|
• `row=1` and `col=0` if `anchor` is "NW" or "NE"
|
|
|
|
• `row=0` and `col=0` if `anchor` is "SW" or "SE" (thus
|
|
|
|
like a tooltip near the buffer text).
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-19 12:55:22 -07:00
|
|
|
• row: Row position in units of "screen cell height", may be
|
2021-10-05 10:48:48 -07:00
|
|
|
fractional.
|
2021-10-19 12:55:22 -07:00
|
|
|
• col: Column position in units of "screen cell width", may
|
|
|
|
be fractional.
|
|
|
|
• focusable: Enable focus by user actions (wincmds, mouse
|
2021-10-05 10:48:48 -07:00
|
|
|
events). Defaults to true. Non-focusable windows can be
|
|
|
|
entered by |nvim_set_current_win()|.
|
2021-10-19 12:55:22 -07:00
|
|
|
• external: GUI should display the window as 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
|
2021-10-05 10:48:48 -07:00
|
|
|
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.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2023-04-02 10:01:10 -07:00
|
|
|
• style: (optional) Configure the appearance of the window.
|
|
|
|
Currently only supports one value:
|
2021-10-05 10:48:48 -07:00
|
|
|
• "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
|
2023-01-10 02:36:48 -07:00
|
|
|
'colorcolumn' is cleared. 'statuscolumn' is changed to
|
|
|
|
empty. The end-of-buffer region is hidden by setting
|
|
|
|
`eob` flag of 'fillchars' to a space char, and clearing
|
|
|
|
the |hl-EndOfBuffer| region in 'winhighlight'.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-19 12:55:22 -07:00
|
|
|
• border: Style of (optional) window border. This can either
|
|
|
|
be a string or an array. The string values are
|
2021-10-05 10:48:48 -07:00
|
|
|
• "none": No border (default).
|
|
|
|
• "single": A single line box.
|
|
|
|
• "double": A double line box.
|
|
|
|
• "rounded": Like "single", but with rounded corners ("╭"
|
|
|
|
etc.).
|
|
|
|
• "solid": Adds padding by a single whitespace cell.
|
|
|
|
• "shadow": A drop shadow effect by blending with the
|
|
|
|
background.
|
|
|
|
• If it is an array, it should have a length of eight or
|
2023-10-29 01:02:32 -07:00
|
|
|
any divisor of eight. The array will specify the eight
|
2021-10-05 10:48:48 -07:00
|
|
|
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
|
2022-03-26 05:21:32 -07:00
|
|
|
less than eight, they will be repeated. Thus an ASCII
|
2021-10-05 10:48:48 -07:00
|
|
|
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
|
2022-03-20 11:00:30 -07:00
|
|
|
`WinSeparator` when not defined. It could also be
|
2022-12-28 06:08:17 -07:00
|
|
|
specified by character: [ ["+", "MyCorner"], ["x",
|
|
|
|
"MyBorder"] ].
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2023-08-25 00:53:35 -07:00
|
|
|
• title: Title (optional) in window border, string or list.
|
|
|
|
List should consist of `[text, highlight]` tuples. If
|
|
|
|
string, the default highlight group is `FloatTitle`.
|
|
|
|
• title_pos: Title position. Must be set with `title`
|
|
|
|
option. Value can be one of "left", "center", or "right".
|
|
|
|
Default is `"left"`.
|
|
|
|
• footer: Footer (optional) in window border, string or
|
|
|
|
list. List should consist of `[text, highlight]` tuples.
|
2023-08-25 00:53:39 -07:00
|
|
|
If string, the default highlight group is `FloatFooter`.
|
2023-08-25 00:53:35 -07:00
|
|
|
• footer_pos: Footer position. Must be set with `footer`
|
|
|
|
option. Value can be one of "left", "center", or "right".
|
|
|
|
Default is `"left"`.
|
2021-10-19 12:55:22 -07:00
|
|
|
• noautocmd: If true then no buffer-related autocommand
|
2021-10-05 10:48:48 -07:00
|
|
|
events such as |BufEnter|, |BufLeave| or |BufWinEnter| may
|
|
|
|
fire from calling this function.
|
2023-09-13 22:30:51 -07:00
|
|
|
• fixed: If true when anchor is NW or SW, the float window
|
|
|
|
would be kept fixed even if the window would be truncated.
|
2023-09-27 02:23:42 -07:00
|
|
|
• hide: If true the floating window will be hidden.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2021-10-05 10:48:48 -07:00
|
|
|
Return: ~
|
|
|
|
Window handle, or 0 on error
|
|
|
|
|
|
|
|
nvim_win_get_config({window}) *nvim_win_get_config()*
|
|
|
|
Gets window configuration.
|
|
|
|
|
|
|
|
The returned value may be given to |nvim_open_win()|.
|
|
|
|
|
|
|
|
`relative` is empty for normal windows.
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
2021-10-05 10:48:48 -07:00
|
|
|
|
|
|
|
Return: ~
|
|
|
|
Map defining the window configuration, see |nvim_open_win()|
|
|
|
|
|
|
|
|
nvim_win_set_config({window}, {*config}) *nvim_win_set_config()*
|
|
|
|
Configures window layout. Currently only for floating and external windows
|
|
|
|
(including changing a split window to those layouts).
|
|
|
|
|
|
|
|
When reconfiguring a floating window, absent option keys will not be
|
2022-03-13 05:48:14 -07:00
|
|
|
changed. `row`/`col` and `relative` must be reconfigured together.
|
2021-10-05 10:48:48 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {window} Window handle, or 0 for current window
|
|
|
|
• {config} Map defining the window configuration, see |nvim_open_win()|
|
2021-10-05 10:48:48 -07:00
|
|
|
|
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_open_win()|
|
2021-10-05 10:48:48 -07:00
|
|
|
|
|
|
|
|
2017-03-01 09:18:03 -07:00
|
|
|
==============================================================================
|
|
|
|
Tabpage Functions *api-tabpage*
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_tabpage_del_var({tabpage}, {name}) *nvim_tabpage_del_var()*
|
|
|
|
Removes a tab-scoped (t:) variable
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {tabpage} Tabpage handle, or 0 for current tabpage
|
|
|
|
• {name} Variable name
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_tabpage_get_number({tabpage}) *nvim_tabpage_get_number()*
|
|
|
|
Gets the tabpage number
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {tabpage} Tabpage handle, or 0 for current tabpage
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
Tabpage number
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_tabpage_get_var({tabpage}, {name}) *nvim_tabpage_get_var()*
|
|
|
|
Gets a tab-scoped (t:) variable
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {tabpage} Tabpage handle, or 0 for current tabpage
|
|
|
|
• {name} Variable name
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
Return: ~
|
|
|
|
Variable value
|
2017-03-01 09:18:03 -07:00
|
|
|
|
|
|
|
nvim_tabpage_get_win({tabpage}) *nvim_tabpage_get_win()*
|
|
|
|
Gets the current window in a tabpage
|
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {tabpage} Tabpage handle, or 0 for current tabpage
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2017-03-01 09:18:03 -07:00
|
|
|
Window handle
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_tabpage_is_valid({tabpage}) *nvim_tabpage_is_valid()*
|
|
|
|
Checks if a tabpage is valid
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {tabpage} Tabpage handle, or 0 for current tabpage
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
true if the tabpage is valid, false otherwise
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_tabpage_list_wins({tabpage}) *nvim_tabpage_list_wins()*
|
|
|
|
Gets the windows in a tabpage
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {tabpage} Tabpage handle, or 0 for current tabpage
|
2017-03-01 09:18:03 -07:00
|
|
|
|
2018-06-29 10:27:50 -07:00
|
|
|
Return: ~
|
2019-12-28 04:27:25 -07:00
|
|
|
List of windows in `tabpage`
|
|
|
|
|
2019-12-31 07:52:14 -07:00
|
|
|
*nvim_tabpage_set_var()*
|
|
|
|
nvim_tabpage_set_var({tabpage}, {name}, {value})
|
2019-12-28 04:27:25 -07:00
|
|
|
Sets a tab-scoped (t:) variable
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {tabpage} Tabpage handle, or 0 for current tabpage
|
|
|
|
• {name} Variable name
|
|
|
|
• {value} Variable value
|
2017-03-01 09:18:03 -07:00
|
|
|
|
|
|
|
|
2021-05-28 12:45:34 -07:00
|
|
|
==============================================================================
|
|
|
|
Autocmd Functions *api-autocmd*
|
|
|
|
|
2022-03-31 10:13:22 -07:00
|
|
|
nvim_clear_autocmds({*opts}) *nvim_clear_autocmds()*
|
2023-07-12 10:27:14 -07:00
|
|
|
Clears all autocommands selected by {opts}. To delete autocmds see
|
|
|
|
|nvim_del_autocmd()|.
|
2022-03-12 13:12:02 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {opts} Parameters
|
2022-03-12 13:12:02 -07:00
|
|
|
• event: (string|table) Examples:
|
|
|
|
• event: "pat1"
|
|
|
|
• event: { "pat1" }
|
|
|
|
• event: { "pat1", "pat2", "pat3" }
|
|
|
|
|
|
|
|
• pattern: (string|table)
|
|
|
|
• pattern or patterns to match exactly.
|
|
|
|
• For example, if you have `*.py` as that pattern for the
|
|
|
|
autocmd, you must pass `*.py` exactly to clear it.
|
|
|
|
`test.py` will not match the pattern.
|
|
|
|
|
|
|
|
• defaults to clearing all patterns.
|
|
|
|
• NOTE: Cannot be used with {buffer}
|
|
|
|
|
|
|
|
• buffer: (bufnr)
|
|
|
|
• clear only |autocmd-buflocal| autocommands.
|
|
|
|
• NOTE: Cannot be used with {pattern}
|
|
|
|
|
|
|
|
• group: (string|int) The augroup name or id.
|
|
|
|
• NOTE: If not passed, will only delete autocmds not in any group.
|
|
|
|
|
2021-05-28 12:45:34 -07:00
|
|
|
nvim_create_augroup({name}, {*opts}) *nvim_create_augroup()*
|
2022-03-25 11:24:53 -07:00
|
|
|
Create or get an autocommand group |autocmd-groups|.
|
2021-05-28 12:45:34 -07:00
|
|
|
|
2022-11-23 04:31:49 -07:00
|
|
|
To get an existing group id, do: >lua
|
2022-03-25 11:24:53 -07:00
|
|
|
local id = vim.api.nvim_create_augroup("MyGroup", {
|
2021-05-28 12:45:34 -07:00
|
|
|
clear = false
|
|
|
|
})
|
|
|
|
<
|
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} String: The name of the group
|
|
|
|
• {opts} Dictionary Parameters
|
2022-03-25 11:24:53 -07:00
|
|
|
• clear (bool) optional: defaults to true. Clear existing
|
|
|
|
commands if the group already exists |autocmd-groups|.
|
2021-05-28 12:45:34 -07:00
|
|
|
|
|
|
|
Return: ~
|
2022-03-25 11:24:53 -07:00
|
|
|
Integer id of the created group.
|
|
|
|
|
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |autocmd-groups|
|
2021-05-28 12:45:34 -07:00
|
|
|
|
|
|
|
nvim_create_autocmd({event}, {*opts}) *nvim_create_autocmd()*
|
2022-12-11 19:41:26 -07:00
|
|
|
Creates an |autocommand| event handler, defined by `callback` (Lua function or Vimscript function name string) or `command` (Ex command string).
|
2021-05-28 12:45:34 -07:00
|
|
|
|
2022-12-11 19:41:26 -07:00
|
|
|
Example using Lua callback: >lua
|
2022-03-26 05:21:32 -07:00
|
|
|
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
|
2022-03-25 11:24:53 -07:00
|
|
|
pattern = {"*.c", "*.h"},
|
2022-12-11 19:41:26 -07:00
|
|
|
callback = function(ev)
|
2023-06-02 07:59:58 -07:00
|
|
|
print(string.format('event fired: %s', vim.inspect(ev)))
|
2022-12-11 19:41:26 -07:00
|
|
|
end
|
2022-03-25 11:24:53 -07:00
|
|
|
})
|
|
|
|
<
|
|
|
|
|
2022-12-11 19:41:26 -07:00
|
|
|
Example using an Ex command as the handler: >lua
|
2022-03-26 05:21:32 -07:00
|
|
|
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
|
2022-03-25 11:24:53 -07:00
|
|
|
pattern = {"*.c", "*.h"},
|
|
|
|
command = "echo 'Entering a C or C++ file'",
|
|
|
|
})
|
|
|
|
<
|
2021-05-28 12:45:34 -07:00
|
|
|
|
2023-09-14 06:23:01 -07:00
|
|
|
Note: `pattern` is NOT automatically expanded (unlike with |:autocmd|),
|
|
|
|
thus names like "$HOME" and "~" must be expanded explicitly: >lua
|
|
|
|
pattern = vim.fn.expand("~") .. "/some/path/*.py"
|
2022-10-27 13:31:58 -07:00
|
|
|
<
|
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
Parameters: ~
|
2022-12-11 19:41:26 -07:00
|
|
|
• {event} (string|array) Event(s) that will trigger the handler
|
|
|
|
(`callback` or `command`).
|
|
|
|
• {opts} Options dict:
|
|
|
|
• group (string|integer) optional: autocommand group name or
|
|
|
|
id to match against.
|
|
|
|
• pattern (string|array) optional: pattern(s) to match
|
|
|
|
literally |autocmd-pattern|.
|
|
|
|
• buffer (integer) optional: buffer number for buffer-local
|
2022-03-25 11:24:53 -07:00
|
|
|
autocommands |autocmd-buflocal|. Cannot be used with
|
|
|
|
{pattern}.
|
2022-12-11 19:41:26 -07:00
|
|
|
• desc (string) optional: description (for documentation and
|
|
|
|
troubleshooting).
|
|
|
|
• callback (function|string) optional: Lua function (or
|
|
|
|
Vimscript function name, if string) called when the
|
|
|
|
event(s) is triggered. Lua callback can return true to
|
|
|
|
delete the autocommand, and receives a table argument with
|
|
|
|
these keys:
|
|
|
|
• id: (number) autocommand id
|
|
|
|
• event: (string) name of the triggered event
|
|
|
|
|autocmd-events|
|
|
|
|
• group: (number|nil) autocommand group id, if any
|
|
|
|
• match: (string) expanded value of |<amatch>|
|
|
|
|
• buf: (number) expanded value of |<abuf>|
|
|
|
|
• file: (string) expanded value of |<afile>|
|
2023-01-27 04:24:20 -07:00
|
|
|
• data: (any) arbitrary data passed from
|
2022-05-18 08:51:26 -07:00
|
|
|
|nvim_exec_autocmds()|
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
• command (string) optional: Vim command to execute on event.
|
|
|
|
Cannot be used with {callback}
|
|
|
|
• once (boolean) optional: defaults to false. Run the
|
|
|
|
autocommand only once |autocmd-once|.
|
|
|
|
• nested (boolean) optional: defaults to false. Run nested
|
|
|
|
autocommands |autocmd-nested|.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
Return: ~
|
2022-12-11 19:41:26 -07:00
|
|
|
Autocommand id (number)
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |autocommand|
|
|
|
|
• |nvim_del_autocmd()|
|
2021-05-28 12:45:34 -07:00
|
|
|
|
|
|
|
nvim_del_augroup_by_id({id}) *nvim_del_augroup_by_id()*
|
2022-03-25 11:24:53 -07:00
|
|
|
Delete an autocommand group by id.
|
2021-05-28 12:45:34 -07:00
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
To get a group id one can use |nvim_get_autocmds()|.
|
2021-05-28 12:45:34 -07:00
|
|
|
|
2022-09-25 16:58:27 -07:00
|
|
|
NOTE: behavior differs from |:augroup-delete|. When deleting a group,
|
2022-03-25 11:24:53 -07:00
|
|
|
autocommands contained in this group will also be deleted and cleared.
|
|
|
|
This group will no longer exist.
|
2021-05-28 12:45:34 -07:00
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {id} Integer The id of the group.
|
2021-05-28 12:45:34 -07:00
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |nvim_del_augroup_by_name()|
|
|
|
|
• |nvim_create_augroup()|
|
2021-05-28 12:45:34 -07:00
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
nvim_del_augroup_by_name({name}) *nvim_del_augroup_by_name()*
|
|
|
|
Delete an autocommand group by name.
|
2021-05-28 12:45:34 -07:00
|
|
|
|
2022-09-25 16:58:27 -07:00
|
|
|
NOTE: behavior differs from |:augroup-delete|. When deleting a group,
|
2022-03-25 11:24:53 -07:00
|
|
|
autocommands contained in this group will also be deleted and cleared.
|
|
|
|
This group will no longer exist.
|
2021-05-28 12:45:34 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {name} String The name of the group.
|
2021-05-28 12:45:34 -07:00
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |autocmd-groups|
|
2022-03-25 11:24:53 -07:00
|
|
|
|
|
|
|
nvim_del_autocmd({id}) *nvim_del_autocmd()*
|
2023-07-12 10:27:14 -07:00
|
|
|
Deletes an autocommand by id.
|
2021-05-28 12:45:34 -07:00
|
|
|
|
|
|
|
Parameters: ~
|
2023-07-12 10:27:14 -07:00
|
|
|
• {id} Integer Autocommand id returned by |nvim_create_autocmd()|
|
2021-05-28 12:45:34 -07:00
|
|
|
|
2022-03-31 10:13:22 -07:00
|
|
|
nvim_exec_autocmds({event}, {*opts}) *nvim_exec_autocmds()*
|
|
|
|
Execute all autocommands for {event} that match the corresponding {opts}
|
|
|
|
|autocmd-execute|.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {event} (String|Array) The event or events to execute
|
|
|
|
• {opts} Dictionary of autocommand options:
|
2022-03-25 11:24:53 -07:00
|
|
|
• group (string|integer) optional: the autocommand group name
|
|
|
|
or id to match against. |autocmd-groups|.
|
|
|
|
• pattern (string|array) optional: defaults to "*"
|
|
|
|
|autocmd-pattern|. Cannot be used with {buffer}.
|
|
|
|
• buffer (integer) optional: buffer number
|
|
|
|
|autocmd-buflocal|. Cannot be used with {pattern}.
|
|
|
|
• modeline (bool) optional: defaults to true. Process the
|
|
|
|
modeline after the autocommands |<nomodeline>|.
|
2022-05-18 08:51:26 -07:00
|
|
|
• data (any): arbitrary data to send to the autocommand
|
|
|
|
callback. See |nvim_create_autocmd()| for details.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
See also: ~
|
2023-03-15 04:51:44 -07:00
|
|
|
• |:doautocmd|
|
2021-05-28 12:45:34 -07:00
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
nvim_get_autocmds({*opts}) *nvim_get_autocmds()*
|
2022-03-31 10:13:22 -07:00
|
|
|
Get all autocommands that match the corresponding {opts}.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-11-23 04:31:49 -07:00
|
|
|
These examples will get autocommands matching ALL the given criteria: >lua
|
2023-09-14 06:23:01 -07:00
|
|
|
-- Matches all criteria
|
|
|
|
autocommands = vim.api.nvim_get_autocmds({
|
|
|
|
group = "MyGroup",
|
|
|
|
event = {"BufEnter", "BufWinEnter"},
|
|
|
|
pattern = {"*.c", "*.h"}
|
|
|
|
})
|
|
|
|
|
|
|
|
-- All commands from one group
|
|
|
|
autocommands = vim.api.nvim_get_autocmds({
|
|
|
|
group = "MyGroup",
|
|
|
|
})
|
2022-03-25 11:24:53 -07:00
|
|
|
<
|
2021-05-28 12:45:34 -07:00
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
NOTE: When multiple patterns or events are provided, it will find all the
|
|
|
|
autocommands that match any combination of them.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {opts} Dictionary with at least one of the following:
|
2022-03-25 11:24:53 -07:00
|
|
|
• group (string|integer): the autocommand group name or id to
|
|
|
|
match against.
|
|
|
|
• event (string|array): event or events to match against
|
|
|
|
|autocmd-events|.
|
|
|
|
• pattern (string|array): pattern or patterns to match against
|
2022-09-16 00:18:42 -07:00
|
|
|
|autocmd-pattern|. Cannot be used with {buffer}
|
|
|
|
• buffer: Buffer number or list of buffer numbers for buffer
|
|
|
|
local autocommands |autocmd-buflocal|. Cannot be used with
|
|
|
|
{pattern}
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-03-25 11:24:53 -07:00
|
|
|
Return: ~
|
|
|
|
Array of autocommands matching the criteria, with each item containing
|
|
|
|
the following fields:
|
|
|
|
• id (number): the autocommand id (only when defined with the API).
|
|
|
|
• group (integer): the autocommand group id.
|
2022-05-05 08:00:47 -07:00
|
|
|
• group_name (string): the autocommand group name.
|
2022-03-25 11:24:53 -07:00
|
|
|
• desc (string): the autocommand description.
|
|
|
|
• event (string): the autocommand event.
|
2022-06-09 06:18:56 -07:00
|
|
|
• command (string): the autocommand command. Note: this will be empty
|
|
|
|
if a callback is set.
|
|
|
|
• callback (function|string|nil): Lua function or name of a Vim script
|
|
|
|
function which is executed when this autocommand is triggered.
|
2022-03-25 11:24:53 -07:00
|
|
|
• once (boolean): whether the autocommand is only run once.
|
|
|
|
• pattern (string): the autocommand pattern. If the autocommand is
|
|
|
|
buffer local |autocmd-buffer-local|:
|
|
|
|
• buflocal (boolean): true if the autocommand is buffer local.
|
|
|
|
• buffer (number): the buffer number.
|
2021-05-28 12:45:34 -07:00
|
|
|
|
|
|
|
|
2017-03-01 09:18:03 -07:00
|
|
|
==============================================================================
|
|
|
|
UI Functions *api-ui*
|
|
|
|
|
|
|
|
nvim_ui_attach({width}, {height}, {options}) *nvim_ui_attach()*
|
2019-04-08 18:14:27 -07:00
|
|
|
Activates UI events on the channel.
|
|
|
|
|
|
|
|
Entry point of all UI clients. Allows |--embed| to continue startup.
|
|
|
|
Implies that the client is ready to show the UI. Adds the client to the
|
|
|
|
list of UIs. |nvim_list_uis()|
|
|
|
|
|
2023-07-06 13:47:27 -07:00
|
|
|
Note: ~
|
|
|
|
• If multiple UI clients are attached, the global screen dimensions
|
2019-04-08 18:14:27 -07:00
|
|
|
degrade to the smallest client. E.g. if client A requests 80x40 but
|
|
|
|
client B requests 200x100, the global screen has size 80x40.
|
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
|
|
|
|
2019-04-08 18:14:27 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {width} Requested screen columns
|
|
|
|
• {height} Requested screen rows
|
|
|
|
• {options} |ui-option| map
|
2017-03-01 09:18:03 -07:00
|
|
|
|
|
|
|
nvim_ui_detach() *nvim_ui_detach()*
|
2019-04-08 18:14:27 -07:00
|
|
|
Deactivates UI events on the channel.
|
|
|
|
|
|
|
|
Removes the client from the list of UIs. |nvim_list_uis()|
|
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
|
|
|
|
2020-02-24 01:40:58 -07:00
|
|
|
*nvim_ui_pum_set_bounds()*
|
|
|
|
nvim_ui_pum_set_bounds({width}, {height}, {row}, {col})
|
2020-07-02 04:09:17 -07:00
|
|
|
Tells Nvim the geometry of the popupmenu, to align floating windows with
|
|
|
|
an external popup menu.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2020-07-02 04:09:17 -07:00
|
|
|
Note that this method is not to be confused with
|
|
|
|
|nvim_ui_pum_set_height()|, which sets the number of visible items in the
|
|
|
|
popup menu, while this function sets the bounding box of the popup menu,
|
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes:
- Deprecated all `vim.lsp.util.{*diagnostics*}()` functions.
- Instead, all functions must be found in vim.lsp.diagnostic
- For now, they issue a warning ONCE per neovim session. In a
"little while" we will remove them completely.
- `vim.lsp.callbacks` has moved to `vim.lsp.handlers`.
- For a "little while" we will just redirect `vim.lsp.callbacks` to
`vim.lsp.handlers`. However, we will remove this at some point, so
it is recommended that you change all of your references to
`callbacks` into `handlers`.
- This also means that for functions like |vim.lsp.start_client()|
and similar, keyword style arguments have moved from "callbacks"
to "handlers". Once again, these are currently being forward, but
will cease to be forwarded in a "little while".
- Changed the highlight groups for LspDiagnostic highlight as they were
inconsistently named.
- For more information, see |lsp-highlight-diagnostics|
- Changed the sign group names as well, to be consistent with
|lsp-highlight-diagnostics|
General Enhancements:
- Rewrote much of the getting started help document for lsp. It also
provides a much nicer configuration strategy, so as to not recommend
globally overwriting builtin neovim mappings.
LSP Enhancements:
- Introduced the concept of |lsp-handlers| which will allow much better
customization for users without having to copy & paste entire files /
functions / etc.
Diagnostic Enhancements:
- "goto next diagnostic" |vim.lsp.diagnostic.goto_next()|
- "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()|
- For each of the gotos, auto open diagnostics is available as a
configuration option
- Configurable diagnostic handling:
- See |vim.lsp.diagnostic.on_publish_diagnostics()|
- Delay display until after insert mode
- Configure signs
- Configure virtual text
- Configure underline
- Set the location list with the buffers diagnostics.
- See |vim.lsp.diagnostic.set_loclist()|
- Better performance for getting counts and line diagnostics
- They are now cached on save, to enhance lookups.
- Particularly useful for checking in statusline, etc.
- Actual testing :)
- See ./test/functional/plugin/lsp/diagnostic_spec.lua
- Added `guisp` for underline highlighting
NOTE: "a little while" means enough time to feel like most plugins and
plugin authors have had a chance to refactor their code to use the
updated calls. Then we will remove them completely. There is no need to
keep them, because we don't have any released version of neovim that
exposes these APIs. I'm trying to be nice to people following HEAD :)
Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
2020-11-12 20:21:34 -07:00
|
|
|
including visual elements such as borders and sliders. Floats need not use
|
2020-07-02 04:09:17 -07:00
|
|
|
the same font size, nor be anchored to exact grid corners, so one can set
|
|
|
|
floating-point numbers to the popup menu geometry.
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
2022-08-11 05:25:48 -07:00
|
|
|
|
2020-02-24 01:40:58 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {width} Popupmenu width.
|
|
|
|
• {height} Popupmenu height.
|
|
|
|
• {row} Popupmenu row.
|
|
|
|
• {col} Popupmenu height.
|
2020-07-02 04:09:17 -07:00
|
|
|
|
|
|
|
nvim_ui_pum_set_height({height}) *nvim_ui_pum_set_height()*
|
|
|
|
Tells Nvim the number of elements displaying in the popupmenu, to decide
|
|
|
|
<PageUp> and <PageDown> movement.
|
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
|
|
|
|
2020-07-02 04:09:17 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {height} Popupmenu height, must be greater than zero.
|
2020-02-24 01:40:58 -07:00
|
|
|
|
2022-05-02 12:10:01 -07:00
|
|
|
nvim_ui_set_focus({gained}) *nvim_ui_set_focus()*
|
|
|
|
Tells the nvim server if focus was gained or lost by the GUI.
|
|
|
|
|
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
|
|
|
|
2017-03-01 09:18:03 -07:00
|
|
|
nvim_ui_set_option({name}, {value}) *nvim_ui_set_option()*
|
2019-12-28 04:27:25 -07:00
|
|
|
TODO: Documentation
|
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
|
|
|
|
2023-11-06 11:42:40 -07:00
|
|
|
nvim_ui_term_event({event}, {value}) *nvim_ui_term_event()*
|
2023-11-16 10:12:42 -07:00
|
|
|
Tells Nvim when a terminal event has occurred
|
2023-11-06 11:42:40 -07:00
|
|
|
|
|
|
|
The following terminal events are supported:
|
|
|
|
|
2023-11-16 10:12:42 -07:00
|
|
|
• "termresponse": The terminal sent an OSC or DCS response sequence to
|
|
|
|
Nvim. The payload is the received response. Sets |v:termresponse| and
|
|
|
|
fires |TermResponse|.
|
2023-11-06 11:42:40 -07:00
|
|
|
|
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
|
|
|
|
|
|
|
Parameters: ~
|
|
|
|
• {event} Event name
|
|
|
|
• {payload} Event payload
|
|
|
|
|
2019-12-28 04:27:25 -07:00
|
|
|
nvim_ui_try_resize({width}, {height}) *nvim_ui_try_resize()*
|
2017-03-01 09:18:03 -07:00
|
|
|
TODO: Documentation
|
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
|
|
|
|
2019-01-10 17:20:15 -07:00
|
|
|
*nvim_ui_try_resize_grid()*
|
|
|
|
nvim_ui_try_resize_grid({grid}, {width}, {height})
|
|
|
|
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.
|
|
|
|
|
|
|
|
On invalid grid handle, fails with error.
|
|
|
|
|
2022-04-30 16:16:16 -07:00
|
|
|
Attributes: ~
|
|
|
|
|RPC| only
|
|
|
|
|
2019-01-10 17:20:15 -07:00
|
|
|
Parameters: ~
|
2022-10-05 05:15:55 -07:00
|
|
|
• {grid} The handle of the grid to be changed.
|
|
|
|
• {width} The new requested width.
|
|
|
|
• {height} The new requested height.
|
2019-01-10 17:20:15 -07:00
|
|
|
|
2017-12-16 13:33:59 -07:00
|
|
|
vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl:
|