rktjmp / lush.nvim

Create Neovim themes with real-time feedback, export anywhere.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestions for handling of linting of the "globals" for each of the highlight groups?

megalithic opened this issue · comments

I love this project with lush.nvim. Thank you!

My question/issue is mostly around how we might handle all of the "globals" that end up being "undefined" for each of the highlight groups that are defined.

I realize this question is out of scope of this project, I'm more just curious how you, and/or contributors/users of this project and lush.nvim might be handling this.

Thanks!

I am not sure we really can do much.

Packer does some similar stuff to Lush, in terms of setting up a DSL environment, they let you inject a use function so the linter/lsp can see something.

Note that if you get linter complaints about use being an undefined global, these errors are spurious - packer injects use into the scope of the function passed to startup. If these errors bother you, the easiest fix is to simply specify use as an argument to the function you pass to startup, e.g.

packer.startup(function(use)
...your config...
end)

Not sure how appropriate that would be in Lush, you would end up with something like spec.Normal { ... }, but I already have some vague ideas for injection for other things #36 which are theoretically more useful than just avoiding linter errors.

It would be great if you could just hint sumneko/etc to ignore certain things via a comment, like how you can tell it that vim is a global but I've never gotten around to looking into it.

Personally I just ignore the warnings or disable the LSP/Linter which isn't a great solution...

https://github.com/sumneko/lua-language-server/wiki/EmmyLua-Annotations#diagnostic

This is listed on the sumneko wiki, but also listed under EmmyLua, so probably works in both, at least theoretically. When I try them they don't work.

It does make me wonder if :Lushify can maybe inject known globals into the LSP somehow when it runs.

Actually seems that I just had to update sumneko, so this should work:

---@diagnostic disable: undefined-global
local theme = lush(function() ...

Fixed 71adf07 rktjmp/lush-template@d0aded2 if you're using the latest sumneko server and probably emmylua.