Skip to content

Semantic Token Highlighting #83

@0x57e11a

Description

@0x57e11a

many language servers have support for semantic tokens, giving each token some information on what it actually refers to, which can be styled

this would be a very helpful feature for teal development, as the most common lua extension does include semantic tokens

example

given:

local function do_work(worker, arg)
	worker(arg) -- worker and arg are `parameter`
end

local test = { -- test is `variable.declaration`
	x = 1,
	y = 2,
	thing = function(x, y)
		return x + y
	end,
}

local worker = function(arg) -- worker is `function.declaration`
	return arg.thing(arg.x, arg.y) -- arg is `parameter`, .thing is `method`, and .x and .y are `property`
end

do_work(worker, test) -- do_work and worker are `function`, test is `variable`

local other = do_work -- it knows that do_work is `function`, and thus other is `function.declaration`

saved as lua (viewed with sumneko.lua):
Image

saved as tl (viewed with pdesaulniers.vscode-teal):
Image

...however, this is nontrivial, especially given the ways the vscode-teal currently operates, wrapping tl, it'd require either direct integration with the base language tl.tl (via some sort of --dump-semantics flag), or a re-implementation of type inference in the language server (a la rust-analyzer reimplementing rustc behaviors for LSP purposes)

either way this is not a small task, so it's entirely understandable if people don't wish to put the time into it ^v^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions