Eglot experiment cont., corfu settings, define astro-mode under web-mode

This commit is contained in:
Andrew Scott 2024-06-11 07:33:21 -04:00
parent cdc898f7e4
commit c147bec036
Signed by: a
GPG key ID: 7CD5A5977E4931C1

View file

@ -103,7 +103,7 @@
;; Initial mode ;; Initial mode
(setq initial-major-mode 'fundamental-mode) (setq initial-major-mode 'fundamental-mode)
;;; Vertico ;; Vertico
;; Add prompt to `completing-read-multiple' ;; Add prompt to `completing-read-multiple'
(defun crm-indicator (args) (defun crm-indicator (args)
(cons (format "[CRM%s] %s" (cons (format "[CRM%s] %s"
@ -123,7 +123,7 @@
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
:bind :bind
(:map global-map (:map global-map
;; Disable suspend-frame shortcut ;; Disable `suspend-frame' shortcut
("C-z" . nil) ("C-z" . nil)
;; Escape behaves like C-g ;; Escape behaves like C-g
("<escape>" . keyboard-escape-quit) ("<escape>" . keyboard-escape-quit)
@ -133,7 +133,7 @@
("S-C-<down>" . shrink-window) ("S-C-<down>" . shrink-window)
("S-C-<up>" . enlarge-window)) ("S-C-<up>" . enlarge-window))
:config :config
;;; General Options ;; General Options
;; Better scrolling ;; Better scrolling
(setq scroll-step 1 (setq scroll-step 1
scroll-conservatively 1000 scroll-conservatively 1000
@ -177,13 +177,29 @@
(use-package eglot (use-package eglot
:ensure nil :ensure nil
:hook (zig-mode . eglot-ensure)
:bind (:map :bind (:map
eglot-mode-map eglot-mode-map
("C-c c a" . eglot-code-actions) ("C-c c a" . eglot-code-actions)
("C-c c o" . eglot-code-actions-organize-imports) ("C-c c o" . eglot-code-actions-organize-imports)
("C-c c r" . eglot-rename) ("C-c c r" . eglot-rename)
("C-c c f" . eglot-format))) ("C-c c f" . eglot-format))
:config
(push '(astro-mode . ("astro-ls" "--stdio"
:initializationOptions
(:typescript (:tsdk "/usr/lib/node_modules/typescript/lib")))) eglot-server-programs)
(setq eglot-autoshutdown t
eglot-ignored-server-capabilities
'(:colorProvider ; "Decorate color references"
:documentFormattingProvider ; "Format buffer"
:documentHighlightProvider ; "Highlight symbols automatically"
:documentOnTypeFormattingProvider ; "On-type formatting"
:documentRangeFormattingProvider ; "Format portion of buffer"
:hoverProvider ; "Documentation on hover"
))
:hook ((astro-mode
c-ts-mode
c++-mode
zig-mode) . eglot-ensure))
(use-package elec-pair (use-package elec-pair
:ensure nil :ensure nil
@ -262,7 +278,7 @@
(save-place-mode)) (save-place-mode))
(use-package seq (use-package seq
;; Unload seq before elpaca build ;; Unload `seq' before elpaca starts building
:ensure `(seq :build ,(+elpaca-seq-build-steps))) :ensure `(seq :build ,(+elpaca-seq-build-steps)))
(use-package simple (use-package simple
@ -488,15 +504,14 @@
(global-corfu-mode) (global-corfu-mode)
(corfu-popupinfo-mode) (corfu-popupinfo-mode)
:custom :custom
(corfu-min-width 60) ;;(corfu-min-width 60)
(corfu-max-width corfu-min-width) ;;(corfu-max-width corfu-min-width)
(corfu-auto t) (corfu-auto t)
(corfu-auto-delay 0.3) ;;(corfu-auto-delay 0.3)
(corfu-cycle t) (corfu-cycle t)
(corfu-popupinfo-delay 0.6) ;;(corfu-popupinfo-delay 0.6)
(corfu-separator ?\s)) (corfu-separator ?\s))
(use-package kind-icon (use-package kind-icon
:after (corfu) :after (corfu)
:config (push #'kind-icon-margin-formatter corfu-margin-formatters) :config (push #'kind-icon-margin-formatter corfu-margin-formatters)
@ -504,6 +519,9 @@
(kind-icon-default-face 'corfu-default) (kind-icon-default-face 'corfu-default)
(kind-icon-blend-background nil)) (kind-icon-blend-background nil))
;; File manager
(use-package dir-treeview)
;; Git ;; Git
(use-package transient) (use-package transient)
(use-package magit (use-package magit
@ -558,7 +576,7 @@
:defer 3 :defer 3
:config (apheleia-global-mode)) :config (apheleia-global-mode))
(use-package reformatter ; required for zig fmt (use-package reformatter ; required for `zig fmt'
:after (zig-mode)) :after (zig-mode))
;; Templates ;; Templates
@ -600,9 +618,12 @@
;; Syntax parsing/highlighting ;; Syntax parsing/highlighting
(use-package treesit-auto (use-package treesit-auto
:defer 3 :defer 1
:config (global-treesit-auto-mode) :config
:custom (treesit-auto-install 'prompt)) (treesit-auto-add-to-auto-mode-alist 'all)
(global-treesit-auto-mode)
:custom
(treesit-auto-install 'prompt))
;; Syntax checking ;; Syntax checking
(use-package flycheck (use-package flycheck
@ -613,6 +634,10 @@
:after (consult flycheck)) :after (consult flycheck))
;; LSP ;; LSP
(use-package consult-eglot
:after (consult eglot))
;; Use `emacs-lsp-booster' with `eglot'
(use-package eglot-booster (use-package eglot-booster
:ensure (eglot-booster :host github :repo "jdtsmith/eglot-booster") :ensure (eglot-booster :host github :repo "jdtsmith/eglot-booster")
:after eglot :after eglot
@ -620,30 +645,20 @@
(use-package lsp-mode (use-package lsp-mode
:hook :hook
(((c-ts-mode ((;; c-ts-mode
c++-ts-mode ;; c++-ts-mode
csharp-ts-mode csharp-ts-mode
go-ts-mode go-ts-mode
python-ts-mode) . lsp) python-ts-mode) . lsp)
;; zig-mode) . lsp) ;; zig-mode) . lsp)
(lsp-mode . lsp-enable-which-key-integration)) (lsp-mode . lsp-enable-which-key-integration)
:custom :custom
(lsp-use-plists t) (lsp-use-plists t)
(lsp-idle-delay 0.6)
(lsp-prefer-flymake nil) (lsp-prefer-flymake nil)
(lsp-session-file (concat xdg_cache_home "lsp-session"))) (lsp-session-file (concat xdg_cache_home "lsp-session")))
(use-package lsp-ui (use-package lsp-ui
:hook (lsp-mode . lsp-ui-mode) :hook (lsp-mode . lsp-ui-mode))
:custom
(lsp-ui-doc-position 'bottom-and-right)
(lsp-ui-flycheck-enable t)
(lsp-ui-flycheck-list-position 'right)
(lsp-ui-peek-enable t)
(lsp-ui-sideline-delay 0.6)
(lsp-ui-sideline-show-code-actions t)
(lsp-ui-sideline-show-hover nil)
(lsp-ui-sideline-update-mode 'line))
(use-package consult-lsp (use-package consult-lsp
:after (consult lsp-mode) :after (consult lsp-mode)
@ -655,7 +670,7 @@
:after (lsp-mode treemacs) :after (lsp-mode treemacs)
:config (lsp-treemacs-sync-mode)) :config (lsp-treemacs-sync-mode))
;; Configure emacs-lsp-booster for lsp-mode ;; Configure `emacs-lsp-booster' for `lsp-mode'
(defun lsp-booster--advice-json-parse (old-fn &rest args) (defun lsp-booster--advice-json-parse (old-fn &rest args)
"Try to parse bytecode instead of json." "Try to parse bytecode instead of json."
(or (or
@ -674,10 +689,10 @@
(defun lsp-booster--advice-final-command (old-fn cmd &optional test?) (defun lsp-booster--advice-final-command (old-fn cmd &optional test?)
"Prepend emacs-lsp-booster command to lsp CMD." "Prepend emacs-lsp-booster command to lsp CMD."
(let ((orig-result (funcall old-fn cmd test?))) (let ((orig-result (funcall old-fn cmd test?)))
(if (and (not test?) ;; for check lsp-server-present? (if (and (not test?) ; for check lsp-server-present?
(not (file-remote-p default-directory)) ;; see lsp-resolve-final-command, it would add extra shell wrapper (not (file-remote-p default-directory)) ; see lsp-resolve-final-command, it would add extra shell wrapper
lsp-use-plists lsp-use-plists
(not (functionp 'json-rpc-connection)) ;; native json-rpc (not (functionp 'json-rpc-connection)) ; native json-rpc
(executable-find "emacs-lsp-booster")) (executable-find "emacs-lsp-booster"))
(progn (progn
(message "Using emacs-lsp-booster for %s!" orig-result) (message "Using emacs-lsp-booster for %s!" orig-result)
@ -722,6 +737,10 @@
(use-package realgud-lldb (use-package realgud-lldb
:defer t) :defer t)
;; C++
(use-package modern-cpp-font-lock
:hook (c++-mode . modern-c++-font-lock-mode))
;; Go ;; Go
(use-package go-mode (use-package go-mode
:hook (go-ts-mode . go-mode) :hook (go-ts-mode . go-mode)
@ -761,7 +780,8 @@
(when (bound-and-true-p conda-project-env-path) (when (bound-and-true-p conda-project-env-path)
(conda-env-activate-for-buffer))))) (conda-env-activate-for-buffer)))))
;; Web templates ;; Web
(define-derived-mode astro-mode web-mode "astro")
(use-package web-mode (use-package web-mode
:custom :custom
(web-mode-attribute-indent-offset 2) (web-mode-attribute-indent-offset 2)
@ -772,10 +792,8 @@
(web-mode-engines-alist '(("blade" . "\\.blade\\.") (web-mode-engines-alist '(("blade" . "\\.blade\\.")
("razor" . "\\.cshtml\\'"))) ("razor" . "\\.cshtml\\'")))
:mode :mode
((("\\.astro\\'" ("\\.astro\\'" . astro-mode)
"\\.cshtml\\'" ("\\.\\(cshtml\\|html?\\|razor\\)\\'" . web-mode))
"\\.html?\\'"
"\\.razor\\'") . web-mode)))
;; Zig ;; Zig
(use-package zig-mode (use-package zig-mode