aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua
Commit message (Collapse)AuthorAge
...
* fix(gx): visual selection, expand env varsJustin M. Keyes2023-07-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | --- Rejected experiment: move vim.ui.open() to vim.env.open() Problem: `vim.ui` is where user-interface "providers" live, which can be overridden. It would also be useful to have a "providers" namespace for platform-specific features such as "open", clipboard, python, and the other providers listed in `:help providers`. We could overload `vim.ui` to serve that purpose as the single "providers" namespace, but `vim.ui.nodejs()` for example seems awkward. Solution: `vim.env` currently has too narrow of a purpose. Overload it to also be a namespace for `vim.env.open`. diff --git a/runtime/lua/vim/_meta.lua b/runtime/lua/vim/_meta.lua index 913f1fe20348..17d05ff37595 100644 --- a/runtime/lua/vim/_meta.lua +++ b/runtime/lua/vim/_meta.lua @@ -37,8 +37,28 @@ local options_info = setmetatable({}, { end, }) -vim.env = setmetatable({}, { - __index = function(_, k) +vim.env = setmetatable({ + open = setmetatable({}, { + __call = function(_, uri) + print('xxxxx'..uri) + return true + end, + __tostring = function() + local v = vim.fn.getenv('open') + if v == vim.NIL then + return nil + end + return v + end, + }) + }, + { + __index = function(t, k, ...) + if k == 'open' then + error() + -- vim.print({...}) + -- return rawget(t, k) + end local v = vim.fn.getenv(k) if v == vim.NIL then return nil
* fix(api, lua): make blank lines in a message work properly (#24244)zeertzjq2023-07-04
|
* Merge pull request #24147 from clason/fix/ftpluginzeertzjq2023-06-30
|\ | | | | fix(ftplugin): respect runtimepath ordering
| * test(lua/runtime_spec): add test for ftplugin orderingzeertzjq2023-06-30
| |
* | fix(docs): vimdoc syntax errorsJustin M. Keyes2023-06-25
|/ | | | gen_help_html: truncate parse-error sample text
* test: spellcheck :help (vimdoc) files #24109Justin M. Keyes2023-06-22
| | | | | | | Enforce consistent terminology (defined in `gen_help_html.lua:spell_dict`) for common misspellings. This does not spellcheck English in general (perhaps a future TODO, though it may be noisy).
* fix(vim.json)!: remove global options, "null", "array_mt" #24070Justin M. Keyes2023-06-21
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: - `vim.json` exposes various global options which: - affect all Nvim Lua plugins (especially the LSP client) - are undocumented and untested - can cause confusing problems such as: https://github.com/codota/tabnine-nvim/commit/cc76ae3abe2f129d44b5a8edee2529e0ee0dcf69 - `vim.json` exposes redundant mechanisms: - `vim.json.null` is redundant with `vim.NIL`. - `array_mt` is redundant because Nvim uses a metatable (`vim.empty_dict()`) for empty dict instead, which `vim.json` is configured to use by default (see `as_empty_dict`). Example: ``` :lua vim.print(vim.json.decode('{"bar":[],"foo":{}}')) --> { bar = {}, foo = vim.empty_dict() } ``` Thus we don't need to also decorate empty arrays with `array_mt`. Solution: Remove the functions from the public vim.json interface. Comment-out the implementation code to minimize drift from upstream. TODO: - Expose the options as arguments to `vim.json.new()`
* fix(fs): make `normalize()` work with '/' path (#24047)Evgeni Chasnovski2023-06-18
| | | | | | | Problem: Current implementation of "remove trailing /" doesn't account for the case of literal '/' as path. Solution: Remove trailing / only if it preceded by something else. Co-authored by: notomo <notomo.motono@gmail.com>
* perf(lsp): reduce polling handles for workspace/didChangeWatchedFiles (#23500)Jon Huhn2023-06-14
| | | Co-authored-by: Lewis Russell <lewis6991@gmail.com>
* feat: tostring(vim.version())Justin M. Keyes2023-06-12
| | | | | | | | | | Problem: tostring(vim.version()) returns "table: 0x…". Solution: Modify vim.version() to return a string prerelease instead of a boolean. Fix #23863
* feat(lua): use callable table as iterator in vim.iter (#23957)Mathias Fußenegger2023-06-10
| | | | A table passed to `vim.iter` can be a class instance with a `__call` implementation for the iterator protocol.
* feat(lua): add ringbuffer (#22894)Mathias Fußenegger2023-06-08
| | | https://en.wikipedia.org/wiki/Circular_buffer
* feat(lua): add `vim.system()`Lewis Russell2023-06-07
| | | | | | | | | | | | | | | feat(lua): add vim.system() Problem: Handling system commands in Lua is tedious and error-prone: - vim.fn.jobstart() is vimscript and comes with all limitations attached to typval. - vim.loop.spawn is too low level Solution: Add vim.system(). Partly inspired by Python's subprocess module Does not expose any libuv objects.
* fix: version-range < and <= #23539Gianmaria Bajo2023-06-06
| | | | | | | | | vim.version.range() couldn't parse them correctly. For example, vim.version.range('<0.9.0'):has('0.9.0') returned `true`. fix: range:has() accepts vim.version() So that it's possible to compare a range with: vim.version.range(spec):has(vim.version())
* fix(spell): splice extmarks on :spellrepall (#23929)zeertzjq2023-06-06
|
* feat(lua): rename vim.loop -> vim.uv (#22846)Lewis Russell2023-06-03
|
* fix(colorscheme): try .lua files in 'rtp' before .vim files in 'pp' (#23727)zeertzjq2023-05-23
| | | | | | This ensures that colorschemes in 'rtp' are tried before ones in 'pp', because some colorschemes in 'pp' may not work if not added to 'rtp'. This also match the current documentation better.
* test: don't unnecessarily specify win/buf for `nvim_(get|set)_option_value`Famiu Haque2023-05-22
| | | | `nvim_(get|set)_option_value` pick the current buffer / window by default for buffer-local/window-local (but not global-local) options. So specifying `buf = 0` or `win = 0` in opts is unnecessary for those options. This PR removes those to reduce code clutter.
* refactor(options): deprecate nvim[_buf|_win]_[gs]et_optionLewis Russell2023-05-21
| | | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: famiu <famiuhaque@protonmail.com>
* feat(fs): expose join_paths as `vim.fs.joinpath` (#23685)Christian Clason2023-05-20
| | | This is a small function but used a lot in some plugins.
* build: bundle uncrustifydundargoc2023-05-18
| | | | | | Uncrustify is sensitive to version changes, which causes friction for contributors that doesn't have that exact version. It's also simpler to download and install the correct version than to have bespoke version checking.
* fix(excmd): append original command to error messagezeertzjq2023-05-05
| | | | | | | | | | Revert the change to do_cmdline_cmd() from #5226. This function is used in many places, so making it different from Vim leads to small differences from Vim in the behavior of some functions like execute() and assert_fails(). If DOCMD_VERBOSE really needs to be removed somewhere, a do_cmdline() call without DOCMD_VERBOSE is also shorter than a do_cmdline() call with DOCMD_VERBOSE.
* vim-patch:8.2.4890: inconsistent capitalization in error messageszeertzjq2023-05-05
| | | | | | | | | Problem: Inconsistent capitalization in error messages. Solution: Make capitalization consistent. (Doug Kearns) https://github.com/vim/vim/commit/cf030578b26460643dca4a40e7f2e3bc19c749aa Co-authored-by: Bram Moolenaar <Bram@vim.org>
* fix(heredoc): allow missing end marker for scriptszeertzjq2023-04-29
| | | | Also do not crash when getting heredoc fails.
* Merge pull request #23216 from bfredl/lpegbfredl2023-04-27
|\ | | | | refactor(build): include lpeg as a library
| * refactor(build): include lpeg as a librarybfredl2023-04-27
| |
* | test: fix dependencies between test cases (#23343)zeertzjq2023-04-27
|/ | | Discovered using --shuffle argument of busted.
* test: move vim.iter tests to separate fileGregory Anders2023-04-24
|
* refactor(iter): use metatable as packed table tag (#23254)Gregory Anders2023-04-21
| | | | | This is a more robust method for tagging a packed table as it completely eliminates the possibility of mistaking an actual table key as the packed table tag.
* fix(lua): vim.split may trim inner empty itemsJustin M. Keyes2023-04-21
| | | | | | | | | | Problem: `vim.split('a:::', ':', {trimempty=true})` trims inner empty items. Regression from 9c49c1047079427ff0a2356cb37302934845108e Solution: Set `empty_start=false` when first non-empty item is found. close #23212
* fix(iter): remove special case totable for map-like tablesGregory Anders2023-04-19
| | | | | | | | | | | | | | | | | | | | | | | This was originally meant as a convenience but prevents possible functionality. For example: -- Get the keys of the table with even values local t = { a = 1, b = 2, c = 3, d = 4 } vim.iter(t):map(function(k, v) if v % 2 == 0 then return k end end):totable() The example above would not work, because the map() function returns only a single value, and cannot be converted back into a table (there are many such examples like this). Instead, to convert an iterator into a map-like table, users can use fold(): vim.iter(t):fold({}, function(t, k, v) t[k] = v return t end)
* fix(iter): add tag to packed tableGregory Anders2023-04-19
| | | | | | | | | | | | | | | If pack() is called with a single value, it does not create a table; it simply returns the value it is passed. When unpack is called with a table argument, it interprets that table as a list of values that were packed together into a table. This causes a problem when the single value being packed is _itself_ a table. pack() will not place it into another table, but unpack() sees the table argument and tries to unpack it. To fix this, we add a simple "tag" to packed table values so that unpack() only attempts to unpack tables that have this tag. Other tables are left alone. The tag is simply the length of the table.
* feat(lua): add vim.iter (#23029)Gregory Anders2023-04-17
| | | | | 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.
* fix(watchfiles): skip Created events when poll starts (#23139)Jon Huhn2023-04-17
|
* feat(diagnostic): specify diagnostic virtual text prefix as a functionIsak Samsten2023-04-17
| | | | - vim.diagnostic.config() now accepts a function for the virtual_text.prefix option, which allows for rendering e.g., diagnostic severities differently.
* vim-patch:8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level (#23131)zeertzjq2023-04-16
| | | | | | | | Problem: Vim9: exception in ISN_INSTR caught at wrong level. Solution: Set the starting trylevel in exec_instructions(). (closes vim/vim#8214) https://github.com/vim/vim/commit/ff65288aa89dcd50760ad942d58baff70c6e93e6 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* fix(lua): inspect_pos respect bufnr when get syntax info (#23098)Raphael2023-04-16
|
* vim-patch:8.2.3783: confusing error for using a variable as a functionzeertzjq2023-04-16
| | | | | | | | | | Problem: Confusing error for using a variable as a function. Solution: If a function is not found but there is a variable, give a more useful error. (issue vim/vim#9310) https://github.com/vim/vim/commit/2ef9156b4284e4a52613c36e3d4667245273a28d Co-authored-by: Bram Moolenaar <Bram@vim.org>
* feat(lua)!: add stricter vim.tbl_islist() and rename old one to ↵NAKAI Tsuyoshi2023-04-14
| | | | | | | | | | | | vim.tbl_isarray() (#16440) feat(lua)!: add stricter vim.tbl_islist(), rename vim.tbl_isarray() Problem: `vim.tbl_islist` allows gaps in tables with integer keys ("arrays"). Solution: Rename `vim.tbl_islist` to `vim.tbl_isarray`, add new `vim.tbl.islist` that checks for consecutive integer keys that start from 1.
* feat(lua): vim.tbl_contains supports general tables and predicates (#23040)Christian Clason2023-04-14
| | | | | | | | | | | | * feat(lua): vim.tbl_contains supports general tables and predicates Problem: `vim.tbl_contains` only works for list-like tables (integer keys without gaps) and primitive values (in particular, not for nested tables). Solution: Rename `vim.tbl_contains` to `vim.list_contains` and add new `vim.tbl_contains` that works for general tables and optionally allows `value` to be a predicate function that is checked for every key.
* fix(loader): reset hashes when running the loaderLewis Russell2023-04-13
|
* feat(lua): vim.region accepts getpos() arg (#22635)NAKAI Tsuyoshi2023-04-11
|
* feat(lua): allow vim.F.if_nil to take multiple arguments (#22903)Gregory Anders2023-04-07
| | | | | | | | | | | | The first argument which is non-nil is returned. This is useful when using nested default values (e.g. in the EditorConfig plugin). Before: local enable = vim.F.if_nil(vim.b.editorconfig, vim.F.if_nil(vim.g.editorconfig, true)) After: local enable = vim.F.if_nil(vim.b.editorconfig, vim.g.editorconfig, true)
* test(lua/diagnostic_spec): remove unnecessary after_each()zeertzjq2023-04-07
| | | There is already a call to clear() in before_each(), so after_each() isn't necessary.
* test(vim.fs.normalize): enable test on Windowsdundargoc2023-04-05
|
* refactor: rename local API alias from a to apiLewis Russell2023-04-05
| | | | | | | | Problem: Codebase inconsistently binds vim.api onto a or api. Solution: Use api everywhere. a as an identifier is too short to have at the module level.
* test: replace lfs with luv and vim.fsdundargoc2023-04-04
| | | | | | test: replace lfs with luv luv already pretty much does everything lfs does, so this duplication of dependencies isn't needed.
* refactor(lua): get all marks instead of iterating over namespacesLuuk van Baal2023-04-02
| | | | | | Inspector now also includes highlights set in anonymous namespaces. Close #22732
* refactor: remove char_u (#22829)dundargoc2023-04-02
| | | Closes https://github.com/neovim/neovim/issues/459
* feat: allow function passed to defaulttable to take an argument (#22839)Gregory Anders2023-04-01
| | | | Pass the value of the key being accessed to the create function, to allow users to dynamically generate default values.