spacemacs/contrib/lang/scala/funcs.el
Chris Barrett 66aa47037d Start ensime only once file exists
This prevents annoying error messages when using find-file to make a new
scala buffer.
2015-01-03 23:17:54 +13:00

60 lines
1.8 KiB
EmacsLisp

;;; Ensime
(defun scala/configure-ensime ()
"Ensure the file exists before starting `ensime-mode'."
(if (file-exists-p (buffer-file-name))
(ensime-mode +1)
(add-hook 'after-save-hook (lambda () (ensime-mode +1)) nil t)))
(defun spacemacs/ensime-refactor-accept ()
(interactive)
(funcall continue-refactor)
(ensime-popup-buffer-quit-function))
(defun spacemacs/ensime-refactor-cancel ()
(interactive)
(funcall cancel-refactor)
(ensime-popup-buffer-quit-function))
;;; Interactive commands
(defun spacemacs/scala-join-line ()
"Adapt `scala-indent:join-line' to behave more like evil's line join.
`scala-indent:join-line' acts like the vanilla `join-line',
joining the current line with the previous one. The vimmy way is
to join the current line with the next.
Try to move to the subsequent line and then join. Then manually move
point to the position of the join."
(interactive)
(let (join-pos)
(save-excursion
(goto-char (line-end-position))
(unless (eobp)
(forward-line)
(call-interactively 'scala-indent:join-line)
(setq join-pos (point))))
(when join-pos
(goto-char join-pos))))
(defun scala/completing-dot ()
"Insert a period and show company completions."
(interactive "*")
(when (s-matches? (rx (+ (not space)))
(buffer-substring (line-beginning-position) (point)))
(delete-horizontal-space t))
(insert ".")
(company-complete))
;;; Flyspell
(defun scala/flyspell-verify ()
"Prevent common flyspell false positives in scala-mode."
(and (flyspell-generic-progmode-verify)
(not (s-matches? (rx bol (* space) "package") (current-line)))))
(defun scala/configure-flyspell ()
(setq-local flyspell-generic-check-word-predicate 'scala/flyspell-verify))