config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

lsp-actionscript.el (4283B)


      1 ;;; lsp-actionscript.el --- ActionScript Client settings         -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2021  Jen-Chieh Shen
      4 
      5 ;; Author: Jen-Chieh Shen <jcs090218@gmail.com>
      6 ;; Keywords: actionscript lsp
      7 
      8 ;; This program is free software; you can redistribute it and/or modify
      9 ;; it under the terms of the GNU General Public License as published by
     10 ;; the Free Software Foundation, either version 3 of the License, or
     11 ;; (at your option) any later version.
     12 
     13 ;; This program is distributed in the hope that it will be useful,
     14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 ;; GNU General Public License for more details.
     17 
     18 ;; You should have received a copy of the GNU General Public License
     19 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
     20 
     21 ;;; Commentary:
     22 
     23 ;; LSP client for ActionScript
     24 
     25 ;;; Code:
     26 
     27 (require 'lsp-mode)
     28 
     29 (defgroup lsp-actionscript nil
     30   "LSP support for ActionScript."
     31   :group 'lsp-mode
     32   :link '(url-link "https://github.com/BowlerHatLLC/vscode-as3mxml")
     33   :package-version `(lsp-mode . "8.0.0"))
     34 
     35 (defcustom lsp-actionscript-java-path "java"
     36   "Path of the java executable."
     37   :group 'lsp-actionscript
     38   :type 'string)
     39 
     40 (defcustom lsp-actionscript-sdk-path ""
     41   "Path to supported SDK.
     42 See https://github.com/BowlerHatLLC/vscode-as3mxml/wiki/Choose-an-ActionScript-SDK-for-the-current-workspace-in-Visual-Studio-Code."
     43   :type 'string
     44   :group 'lsp-actionscript
     45   :package-version '(lsp-mode . "8.0.0"))
     46 
     47 (defcustom lsp-actionscript-version "1.5.0"
     48   "Version of ActionScript language server."
     49   :type 'string
     50   :group 'lsp-actionscript
     51   :package-version '(lsp-mode . "8.0.0"))
     52 
     53 (defcustom lsp-actionscript-extension-name
     54   (format "vscode-nextgenas-%s.vsix" lsp-actionscript-version)
     55   "File name of the extension file from language server."
     56   :type 'string
     57   :group 'lsp-actionscript
     58   :package-version '(lsp-mode . "8.0.0"))
     59 
     60 (defcustom lsp-actionscript-server-download-url
     61   (format "https://github.com/BowlerHatLLC/vscode-as3mxml/releases/download/v%s/%s"
     62           lsp-actionscript-version lsp-actionscript-extension-name)
     63   "Automatic download url for lsp-actionscript."
     64   :type 'string
     65   :group 'lsp-actionscript
     66   :package-version '(lsp-mode . "8.0.0"))
     67 
     68 (defcustom lsp-actionscript-server-store-path
     69   (f-join lsp-server-install-dir "as3mxml")
     70   "The path to the file in which `lsp-actionscript' will be stored."
     71   :type 'file
     72   :group 'lsp-actionscript
     73   :package-version '(lsp-mode . "8.0.0"))
     74 
     75 (defcustom lsp-actionscript-option-charset "UTF8"
     76   "The charset to use by the ActionScript Language server."
     77   :type 'string
     78   :group 'lsp-actionscript
     79   :package-version '(lsp-mode . "8.0.0"))
     80 
     81 (defun lsp-actionscript--extension-path ()
     82   "Return full path of the downloaded extension."
     83   (f-join lsp-actionscript-server-store-path lsp-actionscript-extension-name))
     84 
     85 (defun lsp-actionscript--extension-dir ()
     86   "Return as3mxml extension path."
     87   (f-join lsp-actionscript-server-store-path "extension"))
     88 
     89 (defun lsp-actionscript--server-command ()
     90   "Startup command for ActionScript language server."
     91   (list lsp-actionscript-java-path
     92         (format "-Droyalelib=%s" lsp-actionscript-sdk-path)
     93         (format "-Dfile.encoding=%s" lsp-actionscript-option-charset)
     94         "-cp"
     95         (format "%s/bundled-compiler/*;%s/bin/*"
     96                 (lsp-actionscript--extension-dir) (lsp-actionscript--extension-dir))
     97         "com.as3mxml.vscode.Main"))
     98 
     99 (lsp-dependency
    100  'as3mxml
    101  '(:system "as3mxml")
    102  `(:download :url lsp-actionscript-server-download-url
    103              :decompress :zip
    104              :store-path ,(f-no-ext (lsp-actionscript--extension-path))
    105              :set-executable? t))
    106 
    107 (lsp-register-client
    108  (make-lsp-client
    109   :new-connection (lsp-stdio-connection
    110                    #'lsp-actionscript--server-command
    111                    (lambda () (f-exists? (lsp-actionscript--extension-dir))))
    112   :major-modes '(actionscript-mode)
    113   :priority -1
    114   :server-id 'as3mxml-ls
    115   :download-server-fn (lambda (_client callback error-callback _update?)
    116                         (lsp-package-ensure 'as3mxml callback error-callback))))
    117 
    118 (lsp-consistency-check lsp-actionscript)
    119 
    120 (provide 'lsp-actionscript)
    121 ;;; lsp-actionscript.el ends here