GNU bug report logs -
#67463
30.0.50; Eglot may manage js-json-mode buffers with wrong server
Previous Next
Reported by: Pengji Zhang <kunhtkun <at> gmail.com>
Date: Sun, 26 Nov 2023 21:17:02 UTC
Severity: normal
Found in version 30.0.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
On Sat, Dec 16, 2023, 09:30 Eli Zaretskii <eliz <at> gnu.org> wrote:
> > From: Pengji Zhang <kunhtkun <at> gmail.com>
> > Date: Wed, 6 Dec 2023 20:32:39 -0500
> > Cc: 67463 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
> >
> > Hi João,
> >
> > On Sun, Dec 3, 2023 at 3:51 PM João Távora <joaotavora <at> 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
>
[Message part 2 (text/html, inline)]
This bug report was last modified 1 year and 125 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.