bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#67463: 30.0.50; Eglot may manage js-json-mode buffers with wrong ser


From: Pengji Zhang
Subject: bug#67463: 30.0.50; Eglot may manage js-json-mode buffers with wrong server
Date: Wed, 6 Dec 2023 20:32:39 -0500

Hi João,

On Sun, Dec 3, 2023 at 3:51 PM João Távora <joaotavora@gmail.com> wrote:
>
> Nope this doesn't work.  Even the slightly more involved patch after
> my sig  doesn't work, and it correctly reports the :languageId as "json"
>
> So I think the best courses of action are 3 and 4, in that order.
>

I also think option 3 could be the best. JSON is indeed a subset of
JavaScript but that does not mean valid JSON files are also valid
JavaScript files. For instance, a bare object literal '{"a": 10}' is
not accepted by perhaps all JavaScript runtimes because it is parsed
as a block of statements. That is also why we get those invalid errors
in the example.

> Another workaround is to first start M-x eglot in some json file
> in your project.  If you have one of:
>
> . ,(eglot-alternatives '(("vscode-json-language-server" "--stdio")
>                          ("vscode-json-languageserver" "--stdio")
>                          ("json-languageserver" "--stdio"))))
>
> installed, then these json-specific servers should start to manage
> js-json-mode files in your project.  If afterwards you start M-x
> eglot in a plain js file, that server won't be (erroneously) used
> to manage JSON files.
>

Thanks! This workaround indeed works, even though it is a bit tedious
(and I honestly do not quite need a language server for JSON).

Pengji





reply via email to

[Prev in Thread] Current Thread [Next in Thread]