mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
docs: naming conventions
This commit is contained in:
parent
69fe427df4
commit
9f3679cbfd
@ -29,10 +29,10 @@ Reporting problems
|
|||||||
Developer guidelines
|
Developer guidelines
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
- Nvim developers should read `:help dev`.
|
- Read `:help dev` if you are working on Nvim core.
|
||||||
- External UI developers should read `:help dev-ui`.
|
- Read `:help dev-ui` if you are developing a UI.
|
||||||
- API client developers should read `:help dev-api-client`.
|
- Read `:help dev-api-client` if you are developing an API client.
|
||||||
- Nvim developers are _strongly encouraged_ to install `ninja` for faster builds.
|
- Install `ninja` for faster builds of Nvim.
|
||||||
```
|
```
|
||||||
sudo apt-get install ninja-build
|
sudo apt-get install ninja-build
|
||||||
make distclean
|
make distclean
|
||||||
|
@ -127,14 +127,20 @@ Sometimes a GUI or other application may want to force a provider to
|
|||||||
|
|
||||||
DOCUMENTATION *dev-doc*
|
DOCUMENTATION *dev-doc*
|
||||||
|
|
||||||
- Do not prefix help tags with "nvim-". Use |vim_diff.txt| to document
|
- "Just say it". Avoid mushy, colloquial phrasing in all documentation
|
||||||
differences from Vim; no other distinction is necessary.
|
(docstrings, user manual, website materials, newsletters, …). Don't mince
|
||||||
- If a Vim feature is removed, delete its help section and move its tag to
|
words. Personality and flavor, used sparingly, are welcome--but in general,
|
||||||
|vim_diff.txt|.
|
optimize for the reader's time and energy: be "precise yet concise".
|
||||||
- Move deprecated features to |deprecated.txt|.
|
- 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.
|
||||||
- Use consistent language.
|
- Use consistent language.
|
||||||
- "terminal" in a help tag always means "the embedded terminal emulator", not
|
- "terminal" in a help tag always means "the embedded terminal emulator",
|
||||||
"the user host terminal".
|
not "the user host terminal".
|
||||||
- Use "tui-" to prefix help tags related to the host terminal, and "TUI"
|
- Use "tui-" to prefix help tags related to the host terminal, and "TUI"
|
||||||
in prose if possible.
|
in prose if possible.
|
||||||
- Docstrings: do not start parameter descriptions with "The" or "A" unless it
|
- Docstrings: do not start parameter descriptions with "The" or "A" unless it
|
||||||
@ -222,13 +228,13 @@ LUA *dev-lua*
|
|||||||
|
|
||||||
- Keep the core Lua modules |lua-stdlib| simple. Avoid elaborate OOP or
|
- 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
|
pseudo-OOP designs. Plugin authors just want functions to call, they don't
|
||||||
want to learn a big, fancy inheritance hierarchy. So we should avoid complex
|
want to learn a big, fancy inheritance hierarchy. Thus avoid specialized
|
||||||
objects: tables are usually better.
|
objects; tables or values are usually better.
|
||||||
|
|
||||||
|
|
||||||
API *dev-api*
|
API *dev-api*
|
||||||
|
|
||||||
Use this template to name new API functions:
|
Use this template to name new RPC |API| functions:
|
||||||
nvim_{thing}_{action}_{arbitrary-qualifiers}
|
nvim_{thing}_{action}_{arbitrary-qualifiers}
|
||||||
|
|
||||||
If the function acts on an object then {thing} is the name of that object
|
If the function acts on an object then {thing} is the name of that object
|
||||||
@ -358,9 +364,17 @@ External UIs are expected to implement these common features:
|
|||||||
|
|
||||||
NAMING *dev-naming*
|
NAMING *dev-naming*
|
||||||
|
|
||||||
Naming is very important. Consistent naming in the API and UI helps users
|
Naming is important. Consistent naming in the API and UI helps both users and
|
||||||
discover and intuitively understand related "families" of things. It reduces
|
developers discover and intuitively understand related concepts ("families"),
|
||||||
cognitive burden.
|
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.
|
||||||
|
|
||||||
|
|
||||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||||
|
@ -576,11 +576,11 @@ If you want to exclude visual selections from highlighting on yank, use
|
|||||||
vim.highlight.on_yank({opts}) *vim.highlight.on_yank()*
|
vim.highlight.on_yank({opts}) *vim.highlight.on_yank()*
|
||||||
Highlights the yanked text. The fields of the optional dict {opts}
|
Highlights the yanked text. The fields of the optional dict {opts}
|
||||||
control the highlight:
|
control the highlight:
|
||||||
- {higroup} highlight group for yanked region (default `"IncSearch"`)
|
- {higroup} highlight group for yanked region (default |hl-IncSearch|)
|
||||||
- {timeout} time in ms before highlight is cleared (default `150`)
|
- {timeout} time in ms before highlight is cleared (default `150`)
|
||||||
- {on_macro} highlight when executing macro (default `false`)
|
- {on_macro} highlight when executing macro (default `false`)
|
||||||
- {on_visual} highlight when yanking visual selection (default `true`)
|
- {on_visual} highlight when yanking visual selection (default `true`)
|
||||||
- {event} event structure (default `vim.v.event`)
|
- {event} event structure (default |v:event|)
|
||||||
|
|
||||||
vim.highlight.range({bufnr}, {ns}, {higroup}, {start}, {finish}, {rtype}, {inclusive})
|
vim.highlight.range({bufnr}, {ns}, {higroup}, {start}, {finish}, {rtype}, {inclusive})
|
||||||
*vim.highlight.range()*
|
*vim.highlight.range()*
|
||||||
|
@ -6,16 +6,16 @@
|
|||||||
|
|
||||||
Differences between Nvim and Vim *vim-differences*
|
Differences between Nvim and Vim *vim-differences*
|
||||||
|
|
||||||
Nvim differs from Vim in many ways, although editor and VimL features are
|
Nvim differs from Vim in many ways, although editor and Vimscript (not
|
||||||
mostly identical. This document is a complete and centralized reference of
|
Vim9script) features are mostly identical. This document is a complete and
|
||||||
the differences.
|
centralized reference of the differences.
|
||||||
|
|
||||||
Type |gO| to see the table of contents.
|
Type |gO| to see the table of contents.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
1. Configuration *nvim-config*
|
1. Configuration *nvim-config*
|
||||||
|
|
||||||
- Use `$XDG_CONFIG_HOME/nvim/init.vim` instead of `.vimrc` for configuration.
|
- Use `$XDG_CONFIG_HOME/nvim/init.vim` instead of `.vimrc` for your |config|.
|
||||||
- Use `$XDG_CONFIG_HOME/nvim` instead of `.vim` to store configuration files.
|
- Use `$XDG_CONFIG_HOME/nvim` instead of `.vim` to store configuration files.
|
||||||
- Use `$XDG_DATA_HOME/nvim/shada/main.shada` instead of `.viminfo` for persistent
|
- Use `$XDG_DATA_HOME/nvim/shada/main.shada` instead of `.viminfo` for persistent
|
||||||
session information. |shada|
|
session information. |shada|
|
||||||
@ -78,6 +78,8 @@ the differences.
|
|||||||
|
|
||||||
Default Mappings ~
|
Default Mappings ~
|
||||||
*default-mappings*
|
*default-mappings*
|
||||||
|
Nvim creates the following default mappings at |startup|. You can disable any
|
||||||
|
of these in your config by simply removing the mapping, e.g. ":unmap Y".
|
||||||
>
|
>
|
||||||
nnoremap Y y$
|
nnoremap Y y$
|
||||||
nnoremap <C-L> <Cmd>nohlsearch<Bar>diffupdate<CR><C-L>
|
nnoremap <C-L> <Cmd>nohlsearch<Bar>diffupdate<CR><C-L>
|
||||||
@ -101,17 +103,19 @@ nvim_cmdwin:
|
|||||||
MAJOR COMPONENTS ~
|
MAJOR COMPONENTS ~
|
||||||
|
|
||||||
API |API|
|
API |API|
|
||||||
Lua scripting |lua|
|
|
||||||
Job control |job-control|
|
Job control |job-control|
|
||||||
Remote plugins |remote-plugin|
|
LSP framework |lsp|
|
||||||
|
Lua scripting |lua|
|
||||||
|
Parsing engine |treesitter|
|
||||||
Providers
|
Providers
|
||||||
Clipboard |provider-clipboard|
|
Clipboard |provider-clipboard|
|
||||||
Node.js plugins |provider-nodejs|
|
Node.js plugins |provider-nodejs|
|
||||||
Python plugins |provider-python|
|
Python plugins |provider-python|
|
||||||
Ruby plugins |provider-ruby|
|
Ruby plugins |provider-ruby|
|
||||||
|
Remote plugins |remote-plugin|
|
||||||
Shared data |shada|
|
Shared data |shada|
|
||||||
Embedded terminal |terminal|
|
Terminal emulator |terminal|
|
||||||
VimL parser |nvim_parse_expression()|
|
Vimscript parser |nvim_parse_expression()|
|
||||||
XDG base directories |xdg|
|
XDG base directories |xdg|
|
||||||
|
|
||||||
USER EXPERIENCE ~
|
USER EXPERIENCE ~
|
||||||
@ -160,7 +164,7 @@ FEATURES ~
|
|||||||
|
|
||||||
Command-line highlighting:
|
Command-line highlighting:
|
||||||
The expression prompt (|@=|, |c_CTRL-R_=|, |i_CTRL-R_=|) is highlighted
|
The expression prompt (|@=|, |c_CTRL-R_=|, |i_CTRL-R_=|) is highlighted
|
||||||
using a built-in VimL expression parser. |expr-highlight|
|
using a built-in Vimscript expression parser. |expr-highlight|
|
||||||
*E5408* *E5409*
|
*E5408* *E5409*
|
||||||
|input()|, |inputdialog()| support custom highlighting. |input()-highlight|
|
|input()|, |inputdialog()| support custom highlighting. |input()-highlight|
|
||||||
*g:Nvim_color_cmdline*
|
*g:Nvim_color_cmdline*
|
||||||
@ -413,7 +417,7 @@ TUI:
|
|||||||
UI/Display:
|
UI/Display:
|
||||||
|Visual| selection highlights the character at cursor. |visual-use|
|
|Visual| selection highlights the character at cursor. |visual-use|
|
||||||
|
|
||||||
VimL (Vim script) compatibility:
|
Vimscript compatibility:
|
||||||
`count` does not alias to |v:count|
|
`count` does not alias to |v:count|
|
||||||
`errmsg` does not alias to |v:errmsg|
|
`errmsg` does not alias to |v:errmsg|
|
||||||
`shell_error` does not alias to |v:shell_error|
|
`shell_error` does not alias to |v:shell_error|
|
||||||
|
@ -334,7 +334,7 @@ int main(int argc, char **argv)
|
|||||||
// prepare screen now, so external UIs can display messages
|
// prepare screen now, so external UIs can display messages
|
||||||
starting = NO_BUFFERS;
|
starting = NO_BUFFERS;
|
||||||
screenclear();
|
screenclear();
|
||||||
TIME_MSG("initialized screen early for UI");
|
TIME_MSG("init screen for UI");
|
||||||
}
|
}
|
||||||
|
|
||||||
init_default_mappings(); // Default mappings.
|
init_default_mappings(); // Default mappings.
|
||||||
|
@ -78,10 +78,10 @@ describe('notify', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('cancels stale events on channel close', function()
|
it('cancels stale events on channel close', function()
|
||||||
if isCI() then
|
if isCI() then
|
||||||
pending('Sporadic hangs on CI (c.f., #14083). Skip until it is fixed.')
|
pending('hangs on CI #14083 #15251')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if helpers.pending_win32(pending) then return end
|
if helpers.pending_win32(pending) then return end
|
||||||
local catchan = eval("jobstart(['cat'], {'rpc': v:true})")
|
local catchan = eval("jobstart(['cat'], {'rpc': v:true})")
|
||||||
local catpath = eval('exepath("cat")')
|
local catpath = eval('exepath("cat")')
|
||||||
|
Loading…
Reference in New Issue
Block a user