prettier-plugin-organize-imports: Does not work with pug templates via VS Code Prettier plugin
Now #78 is solved and prettier --write . works… But when I run format on save via VSCode it is the same behavior as before #78 got fixed 🤔
But now I’m not sure if this has something todo with your plugin or if esbenp.prettier-vscode has a bug.
I highly assume it has still something todo with the vueCompilerOptions not forwarded correctly.
/ping @johnsoncodehk
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 27 (14 by maintainers)
Commits related to this issue
- fix: LS host's `getCurrentDirectory` implementation returns project root based on tsconfig location Fixes #84. — committed to simonhaenisch/prettier-plugin-organize-imports by simonhaenisch 2 years ago
- fix: LS host's `getCurrentDirectory` implementation returns project root based on tsconfig location Fixes #84. — committed to simonhaenisch/prettier-plugin-organize-imports by simonhaenisch 2 years ago
Thanks, might be that I can test it first on monday
Update: yeah ok this seems to make it work:
@johnsoncodehk would be nice if you could confirm that it’s a good fix? (I’d only add this to the Vue language service host)
@simonhaenisch Works 🙆
@Shinigami92 finally got around to finish this, should work in
3.2.1🤞Get well soon, I depend on you ^^
Sorry I was sick, will need a bit longer for this one.
Ok then I guess I’ll implement this as a fix and hope it doesn’t backfire 🤞😅 Might take a couple days though.
@johnsoncodehk I get
"/".Edit: hard-coding it to the project’s path fixes it (module not found error gone, and formatting works as expected). I have no idea why the Prettier extension runs
prettierfrom the root directory and not the current VS Code project root 🤷🏻♂️ Maybe it’s a bug that should be raised with the extension… at least this behavior doesn’t make any sense to me.So, it finds the tsconfig and Vue compiler options just fine, however Volar (more specifically,
@volar/vue-language-core, which is used by@volar/vue-typescript, which is is used by this plugin to create the language service) fails to load the pug language plugin:Not sure why this happens, all the paths look kinda ok, and I double-checked that
@volar/vue-language-plugin-pugexists innode_modules🤷🏻♂️ Maybe @johnsoncodehk has an idea…Ok can reproduce, and the first difference I can tell (from logging some stuff into VS Code developer tools) is that when run from the CLI, it runs in the path relative to the project, whereas the VS Code Prettier extension runs the project from the system root (i.e.
process.cwd()gives/) 😳 That might cause an issue with finding the tsconfig but i’ll dig some deeper to narrow it down.