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

VS Code ignores dprint.json and stops formatting with dprint version 0.16.1 on Mac #84

Open
schreter opened this issue May 7, 2024 · 4 comments

Comments

@schreter
Copy link

schreter commented May 7, 2024

Version 0.16.0 works just fine with VS Code on Mac and formats documents.

Version 0.16.1 stopped working. Initialization of the plugin fails with "No configuration file found" printed to the output. The configuration dprint.json in the workspace exists, of course.

Seems like the fix #80 broke it, that's the only one referenced in release notes between 0.16.0 and 0.16.1.

I only tested on newest VS Code 1.89.0 on MacOS.

Downgrading to 0.16.0 restores format-on-save via dprint.

@dsherret
Copy link
Member

dsherret commented May 7, 2024

@schreter do you have a repo I could try it out on? If not, what does the setup look like? It's been working for me.

@schreter
Copy link
Author

schreter commented May 8, 2024

do you have a repo I could try it out on?

Sorry, it's a private repo (and quite large). dprint on the command line works just fine (well, it's also independent :-)).

It's been working for me.

Are you also on MacOS w/ newest VS Code? It could be an OS-related problem.

@schreter
Copy link
Author

schreter commented May 8, 2024

If not, what does the setup look like?

Ah, sorry, missed this one. Here some more details:

  • we use dprint 0.45.1
  • the config is under workspace root in dprint.json

dprint.json:

{
  "incremental": true,
  "markdown": {
    "lineWidth": 100,
    "textWrap": "always",
    "unorderedListKind": "asterisks"
  },
  "toml": {
  },
  "includes": ["**/*.{md,toml}"],
  "excludes": ["external/**"],
  "plugins": [
    "https://plugins.dprint.dev/markdown-0.17.0.wasm",
    "https://plugins.dprint.dev/toml-0.6.1.wasm"
  ]
}

VS Code will not even load dprint extension (with version 0.16.1) due to supposedly missing config file. Trying to format md file will tell me there is no formatter available.

The VS Code is configured w.r.t. dprint like this:

    "[markdown]": {
        "editor.defaultFormatter": "dprint.dprint",
        "editor.formatOnSave": true
    },
    "[toml]": {
        "editor.defaultFormatter": "dprint.dprint",
        "editor.formatOnSave": true
    }

BTW, I also tried to minimize dprint.json to check whether some contents there is causing an issue, but to no avail.

@schreter
Copy link
Author

schreter commented May 8, 2024

I did some digging into dprint-vscode changes. I now see the issue.

The config file is there in the workspace, but it is hidden from the Explorer view by

    "files.exclude": {
        ...
        "dprint.json": true,
        ...
    }

It seems like in VS Code the function fs.existsSync doesn't "see" the file if it's hidden. The question is what to do about it (except removing the exclude).

We did hide quite a few files in workspace directory, since it's polluted by a lot of stuff which various tools require to have in the root of the workspace.

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