 
 ;; tramp
 (set-default 'tramp-default-proxies-alist (quote ((".*" "\\`root\\'" "/ssh:%h:"))))
+(define-key osx-key-mode-map [(alt \\) ?T] 'tramp-cleanup-all-connections)
+
+;; ensime
+(use-package ensime
+  :ensure t
+  :defer t
+  :init
+  (add-to-list 'exec-path "/opt/local/bin")
+  :config
+  (setq ensime-startup-snapshot-notification nil)
+  (setq ensime-startup-notification nil)
+  (add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
+  )
 
 ;; Go
-(env-var-import '("GOPATH"))
-(install-package 'go-mode)
-(install-package 'go-eldoc)
-(install-package 'go-autocomplete)
-
-(require 'go-autocomplete)
-(require 'auto-complete-config)
-(ac-config-default)
-
-(defun go-mode-setup ()
- (setq compile-command "go build -v && go test -v && go vet")
- (define-key (current-local-map) "\C-c\C-c" 'compile)
- (go-eldoc-setup)
- (setq gofmt-command "goimports")
- (add-hook 'before-save-hook 'gofmt-before-save)
- (local-set-key [(alt b)] 'godef-jump))
-(add-hook 'go-mode-hook 'go-mode-setup)
+(use-package env-var-import
+  :ensure t
+  :config
+  (env-var-import '("GOPATH"))
+  )
+
+(use-package go-mode
+  :ensure t
+  :mode "\\.go\\'"
+  :interpreter "go"
+  :config
+  (defun go-mode-setup ()
+    (setq compile-command "go build -v && go test -v && go vet")
+    (define-key (current-local-map) "\C-c\C-c" 'compile)
+    (go-eldoc-setup)
+    (setq gofmt-command "goimports")
+    (add-hook 'before-save-hook 'gofmt-before-save)
+    (local-set-key [(alt b)] 'godef-jump))
+  (add-hook 'go-mode-hook 'go-mode-setup)
+  )
+
+(use-package go-eldoc
+  :ensure t
+  :defer t)
+
+(use-package go-autocomplete
+  :ensure t
+  :defer t
+  :config
+  (ac-config-default)
+  )
+
+;; swift
+(use-package swift-mode
+  :ensure t
+  :mode "\\.swift\\'"
+  :interpreter "swift")
+
+(use-package flycheck-swift
+  :ensure t
+  :defer t
+  :config
+  (flycheck-swift-setup)
+  )
 
 ;; start server
 (server-start)

(put 'erase-buffer 'disabled nil)

;; packages
(defun install-package (x)
  (when (not (package-installed-p x)) (package-install x)))

(require 'package)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
                         ("marmalade" . "https://marmalade-repo.org/packages/")
                         ("melpa" . "http://melpa.org/packages/")))
(package-initialize)
(when (not package-archive-contents)
  (package-refresh-contents))

(install-package 'env-var-import)
(install-package 'magit)
(install-package 'buffer-move)

(install-package 'flycheck)

;; shell
(defun shell-named (name)
  (shell)
  (rename-buffer name)

;; vertical window split
(setq split-width-threshold nil)

;; indentation
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(setq-default py-indent-offset 2)
(setq-default css-indent-offset 2)
(setq-default c-basic-offset 2)
(setq-default js2-basic-offset 2)
(setq-default javascript-indent-level 2)
(setq-default js-indent-level 2)
(setq-default scala-indent-level 2)
(custom-set-variables
 '(python-guess-indent nil)
 '(python-indent 2))

;; auto complete
(setq-default completion-ignore-case t)
