File: lsp-actionscript.el

package info (click to toggle)
lsp-mode 9.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 22,472 kB
  • sloc: lisp: 27,961; makefile: 62; java: 34; cpp: 33; javascript: 31; xml: 23; python: 14; sh: 2
file content (121 lines) | stat: -rw-r--r-- 4,283 bytes parent folder | download
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
;;; lsp-actionscript.el --- ActionScript Client settings         -*- lexical-binding: t; -*-

;; Copyright (C) 2021  Jen-Chieh Shen

;; Author: Jen-Chieh Shen <jcs090218@gmail.com>
;; Keywords: actionscript lsp

;; 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 client for ActionScript

;;; Code:

(require 'lsp-mode)

(defgroup lsp-actionscript nil
  "LSP support for ActionScript."
  :group 'lsp-mode
  :link '(url-link "https://github.com/BowlerHatLLC/vscode-as3mxml")
  :package-version `(lsp-mode . "8.0.0"))

(defcustom lsp-actionscript-java-path "java"
  "Path of the java executable."
  :group 'lsp-actionscript
  :type 'string)

(defcustom lsp-actionscript-sdk-path ""
  "Path to supported SDK.
See https://github.com/BowlerHatLLC/vscode-as3mxml/wiki/Choose-an-ActionScript-SDK-for-the-current-workspace-in-Visual-Studio-Code."
  :type 'string
  :group 'lsp-actionscript
  :package-version '(lsp-mode . "8.0.0"))

(defcustom lsp-actionscript-version "1.5.0"
  "Version of ActionScript language server."
  :type 'string
  :group 'lsp-actionscript
  :package-version '(lsp-mode . "8.0.0"))

(defcustom lsp-actionscript-extension-name
  (format "vscode-nextgenas-%s.vsix" lsp-actionscript-version)
  "File name of the extension file from language server."
  :type 'string
  :group 'lsp-actionscript
  :package-version '(lsp-mode . "8.0.0"))

(defcustom lsp-actionscript-server-download-url
  (format "https://github.com/BowlerHatLLC/vscode-as3mxml/releases/download/v%s/%s"
          lsp-actionscript-version lsp-actionscript-extension-name)
  "Automatic download url for lsp-actionscript."
  :type 'string
  :group 'lsp-actionscript
  :package-version '(lsp-mode . "8.0.0"))

(defcustom lsp-actionscript-server-store-path
  (f-join lsp-server-install-dir "as3mxml")
  "The path to the file in which `lsp-actionscript' will be stored."
  :type 'file
  :group 'lsp-actionscript
  :package-version '(lsp-mode . "8.0.0"))

(defcustom lsp-actionscript-option-charset "UTF8"
  "The charset to use by the ActionScript Language server."
  :type 'string
  :group 'lsp-actionscript
  :package-version '(lsp-mode . "8.0.0"))

(defun lsp-actionscript--extension-path ()
  "Return full path of the downloaded extension."
  (f-join lsp-actionscript-server-store-path lsp-actionscript-extension-name))

(defun lsp-actionscript--extension-dir ()
  "Return as3mxml extension path."
  (f-join lsp-actionscript-server-store-path "extension"))

(defun lsp-actionscript--server-command ()
  "Startup command for ActionScript language server."
  (list lsp-actionscript-java-path
        (format "-Droyalelib=%s" lsp-actionscript-sdk-path)
        (format "-Dfile.encoding=%s" lsp-actionscript-option-charset)
        "-cp"
        (format "%s/bundled-compiler/*;%s/bin/*"
                (lsp-actionscript--extension-dir) (lsp-actionscript--extension-dir))
        "com.as3mxml.vscode.Main"))

(lsp-dependency
 'as3mxml
 '(:system "as3mxml")
 `(:download :url lsp-actionscript-server-download-url
             :decompress :zip
             :store-path ,(f-no-ext (lsp-actionscript--extension-path))
             :set-executable? t))

(lsp-register-client
 (make-lsp-client
  :new-connection (lsp-stdio-connection
                   #'lsp-actionscript--server-command
                   (lambda () (f-exists? (lsp-actionscript--extension-dir))))
  :major-modes '(actionscript-mode)
  :priority -1
  :server-id 'as3mxml-ls
  :download-server-fn (lambda (_client callback error-callback _update?)
                        (lsp-package-ensure 'as3mxml callback error-callback))))

(lsp-consistency-check lsp-actionscript)

(provide 'lsp-actionscript)
;;; lsp-actionscript.el ends here