LuaLS / LuaLS/lua-language-server

VS Code variable resolution in @source annotations/relativity of paths

Abierto
#3,388 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Lua
Estrellas
4.4k
Forks
442
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Linux

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour

Intuitively, I expected:

  1. ---@source annotations in meta files with relative paths to be resolved relative to the workspace
  2. VS Code variables in the @source path to be resolved when resolving a path
Actual Behaviour
  1. @source paths are resolved relative to the meta file itself
  2. VS Code variables in the path are not resolved
Reproduction steps
  1. Create .vscode/luals/library/foo.d.lua with:
    ---@meta
    --- @class foo
    _G.foo = {}
    
    ---@source grault/foo.lua:1
    function bar() end
    
  2. Create baz.lua with:
    require("foo")
    local quux = foo.bar()
    
  3. In extension settings, set:
    {
      "Lua.workspace.userThirdParty": ["${fileWorkspaceFolder}/LuaLS"]
    }
    

[!NOTE]
The variable ${fileWorkspaceFolder} resolves correctly and adds the meta file to the list of search paths

  1. Open baz.lua in VS Code editor
  2. Right click bar
  3. Select Go to Definition
  4. Observe:
    VS Code opens a non-existent source file tab to .vscode/luals/library/grault/foo.lua
Additional Notes

This could be two separate issues, but they're tightly related -- one as a Documentation Issue that the relativity of the resolution of the path should be added to the docs, and two as a Bug/Feature Request that VS Code variables be resolved in the @source paths as they are in the settings

Attempting to work around this using VS Code variables has the variable unresolved and taken literally. For example, setting the @source path to /${fileWorkspaceFolder}/grault/foo.lua:1 causes VS Code to open a tab to that literal string instead of the expected /home/me/my_project/grault/foo.lua:1

Log File

No response

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Reproduce el ejemplo con .vscode/luals/library/foo.d.lua, baz.lua y la configuración workspace.userThirdParty. Empieza trazando cómo se resuelven las rutas @source y cómo se expanden las variables de VS Code; después, verifica el comportamiento de las rutas relativas y la sustitución de variables comparándolos con el destino esperado de Go to Definition. Documenta la relatividad de rutas elegida si permanece sin cambios.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
lua, vscode
Área
devtools
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
55/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.