Commit Graph

382 Commits

Author SHA1 Message Date
dundargoc
6e28589e00
docs: misc (#29229)
Co-authored-by: Ilia Choly <ilia.choly@gmail.com>
Co-authored-by: Jose Pedro Oliveira <jose.p.oliveira.oss@gmail.com>
Co-authored-by: Maria José Solano <majosolano99@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-06-15 07:04:27 +08:00
altermo
f3632e14e3
feat: get/set namespace properties #28728
ref https://github.com/neovim/neovim/pull/28432
ref https://github.com/neovim/neovim/issues/28469
2024-06-07 08:33:40 -07:00
dundargoc
8c5af0eb85
docs: misc (#28837)
Co-authored-by: Danymat <d.danymat@gmail.com>
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: Jakub Okoński <jakub@okonski.org>
Co-authored-by: John L. Villalovos <john@sodarock.com>
Co-authored-by: Maria José Solano <majosolano99@gmail.com>
Co-authored-by: Michaili K <git@michaili.dev>
Co-authored-by: TheLeoP <eugenio2305@hotmail.com>
Co-authored-by: Tobias Schmitz <tobiasschmitz2001@gmail.com>
Co-authored-by: W20MC <157727813+W20MC@users.noreply.github.com>
Co-authored-by: Will Hopkins <willothyh@gmail.com>
Co-authored-by: Yifan Hu <141280278+b0ae989c@users.noreply.github.com>
Co-authored-by: glepnir <glephunter@gmail.com>
Co-authored-by: prljav <74116121+prljav@users.noreply.github.com>
2024-06-07 10:55:14 +08:00
bfredl
75f6ee5b26
Merge pull request #28617 from glepnir/border_hl
fix(float): missing default highlight for title
2024-05-25 11:13:58 +02:00
glepnir
8b2b1fba2a fix(float): missing default highlight for title
Problem: there is missing default title highlight when highlight not defined in title text chunk.

Solution: when attr is not set use default title highlight group.
2024-05-25 15:34:29 +08:00
Justin M. Keyes
aec4938a21
feat(api): broadcast events to ALL channels #28487
Problem:
`vim.rpcnotify(0)` and `rpcnotify(0)` are documented as follows:

    If {channel} is 0, the event is broadcast to all channels.

But that's not actually true. Channels must call `nvim_subscribe` to
receive "broadcast" events, so it's actually "multicast".

- Assuming there is a use-case for "broadcast", the current model adds
  an extra step for broadcasting: all channels need to "subscribe".
- The presence of `nvim_subscribe` is a source of confusion for users,
  because its name implies something more generally useful than what it
  does.

Presumably the use-case of `nvim_subscribe` is to avoid "noise" on RPC
channels not expected a broadcast notification, and potentially an error
if the channel client reports an unknown event.

Solution:
- Deprecate `nvim_subscribe`/`nvim_unsubscribe`.
  - If applications want to multicast, they can keep their own multicast
    list. Or they can use `nvim_list_chans()` and `nvim_get_chan_info()`
    to enumerate and filter the clients they want to target.
- Always send "broadcast" events to ALL channels. Don't require channels
  to "subscribe" to receive broadcasts. This matches the documented
  behavior of `rpcnotify()`.
2024-05-17 07:37:39 -07:00
Justin M. Keyes
97c7646501 refactor(api): nvim_win_xx_ns are EXPERIMENTAL
Problem:
The nvim_win_xx_ns function family introduced in ba0370b1d7
needs more bake-time. Currently it's narrowly defined for windows, but
other scopes ("buffer") and features are likely in the future.

Solution:
- Rename the API with double-underscore to mark it as EXPERIMENTAL.

TODO/FUTURE:
- Rename and change the signature to support more than just "window"
  scope, and for other flexibility.
- Open question: we could choose either:
  - "store scopes on namespaces", or
  - "store namespaces on scopes (w:/b:/…)"
2024-05-12 23:53:24 +02:00
Justin M. Keyes
8f0a166da4 refactor(api): rename nvim_win_remove_ns
Problem:
nvim_win_remove_ns does not follow `help dev-naming` API naming conventions.

Solution:
Rename it.
2024-05-12 23:41:00 +02:00
Luuk van Baal
037ea6e786 feat(api): add nvim__redraw for more granular redrawing
Experimental and subject to future changes.
Add a way to redraw certain elements that are not redrawn while Nvim is waiting
for input, or currently have no API to do so. This API covers all that can be
done with the :redraw* commands, in addition to the following new features:
- Immediately move the cursor to a (non-current) window.
- Target a specific window or buffer to mark for redraw.
- Mark a buffer range for redraw (replaces nvim__buf_redraw_range()).
- Redraw the 'statuscolumn'.
2024-05-02 15:57:06 +02:00
Justin M. Keyes
dafa51c16d
docs(api): sort unreleased nvim__ functions last #28580 2024-04-30 06:06:14 -07:00
Justin M. Keyes
0330dd9e69
fix(api): mark nvim__complete_set as experimental #28579
Problem:
nvim_complete_set was added in 5ed55ff14c
but needs more bake time.

Solution:
Rename it, mark it as experimental.
2024-04-30 05:12:51 -07:00
Justin M. Keyes
71cf75f96a
docs: misc #24163
- Also delete old perl scripts which are not used since 8+ years ago.

fix #23251
fix #27367
ref https://github.com/neovim/neovim/issues/2252#issuecomment-1902662577

Helped-by: Daniel Kongsgaard <dakongsgaard@gmail.com>
Co-authored-by: Kevin Pham <keevan.pham@gmail.com>
2024-04-30 04:30:21 -07:00
Justin M. Keyes
fb5e2db4c7
refactor(api): deprecate nvim_call_atomic #28433
TODO:
FUNC_API_REMOTE_ONLY APIs such as `nvim_ui_*` cannot (yet) be used in
`nvim_exec_lua`. We can change FUNC_API_REMOTE_ONLY to allow
Vimscript/Lua to pass an explicit `channel_id`. #28437
2024-04-22 04:28:16 -07:00
Sean Dewar
7180ef6901
feat(api)!: nvim_open_win: noautocmd blocks all autocmds #28192
Problem: noautocmd is confusing; despite its name, it doesn't block all
autocommands (instead it blocks only those related to setting the buffer), and
is commonly used by plugins to open windows while producing minimal
side-effects.

Solution: be consistent and block all autocommands when noautocmd is set.
This includes WinNew (again), plus autocommands from entering the window (if
enter is set) like WinEnter, WinLeave, TabEnter, .etc.

See the discussion at https://github.com/neovim/neovim/pull/14659#issuecomment-2040029517
for more information.

Remove win_set_buf's noautocmd argument, as it's no longer needed.

NOTE: pum_create_float_preview sets noautocmd for win_set_buf, but all its
callers already use block_autocmds.

Despite that, pum_create_float_preview doesn't actually properly handle
autocommands (it has no checks for whether those from win_enter or
nvim_create_buf free the window).

For now, ensure autocommands are blocked within it for correctness (in case it's
ever called outside of a block_autocmds context; the function seems to have been
refactored in #26739 anyway).
2024-04-14 16:10:16 -07:00
dundargoc
a89ce89742
docs: fix typos (#27868)
Co-authored-by: ite-usagi <77563904+ite-usagi@users.noreply.github.com>
Co-authored-by: v-sim <56476039+v-sim@users.noreply.github.com>
Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Quico Augustijn <quico.public@gmail.com>
Co-authored-by: nhld <nahnera@gmail.com>
Co-authored-by: francisco souza <108725+fsouza@users.noreply.github.com>
2024-03-28 09:32:32 +08:00
Sean Dewar
b596732831
Merge pull request #27330 from seandewar/win_set_config-fixes
fix(api): various window-related function fixes

This is a big one!
2024-03-09 22:32:20 +00:00
Lewis Russell
ade1b12f49 docs: support inline markdown
- Tags are now created with `[tag]()`
- References are now created with `[tag]`
- Code spans are no longer wrapped
2024-03-09 11:21:55 +00:00
Sean Dewar
a70eae57bd
fix(api): make open_win block only enter/leave events if !enter && !noautocmd
Problem: nvim_open_win blocking all win_set_buf autocommands when !enter &&
!noautocmd is too aggressive.

Solution: temporarily block WinEnter/Leave and BufEnter/Leave events when
setting the buffer. Delegate the firing of BufWinEnter back to win_set_buf,
which also has the advantage of keeping the timing consistent (e.g: before the
epilogue in enter_buffer, which also handles restoring the cursor position if
autocommands didn't change it, among other things). Reword the documentation for
noautocmd a bit.

I pondered modifying do_buffer and callees to allow for BufEnter/Leave being
conditionally disabled, but it seems too invasive (and potentially error-prone,
especially if new code paths to BufEnter/Leave are added in the future).

Unfortunately, doing this has the drawback of blocking ALL such events for the
duration, which also means blocking unrelated such events; like if window
switching occurs in a ++nested autocmd fired by win_set_buf. If this turns out
to be a problem in practice, a different solution specialized for nvim_open_win
could be considered. :-)
2024-03-08 23:24:04 +00:00
Sean Dewar
b1577d371a
fix(api): make win_set_config with "win" for splits need "split/vertical"
Problem: currently, for splits, nvim_win_set_config accepts win without any of
split or vertical set, which has little effect and seems error-prone.

Solution: require at least one of split or vertical to also be set for splits.

Also, update nvim_win_set_config docs, as it's no longer limited to just
floating and external windows.
2024-03-08 23:24:04 +00:00
Lewis Russell
9beb40a4db feat(docs): replace lua2dox.lua
Problem:

The documentation flow (`gen_vimdoc.py`) has several issues:
- it's not very versatile
- depends on doxygen
- doesn't work well with Lua code as it requires an awkward filter script to convert it into pseudo-C.
- The intermediate XML files and filters makes it too much like a rube goldberg machine.

Solution:

Re-implement the flow using Lua, LPEG and treesitter.

- `gen_vimdoc.py` is now replaced with `gen_vimdoc.lua` and replicates a portion of the logic.
- `lua2dox.lua` is gone!
- No more XML files.
- Doxygen is now longer used and instead we now use:
  - LPEG for comment parsing (see `scripts/luacats_grammar.lua` and `scripts/cdoc_grammar.lua`).
  - LPEG for C parsing (see `scripts/cdoc_parser.lua`)
  - Lua patterns for Lua parsing (see `scripts/luacats_parser.lua`).
  - Treesitter for Markdown parsing (see `scripts/text_utils.lua`).
- The generated `runtime/doc/*.mpack` files have been removed.
   - `scripts/gen_eval_files.lua` now instead uses `scripts/cdoc_parser.lua` directly.
- Text wrapping is implemented in `scripts/text_utils.lua` and appears to produce more consistent results (the main contributer to the diff of this change).
2024-02-27 14:41:17 +00:00
Evgeni Chasnovski
c2ddef30e7
docs: fix several misleading and superfluous wordings (#27609) 2024-02-25 08:45:34 +08:00
altermo
1c032ad703 feat(extmark): window scoped extmark
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-02-21 16:11:50 +01:00
rktjmp
6d8bbfe19d
docs: remove mention of foreground/background/special keys in nvim_set_hl (#27558)
To align the output of `nvim_get_hl` with its documentation -- which
points to `nvim_set_hl`, remove mentions of the keys `foreground`,
`background` and `special`.

The long keys are are still supported (via fallback checks inside
`dict2hlattrs`), but the `fg`, `bg` and `sp` keys are preferenced.
2024-02-21 21:25:08 +08:00
zeertzjq
a0790558c3
fix(extmarks): priority order of inline and non-inline virt_text (#27532) 2024-02-20 19:53:49 +08:00
Gregory Anders
55a4aa41bb
docs: document breaking change for nvim_create_autocmd callback (#27484)
https://github.com/neovim/neovim/pull/27428 changed the semantics of
callbacks passed to nvim_create_autocmd such that any truthy value will
delete the autocommand (rather than just the literal boolean value
`true`). Update the documentation accordingly and add an entry to
`news.txt`.

The behavior is now consistent between nvim_create_autocmd and
nvim_buf_attach.
2024-02-15 19:56:58 -06:00
bfredl
0353dd3029 refactor(lua): use Arena when converting from lua stack to API args
and for return value of nlua_exec/nlua_call_ref, as this uses
the same family of functions.

NB: the handling of luaref:s is a bit of a mess.
add api_luarefs_free_XX functions as a stop-gap as refactoring
luarefs is a can of worms for another PR:s.

as a minor feature/bug-fix, nvim_buf_call and nvim_win_call now preserves
arbitrary return values.
2024-02-13 11:54:44 +01:00
nikolightsaber
b162adbb7c
feat(api): pass 0 to nvim_get_chan_info for current channel (#27321)
Getting current channel info was kind of annoying via RPC. Two
functions had to be called:
1. `nvim_get_api_info` which returns `[channel_id, meta_data]`.
  - This results in `channel_id = api.nvim_get_api_info()[0]`.
  - Here the meta_data is sent but never used.
2. Finally call `nvim_get_chan_info(channel_id)`.

This commit reduces the need for `nvim_get_api_info` as passing 0
returns current channel info.
2024-02-08 18:59:31 +08:00
Will Hopkins
6bba4beced
feat(api): make nvim_open_win support non-floating windows (#25550)
Adds support to `nvim_open_win` and `nvim_win_set_config` for creating
and manipulating split (non-floating) windows.
2024-02-01 11:43:35 +08:00
Will Hopkins
ca9f6f5694
feat(api): add nvim_tabpage_set_win (#27222)
Allows setting the current window of a non-current tabpage
without switching tabpages.
2024-01-29 15:18:33 +08:00
Gregory Anders
6ea6b3fee2
feat(ui): add support for OSC 8 hyperlinks (#27109)
Extmarks can contain URLs which can then be drawn in any supporting UI.
In the TUI, for example, URLs are "drawn" by emitting the OSC 8 control
sequence to the TTY. On terminals which support the OSC 8 sequence this
will create clickable hyperlinks.

URLs are treated as inline highlights in the decoration subsystem, so
are included in the `DecorSignHighlight` structure. However, unlike
other inline highlights they use allocated memory which must be freed,
so they set the `ext` flag in `DecorInline` so that their lifetimes are
managed along with other allocated memory like virtual text.

The decoration subsystem then adds the URLs as a new highlight
attribute. The highlight subsystem maintains a set of unique URLs to
avoid duplicating allocations for the same string. To attach a URL to an
existing highlight attribute we call `hl_add_url` which finds the URL in
the set (allocating and adding it if it does not exist) and sets the
`url` highlight attribute to the index of the URL in the set (using an
index helps keep the size of the `HlAttrs` struct small).

This has the potential to lead to an increase in highlight attributes
if a URL is used over a range that contains many different highlight
attributes, because now each existing attribute must be combined with
the URL. In practice, however, URLs typically span a range containing a
single highlight (e.g. link text in Markdown), so this is likely just a
pathological edge case.

When a new highlight attribute is defined with a URL it is copied to all
attached UIs with the `hl_attr_define` UI event. The TUI manages its own
set of URLs (just like the highlight subsystem) to minimize allocations.
The TUI keeps track of which URL is "active" for the cell it is
printing. If no URL is active and a cell containing a URL is printed,
the opening OSC 8 sequence is emitted and that URL becomes the actively
tracked URL. If the cursor is moved while in the middle of a URL span,
we emit the terminating OSC sequence to prevent the hyperlink from
spanning multiple lines.

This does not support nested hyperlinks, but that is a rare (and,
frankly, bizarre) use case. If a valid use case for nested hyperlinks
ever presents itself we can address that issue then.
2024-01-24 16:36:25 -06:00
Luuk van Baal
2645c9d576 docs(extmarks): add undocumented "details" array fields 2024-01-18 17:06:47 +01:00
Lewis Russell
2f9ee9b6cf fix(doc): improve doc generation of types using lpeg
Added a lpeg grammar for LuaCATS and use it in lua2dox.lua
2024-01-11 16:24:12 +00:00
Jongwook Choi
f40df63bdc fix(docs): make lines not overflow in vim docs
Problem: Some lines in the generated vim doc are overflowing, not
correctly wrapped at 78 characters. This happens when docs body contains
several consecutive 'inline' elements generated by doxygen.

Solution: Take into account the current column offset of the last line,
and prepend some padding before doc_wrap().
2024-01-09 13:33:18 +00:00
Jaehwang Jung
dc48a98f9a fix(decorations): validate botline for on_win
Problem:
Many decoration providers (treesitter injection highlighting, semantic
token highlighting, inlay hint) rely on the correctness of the `botline`
argument of `on_win` callback. However, `botline` can be smaller than
the actual line number of the last displayed line if some lines are
folded. In such cases, some decorations will be missing in the lines not
covered by `botline`.

Solution:
Validate `botline` when invoking `on_win`.

NOTE:
It seems that the old code was deliberately avoiding this presumably due
to performance reasons. However, I haven't experienced noticeable lag
after this change, and I believe the cost of botline computation would
be much smaller than the cost of decoration providers.
2024-01-04 11:37:00 +00:00
Jaehwang Jung
3faace1995 docs: clarify on_bytes arguments
based on extmark_splice doc
2024-01-01 12:20:19 +01:00
dundargoc
714b075197
docs: small fixes (#26651)
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: WillLillis <wlillis@umass.edu>
2023-12-28 10:28:48 +08:00
luukvbaal
bbd5c6363c
feat(extmarks): add virt_text_repeat_linebreak flag (#26625)
Problem:  Unable to predict which byte-offset to place virtual text to
          make it repeat visually in the wrapped part of a line.
Solution: Add a flag to nvim_buf_set_extmark() that causes virtual
          text to repeat in wrapped lines.
2023-12-26 07:16:03 +08:00
Amanda Graven
428edcde70
feat(api): add forward and back mouse buttons 2023-12-18 21:24:27 +01:00
mathew
e38027ef69 feat(ui): completeopt support popup like vim 2023-12-16 18:59:59 +08:00
Raphael
619407eb54
feat(nvim_open_term): convert LF => CRLF (#26384)
Problem:
Unlike termopen(), nvim_open_term() PTYs do not carriage-return the
cursor on newline ("\n") input.

    nvim --clean
    :let chan_id = nvim_open_term(1, {})
    :call chansend(chan_id, ["here", "are", "some", "lines"])

Actual behavior:

    here
        are
           some
               lines

Expected behaviour:

    here
    are
    some
    lines

Solution:
Add `force_crlf` option, and enable it by default.
2023-12-14 16:08:00 +08:00
Riccardo Mazzarini
0b74ad0a64
refactor(api): complete conversion from Dictionary to Dict(opts) (#26365) 2023-12-05 19:33:57 +08:00
bfredl
ae3685798d feat(decoration): allow conceal_char to be a composing char
decor->text.str pointer must go. This removes it for conceal char,
in preparation for a larger PR which will also handle the sign case.

By actually allowing composing chars for a conceal chars, this
becomes a feature and not just a refactor, as a bonus.
2023-11-28 10:35:25 +01:00
bfredl
df87266b23
Merge pull request #25724 from luukvbaal/signmerge
refactor(sign): move legacy signs to extmarks
2023-11-18 15:04:14 +01:00
Luuk van Baal
c4afb9788c refactor(sign): move legacy signs to extmarks
Problem:  The legacy signlist data structures and associated functions are
          redundant since the introduction of extmark signs.
Solution: Store signs defined through the legacy commands in a hashmap, placed
          signs in the extmark tree. Replace signlist associated functions.

Usage of the legacy sign commands should yield no change in behavior with the
exception of:
  - "orphaned signs" are now always removed when the line it is placed on is
    deleted. This used to depend on the value of 'signcolumn'.
  - It is no longer possible to place multiple signs with the same identifier
    in a single group on multiple lines. This will now move the sign instead.

Moreover, both signs placed through the legacy sign commands and through
|nvim_buf_set_extmark()|:
  - Will show up in both |sign-place| and |nvim_buf_get_extmarks()|.
  - Are displayed by increasing sign identifier, left to right.
    Extmark signs used to be ordered decreasingly as opposed to legacy signs.
2023-11-17 15:10:15 +01:00
Gregory Anders
b4b7ca2d54
feat(tui): support DCS responses in TermResponse event (#26061) 2023-11-16 11:12:42 -06:00
Justin M. Keyes
b73a829837
refactor: vim.ui.clipboard #26040
Problem:
Platform-specific UI providers should live in `vim.ui.*`. #24164

Solution:
- Move `vim.clipboard.osc52` module to `vim.ui.clipboard.osc52`.
- TODO: move all of `clipboard.vim` to `vim.ui.clipboard`.

ref #25872
2023-11-14 05:15:45 -08:00
bfredl
1b0fd377ab
Merge pull request #25767 from luukvbaal/signdel
feat(extmarks): add 'invalidate' property
2023-11-08 12:17:25 +01:00
Luuk van Baal
4e6f559b8c feat(extmarks): add 'invalidate' property to extmarks
Problem:  No way to have extmarks automatically removed when the range it
          is attached to is deleted.
Solution: Add new 'invalidate' property that will hide a mark when the
          entirety of its range is deleted. When "undo_restore" is set
          to false, delete the mark from the buffer instead.
2023-11-08 02:53:49 +01:00
Gregory Anders
56627ca242
feat(tui): use TermResponse event for OSC responses (#25868)
When the terminal emulator sends an OSC sequence to Nvim (as a response
to another OSC sequence that was first sent by Nvim), populate the OSC
sequence in the v:termresponse variable and fire the TermResponse event.
The escape sequence is also included in the "data" field of the
autocommand callback when the autocommand is defined in Lua.

This makes use of the already documented but unimplemented TermResponse
event. This event exists in Vim but is only fired when Vim receives a
primary device attributes response.

Fixes: https://github.com/neovim/neovim/issues/25856
2023-11-06 12:42:40 -06:00
dundargoc
2dc9ceb99c
docs: small fixes (#25585)
Co-authored-by: tmummert <doczook@gmx.de>
Co-authored-by: parikshit adhikari <parikshitadhikari@gmail.com>
2023-10-29 16:02:32 +08:00