aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-05-12 15:07:10 -0700
committerGitHub <noreply@github.com>2024-05-12 15:07:10 -0700
commitc7958356bef304320d86cd541d0de8db968c6cc8 (patch)
treea2e0e786f5f6b829ebb39b58e0e536ffd87c546c /runtime/doc
parentd8b395b10fd033addef9765e30d9ab42e6cef264 (diff)
parent97c7646501d5cd6f57c57ce30acca89c5b8573ff (diff)
downloadrneovim-c7958356bef304320d86cd541d0de8db968c6cc8.tar.gz
rneovim-c7958356bef304320d86cd541d0de8db968c6cc8.tar.bz2
rneovim-c7958356bef304320d86cd541d0de8db968c6cc8.zip
Merge #28432 nvim_win_xx_ns are EXPERIMENTAL
Diffstat (limited to 'runtime/doc')
-rw-r--r--runtime/doc/api.txt31
-rw-r--r--runtime/doc/develop.txt77
-rw-r--r--runtime/doc/news.txt30
3 files changed, 97 insertions, 41 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 86f4c3875c..13884e865d 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -2776,8 +2776,8 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {opts})
• url: A URL to associate with this extmark. In the TUI, the
OSC 8 control sequence is used to generate a clickable
hyperlink to this URL.
- • scoped: boolean that indicates that the extmark should
- only be displayed in the namespace scope. (experimental)
+ • scoped: boolean (EXPERIMENTAL) enables "scoping" for the
+ extmark. See |nvim__win_add_ns()|
Return: ~
Id of the created/updated extmark
@@ -2859,34 +2859,41 @@ nvim_set_decoration_provider({ns_id}, {opts})
["end", tick]
<
-nvim_win_add_ns({window}, {ns_id}) *nvim_win_add_ns()*
- Adds the namespace scope to the window.
+nvim__win_add_ns({window}, {ns_id}) *nvim__win_add_ns()*
+ EXPERIMENTAL: this API will change in the future.
+
+ Scopes a namespace to the a window, so extmarks in the namespace will be
+ active only in the given window.
Parameters: ~
• {window} Window handle, or 0 for current window
- • {ns_id} the namespace to add
+ • {ns_id} Namespace
Return: ~
true if the namespace was added, else false
-nvim_win_get_ns({window}) *nvim_win_get_ns()*
- Gets all the namespaces scopes associated with a window.
+nvim__win_del_ns({window}, {ns_id}) *nvim__win_del_ns()*
+ EXPERIMENTAL: this API will change in the future.
+
+ Unscopes a namespace (un-binds it from the given scope).
Parameters: ~
• {window} Window handle, or 0 for current window
+ • {ns_id} the namespace to remove
Return: ~
- a list of namespaces ids
+ true if the namespace was removed, else false
-nvim_win_remove_ns({window}, {ns_id}) *nvim_win_remove_ns()*
- Removes the namespace scope from the window.
+nvim__win_get_ns({window}) *nvim__win_get_ns()*
+ EXPERIMENTAL: this API will change in the future.
+
+ Gets the namespace scopes for a given window.
Parameters: ~
• {window} Window handle, or 0 for current window
- • {ns_id} the namespace to remove
Return: ~
- true if the namespace was removed, else false
+ a list of namespaces ids
==============================================================================
diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt
index 7fc154441f..11c25362b6 100644
--- a/runtime/doc/develop.txt
+++ b/runtime/doc/develop.txt
@@ -383,7 +383,7 @@ Use existing common {verb} names (actions) if possible:
- enable: Enables/disables functionality. Signature should be
`enable(enable?:boolean, filter?:table)`.
- eval: Evaluates an expression
- - exec: Executes code
+ - exec: Executes code, may return a result
- fmt: Formats
- get: Gets things (often by a query)
- inspect: Presents a high-level, often interactive, view
@@ -405,8 +405,8 @@ Do NOT use these deprecated verbs:
- show: Redundant with "print", "echo"
- toggle: Prefer `enable(not is_enabled())`.
-Use consistent names for {noun} (nouns) in API functions: buffer is called
-"buf" everywhere, not "buffer" in some places and "buf" in others.
+Use consistent names for {topic} in API functions: buffer is called "buf"
+everywhere, not "buffer" in some places and "buf" in others.
- buf: Buffer
- chan: |channel|
- cmd: Command
@@ -419,10 +419,10 @@ Use consistent names for {noun} (nouns) in API functions: buffer is called
- win: Window
Do NOT use these deprecated nouns:
- - buffer
+ - buffer Use "buf" instead
- callback Use on_foo instead
- - command
- - window
+ - command Use "cmd" instead
+ - window Use "win" instead
*dev-name-events*
Use the "on_" prefix to name event-handling callbacks and also the interface for
@@ -440,12 +440,15 @@ Example: >
<
*dev-name-api*
Use this format to name new RPC |API| functions: >
- nvim_{noun}_{verb}_{arbitrary-qualifiers}
+ nvim_{topic}_{verb}_{arbitrary-qualifiers}
-If the function acts on an object then {noun} is the name of that object
-(e.g. "buf" or "win"). If the function operates in a "global" context then
-{noun} is usually omitted (but consider "namespacing" your global operations
-with a {noun} that groups functions under a common concept).
+Do not add new nvim_buf/nvim_win/nvim_tabpage APIs, unless you are certain the
+concept will NEVER be applied to more than one "scope". That is, {topic}
+should be the TOPIC ("ns", "extmark", "option", …) that acts on the scope(s)
+(buf/win/tabpage/global), it should NOT be the scope. Instead the scope should
+be a parameter (typically manifest as mutually-exclusive buf/win/… flags like
+|nvim_get_option_value()|, or less commonly as a `scope: string` field like
+|nvim_get_option_info2()|).
- Example: `nvim_get_keymap('v')` operates in a global context (first
parameter is not a Buffer). The "get" verb indicates that it gets anything
@@ -455,6 +458,58 @@ with a {noun} that groups functions under a common concept).
and uses the "del" {verb}.
+INTERFACE PATTERNS *dev-patterns*
+
+Prefer adding a single `nvim_{topic}_{verb}_…` interface for a given topic.
+
+Example: >
+
+ nvim_ns_add(
+ ns_id: int,
+ filter: {
+ handle: integer (buf/win/tabpage id)
+ scope: "global" | "win" | "buf" | "tabpage"
+ }
+ ): { ok: boolean }
+
+ nvim_ns_get(
+ ns_id: int,
+ filter: {
+ handle: integer (buf/win/tabpage id)
+ scope: "global" | "win" | "buf" | "tabpage"
+ }
+ ): { ids: int[] }
+
+ nvim_ns_del(
+ ns_id: int,
+ filter: {
+ handle: integer (buf/win/tabpage id)
+ scope: "global" | "win" | "buf" | "tabpage"
+ }
+ ): { ok: boolean }
+
+
+Anti-Example:
+
+Creating separate `nvim_xx`, `nvim_buf_xx`, `nvim_win_xx`, and
+`nvim_tabpage_xx`, functions all for the same `xx` topic, requires 4x the
+amount of documentation, tests, boilerplate, and interfaces, which users must
+comprehend, maintainers must maintain, etc. Thus the following is NOT
+recommended (compare these 12(!) functions to the above 3 functions): >
+
+ nvim_add_ns(…)
+ nvim_buf_add_ns(…)
+ nvim_win_add_ns(…)
+ nvim_tabpage_add_ns(…)
+ nvim_del_ns(…)
+ nvim_buf_del_ns(…)
+ nvim_win_del_ns(…)
+ nvim_tabpage_del_ns(…)
+ nvim_get_ns(…)
+ nvim_buf_get_ns(…)
+ nvim_win_get_ns(…)
+ nvim_tabpage_get_ns(…)
+
API-CLIENT *dev-api-client*
*api-client*
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 111e69b0fe..42b6f4b14c 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -206,7 +206,18 @@ The following new APIs and features were added.
• |'smoothscroll'| option to scroll by screen line rather than by text line
when |'wrap'| is set.
-• |nvim_buf_set_extmark()| supports inline virtual text.
+• API enhancements
+ • |nvim_buf_set_extmark()| supports inline virtual text.
+ • |nvim_win_text_height()| computes the number of screen lines occupied
+ by a range of text in a given window.
+ • New RPC client type `msgpack-rpc` is added for |nvim_set_client_info()| to
+ support fully MessagePack-RPC compliant clients.
+ • Floating windows can now be hidden by setting `hide` in |nvim_open_win()| or
+ |nvim_win_set_config()|.
+ • |nvim_input_mouse()| supports mouse buttons "x1" and "x2".
+ • Added |nvim_tabpage_set_win()| to set the current window of a tabpage.
+ • |nvim__win_add_ns()| can bind a |namespace| to a window-local scope(s).
+ • Extmarks opt-in to this scoping via the `scoped` flag of |nvim_buf_set_extmark()|.
• 'foldtext' now supports virtual text format. |fold-foldtext|
@@ -218,9 +229,6 @@ The following new APIs and features were added.
• |vim.lpeg| and |vim.re| expose the bundled Lpeg expression grammar parser
and its regex interface.
-• |nvim_win_text_height()| computes the number of screen lines occupied
- by a range of text in a given window.
-
• Mapping APIs now support abbreviations when mode short-name has suffix "a".
• Better cmdline completion for string option value. |complete-set-option|
@@ -321,15 +329,9 @@ The following new APIs and features were added.
• Functions that take a severity as an optional parameter (e.g.
|vim.diagnostic.get()|) now also accept a list of severities |vim.diagnostic.severity|
-• New RPC client type `msgpack-rpc` is added for |nvim_set_client_info()| to
- support fully MessagePack-RPC compliant clients.
-
• Floating windows can now show footer with new `footer` and `footer_pos`
config fields. Uses |hl-FloatFooter| by default.
-• Floating windows can now be hidden by setting `hide` in |nvim_open_win()| or
- |nvim_win_set_config()|.
-
• |:terminal| command now accepts some |:command-modifiers| (specifically
|:horizontal| and those that affect splitting a window).
@@ -360,8 +362,6 @@ The following new APIs and features were added.
• 'completeopt' option supports "popup" flag to show extra information in a
floating window.
-• |nvim_input_mouse()| supports mouse buttons "x1" and "x2".
-
• |v_Q-default| and |v_@-default| repeat a register for each line of a linewise
visual selection.
@@ -386,14 +386,8 @@ The following new APIs and features were added.
using the OSC 8 control sequence, enabling clickable text in supporting
terminals.
-• Added |nvim_tabpage_set_win()| to set the current window of a tabpage.
-
• Clicking on a tabpage in the tabline with the middle mouse button closes it.
-• |namespace| can now have window scopes. |nvim_win_add_ns()|
-
-• |extmarks| option `scoped`: only show the extmarks in its namespace's scope.
-
• Added built-in |commenting| support.
• |vim.fs.root()| finds project root directories from a list of "root