lpan / lsp-dart

lsp-mode :heart: dart

Home Page:https://emacs-lsp.github.io/lsp-dart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lsp-dart

dart_logo

MELPA MELPA stable CI Gitter

Emacs Dart IDE using lsp-mode to connect to Dart Analysis Server.

flutter_logo LSP works great with Flutter, but there are also other packages that may help to improve your development, for more info see Additional packages.

Quickstart

An example with a minimal configuration to start using lsp-dart:

(use-package lsp-mode :ensure t)

(use-package lsp-dart 
  :ensure t 
  :hook (dart-mode . lsp))

;; Optional packages
(use-package lsp-ui :ensure t)
(use-package company-capf :ensure t)

Features

Besides the lsp-mode features, lsp-dart implements the custom methods features from the dart_analysis_server.

Closing labels

closing-labels

Tree views

lsp-dart uses lsp-treemacs for rendering some tree views features.

lsp-dart-show-outline ⚠️*

outline

lsp-dart-show-flutter-outline ⚠️*

flutter-outline

Run tests

lsp-dart-run-test-file - Run all tests from current test buffer.

lsp-dart-run-test-at-point - Run single test at point. ⚠️*

Running a test interactively:

test

Flutter colors

Display the flutter colors on left fringe.

flutter-fringe-colors

You can disable the feature setting lsp-dart-flutter-fringe-colors to nil.

Flutter widget guides

Display widget guide lines from parent to child widgets on flutter. ⚠️*

flutter-widget-guides

You can disable the feature setting lsp-dart-flutter-widget-guides to nil.

Debug

For debugging, lsp-dart uses dap-mode. You only need to run dap-dart-setup one time to setup the debugger to your Emacs and dap-debug to start the debug.

debug

Flutter

lsp-dart support Flutter debugging too via dap-debug with an option to select the device to debug.

flutter-debug

DevTools

You can also open the Dart DevTools on the current debug session with lsp-dart-dap-devtools-open.

⚠️* Features only available for Dart SDK version 2.8.0 (currently the dev branch) or above.

Supported settings

Variable Description Default
lsp-dart-project-sdk-dir Install directory for dart-sdk $PATH
lsp-dart-project-flutter-command The flutter executable path "flutter" that may be in the $PATH.
lsp-dart-server-command analysis_server executable to use Check source file
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-test-code-lens Enable the Run code lens on tests. t
lsp-dart-dap-extension-version The debugger extension version. 3.9.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-flutter-debugger-program The command to execute the 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-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-dap-devtools-theme The devtools theme when openning via lsp-dart-dap-open-devtools "dark"
lsp-dart-dap-devtools-hide-options What to hide when openning DevTools via lsp-dart-dap-open-devtools debugger

Additional packages

  • lsp-ui : Flycheck, documentation and code actions support.
  • lsp-treemacs : lsp-mode GUI controls implemented using treemacs.
  • company-capf : Completion backend support.
  • flutter.el : Tool to run emulator from emacs.
  • hover.el : Tool to run flutter mobile apps from desktop without the need of an emulator.

FAQ

❔ Emacs can't find my package, it keeps searching up until the dart root package folder.

🔹 Configure projectile to find the package pubspec.yaml and set the folder as project root:

(with-eval-after-load 'projectile
  (add-to-list 'projectile-project-root-files-bottom-up "pubspec.yaml")
  (add-to-list 'projectile-project-root-files-bottom-up "BUILD"))

LSP :: No LSP server for dart-mode(check *lsp-log*).

🔹 Try to set the lsp-dart-project-sdk-dir to the Dart SDK dir instalation or if you are using Flutter, <your-flutter-dir>/bin/cache/dart-sdk/.

Community

All feedback and suggestions are welcome!

You can open a issue or for a quick anwser, send a message on Gitter.

About

lsp-mode :heart: dart

https://emacs-lsp.github.io/lsp-dart

License:GNU General Public License v3.0


Languages

Language:Emacs Lisp 98.6%Language:Makefile 1.4%