Skip to content

Instantly share code, notes, and snippets.

@trusch
Created May 12, 2018 11:54
Show Gist options
  • Save trusch/baed0d242b1f83521ba956ead568513f to your computer and use it in GitHub Desktop.
Save trusch/baed0d242b1f83521ba956ead568513f to your computer and use it in GitHub Desktop.
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "https")))
;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
(add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . (concat proto "://elpa.gnu.org/packages/")))))
(package-initialize)
(setq package-list '(go-mode
projectile
web-mode
all-the-icons
neotree
go-projectile
go-autocomplete
multiple-cursors
flycheck
ansi-color
smex
ido
flx-ido
magit
protobuf-mode
yaml-mode
web-mode
tide
company
fiplr
dockerfile-mode
autopair
gist
kubernetes
)
)
(unless package-archive-contents
(package-refresh-contents))
(dolist (package package-list)
(unless (package-installed-p package)
(package-install package)))
;;
;; BEGIN INITS
;;
(projectile-global-mode)
(setq-default tab-width 4)
(global-flycheck-mode)
(add-to-list 'load-path "~/go/src/github.com/dougm/goflymake")
(require 'ansi-color)
(defun colorize-compilation-buffer ()
(toggle-read-only)
(ansi-color-apply-on-region compilation-filter-start (point))
(toggle-read-only))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)
(require 'smex) ; Not needed if you use package.el
(smex-initialize)
(require 'flx-ido)
(ido-mode 1)
(ido-everywhere 1)
(flx-ido-mode 1)
;; disable ido faces to see flx highlights.
(setq ido-enable-flex-matching t)
(setq ido-use-faces nil)
(delete-selection-mode 1)
(autopair-global-mode)
;; (setq projectile-switch-project-action 'neotree-projectile-action)
;;
;; END INITS
;;
;;
;; BEGIN CUSTOM KEYBINDINGS
;;
(global-set-key (kbd "C-x p") 'projectile-switch-project) ; Ctrl+x p
(global-set-key (kbd "C-x r") 'compile) ; Ctrl+x r
(global-set-key (kbd "C-d") 'mc/mark-next-like-this-word) ; Ctrl+d
(global-set-key (kbd "C-7") 'comment-or-uncomment-region) ; Ctrl+d
(global-set-key (kbd "C-x m") 'magit-status) ; Ctrl+x m
(global-set-key (kbd "C-x C-x") 'kill-this-buffer) ; Ctrl+x+x
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
(global-set-key (kbd "C-x f") 'fiplr-find-file)
(global-set-key (kbd "C-x C-g") 'google-this)
;;
;; END CUSTOM KEYBINDINGS
;;
;;
;; BEGIN GOLANG STUFF
;;
(require 'go-mode)
(defun set-exec-path-from-shell-PATH ()
(let ((path-from-shell (replace-regexp-in-string
"[ \t\n]*$"
""
(shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
(setenv "PATH" path-from-shell)
(setq eshell-path-env path-from-shell) ; for eshell users
(setq exec-path (split-string path-from-shell path-separator))))
(when window-system (set-exec-path-from-shell-PATH))
(setenv "GOPATH" "/home/tino/go")
(add-to-list 'exec-path "/home/tino/go/bin")
(setq gofmt-command "goimports")
(defun my-go-mode-hook ()
; Call Gofmt before saving
(add-hook 'before-save-hook 'gofmt-before-save)
; Godef jump key binding
(local-set-key (kbd "M-,") 'pop-tag-mark)
(local-set-key (kbd "M-.") 'godef-jump)
(local-set-key (kbd "M-d") 'godoc-at-point)
(auto-complete-mode 1)
(if (not (string-match "go" compile-command))
(set (make-local-variable 'compile-command)
"go build -v && go test -v ./... && go vet"))
)
(add-hook 'go-mode-hook 'my-go-mode-hook)
(with-eval-after-load 'go-mode
(require 'go-autocomplete))
(require 'go-projectile)
;;
;; END GOLANG STUFF
;;
;;
;; BEGIN JS STUFF
;;
(defun setup-tide-mode ()
(interactive)
(tide-setup)
(flycheck-mode +1)
(setq flycheck-check-syntax-automatically '(save mode-enabled))
(eldoc-mode +1)
(tide-hl-identifier-mode +1)
;; company is an optional dependency. You have to
;; install it separately via package-install
;; `M-x package-install [ret] company`
(company-mode +1))
;; aligns annotation to the right hand side
(setq company-tooltip-align-annotations t)
;; formats the buffer before saving
(add-hook 'before-save-hook 'tide-format-before-save)
(add-hook 'typescript-mode-hook #'setup-tide-mode)
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
(add-hook 'web-mode-hook
(lambda ()
(when (string-equal "tsx" (file-name-extension buffer-file-name))
(setup-tide-mode))))
;; enable typescript-tslint checker
(flycheck-add-mode 'typescript-tslint 'web-mode)
;;
;; END JS STUFF
;;
(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 (quote (wombat)))
'(inhibit-startup-screen t)
'(package-selected-packages
(quote
(gist kubernetes google-this google autopair dockerfile-mode undo-tree go-playground 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.
)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment