mirror of https://github.com/neovim/neovim.git
Compare commits
8 Commits
65c641399d
...
56bf418d09
Author | SHA1 | Date |
---|---|---|
Justin M. Keyes | 56bf418d09 | |
zeertzjq | 435dee74bb | |
zeertzjq | 694756252b | |
zeertzjq | e81eb34aa1 | |
zeertzjq | a1568f5df0 | |
zeertzjq | f1f5fb911b | |
Justin M. Keyes | 6c8c982213 | |
Justin M. Keyes | 4b34ae4ce3 |
|
@ -2833,16 +2833,7 @@ nvim_win_add_ns({window}, {ns_id}) *nvim_win_add_ns()*
|
|||
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.
|
||||
|
||||
Parameters: ~
|
||||
• {window} Window handle, or 0 for current window
|
||||
|
||||
Return: ~
|
||||
a list of namespaces ids
|
||||
|
||||
nvim_win_remove_ns({window}, {ns_id}) *nvim_win_remove_ns()*
|
||||
nvim_win_del_ns({window}, {ns_id}) *nvim_win_del_ns()*
|
||||
Removes the namespace scope from the window.
|
||||
|
||||
Parameters: ~
|
||||
|
@ -2852,6 +2843,15 @@ nvim_win_remove_ns({window}, {ns_id}) *nvim_win_remove_ns()*
|
|||
Return: ~
|
||||
true if the namespace was removed, else false
|
||||
|
||||
nvim_win_get_ns({window}) *nvim_win_get_ns()*
|
||||
Gets all the namespaces scopes associated with a window.
|
||||
|
||||
Parameters: ~
|
||||
• {window} Window handle, or 0 for current window
|
||||
|
||||
Return: ~
|
||||
a list of namespaces ids
|
||||
|
||||
|
||||
==============================================================================
|
||||
Window Functions *api-window*
|
||||
|
|
|
@ -8208,6 +8208,10 @@ synconcealed({lnum}, {col}) *synconcealed()*
|
|||
synconcealed(lnum, 5) [1, 'X', 2]
|
||||
synconcealed(lnum, 6) [0, '', 0]
|
||||
|
||||
Note: Doesn't consider |matchadd()| highlighting items,
|
||||
since syntax and matching highlighting are two different
|
||||
mechanisms |syntax-vs-match|.
|
||||
|
||||
synstack({lnum}, {col}) *synstack()*
|
||||
Return a |List|, which is the stack of syntax items at the
|
||||
position {lnum} and {col} in the current window. {lnum} is
|
||||
|
|
|
@ -375,7 +375,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
|
||||
|
@ -393,8 +393,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
|
||||
|
@ -407,10 +407,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
|
||||
|
@ -428,12 +428,13 @@ 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. The scope should be
|
||||
a parameter.
|
||||
|
||||
- Example: `nvim_get_keymap('v')` operates in a global context (first
|
||||
parameter is not a Buffer). The "get" verb indicates that it gets anything
|
||||
|
@ -443,6 +444,59 @@ 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, boilerplate, and function interfaces. Thus the
|
||||
following is generally NOT recommended (compare these 12(!) functions to the
|
||||
above 3 functions! All of these require separate docs, which users must read,
|
||||
maintainers must maintain, ...): >
|
||||
|
||||
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*
|
||||
|
|
|
@ -193,7 +193,17 @@ 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".
|
||||
• |nvim_tabpage_set_win()| sets the current window of a tabpage.
|
||||
• |namespace| can now have window scopes. |nvim_ns_add()|
|
||||
|
||||
• 'foldtext' now supports virtual text format. |fold-foldtext|
|
||||
|
||||
|
@ -205,9 +215,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|
|
||||
|
@ -303,15 +310,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).
|
||||
|
||||
|
@ -342,8 +343,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.
|
||||
|
||||
|
@ -367,12 +366,8 @@ The following new APIs and features were added.
|
|||
highlight attribute. The TUI will display URLs 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.
|
||||
|
|
|
@ -1375,6 +1375,19 @@ Finally, these constructs are unique to Perl:
|
|||
==============================================================================
|
||||
10. Highlighting matches *match-highlight*
|
||||
|
||||
*syntax-vs-match*
|
||||
Note that the match highlight mechanism is independent
|
||||
of |syntax-highlighting|, which is (usually) a buffer-local
|
||||
highlighting, while matching is window-local, both methods
|
||||
can be freely mixed. Match highlighting functions give you
|
||||
a bit more flexibility in when and how to apply, but are
|
||||
typically only used for temporary highlighting, without strict
|
||||
rules. Both methods can be used to conceal text.
|
||||
|
||||
Thus the matching functions like |matchadd()| won't consider
|
||||
syntax rules and functions like |synconcealed()| and the
|
||||
other way around.
|
||||
|
||||
*:mat* *:match*
|
||||
:mat[ch] {group} /{pattern}/
|
||||
Define a pattern to highlight in the current window. It will
|
||||
|
|
|
@ -3825,7 +3825,9 @@ Whether or not it is actually concealed depends on the value of the
|
|||
'conceallevel' option. The 'concealcursor' option is used to decide whether
|
||||
concealable items in the current line are displayed unconcealed to be able to
|
||||
edit the line.
|
||||
Another way to conceal text is with |matchadd()|.
|
||||
|
||||
Another way to conceal text is with |matchadd()|, but internally this works a
|
||||
bit differently |syntax-vs-match|.
|
||||
|
||||
concealends *:syn-concealends*
|
||||
|
||||
|
@ -3833,7 +3835,9 @@ When the "concealends" argument is given, the start and end matches of
|
|||
the region, but not the contents of the region, are marked as concealable.
|
||||
Whether or not they are actually concealed depends on the setting on the
|
||||
'conceallevel' option. The ends of a region can only be concealed separately
|
||||
in this way when they have their own highlighting via "matchgroup"
|
||||
in this way when they have their own highlighting via "matchgroup". The
|
||||
|synconcealed()| function can be used to retrieve information about conealed
|
||||
items.
|
||||
|
||||
cchar *:syn-cchar*
|
||||
*E844*
|
||||
|
|
|
@ -948,7 +948,7 @@ Syntax and highlighting: *syntax-functions* *highlighting-functions*
|
|||
synIDattr() get a specific attribute of a syntax ID
|
||||
synIDtrans() get translated syntax ID
|
||||
synstack() get list of syntax IDs at a specific position
|
||||
synconcealed() get info about concealing
|
||||
synconcealed() get info about (syntax) concealing
|
||||
diff_hlID() get highlight ID for diff mode at a position
|
||||
matchadd() define a pattern to highlight (a "match")
|
||||
matchaddpos() define a list of positions to highlight
|
||||
|
|
|
@ -2114,6 +2114,13 @@ function vim.api.nvim_win_call(window, fun) end
|
|||
--- hidden, even if 'hidden' is not set.
|
||||
function vim.api.nvim_win_close(window, force) end
|
||||
|
||||
--- Removes the namespace scope from the window.
|
||||
---
|
||||
--- @param window integer Window handle, or 0 for current window
|
||||
--- @param ns_id integer the namespace to remove
|
||||
--- @return boolean
|
||||
function vim.api.nvim_win_del_ns(window, ns_id) end
|
||||
|
||||
--- Removes a window-scoped (w:) variable
|
||||
---
|
||||
--- @param window integer Window handle, or 0 for current window
|
||||
|
@ -2209,13 +2216,6 @@ function vim.api.nvim_win_hide(window) end
|
|||
--- @return boolean
|
||||
function vim.api.nvim_win_is_valid(window) end
|
||||
|
||||
--- Removes the namespace scope from the window.
|
||||
---
|
||||
--- @param window integer Window handle, or 0 for current window
|
||||
--- @param ns_id integer the namespace to remove
|
||||
--- @return boolean
|
||||
function vim.api.nvim_win_remove_ns(window, ns_id) end
|
||||
|
||||
--- Sets the current buffer in a window, without side effects
|
||||
---
|
||||
--- @param window integer Window handle, or 0 for current window
|
||||
|
|
|
@ -9752,6 +9752,10 @@ function vim.fn.synIDtrans(synID) end
|
|||
--- synconcealed(lnum, 5) [1, 'X', 2]
|
||||
--- synconcealed(lnum, 6) [0, '', 0]
|
||||
---
|
||||
--- Note: Doesn't consider |matchadd()| highlighting items,
|
||||
--- since syntax and matching highlighting are two different
|
||||
--- mechanisms |syntax-vs-match|.
|
||||
---
|
||||
--- @param lnum integer
|
||||
--- @param col integer
|
||||
--- @return {[1]: integer, [2]: string, [3]: integer}
|
||||
|
|
|
@ -158,7 +158,7 @@ function M.on_yank(opts)
|
|||
yank_timer = nil
|
||||
yank_cancel = nil
|
||||
pcall(vim.api.nvim_buf_clear_namespace, bufnr, yank_ns, 0, -1)
|
||||
pcall(vim.api.nvim_win_remove_ns, winid, yank_ns)
|
||||
pcall(vim.api.nvim_win_del_ns, winid, yank_ns)
|
||||
end
|
||||
|
||||
yank_timer = vim.defer_fn(yank_cancel, timeout)
|
||||
|
|
|
@ -1277,7 +1277,7 @@ ArrayOf(Integer) nvim_win_get_ns(Window window, Arena *arena, Error *err)
|
|||
/// @param window Window handle, or 0 for current window
|
||||
/// @param ns_id the namespace to remove
|
||||
/// @return true if the namespace was removed, else false
|
||||
Boolean nvim_win_remove_ns(Window window, Integer ns_id, Error *err)
|
||||
Boolean nvim_win_del_ns(Window window, Integer ns_id, Error *err)
|
||||
FUNC_API_SINCE(12)
|
||||
{
|
||||
win_T *win = find_window_by_handle(window, err);
|
||||
|
|
|
@ -47,8 +47,8 @@ typedef struct {
|
|||
#define VALID_VIRTCOL 0x04 // w_virtcol (file col) is valid
|
||||
#define VALID_CHEIGHT 0x08 // w_cline_height and w_cline_folded valid
|
||||
#define VALID_CROW 0x10 // w_cline_row is valid
|
||||
#define VALID_BOTLINE 0x20 // w_botine and w_empty_rows are valid
|
||||
#define VALID_BOTLINE_AP 0x40 // w_botine is approximated
|
||||
#define VALID_BOTLINE 0x20 // w_botline and w_empty_rows are valid
|
||||
#define VALID_BOTLINE_AP 0x40 // w_botline is approximated
|
||||
#define VALID_TOPLINE 0x80 // w_topline is valid (for cursor position)
|
||||
|
||||
// flags for b_flags
|
||||
|
|
|
@ -11621,6 +11621,10 @@ M.funcs = {
|
|||
synconcealed(lnum, 4) [1, 'X', 2]
|
||||
synconcealed(lnum, 5) [1, 'X', 2]
|
||||
synconcealed(lnum, 6) [0, '', 0]
|
||||
|
||||
Note: Doesn't consider |matchadd()| highlighting items,
|
||||
since syntax and matching highlighting are two different
|
||||
mechanisms |syntax-vs-match|.
|
||||
]=],
|
||||
name = 'synconcealed',
|
||||
params = { { 'lnum', 'integer' }, { 'col', 'integer' } },
|
||||
|
|
|
@ -2467,6 +2467,7 @@ void win_init_empty(win_T *wp)
|
|||
wp->w_topline = 1;
|
||||
wp->w_topfill = 0;
|
||||
wp->w_botline = 2;
|
||||
wp->w_valid = 0;
|
||||
wp->w_s = &wp->w_buffer->b_s;
|
||||
}
|
||||
|
||||
|
|
|
@ -5742,7 +5742,7 @@ describe('decorations: window scoped', function()
|
|||
|
|
||||
]]}
|
||||
|
||||
api.nvim_win_remove_ns(0, ns)
|
||||
api.nvim_win_del_ns(0, ns)
|
||||
|
||||
screen:expect(noextmarks)
|
||||
end)
|
||||
|
@ -5947,7 +5947,7 @@ describe('decorations: window scoped', function()
|
|||
|
|
||||
]]}
|
||||
|
||||
eq(true, api.nvim_win_remove_ns(0, ns))
|
||||
eq(true, api.nvim_win_del_ns(0, ns))
|
||||
eq({}, api.nvim_win_get_ns(0))
|
||||
|
||||
screen:expect(noextmarks)
|
||||
|
|
|
@ -4105,4 +4105,16 @@ func Test_SwapExists_set_other_buf_modified()
|
|||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_BufEnter_botline()
|
||||
set hidden
|
||||
call writefile(range(10), 'Xxx1', 'D')
|
||||
call writefile(range(20), 'Xxx2', 'D')
|
||||
edit Xxx1
|
||||
edit Xxx2
|
||||
au BufEnter Xxx1 call assert_true(line('w$') > 1)
|
||||
edit Xxx1
|
||||
au! BufEnter Xxx1
|
||||
set hidden&vim
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
|
Loading…
Reference in New Issue