From: Stephen Leake <stephen_leake@stephe-leake.org>
To: Theodor Thornhill via "Emacs development discussions."
<emacs-devel@gnu.org>
Cc: "Tassilo Horn" <tsdh@gnu.org>,
"João Távora" <joaotavora@gmail.com>,
"Theodor Thornhill" <theo@thornhill.no>,
"Eli Zaretskii" <eliz@gnu.org>,
"Stefan Monnier" <monnier@iro.umontreal.ca>
Subject: Re: LSP vs Emacs indentation [
Date: Thu, 27 Jul 2023 14:51:59 -0700 [thread overview]
Message-ID: <864jlpnhts.fsf@stephe-leake.org> (raw)
In-Reply-To: <871qgxxjnz.fsf@thornhill.no> (Theodor Thornhill via's message of "Mon, 24 Jul 2023 20:13:04 +0200")
Theodor Thornhill via "Emacs development discussions."
<emacs-devel@gnu.org> writes:
> Consider (| is the cursor)
>
> ```
> func foo() {|}
> ```
>
> Now if you type RET we'd expect some incantation of
>
> ```
> func foo() {
> |
> }
> ```
>
> to be the expected output, not the cursor at col 0, which is what
> happens now. That means we'd have to do something like
>
>
> Where the 'eglot-newline-and-indent-according-to-mode' has to calculate
> the expected indentation. I don't understand how we'd expect the
> formatters to do that indentation for us. They only care about code
> already written, not code yet to be written. So if we'd have to
> calculate that offset anyway, do we win much?
Your "newline-and-indent" function could insert some bogus code
(probably "bar;" or "bar();") and ask LSP to format that, then delete
the bogus code.
--
-- Stephe
next prev parent reply other threads:[~2023-07-27 21:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87bkg4bkfu.fsf@fastmail.fm>
[not found] ` <83a5voa328.fsf@gnu.org>
[not found] ` <87h6pw9tpa.fsf@gmail.com>
[not found] ` <875y6bm5ut.fsf@fastmail.fm>
2023-07-23 10:20 ` bug#64784: LSP vs Emacs indentation [Was: bug#64784: 30.0.50; Eglot: Lisp error: (wrong-type-argument number-or-marker-p return) in eglot--post-self-insert-hook] João Távora
2023-07-23 15:13 ` Theodor Thornhill
2023-07-23 16:42 ` João Távora
2023-07-24 17:03 ` Tassilo Horn
2023-07-24 18:13 ` Theodor Thornhill via Emacs development discussions.
2023-07-27 21:51 ` Stephen Leake [this message]
2023-07-28 5:28 ` LSP vs Emacs indentation [ Tassilo Horn
2023-07-28 13:29 ` Stefan Monnier
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=864jlpnhts.fsf@stephe-leake.org \
--to=stephen_leake@stephe-leake.org \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=joaotavora@gmail.com \
--cc=monnier@iro.umontreal.ca \
--cc=theo@thornhill.no \
--cc=tsdh@gnu.org \
/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).