NiklasPor / prettier-plugin-go-template

Fixes prettier formatting for go templates 🐹

Home Page:prettier-plugin-go-template-niklaspor.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vscode - Couldn't resolve parser "go-template"

ajboni opened this issue · comments

Hello, when I try to format a document I get this error:

["ERROR" - 2:29:42 PM] Error formatting document.
["ERROR" - 2:29:42 PM] Couldn't resolve parser "go-template"
Error: Couldn't resolve parser "go-template"
	at resolveParser$1 (c:\Users\user\.vscode\extensions\esbenp.prettier-vscode-8.0.1\node_modules\prettier\index.js:13626:13)
	at normalize$1 (c:\Users\user\.vscode\extensions\esbenp.prettier-vscode-8.0.1\node_modules\prettier\index.js:13721:18)
	at formatWithCursor$1 (c:\Users\user\.vscode\extensions\esbenp.prettier-vscode-8.0.1\node_modules\prettier\index.js:15404:46)
	at c:\Users\user\.vscode\extensions\esbenp.prettier-vscode-8.0.1\node_modules\prettier\index.js:60171:12
	at Object.format (c:\Users\user\.vscode\extensions\esbenp.prettier-vscode-8.0.1\node_modules\prettier\index.js:60191:12)
	at t.default.<anonymous> (c:\Users\user\.vscode\extensions\esbenp.prettier-vscode-8.0.1\dist\extension.js:1:14555)
	at Generator.next (<anonymous>)
	at i (c:\Users\user\.vscode\extensions\esbenp.prettier-vscode-8.0.1\dist\extension.js:1:7003)
["INFO" - 2:29:42 PM] Formatting completed in 14.9331ms.

I've installed dependencies globally

npm list -g --depth=0                                                                                                                                                                            

+-- npm@6.14.13 
+-- prettier@2.3.2
 `-- prettier-plugin-go-template@0.0.12-beta.1  

Any ideas?

What I found is that prettier and this plugin need to be installed in the same "node_modules". How this will work for vscode I am not sure.

Yes, prettier & prettier-plugin-go-template should be installed in the same node_modules. Prettier only searches inside the same folder for plugins.

The best solution is to install both via npm i inside your repository. VSCode Prettier will automatically default to the local version.

My project was not a node project. Tried to use the global approach without luck. However just initializing an empty project and adding dependencies locally as stated in README fixed the issue.