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

Formatter not working when pyproject.toml not at project root #81

Closed
fabien-michel opened this issue Oct 13, 2022 · 7 comments · Fixed by #82
Closed

Formatter not working when pyproject.toml not at project root #81

fabien-michel opened this issue Oct 13, 2022 · 7 comments · Fixed by #82

Comments

@fabien-michel
Copy link

fabien-michel commented Oct 13, 2022

My project dir structure is like this:

/project
/project/django
/project/django/pyproject.toml
/project/django/app/template/blop.html

The djlint config is inside pyproject.toml :

[tool.djlint]
profile="django"
max_line_length=120
indent=2
blank_line_after_tag="load,extends,include"

The blop.html file language mode is django-html

When running djlint from command line it work as expected:
[/absolute/path/to/project/]$ djlint --reformat django/app/template/blop.html

But when running the formatter from vscode it seems to apply a default configuration (blank_line_after_tag is not respected)

I'v tried to force djlint configuration in vscode config but it still doesn't work:

{
  "djlint.useEditorIndentation": false,
  "djlint.configuration": "/absolute/path/to/project/django/pyproject.toml"
}

The only way I've found so far to have it working is to put pyproject.toml at project root. But it is not a nice solution for me.

Other notes:

  • There is a python venv. Workspace is configured to use it.
  • djlint 1.19.0 is installed inside the venv

Did I miss something ? How to have djlint-vscode respect my pyproject.toml file ?
By the way there is a way to have logs of what djlint-vscode is doing ?

@christopherpickering
Copy link
Contributor

I wonder if this
image

should be the directory of the current file, not the project root?

Right now it is the directory that is opened in VSCode. If it were to use the current file directory it will probably work.

I'm not sure if this is the right vs command, but vscode.window.activeTextEditor.document.uri.fsPath sounds like it would work.

@christopherpickering
Copy link
Contributor

@monosans Easier said than done lol, I found a way that works and uses the pyproject.toml file correctly. I'll put a PR for you.

@monosans
Copy link
Member

Fixed in v2022.10.0. Many thanks to @christopherpickering for the help and quick fix!

@fabien-michel
Copy link
Author

Thanks for he fast fix ! It solve the issue main issue for me without having to specify the configuration file.
Nevertheless, it don't explain why specifying the configuration file make it not used by djlint.

@monosans
Copy link
Member

Nevertheless, it don't explain why specifying the configuration file make it not used by djlint.

AFAIK --configuration doesn't support pyproject.toml, only .djlintrc format.

@christopherpickering
Copy link
Contributor

@monosans thats correct, sorry I didn't notice that @fabien-michel.

@monosans
Copy link
Member

By the way there is a way to have logs of what djlint-vscode is doing ?

The error logs are in Developer Tools (Ctrl+Shift+I or Help > Toggle Developer Tools).

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 a pull request may close this issue.

3 participants