coc-prettier
coc-prettier copied to clipboard
Formatting output is not as expected
So I am trying to use this addon and I did a test to compare how it looks in VScode vs vim. Now maybe VScode is wrong but thought I would ask. So I typed the following:
if(1===1){
When I hit enter it was formatted to
if(1===1) {
}
If I do the same example in VScode I get
if (1 === 1) {
}
Notice how it added the space around the triple equal and between the if and (?
Here is my .prettierrc
{
"bracketSpacing": true,
"singleQuote": true,
"trailingComma": "es5"
}
My project does have an .editorconfig
You need check https://github.com/neoclide/coc.nvim/wiki/Debug-language-server#using-output-channel to make sure it's not formatted by other plugin like coc-tsserver
Hmmm, so it seems like now its not even formatting for me. This is my coc-settings
{
"suggest.enablePreview": true,
"codeLens.enable": true,
"git.addedSign.text": "┃",
"git.removedSign.text": "┃",
"git.changedSign.text": "┃",
"git.changeRemovedSign.text": "┃",
"suggest.maxPreviewWidth": 100,
"diagnostic.checkCurrentLine": true,
"diagnostic.maxWindowHeight": 20,
"diagnostic.errorSign": "✖",
"diagnostic.warningSign": "⚠",
"diagnostic.infoSign": "●",
"diagnostic.hintSign": "○",
"coc.preferences.currentFunctionSymbolAutoUpdate": true,
"git.addGlameToBufferVar": true,
"prettier.requireConfig": true,
"emmet.includeLanguages": {
"html.handlebars": "html",
"javascript": "javascriptreact"
},
"coc.preferences.formatOnType": true,
"tailwindCSS.htmlLanguages": [
"blade",
"edge",
"eelixir",
"ejs",
"elixir",
"erb",
"eruby",
"haml",
"handlebars",
"html",
"HTML (EEx)",
"HTML (Eex)",
"html.twig",
"html.handlebars",
"jade",
"leaf",
"markdown",
"njk",
"nunjucks",
"php",
"razor",
"slim",
"svelte",
"twig",
"vue"
]
}
If I highlight the text and run formatter it formats it correctly. So maybe on type is not supported?
@chemzqm if I do echo coc#status()
it says Prettier TSC
. Is that correct?
I wonder if format on type is using something different then when I grab a selection and format it
command! -nargs=0 Prettier :CocCommand prettier.formatFile
nmap <leader>f :CocCommand prettier.formatFile<cr>
vmap <leader>f <Plug>(coc-format-selected)
I wonder if format on type is using something different then when I grab a selection and format it
command! -nargs=0 Prettier :CocCommand prettier.formatFile nmap <leader>f :CocCommand prettier.formatFile<cr> vmap <leader>f <Plug>(coc-format-selected)
Possibly related to https://github.com/neoclide/coc-prettier/issues/37? I am running into an issue where a different formater is used for a section vs format all (for json). According to that issue, the problem is fixed on master.