LuaLS / LuaLS/lua-language-server

How to override a meta file definition?

Open
#2,540 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

I am using a 3rd party library for neovim runtime (neodev) which defines types for the global variables. There's a table which it generally annotates as:

```lua
---@meta

---@type table>
vim.b = {}
```

Is there way I can override this definition in my project scope as shown below?

```lua
---@meta

---@type table
vim.b = {}
```

The problem that I have currently is that the LSP infers `vim.b[0].autoformat` as `any` because the definitions annotate it as `any|boolean`.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the example with neodev's global vim.b definition and the project-level @meta declaration shown in the issue. Start by tracing how LuaLS resolves competing @meta and @type declarations, then determine what supported override behavior would mean; the issue is complete when the behavior is implemented or clearly documented with a focused validation case.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.