Skip to content

Instantly share code, notes, and snippets.

@theoboldalex
Last active August 22, 2024 20:20
Show Gist options
  • Select an option

  • Save theoboldalex/355c100b37d59c9594aebd3a6d578337 to your computer and use it in GitHub Desktop.

Select an option

Save theoboldalex/355c100b37d59c9594aebd3a6d578337 to your computer and use it in GitHub Desktop.
Things I learned about Emacs

Things I learned about Emacs

Look and Feel

transparent title bar

(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(add-to-list 'default-frame-alist '(ns-appearance . light))

thie things I had to do to get title bar to match theme

(defvar after-load-theme-hook nil
  "Hook run after a color theme is loaded using `load-theme'.")
(defadvice load-theme (after run-after-load-theme-hook activate)
  "Run `after-load-theme-hook'."
  (run-hooks 'after-load-theme-hook))

(defun my-theme-config (theme)
  "Apply custom configurations based on the loaded THEME."
  (cond
   ;; Configuration for `leuven` theme (light mode)
   ((eq theme 'leuven)
    (set-frame-parameter nil 'ns-transparent-titlebar t)
    (set-frame-parameter nil 'ns-appearance 'light))

   ;; Configuration for `gruber-darker` theme (dark mode)
   ((eq theme 'gruber-darker)
    (set-frame-parameter nil 'ns-transparent-titlebar t)
    (set-frame-parameter nil 'ns-appearance 'dark))))

;; set titlebar based on theme
(defun title-bar-hook ()
  "Hook that runs after a theme is loaded."
  (message "Loaded theme: %s" (car custom-enabled-themes))
  (my-theme-config (car custom-enabled-themes)))

(add-hook 'after-load-theme-hook 'title-bar-hook)

(load-theme 'gruber-darker t)

sensible tab-width

(setq-default tab-width 4)

make frame fullscreen on load

(setq frame-resize-pixelwise t)
(dotimes (n 3)
  (toggle-frame-maximized))

sane defaults

(setq ring-bell-function 'ignore)
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(global-display-line-numbers-mode t)

setting a font

(set-frame-font "Jetbrains Mono Light 13" nil t)

Finding Things

plugins

  • Magit
  • Smex
  • Paredit
  • Which Key
  • LSP-Mode
  • Company
  • Eglot

go lsp

;; 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)

;; Get the GOPATH using the go env command
(let* ((gopath (string-trim (shell-command-to-string "go env GOPATH")))
       (gobin (concat gopath "/bin")))
  ;; Add GOPATH/bin to exec-path
  (add-to-list 'exec-path gobin)
  ;; Add GOPATH/bin to the PATH environment variable
  (setenv "PATH" (concat gobin path-separator (getenv "PATH"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment