config

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

lsp-protocol.el (43848B)


      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                     `(pcase-defmacro ,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 (if lsp-use-plists
    250     (progn
    251       (defun lsp-get (from key)
    252         (plist-get from key))
    253       (defun lsp-put (where key value)
    254         (plist-put where key value))
    255       (defun lsp-map (fn value)
    256         (-map (-lambda ((k v))
    257                 (funcall fn (lsp-keyword->string k) v))
    258               (-partition 2 value )))
    259       (defalias 'lsp-merge 'append)
    260       (defalias 'lsp-empty? 'null)
    261       (defalias 'lsp-copy 'copy-sequence)
    262       (defun lsp-member? (from key)
    263         (when (listp from)
    264           (plist-member from key)))
    265       (defalias 'lsp-structure-p 'json-plist-p)
    266       (defun lsp-delete (from key)
    267         (cl-remf from key)
    268         from))
    269   (defun lsp-get (from key)
    270     (when from
    271       (gethash (lsp-keyword->string key) from)))
    272   (defun lsp-put (where key value)
    273     (prog1 where
    274       (puthash (lsp-keyword->string key) value where)))
    275   (defun lsp-map (fn value)
    276     (when value
    277       (maphash fn value)))
    278   (defalias 'lsp-merge 'ht-merge)
    279   (defalias 'lsp-empty? 'ht-empty?)
    280   (defalias 'lsp-copy 'ht-copy)
    281   (defun lsp-member? (from key)
    282     (when (hash-table-p from)
    283       (not (eq (gethash (lsp-keyword->string key) from :__lsp_default)
    284                :__lsp_default))))
    285   (defalias 'lsp-structure-p 'hash-table-p)
    286   (defun lsp-delete (from key)
    287     (ht-remove from (lsp-keyword->string key))
    288     from))
    289 
    290 (defmacro lsp-defun (name match-form &rest body)
    291   "Define a function named NAME.
    292 The function destructures its input as MATCH-FORM then executes BODY.
    293 
    294 Note that you have to enclose the MATCH-FORM in a pair of parens,
    295 such that:
    296 
    297   (-defun (x) body)
    298   (-defun (x y ...) body)
    299 
    300 has the usual semantics of `defun'.  Furthermore, these get
    301 translated into a normal `defun', so there is no performance
    302 penalty.
    303 
    304 See `-let' for a description of the destructuring mechanism."
    305   (declare (doc-string 3) (indent defun)
    306            (debug (&define name sexp
    307                            [&optional stringp]
    308                            [&optional ("declare" &rest sexp)]
    309                            [&optional ("interactive" interactive)]
    310                            def-body)))
    311   (cond
    312    ((nlistp match-form)
    313     (signal 'wrong-type-argument (list #'listp match-form)))
    314    ;; no destructuring, so just return regular defun to make things faster
    315    ((-all? #'symbolp match-form)
    316     `(defun ,name ,match-form ,@body))
    317    (t
    318     (-let* ((inputs (--map-indexed (list it (make-symbol (format "input%d" it-index))) match-form))
    319             ((body docs) (cond
    320                           ;; only docs
    321                           ((and (stringp (car body))
    322                                 (not (cdr body)))
    323                            (list body (car body)))
    324                           ;; docs + body
    325                           ((stringp (car body))
    326                            (list (cdr body) (car body)))
    327                           ;; no docs
    328                           (t (list body))))
    329             ((body interactive-form) (cond
    330                                       ;; interactive form
    331                                       ((and (listp (car body))
    332                                             (eq (caar body) 'interactive))
    333                                        (list (cdr body) (car body)))
    334                                       ;; no interactive form
    335                                       (t (list body)))))
    336       ;; TODO: because inputs to the defun are evaluated only once,
    337       ;; -let* need not to create the extra bindings to ensure that.
    338       ;; We should find a way to optimize that.  Not critical however.
    339       `(defun ,name ,(-map #'cadr inputs)
    340          ,@(when docs (list docs))
    341          ,@(when interactive-form (list interactive-form))
    342          (-let* ,inputs ,@body))))))
    343 
    344 
    345 
    346 
    347 ;; manually defined interfaces
    348 (defconst lsp/markup-kind-plain-text "plaintext")
    349 (defconst lsp/markup-kind-markdown "markdown")
    350 
    351 (lsp-interface (JSONResponse (:params :id :method :result) nil)
    352                (JSONResponseError (:error) nil)
    353                (JSONMessage nil (:params :id :method :result :error))
    354                (JSONResult nil (:params :id :method))
    355                (JSONNotification (:params :method) nil)
    356                (JSONRequest (:params :method) nil)
    357                (JSONError (:message :code) (:data))
    358                (ProgressParams (:token :value) nil)
    359                (Edit (:kind) nil)
    360                (WorkDoneProgress (:kind) nil)
    361                (WorkDoneProgressBegin  (:kind :title) (:cancellable :message :percentage))
    362                (WorkDoneProgressReport  (:kind) (:cancellable :message :percentage))
    363                (WorkDoneProgressEnd  (:kind) (:message))
    364                (WorkDoneProgressOptions nil (:workDoneProgress))
    365                (SemanticTokensOptions (:legend) (:rangeProvider :documentProvider))
    366                (SemanticTokensLegend (:tokenTypes :tokenModifiers))
    367                (SemanticTokensResult (:resultId) (:data))
    368                (SemanticTokensPartialResult nil (:data))
    369                (SemanticTokensEdit (:start :deleteCount) (:data))
    370                (SemanticTokensDelta (:resultId) (:edits))
    371                (SemanticTokensDeltaPartialResult nil (:edits)))
    372 
    373 (lsp-interface (v1:ProgressParams (:id :title) (:message :percentage :done)))
    374 
    375 (defun dash-expand:&RangeToPoint (key source)
    376   "Convert the position KEY from SOURCE into a point."
    377   `(lsp--position-to-point
    378     (lsp-get ,source ,key)))
    379 
    380 (lsp-interface (eslint:StatusParams  (:state) nil)
    381                (eslint:OpenESLintDocParams (:url) nil)
    382                (eslint:ConfirmExecutionParams (:scope :file :libraryPath) nil))
    383 
    384 (lsp-interface (haxe:ProcessStartNotification (:title) nil))
    385 
    386 (lsp-interface (pwsh:ScriptRegion (:StartLineNumber :EndLineNumber :StartColumnNumber :EndColumnNumber :Text) nil))
    387 
    388 (lsp-interface (omnisharp:ErrorMessage (:Text :FileName :Line :Column))
    389                (omnisharp:ProjectInformationRequest (:FileName))
    390                (omnisharp:MsBuildProject (:IsUnitProject :IsExe :Platform :Configuration :IntermediateOutputPath :OutputPath :TargetFrameworks :SourceFiles :TargetFramework :TargetPath :AssemblyName :Path :ProjectGuid))
    391                (omnisharp:ProjectInformation (:ScriptProject :MsBuildProject))
    392                (omnisharp:CodeStructureRequest (:FileName))
    393                (omnisharp:CodeStructureResponse (:Elements))
    394                (omnisharp:CodeElement (:Kind :Name :DisplayName :Children :Ranges :Properties))
    395                (omnisharp:CodeElementProperties () (:static :accessibility :testMethodName :testFramework))
    396                (omnisharp:Range (:Start :End))
    397                (omnisharp:RangeList () (:attributes :full :name))
    398                (omnisharp:Point (:Line :Column))
    399                (omnisharp:RunTestsInClassRequest (:MethodNames :RunSettings :TestFrameworkname :TargetFrameworkVersion :NoBuild :Line :Column :Buffer :FileName))
    400                (omnisharp:RunTestResponse (:Results :Pass :Failure :ContextHadNoTests))
    401                (omnisharp:TestMessageEvent (:MessageLevel :Message))
    402                (omnisharp:DotNetTestResult (:MethodName :Outcome :ErrorMessage :ErrorStackTrace :StandardOutput :StandardError)))
    403 
    404 (lsp-interface (csharp-ls:CSharpMetadata (:textDocument))
    405                (csharp-ls:CSharpMetadataResponse (:source :projectName :assemblyName :symbolName)))
    406 
    407 (lsp-interface (rls:Cmd (:args :binary :env :cwd) nil))
    408 
    409 (lsp-interface (rust-analyzer:AnalyzerStatusParams (:textDocument))
    410                (rust-analyzer:SyntaxTreeParams (:textDocument) (:range))
    411                (rust-analyzer:ViewHir (:textDocument :position))
    412                (rust-analyzer:ViewItemTree (:textDocument))
    413                (rust-analyzer:ExpandMacroParams (:textDocument :position) nil)
    414                (rust-analyzer:ExpandedMacro (:name :expansion) nil)
    415                (rust-analyzer:MatchingBraceParams (:textDocument :positions) nil)
    416                (rust-analyzer:OpenCargoTomlParams (:textDocument) nil)
    417                (rust-analyzer:OpenExternalDocsParams (:textDocument :position) nil)
    418                (rust-analyzer:ResovedCodeActionParams (:id :codeActionParams) nil)
    419                (rust-analyzer:JoinLinesParams (:textDocument :ranges) nil)
    420                (rust-analyzer:MoveItemParams (:textDocument :range :direction) nil)
    421                (rust-analyzer:RunnablesParams (:textDocument) (:position))
    422                (rust-analyzer:Runnable (:label :kind :args) (:location))
    423                (rust-analyzer:RunnableArgs (:cargoArgs :executableArgs) (:workspaceRoot :expectTest))
    424                (rust-analyzer:RelatedTestsParams (:textDocument :position) nil)
    425                (rust-analyzer:RelatedTests (:runnable) nil)
    426                (rust-analyzer:SsrParams (:query :parseOnly) nil)
    427                (rust-analyzer:CommandLink (:title :command) (:arguments :tooltip))
    428                (rust-analyzer:CommandLinkGroup (:commands) (:title)))
    429 
    430 (lsp-interface (clojure-lsp:TestTreeParams (:uri :tree) nil)
    431                (clojure-lsp:TestTreeNode (:name :range :nameRange :kind) (:children))
    432                (clojure-lsp:ProjectTreeNode (:name :type) (:nodes :final :id :uri :detail :range)))
    433 
    434 (lsp-interface (terraform-ls:ModuleCalls (:v :module_calls) nil))
    435 (lsp-interface (terraform-ls:Module (:name :docs_link :version :source_type :dependent_modules) nil))
    436 (lsp-interface (terraform-ls:Providers (:v :provider_requirements :installed_providers) nil))
    437 (lsp-interface (terraform-ls:module.terraform (:v :required_version :discovered_version)))
    438 
    439 
    440 ;; begin autogenerated code
    441 
    442 (defvar lsp/completion-item-kind-lookup
    443   [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])
    444 (defconst lsp/completion-item-kind-text 1)
    445 (defconst lsp/completion-item-kind-method 2)
    446 (defconst lsp/completion-item-kind-function 3)
    447 (defconst lsp/completion-item-kind-constructor 4)
    448 (defconst lsp/completion-item-kind-field 5)
    449 (defconst lsp/completion-item-kind-variable 6)
    450 (defconst lsp/completion-item-kind-class 7)
    451 (defconst lsp/completion-item-kind-interface 8)
    452 (defconst lsp/completion-item-kind-module 9)
    453 (defconst lsp/completion-item-kind-property 10)
    454 (defconst lsp/completion-item-kind-unit 11)
    455 (defconst lsp/completion-item-kind-value 12)
    456 (defconst lsp/completion-item-kind-enum 13)
    457 (defconst lsp/completion-item-kind-keyword 14)
    458 (defconst lsp/completion-item-kind-snippet 15)
    459 (defconst lsp/completion-item-kind-color 16)
    460 (defconst lsp/completion-item-kind-file 17)
    461 (defconst lsp/completion-item-kind-reference 18)
    462 (defconst lsp/completion-item-kind-folder 19)
    463 (defconst lsp/completion-item-kind-enum-member 20)
    464 (defconst lsp/completion-item-kind-constant 21)
    465 (defconst lsp/completion-item-kind-struct 22)
    466 (defconst lsp/completion-item-kind-event 23)
    467 (defconst lsp/completion-item-kind-operator 24)
    468 (defconst lsp/completion-item-kind-type-parameter 25)
    469 (defvar lsp/completion-trigger-kind-lookup
    470   [nil Invoked TriggerCharacter TriggerForIncompleteCompletions])
    471 (defconst lsp/completion-trigger-kind-invoked 1)
    472 (defconst lsp/completion-trigger-kind-trigger-character 2)
    473 (defconst lsp/completion-trigger-kind-trigger-for-incomplete-completions 3)
    474 (defvar lsp/diagnostic-severity-lookup
    475   [nil Error Warning Information Hint Max])
    476 (defconst lsp/diagnostic-severity-error 1)
    477 (defconst lsp/diagnostic-severity-warning 2)
    478 (defconst lsp/diagnostic-severity-information 3)
    479 (defconst lsp/diagnostic-severity-hint 4)
    480 (defconst lsp/diagnostic-severity-max 5)
    481 (defvar lsp/diagnostic-tag-lookup
    482   [nil Unnecessary Deprecated])
    483 (defconst lsp/diagnostic-tag-unnecessary 1)
    484 (defconst lsp/diagnostic-tag-deprecated 2)
    485 (defvar lsp/completion-item-tag-lookup
    486   [nil Deprecated])
    487 (defconst lsp/completion-item-tag-deprecated 1)
    488 (defvar lsp/document-highlight-kind-lookup
    489   [nil Text Read Write])
    490 (defconst lsp/document-highlight-kind-text 1)
    491 (defconst lsp/document-highlight-kind-read 2)
    492 (defconst lsp/document-highlight-kind-write 3)
    493 (defvar lsp/file-change-type-lookup
    494   [nil Created Changed Deleted])
    495 (defconst lsp/file-change-type-created 1)
    496 (defconst lsp/file-change-type-changed 2)
    497 (defconst lsp/file-change-type-deleted 3)
    498 (defvar lsp/insert-text-format-lookup
    499   [nil PlainText Snippet])
    500 (defconst lsp/insert-text-format-plain-text 1)
    501 (defconst lsp/insert-text-format-snippet 2)
    502 (defvar lsp/insert-text-mode-lookup
    503   [nil AsIs AdjustIndentation])
    504 (defconst lsp/insert-text-mode-as-it 1)
    505 (defconst lsp/insert-text-mode-adjust-indentation 2)
    506 (defvar lsp/message-type-lookup
    507   [nil Error Warning Info Log])
    508 (defconst lsp/message-type-error 1)
    509 (defconst lsp/message-type-warning 2)
    510 (defconst lsp/message-type-info 3)
    511 (defconst lsp/message-type-log 4)
    512 (defvar lsp/signature-help-trigger-kind-lookup
    513   [nil Invoked TriggerCharacter ContentChange])
    514 (defconst lsp/signature-help-trigger-kind-invoked 1)
    515 (defconst lsp/signature-help-trigger-kind-trigger-character 2)
    516 (defconst lsp/signature-help-trigger-kind-content-change 3)
    517 (defvar lsp/symbol-kind-lookup
    518   [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])
    519 (defconst lsp/symbol-kind-file 1)
    520 (defconst lsp/symbol-kind-module 2)
    521 (defconst lsp/symbol-kind-namespace 3)
    522 (defconst lsp/symbol-kind-package 4)
    523 (defconst lsp/symbol-kind-class 5)
    524 (defconst lsp/symbol-kind-method 6)
    525 (defconst lsp/symbol-kind-property 7)
    526 (defconst lsp/symbol-kind-field 8)
    527 (defconst lsp/symbol-kind-constructor 9)
    528 (defconst lsp/symbol-kind-enum 10)
    529 (defconst lsp/symbol-kind-interface 11)
    530 (defconst lsp/symbol-kind-function 12)
    531 (defconst lsp/symbol-kind-variable 13)
    532 (defconst lsp/symbol-kind-constant 14)
    533 (defconst lsp/symbol-kind-string 15)
    534 (defconst lsp/symbol-kind-number 16)
    535 (defconst lsp/symbol-kind-boolean 17)
    536 (defconst lsp/symbol-kind-array 18)
    537 (defconst lsp/symbol-kind-object 19)
    538 (defconst lsp/symbol-kind-key 20)
    539 (defconst lsp/symbol-kind-null 21)
    540 (defconst lsp/symbol-kind-enum-member 22)
    541 (defconst lsp/symbol-kind-struct 23)
    542 (defconst lsp/symbol-kind-event 24)
    543 (defconst lsp/symbol-kind-operator 25)
    544 (defconst lsp/symbol-kind-type-parameter 26)
    545 (defvar lsp/text-document-save-reason-lookup
    546   [nil Manual AfterDelay FocusOut])
    547 (defconst lsp/text-document-save-reason-manual 1)
    548 (defconst lsp/text-document-save-reason-after-delay 2)
    549 (defconst lsp/text-document-save-reason-focus-out 3)
    550 (defvar lsp/text-document-sync-kind-lookup
    551   [None Full Incremental])
    552 (defconst lsp/text-document-sync-kind-none 0)
    553 (defconst lsp/text-document-sync-kind-full 1)
    554 (defconst lsp/text-document-sync-kind-incremental 2)
    555 (defvar lsp/type-hierarchy-direction-lookup
    556   [nil Children Parents Both])
    557 (defconst lsp/type-hierarchy-direction-children 1)
    558 (defconst lsp/type-hierarchy-direction-parents 2)
    559 (defconst lsp/type-hierarchy-direction-both 3)
    560 (defvar lsp/call-hierarchy-direction-lookup
    561   [nil CallsFrom CallsTo])
    562 (defconst lsp/call-hierarchy-direction-calls-from 1)
    563 (defconst lsp/call-hierarchy-direction-calls-to 2)
    564 (defvar lsp/response-error-code-lookup
    565   [nil ParseError InvalidRequest MethodNotFound InvalidParams InternalError serverErrorStart serverErrorEnd])
    566 (defconst lsp/response-error-code-parse-error 1)
    567 (defconst lsp/response-error-code-invalid-request 2)
    568 (defconst lsp/response-error-code-method-not-found 3)
    569 (defconst lsp/response-error-code-invalid-params 4)
    570 (defconst lsp/response-error-code-internal-error 5)
    571 (defconst lsp/response-error-code-server-error-start 6)
    572 (defconst lsp/response-error-code-server-error-end 7)
    573 
    574 (lsp-interface
    575  (CallHierarchyCapabilities nil (:dynamicRegistration))
    576  (CallHierarchyItem (:kind :name :range :selectionRange :uri) (:detail :tags))
    577  (ClientCapabilities nil (:experimental :textDocument :workspace))
    578  (ClientInfo (:name) (:version))
    579  (CodeActionCapabilities nil (:codeActionLiteralSupport :dynamicRegistration :isPreferredSupport :dataSupport :resolveSupport))
    580  (CodeActionContext (:diagnostics) (:only))
    581  (CodeActionKindCapabilities (:valueSet) nil)
    582  (CodeActionLiteralSupportCapabilities nil (:codeActionKind))
    583  (CodeActionOptions nil (:codeActionKinds :resolveProvider))
    584  (CodeLensCapabilities nil (:dynamicRegistration))
    585  (CodeLensOptions (:resolveProvider) nil)
    586  (Color (:red :green :blue :alpha) nil)
    587  (ColorProviderCapabilities nil (:dynamicRegistration))
    588  (ColorProviderOptions nil (:documentSelector :id))
    589  (ColoringInformation (:range :styles) nil)
    590  (Command (:title :command) (:arguments))
    591  (CompletionCapabilities nil (:completionItem :completionItemKind :contextSupport :dynamicRegistration))
    592  (CompletionContext (:triggerKind) (:triggerCharacter))
    593  (CompletionItem (:label) (:additionalTextEdits :command :commitCharacters :data :deprecated :detail :documentation :filterText :insertText :insertTextFormat :insertTextMode :kind :preselect :sortText :tags :textEdit :score :labelDetails))
    594  (CompletionItemCapabilities nil (:commitCharactersSupport :deprecatedSupport :documentationFormat :preselectSupport :snippetSupport :tagSupport :insertReplaceSupport :resolveSupport))
    595  (CompletionItemKindCapabilities nil (:valueSet))
    596  (CompletionItemTagSupportCapabilities (:valueSet) nil)
    597  (CompletionOptions nil (:resolveProvider :triggerCharacters :allCommitCharacters))
    598  (ConfigurationItem nil (:scopeUri :section))
    599  (CreateFileOptions nil (:ignoreIfExists :overwrite))
    600  (DeclarationCapabilities nil (:dynamicRegistration :linkSupport))
    601  (DefinitionCapabilities nil (:dynamicRegistration :linkSupport))
    602  (DeleteFileOptions nil (:ignoreIfNotExists :recursive))
    603  (Diagnostic (:range :message) (:code :relatedInformation :severity :source :tags))
    604  (DiagnosticRelatedInformation (:location :message) nil)
    605  (DiagnosticsTagSupport (:valueSet) nil)
    606  (DidChangeConfigurationCapabilities nil (:dynamicRegistration))
    607  (DidChangeWatchedFilesCapabilities nil (:dynamicRegistration))
    608  (DocumentFilter nil (:language :pattern :scheme))
    609  (DocumentHighlightCapabilities nil (:dynamicRegistration))
    610  (DocumentLinkCapabilities nil (:dynamicRegistration :tooltipSupport))
    611  (DocumentLinkOptions nil (:resolveProvider))
    612  (DocumentOnTypeFormattingOptions (:firstTriggerCharacter) (:moreTriggerCharacter))
    613  (DocumentSymbol (:kind :name :range :selectionRange) (:children :deprecated :detail))
    614  (DocumentSymbolCapabilities nil (:dynamicRegistration :hierarchicalDocumentSymbolSupport :symbolKind))
    615  (ExecuteCommandCapabilities nil (:dynamicRegistration))
    616  (ExecuteCommandOptions (:commands) nil)
    617  (FileEvent (:type :uri) nil)
    618  (FileSystemWatcher (:globPattern) (:kind))
    619  (FileOperationFilter (:pattern) (:scheme))
    620  (FileOperationPattern (:glob) (:matches :options))
    621  (FileOperationPatternOptions nil (:ignoreCase))
    622  (FileOperationRegistrationOptions (:filters) nil)
    623  (FoldingRangeCapabilities nil (:dynamicRegistration :lineFoldingOnly :rangeLimit))
    624  (FoldingRangeProviderOptions nil (:documentSelector :id))
    625  (FormattingCapabilities nil (:dynamicRegistration))
    626  (FormattingOptions (:tabSize :insertSpaces) (:trimTrailingWhitespace :insertFinalNewline :trimFinalNewlines))
    627  (HoverCapabilities nil (:contentFormat :dynamicRegistration))
    628  (ImplementationCapabilities nil (:dynamicRegistration :linkSupport))
    629  (LabelDetails (:detail :description) nil)
    630  (LinkedEditingRanges (:ranges) (:wordPattern))
    631  (Location (:range :uri) nil)
    632  (MarkedString (:language :value) nil)
    633  (MarkupContent (:kind :value) nil)
    634  (MessageActionItem (:title) nil)
    635  (OnTypeFormattingCapabilities nil (:dynamicRegistration))
    636  (ParameterInformation (:label) (:documentation))
    637  (ParameterInformationCapabilities nil (:labelOffsetSupport))
    638  (Position (:character :line) nil)
    639  (PublishDiagnosticsCapabilities nil (:relatedInformation :tagSupport :versionSupport))
    640  (Range (:start :end) nil)
    641  (RangeFormattingCapabilities nil (:dynamicRegistration))
    642  (ReferenceContext (:includeDeclaration) nil)
    643  (ReferencesCapabilities nil (:dynamicRegistration))
    644  (Registration (:method :id) (:registerOptions))
    645  (RenameCapabilities nil (:dynamicRegistration :prepareSupport))
    646  (RenameFileOptions nil (:ignoreIfExists :overwrite))
    647  (RenameOptions nil (:documentSelector :id :prepareProvider))
    648  (ResourceChange nil (:current :newUri))
    649  (ResourceOperation (:kind) nil)
    650  (SaveOptions nil (:includeText))
    651  (SelectionRange (:range) (:parent))
    652  (SelectionRangeCapabilities nil (:dynamicRegistration))
    653  (SemanticHighlightingCapabilities nil (:semanticHighlighting))
    654  (SemanticHighlightingInformation (:line) (:tokens))
    655  (SemanticHighlightingServerCapabilities nil (:scopes))
    656  (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))
    657  (ServerInfo (:name) (:version))
    658  (SignatureHelp (:signatures) (:activeParameter :activeSignature))
    659  (SignatureHelpCapabilities nil (:contextSupport :dynamicRegistration :signatureInformation))
    660  (SignatureHelpContext (:triggerKind :isRetrigger) (:activeSignatureHelp :triggerCharacter))
    661  (SignatureHelpOptions nil (:retriggerCharacters :triggerCharacters))
    662  (SignatureInformation (:label) (:documentation :parameters))
    663  (SignatureInformationCapabilities nil (:documentationFormat :parameterInformation))
    664  (StaticRegistrationOptions nil (:documentSelector :id))
    665  (SymbolCapabilities nil (:dynamicRegistration :symbolKind))
    666  (SymbolKindCapabilities nil (:valueSet))
    667  (SynchronizationCapabilities nil (:didSave :dynamicRegistration :willSave :willSaveWaitUntil))
    668  (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))
    669  (TextDocumentContentChangeEvent (:text) (:range :rangeLength))
    670  (TextDocumentEdit (:textDocument :edits) nil)
    671  (TextDocumentIdentifier (:uri) nil)
    672  (TextDocumentItem (:languageId :text :uri :version) nil)
    673  (TextDocumentSyncOptions nil (:change :openClose :save :willSave :willSaveWaitUntil))
    674  (TextEdit (:newText :range) nil)
    675  (InsertReplaceEdit (:newText :insert :replace) nil)
    676  (SnippetTextEdit (:newText :range) (:insertTextFormat))
    677  (TypeDefinitionCapabilities nil (:dynamicRegistration :linkSupport))
    678  (TypeHierarchyCapabilities nil (:dynamicRegistration))
    679  (TypeHierarchyItem (:kind :name :range :selectionRange :uri) (:children :data :deprecated :detail :parents))
    680  (Unregistration (:method :id) nil)
    681  (VersionedTextDocumentIdentifier (:uri) (:version))
    682  (WorkspaceClientCapabilities nil (:applyEdit :configuration :didChangeConfiguration :didChangeWatchedFiles :executeCommand :symbol :workspaceEdit :workspaceFolders))
    683  (WorkspaceEdit nil (:changes :documentChanges :resourceChanges))
    684  (WorkspaceEditCapabilities nil (:documentChanges :failureHandling :resourceChanges :resourceOperations))
    685  (WorkspaceFolder (:uri :name) nil)
    686  (WorkspaceFoldersChangeEvent (:removed :added) nil)
    687  (WorkspaceFoldersOptions nil (:changeNotifications :supported))
    688  (WorkspaceServerCapabilities nil (:workspaceFolders :fileOperations))
    689  (WorkspaceFileOperations nil (:didCreate :willCreate :didRename :willRename :didDelete :willDelete))
    690  (ApplyWorkspaceEditParams (:edit) (:label))
    691  (ApplyWorkspaceEditResponse (:applied) nil)
    692  (CallHierarchyIncomingCall (:from :fromRanges) nil)
    693  (CallHierarchyIncomingCallsParams (:item) nil)
    694  (CallHierarchyOutgoingCall (:to :fromRanges) nil)
    695  (CallHierarchyOutgoingCallsParams (:item) nil)
    696  (CallHierarchyPrepareParams (:textDocument :position) (:uri))
    697  (CodeAction (:title) (:command :diagnostics :edit :isPreferred :kind :data))
    698  (CodeActionKind nil nil)
    699  (CodeActionParams (:textDocument :context :range) nil)
    700  (CodeLens (:range) (:command :data))
    701  (CodeLensParams (:textDocument) nil)
    702  (CodeLensRegistrationOptions nil (:documentSelector :resolveProvider))
    703  (ColorInformation (:color :range) nil)
    704  (ColorPresentation (:label) (:additionalTextEdits :textEdit))
    705  (ColorPresentationParams (:color :textDocument :range) nil)
    706  (ColoringParams (:uri :infos) nil)
    707  (ColoringStyle nil nil)
    708  (CompletionList (:items :isIncomplete) nil)
    709  (CompletionParams (:textDocument :position) (:context :uri))
    710  (CompletionRegistrationOptions nil (:documentSelector :resolveProvider :triggerCharacters))
    711  (ConfigurationParams (:items) nil)
    712  (CreateFile (:kind :uri) (:options))
    713  (DeclarationParams (:textDocument :position) (:uri))
    714  (DefinitionParams (:textDocument :position) (:uri))
    715  (DeleteFile (:kind :uri) (:options))
    716  (DidChangeConfigurationParams (:settings) nil)
    717  (DidChangeTextDocumentParams (:contentChanges :textDocument) (:uri))
    718  (DidChangeWatchedFilesParams (:changes) nil)
    719  (DidChangeWatchedFilesRegistrationOptions (:watchers) nil)
    720  (DidChangeWorkspaceFoldersParams (:event) nil)
    721  (DidCloseTextDocumentParams (:textDocument) nil)
    722  (DidOpenTextDocumentParams (:textDocument) (:text))
    723  (DidSaveTextDocumentParams (:textDocument) (:text))
    724  (DocumentColorParams (:textDocument) nil)
    725  (DocumentFormattingParams (:textDocument :options) nil)
    726  (DocumentHighlight (:range) (:kind))
    727  (DocumentHighlightParams (:textDocument :position) (:uri))
    728  (DocumentLink (:range) (:data :target :tooltip))
    729  (DocumentLinkParams (:textDocument) nil)
    730  (DocumentLinkRegistrationOptions nil (:documentSelector :resolveProvider))
    731  (DocumentOnTypeFormattingParams (:ch :textDocument :options :position) nil)
    732  (DocumentOnTypeFormattingRegistrationOptions (:firstTriggerCharacter) (:documentSelector :moreTriggerCharacter))
    733  (DocumentRangeFormattingParams (:textDocument :options :range) nil)
    734  (DocumentSymbolParams (:textDocument) nil)
    735  (DynamicRegistrationCapabilities nil (:dynamicRegistration))
    736  (ExecuteCommandParams (:command) (:arguments))
    737  (ExecuteCommandRegistrationOptions (:commands) nil)
    738  (FailureHandlingKind nil nil)
    739  (FileRename (:oldUri :newUri) nil)
    740  (FoldingRange (:endLine :startLine) (:endCharacter :kind :startCharacter))
    741  (FoldingRangeKind nil nil)
    742  (FoldingRangeRequestParams (:textDocument) nil)
    743  (Hover (:contents) (:range))
    744  (HoverParams (:textDocument :position) (:uri))
    745  (ImplementationParams (:textDocument :position) (:uri))
    746  (InitializeError (:retry) nil)
    747  (InitializeErrorCode nil nil)
    748  (InitializeParams nil (:capabilities :clientInfo :clientName :initializationOptions :processId :rootPath :rootUri :trace :workspaceFolders))
    749  (InitializeResult (:capabilities) (:serverInfo))
    750  (InitializedParams nil nil)
    751  (LocationLink (:targetSelectionRange :targetUri :targetRange) (:originSelectionRange))
    752  (MarkupKind nil nil)
    753  (MessageParams (:type :message) nil)
    754  (PrepareRenameParams (:textDocument :position) (:uri))
    755  (PrepareRenameResult (:range :placeholder) nil)
    756  (PublishDiagnosticsParams (:diagnostics :uri) (:version))
    757  (QuickPickItem (:label :picked :userData) nil)
    758  (ReferenceParams (:textDocument :context :position) (:uri))
    759  (RegistrationParams (:registrations) nil)
    760  (RenameFile (:kind :newUri :oldUri) (:options))
    761  (RenameFilesParams (:files) nil)
    762  (RenameParams (:newName :textDocument :position) (:uri))
    763  (ResolveTypeHierarchyItemParams (:item :resolve :direction) nil)
    764  (ResourceOperationKind nil nil)
    765  (SelectionRangeParams (:textDocument :positions) nil)
    766  (SemanticHighlightingParams (:textDocument :lines) nil)
    767  (ShowDocumentParams (:uri) (:external :takeFocus :selection))
    768  (ShowDocumentResult (:success) nil)
    769  (ShowInputBoxParams (:prompt) (:value))
    770  (ShowMessageRequestParams (:type :message) (:actions))
    771  (ShowQuickPickParams (:placeHolder :canPickMany :items) nil)
    772  (SignatureHelpParams (:textDocument :position) (:context :uri))
    773  (SignatureHelpRegistrationOptions nil (:documentSelector :triggerCharacters))
    774  (SymbolInformation (:kind :name :location) (:containerName :deprecated))
    775  (TextDocumentChangeRegistrationOptions (:syncKind) (:documentSelector))
    776  (TextDocumentPositionParams (:textDocument :position) (:uri))
    777  (TextDocumentRegistrationOptions nil (:documentSelector))
    778  (TextDocumentSaveRegistrationOptions nil (:documentSelector :includeText))
    779  (TypeDefinitionParams (:textDocument :position) (:uri))
    780  (TypeHierarchyParams (:resolve :textDocument :position) (:direction :uri))
    781  (UnregistrationParams (:unregisterations) nil)
    782  (WatchKind nil nil)
    783  (WillSaveTextDocumentParams (:reason :textDocument) nil)
    784  (WorkspaceSymbolParams (:query) nil)
    785  ;; 3.17
    786  (InlayHint (:label :position) (:kind :paddingLeft :paddingRight))
    787  (InlayHintLabelPart (:value) (:tooltip :location :command))
    788  (InlayHintsParams (:textDocument) (:range)))
    789 
    790 ;; 3.17
    791 (defconst lsp/inlay-hint-kind-type-hint 1)
    792 (defconst lsp/inlay-hint-kind-parameter-hint 2)
    793 
    794 
    795 (provide 'lsp-protocol)
    796 
    797 ;;; lsp-protocol.el ends here