Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

nx.win

nx.win.current()

No documentation comment in the prelude.

Defined in api.lua.

nx.win.list()

No documentation comment in the prelude.

Defined in api.lua.

nx.win.set_current(win)

nx.win.set_current(win): focus win (make it the current window) [alias nvim_set_current_win]. win is a window id (0 / nil = the current window, a no-op). The switch is queued and applied after the Lua chunk like the other window ops; the mirror is updated write-through so an immediate nx.win.current() / current-buffer read in the same chunk reflects the new focus.

Defined in api.lua.

nx.win.buf(win)

No documentation comment in the prelude.

Defined in api.lua.

nx.win.width(win)

No documentation comment in the prelude.

Defined in api.lua.

nx.win.height(win)

No documentation comment in the prelude.

Defined in api.lua.

nx.win.call(win, fn)

nvim_win_call(win, fn) / nvim_buf_call(buf, fn): run fn as if win/buf were current, returning fn’s result. In neovim these temporarily switch the editor’s current window/buffer for the duration of the callback; in nxvim the callback runs synchronously in-VM, where “current” is the mirror the server pushed (nx._cur_win / nx._cur_buf / nx._cur_cursor). So these swap that mirror context for the call, run fn, and restore it — which makes every read inside the callback (nvim_win_get_cursor, nvim_get_current_buf, vim.fn.line/col/winnr, …) resolve against the requested window/buffer, and every explicit-handle write that nxvim does expose (vim.bo[buf] option sets, nvim_buf_set_extmark(buf, …)) resolves the swapped mirror at call time and queues that concrete handle — so it, too, targets the right place.

What nxvim CAN’T do is retarget a mutation that binds to “current” only at DRAIN time — an ex-command (vim.cmd), feedkeys, or an LSP buf request — since the queued-ops model applies those against the editor’s real current buffer/window after the chunk, which this call never actually switched. Rather than silently mutate the wrong context, nx._call_ctx_lock is set for the duration of a call whose target differs from the real current, and those funnels raise while it is set (see nx._assert_call_ctx). Plugins use these calls to read a window’s view/dimensions, which is fully faithful.

Defined in api.lua.

nx.win.config(win)

nvim_win_get_config(win): the float placement of win as neovim’s config map, or { relative = "" } for a tiled window. Reads the nx._wins mirror (the server pushes each float’s config into w.float; nvim_open_win / nvim_win_set_config write through it so a read within the same chunk agrees).

Defined in api.lua.

nx.win.saveview()

nx.win.saveview() [alias vim.fn.winsaveview]: the current window’s view — cursor position, scroll (topline/leftcol), and the cursor-restore fields neovim returns. nxvim has no separate curswant/coladd/skipcol state, so those mirror col / are 0.

Defined in api.lua.

nx.win.set_topline(win, topline)

nx.win.set_topline(win, topline): scroll win so its first visible buffer line is topline (1-based, neovim/winsaveview convention; clamped to the last line).

Defined in api.lua.

nx.win.set_leftcol(win, leftcol)

nx.win.set_leftcol(win, leftcol): horizontally scroll win so its first visible screen column is leftcol (0-based). Only meaningful under 'nowrap'.

Defined in api.lua.

nx.win.set_cursor(win, line, col)

nx.win.set_cursor(win, line[, col]): move win’s cursor to line (1-based) / col (0-based byte column, default 0). The explicit-win counterpart of the (intentionally-absent) nvim_win_set_cursor.

Defined in api.lua.

nx.win.restview(win, view)

nx.win.restview(win, view): restore win’s view from a winsaveview-shaped table (topline 1-based, leftcol 0-based, optional lnum/col cursor) — the explicit-win winrestview analogue. Only the present fields are applied.

Defined in api.lua.

nx.win.nr(arg)

nx.win.nr([arg]) [alias vim.fn.winnr]: the current window’s 1-based number (its index in the layout order), or with “$” the number of windows. (vim’s “#” previous-window form needs window history the mirror doesn’t keep, so it errors.)

Defined in api.lua.

nx.win.width_nr(nr)

No documentation comment in the prelude.

Defined in api.lua.

nx.win.height_nr(nr)

No documentation comment in the prelude.

Defined in api.lua.

nx.win.is_valid(win)

nvim_win_is_valid(win): whether win names a window the mirror knows about (0/nil is the current window, always valid while one exists). The window analogue of nvim_buf_is_valid — picker teardown/resize guards call it constantly.

Defined in api.lua.

nx.win.position(win)

nvim_win_get_position(win): the window’s top-left as 0-based {row, col} screen coordinates. Exact for a float (its placement); a tiled window’s screen origin isn’t carried in the mirror, so it reports {0, 0} — a documented approximation (a float-positioning plugin positions its own floats and reads their config directly, so the value it cares about is exact). 0/nil is the current window.

Defined in api.lua.

nx.win.getid(winnr, _tabnr)

nx.win.getid([winnr[, tabnr]]) [alias vim.fn.win_getid]: the window id for a 1-based window number (default: the current window). tabnr is accepted but only the current tab’s layout order is consulted (the global window mirror carries it).

Defined in api.lua.

nx.win.findbuf(bufnr)

nx.win.findbuf(bufnr) [alias vim.fn.win_findbuf]: the ids of every window currently displaying bufnr.

Defined in api.lua.

nx.win.gettype(winid)

nx.win.gettype([winid]) [alias vim.fn.win_gettype]: “popup” for a float, “” for a normal window — the distinction a plugin draws to know whether a window is one of its own floats.

Defined in api.lua.

nx.win.screenpos(winnr)

nx.win.screenpos(winnr) [alias vim.fn.win_screenpos]: the 1-based (row, col) screen position of a window’s top-left text cell. Known exactly for a float (its placement); a tiled window’s screen origin isn’t carried in the mirror, so it reports {1, 1} (top-left) — a documented approximation float-positioning plugins tolerate (they position their own floats and read their config directly).

Defined in api.lua.