config

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

lsp-protocol.el (45370B)


      1 ;;; lsp-protocol.el --- Language Sever Protocol Bindings  -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2020  Ivan Yonchovski
      4 
      5 ;; Author: Ivan Yonchovski <yyoncho@gmail.com>
      6 ;; Keywords: convenience
      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 ;; Autogenerated bindings from lsp4j using
     24 ;; https://github.com/victools/jsonschema-generator+scripts to generate
     25 ;; scripts/generated.protocol.schema.json and then
     26 ;; scripts/lsp-generate-bindings.el
     27 
     28 ;;; Code:
     29 
     30 (require 'cl-lib)
     31 (require 'dash)
     32 (require 'ht)
     33 (require 's)
     34 (require 'json)
     35 
     36 (eval-and-compile
     37   (defun lsp-keyword->symbol (keyword)
     38     "Convert a KEYWORD to symbol."
     39     (intern (substring (symbol-name keyword) 1)))
     40 
     41   (defun lsp-keyword->string (keyword)
     42     "Convert a KEYWORD to string."
     43     (substring (symbol-name keyword) 1))
     44 
     45   (defvar lsp-use-plists (getenv "LSP_USE_PLISTS")))
     46 
     47 (defmacro lsp-interface (&rest interfaces)
     48   "Generate LSP bindings from INTERFACES triplet.
     49 
     50 Example usage with `dash`.
     51 
     52 \(-let [(&ApplyWorkspaceEditResponse
     53   :failure-reason?) (ht (\"failureReason\" \"...\"))]
     54   failure-reason?)
     55 
     56 \(fn (INTERFACE-NAME-1 REQUIRED-FIELDS-1 OPTIONAL-FIELDS-1) (INTERFACE-NAME-2 REQUIRED-FIELDS-2 OPTIONAL-FIELDS-2) ...)"
     57   (with-case-table ascii-case-table
     58     (->> interfaces
     59          (-map (-lambda ((interface required optional))
     60                  (let ((params (nconc
     61                                 (-map (lambda (param-name)
     62                                         (cons
     63                                          (intern (concat ":" (s-dashed-words (symbol-name param-name)) "?"))
     64                                          param-name))
     65                                       optional)
     66                                 (-map (lambda (param-name)
     67                                         (cons (intern (concat ":" (s-dashed-words (symbol-name param-name))))
     68                                               param-name))
     69                                       required))))
     70                    (cl-list*
     71                     `(defun ,(intern (format "dash-expand:&%s" interface)) (key source)
     72                        (unless (or (member key ',(-map #'cl-first params))
     73                                    (s-starts-with? ":_" (symbol-name key)))
     74                          (error "Unknown key: %s.  Available keys: %s" key ',(-map #'cl-first params)))
     75                        ,(if lsp-use-plists
     76                             ``(plist-get ,source
     77                                          ,(if (s-starts-with? ":_" (symbol-name key))
     78                                               key
     79                                             (cl-rest (assoc key ',params))))
     80                           ``(gethash ,(if (s-starts-with? ":_" (symbol-name key))
     81                                           (substring (symbol-name key) 1)
     82                                         (substring (symbol-name
     83                                                     (cl-rest (assoc key ',params)))
     84                                                    1))
     85                                      ,source)))
     86                     `(defun ,(intern (format "dash-expand:&%s?" interface)) (key source)
     87                        (unless (member key ',(-map #'cl-first params))
     88                          (error "Unknown key: %s.  Available keys: %s" key ',(-map #'cl-first params)))
     89                        ,(if lsp-use-plists
     90                             ``(plist-get ,source
     91                                          ,(if (s-starts-with? ":_" (symbol-name key))
     92                                               key
     93                                             (cl-rest (assoc key ',params))))
     94                           ``(when (ht? ,source)
     95                               (gethash ,(substring (symbol-name
     96                                                     (cl-rest (assoc key ',params)))
     97                                                    1)
     98                                        ,source))))
     99 
    100                     `(defun ,(intern (format "lsp-%s?" (s-dashed-words (symbol-name interface)))) (object)
    101                        (cond
    102                         ((ht? object)
    103                          (-all? (let ((keys (ht-keys object)))
    104                                   (lambda (prop)
    105                                     (member prop keys)))
    106                                 ',(-map (lambda (field-name)
    107                                           (substring (symbol-name field-name) 1))
    108                                         required)))
    109                         ((listp object) (-all? (lambda (prop)
    110                                                  (plist-member object prop))
    111                                                ',required))))
    112                     `(cl-defun ,(intern (format "lsp-make-%s" (s-dashed-words (symbol-name interface))))
    113                          (&rest plist &key ,@(-map (-lambda ((key))
    114                                                      (intern (substring (symbol-name key) 1))) params)
    115                                 &allow-other-keys)
    116                        (ignore ,@(-map (-lambda ((key))
    117                                          (intern (substring (symbol-name key) 1))) params))
    118                        ,(format "Constructs %s from `plist.'
    119 Allowed params: %s" interface (reverse (-map #'cl-first params)))
    120                        ,(if lsp-use-plists
    121                             `(-mapcat (-lambda ((key value))
    122                                         (list (or (cl-rest (assoc key ',params)) key) value))
    123                                       (-partition 2 plist))
    124                           `(let (($$result (ht)))
    125                              (mapc (-lambda ((key value))
    126                                      (puthash (lsp-keyword->string (or (cl-rest (assoc key ',params))
    127                                                                        key))
    128                                               value
    129                                               $$result))
    130                                    (-partition 2 plist))
    131                              $$result)))
    132                     `(cl-defun ,(intern (format "lsp--pcase-macroexpander-%s" interface)) (&rest property-bindings)
    133                        ,(if lsp-use-plists
    134                             ``(and
    135                                (pred listp)
    136                                ;; Check if all the types required by the
    137                                ;; interface exist in the expr-val.
    138                                ,@(-map
    139                                   (lambda (key)
    140                                     `(pred
    141                                       (lambda (plist)
    142                                         (plist-member plist ,key))))
    143                                   ',required)
    144                                ;; Recursively generate the bindings.
    145                                ,@(let ((current-list property-bindings)
    146                                        (output-bindings nil))
    147                                    ;; Invariant: while current-list is
    148                                    ;; non-nil, the car of current-list is
    149                                    ;; always of the form :key, while the
    150                                    ;; cadr of current-list is either a)
    151                                    ;; nil, b) of the form :key-next or c)
    152                                    ;; a pcase pattern that can
    153                                    ;; recursively match an expression.
    154                                    (while current-list
    155                                      (-let* (((curr-binding-as-keyword next-entry . _) current-list)
    156                                              (curr-binding-as-camelcased-symbol
    157                                               (or (alist-get curr-binding-as-keyword ',params)
    158                                                   (error "Unknown key: %s.  Available keys: %s"
    159                                                          (symbol-name curr-binding-as-keyword)
    160                                                          ',(-map #'cl-first params))))
    161                                              (bound-name (lsp-keyword->symbol curr-binding-as-keyword))
    162                                              (next-entry-is-key-or-nil
    163                                               (and (symbolp next-entry)
    164                                                    (or (null next-entry)
    165                                                        (s-starts-with? ":" (symbol-name next-entry))))))
    166                                        (cond
    167                                         ;; If the next-entry is either a
    168                                         ;; plist-key or nil, then bind to
    169                                         ;; bound-name the value corresponding
    170                                         ;; to the camelcased symbol.  Pop
    171                                         ;; current-list once.
    172                                         (next-entry-is-key-or-nil
    173                                          (push `(app (lambda (plist)
    174                                                        (plist-get plist ,curr-binding-as-camelcased-symbol))
    175                                                      ,bound-name)
    176                                                output-bindings)
    177                                          (setf current-list (cdr current-list)))
    178                                         ;; Otherwise, next-entry is a pcase
    179                                         ;; pattern we recursively match to the
    180                                         ;; expression. This can in general
    181                                         ;; create additional bindings that we
    182                                         ;; persist in the top level of
    183                                         ;; bindings.  We pop current-list
    184                                         ;; twice.
    185                                         (t
    186                                          (push `(app (lambda (plist)
    187                                                        (plist-get plist ,curr-binding-as-camelcased-symbol))
    188                                                      ,next-entry)
    189                                                output-bindings)
    190                                          (setf current-list (cddr current-list))))))
    191                                    output-bindings))
    192                           ``(and
    193                              (pred ht?)
    194                              ,@(-map
    195                                 (lambda (key)
    196                                   `(pred
    197                                     (lambda (hash-table)
    198                                       (ht-contains? hash-table ,(lsp-keyword->string key)))))
    199                                 ',required)
    200                              ,@(let ((current-list property-bindings)
    201                                      (output-bindings nil))
    202                                  (while current-list
    203                                    (-let* (((curr-binding-as-keyword next-entry . _) current-list)
    204                                            (curr-binding-as-camelcased-string
    205                                             (lsp-keyword->string (or (alist-get curr-binding-as-keyword ',params)
    206                                                                      (error "Unknown key: %s.  Available keys: %s"
    207                                                                             (symbol-name curr-binding-as-keyword)
    208                                                                             ',(-map #'cl-first params)))))
    209                                            (bound-name (lsp-keyword->symbol curr-binding-as-keyword))
    210                                            (next-entry-is-key-or-nil
    211                                             (and (symbolp next-entry)
    212                                                  (or (null next-entry)
    213                                                      (s-starts-with? ":" (symbol-name next-entry))))))
    214                                      (cond
    215                                       (next-entry-is-key-or-nil
    216                                        (push `(app (lambda (hash-table)
    217                                                      (ht-get hash-table ,curr-binding-as-camelcased-string))
    218                                                    ,bound-name)
    219                                              output-bindings)
    220                                        (setf current-list (cdr current-list)))
    221                                       (t
    222                                        (push `(app (lambda (hash-table)
    223                                                      (ht-get hash-table ,curr-binding-as-camelcased-string))
    224                                                    ,next-entry)
    225                                              output-bindings)
    226                                        (setf current-list (cddr current-list))))))
    227                                  output-bindings))))
    228                     (-mapcat (-lambda ((label . name))
    229                                (list
    230                                 `(defun ,(intern (format "lsp:%s-%s"
    231                                                          (s-dashed-words (symbol-name interface))
    232                                                          (substring (symbol-name label) 1)))
    233                                      (object)
    234                                    ,(if lsp-use-plists
    235                                         `(plist-get object ,name)
    236                                       `(when (ht? object) (gethash ,(lsp-keyword->string name) object))))
    237                                 `(defun ,(intern (format "lsp:set-%s-%s"
    238                                                          (s-dashed-words (symbol-name interface))
    239                                                          (substring (symbol-name label) 1)))
    240                                      (object value)
    241                                    ,@(if lsp-use-plists
    242                                          `((plist-put object ,name value))
    243                                        `((puthash ,(lsp-keyword->string name) value object)
    244                                          object)))))
    245                              params)))))
    246          (apply #'append)
    247          (cl-list* 'progn))))
    248 
    249 (pcase-defmacro lsp-interface (interface &rest property-bindings)
    250   "If EXPVAL is an instance of INTERFACE, destructure it by matching its
    251 properties. EXPVAL should be a plist or hash table depending on the variable
    252 `lsp-use-plists'.
    253 
    254 INTERFACE should be an LSP interface defined with `lsp-interface'. This form
    255 will not match if any of INTERFACE's required fields are missing in EXPVAL.
    256 
    257 Each :PROPERTY keyword matches a field in EXPVAL. The keyword may be followed by
    258 an optional PATTERN, which is a `pcase' pattern to apply to the field's value.
    259 Otherwise, PROPERTY is let-bound to the field's value.
    260 
    261 \(fn INTERFACE [:PROPERTY [PATTERN]]...)"
    262   (cl-check-type interface symbol)
    263   (let ((lsp-pcase-macroexpander
    264          (intern (format "lsp--pcase-macroexpander-%s" interface))))
    265     (cl-assert (fboundp lsp-pcase-macroexpander) "not a known LSP interface: %s" interface)
    266     (apply lsp-pcase-macroexpander property-bindings)))
    267 
    268 (if lsp-use-plists
    269     (progn
    270       (defun lsp-get (from key)
    271         (plist-get from key))
    272       (defun lsp-put (where key value)
    273         (plist-put where key value))
    274       (defun lsp-map (fn value)
    275         (-map (-lambda ((k v))
    276                 (funcall fn (lsp-keyword->string k) v))
    277               (-partition 2 value )))
    278       (defalias 'lsp-merge 'append)
    279       (defalias 'lsp-empty? 'null)
    280       (defalias 'lsp-copy 'copy-sequence)
    281       (defun lsp-member? (from key)
    282         (when (listp from)
    283           (plist-member from key)))
    284       (defalias 'lsp-structure-p 'json-plist-p)
    285       (defun lsp-delete (from key)
    286         (cl-remf from key)
    287         from))
    288   (defun lsp-get (from key)
    289     (when from
    290       (gethash (lsp-keyword->string key) from)))
    291   (defun lsp-put (where key value)
    292     (prog1 where
    293       (puthash (lsp-keyword->string key) value where)))
    294   (defun lsp-map (fn value)
    295     (when value
    296       (maphash fn value)))
    297   (defalias 'lsp-merge 'ht-merge)
    298   (defalias 'lsp-empty? 'ht-empty?)
    299   (defalias 'lsp-copy 'ht-copy)
    300   (defun lsp-member? (from key)
    301     (when (hash-table-p from)
    302       (not (eq (gethash (lsp-keyword->string key) from :__lsp_default)
    303                :__lsp_default))))
    304   (defalias 'lsp-structure-p 'hash-table-p)
    305   (defun lsp-delete (from key)
    306     (ht-remove from (lsp-keyword->string key))
    307     from))
    308 
    309 (defmacro lsp-defun (name match-form &rest body)
    310   "Define a function named NAME.
    311 The function destructures its input as MATCH-FORM then executes BODY.
    312 
    313 Note that you have to enclose the MATCH-FORM in a pair of parens,
    314 such that:
    315 
    316   (-defun (x) body)
    317   (-defun (x y ...) body)
    318 
    319 has the usual semantics of `defun'.  Furthermore, these get
    320 translated into a normal `defun', so there is no performance
    321 penalty.
    322 
    323 See `-let' for a description of the destructuring mechanism."
    324   (declare (doc-string 3) (indent defun)
    325            (debug (&define name sexp
    326                            [&optional stringp]
    327                            [&optional ("declare" &rest sexp)]
    328                            [&optional ("interactive" interactive)]
    329                            def-body)))
    330   (cond
    331    ((nlistp match-form)
    332     (signal 'wrong-type-argument (list #'listp match-form)))
    333    ;; no destructuring, so just return regular defun to make things faster
    334    ((-all? #'symbolp match-form)
    335     `(defun ,name ,match-form ,@body))
    336    (t
    337     (-let* ((inputs (--map-indexed (list it (make-symbol (format "input%d" it-index))) match-form))
    338             ((body docs) (cond
    339                           ;; only docs
    340                           ((and (stringp (car body))
    341                                 (not (cdr body)))
    342                            (list body (car body)))
    343                           ;; docs + body
    344                           ((stringp (car body))
    345                            (list (cdr body) (car body)))
    346                           ;; no docs
    347                           (t (list body))))
    348             ((body interactive-form) (cond
    349                                       ;; interactive form
    350                                       ((and (listp (car body))
    351                                             (eq (caar body) 'interactive))
    352                                        (list (cdr body) (car body)))
    353                                       ;; no interactive form
    354                                       (t (list body)))))
    355       ;; TODO: because inputs to the defun are evaluated only once,
    356       ;; -let* need not to create the extra bindings to ensure that.
    357       ;; We should find a way to optimize that.  Not critical however.
    358       `(defun ,name ,(-map #'cadr inputs)
    359          ,@(when docs (list docs))
    360          ,@(when interactive-form (list interactive-form))
    361          (-let* ,inputs ,@body))))))
    362 
    363 
    364 
    365 
    366 ;; manually defined interfaces
    367 (defconst lsp/markup-kind-plain-text "plaintext")
    368 (defconst lsp/markup-kind-markdown "markdown")
    369 
    370 (lsp-interface (JSONResponse (:params :id :method :result) nil)
    371                (JSONResponseError (:error) nil)
    372                (JSONMessage nil (:params :id :method :result :error))
    373                (JSONResult nil (:params :id :method))
    374                (JSONNotification (:params :method) nil)
    375                (JSONRequest (:params :method) nil)
    376                (JSONError (:message :code) (:data))
    377                (ProgressParams (:token :value) nil)
    378                (Edit (:kind) nil)
    379                (WorkDoneProgress (:kind) nil)
    380                (WorkDoneProgressBegin  (:kind :title) (:cancellable :message :percentage))
    381                (WorkDoneProgressReport  (:kind) (:cancellable :message :percentage))
    382                (WorkDoneProgressEnd  (:kind) (:message))
    383                (WorkDoneProgressOptions nil (:workDoneProgress))
    384                (SemanticTokensOptions (:legend) (:rangeProvider :documentProvider))
    385                (SemanticTokensLegend (:tokenTypes :tokenModifiers))
    386                (SemanticTokensResult (:resultId) (:data))
    387                (SemanticTokensPartialResult nil (:data))
    388                (SemanticTokensEdit (:start :deleteCount) (:data))
    389                (SemanticTokensDelta (:resultId) (:edits))
    390                (SemanticTokensDeltaPartialResult nil (:edits)))
    391 
    392 (lsp-interface (v1:ProgressParams (:id :title) (:message :percentage :done)))
    393 
    394 (defun dash-expand:&RangeToPoint (key source)
    395   "Convert the position KEY from SOURCE into a point."
    396   `(lsp--position-to-point
    397     (lsp-get ,source ,key)))
    398 
    399 (lsp-interface (eslint:StatusParams  (:state) nil)
    400                (eslint:OpenESLintDocParams (:url) nil)
    401                (eslint:ConfirmExecutionParams (:scope :file :libraryPath) nil))
    402 
    403 (lsp-interface (haxe:ProcessStartNotification (:title) nil))
    404 
    405 (lsp-interface (pwsh:ScriptRegion (:StartLineNumber :EndLineNumber :StartColumnNumber :EndColumnNumber :Text) nil))
    406 
    407 (lsp-interface (omnisharp:ErrorMessage (:Text :FileName :Line :Column))
    408                (omnisharp:ProjectInformationRequest (:FileName))
    409                (omnisharp:MsBuildProject (:IsUnitProject :IsExe :Platform :Configuration :IntermediateOutputPath :OutputPath :TargetFrameworks :SourceFiles :TargetFramework :TargetPath :AssemblyName :Path :ProjectGuid))
    410                (omnisharp:ProjectInformation (:ScriptProject :MsBuildProject))
    411                (omnisharp:CodeStructureRequest (:FileName))
    412                (omnisharp:CodeStructureResponse (:Elements))
    413                (omnisharp:CodeElement (:Kind :Name :DisplayName :Children :Ranges :Properties))
    414                (omnisharp:CodeElementProperties () (:static :accessibility :testMethodName :testFramework))
    415                (omnisharp:Range (:Start :End))
    416                (omnisharp:RangeList () (:attributes :full :name))
    417                (omnisharp:Point (:Line :Column))
    418                (omnisharp:RunTestsInClassRequest (:MethodNames :RunSettings :TestFrameworkname :TargetFrameworkVersion :NoBuild :Line :Column :Buffer :FileName))
    419                (omnisharp:RunTestResponse (:Results :Pass :Failure :ContextHadNoTests))
    420                (omnisharp:TestMessageEvent (:MessageLevel :Message))
    421                (omnisharp:DotNetTestResult (:MethodName :Outcome :ErrorMessage :ErrorStackTrace :StandardOutput :StandardError))
    422                (omnisharp:MetadataRequest (:AssemblyName :TypeName :ProjectName :VersionNumber :Language))
    423                (omnisharp:MetadataResponse (:SourceName :Source)))
    424 
    425 (lsp-interface (csharp-ls:CSharpMetadata (:textDocument))
    426                (csharp-ls:CSharpMetadataResponse (:source :projectName :assemblyName :symbolName)))
    427 
    428 (lsp-interface (rls:Cmd (:args :binary :env :cwd) nil))
    429 
    430 (lsp-interface (rust-analyzer:AnalyzerStatusParams (:textDocument))
    431                (rust-analyzer:SyntaxTreeParams (:textDocument) (:range))
    432                (rust-analyzer:ViewHir (:textDocument :position))
    433                (rust-analyzer:ViewItemTree (:textDocument))
    434                (rust-analyzer:ExpandMacroParams (:textDocument :position) nil)
    435                (rust-analyzer:ExpandedMacro (:name :expansion) nil)
    436                (rust-analyzer:MatchingBraceParams (:textDocument :positions) nil)
    437                (rust-analyzer:OpenCargoTomlParams (:textDocument) nil)
    438                (rust-analyzer:OpenExternalDocsParams (:textDocument :position) nil)
    439                (rust-analyzer:ResovedCodeActionParams (:id :codeActionParams) nil)
    440                (rust-analyzer:JoinLinesParams (:textDocument :ranges) nil)
    441                (rust-analyzer:MoveItemParams (:textDocument :range :direction) nil)
    442                (rust-analyzer:RunnablesParams (:textDocument) (:position))
    443                (rust-analyzer:Runnable (:label :kind :args) (:location))
    444                (rust-analyzer:RunnableArgs (:cargoArgs :executableArgs) (:workspaceRoot :expectTest))
    445                (rust-analyzer:RelatedTestsParams (:textDocument :position) nil)
    446                (rust-analyzer:RelatedTests (:runnable) nil)
    447                (rust-analyzer:SsrParams (:query :parseOnly) nil)
    448                (rust-analyzer:CommandLink (:title :command) (:arguments :tooltip))
    449                (rust-analyzer:CommandLinkGroup (:commands) (:title)))
    450 
    451 (lsp-interface (clojure-lsp:TestTreeParams (:uri :tree) nil)
    452                (clojure-lsp:TestTreeNode (:name :range :nameRange :kind) (:children))
    453                (clojure-lsp:ProjectTreeNode (:name :type) (:nodes :final :id :uri :detail :range)))
    454 
    455 (lsp-interface (terraform-ls:ModuleCalls (:v :module_calls) nil))
    456 (lsp-interface (terraform-ls:Module (:name :docs_link :version :source_type :dependent_modules) nil))
    457 (lsp-interface (terraform-ls:Providers (:v :provider_requirements :installed_providers) nil))
    458 (lsp-interface (terraform-ls:module.terraform (:v :required_version :discovered_version)))
    459 
    460 
    461 ;; begin autogenerated code
    462 
    463 (defvar lsp/completion-item-kind-lookup
    464   [nil Text Method Function Constructor Field Variable Class Interface Module Property Unit Value Enum Keyword Snippet Color File Reference Folder EnumMember Constant Struct Event Operator TypeParameter])
    465 (defconst lsp/completion-item-kind-text 1)
    466 (defconst lsp/completion-item-kind-method 2)
    467 (defconst lsp/completion-item-kind-function 3)
    468 (defconst lsp/completion-item-kind-constructor 4)
    469 (defconst lsp/completion-item-kind-field 5)
    470 (defconst lsp/completion-item-kind-variable 6)
    471 (defconst lsp/completion-item-kind-class 7)
    472 (defconst lsp/completion-item-kind-interface 8)
    473 (defconst lsp/completion-item-kind-module 9)
    474 (defconst lsp/completion-item-kind-property 10)
    475 (defconst lsp/completion-item-kind-unit 11)
    476 (defconst lsp/completion-item-kind-value 12)
    477 (defconst lsp/completion-item-kind-enum 13)
    478 (defconst lsp/completion-item-kind-keyword 14)
    479 (defconst lsp/completion-item-kind-snippet 15)
    480 (defconst lsp/completion-item-kind-color 16)
    481 (defconst lsp/completion-item-kind-file 17)
    482 (defconst lsp/completion-item-kind-reference 18)
    483 (defconst lsp/completion-item-kind-folder 19)
    484 (defconst lsp/completion-item-kind-enum-member 20)
    485 (defconst lsp/completion-item-kind-constant 21)
    486 (defconst lsp/completion-item-kind-struct 22)
    487 (defconst lsp/completion-item-kind-event 23)
    488 (defconst lsp/completion-item-kind-operator 24)
    489 (defconst lsp/completion-item-kind-type-parameter 25)
    490 (defvar lsp/completion-trigger-kind-lookup
    491   [nil Invoked TriggerCharacter TriggerForIncompleteCompletions])
    492 (defconst lsp/completion-trigger-kind-invoked 1)
    493 (defconst lsp/completion-trigger-kind-trigger-character 2)
    494 (defconst lsp/completion-trigger-kind-trigger-for-incomplete-completions 3)
    495 (defvar lsp/diagnostic-severity-lookup
    496   [nil Error Warning Information Hint Max])
    497 (defconst lsp/diagnostic-severity-error 1)
    498 (defconst lsp/diagnostic-severity-warning 2)
    499 (defconst lsp/diagnostic-severity-information 3)
    500 (defconst lsp/diagnostic-severity-hint 4)
    501 (defconst lsp/diagnostic-severity-max 5)
    502 (defvar lsp/diagnostic-tag-lookup
    503   [nil Unnecessary Deprecated])
    504 (defconst lsp/diagnostic-tag-unnecessary 1)
    505 (defconst lsp/diagnostic-tag-deprecated 2)
    506 (defvar lsp/completion-item-tag-lookup
    507   [nil Deprecated])
    508 (defconst lsp/completion-item-tag-deprecated 1)
    509 (defvar lsp/document-highlight-kind-lookup
    510   [nil Text Read Write])
    511 (defconst lsp/document-highlight-kind-text 1)
    512 (defconst lsp/document-highlight-kind-read 2)
    513 (defconst lsp/document-highlight-kind-write 3)
    514 (defvar lsp/file-change-type-lookup
    515   [nil Created Changed Deleted])
    516 (defconst lsp/file-change-type-created 1)
    517 (defconst lsp/file-change-type-changed 2)
    518 (defconst lsp/file-change-type-deleted 3)
    519 (defvar lsp/insert-text-format-lookup
    520   [nil PlainText Snippet])
    521 (defconst lsp/insert-text-format-plain-text 1)
    522 (defconst lsp/insert-text-format-snippet 2)
    523 (defvar lsp/insert-text-mode-lookup
    524   [nil AsIs AdjustIndentation])
    525 (defconst lsp/insert-text-mode-as-it 1)
    526 (defconst lsp/insert-text-mode-adjust-indentation 2)
    527 (defvar lsp/message-type-lookup
    528   [nil Error Warning Info Log])
    529 (defconst lsp/message-type-error 1)
    530 (defconst lsp/message-type-warning 2)
    531 (defconst lsp/message-type-info 3)
    532 (defconst lsp/message-type-log 4)
    533 (defvar lsp/signature-help-trigger-kind-lookup
    534   [nil Invoked TriggerCharacter ContentChange])
    535 (defconst lsp/signature-help-trigger-kind-invoked 1)
    536 (defconst lsp/signature-help-trigger-kind-trigger-character 2)
    537 (defconst lsp/signature-help-trigger-kind-content-change 3)
    538 (defvar lsp/symbol-kind-lookup
    539   [nil File Module Namespace Package Class Method Property Field Constructor Enum Interface Function Variable Constant String Number Boolean Array Object Key Null EnumMember Struct Event Operator TypeParameter])
    540 (defconst lsp/symbol-kind-file 1)
    541 (defconst lsp/symbol-kind-module 2)
    542 (defconst lsp/symbol-kind-namespace 3)
    543 (defconst lsp/symbol-kind-package 4)
    544 (defconst lsp/symbol-kind-class 5)
    545 (defconst lsp/symbol-kind-method 6)
    546 (defconst lsp/symbol-kind-property 7)
    547 (defconst lsp/symbol-kind-field 8)
    548 (defconst lsp/symbol-kind-constructor 9)
    549 (defconst lsp/symbol-kind-enum 10)
    550 (defconst lsp/symbol-kind-interface 11)
    551 (defconst lsp/symbol-kind-function 12)
    552 (defconst lsp/symbol-kind-variable 13)
    553 (defconst lsp/symbol-kind-constant 14)
    554 (defconst lsp/symbol-kind-string 15)
    555 (defconst lsp/symbol-kind-number 16)
    556 (defconst lsp/symbol-kind-boolean 17)
    557 (defconst lsp/symbol-kind-array 18)
    558 (defconst lsp/symbol-kind-object 19)
    559 (defconst lsp/symbol-kind-key 20)
    560 (defconst lsp/symbol-kind-null 21)
    561 (defconst lsp/symbol-kind-enum-member 22)
    562 (defconst lsp/symbol-kind-struct 23)
    563 (defconst lsp/symbol-kind-event 24)
    564 (defconst lsp/symbol-kind-operator 25)
    565 (defconst lsp/symbol-kind-type-parameter 26)
    566 (defvar lsp/text-document-save-reason-lookup
    567   [nil Manual AfterDelay FocusOut])
    568 (defconst lsp/text-document-save-reason-manual 1)
    569 (defconst lsp/text-document-save-reason-after-delay 2)
    570 (defconst lsp/text-document-save-reason-focus-out 3)
    571 (defvar lsp/text-document-sync-kind-lookup
    572   [None Full Incremental])
    573 (defconst lsp/text-document-sync-kind-none 0)
    574 (defconst lsp/text-document-sync-kind-full 1)
    575 (defconst lsp/text-document-sync-kind-incremental 2)
    576 (defvar lsp/type-hierarchy-direction-lookup
    577   [nil Children Parents Both])
    578 (defconst lsp/type-hierarchy-direction-children 1)
    579 (defconst lsp/type-hierarchy-direction-parents 2)
    580 (defconst lsp/type-hierarchy-direction-both 3)
    581 (defvar lsp/call-hierarchy-direction-lookup
    582   [nil CallsFrom CallsTo])
    583 (defconst lsp/call-hierarchy-direction-calls-from 1)
    584 (defconst lsp/call-hierarchy-direction-calls-to 2)
    585 (defvar lsp/response-error-code-lookup
    586   [nil ParseError InvalidRequest MethodNotFound InvalidParams InternalError serverErrorStart serverErrorEnd])
    587 (defconst lsp/response-error-code-parse-error 1)
    588 (defconst lsp/response-error-code-invalid-request 2)
    589 (defconst lsp/response-error-code-method-not-found 3)
    590 (defconst lsp/response-error-code-invalid-params 4)
    591 (defconst lsp/response-error-code-internal-error 5)
    592 (defconst lsp/response-error-code-server-error-start 6)
    593 (defconst lsp/response-error-code-server-error-end 7)
    594 
    595 (lsp-interface
    596  (CallHierarchyCapabilities nil (:dynamicRegistration))
    597  (CallHierarchyItem (:kind :name :range :selectionRange :uri) (:detail :tags))
    598  (ClientCapabilities nil (:experimental :textDocument :workspace))
    599  (ClientInfo (:name) (:version))
    600  (CodeActionCapabilities nil (:codeActionLiteralSupport :dynamicRegistration :isPreferredSupport :dataSupport :resolveSupport))
    601  (CodeActionContext (:diagnostics) (:only))
    602  (CodeActionKindCapabilities (:valueSet) nil)
    603  (CodeActionLiteralSupportCapabilities nil (:codeActionKind))
    604  (CodeActionOptions nil (:codeActionKinds :resolveProvider))
    605  (CodeLensCapabilities nil (:dynamicRegistration))
    606  (CodeLensOptions (:resolveProvider) nil)
    607  (Color (:red :green :blue :alpha) nil)
    608  (ColorProviderCapabilities nil (:dynamicRegistration))
    609  (ColorProviderOptions nil (:documentSelector :id))
    610  (ColoringInformation (:range :styles) nil)
    611  (Command (:title :command) (:arguments))
    612  (CompletionCapabilities nil (:completionItem :completionItemKind :contextSupport :dynamicRegistration))
    613  (CompletionContext (:triggerKind) (:triggerCharacter))
    614  (CompletionItem (:label) (:additionalTextEdits :command :commitCharacters :data :deprecated :detail :documentation :filterText :insertText :insertTextFormat :insertTextMode :kind :preselect :sortText :tags :textEdit :score :labelDetails))
    615  (CompletionItemCapabilities nil (:commitCharactersSupport :deprecatedSupport :documentationFormat :preselectSupport :snippetSupport :tagSupport :insertReplaceSupport :resolveSupport))
    616  (CompletionItemKindCapabilities nil (:valueSet))
    617  (CompletionItemTagSupportCapabilities (:valueSet) nil)
    618  (CompletionOptions nil (:resolveProvider :triggerCharacters :allCommitCharacters))
    619  (ConfigurationItem nil (:scopeUri :section))
    620  (CreateFileOptions nil (:ignoreIfExists :overwrite))
    621  (DeclarationCapabilities nil (:dynamicRegistration :linkSupport))
    622  (DefinitionCapabilities nil (:dynamicRegistration :linkSupport))
    623  (DeleteFileOptions nil (:ignoreIfNotExists :recursive))
    624  (Diagnostic (:range :message) (:code :relatedInformation :severity :source :tags))
    625  (DiagnosticClientCapabilities nil (:dynamicRegistration :relatedDocumentSupport))
    626  (DiagnosticOptions (:interFileDependencies :workspaceDiagnostics) (:identifier))
    627  (DiagnosticRelatedInformation (:location :message) nil)
    628  (DiagnosticServerCancellationData (:retriggerRequest) nil)
    629  (DiagnosticsTagSupport (:valueSet) nil)
    630  (DidChangeConfigurationCapabilities nil (:dynamicRegistration))
    631  (DidChangeWatchedFilesCapabilities nil (:dynamicRegistration))
    632  (DocumentDiagnosticParams (:textDocument) (:identifier :previousResultId))
    633  (DocumentDiagnosticReport (:kind) (:resultId :items :relatedDocuments))
    634  (DocumentFilter nil (:language :pattern :scheme))
    635  (DocumentHighlightCapabilities nil (:dynamicRegistration))
    636  (DocumentLinkCapabilities nil (:dynamicRegistration :tooltipSupport))
    637  (DocumentLinkOptions nil (:resolveProvider))
    638  (DocumentOnTypeFormattingOptions (:firstTriggerCharacter) (:moreTriggerCharacter))
    639  (DocumentSymbol (:kind :name :range :selectionRange) (:children :deprecated :detail))
    640  (DocumentSymbolCapabilities nil (:dynamicRegistration :hierarchicalDocumentSymbolSupport :symbolKind))
    641  (ExecuteCommandCapabilities nil (:dynamicRegistration))
    642  (ExecuteCommandOptions (:commands) nil)
    643  (FileEvent (:type :uri) nil)
    644  (FileSystemWatcher (:globPattern) (:kind))
    645  (FileOperationFilter (:pattern) (:scheme))
    646  (FileOperationPattern (:glob) (:matches :options))
    647  (FileOperationPatternOptions nil (:ignoreCase))
    648  (FileOperationRegistrationOptions (:filters) nil)
    649  (FoldingRangeCapabilities nil (:dynamicRegistration :lineFoldingOnly :rangeLimit))
    650  (FoldingRangeProviderOptions nil (:documentSelector :id))
    651  (FormattingCapabilities nil (:dynamicRegistration))
    652  (FormattingOptions (:tabSize :insertSpaces) (:trimTrailingWhitespace :insertFinalNewline :trimFinalNewlines))
    653  (HoverCapabilities nil (:contentFormat :dynamicRegistration))
    654  (ImplementationCapabilities nil (:dynamicRegistration :linkSupport))
    655  (LabelDetails (:detail :description) nil)
    656  (LinkedEditingRanges (:ranges) (:wordPattern))
    657  (Location (:range :uri) nil)
    658  (MarkedString (:language :value) nil)
    659  (MarkupContent (:kind :value) nil)
    660  (MessageActionItem (:title) nil)
    661  (OnTypeFormattingCapabilities nil (:dynamicRegistration))
    662  (ParameterInformation (:label) (:documentation))
    663  (ParameterInformationCapabilities nil (:labelOffsetSupport))
    664  (Position (:character :line) nil)
    665  (PublishDiagnosticsCapabilities nil (:relatedInformation :tagSupport :versionSupport))
    666  (Range (:start :end) nil)
    667  (RangeFormattingCapabilities nil (:dynamicRegistration))
    668  (ReferenceContext (:includeDeclaration) nil)
    669  (ReferencesCapabilities nil (:dynamicRegistration))
    670  (Registration (:method :id) (:registerOptions))
    671  (RenameCapabilities nil (:dynamicRegistration :prepareSupport))
    672  (RenameFileOptions nil (:ignoreIfExists :overwrite))
    673  (RenameOptions nil (:documentSelector :id :prepareProvider))
    674  (ResourceChange nil (:current :newUri))
    675  (ResourceOperation (:kind) nil)
    676  (SaveOptions nil (:includeText))
    677  (SelectionRange (:range) (:parent))
    678  (SelectionRangeCapabilities nil (:dynamicRegistration))
    679  (SemanticHighlightingCapabilities nil (:semanticHighlighting))
    680  (SemanticHighlightingInformation (:line) (:tokens))
    681  (SemanticHighlightingServerCapabilities nil (:scopes))
    682  (ServerCapabilities nil (:callHierarchyProvider :codeActionProvider :codeLensProvider :colorProvider :completionProvider :declarationProvider :definitionProvider :documentFormattingProvider :documentHighlightProvider :documentLinkProvider :documentOnTypeFormattingProvider :documentRangeFormattingProvider :documentSymbolProvider :executeCommandProvider :experimental :foldingRangeProvider :hoverProvider :implementationProvider :referencesProvider :renameProvider :selectionRangeProvider :semanticHighlighting :signatureHelpProvider :textDocumentSync :typeDefinitionProvider :typeHierarchyProvider :workspace :workspaceSymbolProvider :semanticTokensProvider))
    683  (ServerInfo (:name) (:version))
    684  (SignatureHelp (:signatures) (:activeParameter :activeSignature))
    685  (SignatureHelpCapabilities nil (:contextSupport :dynamicRegistration :signatureInformation))
    686  (SignatureHelpContext (:triggerKind :isRetrigger) (:activeSignatureHelp :triggerCharacter))
    687  (SignatureHelpOptions nil (:retriggerCharacters :triggerCharacters))
    688  (SignatureInformation (:label) (:documentation :parameters))
    689  (SignatureInformationCapabilities nil (:documentationFormat :parameterInformation))
    690  (StaticRegistrationOptions nil (:documentSelector :id))
    691  (SymbolCapabilities nil (:dynamicRegistration :symbolKind))
    692  (SymbolKindCapabilities nil (:valueSet))
    693  (SynchronizationCapabilities nil (:didSave :dynamicRegistration :willSave :willSaveWaitUntil))
    694  (TextDocumentClientCapabilities nil (:callHierarchy :codeAction :codeLens :colorProvider :completion :declaration :definition :documentHighlight :documentLink :documentSymbol :foldingRange :formatting :hover :implementation :onTypeFormatting :publishDiagnostics :rangeFormatting :references :rename :selectionRange :semanticHighlightingCapabilities :signatureHelp :synchronization :typeDefinition :typeHierarchyCapabilities))
    695  (TextDocumentContentChangeEvent (:text) (:range :rangeLength))
    696  (TextDocumentEdit (:textDocument :edits) nil)
    697  (TextDocumentIdentifier (:uri) nil)
    698  (TextDocumentItem (:languageId :text :uri :version) nil)
    699  (TextDocumentSyncOptions nil (:change :openClose :save :willSave :willSaveWaitUntil))
    700  (TextEdit (:newText :range) nil)
    701  (InsertReplaceEdit (:newText :insert :replace) nil)
    702  (SnippetTextEdit (:newText :range) (:insertTextFormat))
    703  (TypeDefinitionCapabilities nil (:dynamicRegistration :linkSupport))
    704  (TypeHierarchyCapabilities nil (:dynamicRegistration))
    705  (TypeHierarchyItem (:kind :name :range :selectionRange :uri) (:children :data :deprecated :detail :parents))
    706  (Unregistration (:method :id) nil)
    707  (VersionedTextDocumentIdentifier (:uri) (:version))
    708  (WorkspaceClientCapabilities nil (:applyEdit :configuration :didChangeConfiguration :didChangeWatchedFiles :executeCommand :symbol :workspaceEdit :workspaceFolders))
    709  (WorkspaceEdit nil (:changes :documentChanges :resourceChanges))
    710  (WorkspaceEditCapabilities nil (:documentChanges :failureHandling :resourceChanges :resourceOperations))
    711  (WorkspaceFolder (:uri :name) nil)
    712  (WorkspaceFoldersChangeEvent (:removed :added) nil)
    713  (WorkspaceFoldersOptions nil (:changeNotifications :supported))
    714  (WorkspaceServerCapabilities nil (:workspaceFolders :fileOperations))
    715  (WorkspaceFileOperations nil (:didCreate :willCreate :didRename :willRename :didDelete :willDelete))
    716  (ApplyWorkspaceEditParams (:edit) (:label))
    717  (ApplyWorkspaceEditResponse (:applied) nil)
    718  (CallHierarchyIncomingCall (:from :fromRanges) nil)
    719  (CallHierarchyIncomingCallsParams (:item) nil)
    720  (CallHierarchyOutgoingCall (:to :fromRanges) nil)
    721  (CallHierarchyOutgoingCallsParams (:item) nil)
    722  (CallHierarchyPrepareParams (:textDocument :position) (:uri))
    723  (CodeAction (:title) (:command :diagnostics :edit :isPreferred :kind :data))
    724  (CodeActionKind nil nil)
    725  (CodeActionParams (:textDocument :context :range) nil)
    726  (CodeLens (:range) (:command :data))
    727  (CodeLensParams (:textDocument) nil)
    728  (CodeLensRegistrationOptions nil (:documentSelector :resolveProvider))
    729  (ColorInformation (:color :range) nil)
    730  (ColorPresentation (:label) (:additionalTextEdits :textEdit))
    731  (ColorPresentationParams (:color :textDocument :range) nil)
    732  (ColoringParams (:uri :infos) nil)
    733  (ColoringStyle nil nil)
    734  (CompletionList (:items :isIncomplete) nil)
    735  (CompletionParams (:textDocument :position) (:context :uri))
    736  (CompletionRegistrationOptions nil (:documentSelector :resolveProvider :triggerCharacters))
    737  (ConfigurationParams (:items) nil)
    738  (CreateFile (:kind :uri) (:options))
    739  (DeclarationParams (:textDocument :position) (:uri))
    740  (DefinitionParams (:textDocument :position) (:uri))
    741  (DeleteFile (:kind :uri) (:options))
    742  (DidChangeConfigurationParams (:settings) nil)
    743  (DidChangeTextDocumentParams (:contentChanges :textDocument) (:uri))
    744  (DidChangeWatchedFilesParams (:changes) nil)
    745  (DidChangeWatchedFilesRegistrationOptions (:watchers) nil)
    746  (DidChangeWorkspaceFoldersParams (:event) nil)
    747  (DidCloseTextDocumentParams (:textDocument) nil)
    748  (DidOpenTextDocumentParams (:textDocument) (:text))
    749  (DidSaveTextDocumentParams (:textDocument) (:text))
    750  (DocumentColorParams (:textDocument) nil)
    751  (DocumentFormattingParams (:textDocument :options) nil)
    752  (DocumentHighlight (:range) (:kind))
    753  (DocumentHighlightParams (:textDocument :position) (:uri))
    754  (DocumentLink (:range) (:data :target :tooltip))
    755  (DocumentLinkParams (:textDocument) nil)
    756  (DocumentLinkRegistrationOptions nil (:documentSelector :resolveProvider))
    757  (DocumentOnTypeFormattingParams (:ch :textDocument :options :position) nil)
    758  (DocumentOnTypeFormattingRegistrationOptions (:firstTriggerCharacter) (:documentSelector :moreTriggerCharacter))
    759  (DocumentRangeFormattingParams (:textDocument :options :range) nil)
    760  (DocumentSymbolParams (:textDocument) nil)
    761  (DynamicRegistrationCapabilities nil (:dynamicRegistration))
    762  (ExecuteCommandParams (:command) (:arguments))
    763  (ExecuteCommandRegistrationOptions (:commands) nil)
    764  (FailureHandlingKind nil nil)
    765  (FileRename (:oldUri :newUri) nil)
    766  (FoldingRange (:endLine :startLine) (:endCharacter :kind :startCharacter))
    767  (FoldingRangeKind nil nil)
    768  (FoldingRangeRequestParams (:textDocument) nil)
    769  (Hover (:contents) (:range))
    770  (HoverParams (:textDocument :position) (:uri))
    771  (ImplementationParams (:textDocument :position) (:uri))
    772  (InitializeError (:retry) nil)
    773  (InitializeErrorCode nil nil)
    774  (InitializeParams nil (:capabilities :clientInfo :clientName :initializationOptions :processId :rootPath :rootUri :trace :workspaceFolders))
    775  (InitializeResult (:capabilities) (:serverInfo))
    776  (InitializedParams nil nil)
    777  (LocationLink (:targetSelectionRange :targetUri :targetRange) (:originSelectionRange))
    778  (MarkupKind nil nil)
    779  (MessageParams (:type :message) nil)
    780  (PrepareRenameParams (:textDocument :position) (:uri))
    781  (PrepareRenameResult (:range :placeholder) nil)
    782  (PublishDiagnosticsParams (:diagnostics :uri) (:version))
    783  (QuickPickItem (:label :picked :userData) nil)
    784  (ReferenceParams (:textDocument :context :position) (:uri))
    785  (RegistrationParams (:registrations) nil)
    786  (RenameFile (:kind :newUri :oldUri) (:options))
    787  (RenameFilesParams (:files) nil)
    788  (RenameParams (:newName :textDocument :position) (:uri))
    789  (ResolveTypeHierarchyItemParams (:item :resolve :direction) nil)
    790  (ResourceOperationKind nil nil)
    791  (SelectionRangeParams (:textDocument :positions) nil)
    792  (SemanticHighlightingParams (:textDocument :lines) nil)
    793  (ShowDocumentParams (:uri) (:external :takeFocus :selection))
    794  (ShowDocumentResult (:success) nil)
    795  (ShowInputBoxParams (:prompt) (:value))
    796  (ShowMessageRequestParams (:type :message) (:actions))
    797  (ShowQuickPickParams (:placeHolder :canPickMany :items) nil)
    798  (SignatureHelpParams (:textDocument :position) (:context :uri))
    799  (SignatureHelpRegistrationOptions nil (:documentSelector :triggerCharacters))
    800  (SymbolInformation (:kind :name :location) (:containerName :deprecated))
    801  (TextDocumentChangeRegistrationOptions (:syncKind) (:documentSelector))
    802  (TextDocumentPositionParams (:textDocument :position) (:uri))
    803  (TextDocumentRegistrationOptions nil (:documentSelector))
    804  (TextDocumentSaveRegistrationOptions nil (:documentSelector :includeText))
    805  (TypeDefinitionParams (:textDocument :position) (:uri))
    806  (TypeHierarchyParams (:resolve :textDocument :position) (:direction :uri))
    807  (UnregistrationParams (:unregisterations) nil)
    808  (WatchKind nil nil)
    809  (WillSaveTextDocumentParams (:reason :textDocument) nil)
    810  (WorkspaceSymbolParams (:query) nil)
    811  ;; 3.17
    812  (InlayHint (:label :position) (:kind :paddingLeft :paddingRight))
    813  (InlayHintLabelPart (:value) (:tooltip :location :command))
    814  (InlayHintsParams (:textDocument) (:range)))
    815 
    816 ;; 3.17
    817 (defconst lsp/inlay-hint-kind-type-hint 1)
    818 (defconst lsp/inlay-hint-kind-parameter-hint 2)
    819 
    820 
    821 (provide 'lsp-protocol)
    822 
    823 ;;; lsp-protocol.el ends here