robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

robinmerge: 1dc9728daa1d8a2702

master
142.1 KiB3282 linesraw
1*lsp.txt*   LSP
2
3
4                            NVIM REFERENCE MANUAL
5
6
7LSP client/framework                                     *lsp* *LSP* *vim.lsp*
8
9Nvim supports the Language Server Protocol (LSP), which means it acts as
10a client to LSP servers and includes a Lua framework `vim.lsp` for building
11enhanced LSP tools.
12
13    https://microsoft.github.io/language-server-protocol/
14
15LSP facilitates features like go-to-definition, find references, hover,
16completion, rename, format, refactor, etc., using semantic whole-project
17analysis (unlike |ctags|).
18
19                                      Type |gO| to see the table of contents.
20
21==============================================================================
22QUICKSTART                                              *lsp-quickstart*
23
24Nvim provides an LSP client, but the servers are provided by third parties.
25Follow these steps to get LSP features:
26
271. Install language servers using your package manager or by following the
28   upstream installation instructions. You can find language servers here:
29   https://microsoft.github.io/language-server-protocol/implementors/servers/
302. Define a new config |lsp-new-config| (or install https://github.com/neovim/nvim-lspconfig).
31   Example: >lua
32     vim.lsp.config['emmylua_ls'] = {
33       -- Command and arguments to start the server.
34       cmd = { 'emmylua_ls' },
35       -- Filetypes to automatically attach to.
36       filetypes = { 'lua' },
37       -- Sets the workspace "root" to the directory where any of these files is found.
38       -- Files sharing a root will reuse the LSP client/connection.
39       -- Nested lists indicate equal priority, see |vim.lsp.Config|.
40       root_markers = { { '.emmyrc.json', '.luarc.json' }, '.git' },
41       -- Server-specific settings. https://github.com/EmmyLuaLs/emmylua-analyzer-rust/blob/main/docs/config/emmyrc_json_EN.md
42       settings = {
43         runtime = {
44           version = 'LuaJIT',
45         }
46       }
47     }
483. Use |vim.lsp.enable()| to enable the config. See |lsp-activate|.
49   Example: >lua
50     vim.lsp.enable('emmylua_ls')
514. Open a code file matching one of the `filetypes` specified in the config.
52   Note: Depending on the LSP server, you may need to ensure your project has
53   a |lsp-root_markers| file so the workspace can be recognized.
545. Check that LSP is active ("attached") for the buffer: >vim
55     :checkhealth vim.lsp
566. Note: some LSP features are disabled by default, you can enable them
57   manually:
58     - |lsp-codelens|
59     - |lsp-linked_editing_range|
60     - |lsp-inlay_hint|
61     - |lsp-inline_completion|
627. (Optional) Configure keymaps and autocommands to use LSP features.
63   |lsp-attach|
64
65==============================================================================
66DEFAULTS                                                *lsp-defaults*
67
68When LSP activates, by default it enables various LSP features and sets
69options and keymaps, listed below, if (1) the language server supports the
70functionality and (2) the options are empty or were set by the builtin runtime
71(ftplugin) files. The options are not restored when the LSP client is stopped
72or detached.
73
74GLOBAL DEFAULTS                       *gra* *gri* *grn* *grr* *grt* *grx* *i_CTRL-S*
75
76These GLOBAL keymaps are created unconditionally when Nvim starts:
77
78- "gra" (Normal and Visual mode) is mapped to |vim.lsp.buf.code_action()|
79- "gri" is mapped to |vim.lsp.buf.implementation()|
80- "grn" is mapped to |vim.lsp.buf.rename()|
81- "grr" is mapped to |vim.lsp.buf.references()|
82- "grt" is mapped to |vim.lsp.buf.type_definition()|
83- "grx" is mapped to |vim.lsp.codelens.run()|
84- "gO" is mapped to |vim.lsp.buf.document_symbol()|
85- CTRL-S (Insert mode) is mapped to |vim.lsp.buf.signature_help()|
86- |v_an| and |v_in| fall back to LSP |vim.lsp.buf.selection_range()| if
87  treesitter is not active.
88- |gx| handles `textDocument/documentLink`. Example: with gopls, invoking gx
89  on "os" in this Go code will open documentation externally: >
90    package nvim
91    import (
92       "os"
93    )
94<
95These LSP features are enabled by default:
96
97- Diagnostics |lsp-diagnostic|. See |vim.diagnostic.config()| to customize.
98- `workspace/didChangeWatchedFiles` (except on Linux). If you see poor
99  performance in big workspaces, run `:checkhealth vim.lsp` and look for "file
100  watching". Try disabling file-watching: >lua
101    local capabilities = vim.lsp.protocol.make_client_capabilities()
102    if capabilities.workspace then
103      capabilities.workspace.didChangeWatchedFiles = nil
104    end
105    vim.lsp.config('*', {
106      capabilities = capabilities,
107    })
108<
109
110BUFFER-LOCAL DEFAULTS
111
112- 'omnifunc' is set to |vim.lsp.omnifunc()|, use |i_CTRL-X_CTRL-O| to trigger
113  completion.
114- 'tagfunc' is set to |vim.lsp.tagfunc()|. This enables features like
115  go-to-definition, |:tjump|, and keymaps like |CTRL-]|, |CTRL-W_]|,
116  |CTRL-W_}| to utilize the language server.
117- 'formatexpr' is set to |vim.lsp.formatexpr()|, so you can format lines via
118  |gq| if the language server supports it.
119  - To opt out of this use |gw| instead of gq, or clear 'formatexpr' on |LspAttach|.
120- |K| is mapped to |vim.lsp.buf.hover()| unless 'keywordprg' is customized or
121  a custom keymap for `K` exists.
122- Document colors are enabled for highlighting color references in a document.
123  - To opt out call `vim.lsp.document_color.enable(false, { bufnr = ev.buf })` on |LspAttach|.
124
125DISABLING DEFAULTS                                      *lsp-defaults-disable*
126
127You can remove GLOBAL keymaps at any time using |vim.keymap.del()| or
128|:unmap|. See also |gr-default|.
129
130To remove or override BUFFER-LOCAL defaults, define a |LspAttach| handler: >lua
131
132    vim.api.nvim_create_autocmd('LspAttach', {
133      callback = function(ev)
134        -- Unset 'formatexpr'
135        vim.bo[ev.buf].formatexpr = nil
136        -- Unset 'omnifunc'
137        vim.bo[ev.buf].omnifunc = nil
138        -- Unmap K
139        vim.keymap.del('n', 'K', { buf = ev.buf })
140        -- Disable document colors
141        vim.lsp.document_color.enable(false, { bufnr = ev.buf })
142      end,
143    })
144<
145==============================================================================
146COMMANDS                                        *:lsp* *lsp-commands* *E5800*
147
148                                                *E5801*
149The following commands operate on |lsp-config|s:
150
151                                                *:lsp-enable* *E5802* *E5803*
152:lsp enable [config_name]
153    Activates LSP for current and future buffers. See |vim.lsp.enable()|.
154
155                                                *:lsp-disable* *E5804*
156:lsp disable [config_name]
157    Disables LSP (and stops if running) for current and future buffers.
158    See |vim.lsp.enable()|.
159
160                                                *E5805* *E5806*
161The following commands operate on running clients:
162
163                                                *:lsp-restart*
164:lsp restart [client_name]
165    Restarts LSP clients and servers. If no client names are given, all active
166    clients attached to the current buffer are restarted.
167
168                                                *:lsp-stop*
169:lsp stop [client_name]
170    Stops LSP clients and servers. If no client names are given, all active
171    clients attached to the current buffer are stopped. Use |Client:stop()| for
172    non-interactive use.
173
174==============================================================================
175CONFIG                                                  *lsp-config*
176
177You can configure LSP behavior statically via vim.lsp.config(), and
178dynamically via |lsp-attach| or |Client:on_attach()|.
179
180Use |vim.lsp.config()| to define or modify LSP configurations, and
181|vim.lsp.enable()| to auto-activate them. This is basically a wrapper around
182|vim.lsp.start()| which allows you to share and merge configs (provided by
183Nvim, plugins, and your local config).
184
185
186NEW CONFIG                                            *lsp-new-config*
187
188To create a new config you can either use `vim.lsp.config()` or create
189a `lsp/<config-name>.lua` file.
190
191
192EXAMPLE: DEFINE A CONFIG AS CODE ~
193
1941. Run `:lua vim.lsp.config('foo', {cmd={'true'}})`
1952. Run `:lua vim.lsp.enable('foo')`
1963. Run `:checkhealth vim.lsp`, check "Enabled Configurations". 😎
197
198
199EXAMPLE: DEFINE A CONFIG AS A FILE ~
200
2011. Create a file `lsp/foo.lua` somewhere on your 'runtimepath'. >
202   :exe 'edit' stdpath('config') .. '/lsp/foo.lua'
2032. Add this code to the file (or copy an example from
204   https://github.com/neovim/nvim-lspconfig): >
205   return {
206     cmd = { 'true' },
207   }
2083. Save the file (with `++p` to ensure its parent directory is created). >
209   :write ++p
2104. Enable the config. >
211   :lua vim.lsp.enable('foo')
2125. Run `:checkhealth vim.lsp`, check "Enabled Configurations". 🌈
213
214
215HOW CONFIGS ACTIVATE                                    *lsp-activate*
216
217Call |vim.lsp.enable()| to ENABLE a config: it will automatically ACTIVATE
218(attach a client) whenever you open a buffer, if:
219
220- 'filetype' matches one of the config `filetypes`
221- 'buftype' is empty or "help"
222- `root_markers` or `root_dir()` resolved a workspace root, or the config has
223  `workspace_required=false`
224
225Note: The initial call to |vim.lsp.enable()| (or |:lsp-enable|) also actively
226checks and activates EXISTING buffers, if any.
227
228
229HOW CONFIGS ARE MERGED                                  *lsp-config-merge*
230
231When an LSP client starts, it resolves its configuration by merging the
232following sources (merge semantics defined by |vim.tbl_deep_extend()| with
233"force" behavior), in order of increasing priority:
234
2351. Configuration defined for the `'*'` name.
2362. The merged configuration of all `lsp/<config>.lua` files in 'runtimepath'
237   for the config named `<config>`.
2383. The merged configuration of all `after/lsp/<config>.lua` files in
239   'runtimepath'.
240   - This behavior of the "after/" directory is a standard Vim feature
241     |after-directory| which allows you to override `lsp/*.lua` configs
242     provided by plugins (such as nvim-lspconfig).
2434. Configurations defined anywhere else.
244
245Example: given the following configs... >lua
246
247  -- Defined in init.lua
248  vim.lsp.config('*', {
249    capabilities = {
250      textDocument = {
251        semanticTokens = {
252          multilineTokenSupport = true,
253        }
254      }
255    },
256    root_markers = { '.git' },
257  })
258  -- Defined in <rtp>/lsp/clangd.lua
259  return {
260    cmd = { 'clangd' },
261    root_markers = { '.clangd', 'compile_commands.json' },
262    filetypes = { 'c', 'cpp' },
263  }
264  -- Defined in init.lua
265  vim.lsp.config('clangd', {
266    filetypes = { 'c' },
267  })
268<
269...the merged result is: >lua
270
271  {
272    -- From the clangd configuration in <rtp>/lsp/clangd.lua
273    cmd = { 'clangd' },
274
275    -- From the clangd configuration in <rtp>/lsp/clangd.lua
276    -- Overrides the "*" configuration in init.lua
277    root_markers = { '.clangd', 'compile_commands.json' },
278
279    -- From the clangd configuration in init.lua
280    -- Overrides the clangd configuration in <rtp>/lsp/clangd.lua
281    filetypes = { 'c' },
282
283    -- From the "*" configuration in init.lua
284    capabilities = {
285      textDocument = {
286        semanticTokens = {
287          multilineTokenSupport = true,
288        }
289      }
290    }
291  }
292<
293
294CONFIGURE ON ATTACH                                     *lsp-attach*
295
296To use LSP features beyond those provided by Nvim (see |lsp-buf|), you can set
297keymaps and options on |Client:on_attach()| or |LspAttach|. Not all language
298servers provide the same capabilities; check `supports_method()` in your
299LspAttach handler.
300                                                        *lsp-lint* *lsp-format*
301Example: Enable auto-completion and auto-formatting ("linting"): >lua
302
303    vim.api.nvim_create_autocmd('LspAttach', {
304      group = vim.api.nvim_create_augroup('my.lsp'),
305      callback = function(ev)
306        local client = assert(vim.lsp.get_client_by_id(ev.data.client_id))
307        if client:supports_method('textDocument/implementation') then
308          -- Create a keymap for vim.lsp.buf.implementation ...
309        end
310
311        -- Enable auto-completion. Note: Use CTRL-Y to select an item. |complete_CTRL-Y|
312        if client:supports_method('textDocument/completion') then
313          -- Optional: trigger autocompletion on EVERY keypress. May be slow!
314          -- local chars = {}; for i = 32, 126 do table.insert(chars, string.char(i)) end
315          -- client.server_capabilities.completionProvider.triggerCharacters = chars
316
317          vim.lsp.completion.enable(true, client.id, ev.buf, {autotrigger = true})
318        end
319
320        -- Auto-format ("lint") on save.
321        -- Usually not needed if server supports "textDocument/willSaveWaitUntil".
322        if not client:supports_method('textDocument/willSaveWaitUntil')
323            and client:supports_method('textDocument/formatting') then
324          vim.api.nvim_create_autocmd('BufWritePre', {
325            group = vim.api.nvim_create_augroup('my.lsp', {clear=false}),
326            buffer = ev.buf,
327            callback = function()
328              vim.lsp.buf.format({ bufnr = ev.buf, id = client.id, timeout_ms = 1000 })
329            end,
330          })
331        end
332      end,
333    })
334<
335                                                         *lsp-buf-working-dir*
336The LSP server decides the "workspace root" (|lsp-root_dir()|) of a buffer,
337but the Nvim |current-directory| does not follow it, so commands like |:make|,
338|:grep| and |:terminal| do not run from the workspace root. You can use |:bcd|
339to sync each buffer's directory to its LSP workspace root: >lua
340
341    vim.api.nvim_create_autocmd('LspAttach', {
342      group = vim.api.nvim_create_augroup('my.lsp.bufdir', {}),
343      callback = function(ev)
344        local client = assert(vim.lsp.get_client_by_id(ev.data.client_id))
345        if client.root_dir then
346          vim.cmd.bcd(client.root_dir)
347        end
348      end,
349    })
350<
351To see the capabilities for a given server, try this in a LSP-enabled buffer: >vim
352
353    :lua =vim.lsp.get_clients()[1].server_capabilities
354
355================================================================================
356FAQ                                                     *lsp-faq*
357
358- Q: How to force-reload LSP?
359- A: Use `:lsp restart`. You can also stop all clients, then reload the buffer: >vim
360     :lsp stop
361     :edit
362<
363- Q: Why isn't completion working?
364- A: In the buffer where you want to use LSP, check that 'omnifunc' is set to
365     "v:lua.vim.lsp.omnifunc": `:verbose set omnifunc?`
366     - Some other plugin may be overriding the option. To avoid that you could
367       set the option in an |after-directory| ftplugin, e.g.
368       "after/ftplugin/python.vim".
369
370- Q: How do I run a request synchronously (e.g. for formatting on file save)?
371- A: Check if the function has an `async` parameter and set the value to
372  false. E.g. code formatting: >vim
373
374     " Auto-format *.rs (rust) files prior to saving them
375     " (async = false is the default for format)
376     autocmd BufWritePre *.rs lua vim.lsp.buf.format({ async = false })
377<
378
379- Q: How to avoid my own lsp/ folder being overridden?
380- A: Place your configs under "after/lsp/". Files in "after/lsp/" are loaded
381     after those in "nvim/lsp/", so your settings will take precedence over
382     the defaults provided by nvim-lspconfig. See also: |after-directory|
383
384                                                        *lsp-vs-treesitter*
385- Q: How do LSP, Treesitter and Ctags compare?
386- A: LSP requires a client and language server. The language server uses
387     semantic analysis to understand code at a project level. This provides
388     language servers with the ability to rename across files, find
389     definitions in external libraries and more.
390
391     |treesitter| is a language parsing library that provides excellent tools
392     for incrementally parsing text and handling errors. This makes it a great
393     fit for editors to understand the contents of the current file for things
394     like syntax highlighting, simple goto-definitions, scope analysis and
395     more.
396
397     A |ctags|-like program can generate a |tags| file that allows Nvim to
398     jump to definitions, provide simple completions via |i_CTRL-X_CTRL-]|
399     command. It is not as featureful and doesn't have semantic understanding,
400     but it is fast, lightweight and useful for navigating polyglot projects.
401
402================================================================================
403CONCEPTS
404
405API                                                                  *lsp-api*
406
407The |lsp-core| API provides core functions for creating and managing clients,
408You can even create creating custom (in-process) |lsp-server|s.
409The |lsp-buf| functions operate LSP clients attached to the current buffer.
410
411
412METHOD                                                            *lsp-method*
413Requests and notifications defined by the LSP specification are referred to as
414"LSP methods". These are handled by |lsp-handler| functions.
415
416HANDLER                                                          *lsp-handler*
417LSP handlers are functions that handle |lsp-response|s to requests made by Nvim
418to the server. (Notifications, as opposed to requests, are fire-and-forget:
419there is no response, so they can't be handled. |lsp-notification|)
420
421Each handler has the following signature: >
422
423    vim.lsp.ResponseHandler:
424        fun(err, result, ctx)
425
426    vim.lsp.NotificationHandler:
427        fun(err, params, ctx)
428
429    vim.lsp.RequestHandler:
430        fun(err, params, ctx): Result?, lsp.ResponseError?
431
432Each response handler has this signature: >
433
434    function(err, result, ctx)
435<
436    Parameters: ~
437      • {err}     (`table|nil`) Error info dict, or `nil` if the request
438                  completed.
439      • {result}  (`Result|Params|nil`) `result` key of the |lsp-response| or
440                  `nil` if the request failed.
441      • {ctx}     (`table`) Table of calling state associated with the
442                  handler, with these keys:
443                  • {method}     (`string`) |lsp-method| name.
444                  • {client_id}  (`number`) |vim.lsp.Client| identifier.
445                  • {bufnr}      (`Buffer`) Buffer handle.
446                  • {params}     (`table|nil`) Request parameters table.
447                  • {version}    (`number`) Document version at time of
448                                 request. Handlers can compare this to the
449                                 current document version to check if the
450                                 response is "stale". See also |b:changedtick|.
451
452    Return (multiple): ~
453        • (`Result?`) `result` on success, or `nil` on error.
454        • (`lsp.ResponseError?`) `error` on failure, or `nil` on success.
455          RPC error shape: >
456            { code, message, data? }
457<          You can use |vim.lsp.rpc.rpc_response_error()| to create this object.
458
459        |lsp-response| and |lsp-notification| handlers do not have return
460        values.
461
462                                                      *lsp-handler-resolution*
463Handlers can be set by (in increasing priority):
464
465                                                            *vim.lsp.handlers*
466- Directly calling a LSP method via |Client:request()|. This is the only way
467  to "override" the default client-to-server request handling (by
468  side-stepping `vim.lsp.buf` and related interfaces). >lua
469    local client = assert(vim.lsp.get_clients()[1])
470    client:request('textDocument/definition')
471
472- Setting a field in `vim.lsp.handlers`. This global table contains the
473  default mappings of |lsp-method| names to handlers. (Note: only for
474  server-to-client requests/notifications, not client-to-server.)
475  Example: >lua
476    vim.lsp.handlers['textDocument/publishDiagnostics'] = my_custom_diagnostics_handler
477
478- Passing a {handlers} parameter to |vim.lsp.start()|. This sets the default
479  |lsp-handler| for a specific server. (Note: only for server-to-client
480  requests/notifications, not client-to-server.)
481  Example: >lua
482    vim.lsp.start {
483      ..., -- Other configuration omitted.
484      handlers = {
485        ['textDocument/publishDiagnostics'] = my_custom_diagnostics_handler
486      },
487    }
488
489- Passing a {handler} parameter to |vim.lsp.buf_request_all()|. This sets the
490  |lsp-handler| ONLY for the given request(s).
491  Example: >lua
492    vim.lsp.buf_request_all(
493      0,
494      'textDocument/publishDiagnostics',
495      my_request_params,
496      my_handler
497    )
498<
499
500                                                            *vim.lsp.log_levels*
501Log levels are defined in |vim.log.levels|
502
503
504------------------------------------------------------------------------------
505PROTOCOL                                                    *vim.lsp.protocol*
506
507Module `vim.lsp.protocol` defines constants dictated by the LSP specification,
508and helper functions for creating protocol-related objects.
509https://github.com/microsoft/language-server-protocol/raw/gh-pages/_specifications/specification-3-14.md
510
511For example `vim.lsp.protocol.ErrorCodes` allows reverse lookup by number or
512name: >lua
513
514    vim.lsp.protocol.TextDocumentSyncKind.Full == 1
515    vim.lsp.protocol.TextDocumentSyncKind[1] == "Full"
516<
517
518                                                                *lsp-request*
519LSP request shape: >
520    { id: integer|string, method: string, params?: Params }
521<
522https://microsoft.github.io/language-server-protocol/specifications/specification-current/#requestMessage
523
524                                                                *lsp-response*
525LSP response shape: >
526    { id: integer|string|nil, result: Result, error: nil }       (on success)
527    { id: integer|string|nil, result: nil, error: ResponseError }  (on error)
528<
529https://microsoft.github.io/language-server-protocol/specifications/specification-current/#responseMessage
530
531                                                                *lsp-notification*
532LSP notification shape: >
533    { method: string, params?: Params }
534<
535https://microsoft.github.io/language-server-protocol/specifications/specification-current/#notificationMessage
536
537------------------------------------------------------------------------------
538IN-PROCESS LSP SERVER                                             *lsp-server*
539
540For maximum flexibility you may want to create your own server. This allows
541you to hook into Nvim LSP features automatically. The "server" can be an
542in-process Lua function instead of an external process. For example see
543`runtime/lua/vim/pack/_lsp.lua` which provides features like "docs
544hover" in the vim.pack "Confirm Updates" UI.
545
546This is possible because |vim.lsp.start()| accepts `cmd` as a Lua function.
547The function must accept `vim.lsp.rpc.Dispatchers` and return a table in the
548form of |vim.lsp.rpc.Client|. Use `dispatchers.on_exit()` to signal that the
549server has stopped.
550
551Example (select and run the code with `:lua`, then check `:che vim.lsp` and
552look for "my-server"): >lua
553
554  --- @return vim.lsp.rpc.Client
555  local function cmd_fn(dispatchers)
556    local closing = false
557    local request_id = 0
558
559    local srv = {} --[[@type vim.lsp.rpc.Client]]
560    function srv.request(method, params, callback)
561      if method == 'initialize' then
562        callback(nil, {
563          capabilities = {
564            hoverProvider = true,
565          },
566        })
567      elseif method == 'shutdown' then
568        callback(nil, nil)
569      end
570      request_id = request_id + 1
571      return true, request_id
572    end
573    function srv.notify(method, params)
574      if method == 'exit' then
575        dispatchers.on_exit(0, 15)
576      end
577    end
578    function srv.is_closing()
579      return closing
580    end
581    function srv.terminate()
582      closing = true
583    end
584
585    return srv
586  end
587
588  -- Define a config for the server, then enable it...
589  vim.lsp.config['my-server'] = {
590    cmd = cmd_fn,
591    filetypes = { 'lua' },
592    root_markers = { '.git' },
593  }
594  vim.lsp.enable('my-server')
595
596  -- ...or call start() directly.
597  vim.lsp.start(
598    { cmd = cmd_fn, name = 'my-server', root_dir = vim.uv.cwd() },
599    { attach = true })
600<
601
602================================================================================
603LSP HIGHLIGHT                                                    *lsp-highlight*
604
605Reference Highlights:
606
607Highlight groups that are meant to be used by |vim.lsp.buf.document_highlight()|.
608
609You can see more about the differences in types here:
610https://microsoft.github.io/language-server-protocol/specification#textDocument_documentHighlight
611
612                                                         *hl-LspReferenceText*
613LspReferenceText          used for highlighting "text" references
614                                                         *hl-LspReferenceRead*
615LspReferenceRead          used for highlighting "read" references
616                                                        *hl-LspReferenceWrite*
617LspReferenceWrite         used for highlighting "write" references
618                                                       *hl-LspReferenceTarget*
619LspReferenceTarget        used for highlighting reference targets (e.g. in a
620                          hover range)
621                                                             *hl-LspInlayHint*
622LspInlayHint              used for highlighting inlay hints
623
624
625                                                      *lsp-highlight-codelens*
626
627Highlight groups related to |lsp-codelens| functionality.
628
629                                                              *hl-LspCodeLens*
630LspCodeLens
631    Used to color the virtual text of the codelens. See
632    |nvim_buf_set_extmark()|.
633
634LspCodeLensSeparator                                 *hl-LspCodeLensSeparator*
635    Used to color the separator between two or more code lenses.
636
637                                                     *lsp-highlight-signature*
638
639Highlight groups related to |vim.lsp.handlers.signature_help()|.
640
641                                              *hl-LspSignatureActiveParameter*
642LspSignatureActiveParameter
643    Used to highlight the active parameter in the signature help. See
644    |vim.lsp.handlers.signature_help()|.
645
646------------------------------------------------------------------------------
647LSP SEMANTIC HIGHLIGHTS                               *lsp-semantic-highlight*
648
649When available, the LSP client highlights code using |lsp-semantic_tokens|,
650which are another way that LSP servers can provide information about source
651code.  Note that this is in addition to treesitter syntax highlighting;
652semantic highlighting does not replace syntax highlighting.
653
654The server will typically provide one token per identifier in the source code.
655The token will have a `type` such as "function" or "variable", and 0 or more
656`modifier`s such as "readonly" or "deprecated." The standard types and
657modifiers are described here:
658https://microsoft.github.io/language-server-protocol/specification/#textDocument_semanticTokens
659LSP servers may also use off-spec types and modifiers.
660
661The LSP client adds one or more highlights for each token. The highlight
662groups are derived from the token's type and modifiers:
663  • `@lsp.type.<type>.<ft>` for the type
664  • `@lsp.mod.<mod>.<ft>` for each modifier
665  • `@lsp.typemod.<type>.<mod>.<ft>` for each modifier
666Use |:Inspect| to view the highlights for a specific token. Use |:hi| or
667|nvim_set_hl()| to change the appearance of semantic highlights: >vim
668
669    hi @lsp.type.function guifg=Yellow        " function names are yellow
670    hi @lsp.type.variable.lua guifg=Green     " variables in lua are green
671    hi @lsp.mod.deprecated gui=strikethrough  " deprecated is crossed out
672    hi @lsp.typemod.function.async guifg=Blue " async functions are blue
673<
674The value |vim.hl.priorities|`.semantic_tokens` is the priority of the
675`@lsp.type.*` highlights. The `@lsp.mod.*` and `@lsp.typemod.*` highlights
676have priorities one and two higher, respectively.
677
678You can disable semantic highlights by clearing the highlight groups: >lua
679
680    -- Hide semantic highlights for functions
681    vim.api.nvim_set_hl(0, '@lsp.type.function', {})
682
683    -- Hide all semantic highlights
684    for _, group in ipairs(vim.fn.getcompletion("@lsp", "highlight")) do
685      vim.api.nvim_set_hl(0, group, {})
686    end
687<
688You probably want these inside a |ColorScheme| autocommand.
689
690Use |LspTokenUpdate| and |vim.lsp.semantic_tokens.highlight_token()| for more
691complex highlighting.
692
693The following is a list of standard captures used in queries for Nvim,
694highlighted according to the current colorscheme (use |:Inspect| on one to see
695the exact definition):
696
697@lsp.type.class          Identifiers that declare or reference a class type
698@lsp.type.comment        Tokens that represent a comment
699@lsp.type.decorator      Identifiers that declare or reference decorators and annotations
700@lsp.type.enum           Identifiers that declare or reference an enumeration type
701@lsp.type.enumMember     Identifiers that declare or reference an enumeration property, constant, or member
702@lsp.type.event          Identifiers that declare an event property
703@lsp.type.function       Identifiers that declare a function
704@lsp.type.interface      Identifiers that declare or reference an interface type
705@lsp.type.keyword        Tokens that represent a language keyword
706@lsp.type.macro          Identifiers that declare a macro
707@lsp.type.method         Identifiers that declare a member function or method
708@lsp.type.modifier       Tokens that represent a modifier
709@lsp.type.namespace      Identifiers that declare or reference a namespace, module, or package
710@lsp.type.number         Tokens that represent a number literal
711@lsp.type.operator       Tokens that represent an operator
712@lsp.type.parameter      Identifiers that declare or reference a function or method parameters
713@lsp.type.property       Identifiers that declare or reference a member property, member field, or member variable
714@lsp.type.regexp         Tokens that represent a regular expression literal
715@lsp.type.string         Tokens that represent a string literal
716@lsp.type.struct         Identifiers that declare or reference a struct type
717@lsp.type.type           Identifiers that declare or reference a type that is not covered above
718@lsp.type.typeParameter  Identifiers that declare or reference a type parameter
719@lsp.type.variable       Identifiers that declare or reference a local or global variable
720
721@lsp.mod.abstract        Types and member functions that are abstract
722@lsp.mod.async           Functions that are marked async
723@lsp.mod.declaration     Declarations of symbols
724@lsp.mod.defaultLibrary  Symbols that are part of the standard library
725@lsp.mod.definition      Definitions of symbols, for example, in header files
726@lsp.mod.deprecated      Symbols that should no longer be used
727@lsp.mod.documentation   Occurrences of symbols in documentation
728@lsp.mod.modification    Variable references where the variable is assigned to
729@lsp.mod.readonly        Readonly variables and member fields (constants)
730@lsp.mod.static          Class members (static members)
731
732==============================================================================
733EVENTS                                                            *lsp-events*
734
735LspAttach                                                          *LspAttach*
736    After an LSP client performs "initialize" and attaches to a buffer. The
737    |autocmd-pattern| is the buffer name. The |event-data| (type:
738    `vim.event.lspattach.data`) has the client ID.
739
740    Example: >lua
741    vim.api.nvim_create_autocmd('LspAttach', {
742      callback = function(ev)
743        local client = vim.lsp.get_client_by_id(ev.data.client_id)
744        -- ...
745      end
746    })
747<
748    Note: If the LSP server performs dynamic registration, capabilities may be
749    registered any time _after_ LspAttach. In that case you may want to handle
750    the "registerCapability" event.
751
752    Example: >lua
753    vim.lsp.handlers['client/registerCapability'] = (function(overridden)
754      return function(err, res, ctx)
755        local result = overridden(err, res, ctx)
756        local client = vim.lsp.get_client_by_id(ctx.client_id)
757        if not client then
758          return
759        end
760        for bufnr, _ in pairs(client.attached_buffers) do
761          -- Call your custom on_attach logic...
762          -- my_on_attach(client, bufnr)
763        end
764        return result
765      end
766    end)(vim.lsp.handlers['client/registerCapability'])
767
768LspDetach                                                          *LspDetach*
769    Just before an LSP client detaches from a buffer. The |autocmd-pattern| is
770    the buffer name. The |event-data| (type: `vim.event.lspdetach.data`) has
771    the client ID.
772
773    Example: >lua
774    vim.api.nvim_create_autocmd('LspDetach', {
775      callback = function(ev)
776        -- Get the detaching client
777        local client = vim.lsp.get_client_by_id(ev.data.client_id)
778
779        -- Remove the autocommand to format the buffer on save, if it exists
780        if client:supports_method('textDocument/formatting') then
781          vim.api.nvim_clear_autocmds({
782            event = 'BufWritePre',
783            buffer = ev.buf,
784          })
785        end
786      end,
787    })
788<
789
790LspNotify                                                          *LspNotify*
791    This event is triggered after each successful notification sent to an
792    LSP server.
793
794    The |event-data| (type: `vim.event.lspnotify.data`) has the client_id, LSP
795    method, and parameters.
796
797    Example: >lua
798    vim.api.nvim_create_autocmd('LspNotify', {
799      callback = function(ev)
800        local bufnr = ev.buf
801        local client_id = ev.data.client_id
802        local method = ev.data.method
803        local params = ev.data.params
804
805        -- do something with the notification
806        if method == 'textDocument/...' then
807          update_buffer(bufnr)
808        end
809      end,
810    })
811<
812
813LspProgress                                                       *LspProgress*
814    Upon receipt of a progress notification from the server. Notifications can
815    be polled from a `progress` ring buffer of a |vim.lsp.Client| or use
816    |vim.lsp.status()| to get an aggregate message.
817
818    If the server sends a "work done progress", the `pattern` is set to `kind`
819    (one of `begin`, `report` or `end`).
820
821    The |event-data| (type: `vim.event.lspprogress.data`) has `client_id` and
822    `params` properties, where `params` is the request params sent by the
823    server (see `lsp.ProgressParams`).
824
825    Examples:
826
827    Redraw the statusline whenever an LSP progress message arrives: >vim
828        autocmd LspProgress * redrawstatus
829<
830    Emit a |progress-message| on LSP progress events: >lua
831        vim.api.nvim_create_autocmd('LspProgress', { buffer = buf, callback = function(ev)
832            local value = ev.data.params.value
833            vim.api.nvim_echo({ { value.message or 'done' } }, false, {
834              id = 'lsp.' .. ev.data.params.token,
835              kind = 'progress',
836              source = 'vim.lsp',
837              title = value.title,
838              status = value.kind ~= 'end' and 'running' or 'success',
839              percent = value.percentage,
840            })
841          end,
842        })
843<
844    See also: ~
845      • https://github.com/MicrosoftDocs/terminal/blob/main/TerminalDocs/tutorials/progress-bar-sequences.md
846
847LspRequest                                                        *LspRequest*
848    For each request sent to an LSP server, this event is triggered for
849    every change to the request's status. The status can be one of
850    `pending`, `complete`, or `cancel` and is sent as the {type} on the
851    "data" table passed to the callback function.
852
853    It triggers when the initial request is sent ({type} == `pending`) and
854    when the LSP server responds ({type} == `complete`). If a cancellation
855    is requested using `client.cancel_request(request_id)`, then this event
856    will trigger with {type} == `cancel`.
857
858    The |event-data| (type: `vim.event.lsprequest.data`) has the client ID,
859    request ID, and request (described at |vim.lsp.Client|, {requests} field).
860    If the request type is `complete`, the request will be deleted from the
861    client's pending requests table after processing the event handlers.
862
863    Example: >lua
864    vim.api.nvim_create_autocmd('LspRequest', {
865      callback = function(ev)
866        local bufnr = ev.buf
867        local client_id = ev.data.client_id
868        local request_id = ev.data.request_id
869        local request = ev.data.request
870        if request.type == 'pending' then
871          -- do something with pending requests
872          track_pending(client_id, bufnr, request_id, request)
873        elseif request.type == 'cancel' then
874          -- do something with pending cancel requests
875          track_canceling(client_id, bufnr, request_id, request)
876        elseif request.type == 'complete' then
877          -- do something with finished requests. this pending
878          -- request entry is about to be removed since it is complete
879          track_finish(client_id, bufnr, request_id, request)
880        end
881      end,
882    })
883<
884
885LspTokenUpdate                                                *LspTokenUpdate*
886    When a visible semantic token is sent or updated by the LSP server, or
887    when an existing token becomes visible for the first time. The
888    |autocmd-pattern| is the buffer name. The |event-data| (type:
889    `vim.event.lsptokenupdate.data`) has the client ID and token (see
890    |vim.lsp.semantic_tokens.get_at_pos()|).
891
892    Example: >lua
893    vim.api.nvim_create_autocmd('LspTokenUpdate', {
894      callback = function(ev)
895        local token = ev.data.token
896        if token.type == 'variable' and not token.modifiers.readonly then
897          vim.lsp.semantic_tokens.highlight_token(
898            token, ev.buf, ev.data.client_id, 'MyMutableVariableHighlight'
899          )
900        end
901      end,
902    })
903<
904    Note: doing anything other than calling
905    |vim.lsp.semantic_tokens.highlight_token()| is considered experimental.
906
907==============================================================================
908Lua module: vim.lsp                                                 *lsp-core*
909
910*vim.lsp.Config*
911    Extends: |vim.lsp.ClientConfig|
912
913
914    Fields: ~
915      • {cmd}?           (`string[]|fun(dispatchers: vim.lsp.rpc.Dispatchers, config: vim.lsp.ClientConfig): vim.lsp.rpc.Client`)
916                         See `cmd` in |vim.lsp.ClientConfig|. See also
917                         `reuse_client` to dynamically decide (per-buffer)
918                         when `cmd` should be re-invoked.
919      • {filetypes}?     (`string[]`) Filetypes the client will attach to, or
920                         `nil` for ALL filetypes. To match files by name,
921                         pattern, or contents, you can define a custom
922                         filetype using |vim.filetype.add()|: >lua
923                             vim.filetype.add({
924                               filename = {
925                                 ['my_filename'] = 'my_filetype1',
926                               },
927                               pattern = {
928                                 ['.*/etc/my_file_pattern/.*'] = 'my_filetype2',
929                               },
930                             })
931                             vim.lsp.config('…', {
932                               filetypes = { 'my_filetype1', 'my_filetype2' },
933                             })
934<
935      • {reuse_client}?  (`fun(client: vim.lsp.Client, config: vim.lsp.ClientConfig, bufnr: integer): boolean`)
936                         Predicate which decides if a client should be
937                         re-used. Used on all running clients. The default
938                         implementation re-uses a client if name and root_dir
939                         matches.
940      • {root_dir}?      (`string|fun(bufnr: integer, on_dir:fun(root_dir?:string))`)
941                         *lsp-root_dir()* Decides the workspace root: the
942                         directory where the LSP server will base its
943                         workspaceFolders, rootUri, and rootPath on
944                         initialization. The function form must call the
945                         `on_dir` callback to provide the root dir, or LSP
946                         will not be activated for the buffer. Thus a
947                         `root_dir()` function can dynamically decide
948                         per-buffer whether to activate (or skip) LSP. See
949                         example at |vim.lsp.enable()|.
950      • {root_markers}?  (`(string|string[])[]`)                                    *lsp-root_markers*
951                         Filename(s) (".git/", "package.json", …) used to
952                         decide the workspace root. Unused if `root_dir` is
953                         defined. The list order decides priority. To indicate
954                         "equal priority", specify names in a nested list
955                         `{ { 'a.txt', 'b.lua' }, ... }`.
956                         • For each item, Nvim will search upwards (from the
957                           buffer file) for that marker, or list of markers;
958                           search stops at the first directory containing that
959                           marker, and the directory is used as the root dir
960                           (workspace folder).
961                         • Example: Find the first ancestor directory
962                           containing file or directory "stylua.toml"; if not
963                           found, find the first ancestor containing ".git": >
964                           root_markers = { 'stylua.toml', '.git' }
965<
966                         • Example: Find the first ancestor directory
967                           containing EITHER "stylua.toml" or ".luarc.json";
968                           if not found, find the first ancestor containing
969                           ".git": >
970                           root_markers = { { 'stylua.toml', '.luarc.json' }, '.git' }
971<
972
973
974buf_attach_client({bufnr}, {client_id})          *vim.lsp.buf_attach_client()*
975    Implements the `textDocument/did…` notifications required to track a
976    buffer for any language server.
977
978    Without calling this, the server won't be notified of changes to a buffer.
979
980    Parameters: ~
981      • {bufnr}      (`integer`) Buffer handle, or 0 for current
982      • {client_id}  (`integer`) Client id
983
984    Return: ~
985        (`boolean`) success `true` if client was attached successfully;
986        `false` otherwise
987
988buf_detach_client({bufnr}, {client_id})          *vim.lsp.buf_detach_client()*
989    Detaches client from the specified buffer. Note: While the server is
990    notified that the text document (buffer) was closed, it is still able to
991    send notifications should it ignore this notification.
992
993    Parameters: ~
994      • {bufnr}      (`integer`) Buffer handle, or 0 for current
995      • {client_id}  (`integer`) Client id
996
997buf_is_attached({bufnr}, {client_id})              *vim.lsp.buf_is_attached()*
998    Checks if a buffer is attached for a particular client.
999
1000    Parameters: ~
1001      • {bufnr}      (`integer`) Buffer handle, or 0 for current
1002      • {client_id}  (`integer`) the client id
1003
1004buf_notify({bufnr}, {method}, {params})                 *vim.lsp.buf_notify()*
1005    Send a notification to a server
1006
1007    Attributes: ~
1008        Since: 0.5.0
1009
1010    Parameters: ~
1011      • {bufnr}   (`integer?`) The number of the buffer
1012      • {method}  (`string`) Name of the request method
1013      • {params}  (`any`) Arguments to send to the server
1014
1015    Return: ~
1016        (`boolean`) success true if any client returns true; false otherwise
1017
1018                                                   *vim.lsp.buf_request_all()*
1019buf_request_all({bufnr}, {method}, {params}, {handler})
1020    Sends an async request for all active clients attached to the buffer and
1021    executes the `handler` callback with the combined result.
1022
1023    Attributes: ~
1024        Since: 0.5.0
1025
1026    Parameters: ~
1027      • {bufnr}    (`integer`) Buffer handle, or 0 for current.
1028      • {method}   (`string`) LSP method name
1029      • {params}   (`table|(fun(client: vim.lsp.Client, bufnr: integer): table?)?`)
1030                   Parameters to send to the server. Can also be passed as a
1031                   function that returns the params table for cases where
1032                   parameters are specific to the client.
1033      • {handler}  (`function`) Handler called after all requests are
1034                   completed. Server results are passed as a
1035                   `client_id:result` map.
1036
1037    Return: ~
1038        (`function`) cancel Function that cancels all requests.
1039
1040                                                  *vim.lsp.buf_request_sync()*
1041buf_request_sync({bufnr}, {method}, {params}, {timeout_ms})
1042    Sends a request to all server and waits for the response of all of them.
1043
1044    Calls |vim.lsp.buf_request_all()| but blocks Nvim while awaiting the
1045    result. Parameters are the same as |vim.lsp.buf_request_all()| but the
1046    result is different. Waits a maximum of {timeout_ms}.
1047
1048    Attributes: ~
1049        Since: 0.5.0
1050
1051    Parameters: ~
1052      • {bufnr}       (`integer`) Buffer handle, or 0 for current.
1053      • {method}      (`string`) LSP method name
1054      • {params}      (`table|(fun(client: vim.lsp.Client, bufnr: integer): table?)?`)
1055                      Parameters to send to the server. Can also be passed as
1056                      a function that returns the params table for cases where
1057                      parameters are specific to the client.
1058      • {timeout_ms}  (`integer?`, default: `1000`) Maximum time in
1059                      milliseconds to wait for a result.
1060
1061    Return (multiple): ~
1062        (`table<integer, {error: lsp.ResponseError?, result: any}>?`) result
1063        Map of client_id:request_result.
1064        (`string?`) err On timeout, cancel, or error, `err` is a string
1065        describing the failure reason, and `result` is nil.
1066
1067commands                                                    *vim.lsp.commands*
1068    Map of client-defined handlers implementing custom (off-spec) commands
1069    which a server may invoke. Each key is a unique command name; each value
1070    is a function which is called when an LSP action (code action, code
1071    lenses, …) requests it by name.
1072
1073    If an LSP response requests a command not defined client-side, Nvim will
1074    forward it to the server as `workspace/executeCommand`.
1075    • Argument 1 is the `Command`: >
1076      Command
1077      title: String
1078      command: String
1079      arguments?: any[]
1080<
1081    • Argument 2 is the |lsp-handler| `ctx`.
1082
1083    Example: >lua
1084        vim.lsp.commands['java.action.generateToStringPrompt'] = function(_, ctx)
1085          require("jdtls.async").run(function()
1086            local _, result = request(ctx.bufnr, 'java/checkToStringStatus', ctx.params)
1087            local fields = ui.pick_many(result.fields, 'Include item in toString?', function(x)
1088              return string.format('%s: %s', x.name, x.type)
1089            end)
1090            local _, edit = request(ctx.bufnr, 'java/generateToString', { context = ctx.params; fields = fields; })
1091            vim.lsp.util.apply_workspace_edit(edit, offset_encoding)
1092          end)
1093        end
1094<
1095
1096config({name}, {cfg})                                       *vim.lsp.config()*
1097    Sets the default configuration for an LSP client (or all clients if the
1098    special name "*" is used).
1099
1100    Can also be accessed by table-indexing (`vim.lsp.config[…]`) to get the
1101    resolved config, or redefine the config (instead of "merging" with the
1102    config chain).
1103
1104    Examples:
1105    • Add root markers for ALL clients: >lua
1106      vim.lsp.config('*', {
1107        root_markers = { '.git', '.hg' },
1108      })
1109<
1110    • Add capabilities to ALL clients: >lua
1111      vim.lsp.config('*', {
1112      capabilities = {
1113        textDocument = {
1114          semanticTokens = {
1115            multilineTokenSupport = true,
1116          }
1117        }
1118      }
1119    })
1120<
1121    • Add root markers and capabilities for "clangd": >lua
1122      vim.lsp.config('clangd', {
1123      root_markers = { '.clang-format', 'compile_commands.json' },
1124      capabilities = {
1125        textDocument = {
1126          completion = {
1127            completionItem = {
1128              snippetSupport = true,
1129            }
1130          }
1131        }
1132      }
1133    })
1134<
1135    • (Re-)define the "clangd" configuration (overrides the resolved chain): >lua
1136      vim.lsp.config.clangd = {
1137      cmd = {
1138        'clangd',
1139        '--clang-tidy',
1140        '--background-index',
1141        '--offset-encoding=utf-8',
1142      },
1143      root_markers = { '.clangd', 'compile_commands.json' },
1144      filetypes = { 'c', 'cpp' },
1145    }
1146<
1147    • Get the resolved configuration for "emmylua_ls": >lua
1148      local cfg = vim.lsp.config.emmylua_ls
1149<
1150
1151    Attributes: ~
1152        Since: 0.11.0
1153
1154    Parameters: ~
1155      • {name}  (`string`)
1156      • {cfg}   (`vim.lsp.Config`)
1157
1158enable({name}, {enable})                                    *vim.lsp.enable()*
1159    Enables a |lsp-config|: automatically attaches the client to any buffer
1160    based on the config `filetypes`, `root_markers`, and `root_dir`. See
1161    |lsp-activate| for details.
1162
1163    To disable, pass `enable=false`: Stops related clients and servers
1164    (force-stops servers after a timeout, unless `exit_timeout=false`).
1165
1166    Raises an error under the following conditions:
1167    • `{name}` is not a valid LSP config name (for example, `'*'`).
1168    • `{name}` corresponds to an LSP config file which raises an error.
1169
1170    If an error is raised when multiple names are provided, this function will
1171    have no side-effects; it will not enable/disable any configs, including
1172    ones which contain no errors.
1173
1174    Examples: >lua
1175        vim.lsp.enable('clangd')
1176        vim.lsp.enable({'emmylua_ls', 'pyright'})
1177<
1178
1179    Example: To dynamically decide whether LSP is activated, define a
1180    |lsp-root_dir()| function which calls `on_dir()` only when you want that
1181    config to activate: >lua
1182        vim.lsp.config('emmylua_ls', {
1183          root_dir = function(bufnr, on_dir)
1184            if vim.fs.ext(vim.fn.bufname(bufnr)) ~= 'txt' then
1185              on_dir(vim.fn.getcwd())
1186            end
1187          end
1188        })
1189<
1190
1191    Attributes: ~
1192        Since: 0.11.0
1193
1194    Parameters: ~
1195      • {name}    (`string|string[]`) Name(s) of client(s) to enable.
1196      • {enable}  (`boolean?`) If `true|nil`, enables auto-activation of the
1197                  given LSP config on current and future buffers. If `false`,
1198                  disables auto-activation and stops related LSP clients and
1199                  servers (force-stops servers after `exit_timeout`
1200                  milliseconds).
1201
1202foldclose({kind}, {winid})                               *vim.lsp.foldclose()*
1203    Close all {kind} of folds in the window with {winid}.
1204
1205    To automatically fold imports when opening a file, you can use an autocmd: >lua
1206        vim.api.nvim_create_autocmd('LspNotify', {
1207          callback = function(ev)
1208            if ev.data.method == 'textDocument/didOpen' then
1209              vim.lsp.foldclose('imports', vim.fn.bufwinid(ev.buf))
1210            end
1211          end,
1212        })
1213<
1214
1215    Attributes: ~
1216        Since: 0.11.0
1217
1218    Parameters: ~
1219      • {kind}   (`lsp.FoldingRangeKind`) Kind to close, one of "comment",
1220                 "imports" or "region".
1221      • {winid}  (`integer?`) Defaults to the current window.
1222
1223foldexpr({lnum})                                          *vim.lsp.foldexpr()*
1224    Provides an interface between the built-in client and a `foldexpr`
1225    function.
1226
1227    To use, set 'foldmethod' to "expr" and set the value of 'foldexpr': >lua
1228        vim.o.foldmethod = 'expr'
1229        vim.o.foldexpr = vim.lsp.foldexpr
1230<
1231
1232    Or use it only when supported by checking for the
1233    "textDocument/foldingRange" capability in an |LspAttach| autocommand.
1234    Example: >lua
1235        vim.o.foldmethod = 'expr'
1236        -- Default to treesitter folding
1237        vim.o.foldexpr = vim.treesitter.foldexpr
1238        -- Prefer LSP folding if client supports it
1239        vim.api.nvim_create_autocmd('LspAttach', {
1240          callback = function(ev)
1241            local client = vim.lsp.get_client_by_id(ev.data.client_id)
1242            if client:supports_method('textDocument/foldingRange') then
1243              local win = vim.api.nvim_get_current_win()
1244              vim.wo[win][0].foldexpr = vim.lsp.foldexpr
1245            end
1246          end,
1247        })
1248<
1249
1250    Parameters: ~
1251      • {lnum}  (`integer`) line number
1252
1253foldtext({lnum})                                          *vim.lsp.foldtext()*
1254    Provides a `foldtext` function that shows the `collapsedText` retrieved,
1255    defaults to the first folded line if `collapsedText` is not provided.
1256
1257    The displayed foldtext will be highlighted via treesitter.
1258
1259    Parameters: ~
1260      • {lnum}  (`integer?`) line number (default: current fold start)
1261
1262formatexpr({opts})                                      *vim.lsp.formatexpr()*
1263    Provides an interface between the built-in client and a `formatexpr`
1264    function.
1265
1266    Currently only supports a single client. This can be set via
1267    `vim.bo[bufnr].formatexpr = vim.lsp.formatexpr`, or with a wrapper to pass
1268    options: >lua
1269        vim.bo[bufnr].formatexpr = function()
1270          return vim.lsp.formatexpr({ timeout_ms = 250 })
1271        end
1272<
1273
1274    Parameters: ~
1275      • {opts}  (`table?`) A table with the following fields:
1276                • {timeout_ms}? (`integer`, default: 500ms) The timeout period
1277                  for the formatting request..
1278
1279get_client_by_id({client_id})                     *vim.lsp.get_client_by_id()*
1280    Gets a client by id, or nil if the id is invalid or the client was
1281    stopped. The returned client may not yet be fully initialized.
1282
1283    Parameters: ~
1284      • {client_id}  (`integer`) client id
1285
1286    Return: ~
1287        (`vim.lsp.Client?`) client rpc object
1288
1289get_clients({filter})                                  *vim.lsp.get_clients()*
1290    Gets active clients.
1291
1292    Attributes: ~
1293        Since: 0.10.0
1294
1295    Parameters: ~
1296      • {filter}  (`table?`) Key-value pairs used to filter the returned
1297                  clients.
1298                  • {bufnr}? (`integer`) Only return clients attached to this
1299                    buffer
1300                  • {id}? (`integer`) Only return clients with the given id
1301                  • {method}? (`string`) Only return clients supporting the
1302                    given method
1303                  • {name}? (`string`) Only return clients with the given name
1304
1305    Return: ~
1306        (`vim.lsp.Client[]`) List of |vim.lsp.Client| objects
1307
1308get_configs({filter})                                  *vim.lsp.get_configs()*
1309    Gets LSP configs.
1310
1311    See also |vim.lsp.get_clients()| to get the runtime values of dynamic
1312    fields like `root_dir`, which depend on the current buffer/workspace/etc.
1313
1314    WARNING: May eagerly (prematurely!) evaluate config files in
1315    'runtimepath'.
1316
1317    Attributes: ~
1318        Since: 0.12.0
1319
1320    Parameters: ~
1321      • {filter}  (`table?`) Key-value pairs used to filter the returned
1322                  configs.
1323                  • {enabled}? (`boolean`) If true, only return enabled
1324                    configs. If false, only return configs that aren't
1325                    enabled.
1326                  • {filetype}? (`string`) Only return configs which attach to
1327                    the given filetype.
1328
1329    Return: ~
1330        (`vim.lsp.Config[]`) List of |vim.lsp.Config| objects
1331
1332is_enabled({name})                                      *vim.lsp.is_enabled()*
1333    Checks if the given LSP config is enabled (globally, not per-buffer).
1334
1335    Unlike `vim.lsp.config['…']`, this does not have the side-effect of
1336    resolving the config.
1337
1338    Parameters: ~
1339      • {name}  (`string`) Config name
1340
1341    Return: ~
1342        (`boolean`)
1343
1344omnifunc({findstart}, {base})                             *vim.lsp.omnifunc()*
1345    Implements 'omnifunc' compatible LSP completion.
1346
1347    Parameters: ~
1348      • {findstart}  (`integer`) 0 or 1, decides behavior
1349      • {base}       (`integer`) findstart=0, text to match against
1350
1351    Return: ~
1352        (`integer|table`) Decided by {findstart}:
1353        • findstart=1: column where the completion starts, or -2 or -3
1354        • findstart=0: list of matches (actually just calls |complete()|)
1355
1356    See also: ~
1357      • |complete-functions|
1358      • |complete-items|
1359      • |CompleteDone|
1360
1361start({config}, {opts})                                      *vim.lsp.start()*
1362    Create a new LSP client and start a language server or reuses an already
1363    running client if one is found matching `name` and `root_dir`. Attaches
1364    the current buffer to the client.
1365
1366    Example: >lua
1367        vim.lsp.start({
1368           name = 'my-server-name',
1369           cmd = {'name-of-language-server-executable'},
1370           root_dir = vim.fs.root(0, {'pyproject.toml', 'setup.py'}),
1371        })
1372<
1373
1374    See |vim.lsp.ClientConfig| for all available options. The most important
1375    are:
1376    • `name` arbitrary name for the LSP client. Should be unique per language
1377      server.
1378    • `cmd` command string[] or function. See also |lsp-server|.
1379    • `root_dir` path to the project root. By default this is used to decide
1380      if an existing client should be re-used. The example above uses
1381      |vim.fs.root()| to detect the root by traversing the file system upwards
1382      starting from the current directory until either a `pyproject.toml` or
1383      `setup.py` file is found.
1384    • `workspace_folders` list of `{ uri:string, name: string }` tables
1385      specifying the project root folders used by the language server. If
1386      `nil` the property is derived from `root_dir` for convenience.
1387
1388    Language servers use this information to discover metadata like the
1389    dependencies of your project and they tend to index the contents within
1390    the project folder.
1391
1392    To ensure a language server is only started for languages it can handle,
1393    make sure to call |vim.lsp.start()| within a |FileType| autocmd. Either
1394    use |:au|, |nvim_create_autocmd()| or put the call in a
1395    `ftplugin/<filetype_name>.lua` (See |ftplugin-name|)
1396
1397    Attributes: ~
1398        Since: 0.8.0
1399
1400    Parameters: ~
1401      • {config}  (`vim.lsp.ClientConfig`) Configuration for the server.
1402      • {opts}    (`table?`) Optional keyword arguments.
1403                  • {attach}? (`boolean`) Whether to attach the client to a
1404                    buffer (default true). If set to `false`, `reuse_client`
1405                    and `bufnr` will be ignored.
1406                  • {bufnr}? (`integer`) Buffer handle to attach to if
1407                    starting or re-using a client (0 for current).
1408                  • {reuse_client}?
1409                    (`fun(client: vim.lsp.Client, config: vim.lsp.ClientConfig, bufnr: integer): boolean`)
1410                    Predicate used to decide if a client should be re-used.
1411                    Used on all running clients. The default implementation
1412                    re-uses a client if it has the same name and if the given
1413                    workspace folders (or root_dir) are all included in the
1414                    client's workspace folders.
1415                  • {silent}? (`boolean`) Suppress error reporting if the LSP
1416                    server fails to start (default false).
1417
1418    Return: ~
1419        (`integer?`) client_id
1420
1421status()                                                    *vim.lsp.status()*
1422    Consumes the latest progress messages from all clients and formats them as
1423    a string. Empty if there are no clients or if no new messages
1424
1425    Return: ~
1426        (`string`)
1427
1428tagfunc({pattern}, {flags})                                *vim.lsp.tagfunc()*
1429    Provides an interface between the built-in client and 'tagfunc'.
1430
1431    When used with normal mode commands (e.g. |CTRL-]|) this will invoke the
1432    "textDocument/definition" LSP method to find the tag under the cursor.
1433    Otherwise, uses "workspace/symbol". If no results are returned from any
1434    LSP servers, falls back to using built-in tags.
1435
1436    Parameters: ~
1437      • {pattern}  (`string`) Pattern used to find a workspace symbol
1438      • {flags}    (`string`) See |tag-function|
1439
1440    Return: ~
1441        (`table[]|vim.NIL`) tags A list of matching tags, or `vim.NIL` to use
1442        the built-in tags.
1443
1444
1445==============================================================================
1446Lua module: vim.lsp.buf                                              *lsp-buf*
1447
1448The `vim.lsp.buf_…` functions perform operations for LSP clients attached to
1449the current buffer.
1450
1451
1452*vim.lsp.ListOpts*
1453
1454    Fields: ~
1455      • {loclist}?  (`boolean`) Whether to use the |location-list| or the
1456                    |quickfix| list in the default handler. >lua
1457                        vim.lsp.buf.definition({ loclist = true })
1458                        vim.lsp.buf.references(nil, { loclist = false })
1459<
1460      • {on_list}?  (`fun(what: vim.fn.setqflist.what)`) list-handler
1461                    replacing the default handler. Called for any non-empty
1462                    result. The default handler populates the quickfix (or
1463                    location) list with the result. If there is a single
1464                    result (and the method is not `implementation` or
1465                    `references`), it pushes a tag onto the tagstack and jumps
1466                    to the result. For example, when `loclist == false` (the
1467                    default), the handler is equivalent to: >lua
1468                        local function on_list(what)
1469                          vim.fn.setqflist({}, ' ', what)
1470                          if
1471                            #what.items == 1
1472                            and what.context.method ~= 'textDocument/implementation'
1473                            and what.context.method ~= 'textDocument/references'
1474                          then
1475                            local tagstack = { { tagname = tagname, from = from } }
1476                            vim.fn.settagstack(vim.fn.win_getid(win), { items = tagstack }, 't')
1477                            vim.cmd('cfirst')
1478                          else
1479                            vim.cmd('botright copen')
1480                          end
1481                        end
1482
1483                        vim.lsp.buf.definition({ on_list = on_list })
1484                        vim.lsp.buf.references(nil, { on_list = on_list })
1485<
1486
1487                    The list can be transformed before it is shown. For
1488                    example, to remove duplicate locations returned by
1489                    multiple clients: >lua
1490                        local function on_list(what)
1491                          vim.list.unique(what.items, function(item)
1492                            return ('%s\0%d\0%d\0%d\0%d'):format(
1493                              item.filename or '',
1494                              item.lnum or 0,
1495                              item.col or 0,
1496                              item.end_lnum or 0,
1497                              item.end_col or 0
1498                            )
1499                          end)
1500                          vim.fn.setqflist({}, ' ', what)
1501                          vim.cmd('botright copen')
1502                        end
1503
1504                        vim.lsp.buf.definition({ on_list = on_list })
1505                        vim.lsp.buf.references(nil, { on_list = on_list })
1506<
1507
1508                    See |setqflist-what| for the structure of the `what`
1509                    parameter.
1510      • {pos}?      (`vim.Pos`, default: cursor position) Position on a buffer
1511                    to request.
1512
1513*vim.lsp.buf.hover.Opts*
1514    Extends: |vim.lsp.util.open_floating_preview.Opts|
1515
1516
1517    Fields: ~
1518      • {silent}?  (`boolean`)
1519
1520*vim.lsp.buf.signature_help.Opts*
1521    Extends: |vim.lsp.util.open_floating_preview.Opts|
1522
1523
1524    Fields: ~
1525      • {silent}?  (`boolean`)
1526
1527
1528                                          *vim.lsp.buf.add_workspace_folder()*
1529add_workspace_folder({workspace_folder})
1530    Add the folder at path to the workspace folders. If {path} is not
1531    provided, the user will be prompted for a path using |input()|.
1532
1533    Parameters: ~
1534      • {workspace_folder}  (`string?`)
1535
1536clear_references()                            *vim.lsp.buf.clear_references()*
1537    Removes document highlights from current buffer.
1538
1539code_action({opts})                                *vim.lsp.buf.code_action()*
1540    Selects a code action (LSP: "textDocument/codeAction" request) available
1541    at cursor position.
1542
1543    Parameters: ~
1544      • {opts}  (`table?`) A table with the following fields:
1545                • {apply}? (`boolean`) When set to `true`, and there is just
1546                  one remaining action (after filtering), the action is
1547                  applied without user query.
1548                • {context}? (`table`) Corresponds to `lsp.CodeActionContext`,
1549                  but all fields are optional:
1550                  • {diagnostics}? (`lsp.Diagnostic[]`) Inferred from the
1551                    current position if not provided.
1552                  • {only}? (`lsp.CodeActionKind[]`) `CodeActionKind`s used to
1553                    filter the code actions. Most servers support values like
1554                    "refactor" or "quickfix".
1555                  • {triggerKind}? (`lsp.CodeActionTriggerKind`) Why code
1556                    actions were requested.
1557                • {filter}?
1558                  (`fun(x: lsp.CodeAction|lsp.Command, client_id: integer):boolean`)
1559                  Predicate taking a code action or command and the provider's
1560                  ID. If it returns false, the action is filtered out.
1561                • {range}? (`{start: integer[], end: integer[]}`) Range for
1562                  which code actions should be requested. If in visual mode
1563                  this defaults to the active selection. Table must contain
1564                  `start` and `end` keys with {row,col} tuples using mark-like
1565                  indexing. See |api-indexing|
1566
1567    See also: ~
1568      • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction
1569      • vim.lsp.protocol.CodeActionTriggerKind
1570
1571declaration({opts})                                *vim.lsp.buf.declaration()*
1572    Jumps to the declaration of the symbol under the cursor.
1573
1574    Note: ~
1575      • Many servers do not implement this method. Generally, see
1576        |vim.lsp.buf.definition()| instead.
1577
1578    Parameters: ~
1579      • {opts}  (`vim.lsp.ListOpts?`)
1580
1581definition({opts})                                  *vim.lsp.buf.definition()*
1582    Jumps to the definition of the symbol under the cursor.
1583
1584    Parameters: ~
1585      • {opts}  (`vim.lsp.ListOpts?`)
1586
1587document_highlight()                        *vim.lsp.buf.document_highlight()*
1588    Send request to the server to resolve document highlights for the current
1589    text document position. This request can be triggered by a key mapping or
1590    by events such as `CursorHold`, e.g.: >vim
1591        autocmd CursorHold  <buffer> lua vim.lsp.buf.document_highlight()
1592        autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()
1593        autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
1594<
1595
1596    Note: Usage of |vim.lsp.buf.document_highlight()| requires the following
1597    highlight groups to be defined or you won't be able to see the actual
1598    highlights. |hl-LspReferenceText| |hl-LspReferenceRead|
1599    |hl-LspReferenceWrite|
1600
1601document_symbol({opts})                        *vim.lsp.buf.document_symbol()*
1602    Lists all symbols in the current buffer in the |location-list|.
1603
1604    Parameters: ~
1605      • {opts}  (`vim.lsp.ListOpts?`)
1606
1607format({opts})                                          *vim.lsp.buf.format()*
1608    Formats a buffer using the attached (and optionally filtered) language
1609    server clients.
1610
1611    Parameters: ~
1612      • {opts}  (`table?`) A table with the following fields:
1613                • {async}? (`boolean`, default: false) If true the method
1614                  won't block. Editing the buffer while formatting
1615                  asynchronous can lead to unexpected changes.
1616                • {bufnr}? (`integer`, default: current buffer) Restrict
1617                  formatting to the clients attached to the given buffer.
1618                • {filter}? (`fun(client: vim.lsp.Client): boolean?`)
1619                  Predicate used to filter clients. Receives a client as
1620                  argument and must return a boolean. Clients matching the
1621                  predicate are included. Example: >lua
1622                    -- Never request typescript-language-server for formatting
1623                    vim.lsp.buf.format {
1624                      filter = function(client) return client.name ~= "ts_ls" end
1625                    }
1626<
1627                • {formatting_options}? (`lsp.FormattingOptions`) Can be used
1628                  to specify FormattingOptions. Some unspecified options will
1629                  be automatically derived from the current Nvim options. See
1630                  https://microsoft.github.io/language-server-protocol/specification/#formattingOptions
1631                • {id}? (`integer`) Restrict formatting to the client with ID
1632                  (client.id) matching this field.
1633                • {name}? (`string`) Restrict formatting to the client with
1634                  name (client.name) matching this field.
1635                • {range}?
1636                  (`{start:[integer,integer],end:[integer, integer]}|{start:[integer,integer],end:[integer,integer]}[]`,
1637                  default: current selection in visual mode, `nil` in other
1638                  modes, formatting the full buffer) Range to format. Table
1639                  must contain `start` and `end` keys with {row,col} tuples
1640                  using (1,0) indexing. The end column can be -1 to format
1641                  through the end of the line. Can also be a list of tables
1642                  that contain `start` and `end` keys as described above, in
1643                  which case `textDocument/rangesFormatting` support is
1644                  required.
1645                • {timeout_ms}? (`integer`, default: `1000` for synchronous
1646                  requests) Time in milliseconds allowed for each formatting
1647                  request. On timeout, cancels the request and continues with
1648                  the next client. With async=true, there is no timeout unless
1649                  this option is set. Responses received after the request
1650                  times out are ignored.
1651
1652hover({config})                                          *vim.lsp.buf.hover()*
1653    Displays hover information about the symbol under the cursor in a floating
1654    window. The window will be dismissed on cursor move. Calling the function
1655    twice will jump into the floating window (thus by default, "KK" will open
1656    the hover window and focus it). In the floating window, all commands and
1657    mappings are available as usual, except that "q" dismisses the window. You
1658    can scroll the contents the same as you would any other buffer.
1659
1660    Note: to disable hover highlights, add the following to your config: >lua
1661        vim.api.nvim_create_autocmd('ColorScheme', {
1662          callback = function()
1663            vim.api.nvim_set_hl(0, 'LspReferenceTarget', {})
1664          end,
1665        })
1666<
1667
1668    Parameters: ~
1669      • {config}  (`vim.lsp.buf.hover.Opts?`)
1670
1671implementation({opts})                          *vim.lsp.buf.implementation()*
1672    Lists all the implementations for the symbol under the cursor in the
1673    quickfix window.
1674
1675    Parameters: ~
1676      • {opts}  (`vim.lsp.ListOpts?`)
1677
1678incoming_calls()                                *vim.lsp.buf.incoming_calls()*
1679    Lists all the call sites of the symbol under the cursor in the |quickfix|
1680    window. If the symbol can resolve to multiple items, the user can pick one
1681    in the |inputlist()|.
1682
1683list_workspace_folders()                *vim.lsp.buf.list_workspace_folders()*
1684    List workspace folders.
1685
1686outgoing_calls()                                *vim.lsp.buf.outgoing_calls()*
1687    Lists all the items that are called by the symbol under the cursor in the
1688    |quickfix| window. If the symbol can resolve to multiple items, the user
1689    can pick one in the |inputlist()|.
1690
1691references({context}, {opts})                       *vim.lsp.buf.references()*
1692    Lists all the references to the symbol under the cursor in the quickfix
1693    window.
1694
1695    Parameters: ~
1696      • {context}  (`lsp.ReferenceContext?`) Context for the request
1697      • {opts}     (`vim.lsp.ListOpts?`)
1698
1699    See also: ~
1700      • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references
1701
1702                                       *vim.lsp.buf.remove_workspace_folder()*
1703remove_workspace_folder({workspace_folder})
1704    Remove the folder at path from the workspace folders. If {path} is not
1705    provided, the user will be prompted for a path using |input()|.
1706
1707    Parameters: ~
1708      • {workspace_folder}  (`string?`)
1709
1710rename({new_name}, {opts})                              *vim.lsp.buf.rename()*
1711    Renames all references to the symbol under the cursor.
1712
1713    Parameters: ~
1714      • {new_name}  (`string?`) If not provided, the user will be prompted for
1715                    a new name using |vim.ui.input()|.
1716      • {opts}      (`table?`) Additional options:
1717                    • {bufnr}? (`integer`) (default: current buffer)
1718                    • {filter}? (`fun(client: vim.lsp.Client): boolean?`)
1719                      Predicate used to filter clients. Receives a client as
1720                      argument and must return a boolean. Clients matching the
1721                      predicate are included.
1722                    • {name}? (`string`) Restrict clients used for rename to
1723                      ones where client.name matches this field.
1724
1725                                               *vim.lsp.buf.selection_range()*
1726selection_range({direction}, {timeout_ms})
1727                                                   *lsp-incremental-selection*
1728
1729    Expands or contracts a |Visual| selection at cursor, based on ranges given
1730    by LSP. The `direction` parameter specifies the number of times to expand
1731    the selection. Negative values will shrink the selection.
1732
1733    Parameters: ~
1734      • {direction}   (`integer`)
1735      • {timeout_ms}  (`integer?`) (default: `1000`) Maximum time
1736                      (milliseconds) to wait for a result.
1737
1738signature_help({config})                        *vim.lsp.buf.signature_help()*
1739    Displays signature information about the symbol under the cursor in a
1740    floating window. Allows cycling through signature overloads with `<C-s>`,
1741    which can be remapped via `<Plug>(nvim.lsp.ctrl-s)`
1742
1743    Example: >lua
1744        vim.keymap.set('n', '<C-b>', '<Plug>(nvim.lsp.ctrl-s)')
1745<
1746
1747    Parameters: ~
1748      • {config}  (`vim.lsp.buf.signature_help.Opts?`)
1749
1750type_definition({opts})                        *vim.lsp.buf.type_definition()*
1751    Jumps to the definition of the type of the symbol under the cursor.
1752
1753    Parameters: ~
1754      • {opts}  (`vim.lsp.ListOpts?`)
1755
1756typehierarchy({kind})                            *vim.lsp.buf.typehierarchy()*
1757    Lists all the subtypes or supertypes of the symbol under the cursor in the
1758    |quickfix| window. If the symbol can resolve to multiple items, the user
1759    can pick one using |vim.ui.select()|.
1760
1761    Parameters: ~
1762      • {kind}  (`"subtypes"|"supertypes"`)
1763
1764workspace_diagnostics({opts})            *vim.lsp.buf.workspace_diagnostics()*
1765    Request workspace-wide diagnostics.
1766
1767    Parameters: ~
1768      • {opts}  (`table?`) A table with the following fields:
1769                • {client_id}? (`integer`) Only request diagnostics from the
1770                  indicated client. If nil, the request is sent to all
1771                  clients.
1772
1773    See also: ~
1774      • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_diagnostic
1775
1776workspace_symbol({query}, {opts})             *vim.lsp.buf.workspace_symbol()*
1777    Lists all symbols in the current workspace in the quickfix window.
1778
1779    The list is filtered against {query}; if the argument is omitted from the
1780    call, the user is prompted to enter a string on the command line. An empty
1781    string means no filtering is done.
1782
1783    Parameters: ~
1784      • {query}  (`string?`) optional
1785      • {opts}   (`vim.lsp.ListOpts?`)
1786
1787
1788==============================================================================
1789Lua module: vim.lsp.client                                        *lsp-client*
1790
1791*vim.lsp.Client*
1792
1793    Fields: ~
1794      • {attached_buffers}      (`table<integer,string>`) Each buffer's last
1795                                used `languageId`.
1796      • {cancel_request}        (`fun(self: vim.lsp.Client, id: integer): boolean`)
1797                                See |Client:cancel_request()|.
1798      • {capabilities}          (`lsp.ClientCapabilities`) Capabilities
1799                                provided by the client (editor or tool), at
1800                                startup.
1801      • {commands}              (`table<string,fun(command: lsp.Command, ctx: table)>`)
1802                                Client commands. See |vim.lsp.ClientConfig|.
1803      • {config}                (`vim.lsp.ClientConfig`) Copy of the config
1804                                passed to |vim.lsp.start()|.
1805      • {dynamic_capabilities}  (`lsp.DynamicCapabilities`) Capabilities
1806                                provided at runtime (after startup).
1807      • {exec_cmd}              (`fun(self: vim.lsp.Client, cmd: lsp.Command, context: {bufnr?: integer}?, handler: lsp.Handler?)`)
1808                                See |Client:exec_cmd()|.
1809      • {exit_timeout}          (`integer|boolean`, default: `false`) See
1810                                |vim.lsp.ClientConfig|.
1811      • {flags}                 (`table`) Experimental client flags:
1812                                • {allow_incremental_sync}? (`boolean`,
1813                                  default: `true`) Allow using incremental
1814                                  sync for buffer edits
1815                                • {debounce_text_changes}? (`integer`,
1816                                  default: `150`) Debounce `didChange`
1817                                  notifications to the server by the given
1818                                  number in milliseconds.
1819      • {get_language_id}       (`fun(bufnr: integer, filetype: string): string`)
1820                                See |vim.lsp.ClientConfig|.
1821      • {handlers}              (`table<string,lsp.Handler>`) See
1822                                |vim.lsp.ClientConfig|.
1823      • {id}                    (`integer`) The id allocated to the client.
1824      • {initialized}           (`true?`)
1825      • {is_stopped}            (`fun(self: vim.lsp.Client): boolean`) See
1826                                |Client:is_stopped()|.
1827      • {name}                  (`string`) See |vim.lsp.ClientConfig|.
1828      • {notify}                (`fun(self: vim.lsp.Client, method: string, params: table?, bufnr: integer?): boolean`)
1829                                See |Client:notify()|.
1830      • {offset_encoding}       (`'utf-8'|'utf-16'|'utf-32'`) See
1831                                |vim.lsp.ClientConfig|.
1832      • {on_attach}             (`fun(self: vim.lsp.Client, bufnr: integer)`)
1833                                See |Client:on_attach()|.
1834      • {progress}              (`vim.lsp.Client.Progress`) A ring buffer
1835                                (|vim.ringbuf()|) containing progress messages
1836                                sent by the server.
1837      • {request}               (`fun(self: vim.lsp.Client, method: string, params: table?, handler: lsp.Handler?, bufnr: integer?): boolean, integer?`)
1838                                See |Client:request()|.
1839      • {request_sync}          (`fun(self: vim.lsp.Client, method: string, params: table, timeout_ms: integer?, bufnr: integer?): {err: lsp.ResponseError?, result:any}?, string?`)
1840                                See |Client:request_sync()|.
1841      • {requests}              (`table<integer,{ type: string, bufnr: integer, method: vim.lsp.protocol.Method}?>`)
1842                                The current pending requests in flight to the
1843                                server. Entries are key-value pairs with the
1844                                key being the request id while the value is a
1845                                table with `type`, `bufnr`, and `method`
1846                                key-value pairs. `type` is either "pending"
1847                                for an active request, or "cancel" for a
1848                                cancel request. It will be "complete"
1849                                ephemerally while executing |LspRequest|
1850                                autocmds when replies are received from the
1851                                server.
1852      • {root_dir}              (`string?`) See |vim.lsp.ClientConfig|.
1853      • {rpc}                   (`vim.lsp.rpc.Client`) RPC client object, for
1854                                low level interaction with the client. See
1855                                |vim.lsp.rpc.start()|.
1856      • {server_capabilities}   (`lsp.ServerCapabilities`) Response from the
1857                                server sent on `initialize` describing the
1858                                server's capabilities.
1859      • {server_info}           (`lsp.ServerInfo?`) Response from the server
1860                                sent on `initialize` describing server
1861                                information (e.g. version).
1862      • {settings}              (`lsp.LSPObject`) See |vim.lsp.ClientConfig|.
1863      • {stop}                  (`fun(self: vim.lsp.Client, force: integer|boolean?)`)
1864                                See |Client:stop()|.
1865      • {supports_method}       (`fun(self: vim.lsp.Client, method: string|string, bufnr: integer?): boolean`)
1866                                See |Client:supports_method()|.
1867      • {workspace_folders}     (`lsp.WorkspaceFolder[]?`) See
1868                                |vim.lsp.ClientConfig|.
1869
1870*vim.lsp.Client.Progress*
1871    Extends: |vim.Ringbuf|
1872
1873
1874    Fields: ~
1875      • {pending}  (`table<lsp.ProgressToken,lsp.LSPAny>`)
1876
1877*vim.lsp.ClientConfig*
1878
1879    Fields: ~
1880      • {before_init}?         (`fun(params: lsp.InitializeParams, config: vim.lsp.ClientConfig)`)
1881                               Callback which can modify parameters before
1882                               they are sent to the server. Invoked before LSP
1883                               "initialize" phase (after `cmd` is invoked),
1884                               where `params` is the parameters being sent to
1885                               the server and `config` is the config passed to
1886                               |vim.lsp.start()|.
1887
1888                               Hint: use |vim.tbl_deep_extend()| to set nested
1889                               fields easily. >lua
1890                                   before_init = function(_, config)
1891                                     config.settings = vim.tbl_deep_extend('force',
1892                                       config.settings,
1893                                       { tailwindCSS = { experimental = { configFile = find_tailwind_global_css() } } }
1894                                     )
1895                                   end
1896<
1897      • {capabilities}?        (`lsp.ClientCapabilities`) Map overriding the
1898                               default capabilities defined by
1899                               |vim.lsp.protocol.make_client_capabilities()|,
1900                               passed to the language server on
1901                               initialization. Hint: use
1902                               make_client_capabilities() and modify its
1903                               result.
1904                               • Note: To send an empty dictionary use
1905                                 |vim.empty_dict()|, else it will be encoded
1906                                 as an array.
1907      • {cmd}                  (`string[]|fun(dispatchers: vim.lsp.rpc.Dispatchers, config: vim.lsp.ClientConfig): vim.lsp.rpc.Client`)
1908                               Command `string[]` that launches the language
1909                               server (treated as in |jobstart()|, must be
1910                               absolute or on `$PATH`, shell constructs like
1911                               "~" are not expanded), or function that creates
1912                               an RPC client (or an in-process |lsp-server|).
1913                               Function receives a `dispatchers` table and the
1914                               resolved `config`, and must return an object in
1915                               the form of |vim.lsp.rpc.Client|.
1916
1917                               Example (list): >lua
1918                                   cmd = { 'flow', 'lsp' }
1919<
1920
1921                               Example (function): >lua
1922                                   cmd = function(dispatchers, config)
1923                                     local cmd = vim.fn.executable('flow') == 1 and { 'flow', 'lsp' } or { 'npx', '--no-install', 'flow', 'lsp' }
1924                                     return vim.lsp.rpc.start(cmd, dispatchers)
1925                                   end
1926<
1927                               • See |vim.lsp.rpc.Client|.
1928                               • For TCP there is a builtin RPC client
1929                                 factory: |vim.lsp.rpc.connect()|
1930      • {cmd_cwd}?             (`string`) Directory where the `cmd` process is
1931                               launched when `cmd` is a string array. Defaults
1932                               to `root_dir` when available, then the current
1933                               working directory.
1934      • {cmd_env}?             (`table`) Environment variables passed to the
1935                               LSP process on spawn. Non-string values are
1936                               coerced to string. Example: >lua
1937                                   { PORT = 8080, HOST = '0.0.0.0' }
1938<
1939      • {commands}?            (`table<string,fun(command: lsp.Command, ctx: table)>`)
1940                               Map of client-defined commands overriding the
1941                               global |vim.lsp.commands|.
1942      • {detached}?            (`boolean`, default: `true`) Daemonize the
1943                               server process so that it runs in a separate
1944                               process group from Nvim. Nvim will shutdown the
1945                               process on exit, but if Nvim fails to exit
1946                               cleanly this could leave behind orphaned server
1947                               processes.
1948      • {exit_timeout}?        (`integer|boolean`, default: `false`) Decides
1949                               if/when to force-stop the server after sending
1950                               the "shutdown" request. See |Client:stop()|.
1951                               Note: when Nvim itself is exiting,
1952                               • `false`: Nvim will not force-stop LSP
1953                                 server(s).
1954                               • `true`: Nvim will force-stop LSP server(s)
1955                                 that did not comply with the "shutdown"
1956                                 request.
1957                               • `number`: Nvim will wait up to `exit_timeout`
1958                                 milliseconds before performing force-stop.
1959      • {flags}?               (`table`) Experimental client flags:
1960                               • {allow_incremental_sync}? (`boolean`,
1961                                 default: `true`) Allow using incremental sync
1962                                 for buffer edits
1963                               • {debounce_text_changes}? (`integer`, default:
1964                                 `150`) Debounce `didChange` notifications to
1965                                 the server by the given number in
1966                                 milliseconds.
1967      • {get_language_id}?     (`fun(bufnr: integer, filetype: string): string`)
1968                               Language ID as string. Defaults to the buffer
1969                               filetype.
1970      • {handlers}?            (`table<string,function>`) Map of LSP method
1971                               names to |lsp-handler|s.
1972      • {init_options}?        (`lsp.LSPObject`) Values to pass in the
1973                               initialization request as
1974                               `initializationOptions`. See `initialize` in
1975                               the LSP spec.
1976      • {name}?                (`string`, default: client-id) Name in logs and
1977                               user messages.
1978      • {offset_encoding}?     (`'utf-8'|'utf-16'|'utf-32'`) Called "position
1979                               encoding" in LSP spec. The encoding that the
1980                               LSP server expects, used for communication. Not
1981                               validated. Can be modified in `on_init` before
1982                               text is sent to the server.
1983      • {on_attach}?           (`elem_or_list<fun(client: vim.lsp.Client, bufnr: integer)>`)
1984                               Callback invoked when client attaches to a
1985                               buffer.
1986      • {on_error}?            (`fun(code: integer, err: string)`) Callback
1987                               invoked when the client operation throws an
1988                               error. `code` is a number describing the error.
1989                               Other arguments may be passed depending on the
1990                               error kind. See `vim.lsp.rpc.client_errors` for
1991                               possible errors. Use
1992                               `vim.lsp.rpc.client_errors[code]` to get
1993                               human-friendly name.
1994      • {on_exit}?             (`elem_or_list<fun(code: integer, signal: integer, client_id: integer)>`)
1995                               Callback invoked on client exit.
1996                               • code: exit code of the process
1997                               • signal: number describing the signal used to
1998                                 terminate (if any)
1999                               • client_id: client handle
2000      • {on_init}?             (`elem_or_list<fun(client: vim.lsp.Client, init_result: lsp.InitializeResult)>`)
2001                               Callback invoked after LSP "initialize", where
2002                               `result` is a table of `capabilities` and
2003                               anything else the server may send. For example,
2004                               clangd sends `init_result.offsetEncoding` if
2005                               `capabilities.offsetEncoding` was sent to it.
2006                               You can only modify the
2007                               `client.offset_encoding` here before any
2008                               notifications are sent.
2009      • {root_dir}?            (`string`) Directory where the LSP server will
2010                               base its workspaceFolders, rootUri, and
2011                               rootPath on initialization.
2012      • {settings}?            (`lsp.LSPObject`) Map of language
2013                               server-specific settings, decided by the
2014                               client. Sent to the LS if requested via
2015                               `workspace/configuration`. Keys are
2016                               case-sensitive.
2017      • {trace}?               (`'off'|'messages'|'verbose'`, default: "off")
2018                               Passed directly to the language server in the
2019                               initialize request. Invalid/empty values will
2020      • {workspace_folders}?   (`lsp.WorkspaceFolder[]`) List of workspace
2021                               folders passed to the language server. For
2022                               backwards compatibility rootUri and rootPath
2023                               are derived from the first workspace folder in
2024                               this list. Can be `null` if the client supports
2025                               workspace folders but none are configured. See
2026                               `workspaceFolders` in LSP spec.
2027      • {workspace_required}?  (`boolean`, default: `false`) Server requires a
2028                               workspace (no "single file" support). Note:
2029                               Without a workspace, cross-file features
2030                               (navigation, hover) may or may not work
2031                               depending on the language server, even if the
2032                               server doesn't require a workspace.
2033
2034
2035Client:cancel_request({id})                          *Client:cancel_request()*
2036    Cancels a request with a given request id.
2037
2038    Parameters: ~
2039      • {id}  (`integer`) id of request to cancel
2040
2041    Return: ~
2042        (`boolean`) status indicating if the notification was successful.
2043
2044    See also: ~
2045      • |Client:notify()|
2046
2047Client:exec_cmd({cmd}, {context}, {handler})               *Client:exec_cmd()*
2048    Execute a lsp command, either via client command function (if available)
2049    or via workspace/executeCommand (if supported by the server)
2050
2051    Parameters: ~
2052      • {cmd}      (`lsp.Command`)
2053      • {context}  (`{bufnr?: integer}?`)
2054      • {handler}  (`lsp.Handler?`) only called if a server command
2055
2056Client:is_stopped()                                      *Client:is_stopped()*
2057    Checks whether a client is stopped.
2058
2059    Return: ~
2060        (`boolean`) true if client is stopped or in the process of being
2061        stopped; false otherwise
2062
2063Client:notify({method}, {params}, {bufnr})                   *Client:notify()*
2064    Sends a notification to an LSP server.
2065
2066    Parameters: ~
2067      • {method}  (`string`) LSP method name.
2068      • {params}  (`table?`) LSP request params.
2069      • {bufnr}   (`integer?`) Buffer associated with notification.
2070
2071    Return: ~
2072        (`boolean`) status indicating if the notification was successful. If
2073        it is false, then the client has shutdown.
2074
2075Client:on_attach({bufnr})                                 *Client:on_attach()*
2076    Runs the on_attach function from the client's config if it was defined.
2077    Useful for buffer-local setup.
2078
2079    Parameters: ~
2080      • {bufnr}  (`integer`) Buffer number
2081
2082                                                            *Client:request()*
2083Client:request({method}, {params}, {handler}, {bufnr})
2084    Sends a request to the server.
2085
2086    This is a thin wrapper around {client.rpc.request} with some additional
2087    checks for capabilities and handler availability.
2088
2089    Parameters: ~
2090      • {method}   (`string`) LSP method name.
2091      • {params}   (`table?`) LSP request params.
2092      • {handler}  (`lsp.Handler?`) Response |lsp-handler| for this method.
2093      • {bufnr}    (`integer?`) (default: 0) Buffer handle, or 0 for current.
2094
2095    Return (multiple): ~
2096        (`boolean`) status indicates whether the request was successful. If it
2097        is `false`, then it will always be `false` (the client has shutdown).
2098        (`integer?`) request_id Can be used with |Client:cancel_request()|.
2099        `nil` is request failed.
2100
2101    See also: ~
2102      • |vim.lsp.buf_request_all()|
2103
2104                                                       *Client:request_sync()*
2105Client:request_sync({method}, {params}, {timeout_ms}, {bufnr})
2106    Sends a request to the server and synchronously waits for the response.
2107
2108    This is a wrapper around |Client:request()|
2109
2110    Parameters: ~
2111      • {method}      (`string`) LSP method name.
2112      • {params}      (`table`) LSP request params.
2113      • {timeout_ms}  (`integer?`) Maximum time in milliseconds to wait for a
2114                      result. Defaults to 1000
2115      • {bufnr}       (`integer?`) (default: 0) Buffer handle, or 0 for
2116                      current.
2117
2118    Return (multiple): ~
2119        (`{err: lsp.ResponseError?, result:any}?`) `result` and `err` from the
2120        |lsp-handler|. `nil` is the request was unsuccessful
2121        (`string?`) err On timeout, cancel or error, where `err` is a string
2122        describing the failure reason.
2123
2124    See also: ~
2125      • |vim.lsp.buf_request_sync()|
2126
2127Client:stop({force})                                           *Client:stop()*
2128    Stops a client, optionally with force after a timeout.
2129
2130    By default this sends a "shutdown" request to the server, escalating to
2131    force-stop if the server has not exited after `self.exit_timeout`
2132    milliseconds (unless `exit_timeout=false`). Calling stop() on a client
2133    that was previously requested to shutdown, will escalate to force-stop
2134    immediately, regardless of `force` (or `self.exit_timeout` if
2135    `force=nil`).
2136
2137    Note: Forcing shutdown while a server is busy writing out project or index
2138    files can lead to file corruption.
2139
2140    Parameters: ~
2141      • {force}  (`integer|boolean?`) (default: `self.exit_timeout`) Decides
2142                 whether to force-stop the server.
2143                 • `false`: Do not force-stop after "shutdown" request.
2144                 • `nil`: Defaults to `exit_timeout` from
2145                   |vim.lsp.ClientConfig|.
2146                 • `true`: Force-stop after "shutdown" request.
2147                 • number: Wait up to `force` milliseconds before force-stop.
2148
2149Client:supports_method({method}, {bufnr})           *Client:supports_method()*
2150    Checks if a client supports a given method. Always returns true for
2151    unknown off-spec methods.
2152
2153    Note: Some language server capabilities can be file specific.
2154
2155    Parameters: ~
2156      • {method}  (`string|string`)
2157      • {bufnr}   (`integer?`)
2158
2159    Return: ~
2160        (`boolean`)
2161
2162
2163==============================================================================
2164Lua module: vim.lsp.codelens                                    *lsp-codelens*
2165
2166enable({enable}, {filter})                         *vim.lsp.codelens.enable()*
2167    Enables or disables code lens for the {filter}ed scope.
2168
2169    To "toggle", pass the inverse of `is_enabled()`: >lua
2170        vim.lsp.codelens.enable(not vim.lsp.codelens.is_enabled())
2171<
2172
2173    To run a code lens, see |vim.lsp.codelens.run()|.
2174
2175    Parameters: ~
2176      • {enable}  (`boolean?`) true/nil to enable, false to disable
2177      • {filter}  (`table?`) Optional filters |kwargs|,
2178                  • {bufnr}? (`integer`, default: all) Buffer number, or 0 for
2179                    current buffer, or nil for all.
2180                  • {client_id}? (`integer`, default: all) Client ID, or nil
2181                    for all.
2182
2183get({filter})                                         *vim.lsp.codelens.get()*
2184    Get all code lenses in the {filter}ed scope.
2185
2186    Parameters: ~
2187      • {filter}  (`table?`) Optional filters |kwargs|:
2188                  • {bufnr}? (`integer`, default: 0) Buffer handle, or 0 for
2189                    current.
2190                  • {client_id}? (`integer`, default: all) Client ID, or nil
2191                    for all.
2192
2193    Overloads: ~
2194      • `fun(filter: integer): lsp.CodeLens[]`
2195
2196    Return: ~
2197        (`table[]`) A list of objects with the following fields:
2198        • {client_id} (`integer`)
2199        • {lens} (`lsp.CodeLens`)
2200
2201is_enabled({filter})                           *vim.lsp.codelens.is_enabled()*
2202    Query whether code lens is enabled in the {filter}ed scope
2203
2204    Parameters: ~
2205      • {filter}  (`table?`) Optional filters |kwargs|,
2206                  • {bufnr}? (`integer`, default: all) Buffer number, or 0 for
2207                    current buffer, or nil for all.
2208                  • {client_id}? (`integer`, default: all) Client ID, or nil
2209                    for all.
2210
2211    Return: ~
2212        (`boolean`) whether code lens is enabled.
2213
2214run({opts})                                           *vim.lsp.codelens.run()*
2215    Run code lens at the current cursor position.
2216
2217    Parameters: ~
2218      • {opts}  (`table?`) Optional parameters |kwargs|:
2219                • {client_id}? (`integer`, default: all) Client ID, or nil for
2220                  all.
2221
2222
2223==============================================================================
2224Lua module: vim.lsp.completion                                *lsp-completion*
2225
2226The `vim.lsp.completion` module enables insert-mode completion driven by an
2227LSP server. Call `enable()` to make it available through Nvim builtin
2228completion (via the |CompleteDone| event). Specify `autotrigger=true` to
2229activate "auto-completion" when you type any of the server-defined
2230`triggerCharacters`. Use CTRL-Y to select an item from the completion menu.
2231|complete_CTRL-Y|
2232
2233Example: activate LSP-driven auto-completion: >lua
2234    -- Works best if 'completeopt' has "noselect".
2235    -- Use CTRL-Y to select an item. |complete_CTRL-Y|
2236    vim.cmd[[set completeopt+=menuone,noselect,popup]]
2237    vim.lsp.start({
2238      name = 'ts_ls',
2239      cmd = …,
2240      on_attach = function(client, bufnr)
2241        vim.lsp.completion.enable(true, client.id, bufnr, {
2242          autotrigger = true,
2243          convert = function(item)
2244            return { abbr = item.label:gsub('%b()', '') }
2245          end,
2246        })
2247      end,
2248    })
2249<
2250
2251                                                          *lsp-autocompletion*
2252
2253The LSP `triggerCharacters` field decides when to trigger autocompletion. If
2254you want to trigger on EVERY keypress you can either:
2255• Extend `client.server_capabilities.completionProvider.triggerCharacters` on
2256  `LspAttach`, before you call
2257  `vim.lsp.completion.enable(… {autotrigger=true})`. See the |lsp-attach|
2258  example.
2259• Call `vim.lsp.completion.get()` from an |InsertCharPre| autocommand.
2260
2261If the server provides `commitCharacters` for a completion item, typing one of
2262those characters while the item is selected accepts the completion and then
2263inserts the character. To disable this: >lua
2264    vim.lsp.completion.enable(true, client_id, bufnr, { commit_characters = false })
2265<
2266
2267
2268                                                 *vim.lsp.completion.enable()*
2269enable({enable}, {client_id}, {bufnr}, {opts})
2270    Enables or disables completions from the given language client in the
2271    given buffer. Effects of enabling completions are:
2272    • Calling |vim.lsp.completion.get()| uses the enabled clients to retrieve
2273      completion candidates.
2274    • Selecting a completion item shows a preview popup
2275      ("completionItem/resolve") if 'completeopt' has "popup".
2276    • Accepting a completion item using `<c-y>` applies side effects like
2277      expanding snippets, text edits (e.g. insert import statements) and
2278      executing associated commands. This works for completions triggered via
2279      autotrigger, 'omnifunc' or |vim.lsp.completion.get()|.
2280
2281    Examples: |lsp-attach| |lsp-completion|
2282
2283    Note: ~
2284      • |vim.lsp.omnifunc()| (|i_CTRL-X_CTRL-O|) queries every client that
2285        advertises completion, including clients that were disabled by
2286        `enable(false)`. To suppress completions for a client, clear its
2287        capability on |LspAttach|:
2288        `client.server_capabilities.completionProvider = nil`.
2289      • Behavior of `autotrigger=true` is controlled by the LSP
2290        `triggerCharacters` field. You can override it on LspAttach, see
2291        |lsp-autocompletion|.
2292
2293    Parameters: ~
2294      • {enable}     (`boolean`) True to enable, false to disable
2295      • {client_id}  (`integer`) Client ID
2296      • {bufnr}      (`integer`) Buffer handle, or 0 for the current buffer
2297      • {opts}       (`table?`) A table with the following fields:
2298                     • {autotrigger}? (`boolean`) (default: false) When true,
2299                       completion triggers automatically based on the server's
2300                       `triggerCharacters`.
2301                     • {cmp}? (`fun(a: table, b: table): boolean`) Comparator
2302                       for sorting merged completion items from all servers.
2303                     • {commit_characters}? (`boolean`) (default: true) When
2304                       false, commit characters are ignored.
2305                     • {convert}? (`fun(item: lsp.CompletionItem): table`)
2306                       Transforms an LSP CompletionItem to |complete-items|.
2307
2308get({opts})                                         *vim.lsp.completion.get()*
2309    Triggers LSP completion once in the current buffer, if LSP completion is
2310    enabled (see |lsp-attach| |lsp-completion|).
2311
2312    Use CTRL-Y to select an item from the completion menu. |complete_CTRL-Y|
2313
2314    To invoke manually with CTRL-space, use this mapping: >lua
2315        -- Use CTRL-space to trigger LSP completion.
2316        -- Use CTRL-Y to select an item. |complete_CTRL-Y|
2317        vim.keymap.set('i', '<c-space>', function()
2318          vim.lsp.completion.get()
2319        end)
2320<
2321
2322    Parameters: ~
2323      • {opts}  (`table?`) A table with the following fields:
2324                • {ctx}? (`lsp.CompletionContext`) Completion context.
2325                  Defaults to a trigger kind of `invoked`.
2326
2327
2328==============================================================================
2329Lua module: vim.lsp.diagnostic                                *lsp-diagnostic*
2330
2331This module provides functionality for requesting LSP diagnostics for a
2332document/workspace and populating them using |vim.Diagnostic|s.
2333`DiagnosticRelatedInformation` is supported: it is included in the window
2334shown by |vim.diagnostic.open_float()|. When the cursor is on a line with
2335related information, |gf| jumps to the problem location.
2336
2337
2338from({diagnostics})                                *vim.lsp.diagnostic.from()*
2339    Converts the input `vim.Diagnostic`s to LSP diagnostics.
2340
2341    Parameters: ~
2342      • {diagnostics}  (`vim.Diagnostic[]`)
2343
2344    Return: ~
2345        (`lsp.Diagnostic[]`)
2346
2347                                          *vim.lsp.diagnostic.get_namespace()*
2348get_namespace({client_id}, {is_pull}, {pull_id})
2349    Get the diagnostic namespace associated with an LSP client
2350    |vim.diagnostic| for diagnostics
2351
2352    Parameters: ~
2353      • {client_id}  (`integer`) The id of the LSP client
2354      • {is_pull}    (`boolean?`) Whether the namespace is for a pull or push
2355                     client. Defaults to `false` (push).
2356      • {pull_id}    (`string?`) (default: nil) Optional identifier for pull
2357                     diagnostic providers. Only used if `is_pull` is `true`.
2358
2359                                          *vim.lsp.diagnostic.on_diagnostic()*
2360on_diagnostic({error}, {result}, {ctx})
2361    |lsp-handler| for the method "textDocument/diagnostic"
2362
2363    See |vim.diagnostic.config()| for configuration options.
2364
2365    Parameters: ~
2366      • {error}   (`lsp.ResponseError?`)
2367      • {result}  (`lsp.DocumentDiagnosticReport`)
2368      • {ctx}     (`lsp.HandlerContext`)
2369
2370                                 *vim.lsp.diagnostic.on_publish_diagnostics()*
2371on_publish_diagnostics({_}, {params}, {ctx})
2372    |lsp-handler| for the method "textDocument/publishDiagnostics"
2373
2374    See |vim.diagnostic.config()| for configuration options.
2375
2376    Parameters: ~
2377      • {params}  (`lsp.PublishDiagnosticsParams`)
2378      • {ctx}     (`lsp.HandlerContext`)
2379
2380
2381==============================================================================
2382Lua module: vim.lsp.document_color                        *lsp-document_color*
2383
2384This module provides LSP support for highlighting color references in a
2385document. Highlighting is enabled by default.
2386
2387
2388color_presentation()             *vim.lsp.document_color.color_presentation()*
2389    Select from a list of presentations for the color under the cursor.
2390
2391enable({enable}, {filter}, {opts})           *vim.lsp.document_color.enable()*
2392    Enables or disables document color highlighting for the {filter}ed scope.
2393
2394    To "toggle", pass the inverse of `is_enabled()`: >lua
2395        vim.lsp.document_color.enable(not vim.lsp.document_color.is_enabled())
2396<
2397
2398    Parameters: ~
2399      • {enable}  (`boolean?`) True to enable, false to disable. (default:
2400                  `true`)
2401      • {filter}  (`table?`) Optional filters |kwargs|,
2402                  • {bufnr}? (`integer`, default: all) Buffer number, or 0 for
2403                    current buffer, or nil for all.
2404                  • {client_id}? (`integer`, default: all) Client ID, or nil
2405                    for all.
2406      • {opts}    (`table?`) A table with the following fields:
2407                  • {style}?
2408                    (`'background'|'foreground'|'virtual'|string|fun(bufnr: integer, range: vim.Range, hex_code: string)`)
2409                    Highlight style. It can be one of the pre-defined styles,
2410                    a string to be used as virtual text, or a function that
2411                    receives the buffer handle, the range (start line, start
2412                    col, end line, end col) and the resolved hex color.
2413                    (default: `'background'`)
2414
2415is_enabled({filter})                     *vim.lsp.document_color.is_enabled()*
2416    Query whether document colors are enabled in the {filter}ed scope.
2417
2418    Parameters: ~
2419      • {filter}  (`table?`) Optional filters |kwargs|,
2420                  • {bufnr}? (`integer`, default: all) Buffer number, or 0 for
2421                    current buffer, or nil for all.
2422                  • {client_id}? (`integer`, default: all) Client ID, or nil
2423                    for all.
2424
2425    Return: ~
2426        (`boolean`)
2427
2428
2429==============================================================================
2430Lua module: vim.lsp.inlay_hint                                *lsp-inlay_hint*
2431
2432enable({enable}, {filter})                       *vim.lsp.inlay_hint.enable()*
2433    Enables or disables inlay hints for the {filter}ed scope.
2434
2435    To "toggle", pass the inverse of `is_enabled()`: >lua
2436        vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
2437<
2438
2439    Attributes: ~
2440        Since: 0.10.0
2441
2442    Parameters: ~
2443      • {enable}  (`boolean?`) true/nil to enable, false to disable
2444      • {filter}  (`table?`) Optional filters |kwargs|,
2445                  • {bufnr}? (`integer`, default: all) Buffer number, or 0 for
2446                    current buffer, or nil for all.
2447                  • {client_id}? (`integer`, default: all) Client ID, or nil
2448                    for all.
2449
2450get({filter})                                       *vim.lsp.inlay_hint.get()*
2451    Get the list of inlay hints, (optionally) restricted by buffer or range.
2452
2453    Example usage: >lua
2454        local hint = vim.lsp.inlay_hint.get({ bufnr = 0 })[1] -- 0 for current buffer
2455
2456        local client = vim.lsp.get_client_by_id(hint.client_id)
2457        local resp = client:request_sync('inlayHint/resolve', hint.inlay_hint, 100, 0)
2458        local resolved_hint = assert(
2459          resp and resp.result,
2460          resp and resp.err and vim.lsp.rpc.format_rpc_error(resp.err) or 'request failed'
2461        )
2462        vim.lsp.util.apply_text_edits(resolved_hint.textEdits, 0, client.encoding)
2463
2464        location = resolved_hint.label[1].location
2465        client:request('textDocument/hover', {
2466          textDocument = { uri = location.uri },
2467          position = location.range.start,
2468        })
2469<
2470
2471    Attributes: ~
2472        Since: 0.10.0
2473
2474    Parameters: ~
2475      • {filter}  (`table?`) Optional filters |kwargs|:
2476                  • {bufnr} (`integer?`)
2477                  • {range} (`lsp.Range?`)
2478
2479    Return: ~
2480        (`table[]`) A list of objects with the following fields:
2481        • {bufnr} (`integer`)
2482        • {client_id} (`integer`)
2483        • {inlay_hint} (`lsp.InlayHint`)
2484
2485is_enabled({filter})                         *vim.lsp.inlay_hint.is_enabled()*
2486    Query whether inlay hint is enabled in the {filter}ed scope
2487
2488    Attributes: ~
2489        Since: 0.10.0
2490
2491    Parameters: ~
2492      • {filter}  (`table?`) Optional filters |kwargs|,
2493                  • {bufnr}? (`integer`, default: all) Buffer number, or 0 for
2494                    current buffer, or nil for all.
2495                  • {client_id}? (`integer`, default: all) Client ID, or nil
2496                    for all.
2497
2498    Return: ~
2499        (`boolean`)
2500
2501
2502==============================================================================
2503Lua module: vim.lsp.inline_completion                  *lsp-inline_completion*
2504
2505This module provides the LSP "inline completion" feature, for completing
2506multiline text (e.g., whole methods) instead of just a word or line, which may
2507result in "syntactically or semantically incorrect" code. Unlike regular
2508completion, this is typically presented as overlay text instead of a menu of
2509completion candidates.
2510
2511LSP spec:
2512https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/#textDocument_inlineCompletion
2513
2514To try it out, here is a quickstart example using Copilot:       *lsp-copilot*
25151. Install Copilot: >sh
2516    npm install --global @github/copilot-language-server
2517<
25182. Define a config, (or copy `lsp/copilot.lua` from
2519   https://github.com/neovim/nvim-lspconfig): >lua
2520    vim.lsp.config('copilot', {
2521     cmd = { 'copilot-language-server', '--stdio' },
2522     root_markers = { '.git' },
2523      init_options = {
2524        editorInfo = {
2525          name = 'Neovim', version = tostring(vim.version()) },
2526          editorPluginInfo = { name = 'Neovim', version = tostring(vim.version()) },
2527        },
2528   })
2529<
25303. Activate the config: >lua
2531    vim.lsp.enable('copilot')
2532<
25334. Sign in to Copilot, or use the `:LspCopilotSignIn` command from
2534   https://github.com/neovim/nvim-lspconfig
25355. Enable inline completion: >lua
2536    vim.lsp.inline_completion.enable()
2537<
25386. Set a keymap for `vim.lsp.inline_completion.get()` and invoke the keymap.
2539
2540
2541*vim.lsp.inline_completion.Item*
2542
2543    Fields: ~
2544      • {client_id}    (`integer`) Client ID
2545      • {command}?     (`lsp.Command`) Corresponding server command.
2546      • {insert_text}  (`string|lsp.StringValue`) The text to be inserted, can
2547                       be a snippet.
2548      • {range}?       (`vim.Range`) Which range it be applied.
2549
2550
2551enable({enable}, {filter})                *vim.lsp.inline_completion.enable()*
2552    Enables or disables inline completion for the {filter}ed scope, inline
2553    completion will automatically be refreshed when you are in insert mode.
2554
2555    To "toggle", pass the inverse of `is_enabled()`: >lua
2556        vim.lsp.inline_completion.enable(not vim.lsp.inline_completion.is_enabled())
2557<
2558
2559    Parameters: ~
2560      • {enable}  (`boolean?`) true/nil to enable, false to disable
2561      • {filter}  (`table?`) Optional filters |kwargs|,
2562                  • {bufnr}? (`integer`, default: all) Buffer number, or 0 for
2563                    current buffer, or nil for all.
2564                  • {client_id}? (`integer`, default: all) Client ID, or nil
2565                    for all.
2566
2567get({opts})                                  *vim.lsp.inline_completion.get()*
2568    Accept the currently displayed completion candidate to the buffer.
2569
2570    It returns false when no candidate can be accepted, so you can use the
2571    return value to implement a fallback: >lua
2572         vim.keymap.set('i', '<Tab>', function()
2573          if not vim.lsp.inline_completion.get() then
2574            return '<Tab>'
2575          end
2576        end, { expr = true, desc = 'Accept the current inline completion' })
2577<
2578
2579    Parameters: ~
2580      • {opts}  (`table?`) A table with the following fields:
2581                • {bufnr}? (`integer`, default: 0) Buffer handle, or 0 for
2582                  current.
2583                • {on_accept}?
2584                  (`fun(item: vim.lsp.inline_completion.Item): vim.lsp.inline_completion.Item?`)
2585                  A callback triggered when a completion item is accepted. You
2586                  can use it to modify the completion item that is about to be
2587                  accepted and return it to apply the changes, or return `nil`
2588                  to prevent the changes from being applied to the buffer so
2589                  you can implement custom behavior.
2590
2591    Return: ~
2592        (`boolean`) `true` if a completion was applied, else `false`.
2593
2594is_enabled({filter})                  *vim.lsp.inline_completion.is_enabled()*
2595    Query whether inline completion is enabled in the {filter}ed scope
2596
2597    Parameters: ~
2598      • {filter}  (`table?`) Optional filters |kwargs|,
2599                  • {bufnr}? (`integer`, default: all) Buffer number, or 0 for
2600                    current buffer, or nil for all.
2601                  • {client_id}? (`integer`, default: all) Client ID, or nil
2602                    for all.
2603
2604select({opts})                            *vim.lsp.inline_completion.select()*
2605    Switch between available inline completion candidates.
2606
2607    Parameters: ~
2608      • {opts}  (`table?`) A table with the following fields:
2609                • {bufnr}? (`integer`) (default: current buffer)
2610                • {count}? (`integer`, default: v:count1) The number of
2611                  candidates to move by. A positive integer moves forward by
2612                  {count} candidates, while a negative integer moves backward
2613                  by {count} candidates.
2614                • {wrap}? (`boolean`, default: `true`) Whether to loop around
2615                  file or not. Similar to 'wrapscan'.
2616
2617
2618==============================================================================
2619Lua module: vim.lsp.linked_editing_range            *lsp-linked_editing_range*
2620
2621The `vim.lsp.linked_editing_range` module enables "linked editing" via a
2622language server's `textDocument/linkedEditingRange` request. Linked editing
2623ranges are synchronized text regions, meaning changes in one range are
2624mirrored in all the others. This is helpful in HTML files for example, where
2625the language server can update the text of a closing tag if its opening tag
2626was changed.
2627
2628LSP spec:
2629https://microsoft.github.io/language-server-protocol/specification/#textDocument_linkedEditingRange
2630
2631
2632enable({enable}, {filter})             *vim.lsp.linked_editing_range.enable()*
2633    Enable or disable a linked editing session for the {filter}ed scope. The
2634    following is a practical usage example: >lua
2635        vim.lsp.start({
2636          name = 'html',
2637          cmd = '…',
2638          on_attach = function(client)
2639            vim.lsp.linked_editing_range.enable(true, { client_id = client.id })
2640          end,
2641        })
2642<
2643
2644    Parameters: ~
2645      • {enable}  (`boolean?`) `true` or `nil` to enable, `false` to disable.
2646      • {filter}  (`table?`) Optional filters |kwargs|,
2647                  • {bufnr}? (`integer`, default: all) Buffer number, or 0 for
2648                    current buffer, or nil for all.
2649                  • {client_id}? (`integer`, default: all) Client ID, or nil
2650                    for all.
2651
2652
2653==============================================================================
2654Lua module: vim.lsp.log                                              *lsp-log*
2655
2656The `vim.lsp.log` module provides logging for the Nvim LSP client.
2657
2658When debugging language servers, it is helpful to enable extra-verbose logging
2659of the LSP client RPC events. Example: >lua
2660    vim.lsp.log.set_level 'trace'
2661<
2662
2663Then try to run the language server, and open the log with: >vim
2664    :log lsp
2665<
2666
2667Note:
2668• Remember to DISABLE verbose logging ("debug" or "trace" level), else you may
2669  encounter performance issues.
2670• "ERROR" messages containing "stderr" only indicate that the log was sent to
2671  stderr. Many servers send harmless messages via stderr.
2672
2673
2674get_filename()                                    *vim.lsp.log.get_filename()*
2675    Returns the log filename.
2676
2677    Return: ~
2678        (`string`) log filename
2679
2680get_level()                                          *vim.lsp.log.get_level()*
2681    Gets the current log level.
2682
2683    Return: ~
2684        (`integer`) current log level
2685
2686set_format_func({handle})                      *vim.lsp.log.set_format_func()*
2687    Sets the formatting function used to format logs. If the formatting
2688    function returns nil, the entry won't be written to the log file.
2689
2690    Parameters: ~
2691      • {handle}  (`fun(level:string, ...): string?`) Function to apply to log
2692                  entries. The default will log the level, date, source and
2693                  line number of the caller, followed by the arguments.
2694
2695set_level({level})                                   *vim.lsp.log.set_level()*
2696    Sets the current log level.
2697
2698    Parameters: ~
2699      • {level}  (`string|integer`) One of |vim.log.levels|
2700
2701
2702==============================================================================
2703Lua module: vim.lsp.on_type_formatting                *lsp-on_type_formatting*
2704
2705enable({enable}, {filter})               *vim.lsp.on_type_formatting.enable()*
2706    Enables/disables on-type formatting globally or for the {filter}ed scope.
2707    The following are some practical usage examples: >lua
2708        -- Enable for all clients
2709        vim.lsp.on_type_formatting.enable()
2710
2711        -- Enable for a specific client
2712        vim.api.nvim_create_autocmd('LspAttach', {
2713          callback = function(ev)
2714            local client_id = ev.data.client_id
2715            local client = assert(vim.lsp.get_client_by_id(client_id))
2716            if client.name == 'rust-analyzer' then
2717              vim.lsp.on_type_formatting.enable(true, { client_id = client_id })
2718            end
2719          end,
2720        })
2721<
2722
2723    Parameters: ~
2724      • {enable}  (`boolean?`) true/nil to enable, false to disable.
2725      • {filter}  (`table?`) Optional filters |kwargs|:
2726                  • {client_id} (`integer?`) Client ID, or `nil` for all.
2727
2728
2729==============================================================================
2730Lua module: vim.lsp.rpc                                              *lsp-rpc*
2731
2732*vim.lsp.rpc.Client*
2733    Client RPC object
2734
2735    Fields: ~
2736      • {is_closing}  (`fun(): boolean`) Indicates if the RPC is closing.
2737      • {notify}      (`fun(method: string, params: any): boolean`) Sends a
2738                      notification to the LSP server.
2739      • {request}     (`fun(method: string, params: table?, callback: fun(err?: lsp.ResponseError, result: any, request_id: integer), notify_reply_callback?: fun(message_id: integer)):boolean,integer?`)
2740                      Sends a request to the LSP server.
2741      • {terminate}   (`fun()`) Terminates the RPC client.
2742
2743
2744connect({host_or_path}, {port})                        *vim.lsp.rpc.connect()*
2745    Create a LSP RPC client factory that connects to either:
2746    • a named pipe (windows)
2747    • a domain socket (unix)
2748    • a host and port via TCP
2749
2750    Return a function that can be passed to the `cmd` field for
2751    |vim.lsp.start()|.
2752
2753    Parameters: ~
2754      • {host_or_path}  (`string`) host to connect to or path to a pipe/domain
2755                        socket
2756      • {port}          (`integer?`) TCP port to connect to. If absent the
2757                        first argument must be a pipe
2758
2759    Return: ~
2760        (`fun(dispatchers: vim.lsp.rpc.Dispatchers): vim.lsp.rpc.Client`)
2761
2762format_rpc_error({err})                       *vim.lsp.rpc.format_rpc_error()*
2763    Constructs an error message from an LSP error object.
2764
2765    Parameters: ~
2766      • {err}  (`table`) The error object
2767
2768    Return: ~
2769        (`string`) error_message The formatted error message
2770
2771                                            *vim.lsp.rpc.rpc_response_error()*
2772rpc_response_error({code}, {message}, {data})
2773    Creates an RPC response table `error` to be sent to the LSP response.
2774
2775    Parameters: ~
2776      • {code}     (`integer`) RPC error code defined, see
2777                   `vim.lsp.protocol.ErrorCodes`
2778      • {message}  (`string?`) arbitrary message to send to server
2779      • {data}     (`any?`) arbitrary data to send to server
2780
2781    Return: ~
2782        (`lsp.ResponseError`)
2783
2784    See also: ~
2785      • lsp.ErrorCodes See `vim.lsp.protocol.ErrorCodes`
2786
2787start({cmd}, {dispatchers}, {extra_spawn_params})        *vim.lsp.rpc.start()*
2788    Starts an LSP server process and create an LSP RPC client object to
2789    interact with it. Communication with the spawned process happens via
2790    stdio. For communication via TCP, spawn a process manually and use
2791    |vim.lsp.rpc.connect()|
2792
2793    Parameters: ~
2794      • {cmd}                 (`string[]`) Command to start the LSP server.
2795      • {dispatchers}         (`table?`) Dispatchers for LSP message types.
2796                              • {notification}
2797                                (`fun(method: string, params: table)`)
2798                              • {on_error} (`fun(code: integer, err: any)`)
2799                              • {on_exit}
2800                                (`fun(code: integer, signal: integer)`)
2801                              • {server_request}
2802                                (`fun(method: string, params: table): any?, lsp.ResponseError?`)
2803      • {extra_spawn_params}  (`table?`) Additional context for the LSP server
2804                              process.
2805                              • {cwd}? (`string`) Working directory for the
2806                                LSP server process
2807                              • {detached}? (`boolean`) Detach the LSP server
2808                                process from the current process
2809                              • {env}? (`table<string,string>`) Additional
2810                                environment variables for LSP server process.
2811                                See |vim.system()|
2812
2813    Return: ~
2814        (`vim.lsp.rpc.Client`)
2815
2816
2817==============================================================================
2818Lua module: vim.lsp.semantic_tokens                      *lsp-semantic_tokens*
2819
2820enable({enable}, {filter})                  *vim.lsp.semantic_tokens.enable()*
2821    Enables or disables semantic tokens for the {filter}ed scope.
2822
2823    To "toggle", pass the inverse of `is_enabled()`: >lua
2824        vim.lsp.semantic_tokens.enable(not vim.lsp.semantic_tokens.is_enabled())
2825<
2826
2827    Parameters: ~
2828      • {enable}  (`boolean?`) true/nil to enable, false to disable
2829      • {filter}  (`table?`) Optional filters |kwargs|,
2830                  • {bufnr}? (`integer`, default: all) Buffer number, or 0 for
2831                    current buffer, or nil for all.
2832                  • {client_id}? (`integer`, default: all) Client ID, or nil
2833                    for all.
2834
2835force_refresh({bufnr})               *vim.lsp.semantic_tokens.force_refresh()*
2836    Force a refresh of all semantic tokens
2837
2838    Only has an effect if the buffer is currently active for semantic token
2839    highlighting (|vim.lsp.semantic_tokens.enable()| has been called for it)
2840
2841    Parameters: ~
2842      • {bufnr}  (`integer?`) filter by buffer. All buffers if nil, current
2843                 buffer if 0
2844
2845                                        *vim.lsp.semantic_tokens.get_at_pos()*
2846get_at_pos({bufnr}, {row}, {col})
2847    Return the semantic token(s) at the given position. If called without
2848    arguments, returns the token under the cursor.
2849
2850    Parameters: ~
2851      • {bufnr}  (`integer?`) Buffer number (0 for current buffer, default)
2852      • {row}    (`integer?`) Position row (default cursor position)
2853      • {col}    (`integer?`) Position column (default cursor position)
2854
2855    Return: ~
2856        (`table?`) List of tokens at position. Each token has the following
2857        fields:
2858        • line (integer) line number, 0-based
2859        • start_col (integer) start column, 0-based
2860        • end_line (integer) end line number, 0-based
2861        • end_col (integer) end column, 0-based
2862        • type (string) token type as string, e.g. "variable"
2863        • modifiers (table) token modifiers as a set. E.g., { static = true,
2864          readonly = true }
2865        • client_id (integer)
2866
2867                                   *vim.lsp.semantic_tokens.highlight_token()*
2868highlight_token({token}, {bufnr}, {client_id}, {hl_group}, {opts})
2869    Highlight a semantic token.
2870
2871    Apply an extmark with a given highlight group for a semantic token. The
2872    mark will be deleted by the semantic token engine when appropriate; for
2873    example, when the LSP sends updated tokens. This function is intended for
2874    use inside |LspTokenUpdate| callbacks.
2875
2876    Parameters: ~
2877      • {token}      (`table`) Semantic token, provided as `ev.data.token` in
2878                     |LspTokenUpdate|
2879      • {bufnr}      (`integer`) Buffer to highlight, or `0` for current
2880                     buffer.
2881      • {client_id}  (`integer`) ID of the |vim.lsp.Client|
2882      • {hl_group}   (`string`) Highlight group name
2883      • {opts}       (`table?`) Optional parameters:
2884                     • {priority}? (`integer`, default:
2885                       `vim.hl.priorities.semantic_tokens + 3`) Priority for
2886                       the applied extmark.
2887
2888is_enabled({filter})                    *vim.lsp.semantic_tokens.is_enabled()*
2889    Query whether semantic tokens is enabled in the {filter}ed scope
2890
2891    Parameters: ~
2892      • {filter}  (`table?`) Optional filters |kwargs|,
2893                  • {bufnr}? (`integer`, default: all) Buffer number, or 0 for
2894                    current buffer, or nil for all.
2895                  • {client_id}? (`integer`, default: all) Client ID, or nil
2896                    for all.
2897
2898
2899==============================================================================
2900Lua module: vim.lsp.util                                            *lsp-util*
2901
2902*vim.lsp.util.open_floating_preview.Opts*
2903
2904    Fields: ~
2905      • {anchor_bias}?   (`'auto'|'above'|'below'`, default: `'auto'`) Adjusts
2906                         placement relative to cursor.
2907                         • "auto": place window based on which side of the
2908                           cursor has more lines
2909                         • "above": place the window above the cursor unless
2910                           there are not enough lines to display the full
2911                           window height.
2912                         • "below": place the window below the cursor unless
2913                           there are not enough lines to display the full
2914                           window height.
2915      • {border}?        (`''|'none'|'single'|'double'|'rounded'|'solid'|'shadow'|'bold'|(string|[string,string])[]`)
2916                         override `border`
2917      • {close_events}?  (`table`) List of events that closes the floating
2918                         window
2919      • {focus}?         (`boolean`, default: `true`) If `true`, and if
2920                         {focusable} is also `true`, focus an existing
2921                         floating window with the same {focus_id}
2922      • {focus_id}?      (`string`) If a popup with this id is opened, then
2923                         focus it
2924      • {focusable}?     (`boolean`, default: `true`) Make float focusable.
2925      • {height}?        (`integer`) Height of floating window
2926      • {max_height}?    (`integer`) Maximal height of floating window
2927      • {max_width}?     (`integer`) Maximal width of floating window
2928      • {offset_x}?      (`integer`) offset to add to `col`
2929      • {offset_y}?      (`integer`) offset to add to `row`
2930      • {relative}?      (`'mouse'|'cursor'|'editor'`) (default: `'cursor'`)
2931      • {title}?         (`string|[string,string][]`)
2932      • {title_pos}?     (`'left'|'center'|'right'`)
2933      • {width}?         (`integer`) Width of floating window
2934      • {wrap}?          (`boolean`, default: `true`) Wrap long lines
2935      • {wrap_at}?       (`integer`) Character to wrap at for computing height
2936                         when wrap is enabled
2937      • {zindex}?        (`integer`) override `zindex`, defaults to 50
2938
2939
2940                                     *vim.lsp.util.apply_text_document_edit()*
2941apply_text_document_edit({text_document_edit}, {index}, {position_encoding},
2942                         {change_annotations})
2943    Applies a `TextDocumentEdit`, which is a list of changes to a single
2944    document.
2945
2946    Parameters: ~
2947      • {text_document_edit}  (`lsp.TextDocumentEdit`)
2948      • {index}               (`integer?`) Optional index of the edit, if from
2949                              a list of edits (or nil, if not from a list)
2950      • {position_encoding}   (`'utf-8'|'utf-16'|'utf-32'`)
2951      • {change_annotations}  (`table<string, lsp.ChangeAnnotation>?`)
2952
2953    See also: ~
2954      • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentEdit
2955
2956                                             *vim.lsp.util.apply_text_edits()*
2957apply_text_edits({text_edits}, {bufnr}, {position_encoding},
2958                 {change_annotations}, {opts})
2959    Applies a list of text edits to a buffer. Note: this mutates `text_edits`
2960    (sorts in-place and adds `_index` fields).
2961
2962    Parameters: ~
2963      • {text_edits}          (`(lsp.TextEdit|lsp.AnnotatedTextEdit)[]`)
2964      • {bufnr}               (`integer`) Buffer id
2965      • {position_encoding}   (`'utf-8'|'utf-16'|'utf-32'`)
2966      • {change_annotations}  (`table<string, lsp.ChangeAnnotation>?`)
2967      • {opts}                (`table?`) A table with the following fields:
2968                              • {keep_cursor}? (`boolean`, default: `false`)
2969                                Keep the cursor on the text it is on, instead
2970                                of letting the edits move it.
2971
2972    See also: ~
2973      • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textEdit
2974
2975                                         *vim.lsp.util.apply_workspace_edit()*
2976apply_workspace_edit({workspace_edit}, {position_encoding})
2977    Applies a `WorkspaceEdit`.
2978
2979    Parameters: ~
2980      • {workspace_edit}     (`lsp.WorkspaceEdit`)
2981      • {position_encoding}  (`'utf-8'|'utf-16'|'utf-32'`) (required)
2982
2983    See also: ~
2984      • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_applyEdit
2985
2986buf_clear_references({bufnr})            *vim.lsp.util.buf_clear_references()*
2987    Removes document highlights from a buffer.
2988
2989    Parameters: ~
2990      • {bufnr}  (`integer?`) Buffer id
2991
2992                                     *vim.lsp.util.buf_highlight_references()*
2993buf_highlight_references({bufnr}, {references}, {position_encoding})
2994    Shows a list of document highlights for a certain buffer.
2995
2996    Parameters: ~
2997      • {bufnr}              (`integer`) Buffer id
2998      • {references}         (`lsp.DocumentHighlight[]`) objects to highlight
2999      • {position_encoding}  (`'utf-8'|'utf-16'|'utf-32'`)
3000
3001    See also: ~
3002      • https://microsoft.github.io/language-server-protocol/specification/#textDocumentContentChangeEvent
3003
3004                              *vim.lsp.util.convert_input_to_markdown_lines()*
3005convert_input_to_markdown_lines({input}, {contents})
3006    Converts any of `MarkedString` | `MarkedString[]` | `MarkupContent` into a
3007    list of lines containing valid markdown. Useful to populate the hover
3008    window for `textDocument/hover`, for parsing the result of
3009    `textDocument/signatureHelp`, and potentially others.
3010
3011    Note that if the input is of type `MarkupContent` and its kind is
3012    `plaintext`, then the corresponding value is returned without further
3013    modifications.
3014
3015    Parameters: ~
3016      • {input}     (`lsp.MarkedString|lsp.MarkedString[]|lsp.MarkupContent`)
3017      • {contents}  (`string[]?`) List of strings to extend with converted
3018                    lines. Defaults to {}.
3019
3020    Return: ~
3021        (`string[]`) extended with lines of converted markdown.
3022
3023    See also: ~
3024      • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_hover
3025
3026                     *vim.lsp.util.convert_signature_help_to_markdown_lines()*
3027convert_signature_help_to_markdown_lines({signature_help}, {ft}, {triggers})
3028    Converts `textDocument/signatureHelp` response to markdown lines.
3029
3030    Parameters: ~
3031      • {signature_help}  (`lsp.SignatureHelp`) Response of
3032                          `textDocument/SignatureHelp`
3033      • {ft}              (`string?`) filetype that will be use as the `lang`
3034                          for the label markdown code block
3035      • {triggers}        (`string[]?`) list of trigger characters from the
3036                          lsp server. used to better determine parameter
3037                          offsets
3038
3039    Return (multiple): ~
3040        (`string[]?`) lines of converted markdown.
3041        (`Range4?`) highlight range for the active parameter
3042
3043    See also: ~
3044      • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_signatureHelp
3045
3046get_effective_tabstop({bufnr})          *vim.lsp.util.get_effective_tabstop()*
3047    Returns indentation size.
3048
3049    Parameters: ~
3050      • {bufnr}  (`integer?`) Buffer handle, defaults to current
3051
3052    Return: ~
3053        (`integer`) indentation size
3054
3055    See also: ~
3056      • 'shiftwidth'
3057
3058                                           *vim.lsp.util.locations_to_items()*
3059locations_to_items({locations}, {position_encoding})
3060    Returns the items with the byte position calculated correctly and in
3061    sorted order, for display in quickfix and location lists.
3062
3063    The `user_data` field of each resulting item will contain the original
3064    `Location` or `LocationLink` it was computed from.
3065
3066    The result can be passed to the {list} argument of |setqflist()| or
3067    |setloclist()|.
3068
3069    Parameters: ~
3070      • {locations}          (`lsp.Location[]|lsp.LocationLink[]`)
3071      • {position_encoding}  (`'utf-8'|'utf-16'|'utf-32'`)
3072
3073    Return: ~
3074        (`vim.quickfix.entry[]`) See |setqflist()| for the format
3075
3076                                  *vim.lsp.util.make_floating_popup_options()*
3077make_floating_popup_options({width}, {height}, {opts})
3078    Creates a table with sensible default options for a floating window. The
3079    table can be passed to |nvim_open_win()|.
3080
3081    Parameters: ~
3082      • {width}   (`integer`) window width (in character cells)
3083      • {height}  (`integer`) window height (in character cells)
3084      • {opts}    (`vim.lsp.util.open_floating_preview.Opts?`)
3085
3086    Return: ~
3087        (`vim.api.keyset.win_config`)
3088
3089                                       *vim.lsp.util.make_formatting_params()*
3090make_formatting_params({options})
3091    Creates a `DocumentFormattingParams` object for the current buffer and
3092    cursor position.
3093
3094    Parameters: ~
3095      • {options}  (`lsp.FormattingOptions?`) with valid `FormattingOptions`
3096                   entries
3097
3098    Return: ~
3099        (`lsp.DocumentFormattingParams`) object
3100
3101    See also: ~
3102      • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting
3103
3104                                      *vim.lsp.util.make_given_range_params()*
3105make_given_range_params({start_pos}, {end_pos}, {bufnr}, {position_encoding})
3106    Using the given range in the current buffer, creates an object that is
3107    similar to |vim.lsp.util.make_range_params()|.
3108
3109    Parameters: ~
3110      • {start_pos}          (`[integer,integer]?`) {row,col} mark-indexed
3111                             position. Defaults to the start of the last
3112                             visual selection.
3113      • {end_pos}            (`[integer,integer]?`) {row,col} mark-indexed
3114                             position. Defaults to the end of the last visual
3115                             selection.
3116      • {bufnr}              (`integer?`) buffer handle or 0 for current,
3117                             defaults to current
3118      • {position_encoding}  (`'utf-8'|'utf-16'|'utf-32'`)
3119
3120    Return: ~
3121        (`{ textDocument: { uri: lsp.DocumentUri }, range: lsp.Range }`)
3122
3123                                         *vim.lsp.util.make_position_params()*
3124make_position_params({win}, {position_encoding})
3125    Creates a `TextDocumentPositionParams` object for the current buffer and
3126    cursor position.
3127
3128    Parameters: ~
3129      • {win}                (`integer?`) |window-ID| or 0 for current,
3130                             defaults to current
3131      • {position_encoding}  (`'utf-8'|'utf-16'|'utf-32'`)
3132
3133    Return: ~
3134        (`lsp.TextDocumentPositionParams`)
3135
3136    See also: ~
3137      • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentPositionParams
3138
3139                                            *vim.lsp.util.make_range_params()*
3140make_range_params({win}, {position_encoding})
3141    Using the current position in the current buffer, creates an object that
3142    can be used as a building block for several LSP requests, such as
3143    `textDocument/codeAction`, `textDocument/colorPresentation`,
3144    `textDocument/rangeFormatting`.
3145
3146    Parameters: ~
3147      • {win}                (`integer?`) |window-ID| or 0 for current,
3148                             defaults to current
3149      • {position_encoding}  (`"utf-8"|"utf-16"|"utf-32"`)
3150
3151    Return: ~
3152        (`{ textDocument: { uri: lsp.DocumentUri }, range: lsp.Range }`)
3153
3154                                    *vim.lsp.util.make_text_document_params()*
3155make_text_document_params({bufnr})
3156    Creates a `TextDocumentIdentifier` object for the current buffer.
3157
3158    Parameters: ~
3159      • {bufnr}  (`integer?`) Buffer handle, defaults to current
3160
3161    Return: ~
3162        (`lsp.TextDocumentIdentifier`)
3163
3164    See also: ~
3165      • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentIdentifier
3166
3167                                        *vim.lsp.util.make_workspace_params()*
3168make_workspace_params({added}, {removed})
3169    Create the workspace params
3170
3171    Parameters: ~
3172      • {added}    (`lsp.WorkspaceFolder[]`)
3173      • {removed}  (`lsp.WorkspaceFolder[]`)
3174
3175    Return: ~
3176        (`lsp.DidChangeWorkspaceFoldersParams`)
3177
3178                                        *vim.lsp.util.open_floating_preview()*
3179open_floating_preview({contents}, {syntax}, {opts})
3180    Shows contents in a floating window.
3181
3182    Parameters: ~
3183      • {contents}  (`table`) of lines to show in window
3184      • {syntax}    (`string`) of syntax to set for opened buffer
3185      • {opts}      (`vim.lsp.util.open_floating_preview.Opts?`) with optional
3186                    fields (additional keys are filtered with
3187                    |vim.lsp.util.make_floating_popup_options()| before they
3188                    are passed on to |nvim_open_win()|)
3189
3190    Return (multiple): ~
3191        (`integer`) bufnr of newly created float window
3192        (`integer`) winid of newly created float window preview window
3193
3194preview_location({location}, {opts})         *vim.lsp.util.preview_location()*
3195    Previews a location in a floating window
3196
3197    behavior depends on type of location:
3198    • for Location, range is shown (e.g., function definition)
3199    • for LocationLink, targetRange is shown (e.g., body of function
3200      definition)
3201
3202    Parameters: ~
3203      • {location}  (`lsp.Location|lsp.LocationLink`)
3204      • {opts}      (`vim.lsp.util.open_floating_preview.Opts?`)
3205
3206    Return (multiple): ~
3207        (`integer?`) buffer id of float window
3208        (`integer?`) window id of float window
3209
3210rename({old_fname}, {new_fname}, {opts})               *vim.lsp.util.rename()*
3211    Rename old_fname to new_fname
3212
3213    Existing buffers are renamed as well, while maintaining their bufnr.
3214
3215    It deletes existing buffers that conflict with the renamed file name only
3216    when
3217    • `opts` requests overwriting; or
3218    • the conflicting buffers are not loaded, so that deleting them does not
3219      result in data loss.
3220
3221    Parameters: ~
3222      • {old_fname}  (`string`)
3223      • {new_fname}  (`string`)
3224      • {opts}       (`table?`) Options:
3225                     • {ignoreIfExists}? (`boolean`)
3226                     • {overwrite}? (`boolean`)
3227
3228                                                *vim.lsp.util.show_document()*
3229show_document({location}, {position_encoding}, {opts})
3230    Shows document and optionally jumps to the location.
3231
3232    Parameters: ~
3233      • {location}           (`lsp.Location|lsp.LocationLink`)
3234      • {position_encoding}  (`'utf-8'|'utf-16'|'utf-32'`)
3235      • {opts}               (`table?`) A table with the following fields:
3236                             • {focus}? (`boolean`) Whether to focus/jump to
3237                               location if possible. (defaults: true)
3238                             • {reuse_win}? (`boolean`) Jump to existing
3239                               window if buffer is already open.
3240
3241    Return: ~
3242        (`boolean`) `true` if succeeded
3243
3244                                             *vim.lsp.util.symbols_to_items()*
3245symbols_to_items({symbols}, {bufnr}, {position_encoding})
3246    Converts symbols to quickfix list items.
3247
3248    Parameters: ~
3249      • {symbols}            (`lsp.DocumentSymbol[]|lsp.SymbolInformation[]|lsp.WorkspaceSymbol[]`)
3250                             list of symbols
3251      • {bufnr}              (`integer?`) buffer handle or 0 for current,
3252                             defaults to current
3253      • {position_encoding}  (`'utf-8'|'utf-16'|'utf-32'`)
3254
3255    Return: ~
3256        (`vim.quickfix.entry[]`) See |setqflist()| for the format
3257
3258
3259==============================================================================
3260Lua module: vim.lsp.protocol                                    *lsp-protocol*
3261
3262                                 *vim.lsp.protocol.make_client_capabilities()*
3263make_client_capabilities()
3264    Gets a new ClientCapabilities object describing the LSP client
3265    capabilities.
3266
3267    Return: ~
3268        (`lsp.ClientCapabilities`)
3269
3270                                     *vim.lsp.protocol.resolve_capabilities()*
3271resolve_capabilities({server_capabilities})
3272    Creates a normalized object describing LSP server capabilities.
3273
3274    Parameters: ~
3275      • {server_capabilities}  (`table`) Table of capabilities supported by
3276                               the server
3277
3278    Return: ~
3279        (`lsp.ServerCapabilities?`) Normalized table of capabilities
3280
3281
3282 vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl: