aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/vim_spec.lua
Commit message (Collapse)AuthorAge
* build: make generated source files reproducible #21586Arnout Engelen2023-01-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Build is not reproducible, because generated source files (.c/.h/) are not deterministic, mostly because Lua pairs() is unordered by design (for security). https://github.com/LuaJIT/LuaJIT/issues/626#issuecomment-707005671 https://www.lua.org/manual/5.1/manual.html#pdf-next > The order in which the indices are enumerated is not specified [...] > >> The hardening of the VM deliberately randomizes string hashes. This in >> turn randomizes the iteration order of tables with string keys. Solution: - Update the code generation scripts to be deterministic. - That is only a partial solution: the exported function (funcs_metadata.generated.h) and ui event (ui_events_metadata.generated.h) metadata have some mpack'ed tables, which are not serialized deterministically. - As a workaround, introduce `PRG_GEN_LUA` cmake setting, so you can inject a modified build of luajit (with LUAJIT_SECURITY_PRN=0) that preserves table order. - Longer-term we should change the mpack'ed data structure so it no longer uses tables keyed by strings. Closes #20124 Co-Authored-By: dundargoc <gocdundar@gmail.com> Co-Authored-By: Arnout Engelen <arnout@bzzt.net>
* test: avoid noise in NVIM_LOG_FILEJustin M. Keyes2023-01-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Tests that _intentionally_ fail certain conditions cause noise in $NVIM_LOG_FILE: $NVIM_LOG_FILE: /home/runner/work/neovim/neovim/build/.nvimlog (last 100 lines) WRN 2023-01-16T18:26:27.673 T599.7799.0 unsubscribe:519: RPC: ch 1: tried to unsubscribe unknown event 'doesnotexist' WRN 2023-01-16T18:29:00.557 ?.11151 server_start:163: Failed to start server: no such file or directory: /X/X/X/... WRN 2023-01-16T18:33:07.269 127.0.0.1:12345 server_start:163: Failed to start server: address already in use: 127.0.0.1 ... -- Output to stderr: module 'vim.shared' not found: no field package.preload['vim.shared'] no file './vim/shared.lua' no file '/home/runner/nvim-deps/usr/share/lua/5.1/vim/shared.lua' no file '/home/runner/nvim-deps/usr/share/lua/5.1/vim/shared/init.lua' no file '/home/runner/nvim-deps/usr/lib/lua/5.1/vim/shared.lua' no file '/home/runner/nvim-deps/usr/lib/lua/5.1/vim/shared/init.lua' no file './vim/shared.so' ... E970: Failed to initialize builtin lua modules Solution: - Log to a private $NVIM_LOG_FILE in tests that intentionally fail and cause ERR log messages. - Assert that the expected messages are actually logged.
* fix(lua): always return nil values in vim.tbl_get when no resultsWilliam Boman2022-12-15
| | | | | | | | | | | | | | | | | | | While `return` and `return nil` are for most intents and purposes identical, there are situations where they're not. For example, calculating the amount of values via the `select()` function will yield varying results: ```lua local function nothing() return end local function null() return nil end select('#', nothing()) -- 0 select('#', null()) -- 1 ``` `vim.tbl_get` currently returns both nil and no results, which makes it unreliable to use in certain situations without manually accounting for these discrepancies.
* fix: vim.opt_local:append ignoring global option value (#21382)Phelipe Teles2022-12-12
| | | Closes https://github.com/neovim/neovim/issues/18225
* feat(aucmd_win): allow crazy things with hidden buffers (#21250)zeertzjq2022-12-02
| | | | Problem: Crash when doing crazy things with hidden buffers. Solution: Dynamically allocate the list of autocommand windows.
* docs: fix typos (#21196)dundargoc2022-11-29
| | | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: Raphael <glephunter@gmail.com> Co-authored-by: Gregory Anders <greg@gpanders.com>
* fix(lua): make `vim.deepcopy` work with `vim.NIL`Max2022-11-14
| | | | | | | | style: changed double quotes to single quotes feat: add tests fix tests
* feat(test): add Lua forms for API methods (#20152)Lewis Russell2022-11-14
|
* fix(lua): pesc, tbl_islist result types #20751NAKAI Tsuyoshi2022-10-24
| | | | | | | | | | | | Problem: - pesc() returns multiple results, it should return a single result. - tbl_islist() returns non-boolean in some branches. - Docstring: @generic must be declared first Solution: Constrain docstring annotations. Fix return types. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* docs: fix typos (#20724)dundargoc2022-10-23
| | | Co-authored-by: Marco Lehmann <m99@posteo.de>
* fix(lua): on_yank error with blockwise multibyte region #20162Daniel Zhang2022-10-14
| | | | | Prevent out of range error when calling `str_byteindex`. Use `vim.str_byteindex(bufline, #bufline)` to cacluate utf length of `bufline`. fix #20161
* fix(lua): assert failure with vim.regex() error inside :silent! (#20555)RZia2022-10-10
| | | Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* docs: fix typos (#20394)dundargoc2022-09-30
| | | | | Co-authored-by: Raphael <glephunter@gmail.com> Co-authored-by: smjonas <jonas.strittmatter@gmx.de> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* test: add a Lua test for #17501 (#20392)zeertzjq2022-09-29
|
* Merge pull request #20103 from lewis6991/refactor/vim_optLewis Russell2022-09-22
|\
| * refactor(vim.opt): unify vim.bo/wo buildingLewis Russell2022-09-09
| |
* | fix(eval)!: make Lua Funcref work as method and in substitute() (#20217)zeertzjq2022-09-16
| | | | | | | | | | | | | | | | | | | | | | | | BREAKING CHANGE: When using a Funcref converted from a Lua function as a method in Vim script, the result of the base expression is now passed as the first argument instead of being ignored. vim-patch:8.2.5117: crash when calling a Lua callback from a :def function Problem: Crash when calling a Lua callback from a :def function. (Bohdan Makohin) Solution: Handle FC_CFUNC in call_user_func_check(). (closes vim/vim#10587) https://github.com/vim/vim/commit/7d149f899d423b7bf2b90d7b11ebe3e560c462b9
* | fix(lua): make vim.str_utfindex and vim.str_byteindex handle NUL bytesbfredl2022-09-13
|/ | | | fixes #16290
* Use weak tables in tree-sitter code (#17117)Thomas Vigouroux2022-09-07
| | | | | | feat(treesitter): use weak tables when possible Also add the defaulttable function to create a table whose values are created when a key is missing.
* feat(lua): add vim.iconv (#18286)Lewis Russell2022-08-24
| | | Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* test: improve mapping tests and docs (#19619)zeertzjq2022-08-02
|
* feat(lua): allow vim.cmd to be indexed (#19238)Lewis Russell2022-07-20
|
* fix(lua): make it possible to cancel vim.wait() with Ctrl-C (#19217)JP2022-07-19
|
* Merge pull request #19041 from lewis6991/globallocalbfredl2022-06-25
|\ | | | | fix(api): nvim_set_option_value for global-local options
| * fix(api): nvim_set_option_value for global-local optionsLewis Russell2022-06-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | global-local window options need to be handled specially. When `win` is given but `scope` is not, then we want to set the local version of the option but not the global one, therefore we need to force `scope='local'`. Note this does not apply to window-local only options (e.g. 'number') Example: nvim_set_option_value('scrolloff', 10, {}) -- global-local window option; set global value nvim_set_option_value('scrolloff', 20, {win=0}) -- global-local window option; set local value nvim_set_option_value('number', true, {}) -- local window option is now equivalent to: nvim_set_option_value('scrolloff', 10, {}) nvim_set_option_value('scrolloff', 20, {win=0, scope='local'}) -- changed from before nvim_set_option_value('number', true, {win=0}) -- unchanged from before Only the global-local option with a `win` provided gets forced to local scope.
* | fix(api): check error after getting win/buf handle (#19052)Gregory Anders2022-06-22
|/
* refactor: use nvim_{get,set}_option_value for vim.{b,w}oGregory Anders2022-06-20
| | | | | | | | | | | | | | | | | | | `nvim_get_option_value` and `nvim_set_option_value` better handle unsetting local options. For instance, this is currently not possible: vim.bo.tagfunc = nil This does not work because 'tagfunc' is marked as "local to buffer" and does not have a fallback global option. However, using :setlocal *does* work as expected :setlocal tagfunc= `nvim_set_option_value` behaves more like :set and :setlocal (by design), so using these as the underlying API functions beneath vim.bo and vim.wo makes those two tables act more like :setlocal. Note that vim.o *already* uses `nvim_set_option_value` under the hood, so that vim.o behaves like :set.
* fix(lua): clear got_int when calling vim.on_key() callback (#18979)zeertzjq2022-06-16
|
* fix(tests): check for EOF on exit of nvim properlybfredl2022-06-13
|
* fixup: update test/functional/lua/vim_spec.luaLewis Russell2022-05-17
| | | Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* feat(lua): allow some viml functions to run in fastLewis Russell2022-05-17
| | | | | This change adds the necessary plumbing to annotate functions in funcs.c as being allowed in run in luv fast events.
* fix(shared): avoid indexing unindexable values in vim.tbl_get() (#18337)William Boman2022-05-01
|
* test: correct order of arguments to eq() and neq()zeertzjq2022-04-26
|
* fix(lua): don't mutate opts parameter of vim.keymap.del (#18227)Andrey Mishchenko2022-04-23
| | | | | | `vim.keymap.del` takes an `opts` parameter that lets caller refer to and delete buffer-local mappings. For some reason the implementation of `vim.keymap.del` mutates the table that is passed in, setting `opts.buffer` to `nil`. This is wrong and also undocumented.
* feat: add vim.tbl_get (#17831)Michael Lingelbach2022-03-24
| | | | | | vim.tbl_get takes a table with subsequent string arguments (variadic) that index into the table. If the value pointed to by the set of keys exists, the function returns the value. If the set of keys does not exist, the function returns nil.
* fix(api, lua): return NIL on failure to find converted function (#17779)zeertzjq2022-03-20
|
* feat(api, lua): support converting nested Funcref back to LuaRef (#17749)zeertzjq2022-03-17
|
* fix(lua): don't use nlua_error when exiting earlybfredl2022-03-07
| | | | Screen state is not initialized yet. Print directly to stderr instead.
* test(sr.ht): skip luamod-dev test which crashes nvimJames McCoy2022-03-06
|
* refactor(lua): reorganize builtin modules, phase 1bfredl2022-03-03
|
* fix: autoload variables not loaded with vim.g & nvim_get_varshadmansaleh2022-02-13
|
* fix(api/nvim_win_call): share common win_execute logicSean Dewar2022-02-03
| | | | | | | | | | We have to be sure that the bugs fixed in the previous patches also apply to nvim_win_call. Checking v8.1.2124 and v8.2.4026 is especially important as these patches were only applied to win_execute, but nvim_win_call is also affected by the same bugs. A lot of win_execute's logic can be shared with nvim_win_call, so factor it out into a common macro to reduce the possibility of this happening again.
* vim-patch:8.2.4028: ml_get error with :doautoall and Visual areaSean Dewar2022-02-03
| | | | | | | | Problem: ml_get error with :doautoall and Visual area. (Sean Dewar) Solution: Disable Visual mode while executing autocommands. https://github.com/vim/vim/commit/cb1956d6f2aece8ad93e19e5d4c7e0b5e405f056 This should also fix #16937 for nvim_buf_call, so test for it.
* feat(api, lua): more conversions between LuaRef and Vim Funcrefzeertzjq2022-01-13
|
* feat(lua): add notify_once() (#16956)Gregory Anders2022-01-06
| | | Like vim.notify(), but only displays the notification once.
* feat(lua): add vim.keymapshadmansaleh2022-01-04
| | | | | | | | | | | | | | | | | | | | | | | | | 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 }) ```
* feat(lua): add support for multiple optional types in vim.validate (#16864)Shadman2022-01-01
|
* perf: pre-compile embedded Lua source into bytecode (#16631)Gregory Anders2021-12-16
| | | | | | The Lua modules that make up vim.lua are embedded as raw source files into the nvim binary. These sources are loaded by the Lua runtime on startuptime. We can pre-compile these sources into Lua bytecode before embedding them into the binary, which minimizes the size of the binary and improves startuptime.
* feat(api): add nvim_get_option_valueGregory Anders2021-12-04
|
* fix(lua): fix vim.deepcopy for metatables & cycled tables (#16435)Shadman2021-11-26
| | | | | vim.deepcopy previously didn't retain metatables in copies and caused stackoverflow on recursive tables/cycled tables this fixes these issues