|
1 | 1 | # lsp-dart |
| 2 | + |
| 3 | +[](https://travis-ci.com/emacs-lsp/lsp-dart) |
| 4 | + |
| 5 | +Emacs Dart IDE using [lsp-mode](https://github.com/emacs-lsp/lsp-mode) to connect to [Dart Analysis Server](https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server). |
| 6 | + |
| 7 | +## Quickstart |
| 8 | + |
| 9 | +An example with a minimal configuration to start using `lsp-dart`: |
| 10 | +```elisp |
| 11 | +(use-package lsp-mode :ensure t) |
| 12 | +(use-package lsp-ui :ensure t) |
| 13 | +(use-package company-lsp :ensure t) |
| 14 | +
|
| 15 | +(use-package lsp-dart |
| 16 | + :ensure t |
| 17 | + :hook (dart-mode . lsp)) |
| 18 | +``` |
| 19 | + |
| 20 | +## Features |
| 21 | +Beside the `lsp-mode` features, `lsp-dart` implements the [`dart_analysis_server` custom methods](https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md#custom-methods) features too. |
| 22 | + |
| 23 | +**Closing labels** |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +### Treemacs views |
| 28 | +`lsp-dart` uses `lsp-treemacs` for rendering some tree views features. |
| 29 | + |
| 30 | +**`lsp-dart-show-outline`** |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | +**`lsp-dart-show-flutter-outline`** |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +## Supported settings |
| 39 | + |
| 40 | +* `lsp-dart-sdk-dir` - Install directory for dart-sdk. |
| 41 | +* `lsp-dart-server-command` - The analysis_server executable to use. |
| 42 | +* `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. |
| 43 | +* `lsp-dart-suggest-from-unimported-libraries` - completion will not include synbols that are not already imported into the current file. |
| 44 | +* `lsp-dart-closing-labels` - Enable the closing labels feature on server lsp. |
| 45 | +* `lsp-dart-closing-labels-prefix` - The prefix string to be concatened with the closing label. |
| 46 | +* `lsp-dart-closing-labels-size` - The font size factor to be multiplied by the closing labels font size. |
| 47 | +* `lsp-dart-outline` - Enable the outline tree view feature on server lsp. |
| 48 | +* `lsp-dart-flutter-outline` - Enable the Flutter outline tree view feature on server lsp. |
| 49 | +* `lsp-dart-outline-position-params` - The outline tree position params. Defaults to side. |
| 50 | +* `lsp-dart-flutter-outline-position-params` - The Flutter outline tree position params. Defaults to side. |
| 51 | + |
| 52 | +## Additional packages |
| 53 | +* [lsp-ui](https://github.com/emacs-lsp/lsp-ui) : Flycheck, documentation and code actions support. |
| 54 | +* [company-lsp](https://github.com/tigersoldier/company-lsp) : LSP company backend. |
| 55 | +* [lsp-treemacs](https://github.com/emacs-lsp/lsp-treemacs) : `lsp-mode` GUI controls implemented using treemacs. |
| 56 | + |
| 57 | +## FAQ |
| 58 | + |
| 59 | +* Q. Emacs can't find my package, it keeps searching up until the dart root package folder. |
| 60 | + |
| 61 | +Configure projectile to find the package pubspec.yaml and set the folder as project root: |
| 62 | +```elisp |
| 63 | +(with-eval-after-load 'projectile |
| 64 | + (add-to-list 'projectile-project-root-files-bottom-up "pubspec.yaml")) |
| 65 | +``` |
0 commit comments