From d53903ccae60b0177db13bb24634deeeb6e53a98 Mon Sep 17 00:00:00 2001 From: Gabriel Simmer Date: Sun, 15 May 2022 21:37:25 +0100 Subject: [PATCH] Completely rewrite emacs config with straight and eglot --- .emacs.d/init.el | 168 ++++++++++++++--------------------------------- .zshrc | 11 +++- Dots.org | 168 ++++++++++++++--------------------------------- 3 files changed, 107 insertions(+), 240 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index ff77408..206a459 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -1,141 +1,71 @@ -;; Mostly following along with System Crafter's videos. -;; So this will look pretty familiar. -(setq inhibit-startup-message t) - -(scroll-bar-mode -1) -(tool-bar-mode -1) -(tooltip-mode -1) -(set-fringe-mode 10) - -(menu-bar-mode -1) - -;; disable auto-save and auto-backup +(setq inhibit-startup-message t) +;; neccesary non-package related config (setq auto-save-default nil) (setq make-backup-files nil) - -(set-face-attribute 'default nil :font "IBM Plex Mono" :height 120) (global-set-key (kbd "") 'keyboard-escape-quit) +(set-face-attribute 'default nil :font "IBM Plex Mono" :height 120) +(scroll-bar-mode -1) +(tool-bar-mode -1) +(set-fringe-mode 10) +(menu-bar-mode -1) + (setq org-edit-src-content-indentation 0 org-src-tab-acts-natively t org-src-preserve-indentation t) -;; Packages stuff. -(require 'package) +;; stupid hacks +(setenv "PATH" + (concat "/usr/local/bin/go" "/home/gsimmer/projects/go/bin" (getenv "PATH"))) -(setq package-archives '(("melpa" . "https://melpa.org/packages/") - ("org" . "https://orgmode.org/elpa/") - ("elpa" . "https://elpa.gnu.org/packages/"))) - -(package-initialize) -(unless package-archive-contents - (package-refresh-contents)) - -(unless (package-installed-p 'use-package) - (package-install 'use-package)) - -(require 'use-package) -(setq use-package-always-ensure t) - -(use-package nano-theme - :ensure t - :config - (load-theme 'nano-dark t)) +;; straight.el bootstrapping +(defvar bootstrap-version) +(let ((bootstrap-file + (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) + (bootstrap-version 5)) + (unless (file-exists-p bootstrap-file) + (with-current-buffer + (url-retrieve-synchronously + "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" + 'silent 'inhibit-cookies) + (goto-char (point-max)) + (eval-print-last-sexp))) + (load bootstrap-file nil 'nomessage)) +;; package list we want installed +;; first grab use-package :3 +(straight-use-package 'use-package) +(use-package el-patch :straight t) +(use-package monokai-pro-theme + :straight t + :config (load-theme 'monokai-pro-spectrum t)) (use-package doom-modeline - :ensure t + :straight t :init (doom-modeline-mode 1) - :custom - (doom-mode-line-height 15)) -(use-package all-the-icons :ensure t) - -(use-package treemacs - :ensure t - :defer t - :init - :bind (:map global-map - ("M-0" . treemacs-select-window) - ("C-x t t" . treemacs))) -(use-package treemacs-projectile - :ensure t) -;; LSP config. -(use-package spinner :ensure t) -(use-package lsp-mode - :ensure t - :init - (setq lsp-keymap-prefix "C-c l") - :hook ((rust-mode . lsp) - (go-mode . lsip) - (lsp-mode . lsp-enable-which-key-integration)) - :commands lsp) - -(use-package lsp-ui :commands lsp-ui-mode) -(use-package lsp-ivy :commands lsp-ivy-workspace-symbol) -(use-package lsp-treemacs :commands lsp-treemacs-errors-list) - -(use-package rust-mode) -(use-package go-mode) -(add-hook 'go-mode-hook #'lsp-deferred) - -;; Set up before-save hooks to format buffer and add/delete imports. -;; Make sure you don't have other gofmt/goimports hooks enabled. -(defun lsp-go-install-save-hooks () - (add-hook 'before-save-hook #'lsp-format-buffer t t) - (add-hook 'before-save-hook #'lsp-organize-imports t t)) -(add-hook 'go-mode-hook #'lsp-go-install-save-hooks) - -(use-package json-mode) - -;; Can't have lisps without paredit! + :custom (doom-mode-line-height 14)) +(use-package all-the-icons :straight t) (use-package paredit - :ensure t + :straight t :config (add-hook 'emacs-lisp-mode-hook #'paredit-mode) - ;; enable in the *scratch* buffer (add-hook 'lisp-interaction-mode-hook #'paredit-mode) (add-hook 'ielm-mode-hook #'paredit-mode) (add-hook 'lisp-mode-hook #'paredit-mode) (add-hook 'eval-expression-minibuffer-setup-hook #'paredit-mode)) - +(use-package which-key + :straight t + :config (which-key-mode)) (use-package projectile - :ensure t - :init - (projectile-mode +1) + :straight t + :init (projectile-mode +1) + :config (setq projectile-project-search-path '("~/projects")) :bind (:map projectile-mode-map ("s-p" . projectile-command-map) - ("C-c p" . projectile-command-map)) - :config - (setq projectile-project-search-path '("~/Projects"))) + ("C-c p" . projectile-command-map))) +(use-package dired-sidebar :straight t :commands (dired-sidebar-toggle-sidebar)) -;; Ivy/Swiper/Counsel config. -(use-package swiper) -(use-package counsel) -(use-package ivy - :diminish - :bind (("C-s" . swiper) - :map ivy-minibuffer-map - ("TAB" . ivy-alt-done) - ("C-l" . ivy-alt-done) - ("C-j" . ivy-next-line) - ("C-k" . ivy-previous-line) - :map ivy-switch-buffer-map - ("C-k" . ivy-previous-line) - ("C-l" . ivy-done) - ("C-d" . ivy-switch-buffer-kill) - :map ivy-reverse-i-search-map - ("C-k" . ivy-previous-line) - ("C-d" . ivy-reverse-i-search-kill)) - :config - (ivy-mode 1)) -(custom-set-variables - ;; custom-set-variables was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - '(package-selected-packages - '(treemacs-projectile projectile paredit all-the-fonts doom-modeline rust-mode swipe spinner lsp-treemacs lsp-ivy lsp-ui lsp-mode counsel swiper ivy treemacs use-package monokai-pro-theme))) -(custom-set-faces - ;; custom-set-faces was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - ) +;; lsp-mode stuff +(use-package eglot :straight t + :config (add-hook 'go-mode-hook 'eglot-ensure)) +(use-package company :straight t + :config (add-hook 'after-init-hook 'global-company-mode) (setq company-idle-delay 0) (setq company-minimum-prefix-length 1)) +(use-package go-mode :straight t) diff --git a/.zshrc b/.zshrc index 92c2507..e0b06c2 100644 --- a/.zshrc +++ b/.zshrc @@ -6,9 +6,9 @@ plugins=(git fzf zsh-autosuggestions) source $ZSH/oh-my-zsh.sh -export GOPATH="/home/gsimmer/Projects/go" +export GOPATH="/home/gsimmer/projects/go" export CARGOPATH="/home/gsimmer/.cargo/bin" -export PATH="/home/gsimmer/.local/bin:$GOPATH/bin:$CARGOPATH:$PATH" +export PATH="/usr/local/go/bin:/home/gsimmer/.local/bin:$GOPATH/bin:$CARGOPATH:$PATH" # Starship init. #eval "$(starship init zsh)" @@ -23,3 +23,10 @@ fi if [ $(which rg) != 'rg not found' ]; then alias grep=rg fi + +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +export FLYCTL_INSTALL="/home/gsimmer/.fly" +export PATH="$FLYCTL_INSTALL/bin:$PATH" diff --git a/Dots.org b/Dots.org index f97c7bc..5780fca 100644 --- a/Dots.org +++ b/Dots.org @@ -188,147 +188,77 @@ WantedBy=timers.target =..emacs.d/init.el= #+begin_src elisp :tangle .emacs.d/init.el -;; Mostly following along with System Crafter's videos. -;; So this will look pretty familiar. -(setq inhibit-startup-message t) - -(scroll-bar-mode -1) -(tool-bar-mode -1) -(tooltip-mode -1) -(set-fringe-mode 10) - -(menu-bar-mode -1) - -;; disable auto-save and auto-backup +(setq inhibit-startup-message t) +;; neccesary non-package related config (setq auto-save-default nil) (setq make-backup-files nil) - -(set-face-attribute 'default nil :font "IBM Plex Mono" :height 120) (global-set-key (kbd "") 'keyboard-escape-quit) +(set-face-attribute 'default nil :font "IBM Plex Mono" :height 120) +(scroll-bar-mode -1) +(tool-bar-mode -1) +(set-fringe-mode 10) +(menu-bar-mode -1) + (setq org-edit-src-content-indentation 0 org-src-tab-acts-natively t org-src-preserve-indentation t) -;; Packages stuff. -(require 'package) +;; stupid hacks +(setenv "PATH" + (concat "/usr/local/bin/go" "/home/gsimmer/projects/go/bin" (getenv "PATH"))) -(setq package-archives '(("melpa" . "https://melpa.org/packages/") - ("org" . "https://orgmode.org/elpa/") - ("elpa" . "https://elpa.gnu.org/packages/"))) - -(package-initialize) -(unless package-archive-contents - (package-refresh-contents)) - -(unless (package-installed-p 'use-package) - (package-install 'use-package)) - -(require 'use-package) -(setq use-package-always-ensure t) - -(use-package nano-theme - :ensure t - :config - (load-theme 'nano-dark t)) +;; straight.el bootstrapping +(defvar bootstrap-version) +(let ((bootstrap-file + (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) + (bootstrap-version 5)) + (unless (file-exists-p bootstrap-file) + (with-current-buffer + (url-retrieve-synchronously + "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" + 'silent 'inhibit-cookies) + (goto-char (point-max)) + (eval-print-last-sexp))) + (load bootstrap-file nil 'nomessage)) +;; package list we want installed +;; first grab use-package :3 +(straight-use-package 'use-package) +(use-package el-patch :straight t) +(use-package monokai-pro-theme + :straight t + :config (load-theme 'monokai-pro-spectrum t)) (use-package doom-modeline - :ensure t + :straight t :init (doom-modeline-mode 1) - :custom - (doom-mode-line-height 15)) -(use-package all-the-icons :ensure t) - -(use-package treemacs - :ensure t - :defer t - :init - :bind (:map global-map - ("M-0" . treemacs-select-window) - ("C-x t t" . treemacs))) -(use-package treemacs-projectile - :ensure t) -;; LSP config. -(use-package spinner :ensure t) -(use-package lsp-mode - :ensure t - :init - (setq lsp-keymap-prefix "C-c l") - :hook ((rust-mode . lsp) - (go-mode . lsip) - (lsp-mode . lsp-enable-which-key-integration)) - :commands lsp) - -(use-package lsp-ui :commands lsp-ui-mode) -(use-package lsp-ivy :commands lsp-ivy-workspace-symbol) -(use-package lsp-treemacs :commands lsp-treemacs-errors-list) - -(use-package rust-mode) -(use-package go-mode) -(add-hook 'go-mode-hook #'lsp-deferred) - -;; Set up before-save hooks to format buffer and add/delete imports. -;; Make sure you don't have other gofmt/goimports hooks enabled. -(defun lsp-go-install-save-hooks () - (add-hook 'before-save-hook #'lsp-format-buffer t t) - (add-hook 'before-save-hook #'lsp-organize-imports t t)) -(add-hook 'go-mode-hook #'lsp-go-install-save-hooks) - -(use-package json-mode) - -;; Can't have lisps without paredit! + :custom (doom-mode-line-height 14)) +(use-package all-the-icons :straight t) (use-package paredit - :ensure t + :straight t :config (add-hook 'emacs-lisp-mode-hook #'paredit-mode) - ;; enable in the *scratch* buffer (add-hook 'lisp-interaction-mode-hook #'paredit-mode) (add-hook 'ielm-mode-hook #'paredit-mode) (add-hook 'lisp-mode-hook #'paredit-mode) (add-hook 'eval-expression-minibuffer-setup-hook #'paredit-mode)) - +(use-package which-key + :straight t + :config (which-key-mode)) (use-package projectile - :ensure t - :init - (projectile-mode +1) + :straight t + :init (projectile-mode +1) + :config (setq projectile-project-search-path '("~/projects")) :bind (:map projectile-mode-map ("s-p" . projectile-command-map) - ("C-c p" . projectile-command-map)) - :config - (setq projectile-project-search-path '("~/Projects"))) + ("C-c p" . projectile-command-map))) +(use-package dired-sidebar :straight t :commands (dired-sidebar-toggle-sidebar)) -;; Ivy/Swiper/Counsel config. -(use-package swiper) -(use-package counsel) -(use-package ivy - :diminish - :bind (("C-s" . swiper) - :map ivy-minibuffer-map - ("TAB" . ivy-alt-done) - ("C-l" . ivy-alt-done) - ("C-j" . ivy-next-line) - ("C-k" . ivy-previous-line) - :map ivy-switch-buffer-map - ("C-k" . ivy-previous-line) - ("C-l" . ivy-done) - ("C-d" . ivy-switch-buffer-kill) - :map ivy-reverse-i-search-map - ("C-k" . ivy-previous-line) - ("C-d" . ivy-reverse-i-search-kill)) - :config - (ivy-mode 1)) -(custom-set-variables - ;; custom-set-variables was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - '(package-selected-packages - '(treemacs-projectile projectile paredit all-the-fonts doom-modeline rust-mode swipe spinner lsp-treemacs lsp-ivy lsp-ui lsp-mode counsel swiper ivy treemacs use-package monokai-pro-theme))) -(custom-set-faces - ;; custom-set-faces was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - ) +;; lsp-mode stuff +(use-package eglot :straight t + :config (add-hook 'go-mode-hook 'eglot-ensure)) +(use-package company :straight t + :config (add-hook 'after-init-hook 'global-company-mode) (setq company-idle-delay 0) (setq company-minimum-prefix-length 1)) +(use-package go-mode :straight t) #+end_src *** sublime text