From 45da8d0d5fd815f7705a141aa9afae2d36cc526f Mon Sep 17 00:00:00 2001 From: "sevensidedmarble (Andrew Stewart)" Date: Sat, 15 Feb 2020 12:22:01 -0500 Subject: [PATCH 1/7] Initial version of dart module --- modules/lang/dart/+flutter.el | 7 +++++++ modules/lang/dart/config.el | 12 ++++++++++++ modules/lang/dart/doctor.el | 11 +++++++++++ modules/lang/dart/packages.el | 6 ++++++ 4 files changed, 36 insertions(+) create mode 100644 modules/lang/dart/+flutter.el create mode 100644 modules/lang/dart/config.el create mode 100644 modules/lang/dart/doctor.el create mode 100644 modules/lang/dart/packages.el diff --git a/modules/lang/dart/+flutter.el b/modules/lang/dart/+flutter.el new file mode 100644 index 000000000..f31283902 --- /dev/null +++ b/modules/lang/dart/+flutter.el @@ -0,0 +1,7 @@ +;;; lang/dart/+flutter.el -*- lexical-binding: t; -*- + +(use-package! flutter + :config + (map! :map dart-mode-map + :localleader + "r" #'flutter-run-or-hot-reload)) diff --git a/modules/lang/dart/config.el b/modules/lang/dart/config.el new file mode 100644 index 000000000..fc574a62e --- /dev/null +++ b/modules/lang/dart/config.el @@ -0,0 +1,12 @@ +;;; lang/dart/config.el -*- lexical-binding: t; -*- + +(cond ((featurep! +flutter) (load! "+flutter")) + ((featurep! +lsp) (load! "+lsp"))) + +(use-package! dart-mode + :config + (when (featurep! +flutter) + (if IS-LINUX + (setq lsp-dart-sdk-dir "/opt/flutter/bin/cache/dart-sdk/"))) + (when (featurep! +lsp) + (add-hook 'dart-mode-hook 'lsp))) diff --git a/modules/lang/dart/doctor.el b/modules/lang/dart/doctor.el new file mode 100644 index 000000000..aa68b7bce --- /dev/null +++ b/modules/lang/dart/doctor.el @@ -0,0 +1,11 @@ +;;; lang/dart/doctor.el -*- lexical-binding: t; -*- + +(assert! (or (not (featurep! +lsp)) + (featurep! :tools lsp)) + "This module requires (:tools lsp)") + +(unless (executable-find "dart") + (warn! "Dart isn't on PATH.")) + +(unless (file-readable-p lsp-dart-sdk-dir) + (warn! "LSP Mode can't find lsp-dart-sdk-dir.")) diff --git a/modules/lang/dart/packages.el b/modules/lang/dart/packages.el new file mode 100644 index 000000000..2116e665c --- /dev/null +++ b/modules/lang/dart/packages.el @@ -0,0 +1,6 @@ +;; -*- no-byte-compile: t; -*- +;;; lang/dart/packages.el + +(package! dart-mode) +(when (featurep! +flutter) + (package! flutter)) From ac4961163c578c0e7df0551c24c0db229d569a41 Mon Sep 17 00:00:00 2001 From: "sevensidedmarble (Andrew Stewart)" Date: Mon, 17 Feb 2020 10:12:23 -0500 Subject: [PATCH 2/7] Add README.org --- modules/lang/dart/README.org | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 modules/lang/dart/README.org diff --git a/modules/lang/dart/README.org b/modules/lang/dart/README.org new file mode 100644 index 000000000..5047e6353 --- /dev/null +++ b/modules/lang/dart/README.org @@ -0,0 +1,62 @@ +#+TITLE: lang/dart +#+DATE: February 16, 2020 +#+SINCE: February 16, 2020 +#+STARTUP: inlineimages nofold + +* Table of Contents :TOC_3:noexport: +- [[#description][Description]] + - [[#maintainers][Maintainers]] + - [[#module-flags][Module Flags]] + - [[#plugins][Plugins]] +- [[#prerequisites][Prerequisites]] +- [[#features][Features]] +- [[#configuration][Configuration]] + - [[#dart--flutter][Dart & Flutter]] + - [[#android][Android]] +- [[#troubleshooting][Troubleshooting]] + +* Description +The `dart` module wraps `dart-mode`, with LSP code completion for `.dart` files, +syntax highlighting, etc. Included is a `+lsp` flag for enabling LSP features, +and a `+flutter` flag for working with Flutter. + +** Maintainers ++ @sevensidedmarble (Author) + +** Module Flags ++ =+lsp= Will start LSP automatically in `dart-mode-hook`. ++ =+flutter= Adds the `flutter` package and some settings for Flutter development. + +** Plugins ++ [[https://github.com/bradyt/dart-mode][dart-mode]] ++ [[https://github.com/amake/flutter.el][flutter.el]] + +* Prerequisites +Make sure that the Dart SDK is on your `PATH`, and if using Flutter, make sure +the Flutter binary is on your `PATH` as well. + +* Features ++ Syntax highlighting and formatting for `.dart` files provided by LSP ++ Emacs functions for running and debugging Flutter projects + +* Configuration +** Dart & Flutter +On Linux, the installers for Dart and Flutter use the `/opt` directory, and this +module assumes that. However, you may set `lsp-dart-sdk-dir` to your Dart +install directory, if it differs, to make sure LSP can find the language server +included with the Dart SDK. + +Alternatively, these variables shouldn't be necessary if you just include Dart +and Flutter on your `PATH` variable. +** Android +You will also need to setup your system for Android development if you intend to +use Flutter to develop mobile applications. Refer to your distributions package +manager for details. In most distributions the `/opt/android-sdk` directory is +used, and you might have to change some permissions in this directory since it's +owned by root. The [[https://wiki.archlinux.org/index.php/Android][Arch Linux wiki has a great guide on this here.]] + +* Troubleshooting +See the configuration section for information on the binaries for Dart and +Flutter. On new installs to the `/opt` directory, you will likely need to edit +the permissions of the `/opt/dart-sdk` and `/opt/flutter` directories (not to +mention the Android SDK, as discussed above). From aefb0672b4f41ae284dad753f86143c6f35fcad6 Mon Sep 17 00:00:00 2001 From: "sevensidedmarble (Andrew Stewart)" Date: Mon, 17 Feb 2020 10:12:43 -0500 Subject: [PATCH 3/7] Reformat configuration --- modules/lang/dart/+flutter.el | 7 ------- modules/lang/dart/config.el | 20 +++++++++++++------- 2 files changed, 13 insertions(+), 14 deletions(-) delete mode 100644 modules/lang/dart/+flutter.el diff --git a/modules/lang/dart/+flutter.el b/modules/lang/dart/+flutter.el deleted file mode 100644 index f31283902..000000000 --- a/modules/lang/dart/+flutter.el +++ /dev/null @@ -1,7 +0,0 @@ -;;; lang/dart/+flutter.el -*- lexical-binding: t; -*- - -(use-package! flutter - :config - (map! :map dart-mode-map - :localleader - "r" #'flutter-run-or-hot-reload)) diff --git a/modules/lang/dart/config.el b/modules/lang/dart/config.el index fc574a62e..95a0e2bef 100644 --- a/modules/lang/dart/config.el +++ b/modules/lang/dart/config.el @@ -1,12 +1,18 @@ ;;; lang/dart/config.el -*- lexical-binding: t; -*- -(cond ((featurep! +flutter) (load! "+flutter")) - ((featurep! +lsp) (load! "+lsp"))) - (use-package! dart-mode + :defer t :config - (when (featurep! +flutter) - (if IS-LINUX - (setq lsp-dart-sdk-dir "/opt/flutter/bin/cache/dart-sdk/"))) + (when (and (featurep! +flutter) IS-LINUX) + (setq lsp-dart-sdk-dir "/opt/flutter/bin/cache/dart-sdk/")) (when (featurep! +lsp) - (add-hook 'dart-mode-hook 'lsp))) + (add-hook 'dart-mode-local-vars-hook #'lsp!))) + + +(when (featurep! +flutter) + (use-package! flutter + :defer t + :config + (map! :map dart-mode-map + :localleader + "r" #'flutter-run-or-hot-reload))) From 2b47b1e99acc6cd5c339545e17df374ee8ad2bee Mon Sep 17 00:00:00 2001 From: "M. Yas. Davoodeh" Date: Mon, 16 Mar 2020 00:02:16 +0330 Subject: [PATCH 4/7] Fixed issues addressed by @hlissner on #2549. --- modules/lang/dart/README.org | 52 +++++++++++++++++++++++++++++++---- modules/lang/dart/config.el | 28 +++++++++---------- modules/lang/dart/doctor.el | 6 ++-- modules/lang/dart/packages.el | 4 +-- 4 files changed, 67 insertions(+), 23 deletions(-) diff --git a/modules/lang/dart/README.org b/modules/lang/dart/README.org index 5047e6353..df26b4e64 100644 --- a/modules/lang/dart/README.org +++ b/modules/lang/dart/README.org @@ -1,6 +1,6 @@ #+TITLE: lang/dart #+DATE: February 16, 2020 -#+SINCE: February 16, 2020 +#+SINCE: v3.0.0 #+STARTUP: inlineimages nofold * Table of Contents :TOC_3:noexport: @@ -9,6 +9,8 @@ - [[#module-flags][Module Flags]] - [[#plugins][Plugins]] - [[#prerequisites][Prerequisites]] + - [[#installing-dart-sdk][Installing Dart SDK]] + - [[#installing-flutter-sdk][Installing Flutter SDK]] - [[#features][Features]] - [[#configuration][Configuration]] - [[#dart--flutter][Dart & Flutter]] @@ -16,14 +18,18 @@ - [[#troubleshooting][Troubleshooting]] * Description +[[https://dart.dev/][Dart]] is a client-optimized language by Google for fast apps on any platform. +It is fast and optimized for UI, Famous for the [[https://flutter.io/][Flutter]] framework, also +made by Google. Both Flutter and Dart are free and open-source. + +** Maintainers +This module has no dedicated maintainers. + +** Module Flags The `dart` module wraps `dart-mode`, with LSP code completion for `.dart` files, syntax highlighting, etc. Included is a `+lsp` flag for enabling LSP features, and a `+flutter` flag for working with Flutter. -** Maintainers -+ @sevensidedmarble (Author) - -** Module Flags + =+lsp= Will start LSP automatically in `dart-mode-hook`. + =+flutter= Adds the `flutter` package and some settings for Flutter development. @@ -35,6 +41,42 @@ and a `+flutter` flag for working with Flutter. Make sure that the Dart SDK is on your `PATH`, and if using Flutter, make sure the Flutter binary is on your `PATH` as well. +** Installing Dart SDK +Before starting note that Flutter SDK will have a version of Dart. Therefore, +there is no need to install Dart. If you want to use Flutter just see +the next part. + +The stable version of the SDK is in most major distributions repositories. +If you find it necessary to install any other version or build from source, +please refer to the official website at: https://dart.dev/get-dart + +On Debian (also Ubuntu and its derivations), you can simply install the SDK via: +#+BEGIN_SRC shell +sudo apt-get install dart +#+END_SRC +Or on Arch (and its derivations, like Manjaro), you can install it using: +#+BEGIN_SRC shell +sudo pacman -S dart +#+END_SRC +And finally in MacOS, the [[https://brew.sh/][Homebrew]] can come in handy. If you have it installed +just run: +#+BEGIN_SRC shell +brew tap dart-lang/dart +brew install dart#+END_SRC +#+END_SRC + +** Installing Flutter SDK +Due to complications with permissions, it is suggested not to use AUR or any +automatic installation tools for Flutter SDK. + +On any system just run the following commands to install Flutter, once you have +met dependencies named on [[https://flutter.dev/docs/get-started/install/][the site]]: +#+BEGIN_SRC shell +git clone https://github.com/flutter/flutter --branch stable # to download Flutter +export PATH="$PATH:$(pwd)/flutter/bin" # to add it to PATH +flutter doctor # for Dependency check and further instructions +#+END_SRC + * Features + Syntax highlighting and formatting for `.dart` files provided by LSP + Emacs functions for running and debugging Flutter projects diff --git a/modules/lang/dart/config.el b/modules/lang/dart/config.el index 95a0e2bef..5c7b633f1 100644 --- a/modules/lang/dart/config.el +++ b/modules/lang/dart/config.el @@ -1,18 +1,18 @@ ;;; lang/dart/config.el -*- lexical-binding: t; -*- -(use-package! dart-mode +(after! dart-mode + (when (featurep! +lsp) + (add-hook 'dart-mode-local-vars-hook #'lsp!) + (when (and (featurep! +flutter) IS-LINUX) + (when-let (path (doom-glob "/opt/flutter/bin/cache/dart-sdk")) + (setq lsp-dart-sdk-dir path))))) + + + +(use-package! flutter + :when (featurep! +flutter) :defer t :config - (when (and (featurep! +flutter) IS-LINUX) - (setq lsp-dart-sdk-dir "/opt/flutter/bin/cache/dart-sdk/")) - (when (featurep! +lsp) - (add-hook 'dart-mode-local-vars-hook #'lsp!))) - - -(when (featurep! +flutter) - (use-package! flutter - :defer t - :config - (map! :map dart-mode-map - :localleader - "r" #'flutter-run-or-hot-reload))) + (map! :map dart-mode-map + :localleader + "r" #'flutter-run-or-hot-reload)) diff --git a/modules/lang/dart/doctor.el b/modules/lang/dart/doctor.el index aa68b7bce..521eddc32 100644 --- a/modules/lang/dart/doctor.el +++ b/modules/lang/dart/doctor.el @@ -7,5 +7,7 @@ (unless (executable-find "dart") (warn! "Dart isn't on PATH.")) -(unless (file-readable-p lsp-dart-sdk-dir) - (warn! "LSP Mode can't find lsp-dart-sdk-dir.")) +(when (featurep! +lsp) + (require 'dart-mode) + (unless (file-readable-p lsp-dart-sdk-dir) + (warn! "LSP Mode can't find lsp-dart-sdk-dir."))) diff --git a/modules/lang/dart/packages.el b/modules/lang/dart/packages.el index 2116e665c..e1464b17f 100644 --- a/modules/lang/dart/packages.el +++ b/modules/lang/dart/packages.el @@ -1,6 +1,6 @@ ;; -*- no-byte-compile: t; -*- ;;; lang/dart/packages.el -(package! dart-mode) +(package! dart-mode :pin "04fcd649f1") (when (featurep! +flutter) - (package! flutter)) + (package! flutter :pin "ec92a4df84")) From e43e9fadb98a52f2dc932d37a98616765b66dd45 Mon Sep 17 00:00:00 2001 From: "M. Yas. Davoodeh" Date: Tue, 24 Mar 2020 13:45:36 +0430 Subject: [PATCH 5/7] Added Dart-Snippets from GitHub. --- modules/lang/dart/packages.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/lang/dart/packages.el b/modules/lang/dart/packages.el index e1464b17f..b3e9f698a 100644 --- a/modules/lang/dart/packages.el +++ b/modules/lang/dart/packages.el @@ -2,5 +2,17 @@ ;;; lang/dart/packages.el (package! dart-mode :pin "04fcd649f1") + +;; Optional module features + (when (featurep! +flutter) (package! flutter :pin "ec92a4df84")) + +;; Features according to other user selected options + +(when (featurep! :editor snippets) + (package! dart-snippets + :recipe (:host github + :repo "MYDavoodeh/dart-snippets" + :files ("*.el" ("snippets" "snippets/*"))) + :pin "87ccb4defd")) From 7d829eaa48e68c29a8d227cbcb1a91d8401efcb7 Mon Sep 17 00:00:00 2001 From: "M. Yas. Davoodeh" Date: Tue, 24 Mar 2020 18:48:18 +0430 Subject: [PATCH 6/7] Final pin. --- modules/lang/dart/packages.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lang/dart/packages.el b/modules/lang/dart/packages.el index b3e9f698a..c11f8a62f 100644 --- a/modules/lang/dart/packages.el +++ b/modules/lang/dart/packages.el @@ -15,4 +15,4 @@ :recipe (:host github :repo "MYDavoodeh/dart-snippets" :files ("*.el" ("snippets" "snippets/*"))) - :pin "87ccb4defd")) + :pin "946ad5aaa5")) From 49a21720f887ccb463fa2be0183a16deea93e9c8 Mon Sep 17 00:00:00 2001 From: "M. Yas. Davoodeh" Date: Thu, 26 Mar 2020 00:20:59 +0430 Subject: [PATCH 7/7] Removed the snippet pkg since they're in Doom's. --- modules/lang/dart/packages.el | 9 --------- 1 file changed, 9 deletions(-) diff --git a/modules/lang/dart/packages.el b/modules/lang/dart/packages.el index c11f8a62f..71975f46f 100644 --- a/modules/lang/dart/packages.el +++ b/modules/lang/dart/packages.el @@ -7,12 +7,3 @@ (when (featurep! +flutter) (package! flutter :pin "ec92a4df84")) - -;; Features according to other user selected options - -(when (featurep! :editor snippets) - (package! dart-snippets - :recipe (:host github - :repo "MYDavoodeh/dart-snippets" - :files ("*.el" ("snippets" "snippets/*"))) - :pin "946ad5aaa5"))