docs(lsp): update example, optional parameters #31299

This commit is contained in:
Yi Ming 2024-11-29 00:08:27 +08:00 committed by GitHub
parent 864f25d6b0
commit 146b8300a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 7 deletions

View File

@ -975,7 +975,7 @@ Lua module: vim.lsp.client *lsp-client*
• {dynamic_capabilities} (`lsp.DynamicCapabilities`) • {dynamic_capabilities} (`lsp.DynamicCapabilities`)
• {request} (`fun(self: vim.lsp.Client, method: string, params: table?, handler: lsp.Handler?, bufnr: integer?): boolean, integer?`) • {request} (`fun(self: vim.lsp.Client, method: string, params: table?, handler: lsp.Handler?, bufnr: integer?): boolean, integer?`)
See |Client:request()|. See |Client:request()|.
• {request_sync} (`fun(self: vim.lsp.Client, method: string, params: table, timeout_ms: integer?, bufnr: integer): {err: lsp.ResponseError?, result:any}?, string?`) • {request_sync} (`fun(self: vim.lsp.Client, method: string, params: table, timeout_ms: integer?, bufnr: integer?): {err: lsp.ResponseError?, result:any}?, string?`)
See |Client:request_sync()|. See |Client:request_sync()|.
• {notify} (`fun(self: vim.lsp.Client, method: string, params: table?): boolean`) • {notify} (`fun(self: vim.lsp.Client, method: string, params: table?): boolean`)
See |Client:notify()|. See |Client:notify()|.
@ -1179,7 +1179,7 @@ Client:request({method}, {params}, {handler}, {bufnr})
• {method} (`string`) LSP method name. • {method} (`string`) LSP method name.
• {params} (`table?`) LSP request params. • {params} (`table?`) LSP request params.
• {handler} (`lsp.Handler?`) Response |lsp-handler| for this method. • {handler} (`lsp.Handler?`) Response |lsp-handler| for this method.
• {bufnr} (`integer?`) Buffer handle. 0 for current (default). • {bufnr} (`integer?`) (default: 0) Buffer handle, or 0 for current.
Return (multiple): ~ Return (multiple): ~
(`boolean`) status indicates whether the request was successful. If it (`boolean`) status indicates whether the request was successful. If it
@ -1201,7 +1201,8 @@ Client:request_sync({method}, {params}, {timeout_ms}, {bufnr})
• {params} (`table`) LSP request params. • {params} (`table`) LSP request params.
• {timeout_ms} (`integer?`) Maximum time in milliseconds to wait for a • {timeout_ms} (`integer?`) Maximum time in milliseconds to wait for a
result. Defaults to 1000 result. Defaults to 1000
• {bufnr} (`integer`) Buffer handle (0 for current). • {bufnr} (`integer?`) (default: 0) Buffer handle, or 0 for
current.
Return (multiple): ~ Return (multiple): ~
(`{err: lsp.ResponseError?, result:any}?`) `result` and `err` from the (`{err: lsp.ResponseError?, result:any}?`) `result` and `err` from the
@ -1385,7 +1386,7 @@ format({opts}) *vim.lsp.buf.format()*
predicate are included. Example: >lua predicate are included. Example: >lua
-- Never request typescript-language-server for formatting -- Never request typescript-language-server for formatting
vim.lsp.buf.format { vim.lsp.buf.format {
filter = function(client) return client.name ~= "tsserver" end filter = function(client) return client.name ~= "ts_ls" end
} }
< <
• {async}? (`boolean`, default: false) If true the method • {async}? (`boolean`, default: false) If true the method

View File

@ -487,7 +487,7 @@ end
--- ```lua --- ```lua
--- -- Never request typescript-language-server for formatting --- -- Never request typescript-language-server for formatting
--- vim.lsp.buf.format { --- vim.lsp.buf.format {
--- filter = function(client) return client.name ~= "tsserver" end --- filter = function(client) return client.name ~= "ts_ls" end
--- } --- }
--- ``` --- ```
--- @field filter? fun(client: vim.lsp.Client): boolean? --- @field filter? fun(client: vim.lsp.Client): boolean?

View File

@ -639,7 +639,7 @@ end
--- @param method string LSP method name. --- @param method string LSP method name.
--- @param params? table LSP request params. --- @param params? table LSP request params.
--- @param handler? lsp.Handler Response |lsp-handler| for this method. --- @param handler? lsp.Handler Response |lsp-handler| for this method.
--- @param bufnr? integer Buffer handle. 0 for current (default). --- @param bufnr? integer (default: 0) Buffer handle, or 0 for current.
--- @return boolean status indicates whether the request was successful. --- @return boolean status indicates whether the request was successful.
--- If it is `false`, then it will always be `false` (the client has shutdown). --- If it is `false`, then it will always be `false` (the client has shutdown).
--- @return integer? request_id Can be used with |Client:cancel_request()|. --- @return integer? request_id Can be used with |Client:cancel_request()|.
@ -718,7 +718,7 @@ end
--- @param params table LSP request params. --- @param params table LSP request params.
--- @param timeout_ms integer? Maximum time in milliseconds to wait for --- @param timeout_ms integer? Maximum time in milliseconds to wait for
--- a result. Defaults to 1000 --- a result. Defaults to 1000
--- @param bufnr integer Buffer handle (0 for current). --- @param bufnr? integer (default: 0) Buffer handle, or 0 for current.
--- @return {err: lsp.ResponseError?, result:any}? `result` and `err` from the |lsp-handler|. --- @return {err: lsp.ResponseError?, result:any}? `result` and `err` from the |lsp-handler|.
--- `nil` is the request was unsuccessful --- `nil` is the request was unsuccessful
--- @return string? err On timeout, cancel or error, where `err` is a --- @return string? err On timeout, cancel or error, where `err` is a