-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-lsp.el
77 lines (70 loc) · 3.45 KB
/
init-lsp.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
;; (use-package eglot
;; :commands (eglot eglot-ensure))
(use-package lsp-mode
:custom
(lsp-prefer-flymake nil)
(lsp-restart 'auto-restart)
(lsp-enable-symbol-highlighting nil)
(lsp-enable-indentation nil)
;; don't mess with my `company-backends'
(lsp-completion-enable nil)
(lsp-headerline-breadcrumb-enable nil)
:init
:hook ((rust-mode . lsp) (typescript-mode . lsp) (elm-mode . lsp))
:commands (lsp lsp-deferred))
;; TODO add a hook to 'lsp-completion-mode to fix company-backends (hook does sth when 'jester-tabnine-active-modes)
;; lsp-ui auto configured by lsp-mode
(use-package lsp-ui
:custom ((lsp-ui-sideline-enable nil)
(lsp-ui-flycheck-enable t)
(lsp-ui-doc-max-height 50)
(lsp-ui-doc-alignment 'frame-left-or-right-other))
:init
;; (custom-set-faces `(lsp-ui-doc-background
;; ((t (:background ,(face-attribute 'hl-line :background))))))
(setq lsp-ui-doc-border (face-attribute 'default :foreground))
:config
(setq lsp-ui-doc-alignment 'frame-left-or-right-other)
(defun lsp-ui-doc--move-frame (frame)
"Place our FRAME on screen."
(-let* (((left top right _bottom) (window-edges nil nil nil t))
(window (frame-root-window frame))
((width . height) (window-text-pixel-size window nil nil 10000 10000 t))
(width (+ width (* (frame-char-width frame) 1))) ;; margins
(char-h (frame-char-height))
(height (min (- (* lsp-ui-doc-max-height char-h) (/ char-h 2)) height))
(frame-right (pcase lsp-ui-doc-alignment
('window right)
(_ (frame-pixel-width))))
(frame-resize-pixelwise t)
((window-left-edge window-top-edge window-right-edge _) (window-absolute-pixel-edges))
(window-left-right-center (/ (+ window-left-edge window-right-edge) 2))
((frame-left-edge frame-top-edge frame-right-edge _) (frame-edges))
(frame-left-right-center (/ (+ frame-left-edge frame-right-edge) 2)))
(set-frame-size frame width height t)
(if (eq lsp-ui-doc-position 'at-point)
(lsp-ui-doc--mv-at-point frame height left top)
(set-frame-position frame
(if (and (eq lsp-ui-doc-alignment 'frame-left-or-right-other)
(> window-left-right-center frame-left-right-center))
10
(max (- frame-right width 10 (frame-char-width)) 10))
(pcase lsp-ui-doc-position
('top (pcase lsp-ui-doc-alignment
('window (+ top 10))
(_ 10)))
('bottom (pcase lsp-ui-doc-alignment
('window (- (+ (lsp-ui-doc--line-height 'mode-line) (- window-top-edge frame-top-edge))
height
10))
(_ (- (frame-pixel-height)
height
10)))))))))
)
;; TODO
;; (set-lookup-handlers! 'lsp-ui-mode :async t
;; :definition 'lsp-ui-peek-find-definitions
;; :references 'lsp-ui-peek-find-references)
;; (use-package lsp-vue
;; :demand t)
(provide 'init-lsp)