Skip to content

Instantly share code, notes, and snippets.

@strobe
Last active August 6, 2016 17:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strobe/f6c1d344dbb5e0c66b9f to your computer and use it in GitHub Desktop.
Save strobe/f6c1d344dbb5e0c66b9f to your computer and use it in GitHub Desktop.
osx emacs config for scala
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; !! General Settings !!
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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-names-vector
["#454545" "#cd5542" "#6aaf50" "#baba36" "#5180b3" "#ab75c3" "#bdbc61" "#bdbdb3"])
'(column-number-mode t)
'(default-input-method "russian-computer")
'(display-time-mode t)
'(erc-modules
(quote
(autojoin button completion hecomplete dcc fill irccontrols list log match menu move-to-prompt netsplit networks noncommands notifications readonly ring scrolltobottom services smiley sound stamp spelling track xdcc))))
;;;;;;;;;;;;;;;;;;;;;
;;
;; Packages Repos
;;
;;;;;;;;;;;;;;;;;;;;;
(require 'package) ;; You might already have this line
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
;;(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
;;(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
;; (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line
(when (not package-archive-contents)
(package-refresh-contents))
;;;;;;;;;;;;;;;;;;;;;;;
;; End Packages Repos
;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;
;;
;; Global
;;
;;;;;;;;;;;;
;; custom script path
(let ((default-directory "~/.emacs.d/my-lisp/"))
(normal-top-level-add-to-load-path '("."))
(normal-top-level-add-subdirs-to-load-path))
(defvar *main-path* "~/.emacs.d/my-lisp/")
;; undo\redo win like - keys are ‘C-c left’ and ‘C-c right’
;;(winner-mode t)
(fset 'yes-or-no-p 'y-or-n-p) ;;не заставляйте меня печать yes целиком
;; Mac style undo
(global-set-key (kbd "C-z") 'undo) ; 【Ctrl+z】
;; Mac style redo
(global-set-key (kbd "C-Z") 'redo)
;; globals settings
;;ну.. в принципе не надо, но симпатично
(fset 'yes-or-no-p 'y-or-n-p) ;;не заставляйте меня печать yes целиком
;; сохраняет сессию в текущую директорию
;; (desktop-save-mode t)
;; отключает звук beep
(setq visible-bell t)
;; отключает перенос строк
(toggle-truncate-lines t)
(setq-default truncate-lines t)
;; tabs disabling
(setq-default indent-tabs-mode nil)
;; dired setup
(put 'dired-find-alternate-file 'disabled nil)
;; reloading files if it changed on disk
(global-auto-revert-mode t)
;; move cursor to splitted window
;;(defadvice split-window (after move-point-to-new-window activate)
;; "Moves the point to the newly created window after splitting."
;; (other-window 1))
;; terminal mouse pointer support
(xterm-mouse-mode t)
;; terminal mouse scroll ;;
(defun track-mouse (e))
(setq mouse-wheel-follow-mouse 't)
(defvar alternating-scroll-down-next t)
(defvar alternating-scroll-up-next t)
(defun alternating-scroll-down-line ()
(interactive "@")
(when alternating-scroll-down-next
; (run-hook-with-args 'window-scroll-functions )
(scroll-down-line))
(setq alternating-scroll-down-next (not alternating-scroll-down-next)))
(defun alternating-scroll-up-line ()
(interactive "@")
(when alternating-scroll-up-next
; (run-hook-with-args 'window-scroll-functions)
(scroll-up-line))
(setq alternating-scroll-up-next (not alternating-scroll-up-next)))
(global-set-key (kbd "<mouse-4>") 'alternating-scroll-down-line)
(global-set-key (kbd "<mouse-5>") 'alternating-scroll-up-line)
;; end of terminal mouse scroll ;;
;; open buffer-menu insted buffer-menu-other-window
(global-set-key (kbd "C-x C-b") 'buffer-menu)
;; open buffer in new frame at buffer-menu by key 5
(defun Buffer-menu-other-frame ()
(interactive)
(switch-to-buffer-other-frame (Buffer-menu-buffer t)))
(define-key Buffer-menu-mode-map "5"
'Buffer-menu-other-frame)
;;;;;;;;;;;;;;;
;; End Global
;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;
;;
;; Extensions
;;
;;;;;;;;;;;;;;;
;; tabs bar
;;(byte-compile-file "/Applications/Emacs.app/Contents/Resources/site-lisp/tabbar.el")
; (byte-compile-file (concat *main-path* "tabbar/tabbar.el"))
(require 'tabbar)
(tabbar-mode t)
(global-set-key [(control shift tab)] 'tabbar-forward) ;; - переключение вперед
(global-set-key [(control meta shift tab)] 'tabbar-backward);; а теперь разворачиваемся на 180 градусов - и снова вперед
;; tabbar settings
(set-face-attribute 'tabbar-default-face nil :background "gray60")
(set-face-attribute 'tabbar-unselected-face nil
:background "gray85"
:foreground "gray30"
:box nil)
(set-face-attribute 'tabbar-selected-face nil
:background "#f2f2f6"
:foreground "black"
:box nil)
(set-face-attribute 'tabbar-button-face nil
:box '(:line-width 1 :color "gray72" :style released-button))
(set-face-attribute 'tabbar-separator-face nil
:height 0.7)
(defun tabbar-buffer-groups (buffer)
"Return the list of group names BUFFER belongs to.
Return only one group for each buffer."
(with-current-buffer (get-buffer buffer)
(cond
((string-equal "*" (substring (buffer-name) 0 1))
'("Emacs Buffer"))
((eq major-mode 'dired-mode)
'("Dired"))
(t
'("User Buffer"))
)))
;; parens higlight
(show-paren-mode)
;; http://www.emacswiki.org/emacs/HighlightParentheses
(byte-compile-file (concat *main-path* "highlight-parentheses/highlight-parentheses.el"))
(require 'highlight-parentheses)
(define-globalized-minor-mode global-highlight-parentheses-mode
highlight-parentheses-mode
(lambda ()
(highlight-parentheses-mode t)))
(global-highlight-parentheses-mode t)
;; multiply-cursors ;;
(add-to-list 'load-path "~/.emacs.d/elpa/multiple-cursors-1.3.0/")
(require 'multiple-cursors)
(global-set-key (kbd "M-s c") 'mc/edit-lines)
(global-set-key (kbd "M->") 'mc/mark-next-like-this)
(global-set-key (kbd "M-<") 'mc/mark-previous-like-this)
;;(Global-set-key (kbd "M-s <") 'mc/mark-all-like-this)
;; end ;;
;; ace jump ;;
(autoload
'ace-jump-mode
"ace-jump-mode"
"Emacs quick move minor mode"
t)
(define-key global-map (kbd "C-c SPC") 'ace-jump-mode)
(autoload
'ace-jump-mode-pop-mark
"ace-jump-mode"
"Ace jump back:-)"
t)
(eval-after-load "ace-jump-mode"
'(ace-jump-mode-enable-mark-sync))
(define-key global-map (kbd "C-x SPC") 'ace-jump-mode-pop-mark)
;; end ;;
;; projectile ;;
;(add-to-list 'load-path "~/.emacs.d/elpa/projectile-20150911.844/")
;(require 'projectile)
;(projectile-global-mode)
(add-hook 'scala-mode-hook 'projectile-mode)
(setq projectile-indexing-method 'native)
(setq projectile-enable-caching t)
(setq projectile-projects-cache (make-hash-table))
;; end ;;
;; helm (search anywhere) ;;
(add-to-list 'load-path "~/.emacs.d/elpa/helm-20151005.144/")
(require 'helm-config)
;(setq mac-command-modifier 'super)
(global-set-key (kbd "C-c f") 'helm-find-files)
(global-set-key (kbd "C-c b") 'helm-buffers-list)
(global-set-key (kbd "C-c n") 'helm-projectile)
;; end ;;
;; file explorer three OC
(add-to-list 'load-path "/some/path/neotree")
(require 'neotree)
(global-set-key [f8] 'neotree-toggle)
;; speed bar in main window
(require 'sr-speedbar)
;; transponse frame
(require 'transpose-frame)
;;;;;;;;;;;;;;;;;;;;
;; End Extensions
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;
;;
;; Custom Functions
;;
;;;;;;;;;;;;;;;;;;;;;;
;; swap windows
(defun swap-windows ()
"If you have 2 windows, it swaps them."
(interactive)
(cond ((/= (count-windows) 2)
(message "You need exactly 2 windows to do this."))
(t
(let* ((w1 (first (window-list)))
(w2 (second (window-list)))
(b1 (window-buffer w1))
(b2 (window-buffer w2))
(s1 (window-start w1))
(s2 (window-start w2)))
(set-window-buffer w1 b2)
(set-window-buffer w2 b1)
(set-window-start w1 s2)
(set-window-start w2 s1))))
(other-window 1))
(global-set-key (kbd "C-c s") 'swap-windows) ;; set hotkey for it
;; menu for GUI mode
(define-key global-map (kbd "C-<f2>")
(lambda ()
(interactive)
(x-popup-menu (list '(0 0) (selected-frame))
(mouse-menu-bar-map))))
;;;;;;;;;;;;;;;;;;;;;;;;;;
;; End Custom Functions
;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;
;;
;; Color Theme
;;
;;;;;;;;;;;;;;;;;;
;; color theme
;; then in your init:
;; do for either ample, ample-light, or ample-flat
(load-theme 'ample t)
(enable-theme 'ample)
(custom-set-faces
'(scala-font-lock:var-face
((t (:foreground "DarkOliveGreen3")))))
; (add-to-list 'custom-theme-load-path "~/.emacs.d/emacs-color-theme-darkula")
; (load-theme 'Darkula t)
; (custom-set-faces
; '(scala-font-lock:var-face
; ((t (:foreground "#A9B7C6"))))
; )
;;;;;;;;;;;;;;;;;;;;;;
;; End Color Theme
;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;
;;;
;;; !! Languages !!
;;;
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;
;; Scala
;;;;;;;;;;
;; if you're new to the MELPA package manager, just include
;; this entire snippet in your `~/.emacs` file and follow
;; the instructions in the comments.
(require 'package) ;; You might already have this line
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line
(when (not package-archive-contents)
(package-refresh-contents))
;; Restart emacs and do `M-x package-install [RETURN] ensime [RETURN]`
;; To keep up-to-date, do `M-x list-packages [RETURN] U [RETURN] x [RETURN]`
;; If necessary, make sure "sbt" and "scala" are in the PATH environment
;; (setenv "PATH" (concat "/path/to/sbt/bin:" (getenv "PATH")))
;; (setenv "PATH" (concat "/path/to/scala/bin:" (getenv "PATH")))
;;
;; On Macs, it might be a safer bet to use exec-path instead of PATH, for instance:
;; (setq exec-path (append exec-path '("/usr/local/bin")))
(require 'ensime)
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
;; Fancy unicode arrows for emacs scala-mode
;; https://gist.github.com/stew/6148551
(defun right-arrow ()
(interactive)
(cond ((looking-back "=")
(backward-delete-char 1) (insert "⇒"))
((looking-back "-")
(backward-delete-char 1) (insert "→"))
(t (insert ">"))))
(defun left-arrow ()
(interactive)
(if (looking-back "<")
(progn (backward-delete-char 1)
(insert "←"))
(insert "-")))
(add-hook 'scala-mode-hook '(lambda () (interactive)
(local-set-key (kbd "-") 'left-arrow)
(local-set-key (kbd ">") 'right-arrow)))
;;;;;;;;;;;;;;
;; End Scala
;;;;;;;;;;;;;;
;;;;;;;;;;;;
;;
;; Haskell
;;
;;;;;;;;;;;;
;; haskell mode configuration
(setq auto-mode-alist
(append auto-mode-alist
'(("\\.[hg]s$" . haskell-mode)
("\\.hic?$" . haskell-mode)
("\\.hsc$" . haskell-mode)
("\\.chs$" . haskell-mode)
("\\.l[hg]s$" . literate-haskell-mode))))
(autoload 'haskell-mode "haskell-mode"
"Major mode for editing Haskell scripts." t)
(autoload 'literate-haskell-mode "haskell-mode"
"Major mode for editing literate Haskell scripts." t)
;adding the following lines according to which modules you want to use:
(require 'inf-haskell)
(add-hook 'haskell-mode-hook 'turn-on-font-lock)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
(add-hook 'haskell-mode-hook 'turn-on-haskell-ghci)
(add-hook 'haskell-mode-hook
(function
(lambda ()
(setq haskell-program-name "ghci")
(setq haskell-ghci-program-name "ghci"))))
;;;;;;;;;;;;;;;;
;; End Haskell
;;;;;;;;;;;;;;;;
;;;;;;;;;;;;
;;
;; Go Lang
;;
;;;;;;;;;;;;
(eval-after-load "go-mode"
'(require 'flymake-go))
(require 'go-complete)
(add-hook 'completion-at-point-functions 'go-complete-at-point)
(add-hook 'go-mode-hook 'company-mode)
(add-hook 'go-mode-hook (lambda ()
(set (make-local-variable 'company-backends) '(company-go))
(company-mode)))
(require 'go-mode)
(add-hook 'before-save-hook 'gofmt-before-save)
(add-hook 'go-mode-hook '(lambda ()
(local-set-key (kbd "C-c C-r") 'go-remove-unused-imports)))
(add-hook 'go-mode-hook '(lambda ()
(local-set-key (kbd "C-c C-g") 'go-goto-imports)))
(add-hook 'go-mode-hook '(lambda ()
(local-set-key (kbd "C-c C-f") 'gofmt)))
(add-hook 'before-save-hook 'gofmt-before-save)
(add-hook 'go-mode-hook '(lambda ()
(local-set-key (kbd "C-c C-k") 'godoc)))
;;(add-hook 'go-mode-hook 'go-oracle-mode)
;;;;;;;;;;;;;;;;;
;; End Go Lang
;;;;;;;;;;;;;;;;;
;; This file overwrite setting for UI emacs
(add-to-list 'custom-theme-load-path "~/.emacs.d/emacs-color-theme-darkula")
(load-theme 'Darkula t)
(custom-set-faces
'(scala-font-lock:var-face
((t (:foreground "#A9B7C6"))))
)
;; toolbar disable
(tool-bar-mode -1)
@strobe
Copy link
Author

strobe commented Sep 29, 2015

default.el - is necessary for overwrite colour theme and other settings at GUI version of Emacs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment