efm-langserver
efm-langserver copied to clipboard
htmlbeautifier as format-command for erb filetypes
I'll try to explain this as best I can, and I'm not sure if this is an issue with CoC, efm-langserver or htmlbeautifier.
First off, in case it's not obvious from the above this is using:
efm-langserver 0.0.26 (rev: HEAD/go1.15.6) coc.nvim 0.0.80 using node 15.4.0 htmlbeautifier 1.3.1 nvim 0.4.4 ruby 2.7.2
coc-settings.json
{
"coc.preferences.formatOnSaveFiletypes": [
"css",
"typescript",
"javascript",
"json",
"jsonc",
"jsx",
"html",
"yaml",
"graphql",
"less",
"scss",
"markdown",
"mdx",
"eruby"
],
"solargraph.useBundler": true,
"languageserver": {
"efm": {
"command": "/Users/mattkern/golang/bin/efm-langserver",
"filetypes": ["eruby"],
"args": []
}
},
"cSpell.enabledLanguageIds": [
"git-commit",
"html",
"latex",
"markdown",
"plaintext",
"text"
]
}
~/.config/efm-langserver/config.yaml
version: 2
root-markers:
- .git/
log-file: /Users/mattkern/tmp/output.log
log-level: 1
tools:
eruby-erb: &eruby-erb
lint-command: "erb -x -T - | ruby -c"
lint-stdin: true
lint-offset: 1
format-command: htmlbeautifier
languages:
eruby:
- <<: *eruby-erb
I can see from the efm-langserver logs that the format is successful on writing an eruby filetype.
2020/12/29 13:10:32 htmlbeautifier /Users/mattkern/projects/liquidysplit/liquidysplit-web/app/views/orders/new.html.erb:
2020/12/29 13:10:32 format succeeded
But when that happens I get:
WARNING: The file has been changed since reading it!!!
Do you really want to write to it (y/n)?
If I say no the buffer goes blank and I see a W12 warning:
W12: Warning: File "x.erb" has changed and the buffer was changed in Vim as well.
See ":help W12" for more info.
[O]k, (L)oad File:
L will load the file with the formatting applied properly. So it's clear that the file is being written to outside of vim.
But if I choose O the file is saved as the empty buffer, overwriting the changes as an empty file. Very not ideal.
Of course, if I carefully choose the path through the options the formatting works. But this doesn't happen with any of the other format on write formatters I use, and it can't be the expected behavior.
What's wrong?
do you have swap files enabled in vim?
I don't, no.
Hi @lightcap, did you manage to get it works? I am facing the same problem with neovim + efm + htmlbeautifier.
Manage to figure out the solution, I think we need the format-stdin = true as mentioned here
return {
lintCommand = "erb -x -T - | ruby -c",
lintStdin = true,
lintOffset = 1,
formatCommand = "htmlbeautifier",
formatStdin = true,
lintIgnoreExitCode = true,
lintDebounce = "2s",
}
@marcushwz I wasn't. No, I gave up.