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: João Távora
Subject: bug#67463: 30.0.50; Eglot may manage js-json-mode buffers with wrong server
Date: Sat, 16 Dec 2023 12:01:57 +0000

On Sat, Dec 16, 2023, 09:30 Eli Zaretskii <eliz@gnu.org> wrote:
> From: Pengji Zhang <kunhtkun@gmail.com>
> Date: Wed, 6 Dec 2023 20:32:39 -0500
> Cc: 67463@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>
>
> 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).

So should we now close this bug?  Or is there something left to do
here?

The problem is not solved and the workaround is tedious. There is something to be fixed, but outside Eglot.

I think the fix should be (3) breaking the inheritance between js-json-mode and js-mode, using instead composition to achieve the same code reuse.  As Pengji noted, JSON is not JS in any practical (or even theoretical) sense.

João

reply via email to

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