-
Notifications
You must be signed in to change notification settings - Fork 24
/
lsp-dart-commands.el
90 lines (75 loc) · 2.94 KB
/
lsp-dart-commands.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
;;; lsp-dart-commands.el --- LSP dart commands -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2022 Eric Dallo
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;
;;; Commentary:
;;
;; LSP dart commands
;;
;;; Code:
(require 'lsp-dart-utils)
(defconst lsp-dart-commands-buffer-name "*LSP Dart commands*")
(defun lsp-dart--run-command (command args)
"Run COMMAND with ARGS from the project root."
(lsp-dart-from-project-root
(compilation-start (format "%s %s" (string-join command " ") args)
t
(lambda (_) lsp-dart-commands-buffer-name))))
(defun lsp-dart--pub-get ()
"Run `pub get` from the root project."
(lsp-dart--run-command (lsp-dart-pub-command) "get"))
(defun lsp-dart--flutter-pub-get ()
"Run `flutter pub get` from the root project."
(lsp-dart--run-command (lsp-dart-flutter-command) "pub get"))
(defun lsp-dart--pub-upgrade ()
"Run `pub upgrade` from the root project."
(lsp-dart--run-command (lsp-dart-pub-command) "upgrade"))
(defun lsp-dart--flutter-pub-upgrade ()
"Run `flutter pub upgrade` from the root project."
(lsp-dart--run-command (lsp-dart-flutter-command) "pub upgrade"))
(defun lsp-dart--pub-outdated ()
"Run `pub outdated` from the root project."
(lsp-dart--run-command (lsp-dart-pub-command) "outdated"))
(defun lsp-dart--flutter-pub-outdated ()
"Run `flutter pub outdated` from the root project."
(lsp-dart--run-command (lsp-dart-flutter-command) "pub outdated"))
;;;###autoload
(defun lsp-dart-pub-get ()
"Run pub get on a Dart or Flutter project.
If it is Flutter project, run `flutter pub get` otherwise run
`pub get`."
(interactive)
(if (lsp-dart-flutter-project-p)
(lsp-dart--flutter-pub-get)
(lsp-dart--pub-get)))
;;;###autoload
(defun lsp-dart-pub-upgrade ()
"Run pub upgrade on a Dart or Flutter project.
If it is Flutter project, run `flutter pub upgrade` otherwise run
`pub upgrade`."
(interactive)
(if (lsp-dart-flutter-project-p)
(lsp-dart--flutter-pub-upgrade)
(lsp-dart--pub-upgrade)))
;;;###autoload
(defun lsp-dart-pub-outdated ()
"Run pub outdated on a Dart or Flutter project.
If it is Flutter project, run `flutter pub outdated` otherwise run
`pub outdated`."
(interactive)
(if (lsp-dart-flutter-project-p)
(lsp-dart--flutter-pub-outdated)
(lsp-dart--pub-outdated)))
(provide 'lsp-dart-commands)
;;; lsp-dart-commands.el ends here