Commit Graph

54 Commits

Author SHA1 Message Date
9e86f473e0 feat(lua): vim.region accepts getpos() arg (#22635) 2023-04-11 16:28:46 +02:00
743860de40 test: replace lfs with luv and vim.fs
test: replace lfs with luv

luv already pretty much does everything lfs does, so this duplication
of dependencies isn't needed.
2023-04-04 21:59:06 +02:00
2257ade3dc feat(lua): add vim.loader
feat: new faster lua loader using byte-compilation
2023-03-26 11:42:15 +01:00
4863ca6b89 test: use exec_capture() in more places (#22787)
Problem:
Using `meths.exec2("code", { output = true })` is too verbose.

Solution:
Use exec_capture() in more places.
2023-03-26 10:49:32 +08:00
fe9cbcb3a5 feat(api): nvim_exec2(), deprecate nvim_exec() #19032
Problem:
The signature of nvim_exec() is not extensible per ":help api-contract".

Solution:
Introduce nvim_exec2() and deprecate nvim_exec().
2023-03-25 09:58:48 -07:00
42876ddc7a docs: more details about vim.region (#21116) 2023-03-25 16:28:59 +08:00
210120dde8 fix(lua): vim.deprecate() shows ":help deprecated" #22677
Problem:
vim.deprecate() shows ":help deprecated" for third-party plugins. ":help
deprecated" only describes deprecations in Nvim, and is unrelated to any
3rd party deprecations.

Solution:
If `plugin` is specified, don't show  ":help deprecated".

fix #22235
2023-03-15 05:56:13 -07:00
673d2b52fa refactor!: rename vim.pretty_print => vim.print
Problem:
The function name `vim.pretty_print`:
1. is verbose, which partially defeats its purpose as sugar
2. does not draw from existing precedent or any sort of convention
   (except external projects like penlight or python?), which reduces
   discoverability, and degrades signaling about best practices.

Solution:
- Rename to `vim.print`.
- Change the behavior so that
  1. strings are printed without quotes
  2. each arg is printed on its own line
  3. tables are indented with 2 instead of 4 spaces
- Example:
  :lua ='a', 'b', 42, {a=3}
  a
  b
  42
  {
    a = 3
  }

Comparison of alternatives:
- `vim.print`:
  - pro: consistent with Lua's `print()`
  - pro: aligns with potential `nvim_print` API function which will
    replace nvim_echo, nvim_notify, etc.
  - con: behaves differently than Lua's `print()`, slightly misleading?
- `vim.echo`:
  - pro: `:echo` has similar "pretty print" behavior.
  - con: inconsistent with Lua idioms.
- `vim.p`:
  - pro: very short, fits with `vim.o`, etc.
  - con: not as discoverable as "echo"
  - con: less opportunity for `local p = vim.p` because of potential shadowing.
2023-03-13 01:25:09 +01:00
79571b92ce feat(lua): omnifunc for builting lua interpreter
also make implicit submodules "uri" and "_inspector" work with completion

this is needed for `:lua=vim.uri_<tab>` wildmenu completion
to work even before uri or _inspector functions are used.
2023-03-06 23:12:21 +01:00
ac69ba5fa0 feat(lsp): implement workspace/didChangeWatchedFiles (#22405) 2023-03-05 07:52:27 +01:00
aa16590999 docs(lua): number → integer (#22517) 2023-03-04 13:07:39 +00:00
f0f27e9aef Revert "feat(lsp): implement workspace/didChangeWatchedFiles (#21293)"
This reverts commit 5732aa706c.

Causes editor to freeze in projects with many watcher registrations
2023-02-25 11:17:28 +01:00
5732aa706c feat(lsp): implement workspace/didChangeWatchedFiles (#21293) 2023-02-25 10:07:18 +01:00
c5b34fa554 refactor: move init_default_autocmds to lua
The original motivation for this change came from developping
https://github.com/neovim/neovim/pull/22159, which will require adding
more autocommand creation to Neovim's startup sequence.

This change requires lightly editing a test that expected no autocommand
to have been created from lua.
2023-02-11 14:02:17 +01:00
dfb840970c docs(lua): fix treesitter parsing errors 2023-01-01 15:05:21 +01:00
0b05bd87c0 docs(gen): support language annotation in docstrings 2022-12-02 16:05:00 +01:00
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
850d7146fc fix(paste): feed keys as typed in cmdline mode (#20959) 2022-11-06 12:43:05 +08:00
81986a7349 fix(lua): on_yank error with blockwise multibyte region #20162
Prevent out of range error when calling `str_byteindex`.
Use `vim.str_byteindex(bufline, #bufline)` to cacluate utf length of `bufline`.
fix #20161
2022-10-14 02:12:46 -07:00
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
8c2226fc30 fix(lua): properly configure luacheck and remove local vim = ... lines (#20551) 2022-10-09 12:40:56 +02:00
548a4e2587 docs(docstrings): fix runtime type annotations 2022-10-05 15:25:03 +02:00
63be765182 fix(docs): invalid :help links #20345
Fix those naughty single quotes.

closes #20159
2022-09-25 16:58:27 -07:00
b8dcbcc732 docs: fix typos (#19588)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: notomo <notomo.motono@gmail.com>
2022-08-03 09:47:16 +08:00
559ef3e903 feat(lua): allow vim.cmd to be indexed (#19238) 2022-07-20 12:29:24 +01:00
9169fb8f07 fix(lua): double entries in :lua completion #19410
`:lua vim.ls<tab>` would list `lsp` twice.
2022-07-17 15:40:18 -07:00
eb9b93b5e0 feat(defaults): mouse=nvi #19290
Problem:
Since right-click can now show a popup menu, we can provide messaging to
guide users who expect 'mouse' to be disabled by default. So 'mouse' can
now be enabled by default.

Solution:
Do it.
Closes #15521
2022-07-17 04:14:04 -07:00
aa4f9c5341 refactor(lua): reformat with stylua 0.14.0 (#19264)
* reformat Lua runtime to make lint CI pass
* reduce max line length to 100
2022-07-07 18:27:18 +02:00
0e8186bdd8 fix(lua): highlight.on_yank can close timer in twice #18976
Steps to reproduce:

1. setting `vim.highlight.on_yank`
   ```
   vim.api.nvim_create_autocmd({ "TextYankPost" }, {
     pattern = { "*" },
     callback = function()
       vim.highlight.on_yank({ timeout = 200 })
     end,
   })
   ```
2. repeat typing `yeye` ...
3. causes the following error.
   ```
   Error executing vim.schedule lua callback: vim/_editor.lua:0: handle 0x01e96970 is already closing
   stack traceback:
           [C]: in function 'close'
           vim/_editor.lua: in function ''
           vim/_editor.lua: in function <vim/_editor.lua:0>
   ```

📝 Test result before fix:

    [----------] Global test environment setup.
    [----------] Running tests from test/functional/lua/highlight_spec.lua
    [ RUN      ] vim.highlight.on_yank does not show errors even if buffer is wiped before timeout: 15.07 ms OK
    [ RUN      ] vim.highlight.on_yank does not show errors even if executed between timeout and clearing highlight: 15.07 ms ERR
    test/helpers.lua:73: Expected objects to be the same.
    Passed in:
    (string) 'Error executing vim.schedule lua callback: vim/_editor.lua:0: handle 0x02025260 is already closing
    stack traceback:
            [C]: in function 'close'
            vim/_editor.lua: in function ''
            vim/_editor.lua: in function <vim/_editor.lua:0>'
    Expected:
    (string) ''
2022-06-15 19:39:55 -07:00
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
e6652821bd refactor(checkhealth)!: rename to vim.health, move logic to Lua #18720
- Complete function:
  There was lots of unnecessary C code for the complete function, therefore
  moving it to Lua and use all the plumbing we have in place to retrieve the
  results.
- Moving the module:
  It's important we keep nvim lua modules name spaced, avoids conflict with
  plugins, luarocks, etc.
2022-05-31 11:10:18 -07:00
8a39032fdd Merge pull request #18554 from kevinhwang91/perf-timerstart
perf(_editor): no need to stop inside vim.defer_fn
2022-05-17 18:59:48 +02:00
e501e4ed4b feat(lua): add traceback to vim.deprecate #18575 2022-05-15 18:07:36 -07:00
a33caf9b45 perf(_editor): no need to stop inside vim.defer_fn
uv_run:
1. remove timer handle from heap
2. will start again if repeat is not 0
2022-05-13 14:16:47 +08:00
2bbd588e73 feat(lua): vim.cmd() with kwargs acts like nvim_cmd() #18523 2022-05-12 06:34:38 -07:00
aefdc6783c chore: format runtime with stylua 2022-05-09 16:31:55 +02:00
70e2c5d10d feat(lsp): add logging level "OFF" (#18379) 2022-05-03 08:49:23 -06:00
73741e9486 feat(lua): vim.deprecate() #18320
This is primarily intended to act as documentation for the developer so
they know exactly when and what to remove. This will help prevent the
situation of deprecated code lingering for far too long as developers
don't have to worry if a function is safe to remove.
2022-05-03 06:42:41 -07:00
813ecdac79 fix(paste): ignore mappings in Cmdline mode (#18114) 2022-04-17 08:11:53 +08:00
e263afc0e9 fix(paste): escape control characters in Cmdline mode 2022-03-15 18:15:18 +08:00
a6eafc77ce fix(paste): deal with trailing new line in chunk 2022-03-15 18:15:18 +08:00
fcc6f66cf2 fix(paste): avoid edges cases caused by empty chunk 2022-03-15 18:15:18 +08:00
21ba2d81a8 refactor(paste): do not print dots in cmdline mode 2022-03-15 18:15:18 +08:00
bfb7754442 fix(paste): deal with eol and eof in Visual mode 2022-03-15 18:15:18 +08:00
2601e0873f fix(paste): don't move cursor past the end of pasted text in Normal mode 2022-03-15 18:15:18 +08:00
9b1e1fbc9f fix(paste): use getcmdtype() to determine whether in cmdline mode 2022-03-15 18:15:18 +08:00
1dbf8675c7 fix(remote): respect silent in error reporting 2022-03-11 11:16:46 -05:00
29c3632285 fix(remote): report on missing wait commands, typecheck lua results
Clean up lint errors, too
2022-03-11 11:16:46 -05:00
039e94f491 test(remote): add tests for --remote
This also fixes a fair number of issues found in running the tests
2022-03-11 11:16:46 -05:00
5862176764 feat(remote): add basic --remote support
This is starting from @geekodour's work at
https://github.com/neovim/neovim/pull/8326
2022-03-11 11:16:46 -05:00