mattn / efm-langserver

General purpose Language Server
MIT License
1.35k stars 61 forks source link

🐞 BUG: Spaces in file path `${INPUT}`, are not handled properly. #165

Closed whyjacker closed 1 year ago

whyjacker commented 3 years ago

With below setting for ESlint, ESlint only receives /tmp/Space in place of ${INPUT}. And double quoting "${INPUT}" in the command, breaks ESlint.

FILE: '/tmp/Space folder/test.js'
lintCommand        = 'eslint_d -f visualstudio --no-color --config config/eslint.cjs --stdin --stdin-filename ${INPUT}'

This works (from cli):

echo "$file_content" | eslint_d -f visualstudio --no-color --config config/eslint.cjs --stdin --stdin-filename "/tmp/Space folder/test.js"

Means, it's not ESlint's fault.

This causes ESlint to show some wrong linting messages, because some linting rules depend on file names.

Suggested fix

I think this should be easy to fix, as EFM only has to quote ${INPUT} properly when passing it to the command.


Using with Neovim LSP. ESlint v7.32.0

EFM: 0.0.36

whyjacker commented 3 years ago

@mattn I think the issue is with format %f(%l,%c): %tarning %m. As %f contains spaces.

Kuresov commented 1 year ago

Loving the plugin, thanks for your work mattn!

Seeing this as well, an example can be reproduced using the Pandoc config from the README. Ex:

config.yaml

version: 2
root-markers:
  - .git/
lint-debounce: 1s

tools:
  markdown-pandoc: &markdown-pandoc
    format-command: 'pandoc -f markdown -t gfm -sp --tab-stop=2'

languages:
  markdown:
    - <<: *markdown-pandoc

Create a file in a directory like "test dir", and open or attempt to save a .md file. Logs:

[START][2023-07-15 20:13:03] LSP logging initiated
[ERROR][2023-07-15 20:13:03] .../vim/lsp/rpc.lua:734    "rpc"   "/home/X/.local/share/nvim/mason/bin/efm-langserver"    "stderr"    "2023/07/15 20:13:03 efm-langserver: reading on stdin, writing on stdout\n"
[ERROR][2023-07-15 20:13:25] .../vim/lsp/rpc.lua:734    "rpc"   "/home/X/.local/share/nvim/mason/bin/efm-langserver"    "stderr"    "2023/07/15 20:13:25 pandoc -f markdown -t gfm -sp --tab-stop=2 /home/X/dev/test dir/test.md: pandoc: /home/X/dev/test: withBinaryFile: does not exist (No such file or directory)\n\n"

We can also change the config's format-command to:

  markdown-pandoc: &markdown-pandoc
    format-command: 'pandoc -f markdown -t gfm -sp --tab-stop=2 "${FILENAME}"'

... However, the original filename is still appended at the end:

[ERROR][2023-07-15 20:15:52] .../vim/lsp/rpc.lua:734    "rpc"   "/home/X/.local/share/nvim/mason/bin/efm-langserver"    "stderr"    '2023/07/15 20:15:52 pandoc -f markdown -t gfm -sp --tab-stop=2 "/home/X/dev/test dir/test.md" /home/X/dev/test dir/test.md: pandoc: /home/X/dev/test: withBinaryFile: does not exist (No such file or directory)\n\n'

Perhaps there's a way to signal that FILENAME is being interpolated and should not be appended? I'd be interested in taking a crack at that--would preventing the filename from being appended when provided with the ${FILENAME} argument be a breaking change for some configurations?

mattn commented 1 year ago

What happend with "${INPUT}" ?

Kuresov commented 1 year ago

Ah hey, my mistake in that pandoc will indeed handle from stdin, so this isn't an issue for this particular case.

  markdown-pandoc: &markdown-pandoc
    format-command: 'pandoc -f markdown -t gfm -sp --tab-stop=2'
    format-stdin: true

When using "${INPUT}" (and not format-stdin: true) the file contents seem to be replaced with nothing, though there's probably some other flag to be set on pandoc. I can see from an unrelated issue that the filename is quoted and passed correctly; sorry for missing that.

Appreciate the help! I think this issue can be closed 👍