Commit Graph

131 Commits

Author SHA1 Message Date
Jongwook Choi
2cdea852e8 docs: auto-generate docs for vim.lpeg and vim.re
- Add section `VIM.LPEG` and `VIM.RE` to docs/lua.txt.

- Add `_meta/re.lua` which adds luadoc and type annotations, for the
  vendored `vim.re` package.

- Fix minor style issues on `_meta/lpeg.lua` luadoc for better vimdocs
  generation.

- Fix a bug on `gen_vimdoc` where non-helptags in verbatim code blocks
  were parsed as helptags, affecting code examples on `vim.lpeg.Cf`,
  etc.

- Also move the `vim.regex` section below so that it can be located
  closer to `vim.lpeg` and `vim.re`.
2024-01-14 11:08:33 +00:00
Lewis Russell
2f9ee9b6cf fix(doc): improve doc generation of types using lpeg
Added a lpeg grammar for LuaCATS and use it in lua2dox.lua
2024-01-11 16:24:12 +00:00
Jongwook Choi
f40df63bdc fix(docs): make lines not overflow in vim docs
Problem: Some lines in the generated vim doc are overflowing, not
correctly wrapped at 78 characters. This happens when docs body contains
several consecutive 'inline' elements generated by doxygen.

Solution: Take into account the current column offset of the last line,
and prepend some padding before doc_wrap().
2024-01-09 13:33:18 +00:00
Jongwook Choi
765729a145 fix(gen_vimdoc): INCLUDE_DEPRECATED not generating docs for deprecateds
Since some point INCLUDE_DEPRECATED stopped working as it is usually
turned off when generating an actual vimdoc. This commit fixes this
hidden feature back again (used for devel purposes only).
2024-01-02 11:35:34 -05:00
Jongwook Choi
f74f52a1a5 refactor(gen_vimdoc): refactor section and defgroup doc generation
Problem: main() has too much logic implemented there, too difficult to
read.

Solution: Do more OOP, introduce `Section` dataclass that stores
information about a "section", with documentation and concrete examples
about what each field and variable would mean. Extract all the lines for
rendering a section into `section.render()` pulled out of `main()`.
2024-01-02 11:32:35 -05:00
Jongwook Choi
4e9298ecdf refactor(gen_vimdoc): generate function doc from metadata, not from xml
Problem:

For function definitions to be included in the vimdoc (formatted) and
to be exported as mpack data (unformatted), we had two internal
representations of the same function/API metadata in duplicate;
one is FunctionDoc (which was previously a dict), and the other is
doxygen XML DOM from which vimdoc (functions sections) was generated.

Solution:

We should have a single path and unified data representation
(i.e. FunctionDoc) that contains all the metadata and information about
function APIs, from which both of mpack export and vimdoc are generated.
I.e., vimdocs are no longer generated directly from doxygen XML nodes,
but generated via:

  (XML DOM Nodes) ------------> FunctionDoc ------> mpack (unformatted)
                   Recursive     Internal     |
                   Formatting    Metadata     +---> vimdoc (formatted)

