Skip to content

Commit e63baa6

Browse files
committed
Add dart libs to LSP workspace
1 parent 8852ae5 commit e63baa6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lsp-dart.el

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
:type '(repeat string)
4848
:group 'lsp-dart)
4949

50+
(defcustom lsp-dart-extra-library-directories '()
51+
"List of directories which will be considered to be libraries."
52+
:risky t
53+
:type '(repeat string)
54+
:group 'lsp-dart)
55+
5056
(defcustom lsp-dart-only-analyze-projects-with-open-files t
5157
"Analyze only open files.
5258
When set to non-nil, analysis will only be performed for projects that have
@@ -151,6 +157,15 @@ The key is composed of the KEY-PREFIX with PARAMS uri path."
151157
(let ((key (concat key-prefix "--" (buffer-file-name buffer))))
152158
(lsp-workspace-get-metadata key (lsp-find-workspace 'lsp-find-workspace))))
153159

160+
(defun lsp-dart-library-folders ()
161+
"Return the library folders path to analyze."
162+
(let* ((sdk-lib (expand-file-name "lib" (lsp-dart-project-get-sdk-dir)))
163+
(dirs (lsp--directory-files-recursively sdk-lib ".dart")))
164+
(--> dirs
165+
(-map #'file-name-directory it)
166+
(remove-duplicates it :test 'string=)
167+
(append it lsp-dart-extra-library-directories))))
168+
154169
(defun lsp-dart--outline-kind->icon (kind)
155170
"Maps an outline KIND to a treemacs icon symbol.
156171
Kinds from https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/spec/generated/java/types/ElementKind.java"
@@ -352,6 +367,7 @@ PARAMS closing labels notification data sent from WORKSPACE."
352367
(closingLabels . ,lsp-dart-closing-labels)
353368
(outline . ,lsp-dart-outline)
354369
(flutterOutline . ,lsp-dart-flutter-outline))
370+
:library-folders-fn (lambda (_workspace) (lsp-dart-library-folders))
355371
:notification-handlers (ht ("dart/textDocument/publishClosingLabels" 'lsp-dart--handle-closing-labels)
356372
("dart/textDocument/publishOutline" 'lsp-dart--handle-outline)
357373
("dart/textDocument/publishFlutterOutline" 'lsp-dart--handle-flutter-outline))

0 commit comments

Comments
 (0)