Skip to content

Instantly share code, notes, and snippets.

@strobe
Last active December 18, 2018 07:55
Show Gist options
  • Save strobe/36f42d7867b0fb647f39d43aa2a9a4b4 to your computer and use it in GitHub Desktop.
Save strobe/36f42d7867b0fb647f39d43aa2a9a4b4 to your computer and use it in GitHub Desktop.
minimal emacs config for playing with Metals
;; defaults
(put 'dired-find-alternate-file 'disabled nil)
;; font
(set-face-attribute 'default nil :font "Iosevka SS08-14")
;; hide toolbar
(tool-bar-mode 0)
;; dark theme
(load-theme 'wombat)
;; hightlight parentheses
(show-paren-mode 1)
;; some other modes
(scroll-bar-mode 0)
(blink-cursor-mode 0)
;; hightlight current line
(global-hl-line-mode +1)
(set-face-attribute 'hl-line nil :inherit nil :background "gray17")
;; ergonomic way of moving between buffers
(global-set-key (kbd "M-]") 'other-frame)
(global-set-key (kbd "M-=") 'other-window)
(global-set-key (kbd "C-M-]") 'next-buffer)
(global-set-key (kbd "C-M-[") 'previous-buffer)
;; mac os to include environment-variables from the shell
(exec-path-from-shell-initialize)
(ignore-errors ;; This package is only relevant for Mac OS X.
(when (memq window-system '(mac ns))
(push 'exec-path-from-shell packages)
(push 'reveal-in-osx-finder packages)))
;; mac os pass system commands
(setq mac-pass-command-to-system t)
;; some userful packages
(require 'use-package)
(require 'auto-compile)
(require 'flycheck)
(use-package auto-compile)
;; Add melpa-stable to your packages repositories
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
;; Enable ensure by default for use-package
(setq use-package-always-ensure t)
;;; Language Specific Customizations ;;;
;; Enable scala-mode and sbt-mode
(use-package scala-mode
:interpreter
("scala" . scala-mode))
(use-package sbt-mode
:commands sbt-start sbt-command
:config
;; WORKAROUND: https://github.com/ensime/emacs-sbt-mode/issues/31
;; allows using SPACE when in the minibuffer
(substitute-key-definition
'minibuffer-complete-word
'self-insert-command
minibuffer-local-completion-map))
;;(require 'sbt-mode)
;; Enable nice rendering of diagnostics like compile errors.
(use-package flycheck
:init (global-flycheck-mode))
(add-hook 'scala-mode-hook 'flycheck-mode)
;; Lsp-ui
(use-package lsp-ui
:pin melpa-stable)
;;(require 'lsp-ui)
;; remaps M-. and M-? (aka M-. == go to definition, M-, go back)
(define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
(define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)
;; Eglot
(use-package eglot
:pin melpa-stable)
(add-to-list 'eglot-server-programs '(scala-mode . ("metals-emacs")))
(add-hook 'scala-mode-hook 'eglot-ensure)
;; Lsp-Mode
;;(use-package lsp-mode
;; :pin melpa-stable)
;;(add-hook 'lsp-mode-hook 'lsp-ui-mode )
;;(require 'lsp-mode)
;; Lsp-scala
;;(add-to-list 'load-path ".emacs.d/elpa/lsp-scala")
(use-package lsp-scala
:load-path "~/.emacs.d/elpa/lsp-scala")
(require 'lsp-scala)
(add-hook 'scala-mode-hook #'lsp-scala-enable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment