diff --git a/dot_config/emacs/init.el b/dot_config/emacs/init.el index d622b90..01231e8 100644 --- a/dot_config/emacs/init.el +++ b/dot_config/emacs/init.el @@ -103,7 +103,7 @@ ;; Initial mode (setq initial-major-mode 'fundamental-mode) - ;;; Vertico + ;; Vertico ;; Add prompt to `completing-read-multiple' (defun crm-indicator (args) (cons (format "[CRM%s] %s" @@ -123,7 +123,7 @@ (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) :bind (:map global-map - ;; Disable suspend-frame shortcut + ;; Disable `suspend-frame' shortcut ("C-z" . nil) ;; Escape behaves like C-g ("" . keyboard-escape-quit) @@ -133,7 +133,7 @@ ("S-C-" . shrink-window) ("S-C-" . enlarge-window)) :config - ;;; General Options + ;; General Options ;; Better scrolling (setq scroll-step 1 scroll-conservatively 1000 @@ -177,13 +177,29 @@ (use-package eglot :ensure nil - :hook (zig-mode . eglot-ensure) :bind (:map eglot-mode-map ("C-c c a" . eglot-code-actions) ("C-c c o" . eglot-code-actions-organize-imports) ("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 :ensure nil @@ -262,7 +278,7 @@ (save-place-mode)) (use-package seq - ;; Unload seq before elpaca build + ;; Unload `seq' before elpaca starts building :ensure `(seq :build ,(+elpaca-seq-build-steps))) (use-package simple @@ -488,15 +504,14 @@ (global-corfu-mode) (corfu-popupinfo-mode) :custom - (corfu-min-width 60) - (corfu-max-width corfu-min-width) + ;;(corfu-min-width 60) + ;;(corfu-max-width corfu-min-width) (corfu-auto t) - (corfu-auto-delay 0.3) + ;;(corfu-auto-delay 0.3) (corfu-cycle t) - (corfu-popupinfo-delay 0.6) + ;;(corfu-popupinfo-delay 0.6) (corfu-separator ?\s)) - (use-package kind-icon :after (corfu) :config (push #'kind-icon-margin-formatter corfu-margin-formatters) @@ -504,6 +519,9 @@ (kind-icon-default-face 'corfu-default) (kind-icon-blend-background nil)) +;; File manager +(use-package dir-treeview) + ;; Git (use-package transient) (use-package magit @@ -558,7 +576,7 @@ :defer 3 :config (apheleia-global-mode)) -(use-package reformatter ; required for zig fmt +(use-package reformatter ; required for `zig fmt' :after (zig-mode)) ;; Templates @@ -600,9 +618,12 @@ ;; Syntax parsing/highlighting (use-package treesit-auto - :defer 3 - :config (global-treesit-auto-mode) - :custom (treesit-auto-install 'prompt)) + :defer 1 + :config + (treesit-auto-add-to-auto-mode-alist 'all) + (global-treesit-auto-mode) + :custom + (treesit-auto-install 'prompt)) ;; Syntax checking (use-package flycheck @@ -613,6 +634,10 @@ :after (consult flycheck)) ;; LSP +(use-package consult-eglot + :after (consult eglot)) + +;; Use `emacs-lsp-booster' with `eglot' (use-package eglot-booster :ensure (eglot-booster :host github :repo "jdtsmith/eglot-booster") :after eglot @@ -620,30 +645,20 @@ (use-package lsp-mode :hook - (((c-ts-mode - c++-ts-mode - csharp-ts-mode - go-ts-mode - python-ts-mode) . lsp) - ;; zig-mode) . lsp) - (lsp-mode . lsp-enable-which-key-integration)) + ((;; c-ts-mode + ;; c++-ts-mode + csharp-ts-mode + go-ts-mode + python-ts-mode) . lsp) + ;; zig-mode) . lsp) + (lsp-mode . lsp-enable-which-key-integration) :custom (lsp-use-plists t) - (lsp-idle-delay 0.6) (lsp-prefer-flymake nil) (lsp-session-file (concat xdg_cache_home "lsp-session"))) (use-package lsp-ui - :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)) + :hook (lsp-mode . lsp-ui-mode)) (use-package consult-lsp :after (consult lsp-mode) @@ -655,7 +670,7 @@ :after (lsp-mode treemacs) :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) "Try to parse bytecode instead of json." (or @@ -674,10 +689,10 @@ (defun lsp-booster--advice-final-command (old-fn cmd &optional test?) "Prepend emacs-lsp-booster command to lsp CMD." (let ((orig-result (funcall old-fn cmd test?))) - (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 + (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 lsp-use-plists - (not (functionp 'json-rpc-connection)) ;; native json-rpc + (not (functionp 'json-rpc-connection)) ; native json-rpc (executable-find "emacs-lsp-booster")) (progn (message "Using emacs-lsp-booster for %s!" orig-result) @@ -722,6 +737,10 @@ (use-package realgud-lldb :defer t) +;; C++ +(use-package modern-cpp-font-lock + :hook (c++-mode . modern-c++-font-lock-mode)) + ;; Go (use-package go-mode :hook (go-ts-mode . go-mode) @@ -761,7 +780,8 @@ (when (bound-and-true-p conda-project-env-path) (conda-env-activate-for-buffer))))) -;; Web templates +;; Web +(define-derived-mode astro-mode web-mode "astro") (use-package web-mode :custom (web-mode-attribute-indent-offset 2) @@ -772,10 +792,8 @@ (web-mode-engines-alist '(("blade" . "\\.blade\\.") ("razor" . "\\.cshtml\\'"))) :mode - ((("\\.astro\\'" - "\\.cshtml\\'" - "\\.html?\\'" - "\\.razor\\'") . web-mode))) + ("\\.astro\\'" . astro-mode) + ("\\.\\(cshtml\\|html?\\|razor\\)\\'" . web-mode)) ;; Zig (use-package zig-mode