spacemacs/contrib/lang/scala/funcs.el

60 lines
1.8 KiB
EmacsLisp
Raw Normal View History

;;; 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)))
2014-12-29 20:40:56 +00:00
(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
2014-12-29 20:40:56 +00:00
(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))