LuaLS / LuaLS/lua-language-server

Extending alias functionality [Suggestion]

Open
#3,406 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

Good day, my suggestion is quite unusual - I'm requesting an additional functionality for aliases, basically adding ability to define regexp for string-based aliases. For example I have something like this:

---@alias Identifier string

That makes type check that Identifier is a string, but don't check if identifier need a custom structure, for example if correct structure is something like namespace:path it can't be validated with LLS.

If on another hand I can able to add a regexp to it:

---@alias Identifier string("^[^:]*:[^:]*$")

Then it will automatically check if identifier is valid

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

Start by reviewing the existing alias type-checking behavior and how LuaLS represents string-based types. The requested syntax and regexp semantics need to be defined before implementation. Done should include regexp-constrained aliases such as Identifier being validated against the specified pattern.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.