Skip to content

WIP : Rename buffer to buf for autocmds' api (0.12.2) - #307

Open
ide-outils wants to merge 1 commit into
noib3:mainfrom
ide-outils:main
Open

WIP : Rename buffer to buf for autocmds' api (0.12.2)#307
ide-outils wants to merge 1 commit into
noib3:mainfrom
ide-outils:main

Conversation

@ide-outils

Copy link
Copy Markdown

This fixes #306.

Comment thread crates/api/src/opts/clear_autocmds.rs Outdated
@ide-outils ide-outils changed the title Rename buffer to buf for autocmds' api (0.12.2) WIP : Rename buffer to buf for autocmds' api (0.12.2) Apr 23, 2026
@ide-outils

Copy link
Copy Markdown
Author

It does remove the panic but the autocmd is not lauched anymore...

#[cfg(feature = "neovim-0-12")] // On 0.12 and above.
#[builder(argtype = "Buffer", inline = "{0}.0")]
buf: types::BufHandle,
#[cfg(not(feature = "neovim-0-12"))] // On 0.11 and bellow.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.11 is the earliest version we support, there's nothing below it

Suggested change
#[cfg(not(feature = "neovim-0-12"))] // On 0.11 and bellow.
#[cfg(not(feature = "neovim-0-12"))] // Only on 0.11

@c-c-k

c-c-k commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

@ide-outils hello, could you please merge the pr/307/ide-outils/rename-buffer-to-buf-for-autocmds-api-0.12.2/amend from my fork into your PR.

What it does:

deprecate rather than disable buffer for *autocmds on neovim-0-12+

Sets the neovim-0-12 feature gate to deprecate the .buffer field for ClearAutocmdsOpts, CreateAutocmdOpts, ExecAutocmdsOpts and GetAutocmdsOpts instead of disabling it.

Rationale: As discussed in #309, NVIM 0.12.2 added the buf field but to maintain backwards compatibility it did not remove the buffer field only marked it as deprecated.
As such the buffer field must remain in the *Autocmd* structs for neovim-0-12 and neovim-nightly, but it seems appropriate to also mark it a deprecated.

duplicate autocmd tests for buf and buffer

  • Copies tests/autocmd.rs into tests/autocmd_neovim_0_11.rs.
  • Feature gates tests/autocmd_neovim_0_11.rs and tests/autocmd.rs in tests/mod.rs.
  • Renames the buffer field to buf in tests/autocmd.rs.
  • Adds a single set_get_exec_clear_autocmd_buffer test to tests/autocmd.rs.

Rationale: Since the buffer field is considered as deprecated it seems appropriate to switch the tests for neovim-0-12 and neovim-nightly to the new buf field.
Until neovim-0-11 is dropped it's necessary to keep testing for the buffer field too.
It feels cleaner to so in two separate test files with a single feature gate on their import instead of feature gating each of the duplicated tests.
A single test checking that the deprecated buffer field is still working in neovim-0-12 and neovim-nightly seems reasonable.

c-c-k pushed a commit to nvim-oxi-community/nvim-oxi that referenced this pull request Jul 22, 2026
c-c-k pushed a commit to nvim-oxi-community/nvim-oxi that referenced this pull request Jul 22, 2026
c-c-k pushed a commit to nvim-oxi-community/nvim-oxi that referenced this pull request Jul 22, 2026
c-c-k pushed a commit to nvim-oxi-community/nvim-oxi that referenced this pull request Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic Autocmd without Buffer

3 participants