aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua
Commit message (Collapse)AuthorAge
...
* | feat(lua): update `vim._with` to allow more granular option contextsEvgeni Chasnovski2024-06-24
| | | | | | | | | | | | | | | | | | | | | | Problem: with a single `context.options` there is no way for user to force which scope (local, global, both) is being temporarily set and later restored. Solution: replace single `options` context with `bo`, `go`, `wo`, and `o`. Naming and implementation follows how options can be set directly with `vim.*` (like `vim.bo`, etc.). Options are set for possible target `win` or `buf` context.
* | test(lua): cover `vim._with()` with testsEvgeni Chasnovski2024-06-24
|/ | | | | | | | | | | | Problem: `vim._with()` has many different use cases which are not covered with tests. Solution: cover with tests. Some (many) test cases are intentionally marked as "pending" because they cover cases which don't work as expected at the moment (and fixing them requires specific knowledge of C codebase). Use them as a reference for future fixes. Also some of "can be nested" tests currently might pass only because the tested context doesn't work.
* test: fix vim.deprecate testsLewis Russell2024-06-12
|
* fix(vim.wo): never allow non-zero bufnrLewis Russell2024-06-12
|
* fix(glob): handle overlapping `{}` condition elements #29236Jon Huhn2024-06-10
| | | | | | | | | | | | | | | | | | | | | | | | This change fixes an issue where glob patterns like `{a,ab}` would not match `ab` because the first option `a` matches, then the end of the string is expected but `b` is found, and LPeg does not backtrack to try the next option `ab` which would match. The fix here is to also append the rest of the pattern to the generated LPeg pattern for each option. This changes a glob `{a,ab}` from being parsed as ("a" or "ab") "end of string" to ("a" "end of string" or "ab" "end of string") Here, matching against `ab` would try the first option, fail to match, then proceed to the next option, and match. The sacrifice this change makes is dropping support for nested `{}` conditions, which VSCode doesn't seem to support or test AFAICT. Fixes #28931 Co-authored-by: Sergey Slipchenko <faergeek@gmail.com>
* feat(lua): add `vim._with`dundargoc2024-06-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's a function to perform operations in their own sealed context, similar to pythons `with`. This helps ease operations where you need to perform an operation in a specific context, and then restore the context. Marked as private for now as it's not ready for public use. The current plan is to start using this internally so we can discover and fix any problems. Once this is ready to be exposed it will be renamed to `vim.with`. Usage: ```lua local ret = vim._with({context = val}, function() return "hello" end) ``` , where `context` is any combination of: - `buf` - `emsg_silent` - `hide` - `horizontal` - `keepalt` - `keepjumps` - `keepmarks` - `keeppatterns` - `lockmarks` - `noautocmd` - `options` - `sandbox` - `silent` - `unsilent` - `win` (except for `win` and `buf` which can't be used at the same time). This list will most likely be expanded in the future. Work on https://github.com/neovim/neovim/issues/19832. Co-authored-by: Lewis Russell <lewis6991@gmail.com>
* feat: get/set namespace properties #28728altermo2024-06-07
| | | | ref https://github.com/neovim/neovim/pull/28432 ref https://github.com/neovim/neovim/issues/28469
* fix(lua): don't clamp -1 or v:maxcol in vim.highlight.range() (#29203)zeertzjq2024-06-05
|
* fix(diagnostic): fix float scope filtering (#29134)Andre Toerien2024-06-04
|
* feat(ftplugin): change 'commentstring' to `// %s` for C/C++ (#29085)Soham Shanbhag2024-06-03
| | | | | | | | | Problem: The default commentstring for C/C++ can lead to invalid code when commenting and does not match the Nvim codebase. Solution: Change commentstring to `// %s` as used by Neovim. Also set all commentstrings that derive from the default C string explicitly (and correctly).
* test: add a test for #29119zeertzjq2024-06-02
|
* feat(defaults): use vim.diagnostic.jump() for default mappings (#29066)Gregory Anders2024-05-28
| | | | This allows the mappings to work with a count and also enables new ]D and [D mappings to go to the last/first diagnostic in the buffer.
* Merge pull request #27339 from MariaSolOs/completionGregory Anders2024-05-28
|\ | | | | feat(lsp): completion side effects
| * feat(snippet): add default keymaps during snippet sessionMaria José Solano2024-05-28
| |
* | feat(diagnostic): add vim.diagnostic.jump() (#26745)Gregory Anders2024-05-28
| | | | | | | | | | | | | | | | | | | | | | | | Deprecate vim.diagnostic.goto_prev() and vim.diagnostic.goto_next() in favor of a unified vim.diagnostic.jump() interface. We cannot name the function "goto()" because some of our tooling (luacheck and stylua) fail to parse it, presumably because "goto" is a keyword in newer versions of Lua. vim.diagnostic.jump() also allows moving to a specific diagnostic and moving by multiple diagnostics at a time (useful for creating mappings that use v:count).
* | fix(ui): flush ext_cmdline events before doing cmdpreview #27950luukvbaal2024-05-28
| | | | | | | | Problem: Unable to update the screen for external cmdline during cmdpreview. Solution: Flush the cmdline UI before cmdpreview state.
* | fix(runtime): source c ftplugin properly for cpp on Windows (#29053)zeertzjq2024-05-28
| | | | | | | | | | | | | | | | On Windows, '{' is currently not treated as a wildcard char, so another wildcard char is needed for the pattern to be treated as a wildcard. It may be worth trying to make '{' always a wildcard char in the future, but that'll be a bit harder as it'll be necessary to make sure '{' is escaped at various places.
* | perf: add fast path to vim.validate (#28977)Gregory Anders2024-05-27
| | | | | | | | | | | | For many small/simple functions (like those found in shared.lua), the runtime of vim.validate can far exceed the runtime of the function itself. Add an "overload" to vim.validate that uses a simple assertion pattern, rather than parsing a full "validation spec".
* | refactor(lua): rewrite vim.highlight.range() (#28986)zeertzjq2024-05-25
|/ | | | - Use getregionpos(). - Use a single extmark for non-blockwise selection.
* fix(fs): make vim.fs.root work for relative paths and unnamed buffers (#28964)Gregory Anders2024-05-24
| | | | If a buffer does not have a backing file then fall back to the current working directory.
* fix: change deprecation presentationdundargoc2024-05-24
| | | | | | | | | | | | | | Deprecation with vim.deprecate is currently too noisy. Show the following warning instead: [function] is deprecated. Run ":checkhealth vim.deprecated" for more information. The important part is that the full message needs to be short enough to fit in one line in order to not trigger the "Press ENTER or type command to continue" prompt. The full information and stack trace for the deprecated functions will be shown in the new healthcheck `vim.deprecated`.
* fix(comment): fall back to using trimmed comment markers (#28938)Evgeni Chasnovski2024-05-23
| | | | | | | | | | | | | Problem: Currently comment detection, addition, and removal are done by matching 'commentstring' exactly. This has the downside when users want to add comment markers with space (like with `-- %s` commentstring) but also be able to uncomment lines that do not contain space (like `--aaa`). Solution: Use the following approach: - Line is commented if it matches 'commentstring' with trimmed parts. - Adding comment is 100% relying on 'commentstring' parts (as is now). - Removing comment is first trying exact 'commentstring' parts with fallback on trying its trimmed parts.
* fix(vim.iter): enable optimizations for arrays (lists with holes) (#28781)Gregory Anders2024-05-17
| | | | | | | | The optimizations that vim.iter uses for array-like tables don't require that the source table has no holes. The only thing that needs to change is the determination if a table is "list-like": rather than requiring consecutive, integer keys, we can simply test for (positive) integer keys only, and remove any holes in the original array when we make a copy for the iterator.
* fix(test): failure after version bump #28771Justin M. Keyes2024-05-16
| | | | | | | | | Problem: - The test for vim.deprecate() has a "mock" which is outdated because vim.deprecate() no longer uses that. - The tests get confused after a version bump. Solution: Make the tests adapt to the current version.
* refactor(api): nvim_win_xx_ns are EXPERIMENTALJustin M. Keyes2024-05-12
| | | | | | | | | | | | | | | | | Problem: The nvim_win_xx_ns function family introduced in ba0370b1d718d473d0ef51c35d88b98ba220082b needs more bake-time. Currently it's narrowly defined for windows, but other scopes ("buffer") and features are likely in the future. Solution: - Rename the API with double-underscore to mark it as EXPERIMENTAL. TODO/FUTURE: - Rename and change the signature to support more than just "window" scope, and for other flexibility. - Open question: we could choose either: - "store scopes on namespaces", or - "store namespaces on scopes (w:/b:/…)"
* fix(vim.json): properly treat luanil options as booleans (#28622)zeertzjq2024-05-03
| | | Note: Upstream doesn't have this. It's an Nvim addition.
* fix(vim.ui)!: change open() to return `result|nil, errmsg|nil` #28612Justin M. Keyes2024-05-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | reverts e0d92b9cc20b58179599f53dfa74ca821935a539 #28502 Problem: `vim.ui.open()` has a `pcall()` like signature, under the assumption that this is the Lua idiom for returning result-or-error. However, the `result|nil, errmsg|nil` pattern: - has precedent in: - `io.open` - `vim.uv` (`:help luv-error-handling`) - has these advantages: - Can be used with `assert()`: ``` local result, err = assert(foobar()) ``` - Allows LuaLS to infer the type of `result`: ``` local result, err = foobar() if err then ... elseif result then ... end ``` Solution: - Revert to the `result|nil, errmsg|nil` pattern. - Document the pattern in our guidelines.
* fix(ui): avoid recursiveness and invalid memory access #28578luukvbaal2024-05-01
| | | | | | | | Problem: Calling :redraw from vim.ui_attach() callback results in recursive cmdline/message events. Solution: Avoid recursiveness where possible and replace global "call_buf" with separate, temporary buffers for each event so that when a Lua callback for one event fires another event, that does not result in invalid memory access.
* feat(diagnostic): revert default behaviour of goto_next/prev()Lewis Russell2024-04-30
| | | | | | | | | | | | | | | | | Follow-up to #28490 Problem: The new behaviour of goto_next/prev() of navigating to the next highest severity doesn't work well when diagnostic providers have different interpretations of severities. E.g. the user may be blocked from navigating to a useful LSP warning, due to some linter error. Solution: The behaviour of next highest severity is now a hidden option `_highest = true`. We can revisit how to integrate this behaviour during the 0.11 cycle.
* fix(lsp): redundant vim.snippet.jumpable #28560Maria José Solano2024-04-29
|
* fix(ui): activating all ext capabilities without remote UI #28555luukvbaal2024-04-28
|
* fix(snippet): do not add extra indent on newlines (#28538)Mathias Fußenegger2024-04-28
| | | | | | | | | | | | | | | | | | | | | | | Reverts parts of https://github.com/neovim/neovim/pull/27674 LSP snippets typically do include tabs or spaces to add extra indentation and don't rely on the client using `autoindent` functionality. For example: public static void main(String[] args) {\n\t${0}\n} Notice the `\t` after `{\n` Adding spaces or tabs independent of that breaks snippets for languages like Haskell where you can have snippets like: ${1:name} :: ${2}\n${1:name} ${3}= ${0:undefined} To generate: name :: name = undefined
* fix(diagnostic): invalid col number compare in next_diagnostic (#28397)Raphael2024-04-27
| | | | | Problem: when line is blank link then there will got an invalid column number in math.min compare. Solution: make sure the min column number is 0 not an illegal number.
* Merge #28522 handle ui_attach side effectsJustin M. Keyes2024-04-27
|\
| * fix(ui): set 'cmdheight' to zero for all open tabpagesLuuk van Baal2024-04-27
| | | | | | | | | | | | Problem: Enabling ext_messages claims to set 'cmdheight' to zero, but only does so for the current tabpage. Solution: Set stored 'cmdheight' value to zero for all tabpages.
| * fix(ui): update ext_ui widgets when attaching non-remote UILuuk van Baal2024-04-26
| | | | | | | | | | | | Problem: Updating internalized UI capabilities is postponed until a remote UI attaches. Solution: Always update active UI widgets in ui_refresh().
* | refactor(vim.iter)!: rename xxback() => rxx() #28503Justin M. Keyes2024-04-26
|/ | | | | | | | | | | | | | | | Problem: vim.iter has both `rfind()` and various `*back()` methods, which work in "reverse" or "backwards" order. It's inconsistent to have both kinds of names, and "back" is fairly uncommon (rust) compared to python (rfind, rstrip, rsplit, …). Solution: - Remove `nthback()` and let `nth()` take a negative index. - Because `rnth()` looks pretty obscure, and because it's intuitive for a function named `nth()` to take negative indexes. - Rename `xxback()` methods to `rxx()`. - This informally groups the "list-iterator" functions under a common `r` prefix, which helps discoverability. - Rename `peekback()` to `pop()`, in duality with the existing `peek`.
* feat(diagnostic): goto functions jump to highest severity (#28490)Gregory Anders2024-04-25
| | | | | When the "severity" option is nil, vim.diagnostic.goto_next() and vim.diagnostic.goto_prev() jump to the next diagnostic with the highest severity.
* fix(vim.ui)!: change open() to return pcall-like values #28502Justin M. Keyes2024-04-25
| | | | | | | | | Problem: `vim.ui.open` unnecessarily invents a different success/failure convention. Its return type was changed in 57adf8c6e01d, so we might as well change it to have a more conventional form. Solution: Change the signature to use the `pcall` convention of `status, result`.
* Merge pull request #28492 from bfredl/hotfixbfredl2024-04-25
|\ | | | | fix(lua): vim.fn.has('nvim-0.10') in fast context, used by vim.deprecate
| * fix(lua): vim.fn.has('nvim-0.10') in fast context, used by vim.deprecatebfredl2024-04-25
| |
* | feat(fs): add vim.fs.root (#28477)Gregory Anders2024-04-24
|/ | | | | | vim.fs.root() is a function for finding a project root relative to a buffer using one or more "root markers". This is useful for LSP and could be useful for other "projects" designs, as well as for any plugins which work with a "projects" concept.
* test: improve test conventionsdundargoc2024-04-23
| | | | | | | | | Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004.
* perf(lua): faster vim.deprecate() #28470Evgeni Chasnovski2024-04-23
| | | | | | | | | | | | Problem: `vim.deprecate()` can be relatively significantly slower than the deprecated function in "Nvim" plugin. Solution: Optimize checks for "Nvim" plugin. This also results into not distinguishing "xxx-dev" and "xxx" versions when doing checks, which is essentially covered by the deprecation logic itself. With this rewrite I get the times from #28459: `{ 0.024827, 0.003797, 0.002024, 0.001774, 0.001703 }`. For quicker reference: - On current Nightly it is something like `{ 3.72243, 0.918169, 0.968143, 0.763256, 0.783424 }`. - On 0.9.5: `{ 0.002955, 0.000361, 0.000281, 0.000251, 0.00019 }`.
* fix(diagnostic): vim.diagnostic.get(…,{lnum=…}) on multi-line diagnostic ↵Raphael2024-04-23
| | | | | | | | #28273 Problem: vim.diagnostic.get(…,{lnum=…}) does not match multi-line diagnostics. Solution: add end_lnum support.
* fix(diagnostic): open_float on multi-line diagnostics #28301Raphael2024-04-23
| | | | | Problem: when diagnostic have a range of line, open_float not work. Solution: filter diagnostic by line number range.
* refactor(lua): rename tbl_isarray => isarrayJustin M. Keyes2024-04-21
| | | | | | | tbl_isarray was not released yet, so it will not go through a deprecation cycle. ref #24572
* refactor(lua): rename tbl_islist => islistJustin M. Keyes2024-04-21
| | | | ref #24572
* fix(vim.ui.open): try wslview before explorer.exe #28424Justin M. Keyes2024-04-20
| | | | | | | | | Problem: explorer.exe is unreliable on WSL. Solution: Try wslview before explorer.exe. fix #28410
* feat(lua): enable(enable:boolean, filter:table) #28374Justin M. Keyes2024-04-18
| | | | | | | | | | | | | Problem: We need to establish a pattern for `enable()`. Solution: - First `enable()` parameter is always `enable:boolean`. - Update `vim.diagnostic.enable()` - Update `vim.lsp.inlay_hint.enable()`. - It was not released yet, so no deprecation is needed. But to help HEAD users, it will show an informative error. - vim.deprecate(): - Improve message when the "removal version" is a *current or older* version.