Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neovim/init: add autocommand & autogroup APIs #656

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

NotAShelf
Copy link
Owner

@NotAShelf NotAShelf commented Feb 20, 2025

Adds vim.augroups and vim.autocmds as Nix-native APIs for defining autocommands and autogroups in Nix. The implementation is a bit hacky, and relies on Lua instead of Nix for resolving auto{cmd,group} tables but should work as intended. Basic testing yields no errors, but I'll know for sure after I convert all of my autocommands to the new format.

github-actions bot pushed a commit that referenced this pull request Feb 20, 2025
Copy link

github-actions bot commented Feb 20, 2025

🚀 Live preview deployed from b248b5a

View it here:

Debug Information

Triggered by: NotAShelf

HEAD at: neovim-basics

Reruns: 304

horriblename
horriblename previously approved these changes Feb 20, 2025
github-actions bot pushed a commit that referenced this pull request Feb 22, 2025
@NotAShelf NotAShelf changed the title neovim/init: add more neovim-native APIs neovim/init: add autocommand & autogroup APIs Feb 22, 2025
@NotAShelf NotAShelf marked this pull request as ready for review February 22, 2025 17:40
callback = mkOption {
type = nullOr luaInline;
default = null;
example = ''
Copy link
Collaborator

Choose a reason for hiding this comment

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

perhaps add the lib.generators.mkLuaInline part?

Copy link
Collaborator

Choose a reason for hiding this comment

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

or make it a string and use apply to auto luaInline it

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm pretty sure null is converted to Lua correctly, and luaInline contains appropriate type-checking for non-null cases. Does this really need changing? I can't think of an edge case not caught by the current type.


assertions = [
{
assertion = builtins.all (cmd: !(cmd.command != null && cmd.callback != null)) cfg.autocmds;
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it required to have exactly one of them? if so, please use an xor

if not, I'd prefer cmd.command == null || cmd.callback == null but this is more a style nitpick

Copy link
Owner Author

Choose a reason for hiding this comment

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

Technically you can have an autocommand without either, but it doesn't make sense to.

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