This refactoring eliminates the hacky and ugly use of `fmt_vimhelp` in
`fmt_node_as_vimhelp()` and all other helper functions! This way,
`fmt_node_as_vimhelp()` can simplified as it no longer needs to handle
generating of function docs, which needs to be done only in the topmost
level of recursion.
2024-01-02 11:32:32 -05:00
Jongwook Choi
1a31d4cf2b refactor(gen_vimdoc): use typing for function API vimdoc generation 2024-01-02 11:15:36 -05:00
Jongwook Choi
5e2d4b3c4d refactor(gen_vimdoc): use stronger typing for CONFIG, avoid dict 2024-01-02 11:15:31 -05:00
Mathias Fußenegger
5dc0bdfe98
docs(glob): add glob module (#26853) 2024-01-02 14:32:43 +01:00
LW
9fa9b3cad9
docs: support @since for api level #25574
close #25416
2023-11-27 08:23:04 -08:00
Gregory Anders
4bf47222c9
feat: add vim.text module (#26069) 2023-11-16 11:35:54 -06:00
Gregory Anders
dc3f84bf4f
docs: fix vim.snippet help tags (#26068) 2023-11-16 10:53:25 -06:00
LW
448907f65d
feat(lsp)!: vim.lsp.inlay_hint.get(), enable(), is_enabled() #25512
refactor!: `vim.lsp.inlay_hint()` -> `vim.lsp.inlay_hint.enable()`

Problem:
The LSP specification allows inlay hints to include tooltips, clickable
label parts, and code actions; but Neovim provides no API to query for
these.

Solution:
Add minimal viable extension point from which plugins can query for
inlay hints in a range, in order to build functionality on top of.

Possible Next Steps
---

- Add `virt_text_idx` field to `vim.fn.getmousepos()` return value, for
  usage in mappings of `<LeftMouse>`, `<C-LeftMouse>`, etc
2023-11-12 04:54:27 -08:00
Gregory Anders
224f303ee5
feat(stdlib): add vim.base64 module (#25843)
Add base64 encode() and decode() functions to a vim.base64 module.
2023-10-31 09:15:32 -05:00
Maria José Solano
f1775da07f
feat(lsp): add snippet API (#25301) 2023-10-21 08:51:26 +02:00
Gregory Anders
2e92065686
docs: replace <pre> with ``` (#25136) 2023-09-14 08:23:01 -05:00
Gregory Anders
27a566f3f8
feat(vimdoc): support Markdown code blocks (#25127)
Support Markdown code blocks in addition to <pre> blocks in Doxygen doc
comments.

Update doc comments in iter.lua as a test.
2023-09-13 08:38:28 -05:00
Lewis Russell
2234b84a1b docs(generators): bake into cmake 2023-08-23 12:16:04 +01:00
Lewis Russell
48d533272e
feat(lua-types): types for vim.api.* (#24523) 2023-08-01 14:20:44 +01:00
Lewis Russell
42333ea98d
feat(docs): generate builtin.txt (#24493)
- eval.lua is now the source of truth.

- Formatting is much more consistent.

- Fixed Lua type generation for polymorphic functions (get(), etc).

- Removed "Overview" section from builtin.txt
  - Can generate this if we really want it.

- Moved functions from sign.txt and testing.txt into builtin.txt.

- Removed the *timer* *timers* tags since libuv timers via vim.uv should be preferred.

- Removed the temp-file-name tag from tempname()

- Moved lueval() from lua.txt to builtin.txt.

* Fix indent

* fixup!

* fixup! fixup!

* fixup! better tag formatting

* fixup: revert changes no longer needed

* fixup! CI

---------

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-07-28 14:48:41 +01:00
Lewis Russell
be74807eef
docs(lua): more improvements (#24387)
* docs(lua): teach lua2dox how to table

* docs(lua): teach gen_vimdoc.py about local functions

No more need to mark local functions with @private

* docs(lua): mention @nodoc and @meta in dev-lua-doc

* fixup!

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>

---------

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2023-07-18 15:42:30 +01:00
Lewis Russell
e6e0bc225b refactor(gen_vimdoc): put defgroup handling in a function 2023-07-17 16:25:29 +01:00
Lewis Russell
c2d7c2826c docs(lua): change *lua-foo* -> *vim.foo* 2023-07-17 16:25:29 +01:00
Lewis Russell
0ac3c4d631 docs(lua): move function docs to lua files 2023-07-17 16:25:28 +01:00
Lewis Russell
a54f88ea64 docs(lua): do not render self args 2023-07-17 12:59:06 +01:00
Justin M. Keyes
d2e44da516 docs: gather @notes items into one section
related: 21eacbfef3
2023-07-08 15:06:36 +02:00
Justin M. Keyes
3a721820c3 docs: "Return (multiple)" heading
Problem:
Lua functions that return multiple results are declared by using
multiple `@return` docstring directives. But the generated docs don't
make it obvious what this represents.

Solution:
- Generate a "Return (multiple)" heading for multiple-value functions.
- Fix `@note` directives randomly placed after `@return`.
2023-07-08 15:06:36 +02:00
Sean Dewar
77118d0da8
fix(api): use text_locked() to check textlock
Problem: some API functions that check textlock (usually those that can change
curwin or curbuf) can break the cmdwin.

Solution: make FUNC_API_CHECK_TEXTLOCK call text_locked() instead, which already
checks for textlock, cmdwin and `<expr>` status.

Add FUNC_API_TEXTLOCK_ALLOW_CMDWIN to allow such functions to be usable in the
cmdwin if they can work properly there; the opt-in nature of this attribute
should hopefully help mitigate future bugs.

Also fix a regression in #22634 that made functions checking textlock usable in
`<expr>` mappings, and rename FUNC_API_CHECK_TEXTLOCK to FUNC_API_TEXTLOCK.
2023-07-05 08:31:52 +01:00
Justin M. Keyes
49a7585981 docs: autocmds, misc 2023-06-25 17:25:47 +02:00
Chinmay Dalal
ca5de9306c
feat(lsp): inlay hints #23984
Add automatic refresh and a public interface on top of #23736

 * add on_reload, on_detach handlers in `enable()` buf_attach, and
  LspDetach autocommand in case of manual detach
* unify `__buffers` and `hint_cache_by_buf`
* use callback bufnr in `on_lines` callback, bufstate: remove __index override
* move user-facing functions into vim.lsp.buf, unify enable/disable/toggle

Closes #18086
2023-06-19 23:06:54 -07:00
Chinmay Dalal
643546b82b
feat(lsp): add handlers for inlay hints (#23736)
initial support; public API left for a follow-up PR
2023-06-11 11:53:37 +02:00
Justin M. Keyes
c48b1421af
refactor!: rename "playground" => "dev" #23919
Problem:
"playground" is new jargon that overlaps with existing concepts:
"dev" (`:help dev`) and "view" (also "scratch" `:help scratch-buffer`) .

Solution:
We should consistently use "dev" as the namespace for where "developer
tools" live. For purposes of a "throwaway sandbox object", we can use
the name "view".
- Rename `TSPlayground` => `TSView`
- Rename `playground.lua` => `dev.lua`
2023-06-06 08:23:20 -07:00
Mathias Fußenegger
5e31f53457
docs(lsp): remove vim.lsp.sync (#23416)
The module is used internally and not intended to be used by plugins or
users.
2023-05-01 10:54:37 +02:00
Gregory Anders
1e73891d69 refactor(iter): move helper functions under vim.iter
vim.iter is now both a function and a module (similar to vim.version).
2023-04-25 08:23:16 -06:00
Gregory Anders
ab1edecfb7
feat(lua): add vim.iter (#23029)
vim.iter wraps a table or iterator function into an `Iter` object with
methods such as `filter`, `map`, and `fold` which can be chained to
produce iterator pipelines that do not create new tables at each step.
2023-04-17 12:54:19 -06:00
Folke Lemaitre
2257ade3dc
feat(lua): add vim.loader
feat: new faster lua loader using byte-compilation
2023-03-26 11:42:15 +01:00
Lewis Russell
cbbf8bd666
feat(treesitter)!: deprecate top level indexes to modules (#22761)
The following top level Treesitter functions have been moved:
  - vim.treesitter.inspect_language() -> vim.treesitter.language.inspect()
  - vim.treesitter.get_query_files() -> vim.treesitter.query.get_files()
  - vim.treesitter.set_query() -> vim.treesitter.query.set()
  - vim.treesitter.query.set_query() -> vim.treesitter.query.set()
  - vim.treesitter.get_query() -> vim.treesitter.query.get()
  - vim.treesitter.query.get_query() -> vim.treesitter.query.get()
  - vim.treesitter.parse_query() -> vim.treesitter.query.parse()
  - vim.treesitter.query.parse_query() -> vim.treesitter.query.parse()
  - vim.treesitter.add_predicate() -> vim.treesitter.query.add_predicate()
  - vim.treesitter.add_directive() -> vim.treesitter.query.add_directive()
  - vim.treesitter.list_predicates() -> vim.treesitter.query.list_predicates()
  - vim.treesitter.list_directives() -> vim.treesitter.query.list_directives()
  - vim.treesitter.query.get_range() -> vim.treesitter.get_range()
  - vim.treesitter.query.get_node_text() -> vim.treesitter.get_node_text()
2023-03-24 14:43:14 +00:00
Justin M. Keyes
21eacbfef3
docs(html): render @see items as a list #22675
Needed for "flow" HTML layout.

Flow layout before:
    See also:
    https://github.com/kikito/inspect.lua https://github.com/mpeterv/vinspect
Flow layout after:
    See also:
    - https://github.com/kikito/inspect.lua
    - https://github.com/mpeterv/vinspect
2023-03-15 04:51:44 -07:00
Justin M. Keyes
e31e49a8e3 refactor(vim.version): cleanup
- version.cmp(): assert valid version
- add test for loading vim.version (the other tests use shared.lua in
  the test runner)
- reduce test scopes, reword test descriptions
2023-03-06 14:51:56 +01:00
Kelly Lin
0e7196438d feat(lua): add semver api 2023-03-06 13:45:59 +01:00
Justin M. Keyes
533d671271
docs: module-level docstrings (@defgroup) #22498
Problem:
gen_vimdoc.py / lua2dox.lua does not support @defgroup or \defgroup
except for "api-foo" modules.

Solution:
Modify `gen_vimdoc.py` to look for section names based on `helptag_fmt`.

TODO:
- Support @module ?
  https://github.com/LuaLS/lua-language-server/wiki/Annotations#module
2023-03-05 15:15:29 -08:00
Justin M. Keyes
57f26e0903 docs: lua2dox.lua debugging 2023-03-03 15:07:23 +01:00
Justin M. Keyes
8414cfe7f4 docs: fix vim.treesitter tags
Problem:
Help tags like vim.treesitter.language.add() are confusing because
`vim.treesitter.language` is (thankfully) not a user-facing module.

Solution:
Ignore the "fstem" when generating "treesitter" tags.
2023-03-03 15:07:23 +01:00
Mathias Fußenegger
db32d312ac
ci(fix): repair regen-api-docs (#22403)
https://github.com/neovim/neovim/pull/22398 broke the job because there
is no `build/bin/nvim`

This keeps the preference for `build/bin/nvim` but adds back `nvim` as
fallback if it doesn't exist.
2023-02-25 17:24:43 +01:00
Mathias Fußenegger
2708507e87
docs: use build/bin/nvim instead of nvim in gen_vimdoc (#22398)
Problem:

`nvim` could point to stable release missing the `nvim -l`
functionality.

Solution:

Require to build nvim first and use `build/bin/nvim`
2023-02-25 16:35:45 +01:00
Justin M. Keyes
7c94bcd2d7 feat(lua)!: execute Lua with "nvim -l"
Problem:
Nvim has Lua but the "nvim" CLI can't easily be used to execute Lua
scripts, especially scripts that take arguments or produce output.

Solution:
- support "nvim -l [args...]" for running scripts. closes #15749
- exit without +q
- remove lua2dox_filter
- remove Doxyfile. This wasn't used anyway, because the doxygen config
  is inlined in gen_vimdoc.py (`Doxyfile` variable).
- use "nvim -l" in docs-gen CI job

Examples:

    $ nvim -l scripts/lua2dox.lua --help
    Lua2DoX (0.2 20130128)
    ...

    $ echo "print(vim.inspect(_G.arg))" | nvim -l - --arg1 --arg2
    $ echo 'print(vim.inspect(vim.api.nvim_buf_get_text(1,0,0,-1,-1,{})))' | nvim +"put ='text'" -l -

TODO?
  -e executes Lua code
  -l loads a module
  -i enters REPL _after running the other arguments_.
2023-01-05 17:10:02 +01:00
Folke Lemaitre
ef91146efc
feat: vim.inspect_pos, vim.show_pos, :Inspect 2022-12-17 13:05:31 +01:00
John Drouhard
9f035559de feat(lsp): initial support for semantic token highlighting
* credit to @smolck and @theHamsta for their contributions in laying the
  groundwork for this feature and for their work on some of the helper
  utility functions and tests
2022-12-08 11:31:56 -06:00
Gregory Anders
f8aa2a0dea
docs(treesitter): use full function names in tags (#21321) 2022-12-07 09:27:41 +01:00
Christian Clason
0b05bd87c0 docs(gen): support language annotation in docstrings 2022-12-02 16:05:00 +01:00