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

allow matching by file path #11

Open
adrian-gierakowski opened this issue Nov 2, 2023 · 4 comments
Open

allow matching by file path #11

adrian-gierakowski opened this issue Nov 2, 2023 · 4 comments

Comments

@adrian-gierakowski
Copy link

I am working in a monorepo in which different sub-projects use different formatters for the same file types

I would like to enable formatting on save but don't see how I could make formatting conditional on the files path using sublime selectors

could a new setting be added to enable this? Thanks!

@mitranim
Copy link
Owner

mitranim commented Nov 2, 2023

Hmm. My first question would be: what about anonymous buffers? They don't have paths (view.file_path() is None). They only have scope selectors.

@adrian-gierakowski
Copy link
Author

Anonymous buffer could match only if given formatter didn’t have a path based condition, or if the condition matched an empty string

@mitranim
Copy link
Owner

mitranim commented Nov 2, 2023

Might be useful to get more details about your use case, such as directory structure, files involved, formatters used. We might come up with other solutions too.

@adrian-gierakowski
Copy link
Author

I'm using dprint and prettier for js\ts files and other formatters for other languages.
One of the sub-dirs in the monorepo needs to be formatted with prettier.

I started using https://numtide.github.io/treefmt to dispatch do different formatters, however it needs a file path to be able to select the formatter to use.

So I would need sublime-fmt to provide full path of formatted file when running on save. If formatting a buffer without a path, a dummy file name (with extension) could be provided to let treefmt pick the formatter to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants