Skip to content

Commit f6c7b53

Browse files
committed
Migrate closing labels
1 parent 1b5139f commit f6c7b53

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lsp-dart-closing-labels.el

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ be sent with information to render editor closing labels."
4040
:type 'float
4141
:group 'lsp-dart)
4242

43-
(lsp-defun lsp-dart-closing-labels-handle (_workspace (&ClosingLabelsNotification :uri :labels))
43+
(lsp-defun lsp-dart--closing-labels-check ((&ClosingLabelsNotification :uri :labels))
4444
"Closing labels notification handler."
4545
(when-let (buffer (find-buffer-visiting (lsp--uri-to-path uri)))
4646
(with-current-buffer buffer
@@ -58,5 +58,16 @@ be sent with information to render editor closing labels."
5858
'cursor t
5959
'font-lock-face 'font-lock-comment-face))))))))
6060

61+
(define-minor-mode lsp-dart-closing-labels-mode
62+
"Mode for displaying flutter closing labels on the end of methods/contructors."
63+
nil nil nil
64+
(cond
65+
(lsp-dart-closing-labels-mode
66+
(add-hook 'lsp-dart-closing-labels-arrived-hook #'lsp-dart--closing-labels-check nil t))
67+
(t
68+
(progn
69+
(remove-overlays (point-min) (point-max) 'lsp-dart-closing-labels t)
70+
(remove-hook 'lsp-dart-closing-labels-arrived-hook #'lsp-dart--closing-labels-check t)))))
71+
6172
(provide 'lsp-dart-closing-labels)
6273
;;; lsp-dart-closing-labels.el ends here

lsp-dart.el

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ PARAMS is the data sent from server."
106106
(when lsp-dart-flutter-widget-guides
107107
(lsp-dart-flutter-widget-guides-mode 1))
108108
(when lsp-dart-flutter-fringe-colors
109-
(lsp-dart-flutter-fringe-colors-mode 1)))
109+
(lsp-dart-flutter-fringe-colors-mode 1))
110+
(when lsp-dart-closing-labels
111+
(lsp-dart-closing-labels-mode 1)))
110112

111113
(lsp-register-client
112114
(make-lsp-client :new-connection
@@ -120,7 +122,8 @@ PARAMS is the data sent from server."
120122
(outline . ,lsp-dart-outline)
121123
(flutterOutline . ,lsp-dart-flutter-outline))
122124
:library-folders-fn (lambda (_workspace) (lsp-dart--library-folders))
123-
:notification-handlers (lsp-ht ("dart/textDocument/publishClosingLabels" #'lsp-dart-closing-labels-handle)
125+
:notification-handlers (lsp-ht ("dart/textDocument/publishClosingLabels" (lambda (_workspace notification)
126+
(run-hook-with-args 'lsp-dart-closing-labels-arrived-hook notification)))
124127
("dart/textDocument/publishOutline" #'lsp-dart-outline-handle-outline)
125128
("dart/textDocument/publishFlutterOutline" #'lsp-dart-outline-handle-flutter-outline)
126129
("$/analyzerStatus" #'lsp-dart--handle-analyzer-status))

0 commit comments

Comments
 (0)