-
-
Notifications
You must be signed in to change notification settings - Fork 384
feat: support per library ignoreDir when library path prefix matched #3225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8178c9b
to
6a5b559
Compare
我认为应该支持使用 "${lib:idx}"和${workspaceFolder:name}
Issues-translate-bot
commented
Jul 7, 2025
Sumneko Lua translate bot
I think the use of "${lib:idx}" and ${workspaceFolder:name} should be supported
我认为应该支持使用
"${lib:idx}"
${lib:idx}
這個不好吧 🤔
因為這個受 workspace.library[]
中對應 entry 的次序影響
- 如果 user 在 array 中間插值 => 那後續的 index 就亂套了
- 並且完全不直觀,比如當看到
ignoreDir: [ "${lib:2}/xxx/yyy" ]
=> 一眼看過去看不出lib:2
是哪1個 library path
=> 還得手動數一下workspace.library[]
中對應的 element 是什麼? 😂
... 和
${workspaceFolder:name}
確實是個好想法 👍
- 這個 placeholder 應該會在
files.normalize()
時
由裡邊的m.resolvePathPlaceholders
負責處理了的
lua-language-server/script/files.lua
Lines 984 to 989 in 32fec3c
---@param path string---@return stringfunction m.normalize(path)path = m.resolvePathPlaceholders(path)path = util.expandPath(path)path = path:gsub('^%.[/\\]+', '') - 但問題是這 PR 中處理 per library ignoreDir 的方式
是因為m.getLibraryMatchers
本身就有為 每1個 library 創建1個 matcher
=> 我按 library path 對應的 matcher 來寫入不同的 ignore patterns - 而對於 workspace root 自身的 path matcher 來說
我暫不確定他的運作機制是如何 😕
我看到m.getNativeMatcher
最終只會返回 1個 matcher?
不確定可以怎樣支持到 🙈
如果有必要支持 multi root workspace 中針對不同 workspaceFolder
的 ignoreDir
感覺應該再開個新 PR 較好?
Issues-translate-bot
commented
Jul 7, 2025
Sumneko Lua translate bot
I think the use of `"${lib:idx}" should be supported
${lib:idx}
This is not good 🤔
Because this is affected by the order of the corresponding entry in workspace.library[]
- If user interpolates => in the middle of array, then the subsequent index will be messed up
- And it is completely unintuitive, for example when you see
ignoreDir: [ "${lib:2}/xxx/yyy" ]
=> I can't see which library pathlib:2
is
=> You have to manually count what is the corresponding element inworkspace.library[]
? 😂
... and
${workspaceFolder:name}
It's a good idea indeed
- This placeholder should be in
files.normalize()
Them.resolvePathPlaceholders
is handled by
lua-language-server/script/files.lua
Lines 984 to 989 in 32fec3c
---@param path string---@return stringfunction m.normalize(path)path = m.resolvePathPlaceholders(path)path = util.expandPath(path)path = path:gsub('^%.[/\\]+', '') - But the problem is how to deal with per library ignoreDir in this PR
Becausem.getLibraryMatchers
itself has a chance Create 1 matcher for every library
=> I press the matcher corresponding to library path to write different ignore patterns - And for the workspace root's own path matcher
I'm not sure how it works 😕
I see thatm.getNativeMatcher
will only return 1 matcher in the end?
Not sure how to support it 🙈
If necessary, support ignoreDir for different workspaceFolder
in multi root workspace
I feel like it should be better to open a new PR?
This adds support for per library setting in
ignoreDir
as requested in #3213.Use case
Ignore a same named folder in the library path, but not in current workspace.
For more details please refer to the discussion link above.
Proposed Solution
After in-depth discussion, we come up with the following approach with NO change to existing API while maintaining backward compatibility:
ignoreDir
path is a subpath of any library path/
Example Config
中文版
支持
workspace.ignoreDir
配置 只應用在指定 library 的 pattern修改方式
ignoreDir
,檢查是否屬於任意 library 的 subpath/
以換成1個 absolute 的 gitignore pattern