Commit Graph

97 Commits

Author SHA1 Message Date
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
Gregory Anders
f1922e78a1 feat: add vim.secure.read()
This function accepts a path to a file and prompts the user if the file
is trusted. If the user confirms that the file is trusted, the contents
of the file are returned. The user's decision is stored in a trust
database at $XDG_STATE_HOME/nvim/trust. When this function is invoked
with a path that is already marked as trusted in the trust database, the
user is not prompted for a response.
2022-11-17 08:23:41 -07:00
Lewis Russell
f8c6718277
feat(lua-api): avoid unnecessary allocations (#19877)
Lua makes (or reuses) an internal copy of strings, so we can safely push
buf pointers onto the stack.
2022-11-14 18:04:36 +00:00
Justin M. Keyes
e5cb3104d0
docs: fix/remove invalid URLs #20647 2022-10-14 08:01:13 -07:00
Justin M. Keyes
09dffb9db7
docs: various #12823
- increase python line-length limit from 88 => 100.
- gen_help_html: fix bug in "tag" case (tbl_count => tbl_contains)

ref #15632
fix #18215
fix #18479
fix #20527
fix #20532

Co-authored-by: Ben Weedon <ben@weedon.email>
2022-10-09 05:21:52 -07:00
Justin M. Keyes
18afacee1d
feat(docs): format parameters as a list #20485
Problem:
The {foo} parameters listed in `:help api` and similar generated docs,
are intended to be a "list" but they aren't prefixed with a list symbol.
This prevents parsers from understanding the list, which forces
generators like `gen_help_html.lua` to use hard-wrapped/preformatted
layout instead of a soft-wrapped "flow" layout.

Solution:
Modify gen_vimdoc.py to prefix {foo} parameters with a "•" symbol.
2022-10-05 05:15:55 -07:00
Justin M. Keyes
1b60b5ec94 fix(gen_vimdoc.py): handle missing luajit 2022-09-25 14:31:33 +02:00
Christian Clason
ddb762f401
docs(treesitter): clean up and update treesitter.txt (#20142)
* add type annotations to code
* clean up and expand static documentation
* consistent use of tags for static and generated docs
2022-09-14 11:08:31 +02:00
bfredl
c0d6052654 perf(api): allow to use an arena for return values 2022-08-23 18:34:24 +02:00
ii14
d2975d58cb docs: change gen_vimdoc indentation to 4 spaces 2022-08-11 14:25:18 +02:00
bfredl
101fd04ee2
Merge pull request #19409 from bfredl/uiunpack
perf(ui): some ui_client fixes/optimizations before externalized TUI
2022-07-19 13:08:11 +02:00
bfredl
f87c824513 fix(rpc): break nvim_error_event feedback loop between two nvim instances
In case nvim A sends nvim_error_event to nvim B, it would
respond with another nvim_error_event due to unknown
request name. Fix this by adding dummy request handler for now.
2022-07-19 12:38:37 +02:00
Maverun
4e3699d13a fix(docs): remove internal function from docs (nvim__*) 2022-07-19 05:03:22 -04:00
Axis
ece2960f1b
build(gen_vimdoc): remove needless list creation and unused variable (#19079)
build(gen_vimdoc): remove needless list creation
2022-06-25 18:03:02 +08:00
bfredl
612944c586 refactor(api): update vimdoc 2022-06-12 19:45:39 +02:00
Gregory Anders
67cbaf58c4 feat(fs): add vim.fs.parents()
vim.fs.parents() is a Lua iterator that returns the next parent
directory of the given file or directory on each iteration.
2022-05-31 13:04:40 -06:00
dundargoc
b1b5802009
build(gen_vimdoc): eliminate non-constant global variables (#17781) 2022-05-15 11:23:56 +02:00
Dundar Goc
59162584b1 build(gen_vimdoc): print user's doxygen version if it's too old
@theHamsta suggested in
https://github.com/neovim/neovim/pull/18348#discussion_r862594173 to
also print the users doxygen version if the version is too old.
2022-05-02 11:17:06 +02:00
Dundar Goc
649cdc14ba ci(gen_vimdoc): handle edge case when checking doxygen version
When checking the version of the doxygen installed from conda the output
has the following format:

1.9.2 (ee54ebd4f0ad83d9c44f19a459146de64d0ffba2*)

This would cause an error in the "Missing API docs" CI job. This fix
will correctly parse the doxygen version for both stable releases
("1.9.2") as well as the version with the git commit hash attached.
2022-05-02 10:58:40 +02:00
Dundar Goc
5fc251daeb build(gen_vimdoc): abort if doxygen version is too old
There have been a few instances where developers got confused as to why
their generated documentation differs from the one generated by the CI.
More often than not, the reason is that their doxygen version is older
than 1.9.0, which is the current minimum version. Having a simple
version check will help save future developers avoid this problem.
2022-05-01 18:05:12 +02:00
ii14
7502f1cae0
docs(api): more API attributes #18336 2022-04-30 16:16:16 -07:00
Daiki Mizukami
ecc36c3d1c
docs: remove extra whitespaces 2022-03-14 08:16:01 +09:00
Daiki Mizukami
be2def4100
chore(gen_vimdoc): fall back to brief_desc_node when desc_node is empty 2022-03-14 07:53:42 +09:00
Daiki Mizukami
334a16c791
refactor(gen_vimdoc): simplify files in CONFIG 2022-03-14 07:53:42 +09:00
Daiki Mizukami
cf4786ddfa
chore(gen_vimdoc): call delete_lines_below only if the file exists
Previously, `delete_lines_below` would raise `FileNotFoundError` when
adding a new file to `CONFIG` and you had to manually write a file with
help tag of the first section as placeholder. This change relieves you
of that need.
2022-03-14 07:53:41 +09:00
Daiki Mizukami
2d28c40ef9
refactor(gen_vimdoc): detect section_start_token automatically 2022-03-14 07:53:41 +09:00
zeertzjq
80e6f81862 docs(lua): reference runtime/lua/vim/_editor.lua 2022-03-06 22:32:22 +08:00
TJ DeVries
991e472881 feat(lua): add api and lua autocmds 2022-02-27 22:04:55 +01:00
Dundar Göc
03e189d1a1 chore(gen_vimdoc): correct minimum python version 2022-02-05 13:36:27 +01:00
Dundar Göc
de672b6d7a chore(gen_vimdoc): remove duplicate extmark.c entry 2022-02-03 18:56:32 +01:00
shadmansaleh
6d41f65aa4 feat(lua): add vim.keymap
This introduces two new functions `vim.keymap.set` & `vim.keymap.del`

differences compared to regular set_keymap:
- remap is used as opposite of noremap. By default it's true for <Plug> keymaps and false for others.
- rhs can be lua function.
- mode can be a list of modes.
- replace_keycodes option for lua function expr maps. (Default: true)
- handles buffer specific keymaps

Examples:
```lua
vim.keymap.set('n', 'asdf', function() print("real lua function") end)
vim.keymap.set({'n', 'v'}, '<leader>lr', vim.lsp.buf.references, {buffer=true})
vim.keymap.set('n', '<leader>w', "<cmd>w<cr>", {silent = true, buffer = 5 })
vim.keymap.set('i', '<Tab>', function()
  return vim.fn.pumvisible() == 1 and "<C-n>" or "<Tab>"
end, {expr = true})
vim.keymap.set('n', '[%', '<Plug>(MatchitNormalMultiBackward)')

vim.keymap.del('n', 'asdf')
vim.keymap.del({'n', 'i', 'v'}, '<leader>w', {buffer = 5 })
```
2022-01-04 22:31:59 +06:00
Gregory Anders
3fd454bd4a
feat: filetype.lua (#16600)
Adds a new vim.filetype module that provides support for filetype detection in
Lua.
2022-01-04 07:28:29 -07:00
Michael Lingelbach
0746f0021f fix(docgen): add tagfunc.lua 2021-11-18 11:30:09 -07:00
Michael Lingelbach
9d6a475ced
fix(docs): add sync.lua to gen_vimdoc (#16285) 2021-11-11 07:23:52 -07:00
Björn Linse
a60beeb34f refactor(api): break out Vim script functions to its own file 2021-10-29 16:59:53 +02:00