Created
May 15, 2023 10:34
-
-
Save serkanaltuntas/1cd2ad4fdecf55b64a0d7a9551ced50f to your computer and use it in GitHub Desktop.
Emacs Configuration File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'package) | |
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) | |
(package-initialize) | |
(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. | |
'(ansi-color-faces-vector | |
[default default default italic underline success warning error]) | |
'(custom-enabled-themes '(wombat)) | |
'(package-selected-packages '(go-mode ##))) | |
(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. | |
) | |
;; disable splash screen and startup message | |
(setq inhibit-startup-message t) | |
(setq initial-scratch-message nil) | |
;; disable backup | |
(setq backup-inhibited t) | |
;; disable auto save | |
(setq auto-save-default nil) | |
;; Font size: | |
(set-face-attribute 'default nil :height 250) | |
;; Disable line wrap | |
(setq-default truncate-lines t) | |
;; Display line numbers | |
(add-hook 'prog-mode-hook 'display-line-numbers-mode) | |
;; if Mac keyboard Input Sources shortcut is not disabled, than use Meta key | |
;; (global-set-key (kbd "M-SPC") 'set-mark-command) | |
;; Bind AltGr + 7 to insert { and AltGr + 0 to insert } | |
(global-set-key (kbd "M-7") "{") | |
(global-set-key (kbd "M-0") "}") | |
;; Bind AltGr + 8 to insert [ and AltGr + 9 to insert ] | |
(global-set-key (kbd "M-8") "[") | |
(global-set-key (kbd "M-9") "]") | |
;; matching paranthesis | |
(electric-pair-mode 1) | |
;; ================ The Go IDE =================== | |
(require 'go-mode) | |
;; format go code | |
(defun run-gofmt-hook () | |
"Run Gofmt hook." | |
;; Add `gofmt` to `before-save-hook'. | |
(add-hook 'before-save-hook 'gofmt nil t)) | |
(add-hook 'go-mode-hook 'run-gofmt-hook) | |
(defun go-run () | |
(interactive) | |
(compile (concat "go run " (buffer-file-name)))) | |
(defun go-test () | |
(interactive) | |
(compile (concat "go test " (file-name-directory (buffer-file-name))))) | |
(defun goimports-before-save () | |
"Add imports, remove unused imports, and format code using goimports." | |
(interactive) | |
(when (eq major-mode 'go-mode) | |
(let ((orig-point (point))) | |
(goimports) | |
(gofmt) | |
(goto-char orig-point)))) | |
(define-key go-mode-map (kbd "C-c C-c") 'go-run) | |
(define-key go-mode-map (kbd "C-c C-t") 'go-test) | |
;; ================ The Go IDE =================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment