forked from Ruin0x11/lsp-intellij-spacemacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
funcs.el
50 lines (41 loc) · 1.68 KB
/
funcs.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
;;; funcs.el --- lsp-intellij layer packages file for Spacemacs.
;;
;; Copyright (c) 2018 Richard Jones
;;
;; Author: <joneseh25@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: MIT
;;; Code:
;; shared functions
;; The following is adapted from Spacemacs' Eclim completion functions:
;; https://github.com/syl20bnr/spacemacs/blob/3731d0d/layers/%2Blang/java/funcs.el
(defun spacemacs//java-lsp-delete-horizontal-space ()
(when (s-matches? (rx (+ (not space)))
(buffer-substring (line-beginning-position) (point)))
(delete-horizontal-space t)))
(defun spacemacs/java-lsp-completing-dot ()
"Insert a period and show company completions."
(interactive "*")
(spacemacs//java-lsp-delete-horizontal-space)
(insert ".")
(company-lsp 'interactive))
(defun spacemacs/java-lsp-completing-double-colon ()
"Insert double colon and show company completions."
(interactive "*")
(spacemacs//java-lsp-delete-horizontal-space)
(insert ":")
(let ((curr (point)))
(when (s-matches? (buffer-substring (- curr 2) (- curr 1)) ":")
(company-lsp 'interactive))))
(if (version< spacemacs-version "0.300")
(setq spacemacs//intellij-lsp-version-dir-name "spacemacs-0.200")
(setq spacemacs//intellij-lsp-version-dir-name "spacemacs-0.300"))
(setq spacemacs//intellij-lsp-version-dir-fullpath
(expand-file-name spacemacs//intellij-lsp-version-dir-name
(file-name-directory (or load-file-name buffer-file-name))))
;; Load the relevant `funcs.el` based on Spacemacs version
(load (expand-file-name "funcs" spacemacs//intellij-lsp-version-dir-fullpath) t)
;;; funcs.el ends here