config

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

lsp-protocol.el (45991B)


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