Skip to content

Instantly share code, notes, and snippets.

@hxy9243
Last active October 21, 2019 15:19
Show Gist options
  • Save hxy9243/b52ff4953af3df7d6ec2 to your computer and use it in GitHub Desktop.
Save hxy9243/b52ff4953af3df7d6ec2 to your computer and use it in GitHub Desktop.
My Emacs Config
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Install melpa
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(when (>= emacs-major-version 24)
(require 'package)
(add-to-list
'package-archives
'("melpa" . "http://melpa.org/packages/")
t)
(package-initialize))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Personal setup
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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
(quote
(jedi jedi-core golint go-eldoc go-autocomplete gnu-elpa-keyring-update company-go browse-kill-ring hyperbole protobuf-mode dockerfile-mode elpy lsp-go ibuffer-sidebar dired-sidebar jinja2-mode fill-column-indicator highlight-indent-guides go-guru guru-mode clang-format groovy-mode babel babel-repl challenger-deep-theme ido-vertical-mode color-theme cmake-mode ac-helm helm auto-complete))))
(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.
)
(column-number-mode)
(global-linum-mode t)
(add-to-list 'auto-mode-alist '("\\.m\\'" . octave-mode))
(add-to-list 'auto-mode-alist '("\\.cu\\'" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.hbs\\'" . html-mode))
(add-to-list 'auto-mode-alist '("\\.jinja\\'" . jinja2-mode))
(global-auto-revert-mode t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Setup general dev
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'prog-mode-hook 'fci-mode)
(setq-default fci-rule-column 80)
(require 'highlight-indent-guides)
(add-hook 'prog-mode-hook 'highlight-indent-guides-mode)
(setq highlight-indent-guides-method 'character)
(setq highlight-indent-guides-character ?\|)
(set-face-foreground 'highlight-indent-guides-character-face "dimgray")
;; setup list buffer kill ring
(global-set-key (kbd "C-x w") 'browse-kill-ring)
;; Setup dired mode
(require 'dired-sidebar)
(defun sidebar-toggle()
"Toggle sidebar"
(interactive)
(dired-sidebar-toggle-with-current-directory)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Package specific steup
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(ac-config-default)
(window-numbering-mode t)
(require 'ido)
(ido-mode t)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Setup C/C++ dev
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq-default c-basic-offset 4)
(require 'clang-format)
(global-set-key (kbd "C-c u") 'clang-format-buffer)
(setq clang-format-style-option "file")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Setup Python dev
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'py-autopep8)
(add-hook 'python-mode-hook 'py-autopep8-enable-on-save)
(setq py-autopep8-options '("--max-line-length=80"))
;; Setup jedi mode
;; (autoload 'jedi:setup "jedi" nil t)
(setq jedi:server-command '("python3" "/home/huke/.emacs.d/elpa/jedi-core-20181207.1750/jediepcserver.py"))
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t)
(setq jedi:use-shortcuts t)
(defun python-config ()
(interactive)
(local-set-key (kbd "M-?") 'jedi:show-doc))
(add-hook 'python-mode-hook 'python-config)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Setup golang dev
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(with-eval-after-load 'go-mode
(require 'go-autocomplete))
(defun user-go-config()
(local-set-key (kbd "M-.") 'godef-jump)
(auto-complete-mode 1)
(setq gofmt-command "goimports")
(add-hook 'before-save-hook 'gofmt-before-save)
)
(add-hook 'go-mode-hook 'user-go-config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment