This commit is contained in:
2025-10-23 09:14:41 -04:00
parent e0b50d49c0
commit 11be2aa0bb
2 changed files with 142 additions and 68 deletions

View File

@@ -154,9 +154,11 @@
(setq corfu-quit-no-match t)
(setq corfu-preselect 'prompt)
(setq corfu-on-exact-match nil)
(setq corfu-preview-current 'insert)
(setq corfu-auto t)
(setq corfu-auto-prefix 2)
(setq corfu-popupinfo-delay 0.5)
(setq corfu-auto-delay 0)
(setq corfu-popupinfo-delay '(0.5 . 0.2))
(global-corfu-mode)
(corfu-history-mode)
(corfu-popupinfo-mode))
@@ -177,19 +179,14 @@
(add-hook 'completion-at-point-functions #'cape-keyword)
(add-hook 'completion-at-point-functions #'cape-tex))
(use-package tempel
(use-package yasnippet
:ensure t
:custom
(defun tempel-setup-capf ()
(setq-local completion-at-point-functions
(cons #'tempel-expand
completion-at-point-functions)))
(add-hook 'conf-mode-hook 'tempel-setup-capf)
(add-hook 'prog-mode-hook 'tempel-setup-capf)
(add-hook 'text-mode-hook 'tempel-setup-capf))
:config
(yas-global-mode 1))
(use-package tempel-collection
:ensure t)
(use-package yasnippet-snippets
:ensure t
:after yasnippet)
(use-package eldoc
:ensure nil
@@ -202,15 +199,6 @@
:config
(global-flycheck-mode))
(use-package consult-flycheck
:ensure t)
(use-package flycheck-eglot
:ensure t
:after (flycheck eglot)
:config
(global-flycheck-eglot-mode 1))
;; LANGUAGE MODES -------
(use-package treesit-auto
:ensure t
@@ -223,20 +211,107 @@
:mode "\\.nix\\'")
;; LSP ---------
(use-package eglot
(use-package lsp-mode
:ensure t
:defer t
:hook ((nix-ts-mode . eglot-ensure)
(go-ts-mode . eglot-ensure)))
(use-package eglot-booster
:ensure t
:after eglot
:hook ((typescript-ts-mode . lsp)
(tsx-ts-mode . lsp)
(js-ts-mode . lsp)
(css-ts-mode . lsp)
(rust-ts-mode . lsp)
(go-ts-mode . lsp)
(lsp-mode . lsp-enable-which-key-integration))
:commands lsp
:config
(eglot-booster-mode))
;; core
(setq lsp-keymap-prefix "C-c l")
(setq lsp-completion-provider :none)
(setq lsp-log-io nil)
(setq lsp-keep-workspace-alive nil)
(setq lsp-idle-delay 0.5)
(setq lsp-enable-xref t)
(setq lsp-auto-configure t)
(setq lsp-eldoc-enable-hover t)
(setq lsp-enable-dap-auto-configure t)
(setq lsp-enable-file-watchers nil) ;; TODO: check this
(setq lsp-enable-folding nil)
(setq lsp-enable-imenu t)
(setq lsp-enable-indentation t) ;; TODO: check this as well
(setq lsp-enable-links t)
(setq lsp-enable-on-type-formatting t)
(setq lsp-enable-suggest-server-download nil)
(setq lsp-enable-symbol-highlighting t)
(setq lsp-enable-text-document-color nil)
(setq lsp-auto-execute-action nil)
(use-package markdown-mode
:ensure t)
;; sideline
(setq lsp-ui-sideline-show-hover nil)
(setq lsp-ui-sideline-diagnostic-max-lines 20)
;; completion
(setq lsp-completion-enable t)
(setq lsp-completion-enable-additional-text-edit t)
(setq lsp-enable-snippet t)
(setq lsp-completion-show-kind t)
;; headerline
(setq lsp-headerline-breadcrumb-enable t)
(setq lsp-headerline-breadcrumb-icons-enable t)
;; modeline
(setq lsp-modeline-code-actions-enable nil)
(setq lsp-modeline-diagnostics-enable nil)
(setq lsp-modeline-workspace-status-enable nil)
(setq lsp-signature-doc-lines 1)
(setq lsp-ui-doc-use-childframe t)
;; lens
(setq lsp-lens-enable nil)
;; semantic
(setq lsp-semantic-tokens-enable nil)
;; misc
(setq lsp-use-plists nil))
(use-package lsp-ui
:ensure t
:after (lsp-mode evil)
:config (setq lsp-ui-doc-enable t
evil-lookup-func #'lsp-ui-doc-glance
lsp-ui-doc-show-with-cursor nil
lsp-ui-doc-include-signature t
lsp-ui-doc-position 'at-point))
(defun lsp-booster--advice-json-parse (old-fn &rest args)
"Try to parse bytecode instead of json."
(or
(when (equal (following-char) ?#)
(let ((bytecode (read (current-buffer))))
(when (byte-code-function-p bytecode)
(funcall bytecode))))
(apply old-fn args)))
(advice-add (if (progn (require 'json)
(fboundp 'json-parse-buffer))
'json-parse-buffer
'json-read)
:around
#'lsp-booster--advice-json-parse)
(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
lsp-use-plists
(not (functionp 'json-rpc-connection)) ;; native json-rpc
(executable-find "emacs-lsp-booster"))
(progn
(when-let ((command-from-exec-path (executable-find (car orig-result)))) ;; resolve command from exec-path (in case not found in $PATH)
(setcar orig-result command-from-exec-path))
(message "Using emacs-lsp-booster for %s!" orig-result)
(cons "emacs-lsp-booster" orig-result))
orig-result)))
(advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command)
;; TOOLS ---------
(use-package magit
@@ -268,7 +343,7 @@
(ledger-report-auto-width nil)
(ledger-report-links-in-register nil)
(ledger-report-native-highlighting-arguments '("--color=always")))
:mode ("\\.hledger\\'" "\\.ledger\\'"))
:mode ("\\.hledger\\'" "\\.ledger\\'" "\\.journal\\'"))
;; PATH STUFF --------
(use-package exec-path-from-shell
@@ -298,8 +373,7 @@
'((sequence "TODO(t)" "NEXT(n)" "PROG(p)" "INTR(i)" "WAIT(w)" "SOMEDAY(s)" "|" "DONE(d)" "CANCELLED(c)")))
(org-capture-templates
`(("i" "Inbox" entry (file+headline "todo.org" "Inbox")
,(concat "* TODO %?\n"
"%U"))
"* TODO %?")
("j" "Journal" entry (file denote-journal-path-to-new-or-existing-entry)
"* %U %?\n%i\n%a"
:kill-buffer t
@@ -416,11 +490,10 @@
(general-define-key
:states 'normal
"] d" '(next-error :wk "Goto next error")
"[ d" '(previous-error :wk "Goto prev error")
"] d" '(flycheck-next-error :wk "Goto next error")
"[ d" '(flycheck-previous-error :wk "Goto prev error")
"] c" '(diff-hl-next-hunk :wk "Goto next hunk")
"[ c" '(diff-hl-previous-hunk :wk "Goto prev hunk")
"K" '(eldoc :wk "Describe"))
"K" '(evil-lookup :wk "Describe"))
(general-create-definer my-leader-def
:states '(normal insert visual motion emacs)
@@ -439,7 +512,7 @@
(my-leader-def
"c" '(:ignore t :wk "Code")
"c a" '(eglot-code-actions :wk "Code actions"))
"c a" '(lsp-execute-code-action :wk "Code actions"))
(my-leader-def
"h" '(:ignore t :wk "Help")
@@ -474,34 +547,34 @@
(global-diff-hl-mode))
;; LSP Mode
(use-package lsp-mode
:ensure t
:init
(setq lsp-keymap-prefix "C-c l")
(defun my/lsp-mode-setup-completion ()
(setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
'(orderless)))
:hook ((typescript-ts-mode . lsp)
(tsx-ts-mode . lsp)
(js-ts-mode . lsp)
;; if you want which-key integration
(lsp-mode . lsp-enable-which-key-integration)
(lsp-completion-mode . my/lsp-mode-setup-completion))
:commands lsp
:config
(setq lsp-eslint-server-command '("vscode-eslint-language-server" "--stdio"))
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection '("tailwindcss-language-server" "--stdio"))
:activation-fn (lsp-activate-on "typescriptreact" "typescript" "css" "html")
:add-on? t
:notification-handlers (ht ("@/tailwindCSS/projectInitialized" #'ignore)
("@/tailwindCSS/projectsDestroyed" #'ignore)))))
;; (use-package lsp-mode
;; :ensure t
;; :init
;; (setq lsp-keymap-prefix "C-c l")
;; (defun my/lsp-mode-setup-completion ()
;; (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
;; '(orderless)))
;; :hook ((typescript-ts-mode . lsp)
;; (tsx-ts-mode . lsp)
;; (js-ts-mode . lsp)
;; ;; if you want which-key integration
;; (lsp-mode . lsp-enable-which-key-integration)
;; (lsp-completion-mode . my/lsp-mode-setup-completion))
;; :commands lsp
;; :config
;; (setq lsp-eslint-server-command '("vscode-eslint-language-server" "--stdio"))
;; (lsp-register-client
;; (make-lsp-client
;; :new-connection (lsp-stdio-connection '("tailwindcss-language-server" "--stdio"))
;; :activation-fn (lsp-activate-on "typescriptreact" "typescript" "css" "html")
;; :add-on? t
;; :notification-handlers (ht ("@/tailwindCSS/projectInitialized" #'ignore)
;; ("@/tailwindCSS/projectsDestroyed" #'ignore)))))
(use-package lsp-ui
:ensure t
:commands lsp-ui-mode
:config
(setq lsp-ui-sideline-enable nil))
;; (use-package lsp-ui
;; :ensure t
;; :commands lsp-ui-mode
;; :config
;; (setq lsp-ui-sideline-enable nil))
(provide 'init)