LuaLS / LuaLS/lua-language-server

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

オープン
#3,388 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Lua
スター
4.4k
フォーク
442
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

.vscode/luals/library/foo.d.lua、baz.lua、および workspace.userThirdParty 設定を使って例を再現します。まず、@source パスがどのように解決され、VS Code の変数がどのように展開されるかを追跡し、次に相対パスの動作と変数置換を、期待される Go to Definition の移動先と照合して確認します。変更されない場合は、選択したパスの相対性を記録します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
lua, vscode
領域
devtools
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。