From 4b225cf2442c72789b50fcf661da14b1f032b9ee Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Thu, 12 Oct 2023 04:12:53 -0700 Subject: [PATCH] Add a bunch of prog language support stuff --- init.el | 136 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 87 insertions(+), 49 deletions(-) diff --git a/init.el b/init.el index dae3a0d..1ef24d4 100644 --- a/init.el +++ b/init.el @@ -111,7 +111,12 @@ (java "https://github.com/tree-sitter/tree-sitter-java") (python "https://github.com/tree-sitter/tree-sitter-python") (rust "https://github.com/tree-sitter/tree-sitter-rust") - (json "https://github.com/tree-sitter/tree-sitter-json"))) + (json "https://github.com/tree-sitter/tree-sitter-json") + (css "https://github.com/tree-sitter/tree-sitter-css") + (go "https://github.com/tree-sitter/tree-sitter-go") + (js "https://github.com/tree-sitter/tree-sitter-javascript") + (bash "https://github.com/tree-sitter/tree-sitter-bash") + (cmake "https://github.com/uyha/tree-sitter-cmake"))) ;; Tree sitter major mode conversions (setq major-mode-remap-alist '((c-mode . c-ts-mode) @@ -119,7 +124,10 @@ (c-or-c++-mode . c-or-c++-ts-mode) (java-mode . java-ts-mode) (rust-mode . rust-ts-mode) - (json-mode . json-ts-mode)))) + (json-mode . json-ts-mode) + (css-mode . css-ts-mode) + (js-mode . js-ts-mode) + (cmake-mode . cmake-ts-mode)))) ;; c-ts-mode (use-package c-ts-mode @@ -395,8 +403,8 @@ visual states." ;; eglot (use-package eglot - :hook (((c-ts-mode c++-ts-mode java-ts-mode rust-ts-mode - python-ts-mode latex-mode) . eglot-ensure) + :hook (((c-ts-mode c++-ts-mode java-ts-mode rust-ts-mode python-ts-mode + latex-mode markdown-mode) . eglot-ensure) (eglot-managed-mode . my/-eglot-setup)) :init (defvar my/-eglot-documentation-buffer nil @@ -426,10 +434,20 @@ visual states." "Setup eldoc variables for `eglot-managed-mode-hook'." (setq-local eldoc-echo-area-use-multiline-p nil evil-lookup-func #'my/eglot-documentation-at-point) - (evil-define-key '(normal motion) 'local "K" #'evil-lookup) + (evil-define-key '(normal motion) 'local + "K" #'evil-lookup + "gR" #'eglot-rename + "gA" #'eglot-code-actions) (eglot-inlay-hints-mode -1)) - (advice-add 'eglot-completion-at-point :around #'cape-wrap-buster) - (setq eglot-autoshutdown t)) + (setq eglot-autoshutdown t) + :config + (add-to-list 'eglot-server-programs + (cons '(c-mode c-ts-mode c++-mode c++-ts-mode objc-mode) + '("clangd" "--all-scopes-completion" "--background-index" + "--clang-tidy" "--completion-style=detailed" + "--header-insertion=never" "--pch-storage=memory" + "--malloc-trim" "--function-arg-placeholders"))) + (advice-add 'eglot-completion-at-point :around #'cape-wrap-buster)) ;; project.el (use-package project @@ -453,8 +471,12 @@ visual states." my/project-vterm-hash-table)))) (defvar my/project-run-command nil "Command to run with `my/project-run'.") + (put 'my/project-run-command 'safe-local-variable (lambda (val) + (stringp val))) (defvar my/project-run-dir nil "Directory to run project in with `my/project-run'.") + (put 'my/project-run-dir 'safe-local-variable (lambda (val) + (stringp val))) (defvar my/-project-run-history '() "Commands previously run with `my/project-run'") (defun my/project-get-root-dir () @@ -490,6 +512,18 @@ COMMAND and COMINT are like `compile'." ;; rust (use-package rust-mode) +;; markdown +(use-package markdown-mode) + +;; cmake +(use-package cmake-mode + :ensure nil + :hook (cmake-ts-mode . my/setup-cmake-ts-mode) + :init + (defun my/setup-cmake-ts-mode () + "Setup `cmake-ts-mode' buffers." + (setq-local indent-line-function #'cmake-indent))) + ;; json (use-package json-mode) @@ -571,48 +605,52 @@ COMMAND and COMINT are like `compile'." ;; mu4e (require 'auth-source-pass) (auth-source-pass-enable) -(add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e/") -(require 'mu4e) -(add-hook 'mu4e-index-updated-hook #'my/-mu4e-enable-index-messages) -(global-set-key (kbd "C-x C-m") #'mu4e) -(global-set-key (kbd "C-x m") #'mu4e-compose-new) -(define-key message-mode-map (kbd "C-c k") #'khard-insert-email-contact) -(evil-define-key '(normal motion) mu4e-main-mode-map "q" #'bury-buffer) -(defun my/-mu4e-enable-index-messages () - (setq mu4e-hide-index-messages nil)) -(defun my/mu4e-update-mail-and-index-silent () - "Run `mu4e-update-mail-and-index' without any messages in the background." - (setq mu4e-hide-index-messages t) - (mu4e-update-mail-and-index t)) -(setq message-kill-buffer-on-exit t - message-send-mail-function 'sendmail-send-it - mu4e-change-filenames-when-moving t - mu4e-context-policy 'pick-first - mu4e-index-update-error-warning nil - mu4e-get-mail-command "mbsync protonmail" - mu4e-completing-read-function #'completing-read-default - mu4e-contexts - `(,(make-mu4e-context - :name "Personal" - :enter-func (lambda () (mu4e-message "Entered personal context")) - :match-func (lambda (msg) - (when msg - (string-match-p "^/protonmail/" - (mu4e-message-field msg - :maildir)))) - :vars `((user-mail-address . ,(auth-source-pass-get "email" "emacs/mu4e-protonmail")) - (user-full-name . ,(auth-source-pass-get "name" "emacs/mu4e-protonmail")) - (message-signature nil) - (mu4e-refile-folder . "/protonmail/Archive") - (mu4e-sent-folder . "/protonmail/Sent") - (mu4e-drafts-folder . "/protonmail/Drafts") - (mu4e-trash-folder . "/protonmail/Trash") - (mu4e-bookmarks . ((:name "Inbox" - :query "maildir:/protonmail/Inbox" - :key ?i) - (:name "Unread" - :query "flag:unread AND NOT flag:trashed AND NOT maildir:/protonmail/Spam" - :key ?u))))))) +(use-package mu4e + :ensure nil + :defer nil + :hook (mu4e-index-updated . my/-mu4e-enable-index-messages) + :bind (("C-x C-m" . mu4e) + ("C-x m" . mu4e-compose-new) + :map message-mode-map + ("C-c k" . khard-insert-email-contact)) + :init + (require 'mu4e) + (evil-define-key '(normal motion) mu4e-main-mode-map "q" #'bury-buffer) + (defun my/-mu4e-enable-index-messages () + (setq mu4e-hide-index-messages nil)) + (defun my/mu4e-update-mail-and-index-silent () + "Run `mu4e-update-mail-and-index' without any messages in the background." + (setq mu4e-hide-index-messages t) + (mu4e-update-mail-and-index t)) + (setq message-kill-buffer-on-exit t + message-send-mail-function 'sendmail-send-it + mu4e-change-filenames-when-moving t + mu4e-context-policy 'pick-first + mu4e-index-update-error-warning nil + mu4e-get-mail-command "mbsync protonmail" + mu4e-completing-read-function #'completing-read-default + mu4e-contexts + `(,(make-mu4e-context + :name "Personal" + :enter-func (lambda () (mu4e-message "Entered personal context")) + :match-func (lambda (msg) + (when msg + (string-match-p "^/protonmail/" + (mu4e-message-field msg + :maildir)))) + :vars `((user-mail-address . ,(auth-source-pass-get "email" "emacs/mu4e-protonmail")) + (user-full-name . ,(auth-source-pass-get "name" "emacs/mu4e-protonmail")) + (message-signature nil) + (mu4e-refile-folder . "/protonmail/Archive") + (mu4e-sent-folder . "/protonmail/Sent") + (mu4e-drafts-folder . "/protonmail/Drafts") + (mu4e-trash-folder . "/protonmail/Trash") + (mu4e-bookmarks . ((:name "Inbox" + :query "maildir:/protonmail/Inbox" + :key ?i) + (:name "Unread" + :query "flag:unread AND NOT flag:trashed AND NOT maildir:/protonmail/Spam" + :key ?u)))))))) (use-package mu4e-alert :after mu4e :hook (after-init . mu4e-alert-enable-notifications)