Commit Graph
80 Commits
Author SHA1 Message Date
Hye Sung Jung 14a8b3b98c doc: fix typos [ci skip] #11787 2020-01-30 22:56:34 -08:00
Axel Forsman 2538e61513 Fix shift change callbacks reading bad cursor (#11782)
Sloppy code inherited from Vim caused user scripts to be able
to observe the cursor line in an invalid intermediary state,
due to Neovim change callbacks being unbuffered unlike Vim listeners.

Manifested in Vimscript executed from the callback possibly erroring
when `:call`:ing any function,
due to the implicit range `curwin->w_cursor.lnum,curwin->w_cursor.lnum`
failing validation.

Fixed by deferring the call to `changed_lines()` until after
`curwin->w_cursor.lnum` gets its correct value.
2020-01-30 07:34:34 +01:00
Daniel Hahler 3d1531aee5 API: include invalid buffer/window/tabpage in error message (#11712) 2020-01-14 09:21:10 +01:00
Björn Linse ea4127e9a7 lua: metatable for empty dict value 2020-01-01 19:26:29 +01:00
Björn Linse 440695c296 tree-sitter: implement query functionality and highlighting prototype [skip.lint] 2019-12-22 12:51:46 +01:00
Ashkan Kiani 0e6c6261e1 Fix access on vim.wo (#11517)
* Add more tests for vim.wo
2019-12-07 03:34:02 -08:00
Justin M. Keyes a3b6c2a3dc API: rename nvim_execute_lua => nvim_exec_lua
- We already find ourselves renaming nvim_execute_lua in tests and
  scripts, which suggests "exec" is the verb we actually want.
- Add "exec" verb to `:help dev-api`.
2019-12-02 22:06:42 -08:00
Ashkan Kiani 70b6061666 Add vim.startswith and vim.endswith (#11248) 2019-12-01 05:32:55 -08:00
Ashkan Kiani e6da21d128 Add vim.cmd as an alias for nvim_command (#11446) 2019-12-01 05:28:53 -08:00
Ashkan Kiani edca84cfc9 Return nil instead of NIL for vim.env (#11486) 2019-12-01 05:04:57 -08:00
Björn Linse a76a669ac2 lua: make vim.wo and vim.bo used nested indexing for specified handle
Also missing option should be an error. Options are functionality,
not arbitrary variable names (as for vim.g)
2019-11-26 18:44:36 +01:00
Ashkan Kiani b78fdd7ce5 Merge branch 'master' into lsp-followup 2019-11-24 02:29:23 -08:00
Ashkan Kiani d0d38fc36e Lua: vim.env, vim.{g,v,w,bo,wo} #11442
- Add vim variable meta accessors: vim.env, vim.{g,v,w,bo,wo}
- Redo gen_char_blob to generate multiple blobs instead of just one
  so that multiple Lua modules can be inlined.
- Reorder vim.lua inclusion so that it can use previously defined C
  functions and utility functions like vim.shared and vim.inspect things.
- Inline shared.lua into nvim, but also keep it available in runtime.
2019-11-24 02:28:48 -08:00
Ashkan Kiani b984f613c1 Extend list_extend to take start/finish. 2019-11-20 17:09:21 -08:00
Björn Linse dab40f43b1 Add v:lua.func() vimL syntax for calling lua
Also simplify error messages when calling lua from vimL.
2019-11-16 22:33:21 +01:00
Ashkan Kiani 00dc12c5d8 lua LSP client: initial implementation (#11336)
Mainly configuration and RPC infrastructure can be considered "done". Specific requests and their callbacks will be improved later (and also served by plugins). There are also some TODO:s for the client itself, like incremental updates.

Co-authored by at-tjdevries and at-h-michael, with many review/suggestion contributions.
2019-11-13 21:55:26 +01:00
Justin M. Keyes a0d992785f Lua: Use vim.validate() instead of assert() 2019-11-10 23:43:49 -08:00
Justin M. Keyes 7aa4042d3b Lua: vim.validate() 2019-11-10 23:43:49 -08:00
Hirokazu Hata 678a51b1da Lua: vim.validate()
We often want to do type checking of public function arguments.

- test: Rename utility_function_spec.lua to vim_spec.lua
- .luacov: Map lua module names
2019-11-10 22:50:24 -08:00
Björn Linse d200a818a7 tests: vim.rpcnotify test is flaky 2019-11-10 17:13:53 +01:00
Björn Linse 474d0bcbf7 lua: vim.rpcrequest, vim.rpcnotify, vim.NIL 2019-11-10 13:08:05 +01:00
Justin M. Keyes 9ef16a1628 doc: vim.fn, vim.call(), vim.api [ci skip] 2019-11-06 01:37:50 -08:00
Björn Linse 8ee7c94a92 lua: add vim.fn.{func} for direct access to vimL function
compared to vim.api.|nvim_call_function|, this fixes some typing issues
due to the indirect conversion via the API. float values are preserved
as such (fixes #9389) as well as empty dicts/arrays.

Ref https://github.com/norcalli/nvim.lua for the call syntax
2019-10-27 17:23:17 +01:00
Justin M. Keyes 316c29bbf3 test/pcall_err(): truncate full paths, omit linenr
ref #11271
2019-10-26 02:00:58 -07:00
Hirokazu Hata 996a057fb9 lua/stdlib: adjust some validation messages #11271
close #11271
2019-10-26 00:27:01 -07:00
Björn Linse 9fa850991d tree-sitter: improve and cleanup tests 2019-09-28 17:46:25 +02:00
Björn Linse d5a69eb076 tree-sitter: handle node equality 2019-09-28 17:46:25 +02:00
Björn Linse e0d6228978 tree-sitter: use "range" instead of "point_range" consistently in lua API 2019-09-28 17:46:25 +02:00
Björn Linse 06ee45b9b1 tree-sitter: fix lint, delete "demo" plugin (replaced by functional tests) 2019-09-28 17:46:25 +02:00
Björn Linse 167a1cfdef tree-sitter: improve parser API (shared parser between plugins) 2019-09-28 14:55:43 +02:00
Björn Linse c8f861b739 tree-sitter: rename tree_sitter => treesitter for consistency 2019-09-28 14:55:43 +02:00
Björn Linse 4ea5e63aa8 tree-sitter: add basic testing on ci
build tree-sitter c parser on ci for testing purposes
2019-09-28 14:55:43 +02:00
Justin M. Keyes af946046b9 test: Rename meth_pcall to pcall_err
- Rename `meth_pcall`.
- Make `pcall_err` raise an error if the function does not fail.
- Add `vim.pesc()` to treat a string as literal where a Lua pattern is
  expected.
2019-09-06 17:19:07 -07:00
Björn Linse 7e07efaff4 api: make try_end clean-up after an exception properly. Fixes #10809
Otherwise `force_abort` will cause an emsg() higher on the stack
to be converted to an exception, even though it is outside any
try/catch.
2019-09-02 23:01:16 +02:00
Björn Linse 1f54f68732 lua: minimal UTF-16 support needed for LSP 2019-08-08 20:10:14 +02:00
Björn Linse c0993ed343 lua: support getting UTF-32 and UTF-16 sizes of replaced text 2019-08-06 20:24:36 +02:00
Björn Linse b0e26199ec lua: add {old_byte_size} to on_lines buffer change event 2019-08-06 17:01:47 +02:00
Björn Linse 88938634e7 lua: add vim.in_fast_event() to check if we are in a luv callback 2019-08-05 13:57:24 +02:00
Björn Linse e6d77993d1 lua: do not crash on syntax error in debug.debug() 2019-08-05 13:19:44 +02:00
Björn Linse d3a7bdefb0 lua: immediate-callback safe print() 2019-08-05 13:19:44 +02:00
Daniel Hahler 68c594b10c tests: loop_spec: retry (#10413)
Flaky test (osx):

    [  FAILED  ] ...is/build/neovim/neovim/test/functional/lua/loop_spec.lua @ 23: vim.loop timer
    ...is/build/neovim/neovim/test/functional/lua/loop_spec.lua:56: Expected objects to be the same.
    Passed in:
    (number) 0
    Expected:
    (number) 2
    stack traceback:
            ...is/build/neovim/neovim/test/functional/lua/loop_spec.lua:56: in function <...is/build/neovim/neovim/test/functional/lua/loop_spec.lua:23>

It was bumped from sleeping for 20ms to 50ms in d33aaa0f5f already.
2019-07-04 16:42:10 +02:00
Björn Linse 99f24dfbed make vim.loop == require'luv'
This avoids initializing libluv a second time if a plugin invokes
require'luv'. It is probably not an issue, but better to be safe.
2019-06-30 15:16:32 +02:00
Björn Linse d33aaa0f5f libluv: use luv_set_callback to control callback execution
Disable the use of deferred API functions in a fast lua callback
Correctly display error messages from a fast lua callback
2019-06-30 13:13:08 +02:00
Björn Linse 64cdf9f78a api/lua: add on_detach to nvim_buf_attach 2019-06-15 13:19:12 +02:00
George Zhao c83926cd0a lua: introduce vim.loop (expose libuv event-loop) #10123
Co-authored-by: Andrey Popp <8mayday@gmail.com>

closes #9546
closes #10084
2019-06-10 14:13:18 +02:00
Björn Linse b684bd05b5 lua: docs and tests for vim.schedule 2019-06-05 10:46:22 +02:00
Justin M. Keyes 11a481f711 Merge #9686 'win/Lua: monkey-patch os.getenv()'
fixes #9681
2019-03-16 20:28:52 +01:00
erw7 c9264e6d52 Fix os.getenv of lua on Windows
Change to use os_getenv instead of getenv because environment variable
set by uv_os_setenv can not be get with getenv.
2019-03-07 13:49:02 +09:00
Björn Linse f7b174eb71 tests/lua: test for multiline error messages in lua 2019-01-23 19:34:13 +01:00
Björn Linse 3a84e5be88 lua: expose full interface of vim.inspect and add test
Implement lazy loading for vim.submodule, this would be over-engineering
for inspect only, but we expect to use this solution also for more and
larger modules.
2019-01-14 20:12:57 +01:00