From 0b05bd87c04f9cde5c84a062453619349e370795 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 23 Nov 2022 12:31:49 +0100 Subject: docs(gen): support language annotation in docstrings --- src/nvim/api/autocmd.c | 21 ++++++++++----------- src/nvim/api/buffer.c | 2 +- src/nvim/api/command.c | 2 +- src/nvim/api/extmark.c | 6 ++---- src/nvim/api/vim.c | 8 ++++---- src/nvim/api/win_config.c | 4 ++-- 6 files changed, 20 insertions(+), 23 deletions(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c index af185c50c9..db84ecb5d8 100644 --- a/src/nvim/api/autocmd.c +++ b/src/nvim/api/autocmd.c @@ -47,7 +47,7 @@ static int64_t next_autocmd_id = 1; /// 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",
@@ -367,7 +367,7 @@ cleanup:
 /// triggers: a callback function (Lua or Vimscript), or a command (like regular autocommands).
 ///
 /// Example using callback:
-/// 
+/// 
lua
 ///     -- Lua function
 ///     local myluafun = function() print("This buffer enters") end
 ///
@@ -383,8 +383,7 @@ cleanup:
 /// Lua functions receive a table with information about the autocmd event as an argument. To use
 /// a function which itself accepts another (optional) parameter, wrap the function
 /// in a lambda:
-///
-/// 
+/// 
lua
 ///     -- Lua function with an optional parameter.
 ///     -- The autocmd callback would pass a table as argument but this
 ///     -- function expects number|nil
@@ -397,7 +396,7 @@ cleanup:
 /// 
/// /// Example using command: -///
+/// 
lua
 ///     vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
 ///       pattern = {"*.c", "*.h"},
 ///       command = "echo 'Entering a C or C++ file'",
@@ -405,7 +404,7 @@ cleanup:
 /// 
/// /// Example values for pattern: -///
+/// 
lua
 ///   pattern = "*.py"
 ///   pattern = { "*.py", "*.pyi" }
 /// 
@@ -413,14 +412,14 @@ cleanup: /// Note: The `pattern` is passed to callbacks and commands as a literal string; environment /// variables like `$HOME` and `~` are not automatically expanded as they are by |:autocmd|. /// Instead, |expand()| such variables explicitly: -///
+/// 
lua
 ///   pattern = vim.fn.expand("~") .. "/some/path/*.py"
 /// 
/// /// Example values for event: -///
-///   "BufWritePre"
-///   {"CursorHold", "BufWritePre", "BufWritePost"}
+/// 
lua
+///   event = "BufWritePre"
+///   event = {"CursorHold", "BufWritePre", "BufWritePost"}
 /// 
/// /// @param event (string|array) The event or events to register this autocommand @@ -703,7 +702,7 @@ cleanup: /// Create or get an autocommand group |autocmd-groups|. /// /// To get an existing group id, do: -///
+/// 
lua
 ///     local id = vim.api.nvim_create_augroup("MyGroup", {
 ///         clear = false
 ///     })
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 0a31286df7..fe9e6077d6 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -84,7 +84,7 @@ Integer nvim_buf_line_count(Buffer buffer, Error *err)
 ///
 /// Example (Lua): capture buffer updates in a global `events` variable
 /// (use "print(vim.inspect(events))" to see its contents):
-/// 
+/// 
lua
 ///   events = {}
 ///   vim.api.nvim_buf_attach(0, false, {
 ///     on_lines=function(...) table.insert(events, {...}) end})
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index 8a7abf0845..416dbc0e5d 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -889,7 +889,7 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin
 /// {command} is the replacement text or Lua function to execute.
 ///
 /// Example:
-/// 
+/// 
vim
 ///    :call nvim_create_user_command('SayHello', 'echo "Hello world!"', {})
 ///    :SayHello
 ///    Hello world!
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index 3a96c42dba..b406672aa5 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -255,8 +255,7 @@ ArrayOf(Integer) nvim_buf_get_extmark_by_id(Buffer buffer, Integer ns_id,
 /// 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
 ///   nvim_buf_get_extmarks(0, my_ns, 0, -1, {})
 ///   nvim_buf_get_extmarks(0, my_ns, [0,0], [-1,-1], {})
 /// 
@@ -265,8 +264,7 @@ ArrayOf(Integer) nvim_buf_get_extmark_by_id(Buffer buffer, Integer ns_id, /// with `limit`, to get the first marks prior to a given position.) /// /// Example: -/// -///
+/// 
lua
 ///   local a   = vim.api
 ///   local pos = a.nvim_win_get_cursor(0)
 ///   local ns  = a.nvim_create_namespace('my-plugin')
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index c3f71cc625..857c03eb27 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -229,7 +229,7 @@ void nvim_set_hl_ns_fast(Integer ns_id, Error *err)
 /// nvim_feedkeys().
 ///
 /// Example:
-/// 
+/// 
vim
 ///     :let key = nvim_replace_termcodes("", v:true, v:false, v:true)
 ///     :call nvim_feedkeys(key, 'n', v:false)
 /// 
@@ -1295,7 +1295,7 @@ void nvim_unsubscribe(uint64_t channel_id, String event) /// "#rrggbb" hexadecimal string. /// /// Example: -///
+/// 
vim
 ///     :echo nvim_get_color_by_name("Pink")
 ///     :echo nvim_get_color_by_name("#cbcbcb")
 /// 
@@ -1437,12 +1437,12 @@ ArrayOf(Dictionary) nvim_get_keymap(String mode) /// Empty {rhs} is ||. |keycodes| are replaced as usual. /// /// Example: -///
+/// 
vim
 ///     call nvim_set_keymap('n', ' ', '', {'nowait': v:true})
 /// 
/// /// is equivalent to: -///
+/// 
vim
 ///     nmap   
 /// 
/// diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index cfe887d762..828ef2f0eb 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -55,13 +55,13 @@ /// this should not be used to specify arbitrary WM screen positions. /// /// Example (Lua): window-relative float -///
+/// 
lua
 ///     vim.api.nvim_open_win(0, false,
 ///       {relative='win', row=3, col=3, width=12, height=3})
 /// 
/// /// 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}})
 /// 
-- cgit