Skip to content

Documentation: Editor integration: Emacs #2902

@FabriceSalvaire

Description

@FabriceSalvaire

Summary

I open this issue to draft an Emacs section in https://docs.astral.sh/ty/editors

Support

Setup

Add this snippet in init.el

;; load flycheck, eglot, and flycheck-eglot packages
;;   or use Flymake package
;;   see package doc

(use-package flycheck
  :ensure t

  :init
  (global-flycheck-mode)
  ;; A minor mode to show Flycheck error messages in a popup.
  (flycheck-pos-tip-mode)
)

;; A minor-mode for Flycheck which colors the mode line according to the Flycheck state of the current buffer.
;;   https://github.com/flycheck/flycheck-color-mode-line
(use-package flycheck-color-mode-line
  :after (flycheck)
  :hook (flycheck-mode . flycheck-color-mode-line-mode)
  )

(use-package eglot
  :ensure t

  :commands eglot
  ;; auto start eglot for those modes
  :hook ((python-mode python-ts-mode) . eglot-ensure)
  :custom
  (eglot-autoshutdown t)
  )

;; Customize eglot-server-programs to use ty as lsp
(with-eval-after-load 'eglot
  (add-to-list 'eglot-server-programs
               `((python-mode python-ts-mode) . ("ty" "server"))))

;; Flycheck support for eglot
;;   https://github.com/intramurz/flycheck-eglot
(use-package flycheck-eglot
  :ensure t
  :after (flycheck eglot)
  :config
  (global-flycheck-eglot-mode 1)
  )

Eglot Inlay Hints

Eglot Inlay Hints mode show implicit kwargs in the buffer.

Use M-x eglot-inlay-hints-mode to toggle inlay hints mode which are quite annoying (buggy) while editing code !!!

inlay hints are displayed using the three faces eglot-type-hint-face, eglot-parameter-hint-face, and eglot-inlay-hint-face, which all inherit from eglot-inlay-hint-face.

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationeditor

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions