Skip to content

Commit

Permalink
Add client workspace configuration settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ericdallo committed Aug 26, 2020
1 parent 437c548 commit f57bbef
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 33 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.15.0
* Add `lsp-dart-enable-sdk-formatter` setting.
* Add `lsp-dart-line-length` setting.

## 1.14.0
* Add `lsp-dart-pub-get` command.
* Add `lsp-dart-pub-upgrade` command.
Expand Down
68 changes: 35 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,39 +163,41 @@ You can also open the [Dart DevTools](https://dart.dev/tools/dart-devtools) on t

## Supported settings

| Variable | Description | Default |
|:-------------------------------------------------|:--------------------------------------------------------------------------------------------------------|:------------------|
| `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` |
| `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` |
| `lsp-dart-server-command` | `analysis_server` executable to use | Check source file |
| `lsp-dart-extra-library-directories` | Extra libs to analyze besides Dart SDK libs | `'()` |
| `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` |
| `lsp-dart-suggest-from-unimported-libraries` | Completion will not include symbols that are not already imported into the current file. | `t` |
| `lsp-dart-closing-labels` | Enable the closing labels feature on server lsp | `t` |
| `lsp-dart-closing-labels-prefix` | The prefix string to be concatenated with the closing label | `""` |
| `lsp-dart-closing-labels-size` | The font size factor to be multiplied by the closing labels font size | 0.9 |
| `lsp-dart-outline` | Enable the outline tree view feature on server lsp | `t` |
| `lsp-dart-outline-position-params` | The outline tree position params. | Left side |
| `lsp-dart-flutter-outline` | Wheter to enable the Flutter outline tree view feature on server lsp | `t` |
| `lsp-dart-flutter-outline-position-params` | The Flutter outline tree position params | Left side |
| `lsp-dart-flutter-fringe-colors` | Enable the Flutter colors on fringe. | `t` |
| `lsp-dart-flutter-widget-guides` | Enable the Flutter widget guide lines from parent to child widgets | `t` |
| `lsp-dart-main-code-lens` | Enable the `Run|Debug` code lens on main methods. | `t` |
| `lsp-dart-test-code-lens` | Enable the `Run|Debug` code lens on tests. | `t` |
| `lsp-dart-dap-extension-version` | The debugger extension version. | 3.10.1 |
| `lsp-dart-dap-debugger-path` | The debugger extension path | Check source file |
| `lsp-dart-dap-dart-debugger-program` | The command to execute the debugger extension on dart projects. | Check source file |
| `lsp-dart-dap-dart-test-debugger-program` | The command to execute the test debugger extension on dart projects. | Check source file |
| `lsp-dart-dap-flutter-debugger-program` | The command to execute the debugger extension on flutter projects. | Check source file |
| `lsp-dart-dap-flutter-test-debugger-program` | The command to execute the test debugger extension on flutter projects. | Check source file |
| `lsp-dart-dap-debug-external-libraries` | Whether to enable the debug on external libraries | `nil` |
| `lsp-dart-dap-debug-sdk-libraries` | Whether to enable the debug on Dart SDK libraries | `nil` |
| `lsp-dart-dap-vm-additional-args` | Additional args for dart debugging VM when the debugging. | `""` |
| `lsp-dart-dap-flutter-track-widget-creation` | Whether to pass –track-widget-creation to Flutter apps. Required to support 'Inspect Widget'. | `t` |
| `lsp-dart-dap-flutter-structured-errors` | Whether to use Flutter’s structured error support for improve error display. | `t` |
| `lsp-dart-dap-flutter-verbose-log` | Whether to enable verbose logs from Flutter DAP | `nil` |
| `lsp-dart-devtools-theme` | The devtools theme when openning via `lsp-dart-dap-open-devtools` | `"dark"` |
| `lsp-dart-devtools-hide-options` | What to hide when openning DevTools via `lsp-dart-dap-open-devtools` | `debugger` |
| Variable | Description | Default | |
|:-------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------|-----|
| `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` | |
| `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` | |
| `lsp-dart-server-command` | `analysis_server` executable to use | Check source file | |
| `lsp-dart-enable-sdk-formatter` | Whether to enable server formatting. | `t` | |
| `lsp-dart-line-length` | Line length used by server formatter. | 80 | |
| `lsp-dart-extra-library-directories` | Extra libs to analyze besides Dart SDK libs | `'()` | |
| `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` | |
| `lsp-dart-suggest-from-unimported-libraries` | Completion will not include symbols that are not already imported into the current file. | `t` | |
| `lsp-dart-closing-labels` | Enable the closing labels feature on server lsp | `t` | |
| `lsp-dart-closing-labels-prefix` | The prefix string to be concatenated with the closing label | `""` | |
| `lsp-dart-closing-labels-size` | The font size factor to be multiplied by the closing labels font size | 0.9 | |
| `lsp-dart-outline` | Enable the outline tree view feature on server lsp | `t` | |
| `lsp-dart-outline-position-params` | The outline tree position params. | Left side | |
| `lsp-dart-flutter-outline` | Wheter to enable the Flutter outline tree view feature on server lsp | `t` | |
| `lsp-dart-flutter-outline-position-params` | The Flutter outline tree position params | Left side | |
| `lsp-dart-flutter-fringe-colors` | Enable the Flutter colors on fringe. | `t` | |
| `lsp-dart-flutter-widget-guides` | Enable the Flutter widget guide lines from parent to child widgets | `t` | |
| `lsp-dart-main-code-lens` | Enable the `Run | Debug` code lens on main methods. | `t` |
| `lsp-dart-test-code-lens` | Enable the `Run | Debug` code lens on tests. | `t` |
| `lsp-dart-dap-extension-version` | The debugger extension version. | 3.10.1 | |
| `lsp-dart-dap-debugger-path` | The debugger extension path | Check source file | |
| `lsp-dart-dap-dart-debugger-program` | The command to execute the debugger extension on dart projects. | Check source file | |
| `lsp-dart-dap-dart-test-debugger-program` | The command to execute the test debugger extension on dart projects. | Check source file | |
| `lsp-dart-dap-flutter-debugger-program` | The command to execute the debugger extension on flutter projects. | Check source file | |
| `lsp-dart-dap-flutter-test-debugger-program` | The command to execute the test debugger extension on flutter projects. | Check source file | |
| `lsp-dart-dap-debug-external-libraries` | Whether to enable the debug on external libraries | `nil` | |
| `lsp-dart-dap-debug-sdk-libraries` | Whether to enable the debug on Dart SDK libraries | `nil` | |
| `lsp-dart-dap-vm-additional-args` | Additional args for dart debugging VM when the debugging. | `""` | |
| `lsp-dart-dap-flutter-track-widget-creation` | Whether to pass –track-widget-creation to Flutter apps. Required to support 'Inspect Widget'. | `t` | |
| `lsp-dart-dap-flutter-structured-errors` | Whether to use Flutter’s structured error support for improve error display. | `t` | |
| `lsp-dart-dap-flutter-verbose-log` | Whether to enable verbose logs from Flutter DAP | `nil` | |
| `lsp-dart-devtools-theme` | The devtools theme when openning via `lsp-dart-dap-open-devtools` | `"dark"` | |
| `lsp-dart-devtools-hide-options` | What to hide when openning DevTools via `lsp-dart-dap-open-devtools` | `debugger` | |

## Additional packages
* [lsp-ui](https://github.com/emacs-lsp/lsp-ui) : Flycheck, documentation and code actions support.
Expand Down
3 changes: 3 additions & 0 deletions lsp-dart-protocol.el
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

(require 'lsp-protocol)

(lsp-interface
(DartConfiguration nil (:dart.enableSdkFormatter :dart.lineLength)))

(lsp-interface
(AnalyzerStatusNotification (:isAnalyzing) nil))

Expand Down
23 changes: 23 additions & 0 deletions lsp-dart.el
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ imported into the current file."
:type 'boolean
:group 'lsp-dart)

(defcustom lsp-dart-enable-sdk-formatter t
"When to enable server formmating."
:type 'boolean
:group 'lsp-dart)

(defcustom lsp-dart-line-length 80
"The number of characters the formatter should wrap code at."
:type 'number
:group 'lsp-dart)


;;; Internal

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

(lsp-defun lsp-dart--configuration (_workspace (&ConfigurationParams :items))
"Return the client workspace configuration."
(->> items
(seq-map (-lambda ((&ConfigurationItem :scope-uri?))
(-when-let* ((file (lsp--uri-to-path scope-uri?))
(buffer (find-buffer-visiting file))
(workspace-folder (lsp-find-session-folder (lsp-session) file)))
(with-current-buffer buffer
(lsp-make-dart-configuration :dart-enable-sdk-formatter? lsp-dart-enable-sdk-formatter
:dart-line-length? lsp-dart-line-length)))))
(apply #'vector)))

(defun lsp-dart--server-command ()
"Generate LSP startup command."
(let ((client-version (when (require 'pkg-info nil t)
Expand Down Expand Up @@ -140,6 +162,7 @@ PARAMS is the data sent from server."
("dart/textDocument/publishFlutterOutline" (lambda (_workspace notification)
(run-hook-with-args 'lsp-dart-flutter-outline-arrived-hook notification)))
("$/analyzerStatus" #'lsp-dart--handle-analyzer-status))
:request-handlers (lsp-ht ("workspace/configuration" #'lsp-dart--configuration))
:after-open-fn #'lsp-dart--activate-features
:server-id 'dart_analysis_server))

Expand Down

0 comments on commit f57bbef

Please sign in to comment.