Skip to content

Instantly share code, notes, and snippets.

@mdempsky
Created January 9, 2021 06:45
Show Gist options
  • Save mdempsky/06db6c7cb658169a61d7c511cd307d6d to your computer and use it in GitHub Desktop.
Save mdempsky/06db6c7cb658169a61d7c511cd307d6d to your computer and use it in GitHub Desktop.
emacs config
;; Performance suggestions from
;; https://emacs-lsp.github.io/lsp-mode/page/performance/
(setq gc-cons-threshold 100000000)
(setq read-process-output-max (* 1024 1024)) ;; 1mb
(tool-bar-mode -1)
(menu-bar-mode -1)
(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives
'(("melpa" . "~/.emacs.d/elpa-mirror/melpa/")
("org" . "~/.emacs.d/elpa-mirror/org/")
("gnu" . "~/.emacs.d/elpa-mirror/gnu/")))
(package-initialize)
; Bootstrap John Wigley's `use-package'
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(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.
'(custom-enabled-themes '(tango-dark))
'(custom-safe-themes
'("2dff5f0b44a9e6c8644b2159414af72261e38686072e063aa66ee98a2faecf0e" "0cd00c17f9c1f408343ac77237efca1e4e335b84406e05221126a6ee7da28971" "7575474658c34b905bcec30a725653b2138c2f2d3deef0587e3abfae08c5b276" "5846b39f2171d620c45ee31409350c1ccaddebd3f88ac19894ae15db9ef23035" "46b2d7d5ab1ee639f81bde99fcd69eb6b53c09f7e54051a591288650c29135b0" "8b58ef2d23b6d164988a607ee153fd2fa35ee33efc394281b1028c2797ddeebb" "24714e2cb4a9d6ec1335de295966906474fdb668429549416ed8636196cb1441" "bb7303ab60750380957d8205794d031ab222390673ff6dd6369d0277b966c1d4" "4cf9ed30ea575fb0ca3cff6ef34b1b87192965245776afa9e9e20c17d115f3fb" "2681c80b05b9b972e1c5e4d091efb9ba7bb5fa7dad810d9026bc79607a78f1c0" "b89ae2d35d2e18e4286c8be8aaecb41022c1a306070f64a66fd114310ade88aa" default))
'(diff-switches "-u")
'(lsp-enable-snippet nil)
'(lsp-ui-doc-deplay 1)
'(lsp-ui-doc-max-height 8)
'(lsp-ui-sideline-delay 2)
'(lsp-ui-sideline-show-code-actions nil)
'(lsp-ui-sideline-show-hover nil)
'(package-selected-packages
'(yaml-mode dap-mode use-package doom-themes doom-modeline counsel lsp-ivy adaptive-wrap ace-window swiper avy forge which-key company-coq proof-general darkokai-theme darkburn-theme monokai-alt-theme monokai-pro-theme monokai-theme dracula-theme gotham-theme gruvbox-theme suscolors-theme company-lsp lsp-mode lsp-ui magit go-mode))
'(split-height-threshold 200)
'(split-width-threshold 80))
;;; uncomment for CJK utf-8 support for non-Asian users
;; (require 'un-define)
;; (require 'package)
;; (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
;; (package-initialize)
(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.
)
;; TODO(mdempsky): Where should these go?
(set-face-attribute 'default nil :height 160)
(fset 'yes-or-no-p 'y-or-n-p)
(column-number-mode)
(setq vc-handled-backends '(Git))
(setq compilation-scroll-output 'first-error)
(add-hook 'text-mode-hook #'visual-line-mode)
(setq use-package-always-ensure t)
(use-package go-mode
:config
(setq gofmt-command "goimports")
(add-hook 'before-save-hook 'gofmt-before-save)
(add-hook 'go-mode-hook (lambda () (setq tab-width 2)))
(add-hook 'go-mode-hook 'electric-pair-mode))
(defun brb ()
(interactive)
(let ((gopher-gif (create-image "/home/matthew-live/gopher-drink.gif"))
(brb-buf (get-buffer-create "brb")))
(switch-to-buffer brb-buf)
(text-scale-increase 8)
(erase-buffer)
(insert " ")
(insert-image gopher-gif)
(insert "BRB")
(newline 1)
(image-animate gopher-gif 0 t)))
(defun gotry ()
(interactive)
(let ((default-directory (shell-command-to-string "echo -n $(go env GOROOT)/test")))
(compile "gotry")))
(defun gotry-nocmp ()
(interactive)
(let ((default-directory (shell-command-to-string "echo -n $(go env GOROOT)/test")))
(compile "gotry -nocmp")))
(defun gotry-make ()
(interactive)
(let ((default-directory (shell-command-to-string "echo -n $(go env GOROOT)/src")))
(compile "gotrymake")))
(use-package tramp
:config
(add-to-list 'tramp-remote-path 'tramp-own-remote-path))
(use-package lsp-mode
:commands (lsp lsp-deferred)
:hook (go-mode . lsp-deferred)
:config
(setq lsp-enable-file-watchers nil)
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)
(lsp-register-client
(make-lsp-client
:new-connection (lsp-tramp-connection "gopls")
:major-modes '(go-mode go-dot-mod-mode)
:language-id "go"
:priority 0
:server-id 'gopls-remote
:completion-in-comments? t
:remote? t
:library-folders-fn #'lsp-go--library-default-directories
:after-open-fn (lambda ()
;; https://github.com/golang/tools/commit/b2d8b0336
(setq-local lsp-completion-filter-on-incomplete nil)))))
(use-package lsp-ivy
:config
(global-set-key (kbd "C->") 'lsp-ivy-workspace-symbol)
;; Ensure that lsp-ivy sets xref stack markers so I can use M-, to pop
;; back to previous location.
(advice-add 'lsp-ivy--workspace-symbol-action
:before (lambda (&rest r) (xref-push-marker-stack))))
(setq dvorak-homerow-keys '(?e ?t ?u ?h ?o ?n ?i ?d ?a ?s))
(use-package avy
:config
(global-set-key (kbd "C-r") 'avy-goto-char)
(setq avy-keys dvorak-homerow-keys))
(use-package swiper
:config
(global-set-key (kbd "C-s") 'swiper))
(use-package ace-window
:config
(global-set-key (kbd "M-o") 'ace-window)
(setq aw-keys dvorak-homerow-keys))
(use-package git-commit
:config
(add-hook 'git-commit-mode-hook 'turn-off-auto-fill))
(use-package yaml-mode)
(defun git-generate ()
(interactive)
(magit-run-git-async "generate"))
(defun git-generate-conflict ()
(interactive)
(magit-run-git-async "generate" "-conflict"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment