LuaLS / LuaLS/lua-language-server

How do I annotate an imported global?

Open
#2,498 2 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 have the following use case. There's a library that defines a global vim.g as table<string, any>. In my application code, I want to utilise only the "autoformat" key of that table, i.e. vim.g.autoformat. I want to enforce this key as a boolean? but the language server marks it as any.

Is there any way I could achieve this?

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

No source file, test, or entry point is named. Start by reproducing the vim.g.autoformat annotation case described in the issue and trace how the language server types imported globals and table fields. Done should be a confirmed supported approach, with coverage or documentation showing how to enforce autoformat as boolean?.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.