Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
tomlau10 wants to merge1 commit intoLuaLS:master
base:master
Choose a base branch
Loading
fromtomlau10:poc/per-library-ignoreDir

Conversation

@tomlau10
Copy link
Contributor

This adds support forper library setting inignoreDir 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 withNO change to existing API while maintaining backward compatibility:

  • check if anignoreDir path is asubpath of any library path
  • if it is a subpath of a library path
    • extract this subpath (which is a relative path to that library path)
    • convert it toabsolute gitignore pattern by adding a leading/
    • keep it aslibrary specific ignore pattern
  • otherwise treat it as global ignore pattern as before

Example Config

{"workspace.library": ["/path/to/lib","/path/to/lib2" ],"workspace.ignoreDir": ["/path/to/lib/**/lib-ignore",// extracted pattern will be "/**/lib-ignore" and only applies to "/path/to/lib""global-ignore"// this will still apply to all of "/path/to/lib", "/path/to/lib2", current workspace  ]}

中文版

支持workspace.ignoreDir 配置只應用在指定 library 的 pattern

修改方式

  • 對於每1個ignoreDir,檢查是否屬於任意 library 的subpath
  • 假設是該 library 下的 subpath
    • 先提取出這個 subpath (就是該 library 下的 1個 relative path)
    • 在最開首補上/ 以換成1個 absolute 的 gitignore pattern
    • 並添加到這 library 下的 ignore pattern matcher
  • 否則如常當成 global ignore pattern 來添加

@tomlau10tomlau10force-pushed thepoc/per-library-ignoreDir branch from8178c9b to6a5b559CompareJuly 6, 2025 10:20
@CppCXY
Copy link
Member

我认为应该支持使用 "${lib:idx}"和${workspaceFolder:name}

@Issues-translate-bot

Sumneko Lua translate bot


I think the use of "${lib:idx}" and ${workspaceFolder:name} should be supported

@tomlau10
Copy link
ContributorAuthor

我认为应该支持使用"${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 負責處理了的
    ---@parampathstring
    ---@returnstring
    functionm.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

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 inworkspace.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 seeignoreDir: [ "${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 infiles.normalize()
    Them.resolvePathPlaceholders is handled by
    ---@parampathstring
    ---@returnstring
    functionm.normalize(path)
    path=m.resolvePathPlaceholders(path)
    path=util.expandPath(path)
    path=path:gsub('^%.[/\\]+','')
  • But the problem is how to deal withper library ignoreDir in this PR
    Becausem.getLibraryMatchers itself has a chanceCreate 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 differentworkspaceFolder in multi root workspace
I feel like it should be better to open a new PR?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@tomlau10@CppCXY@Issues-translate-bot

[8]ページ先頭

©2009-2025 Movatter.jp