Skip to content
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

Request to add feature setting match file type by using regex. #10765

Closed
1 task done
hoangnx30 opened this issue Apr 19, 2024 · 9 comments
Closed
1 task done

Request to add feature setting match file type by using regex. #10765

hoangnx30 opened this issue Apr 19, 2024 · 9 comments
Labels
editor Feedback for code editing, formatting, editor iterations, etc enhancement [core label] good first issue Issue suitable for first-time contributors setting Feedback for preferences, configuration, etc

Comments

@hoangnx30
Copy link

Check for existing issues

  • Completed

Describe the feature

Currently, I saw file_types only matches word by word. Can team support to match by regex?

"file_types": {
    "Dockerfile": [
      "Dockerfile",
      "Dockerfile.dev",
      "Dockerfile.prod",
      "Dockerfile.uat"
    ]
  }

------> It worked.

"file_types": {
    "Dockerfile": [
      "Dockerfile",
      "Dockerfile.*",
    ]
  }

-----> it didn't work

If applicable, add mockups / screenshots to help present your vision of the feature

No response

@hoangnx30 hoangnx30 added admin read Pending admin review enhancement [core label] triage Maintainer needs to classify the issue labels Apr 19, 2024
@osiewicz
Copy link
Contributor

osiewicz commented Apr 19, 2024

I think a better alternative would be to support matching via globs, not regexes; https://docs.rs/glob/latest/glob/ It's less powerful than a regex, but it should suffice for your use case.

@JosephTLyons JosephTLyons added editor Feedback for code editing, formatting, editor iterations, etc setting Feedback for preferences, configuration, etc good first issue Issue suitable for first-time contributors and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Apr 19, 2024
@guibes
Copy link

guibes commented Apr 20, 2024

Nice, anyone can help me, will be my first issue, I can try fix it.

@osiewicz
Copy link
Contributor

osiewicz commented Apr 22, 2024

Sure! For starters, this function does path filtering:

user_file_types: Option<&HashMap<Arc<str>, Vec<String>>>,

user_file_types is a deserialized content of file_types, e.g. for the example provided in original post:

"file_types": {
    "Dockerfile": [
      "Dockerfile",
      "Dockerfile.dev",
      "Dockerfile.prod",
      "Dockerfile.uat"
    ]
  }

user_file_types is gonna be Some({"Dockerfile": [ "Dockerfile", "Dockerfile.dev", "Dockerfile.prod", "Dockerfile.uat" ]}).

It then follows that all you have to do is change the code within the call to any to use globs instead:

.any(|suffix| path_suffixes.contains(&Some(suffix.as_str())));

@guibes
Copy link

guibes commented Apr 25, 2024

I opened this PR #10960. I'm a newcomer, so please if someone can review and give me a feedback.

@nathansbradshaw
Copy link

nathansbradshaw commented May 2, 2024

I believe the issue I am running into with my angular LSP is similar to this one. From what I gather, the Angular LSP should only be applied to HTML files that have a component prefix to the suffix IE app.component.html I made a branch that fixed this issue, but reading here it looks like it's not the desired solution. However, pulling down PR #10960 I am not seeing how I can get the LSP to recognize angular files.

Edit: After looking into this some more, I see that this only effects language overrides in the config, so it's not exactly what I am looking for in regard to my language server issues.

@farayolaj
Copy link
Contributor

I made PR #12043 to work on this. I picked up the work from where @guibes stopped, taking note of the reviews from @osiewicz.

osiewicz pushed a commit that referenced this issue May 20, 2024
Release Notes:

- Added glob support for file_types configuration
([#10765](#10765)).

`file_types` can now be written like this:

```json
"file_types": {
  "Dockerfile": [
    "Dockerfile",
    "Dockerfile.*",
  ]
}
```
@osiewicz
Copy link
Contributor

This is gonna land in next Preview on Wednesday, 22.05. Thanks for getting this across the line @farayolaj :)

@JosephTLyons
Copy link
Contributor

This is now available in v0.136.0-pre.

@znycheporuk
Copy link
Contributor

is it possible to show docker image near file that is considered dockerfile?
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor Feedback for code editing, formatting, editor iterations, etc enhancement [core label] good first issue Issue suitable for first-time contributors setting Feedback for preferences, configuration, etc
Projects
None yet
Development

No branches or pull requests

7 participants