config

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

lsp-lua.el (24475B)


      1 ;;; lsp-lua.el --- description -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2020 E. Alexander Barbosa
      4 
      5 ;; Author: E. Alexander Barbosa <elxbarbosa@outlook.com>
      6 ;; Keywords:
      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 Clients for the Lua Programming Language
     24 
     25 ;;; Code:
     26 
     27 (require 'lsp-mode)
     28 (require 'f)
     29 (require 'files)
     30 
     31 (defgroup lsp-emmy-lua nil
     32   "Lua LSP client, provided by the EmmyLua Language Server."
     33   :group 'lsp-mode
     34   :version "8.0.0"
     35   :link '(url-link "https://github.com/EmmyLua/EmmyLua-LanguageServer"))
     36 
     37 (defcustom lsp-clients-emmy-lua-java-path "java"
     38   "Java Runtime binary location."
     39   :group 'lsp-emmy-lua
     40   :version "8.0.0"
     41   :risky t
     42   :type 'file)
     43 
     44 (defcustom lsp-clients-emmy-lua-jar-path (f-join lsp-server-install-dir "EmmyLua-LS-all.jar")
     45   "Emmy Lua language server jar file."
     46   :group 'lsp-emmy-lua
     47   :version "8.0.0"
     48   :risky t
     49   :type 'file)
     50 
     51 (defcustom lsp-clients-emmy-lua-args '("-jar")
     52   "Arguments to the Lua Language server."
     53   :group 'lsp-emmy-lua
     54   :version "8.0.0"
     55   :risky t
     56   :type  '(repeat string))
     57 
     58 (defcustom lsp-clients-emmy-lua-command nil
     59   "Final command to call the Lua Language server."
     60   :group 'lsp-emmy-lua
     61   :version "8.0.0"
     62   :risky t
     63   :type '(repeat string))
     64 
     65 (defun lsp-clients-emmy-lua-test ()
     66   "Test the Emmy Lua binaries and files."
     67   (and (executable-find lsp-clients-emmy-lua-java-path)
     68        (f-exists? lsp-clients-emmy-lua-jar-path)))
     69 
     70 (lsp-register-client
     71  (make-lsp-client
     72   :new-connection (lsp-stdio-connection (lambda () (or lsp-clients-emmy-lua-command
     73                                                        `(,lsp-clients-emmy-lua-java-path
     74                                                          ,@lsp-clients-emmy-lua-args
     75                                                          ,lsp-clients-emmy-lua-jar-path)))
     76                                         #'lsp-clients-emmy-lua-test)
     77   :activation-fn (lsp-activate-on "lua")
     78   :server-id 'emmy-lua
     79   :priority -1
     80   :notification-handlers (lsp-ht ("emmy/progressReport" #'ignore))))
     81 
     82 
     83 ;;; lua-language-server
     84 (defgroup lsp-lua-language-server nil
     85   "Lua LSP client, provided by the Lua Language Server."
     86   :group 'lsp-mode
     87   :version "8.0.0"
     88   :link '(url-link "https://github.com/sumneko/lua-language-server"))
     89 
     90 (defcustom lsp-clients-lua-language-server-install-dir (f-join lsp-server-install-dir "lua-language-server/")
     91   "Installation directory for Lua Language Server."
     92   :group 'lsp-lua-language-server
     93   :version "8.0.0"
     94   :risky t
     95   :type 'directory)
     96 
     97 (defcustom lsp-clients-lua-language-server-bin
     98   (f-join lsp-clients-lua-language-server-install-dir
     99           "bin/"
    100           (pcase system-type
    101             ('gnu/linux "lua-language-server")
    102             ('darwin "lua-language-server")
    103             ('windows-nt "lua-language-server.exe")
    104             (_ "lua-language-server")))
    105   "Location of Lua Language Server."
    106   :group 'lsp-lua-language-server
    107   :version "8.0.0"
    108   :risky t
    109   :type 'file)
    110 
    111 (defcustom lsp-clients-lua-language-server-main-location
    112   (f-join lsp-clients-lua-language-server-install-dir
    113           "main.lua")
    114   "Location of Lua Language Server main.lua."
    115   :group 'lsp-lua-language-server
    116   :version "8.0.0"
    117   :risky t
    118   :type 'file)
    119 
    120 (defcustom lsp-clients-lua-language-server-args '("-E")
    121   "Arguments to run the Lua Language server."
    122   :group 'lsp-lua-language-server
    123   :version "8.0.0"
    124   :risky t
    125   :type '(repeat string))
    126 
    127 (defcustom lsp-clients-lua-language-server-command nil
    128   "Command to start Lua Language server."
    129   :group 'lsp-lua-language-server
    130   :type '(repeat string))
    131 
    132 
    133 (defun lsp-clients-lua-language-server-test ()
    134   "Test Lua language server binaries and files."
    135   (and (f-exists? lsp-clients-lua-language-server-main-location)
    136        (f-exists? lsp-clients-lua-language-server-bin)))
    137 
    138 (defcustom lsp-lua-color-mode "Semantic"
    139   "Color mode."
    140   :type '(choice (:tag "Grammar" "Semantic"))
    141   :package-version '(lsp-mode . "8.0.0")
    142   :group 'lsp-lua-language-server)
    143 
    144 (defcustom lsp-lua-completion-call-snippet "Disable"
    145   "Shows function call snippets."
    146   :type '(choice (:tag "Disable" "Both" "Replace"))
    147   :package-version '(lsp-mode . "8.0.0")
    148   :group 'lsp-lua-language-server)
    149 
    150 (defcustom lsp-lua-completion-display-context 6
    151   "Previewing the relevant code snippet of the suggestion may help you
    152 understand the usage of the suggestion.
    153 
    154 The number set indicates the number of intercepted lines in the code
    155 fragment.  If it is set to `0`, this feature can be disabled."
    156   :type 'number
    157   :package-version '(lsp-mode . "8.0.0")
    158   :group 'lsp-lua-language-server)
    159 
    160 (defcustom lsp-lua-completion-enable t
    161   "Enable completion."
    162   :type 'boolean
    163   :package-version '(lsp-mode . "8.0.0")
    164   :group 'lsp-lua-language-server)
    165 
    166 (defcustom lsp-lua-completion-keyword-snippet "Replace"
    167   "Shows keyword syntax snippets."
    168   :type '(choice (:tag "Disable" "Both" "Replace"))
    169   :package-version '(lsp-mode . "8.0.0")
    170   :group 'lsp-lua-language-server)
    171 
    172 (defcustom lsp-lua-completion-workspace-word t
    173   "Show words within the workspace."
    174   :type 'boolean
    175   :package-version '(lsp-mode . "8.0.0")
    176   :group 'lsp-lua-language-server)
    177 
    178 (defcustom lsp-lua-develop-debugger-port 11412
    179   "Listen port of debugger."
    180   :type 'number
    181   :package-version '(lsp-mode . "8.0.0")
    182   :group 'lsp-lua-language-server)
    183 
    184 (defcustom lsp-lua-develop-debugger-wait nil
    185   "Suspend before debugger connects."
    186   :type 'boolean
    187   :package-version '(lsp-mode . "8.0.0")
    188   :group 'lsp-lua-language-server)
    189 
    190 (defcustom lsp-lua-develop-enable nil
    191   "Developer mode.  Do not enable, performance will be affected."
    192   :type 'boolean
    193   :package-version '(lsp-mode . "8.0.0")
    194   :group 'lsp-lua-language-server)
    195 
    196 (defcustom lsp-lua-diagnostics-disable nil
    197   "Disabled diagnostic (Use code in hover brackets).
    198 ```json
    199 \"Lua.diagnostics.disable\" : [
    200 \"unused-local\",
    201 \"lowercase-global\"
    202 ]
    203 ```"
    204   :type 'lsp-string-vector
    205   :package-version '(lsp-mode . "8.0.0")
    206   :group 'lsp-lua-language-server)
    207 
    208 (defcustom lsp-lua-diagnostics-enable t
    209   "Enable diagnostics."
    210   :type 'boolean
    211   :package-version '(lsp-mode . "8.0.0")
    212   :group 'lsp-lua-language-server)
    213 
    214 (defcustom lsp-lua-diagnostics-globals nil
    215   "Defined global variables.
    216 ```json
    217 \"Lua.diagnostics.globals\" : [
    218 \"GLOBAL1\",
    219 \"GLOBAL2\"
    220 ]
    221 ```"
    222   :type 'lsp-string-vector
    223   :package-version '(lsp-mode . "8.0.0")
    224   :group 'lsp-lua-language-server)
    225 
    226 (defcustom lsp-lua-diagnostics-needed-file-status nil
    227   "If you want to check only opened files, choice Opened; else choice Any.
    228 ```json
    229 \"Lua.diagnostics.neededFileStatus\" : {
    230 \"ambiguity-1\" : \"Any\",
    231 \"circle-doc-class\" : \"Opened\"
    232 }
    233 ```"
    234   :type 'alist
    235   :package-version '(lsp-mode . "8.0.0")
    236   :group 'lsp-lua-language-server)
    237 
    238 (defcustom lsp-lua-diagnostics-severity nil
    239   "Modified diagnostic severity.
    240 ```json
    241 \"Lua.diagnostics.severity\" : {
    242 \"redefined-local\" : \"Warning\",
    243 \"emmy-lua\" : \"Hint\"
    244 }
    245 ```"
    246   :type 'alist
    247   :package-version '(lsp-mode . "8.0.0")
    248   :group 'lsp-lua-language-server)
    249 
    250 (defcustom lsp-lua-diagnostics-workspace-delay 0
    251   "Latency (milliseconds) for workspace diagnostics. When you start the
    252 workspace, or edit any file, the entire workspace will be re-diagnosed in the
    253 background. Set to negative to disable workspace diagnostics."
    254   :type 'number
    255   :package-version '(lsp-mode . "8.0.0")
    256   :group 'lsp-lua-language-server)
    257 
    258 (defcustom lsp-lua-diagnostics-workspace-rate 100
    259   "Workspace diagnostics run rate (%). Decreasing this value reduces CPU usage,
    260 but also reduces the speed of workspace diagnostics. The diagnosis of the file
    261 you are currently editing is always done at full speed and is not affected by
    262 this setting."
    263   :type 'number
    264   :package-version '(lsp-mode . "8.0.0")
    265   :group 'lsp-lua-language-server)
    266 
    267 (defcustom lsp-lua-hint-enable nil
    268   "Enable hint."
    269   :type 'boolean
    270   :package-version '(lsp-mmode . "8.0.0")
    271   :group 'lsp-lua-language-server)
    272 
    273 (defcustom lsp-lua-hint-param-name t
    274   "Hint parameter name when the parameter called is literal."
    275   :type 'boolean
    276   :package-version '(lsp-mode . "8.0.0")
    277   :group 'lsp-lua-language-server)
    278 
    279 (defcustom lsp-lua-hint-param-type t
    280   "Show type hints at the parameter of the function."
    281   :type 'boolean
    282   :package-version '(lsp-mode . "8.0.0")
    283   :group 'lsp-lua-language-server)
    284 
    285 (defcustom lsp-lua-hint-set-type nil
    286   "Hint type at assignment operation."
    287   :type 'boolean
    288   :package-version '(lsp-mode . "8.0.0")
    289   :group 'lsp-lua-language-server)
    290 
    291 (defcustom lsp-lua-hover-enable t
    292   "Enable hover."
    293   :type 'boolean
    294   :package-version '(lsp-mode . "8.0.0")
    295   :group 'lsp-lua-language-server)
    296 
    297 (defcustom lsp-lua-hover-field-infer 3000
    298   "When hovering to view a table, type infer will be performed for each field.
    299 When the accumulated time of type infer reaches the set value (MS), the type
    300 infer of subsequent fields will be skipped."
    301   :type 'number
    302   :package-version '(lsp-mode . "8.0.0")
    303   :group 'lsp-lua-language-server)
    304 
    305 (defcustom lsp-lua-hover-preview-fields 100
    306   "When hovering to view a table, limits the maximum number of previews for
    307 fields."
    308   :type 'number
    309   :package-version '(lsp-mode . "8.0.0")
    310   :group 'lsp-lua-language-server)
    311 
    312 (defcustom lsp-lua-hover-view-number t
    313   "Hover to view numeric content (only if literal is not decimal)."
    314   :type 'boolean
    315   :package-version '(lsp-mode . "8.0.0")
    316   :group 'lsp-lua-language-server)
    317 
    318 (defcustom lsp-lua-hover-view-string t
    319   "Hover to view the contents of a string (only if the literal contains an
    320 escape character)."
    321   :type 'boolean
    322   :package-version '(lsp-mode . "8.0.0")
    323   :group 'lsp-lua-language-server)
    324 
    325 (defcustom lsp-lua-hover-view-string-max 1000
    326   "The maximum length of a hover to view the contents of a string."
    327   :type 'number
    328   :package-version '(lsp-mode . "8.0.0")
    329   :group 'lsp-lua-language-server)
    330 
    331 (defcustom lsp-lua-intelli-sense-search-depth 0
    332   "Set the search depth for IntelliSense. Increasing this value increases
    333 accuracy, but decreases performance. Different workspace have different
    334 tolerance for this setting. Please adjust it to the appropriate value."
    335   :type 'number
    336   :package-version '(lsp-mode . "8.0.0")
    337   :group 'lsp-lua-language-server)
    338 
    339 (defcustom lsp-lua-runtime-file-encoding "utf8"
    340   "File encoding.  The `ansi' option is only available under the `Windows'
    341 platform."
    342   :type '(choice (:tag "utf8" "ansi"))
    343   :package-version '(lsp-mode . "8.0.0")
    344   :group 'lsp-lua-language-server)
    345 
    346 (defcustom lsp-lua-runtime-nonstandard-symbol nil
    347   "Supports non-standard symbols. Make sure that your runtime environment
    348 supports these symbols."
    349   :type 'lsp-string-vector
    350   :package-version '(lsp-mode . "8.0.0")
    351   :group 'lsp-lua-language-server)
    352 
    353 (defcustom lsp-lua-runtime-path
    354   ["?.lua" "?/init.lua" "?/?.lua"]
    355   "`package.path`."
    356   :type 'lsp-string-vector
    357   :package-version '(lsp-mode . "8.0.0")
    358   :group 'lsp-lua-language-server)
    359 
    360 (defcustom lsp-lua-runtime-plugin nil
    361   "(Proposed) Plugin path. Default is `.vscode/lua/plugin.lua`"
    362   :type 'file
    363   :package-version '(lsp-mode . "8.0.0")
    364   :group 'lsp-lua-language-server)
    365 
    366 (defcustom lsp-lua-runtime-special nil
    367   "The custom global variables are regarded as some special built-in variables,
    368 and the language server will provide special support.
    369 ```json
    370 \"Lua.runtime.special\" : {
    371 \"include\" : \"require\"
    372 }
    373 ```"
    374   :type 'alist
    375   :package-version '(lsp-mode . "8.0.0")
    376   :group 'lsp-lua-language-server)
    377 
    378 (defcustom lsp-lua-runtime-unicode-name nil
    379   "Allows Unicode characters in name."
    380   :type 'boolean
    381   :package-version '(lsp-mode . "8.0.0")
    382   :group 'lsp-lua-language-server)
    383 
    384 (defcustom lsp-lua-runtime-version "Lua 5.4"
    385   "Lua runtime version."
    386   :type '(choice (:tag "Lua 5.1" "Lua 5.2" "Lua 5.3" "Lua 5.4" "LuaJIT"))
    387   :package-version '(lsp-mode . "8.0.0")
    388   :group 'lsp-lua-language-server)
    389 
    390 (defcustom lsp-lua-signature-help-enable t
    391   "Enable signature help."
    392   :type 'boolean
    393   :package-version '(lsp-mode . "8.0.0")
    394   :group 'lsp-lua-language-server)
    395 
    396 (defcustom lsp-lua-telemetry-enable nil
    397   "Enable telemetry to send your editor information and error logs over the
    398 network."
    399   :type 'boolean
    400   :package-version '(lsp-mode . "8.0.0")
    401   :group 'lsp-lua-language-server)
    402 
    403 (defcustom lsp-lua-window-progress-bar t
    404   "Show progress bar in status bar."
    405   :type 'boolean
    406   :package-version '(lsp-mode . "8.0.0")
    407   :group 'lsp-lua-language-server)
    408 
    409 (defcustom lsp-lua-window-status-bar t
    410   "Show extension status in status bar."
    411   :type 'boolean
    412   :package-version '(lsp-mode . "8.0.0")
    413   :group 'lsp-lua-language-server)
    414 
    415 (defcustom lsp-lua-workspace-ignore-dir
    416   [".vscode"]
    417   "Ignored directories (Use `.gitignore` grammar).
    418 ```json
    419 \"Lua.workspace.ignoreDir\" : [
    420 \"temp/*.*\",
    421 \"!temp/*.lua\"
    422 ]
    423 ```"
    424   :type 'lsp-string-vector
    425   :package-version '(lsp-mode . "8.0.0")
    426   :group 'lsp-lua-language-server)
    427 
    428 (defcustom lsp-lua-workspace-ignore-submodules t
    429   "Ignore submodules."
    430   :type 'boolean
    431   :package-version '(lsp-mode . "8.0.0")
    432   :group 'lsp-lua-language-server)
    433 
    434 (defcustom lsp-lua-workspace-library nil
    435   "Load external library.
    436 
    437 This feature can load external Lua files, which can be used for definition,
    438 automatic completion and other functions.  Note that the language server does
    439 not monitor changes in external files and needs to restart if the external
    440 files are modified.  The following example shows loaded files in `C:/lua`
    441 and `../lib` ,exclude `../lib/temp`.
    442 
    443 ```json
    444 \"Lua.workspace.library\": {
    445 \"C:/lua\": true,
    446 \"../lib\": [
    447 \"temp/*\"
    448 ]
    449 }
    450 ```"
    451   :type 'alist
    452   :package-version '(lsp-mode . "8.0.0")
    453   :group 'lsp-lua-language-server)
    454 
    455 (defcustom lsp-lua-workspace-max-preload 1000
    456   "Max preloaded files."
    457   :type 'number
    458   :package-version '(lsp-mode . "8.0.0")
    459   :group 'lsp-lua-language-server)
    460 
    461 (defcustom lsp-lua-workspace-preload-file-size 100
    462   "Skip files larger than this value (KB) when preloading."
    463   :type 'number
    464   :package-version '(lsp-mode . "8.0.0")
    465   :group 'lsp-lua-language-server)
    466 
    467 (defcustom lsp-lua-workspace-use-git-ignore t
    468   "Ignore files list in `.gitignore` ."
    469   :type 'boolean
    470   :package-version '(lsp-mode . "8.0.0")
    471   :group 'lsp-lua-language-server)
    472 
    473 (defcustom lsp-lua-files-associations nil
    474   "Files.associations."
    475   :type 'alist
    476   :package-version '(lsp-mode . "8.0.0")
    477   :group 'lsp-lua-language-server)
    478 
    479 (defcustom lsp-lua-files-exclude nil
    480   "Files.exclude."
    481   :type 'alist
    482   :package-version '(lsp-mode . "8.0.0")
    483   :group 'lsp-lua-language-server)
    484 
    485 (defcustom lsp-lua-prefer-musl nil
    486   "Whether or not to download the musl-compiled server."
    487   :type 'boolean
    488   :package-version '(lsp-mode . "8.0.0")
    489   :group 'lsp-lua-language-server)
    490 
    491 (lsp-register-custom-settings
    492  '(("files.associations" lsp-lua-files-associations t)
    493    ("files.exclude" lsp-lua-files-exclude t)
    494    ("Lua.workspace.useGitIgnore" lsp-lua-workspace-use-git-ignore t)
    495    ("Lua.workspace.preloadFileSize" lsp-lua-workspace-preload-file-size)
    496    ("Lua.workspace.maxPreload" lsp-lua-workspace-max-preload)
    497    ("Lua.workspace.library" lsp-lua-workspace-library)
    498    ("Lua.workspace.ignoreSubmodules" lsp-lua-workspace-ignore-submodules t)
    499    ("Lua.workspace.ignoreDir" lsp-lua-workspace-ignore-dir)
    500    ("Lua.window.statusBar" lsp-lua-window-status-bar t)
    501    ("Lua.window.progressBar" lsp-lua-window-progress-bar t)
    502    ("Lua.telemetry.enable" lsp-lua-telemetry-enable t)
    503    ("Lua.signatureHelp.enable" lsp-lua-signature-help-enable t)
    504    ("Lua.runtime.version" lsp-lua-runtime-version)
    505    ("Lua.runtime.unicodeName" lsp-lua-runtime-unicode-name nil)
    506    ("Lua.runtime.special" lsp-lua-runtime-special)
    507    ("Lua.runtime.plugin" lsp-lua-runtime-plugin)
    508    ("Lua.runtime.path" lsp-lua-runtime-path)
    509    ("Lua.runtime.nonstandardSymbol" lsp-lua-runtime-nonstandard-symbol)
    510    ("Lua.runtime.fileEncoding" lsp-lua-runtime-file-encoding)
    511    ("Lua.intelliSense.searchDepth" lsp-lua-intelli-sense-search-depth)
    512    ("Lua.hover.viewStringMax" lsp-lua-hover-view-string-max)
    513    ("Lua.hover.viewString" lsp-lua-hover-view-string t)
    514    ("Lua.hover.viewNumber" lsp-lua-hover-view-number t)
    515    ("Lua.hover.previewFields" lsp-lua-hover-preview-fields)
    516    ("Lua.hover.fieldInfer" lsp-lua-hover-field-infer)
    517    ("Lua.hover.enable" lsp-lua-hover-enable t)
    518    ("Lua.hint.setType" lsp-lua-hint-set-type nil)
    519    ("Lua.hint.paramType" lsp-lua-hint-param-type t)
    520    ("Lua.hint.paramName" lsp-lua-hint-param-name t)
    521    ("Lua.hint.enable" lsp-lua-hint-enable t)
    522    ("Lua.diagnostics.workspaceRate" lsp-lua-diagnostics-workspace-rate)
    523    ("Lua.diagnostics.workspaceDelay" lsp-lua-diagnostics-workspace-delay)
    524    ("Lua.diagnostics.severity" lsp-lua-diagnostics-severity)
    525    ("Lua.diagnostics.neededFileStatus" lsp-lua-diagnostics-needed-file-status)
    526    ("Lua.diagnostics.globals" lsp-lua-diagnostics-globals)
    527    ("Lua.diagnostics.enable" lsp-lua-diagnostics-enable t)
    528    ("Lua.diagnostics.disable" lsp-lua-diagnostics-disable)
    529    ("Lua.develop.enable" lsp-lua-develop-enable t)
    530    ("Lua.develop.debuggerWait" lsp-lua-develop-debugger-wait t)
    531    ("Lua.develop.debuggerPort" lsp-lua-develop-debugger-port)
    532    ("Lua.completion.workspaceWord" lsp-lua-completion-workspace-word t)
    533    ("Lua.completion.keywordSnippet" lsp-lua-completion-keyword-snippet)
    534    ("Lua.completion.enable" lsp-lua-completion-enable t)
    535    ("Lua.completion.displayContext" lsp-lua-completion-display-context)
    536    ("Lua.completion.callSnippet" lsp-lua-completion-call-snippet)
    537    ("Lua.color.mode" lsp-lua-color-mode)))
    538 
    539 (defun lsp-lua-language-server-install-latest (client callback error-callback update?)
    540   "Download the latest version of lua-language-server and extract it to
    541 `lsp-lua-language-server-install-dir'."
    542   (ignore client update?)
    543   (let ((store-path (expand-file-name "lua-language-server-github" lsp-clients-lua-language-server-install-dir)))
    544     (lsp-download-install
    545      (lambda (&rest _)
    546        (set-file-modes lsp-clients-lua-language-server-bin #o0700)
    547        (funcall callback))
    548      error-callback
    549      :url (lsp--find-latest-gh-release-url
    550            "https://api.github.com/repos/sumneko/lua-language-server/releases/latest"
    551            (format "%s%s.tar.gz"
    552                    (pcase system-type
    553                      ('gnu/linux
    554                       (pcase (lsp-resolve-value lsp--system-arch)
    555                         ('x64     "linux-x64")))
    556                      ('darwin
    557                       (pcase (lsp-resolve-value lsp--system-arch)
    558                         ('x64     "darwin-x64")
    559                         ('arm64   "darwin-arm64")))
    560                      ('windows-nt
    561                       (pcase (lsp-resolve-value lsp--system-arch)
    562                         ('x64     "win32-x64")
    563                         ('arm64   "win32-ia32")))
    564                      (_
    565                       (pcase (lsp-resolve-value lsp--system-arch)
    566                         ('x64     "linux-x64"))))
    567                    (if lsp-lua-prefer-musl "-musl" "")))
    568      :store-path store-path
    569      :decompress (pcase system-type ('windows-nt :zip) (_ :targz)))))
    570 
    571 (lsp-register-client
    572  (make-lsp-client
    573   :new-connection (lsp-stdio-connection (lambda () (or lsp-clients-lua-language-server-command
    574                                                        `(,lsp-clients-lua-language-server-bin
    575                                                          ,@lsp-clients-lua-language-server-args
    576                                                          ,lsp-clients-lua-language-server-main-location)))
    577                                         #'lsp-clients-lua-language-server-test)
    578   :activation-fn (lsp-activate-on "lua")
    579   :priority -2
    580   :server-id 'lua-language-server
    581   :download-server-fn #'lsp-lua-language-server-install-latest))
    582 
    583 ;;; lua-lsp
    584 (defgroup lsp-lua-lsp nil
    585   "Lua LSP client, provided by the Lua-Lsp."
    586   :group 'lsp-mode
    587   :version "8.0.0"
    588   :link '(url-link "https://github.com/Alloyed/lua-lsp"))
    589 
    590 (defcustom lsp-clients-luarocks-bin-dir (f-join (getenv "HOME") ".luarocks/bin/")
    591   "LuaRocks bin directory."
    592   :group 'lsp-lua-lsp
    593   :version "8.0.0"
    594   :risky t
    595   :type 'directory)
    596 
    597 (defcustom lsp-clients-lua-lsp-server-install-dir nil
    598   "Installation directory for Lua-Lsp Language Server."
    599   :group 'lsp-lua-lsp
    600   :version "8.0.0"
    601   :risky t
    602   :type 'file)
    603 
    604 (defun lsp-clients-lua-lsp-test ()
    605   "Test Lua-lsp language server files."
    606   (and (f-exists? lsp-clients-lua-lsp-server-install-dir)))
    607 
    608 (lsp-register-client
    609  (make-lsp-client
    610   :new-connection (lsp-stdio-connection (lambda ()
    611                                           (or lsp-clients-lua-lsp-server-install-dir
    612                                               (f-join lsp-clients-luarocks-bin-dir "lua-lsp")))
    613                                         #'lsp-clients-lua-lsp-test)
    614   :activation-fn (lsp-activate-on "lua")
    615   :priority -3
    616   :server-id 'lsp-lua-lsp))
    617 
    618 ;;; lua-roblox-language-server
    619 (defgroup lsp-lua-roblox-language-server nil
    620   "Roblox Lua LSP client, provided by the Roblox Lua Language Server."
    621   :group 'lsp-mode
    622   :version "8.0.0"
    623   :link '(url-link "https://github.com/NightrainsRbx/RobloxLsp"))
    624 
    625 (defcustom lsp-lua-roblox-language-server-install-dir (f-join lsp-server-install-dir "lua-roblox-language-server/")
    626   "Installation directory for Lua Language Server."
    627   :group 'lsp-lua-roblox-language-server
    628   :version "8.0.0"
    629   :risky t
    630   :type 'directory)
    631 
    632 (defcustom lsp-lua-roblox-language-server-bin
    633   (f-join lsp-lua-roblox-language-server-install-dir
    634           "extension/server/bin/"
    635           (pcase system-type
    636             ('gnu/linux "Linux/lua-language-server")
    637             ('darwin "macOS/lua-language-server")
    638             ('windows-nt "Windows/lua-language-server.exe")
    639             (_ "Linux/lua-language-server")))
    640   "Location of Roblox Lua Language Server."
    641   :group 'lsp-lua-roblox-language-server
    642   :version "8.0.0"
    643   :risky t
    644   :type 'file)
    645 
    646 (defcustom lsp-lua-roblox-language-server-main-location
    647   (f-join lsp-lua-roblox-language-server-install-dir
    648           "extension/server/main.lua")
    649   "Location of Roblox Lua Language Server main.lua."
    650   :group 'lsp-lua-roblox-language-server
    651   :version "8.0.0"
    652   :risky t
    653   :type 'file)
    654 
    655 (defcustom lsp-lua-roblox-server-download-url
    656   (lsp-vscode-extension-url "Nightrains" "robloxlsp" "1.5.11")
    657   "Download url for Roblox Lua vscode extension."
    658   :group 'lsp-lua-roblox-language-server
    659   :version "8.0.0"
    660   :type 'string)
    661 
    662 (defcustom lsp-lua-roblox-server-store-path
    663   (expand-file-name "vs-lua-roblox" lsp-lua-roblox-language-server-install-dir)
    664   "Server file name for the vscode extension."
    665   :group 'lsp-lua-roblox-language-server
    666   :version "8.0.0"
    667   :type 'string)
    668 
    669 (defun lsp-lua-roblox-language-server-test ()
    670   "Test Lua language server binaries and files."
    671   (and (f-exists? lsp-lua-roblox-language-server-main-location)
    672        (f-exists? lsp-lua-roblox-language-server-bin)))
    673 
    674 (defun lsp-lua-roblox-language-server-install (_client callback error-callback _update?)
    675   "Download the latest version of lua-language-server and extract it to
    676 `lsp-lua-roblox-language-server-download-url'."
    677   (lsp-download-install
    678     (lambda (&rest _)
    679      (set-file-modes lsp-lua-roblox-language-server-bin #o0700)
    680      (funcall callback))
    681      error-callback
    682      :url lsp-lua-roblox-server-download-url
    683      :store-path lsp-lua-roblox-server-store-path
    684      :decompress :zip))
    685 
    686 (lsp-register-client
    687  (make-lsp-client
    688   :new-connection (lsp-stdio-connection (lambda () (or lsp-clients-lua-language-server-command
    689                                                        `(,lsp-lua-roblox-language-server-bin
    690                                                          ,@lsp-clients-lua-language-server-args
    691                                                          ,lsp-lua-roblox-language-server-main-location)))
    692                                         #'lsp-lua-roblox-language-server-test)
    693   :activation-fn (lsp-activate-on "lua")
    694   :priority -4
    695   :server-id 'lua-roblox-language-server
    696   :download-server-fn #'lsp-lua-roblox-language-server-install))
    697 
    698 (lsp-consistency-check lsp-lua)
    699 
    700 (provide 'lsp-lua)
    701 ;;; lsp-lua.el ends here