LuaLS / LuaLS/lua-language-server
[Feature Request] Setting for case-insensitive require resolution?
まだ誰も着手していません。
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
**Priority**
Low
**Description**
On Windows and Mac, file systems are case-insensitive by default. Lua's filepath resolution is based on the OS, so I feel like while only the exact spelling for a file should be autocompleted, when actually resolving the type of a module, lua-language-server should have an option to be case-insensitive.
**Example**
```
root/
├── myscript.lua
└── mymod.lua
```
```lua
-- myscript.lua --
local myMod = require "myMod"
```
Currently you can write a plugin similar to the one below using `ResolveRequire`
```lua
local libRoot = fs.current_path() / "library"
local function resolveCaseInsensitive(root, moduleName)
for file in fs.pairs(root) do
if fs.is_regular_file(file) then
local fileName = file:filename():string()
if fileName:lower() == (moduleName .. ".lua"):lower() then
return file:string()
end
end
end
end
---@param uri string # The URI of file
---@param name string # Argument of require()
---@return string[]?
function ResolveRequire(uri, name)
local libModuleFile = resolveCaseInsensitive(libRoot, name)
local localModuleFile = resolveCaseInsensitive(fs.path(furi.decode(uri)), name)
local result = {}
if libModuleFile then
result[#result+1] = furi.encode(libModuleFile)
end
if localModuleFile then
result[#result+1] = furi.encode(localModuleFile)
end
if #result ~= 0 then
return result
end
end
```
Alternatively, I propose that a spellchecking diagnostic could be introduced for resolving module names. If a name matches the name of a known module in all except its case, a blue or yellow squiggly would underline the string, and the message could be something like "did you mean 'otherName'". This could be an opt-in diagnostic if it is considered a breaking change.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
既存の ResolveRequire プラグインフックから始めて、require() のモジュール解決パスを追跡します。プロジェクトで大文字と小文字を区別しない設定を実装すべきか、opt-in の診断を実装すべきかを判断し、その後、関連するテストを特定します。Windows と macOS でモジュール名の大文字と小文字が一致しない場合を選択した動作が処理し、テストでカバーされていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100