[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dart-mode 6397b3d 115/192: Clean up the way the SDK is con
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dart-mode 6397b3d 115/192: Clean up the way the SDK is configured |
Date: |
Sun, 29 Aug 2021 11:02:01 -0400 (EDT) |
branch: elpa/dart-mode
commit 6397b3dfd6eeafc6de22c11a0b66ba8e6b276bc1
Author: Natalie Weizenbaum <nex342@gmail.com>
Commit: Natalie Weizenbaum <nex342@gmail.com>
Clean up the way the SDK is configured
---
CHANGELOG.md | 14 ++++++++++--
README.md | 12 ++++++++++
dart-mode.el | 73 +++++++++++++++++++++++++++++++++++-------------------------
3 files changed, 67 insertions(+), 32 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 302b2c3..845c80d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,7 @@
## 1.0.0
+### Additions
+
* Added a `dart-show-hover` command bound to `C-c ?` which displays information
about the Dart API under the cursor.
@@ -23,5 +25,13 @@
`dart-expand-parameters` command bound to `M-?` which inserts the parameter
list for the chosen completion.
-* `dart-executable-path`'s default value is now set correctly even if the
- executable named `dart` on the user's path is a symlink or a wrapper script.
+* Added a `dart-sdk-path` variable.
+
+### Replacements
+
+* `dart-executable-path` is now a function rather than a variable, so that it
+ updates when `dart-sdk-path` is updated.
+
+### Removals
+
+* The `dart-analysis-server-snapshot-path` variable has been removed.
diff --git a/README.md b/README.md
index fbbc4b5..2b4472f 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
`dart-mode` is a major mode for editing Dart files in Emacs.
* [Installation](#installation)
+ * [General Configuration](#general-configuration)
* [Dart Analyzer](#dart-analyzer)
* [Error Checking](#error-checking)
* [Seeing Information](#seeing-information)
@@ -19,6 +20,17 @@
M-x package-install [RET] dart-mode
```
+### General Configuration
+
+The `dart-sdk-path` variable can be set to tell Emacs where to find the Dart
+SDK. This is used to run the [Dart analysis server](#dart-analyzer) and the
Dart
+formatter. By default, it's set by finding the `dart` executable on the system
+path.
+
+Note that user code that wants to run Dart scripts can use the
+`dart-executable-path` function to locate the `dart` executable itself in the
+SDK's `bin/` directory.
+
## Dart Analyzer
`dart-mode` supports the Dart analysis server, which runs in the background and
diff --git a/dart-mode.el b/dart-mode.el
index 1a1814d..1dde417 100644
--- a/dart-mode.el
+++ b/dart-mode.el
@@ -253,6 +253,41 @@ Any stderr is logged using dart-log. Returns nil if the
exit code is non-0."
(if (eq (nth 2 result) 0) (nth 0 result))))
+;;; General configuration
+
+(defcustom dart-sdk-path
+ ;; Use Platform.resolvedExecutable so that this logic works through symlinks
+ ;; and wrapper scripts.
+ (-when-let (dart (executable-find "dart"))
+ (dart--with-temp-file input
+ (with-temp-file input (insert "
+ import 'dart:io';
+
+ void main() {
+ print(Platform.resolvedExecutable);
+ }
+ "))
+ (-when-let (result (dart--try-process dart input))
+ (file-name-directory
+ (directory-file-name
+ (file-name-directory (string-trim result)))))))
+ "The absolute path to the root of the Dart SDK."
+ :group 'dart-mode
+ :type 'directory
+ :package-version '(dart-mode . "1.0.0"))
+
+(defun dart-executable-path ()
+ "The absolute path to the 'dart' executable.
+
+Returns nil if `dart-sdk-path' is nil."
+ (when dart-sdk-path
+ (concat dart-sdk-path
+ (file-name-as-directory "bin")
+ (if (memq system-type '(ms-dos windows-nt))
+ "dart.exe"
+ "dart"))))
+
+
;;; CC configuration
(c-lang-defconst c-symbol-start
@@ -703,34 +738,13 @@ navigation, and more."
(defvar dart--analysis-server nil
"The instance of the Dart analysis server we are communicating with.")
-(defcustom dart-executable-path
- ;; Use Platform.resolvedExecutable so that this logic works through symlinks
- ;; and wrapper scripts.
- (-when-let (dart (executable-find "dart"))
- (dart--with-temp-file input
- (with-temp-file input (insert "
- import 'dart:io';
-
- void main() {
- print(Platform.resolvedExecutable);
- }
- "))
- (-when-let (result (dart--try-process dart input))
- (string-trim result))))
- "The absolute path to the 'dart' executable."
- :group 'dart-mode
- :type 'file
- :package-version '(dart-mode . "1.0.0"))
-
-(defcustom dart-analysis-server-snapshot-path
- (when dart-executable-path
- (concat (file-name-directory dart-executable-path)
+(defun dart--analysis-server-snapshot-path ()
+ (when dart-sdk-path
+ (concat dart-sdk-path
+ (file-name-as-directory "bin")
(file-name-as-directory "snapshots")
"analysis_server.dart.snapshot"))
- "The absolute path to the snapshot file that runs the Dart analysis server."
- :group 'dart-mode
- :type 'file
- :package-version '(dart-mode . "0.12"))
+ "The absolute path to the snapshot file that runs the Dart analysis server.")
(defvar dart-analysis-roots nil
"The list of analysis roots that are known to the analysis server.
@@ -796,8 +810,8 @@ directory or the current file directory to the analysis
roots."
(dart-process
(start-process "dart-analysis-server"
"*dart-analysis-server*"
- dart-executable-path
- dart-analysis-server-snapshot-path
+ (dart-executable-path)
+ (dart--analysis-server-snapshot-path)
"--no-error-notification")))
(set-process-query-on-exit-flag dart-process nil)
(setq dart--analysis-server
@@ -1808,8 +1822,7 @@ Key bindings:
(c-common-init 'dart-mode)
(c-set-style "dart")
(when dart-enable-analysis-server
- (if (or (null dart-executable-path)
- (null dart-analysis-server-snapshot-path))
+ (if (null dart-sdk-path)
(dart-log
"Cannot find `dart' executable or Dart analysis server snapshot.")
(dart--start-analysis-server-for-current-buffer)))
- [nongnu] elpa/dart-mode eca3f15 105/192: Add the ability to autocomplete parameters, (continued)
- [nongnu] elpa/dart-mode eca3f15 105/192: Add the ability to autocomplete parameters, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode d333a73 102/192: Add an analyzer-based auto-complete, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode d507fa1 101/192: Add a binding to re-run searches, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode a2ab55b 114/192: Make more thorough use of dash, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode c11d02a 137/192: Remedy invalid file path format, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 8f972c0 097/192: Add support for finding references, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 848f983 104/192: Show docs for expansions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 6bc08f7 136/192: Adds failing test against dart dev, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 9c9a63e 130/192: Fix dart-format, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1f27d03 119/192: Properly set up font-lock variables, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 6397b3d 115/192: Clean up the way the SDK is configured,
ELPA Syncer <=
- [nongnu] elpa/dart-mode e9cd33d 109/192: Use proper private name convention, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode a087c75 099/192: Add a result counter in search results, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 847707d 129/192: Require final newline, like dartfmt, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 570e58c 116/192: Refactor formatter support, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode d4da484 126/192: Removes nil c-syntactic-context (#56), ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 7c28c58 131/192: Add Travis-CI and Cask, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode adef2a5 118/192: Be more resilient to server crashes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 61f334c 149/192: Improves indentation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 47dc5a0 146/192: Fixes flycheck in Windows, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 6e1c42f 156/192: Fontify string interpolation, ELPA Syncer, 2021/08/29