Skip to content

api: highlight update for neovim-0-12 and neovim-nightly - #312

Open
Alexdelia wants to merge 11 commits into
noib3:mainfrom
Alexdelia:feat/nvim-0.12/highlight
Open

api: highlight update for neovim-0-12 and neovim-nightly#312
Alexdelia wants to merge 11 commits into
noib3:mainfrom
Alexdelia:feat/nvim-0.12/highlight

Conversation

@Alexdelia

@Alexdelia Alexdelia commented Jun 6, 2026

Copy link
Copy Markdown

solve #311

implement:

  • SetHighlightOpts for neovim-0-12 & neovim-nightly
  • HighlightCterm for neovim-0-12 & neovim-nightly

also organize & add more test related to highlight


first time contributing to this repo, I did not see any guideline, but I ran:

cargo fmt
cargo clippy --features neovim-0-11
cargo clippy --features neovim-0-12
cargo clippy --features neovim-nightly

cargo clippy -p nvim-oxi-api --no-default-features --features neovim-0-11
cargo clippy -p nvim-oxi-api --no-default-features --features neovim-0-12
cargo clippy -p nvim-oxi-api --no-default-features --features neovim-nightly
# with nvim 0.12.2
cargo test -p tests --no-default-features --features neovim-0-12 highlight::
# with nvim 0.11.7
cargo test -p tests --no-default-features --features neovim-0-11 highlight::
# with nvim 0.13.0-nightly
cargo test -p tests --no-default-features --features neovim-nightly highlight::

I also tested my fork with my plugin vity.nvim and my nixos/home-manager config https://github.com/Alexdelia/nixconf

@Alexdelia

Copy link
Copy Markdown
Author

my dumb ass didn't check if a PR was already open with this fix

and there is one: #303

sorry about the duplicate

@Alexdelia Alexdelia closed this Jun 6, 2026
@Alexdelia

Copy link
Copy Markdown
Author

re-open as #303 is not complete

will give it a shot at completing it on this PR

@Alexdelia Alexdelia reopened this Jun 6, 2026
@Alexdelia Alexdelia changed the title feat: implement SetHighlightOpts struct for neovim-0-12 Draft: feat: implement SetHighlightOpts struct for neovim-0-12 Jun 6, 2026
@Alexdelia Alexdelia changed the title Draft: feat: implement SetHighlightOpts struct for neovim-0-12 feat: implement SetHighlightOpts struct for neovim-0-12 Jun 6, 2026
@Alexdelia
Alexdelia marked this pull request as draft June 6, 2026 09:33
@Alexdelia Alexdelia changed the title feat: implement SetHighlightOpts struct for neovim-0-12 api: implement SetHighlightOpts struct for neovim-0-12 Jun 6, 2026
@Alexdelia Alexdelia changed the title api: implement SetHighlightOpts struct for neovim-0-12 api: highlight update for neovim-0-12 and neovim-nightly Jun 6, 2026
@Alexdelia
Alexdelia force-pushed the feat/nvim-0.12/highlight branch from dd2d1a5 to 22802f8 Compare June 6, 2026 10:04
@c-c-k

c-c-k commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Thank you for taking over this issue, I've been putting off finishing my own PR for two months now because I've become obsessed with the idea of using nvim-oxi through an mlua entry point to solve the NVIM crushing on nvim-oxi panics and errors, sorry.

@c-c-k

c-c-k commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

@Alexdelia hello, could you please merge the pr/312/Alexdelia/api-highlight-update-for-neovim-0-12-and-neovim-nightly/amend from my fork into your PR.

What it does:

add version feature comments

Adds comments like // Only on 0.11 after each version feature gate.

Rationale: Most of the codebase contains these comments so it would be appropriate to add them here too.

compact neovim-nightly only feature gate to the font field

Removes the separate SetHighlightOpts feature gated struct for neovim-nightly and adds a feature gated font field to the neovim-0-12 struct instead.

Rationale: The C-API change for the SetHighlightOpts struct between NVIM v0.11 and NVIM v0.12 is almost complete so it seems clearer and cleaner to create separate version feature gated structs for each of them.
However, the change between NVIM v0.12 and NVIM v0.13 amounts only to the single font field so I think it would be better to set the feature gate only on the single field.

set HighlightCterm->Dictionary as HighlightCterm->Object->Dictionary

Adds a ToObject implementation for HighlightCterm that uses serde and then changes impl From<HighlightCterm> for Dictionary to convert HighlightCterm to Object and then the Object to a Dictionary.

Rationale: I'm not entirely sure about this one, it would be nice to have @noib3's opinion but I think that the performance drop won't be significant and it would make future maintenance easier.

add OptsBuilder for HighlightCterm

Adds the OptsBuilder derive for HighlightCterm and adjusts the hl_cterm test to use the builder instead of creating HighlightCterm as a Dictionary.

Rationale: I think this better falls in line with the general builder pattern used for creating option arguments.

@Alexdelia

Alexdelia commented Jun 15, 2026

Copy link
Copy Markdown
Author

@Alexdelia hello, could you please merge the pr/312/Alexdelia/api-highlight-update-for-neovim-0-12-and-neovim-nightly/amend from my fork into your PR.

@c-c-k thank you very much for the contribution, the code is much better now


I agree with the

c.to_object().unwrap().into_dictionary_unchecked()

this makes the code much easier to understand and maintain

It does add an extra unsafe keyword & .unwrap() to the repo tho


I've added your commits to the PR and tested everything just as before

no visible regression on my nvim plugin and nvim config

@c-c-k

c-c-k commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

It does add an extra unsafe keyword & .unwrap() to the repo tho

Sorry I was focused on copying builder/serde/conversion logic and didn't think things through, try to replace:

unsafe {
    c.to_object()
        .expect("HighlightCterm.to_object() failed")
        .into_dictionary_unchecked()
}

with:

Self::try_from(
    c.to_object().expect("HighlightCterm.to_object() failed"),
)
.expect("Dictionary::try_from(HighlightCterm.to_object()) failed")

@Alexdelia

Copy link
Copy Markdown
Author

thanks, fixed in bc3838f

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.

2 participants