aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/api.txt
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2023-09-14 08:23:01 -0500
committerGitHub <noreply@github.com>2023-09-14 08:23:01 -0500
commit2e92065686f62851318150a315591c30b8306a4b (patch)
tree3d4d216f7b031cd2e966380f9b32d1aae472d32f /runtime/doc/api.txt
parent9fc321c9768d1a18893e14f46b0ebacef1be1db4 (diff)
downloadrneovim-2e92065686f62851318150a315591c30b8306a4b.tar.gz
rneovim-2e92065686f62851318150a315591c30b8306a4b.tar.bz2
rneovim-2e92065686f62851318150a315591c30b8306a4b.zip
docs: replace <pre> with ``` (#25136)
Diffstat (limited to 'runtime/doc/api.txt')
-rw-r--r--runtime/doc/api.txt75
1 files changed, 40 insertions, 35 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 34e2aedabf..ffd90ec3d7 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -1791,9 +1791,9 @@ nvim_create_user_command({name}, {command}, {*opts})
For Lua usage see |lua-guide-commands-create|.
Example: >vim
- :call nvim_create_user_command('SayHello', 'echo "Hello world!"', {'bang': v:true})
- :SayHello
- Hello world!
+ :call nvim_create_user_command('SayHello', 'echo "Hello world!"', {'bang': v:true})
+ :SayHello
+ Hello world!
<
Parameters: ~
@@ -2041,10 +2041,14 @@ whether a buffer is loaded.
nvim_buf_attach({buffer}, {send_buffer}, {opts}) *nvim_buf_attach()*
Activates buffer-update events on a channel, or as Lua callbacks.
- 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})
+ 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,
+ })
<
Parameters: ~
@@ -2553,8 +2557,8 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {*opts})
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)
respectively, thus the following are equivalent: >lua
- vim.api.nvim_buf_get_extmarks(0, my_ns, 0, -1, {})
- vim.api.nvim_buf_get_extmarks(0, my_ns, {0,0}, {-1,-1}, {})
+ vim.api.nvim_buf_get_extmarks(0, my_ns, 0, -1, {})
+ vim.api.nvim_buf_get_extmarks(0, my_ns, {0,0}, {-1,-1}, {})
<
If `end` is less than `start`, traversal works backwards. (Useful with
@@ -2565,18 +2569,18 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {*opts})
an extmark will be considered.
Example: >lua
- 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)
+ 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)
<
Parameters: ~
@@ -3062,6 +3066,7 @@ nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()*
Example (Lua): buffer-relative float (travels as buffer is scrolled) >lua
vim.api.nvim_open_win(0, false,
{relative='win', width=12, height=3, bufpos={100,10}})
+ })
<
Attributes: ~
@@ -3340,9 +3345,9 @@ nvim_create_autocmd({event}, {*opts}) *nvim_create_autocmd()*
})
<
- 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"
+ 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"
<
Parameters: ~
@@ -3447,17 +3452,17 @@ nvim_get_autocmds({*opts}) *nvim_get_autocmds()*
Get all autocommands that match the corresponding {opts}.
These examples will get autocommands matching ALL the given criteria: >lua
- -- 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",
- })
+ -- 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",
+ })
<
NOTE: When multiple patterns or events are provided, it will find all the