forked from emacs-lsp/lsp-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lsp-dart.el
85 lines (67 loc) · 2.85 KB
/
lsp-dart.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
78
79
80
81
82
83
84
85
;;; lsp-dart.el --- LSP mode -*- lexical-binding: t; -*-
;; Copyright (C) 2019 Takeshi Tsukamoto
;; Author: Takeshi Tsukamoto <[email protected]>
;; Keywords: languages
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; dart analysis server client
;;; Code:
(defgroup lsp-dart nil
"LSP support for Dart, using dart analysis server."
:group 'lsp-mode
:link '(url-link "https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server")
:package-version '(lsp-mode . "6.1"))
(defcustom lsp-dart-sdk-dir "~/flutter/bin/cache/dart-sdk/"
"Install directory for dart-sdk."
:group 'lsp-dart
:risky t
:type 'directory
:package-version '(lsp-mode . "6.1"))
(defcustom lsp-dart-server-command nil
"The analysis_server executable to use"
:type '(repeat string)
:group 'lsp-dart
:package-version '(lsp-mode . "6.1"))
(defcustom lsp-dart-only-analyze-projects-with-open-files t
"When set to non-nil, analysis will only be performed for projects that have open files
rather than the root workspace folder. Defaults to t"
:type 'boolean
:group 'lsp-dart
:package-version '(lsp-mode . "6.2"))
(defcustom lsp-dart-suggest-from-unimported-libraries t
"When set to nil, completion will not include synbols that are not already
imported into the current file. Defaults to true"
:type 'boolean
:group 'lsp-dart
:package-version '(lsp-mode . "6.2"))
(defun lsp-dart--server-command ()
"Generate LSP startup command."
(or
lsp-dart-server-command
`(,(expand-file-name (f-join lsp-dart-sdk-dir "bin/dart"))
,(expand-file-name (f-join lsp-dart-sdk-dir "bin/snapshots/analysis_server.dart.snapshot"))
"--lsp")))
(lsp-register-client
(make-lsp-client :new-connection
(lsp-stdio-connection
'lsp-dart--server-command)
:major-modes '(dart-mode)
:priority -1
:initialization-options
`((onlyAnalyzeProjectsWithOpenFiles . ,lsp-dart-only-analyze-projects-with-open-files)
(suggestFromUnimportedLibraries . ,lsp-dart-suggest-from-unimported-libraries))
:server-id 'dart_analysis_server))
(provide 'lsp-dart)
;;; lsp-dart.el ends here
;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)
;; End: