2017-03-21 17:13:51 -07:00
|
|
|
*develop.txt* Nvim
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
|
2016-06-12 23:11:12 -07:00
|
|
|
NVIM REFERENCE MANUAL
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
|
2019-01-10 17:20:15 -07:00
|
|
|
Development of Nvim *development* *dev*
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2018-11-15 18:00:04 -07:00
|
|
|
This reference describes design constraints and guidelines, for developing
|
|
|
|
Nvim applications or Nvim itself.
|
|
|
|
Architecture and internal concepts are covered in src/nvim/README.md
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2018-11-15 18:00:04 -07:00
|
|
|
Nvim is free and open source. Everybody is encouraged to contribute.
|
|
|
|
https://github.com/neovim/neovim/blob/master/CONTRIBUTING.md
|
2016-06-14 20:12:43 -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
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
==============================================================================
|
2017-04-17 14:52:38 -07:00
|
|
|
Design goals *design-goals*
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2018-11-15 18:00:04 -07:00
|
|
|
Most important things come first (roughly). Some items conflict; this is
|
|
|
|
intentional. A balance must be found.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
|
2016-06-12 23:11:12 -07:00
|
|
|
NVIM IS... IMPROVED *design-improved*
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2018-09-05 15:58:10 -07:00
|
|
|
The Neo bits of Nvim should make it a better Vim, without becoming a
|
|
|
|
completely different editor.
|
|
|
|
- In matters of taste, prefer Vim/Unix tradition. If there is no relevant
|
|
|
|
Vim/Unix tradition, consider the "common case".
|
2014-07-10 21:05:51 -07:00
|
|
|
- A feature that people do not know about is a useless feature. Don't add
|
|
|
|
obscure features, or at least add hints in documentation that they exist.
|
|
|
|
- There is no limit to the features that can be added. Selecting new features
|
2017-04-17 14:52:38 -07:00
|
|
|
is based on (1) what users ask for, (2) how much effort it takes to
|
2014-07-10 21:05:51 -07:00
|
|
|
implement and (3) someone actually implementing it.
|
2018-09-05 15:58:10 -07:00
|
|
|
- Backwards compatibility is a feature. The RPC API in particular should
|
|
|
|
never break.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
|
2016-06-12 23:11:12 -07:00
|
|
|
NVIM IS... WELL DOCUMENTED *design-documented*
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
- A feature that isn't documented is a useless feature. A patch for a new
|
|
|
|
feature must include the documentation.
|
2017-04-17 14:52:38 -07:00
|
|
|
- Documentation should be comprehensive and understandable. Use examples.
|
2014-07-10 21:05:51 -07:00
|
|
|
- Don't make the text unnecessarily long. Less documentation means that an
|
|
|
|
item is easier to find.
|
|
|
|
|
|
|
|
|
2021-08-21 18:26:33 -07:00
|
|
|
NVIM IS... FAST AND SMALL *design-speed-size*
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2017-04-17 14:52:38 -07:00
|
|
|
Keep Nvim small and fast.
|
2014-07-10 21:05:51 -07:00
|
|
|
- Computers are becoming faster and bigger each year. Vim can grow too, but
|
|
|
|
no faster than computers are growing. Keep Vim usable on older systems.
|
|
|
|
- Many users start Vim from a shell very often. Startup time must be short.
|
|
|
|
- Commands must work efficiently. The time they consume must be as small as
|
|
|
|
possible. Useful commands may take longer.
|
|
|
|
- Don't forget that some people use Vim over a slow connection. Minimize the
|
|
|
|
communication overhead.
|
|
|
|
- Vim is a component among other components. Don't turn it into a massive
|
|
|
|
application, but have it work well together with other programs.
|
|
|
|
|
|
|
|
|
2016-06-12 23:11:12 -07:00
|
|
|
NVIM IS... MAINTAINABLE *design-maintain*
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
- The source code should not become a mess. It should be reliable code.
|
|
|
|
- Use comments in a useful way! Quoting the function name and argument names
|
|
|
|
is NOT useful. Do explain what they are for.
|
|
|
|
- Porting to another platform should be made easy, without having to change
|
|
|
|
too much platform-independent code.
|
|
|
|
- Use the object-oriented spirit: Put data and code together. Minimize the
|
|
|
|
knowledge spread to other parts of the code.
|
|
|
|
|
|
|
|
|
2015-01-14 00:02:39 -07:00
|
|
|
NVIM IS... NOT *design-not*
|
|
|
|
|
2016-06-14 20:12:43 -07:00
|
|
|
Nvim is not an operating system; instead it should be composed with other
|
|
|
|
tools or hosted as a component. Marvim once said: "Unlike Emacs, Nvim does not
|
2017-04-17 14:52:38 -07:00
|
|
|
include the kitchen sink... but it's good for plumbing."
|
2015-01-14 00:02:39 -07:00
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2019-01-10 17:20:15 -07:00
|
|
|
Developer guidelines *dev-guidelines*
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2017-04-17 14:52:38 -07:00
|
|
|
|
|
|
|
PROVIDERS *dev-provider*
|
2016-06-14 22:20:08 -07:00
|
|
|
|
2019-08-03 18:54:06 -07:00
|
|
|
A primary goal of Nvim is to allow extension of the editor without special
|
|
|
|
knowledge in the core. Some core functions are delegated to "providers"
|
|
|
|
implemented as external scripts.
|
2016-06-14 22:20:08 -07:00
|
|
|
|
2019-08-03 18:54:06 -07:00
|
|
|
Examples:
|
2016-06-14 22:20:08 -07:00
|
|
|
|
|
|
|
1. In the Vim source code, clipboard logic accounts for more than 1k lines of
|
|
|
|
C source code (ui.c), to perform two tasks that are now accomplished with
|
|
|
|
shell commands such as xclip or pbcopy/pbpaste.
|
|
|
|
|
|
|
|
2. Python scripting support: Vim has three files dedicated to embedding the
|
|
|
|
Python interpreter: if_python.c, if_python3.c and if_py_both.h. Together
|
|
|
|
these files sum about 9.5k lines of C source code. In contrast, Nvim Python
|
|
|
|
scripting is performed by an external host process implemented in ~2k lines
|
|
|
|
of Python.
|
|
|
|
|
2019-08-03 18:54:06 -07:00
|
|
|
The provider framework invokes VimL from C. It is composed of two functions
|
|
|
|
in eval.c:
|
2016-06-14 22:20:08 -07:00
|
|
|
|
2020-09-01 20:22:42 -07:00
|
|
|
- eval_call_provider(name, method, arguments, discard): calls
|
|
|
|
provider#{name}#Call with the method and arguments. If discard is true, any
|
|
|
|
value returned by the provider will be discarded and and empty value be
|
|
|
|
returned.
|
2019-08-03 18:54:06 -07:00
|
|
|
- eval_has_provider(name): Checks the `g:loaded_{name}_provider` variable
|
2019-08-04 03:06:24 -07:00
|
|
|
which must be set to 2 by the provider script to indicate that it is
|
|
|
|
"enabled and working". Called by |has()| to check if features are available.
|
2016-06-14 22:20:08 -07:00
|
|
|
|
|
|
|
For example, the Python provider is implemented by the
|
2019-08-03 18:54:06 -07:00
|
|
|
"autoload/provider/python.vim" script, which sets `g:loaded_python_provider`
|
2019-08-04 03:06:24 -07:00
|
|
|
to 2 only if a valid external Python host is found. Then `has("python")`
|
2019-08-03 18:54:06 -07:00
|
|
|
reflects whether Python support is working.
|
|
|
|
|
|
|
|
*provider-reload*
|
|
|
|
Sometimes a GUI or other application may want to force a provider to
|
|
|
|
"reload". To reload a provider, undefine its "loaded" flag, then use
|
|
|
|
|:runtime| to reload it: >
|
|
|
|
|
|
|
|
:unlet g:loaded_clipboard_provider
|
|
|
|
:runtime autoload/provider/clipboard.vim
|
|
|
|
|
2016-06-14 22:20:08 -07:00
|
|
|
|
2017-03-14 16:12:21 -07:00
|
|
|
DOCUMENTATION *dev-doc*
|
|
|
|
|
2021-08-27 03:59:13 -07:00
|
|
|
- "Just say it". Avoid mushy, colloquial phrasing in all documentation
|
|
|
|
(docstrings, user manual, website materials, newsletters, …). Don't mince
|
|
|
|
words. Personality and flavor, used sparingly, are welcome--but in general,
|
|
|
|
optimize for the reader's time and energy: be "precise yet concise".
|
|
|
|
- Prefer the active voice: "Foo does X", not "X is done by Foo".
|
|
|
|
- Vim differences:
|
|
|
|
- Do not prefix help tags with "nvim-". Use |vim_diff.txt| to catalog
|
|
|
|
differences from Vim; no other distinction is necessary.
|
|
|
|
- If a Vim feature is removed, delete its help section and move its tag to
|
|
|
|
|vim_diff.txt|.
|
|
|
|
- Mention deprecated features in |deprecated.txt| and delete their old doc.
|
2017-03-14 16:12:21 -07:00
|
|
|
- Use consistent language.
|
2021-08-27 03:59:13 -07:00
|
|
|
- "terminal" in a help tag always means "the embedded terminal emulator",
|
|
|
|
not "the user host terminal".
|
2017-03-14 16:12:21 -07:00
|
|
|
- Use "tui-" to prefix help tags related to the host terminal, and "TUI"
|
|
|
|
in prose if possible.
|
2018-12-08 17:49:59 -07:00
|
|
|
- Docstrings: do not start parameter descriptions with "The" or "A" unless it
|
|
|
|
is critical to avoid ambiguity.
|
|
|
|
GOOD: >
|
|
|
|
/// @param dirname Path fragment before `pend`
|
|
|
|
< BAD: >
|
|
|
|
/// @param dirname The path fragment before `pend`
|
|
|
|
<
|
2016-06-14 22:20:08 -07:00
|
|
|
|
2019-10-27 15:05:59 -07:00
|
|
|
C docstrings ~
|
|
|
|
|
|
|
|
Nvim API documentation lives in the source code, as docstrings (Doxygen
|
|
|
|
comments) on the function definitions. The |api| :help is generated
|
|
|
|
from the docstrings defined in src/nvim/api/*.c.
|
|
|
|
|
|
|
|
Docstring format:
|
|
|
|
- Lines start with `///`
|
|
|
|
- Special tokens start with `@` followed by the token name:
|
|
|
|
`@note`, `@param`, `@returns`
|
|
|
|
- Limited markdown is supported.
|
|
|
|
- List-items start with `-` (useful to nest or "indent")
|
|
|
|
- Use `<pre>` for code samples.
|
|
|
|
|
|
|
|
Example: the help for |nvim_open_win()| is generated from a docstring defined
|
2021-10-04 19:10:07 -07:00
|
|
|
in src/nvim/api/win_config.c like this: >
|
2019-10-27 15:05:59 -07:00
|
|
|
|
|
|
|
/// Opens a new window.
|
|
|
|
/// ...
|
|
|
|
///
|
|
|
|
/// Example (Lua): window-relative float
|
|
|
|
/// <pre>
|
|
|
|
/// vim.api.nvim_open_win(0, false,
|
|
|
|
/// {relative='win', row=3, col=3, width=12, height=3})
|
|
|
|
/// </pre>
|
|
|
|
///
|
|
|
|
/// @param buffer Buffer to display
|
|
|
|
/// @param enter Enter the window
|
|
|
|
/// @param config Map defining the window configuration. Keys:
|
|
|
|
/// - relative: Sets the window layout, relative to:
|
|
|
|
/// - "editor" The global editor grid.
|
|
|
|
/// - "win" Window given by the `win` field.
|
|
|
|
/// - "cursor" Cursor position in current window.
|
|
|
|
/// ...
|
|
|
|
/// @param[out] err Error details, if any
|
|
|
|
///
|
|
|
|
/// @return Window handle, or 0 on error
|
|
|
|
|
|
|
|
|
|
|
|
Lua docstrings ~
|
|
|
|
*dev-lua-doc*
|
|
|
|
Lua documentation lives in the source code, as docstrings on the function
|
|
|
|
definitions. The |lua-vim| :help is generated from the docstrings.
|
|
|
|
|
|
|
|
Docstring format:
|
|
|
|
- Lines in the main description start with `---`
|
2021-08-22 13:55:28 -07:00
|
|
|
- Special tokens start with `---@` followed by the token name:
|
|
|
|
`---@see`, `---@param`, `---@returns`
|
2019-10-27 15:05:59 -07:00
|
|
|
- Limited markdown is supported.
|
|
|
|
- List-items start with `-` (useful to nest or "indent")
|
|
|
|
- Use `<pre>` for code samples.
|
|
|
|
|
|
|
|
Example: the help for |vim.paste()| is generated from a docstring decorating
|
|
|
|
vim.paste in src/nvim/lua/vim.lua like this: >
|
|
|
|
|
|
|
|
--- Paste handler, invoked by |nvim_paste()| when a conforming UI
|
|
|
|
--- (such as the |TUI|) pastes text into the editor.
|
|
|
|
---
|
|
|
|
--- Example: To remove ANSI color codes when pasting:
|
|
|
|
--- <pre>
|
|
|
|
--- vim.paste = (function()
|
|
|
|
--- local overridden = vim.paste
|
|
|
|
--- ...
|
|
|
|
--- end)()
|
|
|
|
--- </pre>
|
|
|
|
---
|
2021-08-22 13:55:28 -07:00
|
|
|
---@see |paste|
|
2019-10-27 15:05:59 -07:00
|
|
|
---
|
2021-08-22 13:55:28 -07:00
|
|
|
---@param lines ...
|
|
|
|
---@param phase ...
|
|
|
|
---@returns false if client should cancel the paste.
|
2019-10-27 15:05:59 -07:00
|
|
|
|
|
|
|
|
|
|
|
LUA *dev-lua*
|
|
|
|
|
|
|
|
- Keep the core Lua modules |lua-stdlib| simple. Avoid elaborate OOP or
|
|
|
|
pseudo-OOP designs. Plugin authors just want functions to call, they don't
|
2021-08-27 03:59:13 -07:00
|
|
|
want to learn a big, fancy inheritance hierarchy. Thus avoid specialized
|
|
|
|
objects; tables or values are usually better.
|
2019-10-27 15:05:59 -07:00
|
|
|
|
|
|
|
|
2017-04-17 14:52:38 -07:00
|
|
|
API *dev-api*
|
2016-09-16 21:30:36 -07:00
|
|
|
|
2021-08-27 03:59:13 -07:00
|
|
|
Use this template to name new RPC |API| functions:
|
2016-09-16 21:30:36 -07:00
|
|
|
nvim_{thing}_{action}_{arbitrary-qualifiers}
|
|
|
|
|
|
|
|
If the function acts on an object then {thing} is the name of that object
|
|
|
|
(e.g. "buf" or "win"). If the function operates in a "global" context then
|
|
|
|
{thing} is usually omitted (but consider "namespacing" your global operations
|
|
|
|
with a {thing} that groups functions under a common concept).
|
|
|
|
|
|
|
|
Use existing common {action} names if possible:
|
2016-09-24 06:07:49 -07:00
|
|
|
add Append to, or insert into, a collection
|
|
|
|
del Delete a thing (or group of things)
|
2019-12-02 01:46:46 -07:00
|
|
|
exec Execute code
|
|
|
|
get Get a thing (or group of things by query)
|
2016-09-24 06:07:49 -07:00
|
|
|
list Get all things
|
2019-12-02 01:46:46 -07:00
|
|
|
set Set a thing (or group of things)
|
2016-09-16 21:30:36 -07:00
|
|
|
|
2016-09-24 06:07:49 -07:00
|
|
|
Use consistent names for {thing} in all API functions. E.g. a buffer is called
|
2016-09-16 21:30:36 -07:00
|
|
|
"buf" everywhere, not "buffer" in some places and "buf" in others.
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
Example:
|
|
|
|
`nvim_get_current_line` acts on the global editor state; the common
|
|
|
|
{action} "get" is used but {thing} is omitted.
|
2016-09-16 21:30:36 -07:00
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
Example:
|
|
|
|
`nvim_buf_add_highlight` acts on a `Buffer` object (the first parameter)
|
|
|
|
and uses the common {action} "add".
|
2016-09-16 21:30:36 -07:00
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
Example:
|
|
|
|
`nvim_list_bufs` operates in a global context (first parameter is not
|
|
|
|
a Buffer). The common {action} "list" indicates that it lists all bufs
|
|
|
|
(plural) in the global context.
|
2016-09-16 21:30:36 -07:00
|
|
|
|
2017-12-27 11:30:23 -07:00
|
|
|
Use this template to name new API events:
|
|
|
|
nvim_{thing}_{event}_event
|
|
|
|
|
2019-05-11 07:58:47 -07:00
|
|
|
Example:
|
|
|
|
`nvim_buf_changedtick_event`
|
2017-12-27 11:30:23 -07:00
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2017-08-19 05:13:14 -07:00
|
|
|
API-CLIENT *dev-api-client*
|
|
|
|
|
2019-08-25 16:00:58 -07:00
|
|
|
*api-client*
|
|
|
|
API clients wrap the Nvim |API| to provide idiomatic "SDKs" for their
|
|
|
|
respective platforms (see |jargon|). You can build a new API client for your
|
|
|
|
favorite platform or programming language.
|
|
|
|
|
|
|
|
List of API clients:
|
|
|
|
https://github.com/neovim/neovim/wiki/Related-projects#api-clients
|
|
|
|
|
|
|
|
*pynvim*
|
|
|
|
The Python client is the reference implementation for API clients.
|
|
|
|
https://github.com/neovim/pynvim
|
|
|
|
|
2018-08-04 18:17:08 -07:00
|
|
|
Standard Features ~
|
|
|
|
|
2019-08-25 16:00:58 -07:00
|
|
|
- API clients exist to hide msgpack-rpc details. The wrappers can be
|
|
|
|
automatically generated by reading the |api-metadata| from Nvim. |api-mapping|
|
2018-08-04 18:17:08 -07:00
|
|
|
- Clients should call |nvim_set_client_info()| after connecting, so users and
|
2019-08-25 16:00:58 -07:00
|
|
|
plugins can detect the client by handling the |ChanInfo| event. This avoids
|
|
|
|
the need for special variables or other client hints.
|
2018-12-01 08:44:36 -07:00
|
|
|
- Clients should handle |nvim_error_event| notifications, which will be sent
|
|
|
|
if an async request to nvim was rejected or caused an error.
|
2018-08-04 18:17:08 -07:00
|
|
|
|
2017-08-19 05:13:14 -07:00
|
|
|
Package Naming ~
|
2018-08-04 18:17:08 -07:00
|
|
|
|
2017-08-19 05:13:14 -07:00
|
|
|
API client packages should NOT be named something ambiguous like "neovim" or
|
|
|
|
"python-client". Use "nvim" as a prefix/suffix to some other identifier
|
|
|
|
following ecosystem conventions.
|
|
|
|
|
|
|
|
For example, Python packages tend to have "py" in the name, so "pynvim" is
|
|
|
|
a good name: it's idiomatic and unambiguous. If the package is named "neovim",
|
|
|
|
it confuses users, and complicates documentation and discussions.
|
|
|
|
|
|
|
|
Examples of API-client package names:
|
|
|
|
GOOD: nvim-racket
|
|
|
|
GOOD: pynvim
|
|
|
|
BAD: python-client
|
|
|
|
BAD: neovim
|
|
|
|
|
2019-08-25 16:00:58 -07:00
|
|
|
API client implementation guidelines ~
|
|
|
|
|
|
|
|
- Separate the transport layer from the rest of the library. |rpc-connecting|
|
|
|
|
- Use a MessagePack library that implements at least version 5 of the
|
|
|
|
MessagePack spec, which supports the BIN and EXT types used by Nvim.
|
|
|
|
- Use a single-threaded event loop library/pattern.
|
|
|
|
- Use a fiber/coroutine library for the language being used for implementing
|
|
|
|
a client. These greatly simplify concurrency and allow the library to
|
|
|
|
expose a blocking API on top of a non-blocking event loop without the
|
|
|
|
complexity that comes with preemptive multitasking.
|
|
|
|
- Don't assume anything about the order of responses to RPC requests.
|
|
|
|
- Clients should expect requests, which must be handled immediately because
|
|
|
|
Nvim is blocked while waiting for the client response.
|
|
|
|
- Clients should expect notifications, but these can be handled "ASAP" (rather
|
|
|
|
than immediately) because they won't block Nvim.
|
|
|
|
- For C/C++ projects, consider libmpack instead of the msgpack.org library.
|
2019-01-10 17:20:15 -07:00
|
|
|
https://github.com/libmpack/libmpack/
|
2019-08-25 16:00:58 -07:00
|
|
|
libmpack is small (no dependencies, can inline into your C/C++ project) and
|
|
|
|
efficient (no allocations). It also implements msgpack-RPC, the protocol
|
|
|
|
required by Nvim.
|
2019-01-10 17:20:15 -07:00
|
|
|
https://github.com/msgpack-rpc/msgpack-rpc
|
2017-08-19 05:13:14 -07:00
|
|
|
|
2019-08-25 16:00:58 -07:00
|
|
|
|
2017-04-17 14:52:38 -07:00
|
|
|
EXTERNAL UI *dev-ui*
|
|
|
|
|
|
|
|
External UIs should be aware of the |api-contract|. In particular, future
|
2017-08-19 05:13:14 -07:00
|
|
|
versions of Nvim may add new items to existing events. The API is strongly
|
2018-06-27 15:48:17 -07:00
|
|
|
backwards-compatible, but clients must not break if new (optional) fields are
|
|
|
|
added to existing events.
|
2017-04-17 14:52:38 -07:00
|
|
|
|
2018-08-04 18:17:08 -07:00
|
|
|
Standard Features ~
|
|
|
|
|
2017-08-19 05:13:14 -07:00
|
|
|
External UIs are expected to implement these common features:
|
2018-08-04 18:17:08 -07:00
|
|
|
|
|
|
|
- Call |nvim_set_client_info()| after connecting, so users and plugins can
|
|
|
|
detect the UI by handling the |ChanInfo| event. This avoids the need for
|
|
|
|
special variables and UI-specific config files (gvimrc, macvimrc, …).
|
2018-06-27 15:48:17 -07:00
|
|
|
- Cursor style (shape, color) should conform to the 'guicursor' properties
|
2017-08-19 05:13:14 -07:00
|
|
|
delivered with the mode_info_set UI event.
|
2017-12-27 11:30:23 -07:00
|
|
|
- Send the ALT/META ("Option" on macOS) key as a |<M-| chord.
|
2017-08-19 05:13:14 -07:00
|
|
|
- Send the "super" key (Windows key, Apple key) as a |<D-| chord.
|
2018-06-27 15:48:17 -07:00
|
|
|
- Avoid mappings that conflict with the Nvim keymap-space; GUIs have many new
|
|
|
|
chords (<C-,> <C-Enter> <C-S-x> <D-x>) and patterns ("shift shift") that do
|
|
|
|
not potentially conflict with Nvim defaults, plugins, etc.
|
|
|
|
- Consider the "option_set" |ui-global| event as a hint for other GUI
|
2019-11-25 09:56:42 -07:00
|
|
|
behaviors. Various UI-related options ('guifont', 'ambiwidth', …) are
|
|
|
|
published in this event. See also "mouse_on", "mouse_off".
|
2017-04-17 14:52:38 -07:00
|
|
|
|
|
|
|
|
2021-08-22 18:26:35 -07:00
|
|
|
NAMING *dev-naming*
|
|
|
|
|
2021-08-27 03:59:13 -07:00
|
|
|
Naming is important. Consistent naming in the API and UI helps both users and
|
|
|
|
developers discover and intuitively understand related concepts ("families"),
|
|
|
|
and reduces cognitive burden. Discoverability encourages code re-use and
|
|
|
|
likewise avoids redundant, overlapping mechanisms, which reduces code
|
|
|
|
surface-area, and thereby minimizes bugs...
|
|
|
|
|
|
|
|
Naming conventions ~
|
|
|
|
|
|
|
|
Use the "on_" prefix to name event handlers and also the interface for
|
|
|
|
"registering" such handlers (on_key). The dual nature is acceptable to avoid
|
|
|
|
a confused collection of naming conventions for these related concepts.
|
2021-08-22 18:26:35 -07:00
|
|
|
|
|
|
|
|
2018-10-29 01:50:39 -07:00
|
|
|
vim:tw=78:ts=8:noet:ft=help:norl:
|