docs(lsp): correct usage examples of formatexpr (#16216)

This commit is contained in:
Michael Lingelbach
2021-11-02 17:02:04 -07:00
committed by GitHub
parent 487286b621
commit 7899c4099b
2 changed files with 3 additions and 5 deletions

View File

@@ -63,7 +63,7 @@ Example config (in init.vim): >
-- Use LSP as the handler for formatexpr. -- Use LSP as the handler for formatexpr.
-- See `:help formatexpr` for more information. -- See `:help formatexpr` for more information.
vim.api.nvim_buf_set_option(0, 'formatexpr', 'v:lua.vim.lsp.formatexpr') vim.api.nvim_buf_set_option(0, 'formatexpr', 'v:lua.vim.lsp.formatexpr()')
-- For plugins with an `on_attach` callback, call them here. For example: -- For plugins with an `on_attach` callback, call them here. For example:
-- require('completion').on_attach() -- require('completion').on_attach()

View File

@@ -1543,12 +1543,10 @@ end
--- ---
--- Currently only supports a single client. This can be set via --- Currently only supports a single client. This can be set via
--- `setlocal formatexpr=v:lua.vim.lsp.formatexpr()` but will typically or in `on_attach` --- `setlocal formatexpr=v:lua.vim.lsp.formatexpr()` but will typically or in `on_attach`
--- via `vim.api.nvim_buf_set_option(bufnr, 'formatexpr', 'v:lua.vim.lsp.formatexpr()')`. --- via `vim.api.nvim_buf_set_option(bufnr, 'formatexpr', 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')`.
---
--- Can additionally be wrapped with a function that passes an optional table for customization.
--- ---
---@param opts table options for customizing the formatting expression which takes the ---@param opts table options for customizing the formatting expression which takes the
--- following keys: --- following optional keys:
--- * timeout_ms (default 500ms). The timeout period for the formatting request. --- * timeout_ms (default 500ms). The timeout period for the formatting request.
function lsp.formatexpr(opts) function lsp.formatexpr(opts)
opts = opts or {} opts = opts or {}