emacs-devel
[Top][All Lists]
Advanced

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

Re: LSP vs Emacs indentation [Was: bug#64784: 30.0.50; Eglot: Lisp error


From: Tassilo Horn
Subject: Re: 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]
Date: Mon, 24 Jul 2023 19:03:30 +0200
User-agent: mu4e 1.11.10; emacs 30.0.50

João Távora <joaotavora@gmail.com> writes:

Hi João,

> If your aim is to make the LSP side "win",

Yes, please!

> I don't think you should use the "trigger character" technique
> specifically.  But in Emacs you can of course bind keys to commands
> that invoke 'eglot-format' synchronously.
>
> Even better, I think the most correct way is to buffer-locally set
> 'indent-line-function' and 'indent-region-function', so you can keep
> the familiar feeling of TAB.

I've now tried this:

  (defun th/eglot-indent-line ()
    (eglot-format (line-beginning-position) (line-end-position)))
  
  (defun th/eglot-format-setup ()
    (setq-local indent-region-function #'eglot-format)
    (setq-local indent-line-function #'th/eglot-indent-line))
  
  (add-hook 'eglot-managed-mode-hook #'th/eglot-format-setup)

Basically, it works, but it seems rust-analyzer doesn't support
formatting of only a range.

  eglot--error: [eglot] Unsupported or ignored LSP capability 
`:documentRangeFormattingProvider'

No big deal, so now I tried just using eglot-format also an
indent-line-function.  But indeed, then I cannot insert newlines
anymore. :-)

I'll try experimenting a bit more at some time.

Bye,
Tassilo



reply via email to

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