Switched from lsp-mode/flycheck to eglot/flymake

This commit is contained in:
Random936
2025-08-17 11:42:50 -07:00
parent 527f231455
commit 1e79e78465

View File

@@ -1,47 +1,16 @@
* LSP Mode
* Eglot
Lsp Mode is a package that adds language server functionalities to Emacs.
** Breadcrumb Header Line
This adds a headerline that shows the scope of where the cursor is in the code. For example if the user is in the main function, the headerline will contain main.
** Keybindings
#+begin_src elisp
(defun jm/lsp-mode-setup ()
(setq lsp-headerline-breadcrumb-segments '(path-up-to-project file symbols))
(lsp-headerline-breadcrumb-mode))
#+end_src
** Install Lsp Mode
Below I am installing the actual package and adding some basic configuration.
#+begin_src elisp
(use-package lsp-mode
:init (setq lsp-keymap-prefix "C-c l") ; Lsp mode prefix
:hook (lsp-mode . jm/lsp-mode-setup)
:commands (lsp lsp-deferred) ; Startup commands
:config
(lsp-enable-which-key-integration t)
(setq lsp-enable-snippet nil))
#+end_src
** Lsp Additional Packages
#+begin_src elisp
(use-package lsp-ui
:hook (lsp-mode . lsp-ui-mode)
:config
(setq lsp-ui-sideline-enable t
lsp-ui-show-diagnostics t
lsp-ui-doc-enable t))
#+end_src
** Flycheck
#+begin_src elisp
(use-package flycheck
:init (global-flycheck-mode))
(use-package eglot
:bind (:map eglot-mode-map
("C-c l a" . eglot-code-actions)
("C-c l r" . eglot-rename)
("C-c l h" . eldoc)
("C-c l f" . eglot-format)
("C-c l F" . eglot-format-buffer)
("C-c l R" . eglot-reconnect)))
#+end_src
** Direnv for Nix-Shell Integration
@@ -64,7 +33,7 @@ This will include any language server packages and configuration.
(use-package web-mode
:defer t
:mode ("\\.html\\'" "\\.svelte\\'")
:hook (web-mode . lsp-deferred)
:hook (web-mode . eglot-ensure)
:init
(setq web-mode-engines-alist '(("svelte" . "\\.svelte\\'"))))
#+end_src
@@ -75,7 +44,7 @@ This will include any language server packages and configuration.
(use-package typescript-mode
:defer t
:mode ("\\.ts\\'" "\\.js\\'")
:hook (typescript-mode . lsp-deferred))
:hook (typescript-mode . eglot-ensure))
#+end_src
Install the ~typescript-language-server~ through npm.
@@ -90,7 +59,7 @@ Install the ~typescript-language-server~ through npm.
(use-package python-mode
:defer t
:mode ("\\.py\\'")
:hook (python-mode . lsp-deferred))
:hook (python-mode . eglot-ensure))
#+end_src
Install the ~python-lsp-server~ though pip.
@@ -121,7 +90,7 @@ Install ~ccls~ with homebrew using the following command.
#+begin_src elisp
(use-package go-mode
:defer t
:hook (go-mode . lsp-deferred))
:hook (go-mode . eglot-ensure))
#+end_src
** Rust
@@ -129,7 +98,7 @@ Install ~ccls~ with homebrew using the following command.
#+begin_src elisp
(use-package rustic
:defer t
:hook (rust-mode . lsp-deferred)
:hook (rust-mode . eglot-ensure)
:init
(let ((brew-prefix (string-trim (shell-command-to-string "brew --prefix"))))
(when (and (memq window-system '(mac ns x)) brew-prefix (f-directory-p brew-prefix))
@@ -142,7 +111,7 @@ Install ~ccls~ with homebrew using the following command.
#+begin_src elisp
(use-package csharp-mode
:defer t
:hook (csharp-mode . lsp-deferred))
:hook (csharp-mode . eglot-ensure))
#+end_src
** JSON
@@ -150,7 +119,7 @@ Install ~ccls~ with homebrew using the following command.
#+begin_src elisp
(use-package json-mode
:defer t
:hook (json-mode . lsp-deferred))
:hook (json-mode . eglot-ensure))
#+end_src
** Yaml
@@ -158,7 +127,7 @@ Install ~ccls~ with homebrew using the following command.
#+begin_src elisp
(use-package yaml-mode
:defer t
:hook (yaml-mode . lsp-deferred))
:hook (yaml-mode . eglot-ensure))
#+end_src
** Yara
@@ -168,7 +137,7 @@ To install the corresponding LSP, you need to install ~yls~. Using the command ~
#+begin_src elisp
(use-package yara-mode
:defer t
:hook (yara-mode . lsp-deferred)
:hook (yara-mode . eglot-ensure)
:config
(with-eval-after-load 'lsp-mode
(add-to-list 'lsp-language-id-configuration
@@ -185,7 +154,7 @@ To install the corresponding LSP, you need to install ~yls~. Using the command ~
#+begin_src elisp
(use-package ess
:defer t
:hook (R-mode . lsp-deferred))
:hook (R-mode . eglot-ensure))
#+end_src
** Haskell
@@ -193,11 +162,11 @@ To install the corresponding LSP, you need to install ~yls~. Using the command ~
#+begin_src elisp
(use-package haskell-mode
:defer t
:hook (haskell-mode . lsp-deferred))
:hook (haskell-mode . eglot-ensure))
(use-package lsp-haskell
:defer t
:hook (lsp-literate-mode . lsp-deferred))
:hook (lsp-literate-mode . eglot-ensure))
#+end_src
** Ebuild
@@ -212,7 +181,7 @@ sudo emerge -v app-emacs/ebuild-mode
(use-package ebuild-mode
:ensure nil
:defer t
:hook (ebuild-mode . lsp-deferred))
:hook (ebuild-mode . eglot-ensure))
#+end_src
** Nix
@@ -228,6 +197,6 @@ Nix is the language used by NixOS and the Nix package manager.
(use-package nix-mode
:mode "\\.nix\\'"
:hook (nix-mode . lsp-deferred))
:hook (nix-mode . eglot-ensure))
#+end_src