Commit Graph

23 Commits

Author SHA1 Message Date
Lewis Russell
3f1d09bc94 feat(lsp): add vim.lsp.config and vim.lsp.enable
Design goals/requirements:
- Default configuration of a server can be distributed across multiple sources.
  - And via RTP discovery.
- Default configuration can be specified for all servers.
- Configuration _can_ be project specific.

Solution:

- Two new API's:
  - `vim.lsp.config(name, cfg)`:
    - Used to define default configurations for servers of name.
    - Can be used like a table or called as a function.
    - Use `vim.lsp.confg('*', cfg)` to specify default config for all
      servers.
  - `vim.lsp.enable(name)`
    - Used to enable servers of name. Uses configuration defined
    via `vim.lsp.config()`.
2024-12-10 17:16:01 +00:00
Yi Ming
a1e313ded6
feat(lsp): support textDocument/foldingRange (#31311)
* refactor(shared): extract `vim._list_insert` and `vim._list_remove`

* feat(lsp): add `vim.lsp.foldexpr()`

* docs(lsp): add a todo for state management

* feat(lsp): add `vim.lsp.folding_range.foldclose()`

* feat(lsp): schedule `foldclose()` if the buffer is not up-to-date

* feat(lsp): add `vim.lsp.foldtext()`

* feat(lsp): support multiple folding range providers

* refactor(lsp): expose all folding related functions under `vim.lsp.*`

* perf(lsp): add `lsp.MultiHandler` for do `foldupdate()` only once
2024-11-29 12:40:32 +00:00
Lewis Russell
454ae672aa feat(lsp): deprecate non-method client functions
Deprecated:
- `client.request()` -> `client:request()`
- `client.request_sync()` -> `client:request_sync()`
- `client.notify()` -> `client:notify()`
- `client.cancel_request()` -> `client:cancel_request()`
- `client.stop()` -> `client:stop()`
- `client.is_stopped()` `client:is_stopped()`
- `client.supports_method()` -> `client:supports_method()`
- `client.on_attach()` -> `client:on_attach()`

Fixed docgen to link class fields to the full function doc.
2024-11-20 08:51:45 +00:00
Lewis Russell
3275ae830d fix(lsp.protocal): improve typing of constants 2024-10-24 10:53:03 +01:00
Justin M. Keyes
18b43c331d refactor: rename vim.highlight => vim.hl
Problem:
- `vim.highlight` module does not follow `:help dev-name-common`, which
  documents the name for "highlight" as "hl".
- Shorter names are usually preferred.

Solution:
Rename `vim.highlight` to `vim.hl`.

This is not a breaking change until 2.0 (or maybe never).
2024-10-21 00:54:43 +02:00
Justin M. Keyes
b45c50f314
docs: render @since versions, 0 means experimental #30649
An implication of this current approach is that `NVIM_API_LEVEL` should be
bumped when a new Lua function is added.

TODO(future): add a lint check which requires `@since` on all new functions.

ref #25416
2024-10-04 02:13:31 -07:00
Riley Bruins
f62728cd80
docs(treesitter): generate TSNode, TSTree docs #30643
**Problem:** The documentation for `TSNode` and `TSTree` methods is
incomplete from the LSP perspective. This is because they are written
directly to the vimdoc, rather than in Lua and generated to vimdoc.

**Solution:** Migrate the docs to Lua and generate them into the vimdoc.
This requires breaking up the `treesitter/_meta.lua` file into a
directory with a few different modules.

This commit also makes the vimdoc generator slightly more robust with
regard to sections that have multiple help tags (e.g. `*one* *two*`)
2024-10-03 16:57:19 -07:00
Justin M. Keyes
61e9137394
docs: misc #28970 2024-09-01 13:01:24 -07:00
Lewis Russell
5e49ef0af3 refactor(lua): improve type annotations 2024-06-11 12:45:43 +01:00
Ilia Choly
8cbb1f20e5
refactor(lua): use tuple syntax everywhere #29111 2024-06-04 06:06:02 -07:00
Gregory Anders
0bdd602bf9
Merge pull request #27339 from MariaSolOs/completion
feat(lsp): completion side effects
2024-05-28 12:39:30 -05:00
Maria José Solano
ff097f2091 feat(lsp): completion side effects 2024-05-27 14:53:28 -07:00
dundargoc
6e8a728e3d refactor: fix luals type warnings 2024-05-27 20:48:46 +02:00
dundargoc
6dc62c2e2b docs: extract health to its own file 2024-05-24 11:07:30 +02:00
dundargoc
e8f7025de1 docs: move vim.health documentation to lua.txt
`vim.health` is not a "plugin" but part of our Lua API and the
documentation should reflect that. This also helps make the
documentation maintenance easier as it is now generated.
2024-05-22 20:15:17 +02:00
zeertzjq
ffb4b50e74
docs(lua): restore missing indexing for vim.bo and vim.wo (#28751) 2024-05-15 19:39:35 +08:00
Justin M. Keyes
dafa51c16d
docs(api): sort unreleased nvim__ functions last #28580 2024-04-30 06:06:14 -07:00
Lewis Russell
14e4b6bbd8 refactor(lua): type annotations 2024-03-16 19:26:10 +00:00
Lewis Russell
a09ddd7ce5 docs(editorconfig): move to source 2024-03-10 23:20:44 +00:00
Lewis Russell
a4290f462e docs(lua): improvements for LSP and Diagnostic 2024-03-05 13:36:46 +00:00
Lewis Russell
a5fe8f59d9 docs: improve/add documentation of Lua types
- Added `@inlinedoc` so single use Lua types can be inlined into the
  functions docs. E.g.

  ```lua
  --- @class myopts
  --- @inlinedoc
  ---
  --- Documentation for some field
  --- @field somefield integer

  --- @param opts myOpts
  function foo(opts)
  end
  ```

  Will be rendered as

  ```
  foo(opts)

    Parameters:
      - {opts} (table) Object with the fields:
               - somefield (integer) Documentation
                 for some field
  ```

- Marked many classes with with `@nodoc` or `(private)`.
  We can eventually introduce these when we want to.
2024-03-01 23:02:18 +00:00
altermo
2f85bbe615 feat!: rewrite TOhtml in lua
Co-authored-by: wookayin <wookayin@gmail.com>
Co-authored-by: clason <c.clason@uni-graz.at>
Co-authored-by: Lewis Russell <me@lewisr.dev>
2024-02-28 16:26:00 +00:00
Lewis Russell
9beb40a4db feat(docs): replace lua2dox.lua
Problem:

The documentation flow (`gen_vimdoc.py`) has several issues:
- it's not very versatile
- depends on doxygen
- doesn't work well with Lua code as it requires an awkward filter script to convert it into pseudo-C.
- The intermediate XML files and filters makes it too much like a rube goldberg machine.

Solution:

Re-implement the flow using Lua, LPEG and treesitter.

- `gen_vimdoc.py` is now replaced with `gen_vimdoc.lua` and replicates a portion of the logic.
- `lua2dox.lua` is gone!
- No more XML files.
- Doxygen is now longer used and instead we now use:
  - LPEG for comment parsing (see `scripts/luacats_grammar.lua` and `scripts/cdoc_grammar.lua`).
  - LPEG for C parsing (see `scripts/cdoc_parser.lua`)
  - Lua patterns for Lua parsing (see `scripts/luacats_parser.lua`).
  - Treesitter for Markdown parsing (see `scripts/text_utils.lua`).
- The generated `runtime/doc/*.mpack` files have been removed.
   - `scripts/gen_eval_files.lua` now instead uses `scripts/cdoc_parser.lua` directly.
- Text wrapping is implemented in `scripts/text_utils.lua` and appears to produce more consistent results (the main contributer to the diff of this change).
2024-02-27 14:41:17 +00:00