Skip to content

Conversation

@zw963
Copy link

@zw963 zw963 commented Jul 1, 2022

#198

Hi, current this PR still not work, when i try to run format-all-buffer in one mint buffer, i get error like this:

Unhandled exception: Error opening file with mode 'r': '/home/common/Study/Mint/test_formatter/source/mint.json': No such file or directory (File::NotFoundError)
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from src/env/__libc_start_main.c:94:2 in 'libc_start_main_stage2'

I am still newbie to both of emacs-format-all-the-code and mint, i don't know why this happen.

But, i can confirm following code can output the correct formatted buffer content:

 ╭─ 20:27  zw963 ⮀ ~/Study/Mint/test_formatter ⮀ ⭠ (30f376c) master  ➦ ruby-3.1.0 
 ╰─ $ cat source/Main.mint |mint format --stdin
component Main {
  style app {
    justify-content: center;
    flex-direction: column;
    align-items: center;
    display: flex;

    background-color: #282C34;
    height: 100vh;
    width: 100vw;

    font-family: Open Sans;
    font-weight: bold;
  }

  fun render : Html {
    <div::app>
      <Logo/>

      <Info mainPath="source/Main.mint"/>

      <Link href="https://www.mint-lang.com/">
        "Learn Mint"
      </Link>
    </div>
  }
}

@zw963
Copy link
Author

zw963 commented Jul 1, 2022

Oops, i get same output issue when try on reformatter, that should not issue about this package, let me do some research.

@zw963
Copy link
Author

zw963 commented Jul 1, 2022

Yes, i can reproduce this:

╭─ 20:38  zw963 ⮀ ~/Study/Mint/test_formatter/source ⮀ ⭠ (30f376c) master *  ➦ ruby-3.1.0 
 ╰─ $ cat Main.mint |mint format --stdin
Unhandled exception: Error opening file with mode 'r': '/home/common/Study/Mint/test_formatter/source/mint.json': No such file or directory (File::NotFoundError)
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from src/env/__libc_start_main.c:94:2 in 'libc_start_main_stage2'

Because current project root folder is: ~/Study/Mint/test_formatter

When i entry ~/Study/Mint/test_formatter/source, and run format code on it, get this error.

So, how to fix it? if consider a upstream issue?

@lassik
Copy link
Owner

lassik commented Jul 1, 2022

Because current project root folder is: ~/Study/Mint/test_formatter

When i entry ~/Study/Mint/test_formatter/source, and run format code on it, get this error.

You probably need to pass --env. Look at how other formatter definitions use format-all--locate-file for examples.

@zw963
Copy link
Author

zw963 commented Jul 1, 2022

You probably need to pass --env. Look at how other formatter definitions use format-all--locate-file for examples.

Don't understand how to use it, what is the environment variable in the .env to specified?

I consider maybe use "mint.json" to locate the project root is better, so, i add like this:

(define-format-all-formatter mint
  (:executable "mint")
  (:install (macos "brew install mint-lang"))
  (:languages "Mint")
  (:features)
  (:format
   (cl-destructuring-bind (output error-output)
       (format-all--buffer-hard nil nil '("mint.json")
                                executable "format" "--stdin")
     (let ((error-output (format-all--remove-ansi-color error-output)))
       (list output error-output)))))

but still not work with same error.

@zw963
Copy link
Author

zw963 commented Jul 3, 2022

Hi, can i know if where an example for set the default-direcotry for current running formatter process?

I can use (file-name-directory (format-all--locate-file "mint.json")) get the project root folder, how to set default directory for the formatter process?

Thank you.

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

Successfully merging this pull request may close these issues.

2 participants