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

I was looking for a pattern that contains ".mint" files, such as "source/**/*.mint", Got "...." when running mint format. #549

Open
zw963 opened this issue Jul 3, 2022 · 2 comments

Comments

@zw963
Copy link

zw963 commented Jul 3, 2022

I am try to fixing format buffer feature use mint format in the emacs-mint-mode issue.

After some debug, i get following error message instead.

Mint - Formatting files[
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
I was looking for a pattern that contains ".mint" files,
such as "source/**/*.mint". Got "/home/common/Study/Mint/test_formatter/source/Main.mint" instead.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
All done in 3.502ms!

It wired, because, because sure i can run command successful in my konsole.

 ╭─ 21:07  zw963 ⮀ ~/Study/Mint/test_formatter ⮀ ⭠ (30f376c) master *%  ➦ ruby-3.1.0 
 ╰─ $ mint format  /home/common/Study/Mint/test_formatter/source/Main.mint
Mint - Formatting files
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Formatted: /home/common/Study/Mint/test_formatter/source/Main.mint
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
All done in 314μs!
 ╰─ $ 1  pwd
/home/zw963/Study/Mint/test_formatter

The above issue will happen if current PWD directory is not the project root

 ╰─ $ cd ~

 ╭─ 21:10  zw963 ⮀ ~ ⮀ ➦ ruby-3.1.0  0 
 ╰─ $ mint format  /home/common/Study/Mint/test_formatter/source/Main.mint
Mint - Formatting files
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
I was looking for a pattern that contains ".mint" files,
such as "source/**/*.mint". Got "/home/common/Study/Mint/test_formatter/source/Main.mint" instead.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
All done in 3.554ms!

In this case, mint format never format file.

So, the really issue is, we need a way to told formatter, where is the project root.

Following is some solution:

  1. like crystal tool format, i can run any file outside project root.
  2. mint format provided a command line option for specify the path of mint.json, then, when formatter do format,
    can pass this argument, for my case, format can do like this:
    mint format --config /home/common/Study/Mint/test_formatter/ /home/common/Study/Mint/test_formatter/source/Main.mint
  3. Or support set a environment variable, where project root is, mint format can read it.
@zw963
Copy link
Author

zw963 commented Jul 3, 2022

I workaround this issue in this PR with:

  1. locate the project root with mint.json
  2. goto project root, set this directory as default directory.
  3. run code here.

@zw963
Copy link
Author

zw963 commented Oct 28, 2022

Hi, i get a similiar issue when try to add mint-lang support to apheleia

As you can see, i added support for Crystal is in recent days, it quite easy, check this pr, and, it support almost all languages for now, even, nix.

But, when i try to add mint support for it, i get same(type) error as this.

Sat Oct 29 02:16:33 2022 :: /home/zw963/Crystal/play/mint-realworld-rework/source/
$ mint format --stdin

Unhandled exception: Error opening file with mode 'r': '/home/zw963/Crystal/play/mint-realworld-rework/source/mint.json': No such file or directory (File::NotFoundError)
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???

Command failed with exit code 1.

Yes, the checker could not found the mint.json in the same folder of the opened file buffer, most other language format checker can handle this, but, always limit by this when i try to add auto save formatter for mint.

Thanks.

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

No branches or pull requests

1 participant