From: "João Távora" <joaotavora@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Pengji Zhang <kunhtkun@gmail.com>, 67463@debbugs.gnu.org
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 [thread overview]
Message-ID: <CALDnm50zUJOu9iBCJyCQRkBLUPcRQp7iy+N4Mo-GHNTM8Zuk1Q@mail.gmail.com> (raw)
In-Reply-To: <834jgio5os.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 2166 bytes --]
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
>
[-- Attachment #2: Type: text/html, Size: 3536 bytes --]
next prev parent reply other threads:[~2023-12-16 12:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-26 21:15 bug#67463: 30.0.50; Eglot may manage js-json-mode buffers with wrong server Pengji Zhang
2023-12-02 12:51 ` Eli Zaretskii
2023-12-03 18:14 ` João Távora
2023-12-03 20:51 ` João Távora
2023-12-07 1:32 ` Pengji Zhang
2023-12-16 9:30 ` Eli Zaretskii
2023-12-16 12:01 ` João Távora [this message]
2024-01-06 16:01 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-06 18:04 ` Dmitry Gutov
2024-01-07 1:57 ` João Távora
2024-01-07 5:20 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-08 0:20 ` João Távora
2024-01-08 3:21 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-15 3:17 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALDnm50zUJOu9iBCJyCQRkBLUPcRQp7iy+N4Mo-GHNTM8Zuk1Q@mail.gmail.com \
--to=joaotavora@gmail.com \
--cc=67463@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=kunhtkun@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).