From 6fe111be02fe347e075be5a2f163365131fa339d Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Fri, 15 Sep 2023 02:36:16 -0500 Subject: [PATCH] feat(emacs): include early init --- dots/.config/emacs/.gitignore | 1 + dots/.config/emacs/early-init.el | 1 + dots/.config/emacs/init.el | 66 +++++++++++++++++++++++++++----- 3 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 dots/.config/emacs/early-init.el diff --git a/dots/.config/emacs/.gitignore b/dots/.config/emacs/.gitignore index 3fda025e..71f1d3d4 100644 --- a/dots/.config/emacs/.gitignore +++ b/dots/.config/emacs/.gitignore @@ -2,3 +2,4 @@ !.gitignore !init.el !lisp +!early-init.el diff --git a/dots/.config/emacs/early-init.el b/dots/.config/emacs/early-init.el new file mode 100644 index 00000000..e9c0d5f5 --- /dev/null +++ b/dots/.config/emacs/early-init.el @@ -0,0 +1 @@ +(set-face-attribute 'default nil :family "FiraCode Nerd Font" :height 120) diff --git a/dots/.config/emacs/init.el b/dots/.config/emacs/init.el index cd4bb3ae..5504e2ec 100644 --- a/dots/.config/emacs/init.el +++ b/dots/.config/emacs/init.el @@ -56,6 +56,7 @@ (general-create-definer key-local-leader :prefix ";") + (key-leader :states 'normal "/" '(comment-line :which-key "Comment: Toggle Current Line") @@ -87,6 +88,13 @@ (general-def "" #'keyboard-escape-quit) + +;; Ensure emacs paths load the same as our shell +(use-package exec-path-from-shell + :config + (when (memq window-system '(mac ns x)) + (exec-path-from-shell-initialize))) + ;; Which key to hint key bindings (use-package which-key :defer nil @@ -174,10 +182,10 @@ (which-key-allow-evil-operators t) (evil-undo-system 'undo-redo) (evil-want-fine-undo t) - (evil-show-paren-range 1000) :config (evil-mode 1)) + (use-package evil-surround :config (global-evil-surround-mode 1)) @@ -465,12 +473,8 @@ register-preview-function #'consult-register-format xref-show-xrefs-function #'consult-xref xref-show-definitions-function #'consult-xref - completion-in-region-function (lambda (&rest args) - (apply (if vertico-mode - #'consult-completion-in-region - #'completion--in-region) - args)) - consult-narrow-key "<") + consult-narrow-key "<" + completion-in-region-function #'consult-completion-in-region) :general (key-leader :states 'normal @@ -480,7 +484,6 @@ "c r" '(consult-recent-file :which-key "Consult: Recent Files"))) - ;; Persist history over Emacs restarts. Vertico sorts by history position. (use-package savehist :elpaca nil @@ -533,11 +536,56 @@ :config (rainbow-mode t)) +;; Setup Language Servers + +(general-create-definer key-lsp-leader + :prefix "SPC l") + +(use-package lsp-mode + :init + ;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l") + (setq lsp-keymap-prefix "SPC l") + :hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode) + ;; (XXX-mode . lsp) + ;; if you want which-key integration + (lsp-mode . lsp-enable-which-key-integration)) + :commands lsp) + +;; optionally +(use-package lsp-ui :commands lsp-ui-mode) + +;; optionally if you want to use debugger +(use-package dap-mode + :config + (require 'dap-cpptools) + (require 'dap-gdb-lldb) + (dap-register-debug-template "Rust::GDB Run Configuration" + (list :type "gdb" + :request "launch" + :name "GDB::Run" + :gdbpath "rust-gdb" + :target nil + :cwd nil)) + (dap-ui-mode) + (dap-tooltip-mode) + (dap-ui-controls-mode) + (dap-mode)) + + +;; (use-package dap-LANGUAGE) to load the dap adapter for your language + +;; Rust integration +(use-package rustic + :general + (key-lsp-leader + :states 'normal)) + ;; "f r" ((rustic-cargo-run) :which-key "Cargo: Run"))) + ;; Opacity (menu-bar-mode -1) ; Disable menubar (scroll-bar-mode -1) ; Disable visible scrollbar (tool-bar-mode -1) ; Disable toolbar -(tooltip-mode -1) ; Disable tooltips +(tooltip-mode) ; Enable tooltips (set-fringe-mode 10) ; Breathing room (setq visible-bell t) ; Enable visible bell (blink-cursor-mode 0) ; Disable blinking cursor