Skip to content

Commit f57bbef

Browse files
committed
Add client workspace configuration settings
1 parent 437c548 commit f57bbef

File tree

4 files changed

+65
-33
lines changed

4 files changed

+65
-33
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.15.0
4+
* Add `lsp-dart-enable-sdk-formatter` setting.
5+
* Add `lsp-dart-line-length` setting.
6+
37
## 1.14.0
48
* Add `lsp-dart-pub-get` command.
59
* Add `lsp-dart-pub-upgrade` command.

README.md

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -163,39 +163,41 @@ You can also open the [Dart DevTools](https://dart.dev/tools/dart-devtools) on t
163163

164164
## Supported settings
165165

166-
| Variable | Description | Default |
167-
|:-------------------------------------------------|:--------------------------------------------------------------------------------------------------------|:------------------|
168-
| `lsp-dart-sdk-dir` | The optional Dart SDK path. If nil and in a flutter project, it will try to find the dart SDK from Flutter SDK cache dir, otherwise it will search for a dart executable in `$PATH`. | `nil` |
169-
| `lsp-dart-flutter-sdk-dir` | The optional Flutter SDK path. If nil, it will try to find the Flutter SDK from the `flutter` executable in `$PATH` and if not found, it will try in `$FLUTTER_ROOT`. | `nil` |
170-
| `lsp-dart-server-command` | `analysis_server` executable to use | Check source file |
171-
| `lsp-dart-extra-library-directories` | Extra libs to analyze besides Dart SDK libs | `'()` |
172-
| `lsp-dart-only-analyze-projects-with-open-files` | Analysis will only be performed for projects that have open files rather than the root workspace folder | `t` |
173-
| `lsp-dart-suggest-from-unimported-libraries` | Completion will not include symbols that are not already imported into the current file. | `t` |
174-
| `lsp-dart-closing-labels` | Enable the closing labels feature on server lsp | `t` |
175-
| `lsp-dart-closing-labels-prefix` | The prefix string to be concatenated with the closing label | `""` |
176-
| `lsp-dart-closing-labels-size` | The font size factor to be multiplied by the closing labels font size | 0.9 |
177-
| `lsp-dart-outline` | Enable the outline tree view feature on server lsp | `t` |
178-
| `lsp-dart-outline-position-params` | The outline tree position params. | Left side |
179-
| `lsp-dart-flutter-outline` | Wheter to enable the Flutter outline tree view feature on server lsp | `t` |
180-
| `lsp-dart-flutter-outline-position-params` | The Flutter outline tree position params | Left side |
181-
| `lsp-dart-flutter-fringe-colors` | Enable the Flutter colors on fringe. | `t` |
182-
| `lsp-dart-flutter-widget-guides` | Enable the Flutter widget guide lines from parent to child widgets | `t` |
183-
| `lsp-dart-main-code-lens` | Enable the `Run|Debug` code lens on main methods. | `t` |
184-
| `lsp-dart-test-code-lens` | Enable the `Run|Debug` code lens on tests. | `t` |
185-
| `lsp-dart-dap-extension-version` | The debugger extension version. | 3.10.1 |
186-
| `lsp-dart-dap-debugger-path` | The debugger extension path | Check source file |
187-
| `lsp-dart-dap-dart-debugger-program` | The command to execute the debugger extension on dart projects. | Check source file |
188-
| `lsp-dart-dap-dart-test-debugger-program` | The command to execute the test debugger extension on dart projects. | Check source file |
189-
| `lsp-dart-dap-flutter-debugger-program` | The command to execute the debugger extension on flutter projects. | Check source file |
190-
| `lsp-dart-dap-flutter-test-debugger-program` | The command to execute the test debugger extension on flutter projects. | Check source file |
191-
| `lsp-dart-dap-debug-external-libraries` | Whether to enable the debug on external libraries | `nil` |
192-
| `lsp-dart-dap-debug-sdk-libraries` | Whether to enable the debug on Dart SDK libraries | `nil` |
193-
| `lsp-dart-dap-vm-additional-args` | Additional args for dart debugging VM when the debugging. | `""` |
194-
| `lsp-dart-dap-flutter-track-widget-creation` | Whether to pass –track-widget-creation to Flutter apps. Required to support 'Inspect Widget'. | `t` |
195-
| `lsp-dart-dap-flutter-structured-errors` | Whether to use Flutter’s structured error support for improve error display. | `t` |
196-
| `lsp-dart-dap-flutter-verbose-log` | Whether to enable verbose logs from Flutter DAP | `nil` |
197-
| `lsp-dart-devtools-theme` | The devtools theme when openning via `lsp-dart-dap-open-devtools` | `"dark"` |
198-
| `lsp-dart-devtools-hide-options` | What to hide when openning DevTools via `lsp-dart-dap-open-devtools` | `debugger` |
166+
| Variable | Description | Default | |
167+
|:-------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------|-----|
168+
| `lsp-dart-sdk-dir` | The optional Dart SDK path. If nil and in a flutter project, it will try to find the dart SDK from Flutter SDK cache dir, otherwise it will search for a dart executable in `$PATH`. | `nil` | |
169+
| `lsp-dart-flutter-sdk-dir` | The optional Flutter SDK path. If nil, it will try to find the Flutter SDK from the `flutter` executable in `$PATH` and if not found, it will try in `$FLUTTER_ROOT`. | `nil` | |
170+
| `lsp-dart-server-command` | `analysis_server` executable to use | Check source file | |
171+
| `lsp-dart-enable-sdk-formatter` | Whether to enable server formatting. | `t` | |
172+
| `lsp-dart-line-length` | Line length used by server formatter. | 80 | |
173+
| `lsp-dart-extra-library-directories` | Extra libs to analyze besides Dart SDK libs | `'()` | |
174+
| `lsp-dart-only-analyze-projects-with-open-files` | Analysis will only be performed for projects that have open files rather than the root workspace folder | `t` | |
175+
| `lsp-dart-suggest-from-unimported-libraries` | Completion will not include symbols that are not already imported into the current file. | `t` | |
176+
| `lsp-dart-closing-labels` | Enable the closing labels feature on server lsp | `t` | |
177+
| `lsp-dart-closing-labels-prefix` | The prefix string to be concatenated with the closing label | `""` | |
178+
| `lsp-dart-closing-labels-size` | The font size factor to be multiplied by the closing labels font size | 0.9 | |
179+
| `lsp-dart-outline` | Enable the outline tree view feature on server lsp | `t` | |
180+
| `lsp-dart-outline-position-params` | The outline tree position params. | Left side | |
181+
| `lsp-dart-flutter-outline` | Wheter to enable the Flutter outline tree view feature on server lsp | `t` | |
182+
| `lsp-dart-flutter-outline-position-params` | The Flutter outline tree position params | Left side | |
183+
| `lsp-dart-flutter-fringe-colors` | Enable the Flutter colors on fringe. | `t` | |
184+
| `lsp-dart-flutter-widget-guides` | Enable the Flutter widget guide lines from parent to child widgets | `t` | |
185+
| `lsp-dart-main-code-lens` | Enable the `Run | Debug` code lens on main methods. | `t` |
186+
| `lsp-dart-test-code-lens` | Enable the `Run | Debug` code lens on tests. | `t` |
187+
| `lsp-dart-dap-extension-version` | The debugger extension version. | 3.10.1 | |
188+
| `lsp-dart-dap-debugger-path` | The debugger extension path | Check source file | |
189+
| `lsp-dart-dap-dart-debugger-program` | The command to execute the debugger extension on dart projects. | Check source file | |
190+
| `lsp-dart-dap-dart-test-debugger-program` | The command to execute the test debugger extension on dart projects. | Check source file | |
191+
| `lsp-dart-dap-flutter-debugger-program` | The command to execute the debugger extension on flutter projects. | Check source file | |
192+
| `lsp-dart-dap-flutter-test-debugger-program` | The command to execute the test debugger extension on flutter projects. | Check source file | |
193+
| `lsp-dart-dap-debug-external-libraries` | Whether to enable the debug on external libraries | `nil` | |
194+
| `lsp-dart-dap-debug-sdk-libraries` | Whether to enable the debug on Dart SDK libraries | `nil` | |
195+
| `lsp-dart-dap-vm-additional-args` | Additional args for dart debugging VM when the debugging. | `""` | |
196+
| `lsp-dart-dap-flutter-track-widget-creation` | Whether to pass –track-widget-creation to Flutter apps. Required to support 'Inspect Widget'. | `t` | |
197+
| `lsp-dart-dap-flutter-structured-errors` | Whether to use Flutter’s structured error support for improve error display. | `t` | |
198+
| `lsp-dart-dap-flutter-verbose-log` | Whether to enable verbose logs from Flutter DAP | `nil` | |
199+
| `lsp-dart-devtools-theme` | The devtools theme when openning via `lsp-dart-dap-open-devtools` | `"dark"` | |
200+
| `lsp-dart-devtools-hide-options` | What to hide when openning DevTools via `lsp-dart-dap-open-devtools` | `debugger` | |
199201

200202
## Additional packages
201203
* [lsp-ui](https://github.com/emacs-lsp/lsp-ui) : Flycheck, documentation and code actions support.

lsp-dart-protocol.el

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
(require 'lsp-protocol)
2525

26+
(lsp-interface
27+
(DartConfiguration nil (:dart.enableSdkFormatter :dart.lineLength)))
28+
2629
(lsp-interface
2730
(AnalyzerStatusNotification (:isAnalyzing) nil))
2831

lsp-dart.el

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ imported into the current file."
7171
:type 'boolean
7272
:group 'lsp-dart)
7373

74+
(defcustom lsp-dart-enable-sdk-formatter t
75+
"When to enable server formmating."
76+
:type 'boolean
77+
:group 'lsp-dart)
78+
79+
(defcustom lsp-dart-line-length 80
80+
"The number of characters the formatter should wrap code at."
81+
:type 'number
82+
:group 'lsp-dart)
83+
7484

7585
;;; Internal
7686

@@ -83,6 +93,18 @@ imported into the current file."
8393
(append (list (file-name-directory (buffer-file-name))) lsp-dart-extra-library-directories)
8494
lsp-dart-extra-library-directories)))
8595

96+
(lsp-defun lsp-dart--configuration (_workspace (&ConfigurationParams :items))
97+
"Return the client workspace configuration."
98+
(->> items
99+
(seq-map (-lambda ((&ConfigurationItem :scope-uri?))
100+
(-when-let* ((file (lsp--uri-to-path scope-uri?))
101+
(buffer (find-buffer-visiting file))
102+
(workspace-folder (lsp-find-session-folder (lsp-session) file)))
103+
(with-current-buffer buffer
104+
(lsp-make-dart-configuration :dart-enable-sdk-formatter? lsp-dart-enable-sdk-formatter
105+
:dart-line-length? lsp-dart-line-length)))))
106+
(apply #'vector)))
107+
86108
(defun lsp-dart--server-command ()
87109
"Generate LSP startup command."
88110
(let ((client-version (when (require 'pkg-info nil t)
@@ -140,6 +162,7 @@ PARAMS is the data sent from server."
140162
("dart/textDocument/publishFlutterOutline" (lambda (_workspace notification)
141163
(run-hook-with-args 'lsp-dart-flutter-outline-arrived-hook notification)))
142164
("$/analyzerStatus" #'lsp-dart--handle-analyzer-status))
165+
:request-handlers (lsp-ht ("workspace/configuration" #'lsp-dart--configuration))
143166
:after-open-fn #'lsp-dart--activate-features
144167
:server-id 'dart_analysis_server))
145168

0 commit comments

Comments
 (0)