-
-
Notifications
You must be signed in to change notification settings - Fork 95
Description
Neovim has one of the biggest Lua 5.1 user bases, and I believe that Neovim-specific lint rules that help plugin development would be a good idea.
Other linters like ruff or biome has a framework/library-specific lint rules like Numpy, FastAPI, React, etc.
Example 1
Neovim APIs change over version. For example, according to https://neovim.io/doc/user/news-0.10.html,
vim.tbl_contains() now works for general tables and allows specifying a predicate function that is checked for each value. (Use vim.list_contains() for checking list-like tables (integer keys without gaps) for literal values.)
Example 2
I also remember that when I tried to use vim.fn.system(), the lua-language-server told me I should use vim.system()
--- Note: Prefer |vim.system()| in Lua.So I used that function only to realise that it's new from nvim-0.10 and I broke compatibility for all previous versions of Neovim.
Example 3
Treesitter functions change a lot, for example, https://github.com/nvim-treesitter/nvim-treesitter-context/blob/6daca3ad780f045550b820f262002f35175a6c04/lua/treesitter-context/context.lua#L96-L103
-- max_start_depth depth is only supported in nvim 0.10. It is ignored on
-- versions 0.9 or less. It is only needed to improve performance
for _, match in query:iter_matches(node, bufnr, 0, -1, { max_start_depth = 0 }) do
local r = false
for id, nodes in pairs(match) do
--- In Nvim 0.9 node is a TSNode, in Nvim 0.10+ it is a list of TSNode
--- @type TSNodeIn these few lines, you can read that there are two differences over the nvim version.
Example 4
In Neovim 0.11, the vim.str_byteindex() API has been changed: neovim/neovim#30804
So you can suggest to migrate if the target version is over nvim 0.11.
If you don't use Neovim, you might think there are too many things to address that you don't really know. However, I feel like such lints are easy to implement (write target nvim version and restrict some function calls / suggest other functions etc.) and once some lints are available, more nvim users will use this linter and they will suggest more lints and even help you implement them.