aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua
Commit message (Collapse)AuthorAge
* feat(diagnostic): allow customized diagnostic messages (#15742)Gregory Anders2021-09-22
| | | | Provide a 'format' option for virtual text and floating window previews that allows the displayed text of a diagnostic to be customized.
* feat(diagnostic): add option to include diagnostic sourceGregory Anders2021-09-21
| | | | | Add an option to virtual text display and floating window previews to include diagnostic source in the diagnostic message.
* fix(diagnostic): clamp line numbers in display layer (#15729)Gregory Anders2021-09-20
| | | | | | Some parts of LSP need to use cached diagnostics as sent from the LSP server unmodified. Rather than fixing invalid line numbers when diagnostics are first set, fix them when they are displayed to the user (e.g. in show() or one of the get_next/get_prev family of functions).
* feat(diagnostic): match(), tolist(), fromlist() #15704Gregory Anders2021-09-19
| | | | | | * feat(diagnostic): add vim.diagnostic.match() Provide vim.diagnostic.match() to generate a diagnostic from a string and a Lua pattern. * feat(diagnostic): add tolist() and fromlist()
* refactor(tests): remove redir_exec #15718Justin M. Keyes2021-09-19
| | | | | | | | | | | Problem - `redir_exec` is obsolete, but it keeps getting used in new tests because people copy existing tests. - Disadvantages of `redir_exec`: - Captures extra junk before the actual error/message that we _want_ to test. - Does not fail on error, unlike e.g. `command()`. Solution - Use new functions like `nvim_exec` and `pcall_err`.
* test: add test case for show_line_diagnosticsGregory Anders2021-09-18
|
* fix(diagnostic): change default severity_sort orderGregory Anders2021-09-17
| | | | | | | When severity_sort is true, higher severities should be displayed before lower severities (e.g. ERROR is displayed over WARN). Also improved the test case for this.
* fix(diagnostic): support severity_sortGregory Anders2021-09-17
|
* Merge #15585 refactor: move vim.lsp.diagnostic to vim.diagnosticJustin M. Keyes2021-09-16
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## Overview - Move vim.lsp.diagnostic to vim.diagnostic - Refactor client ids to diagnostic namespaces - Update tests - Write/update documentation and function signatures Currently, non-LSP diagnostics in Neovim must hook into the LSP subsystem. This is what e.g. null-ls and nvim-lint do. This is necessary because none of the diagnostic API is exposed separately from the LSP subsystem. This commit addresses this by generalizing the diagnostic subsystem beyond the scope of LSP. The `vim.lsp.diagnostic` module is now simply a specific diagnostic producer and primarily maintains the interface between LSP clients and the broader diagnostic API. The current diagnostic API uses "client ids" which only makes sense in the context of LSP. We replace "client ids" with standard API namespaces generated from `nvim_create_namespace`. This PR is *mostly* backward compatible (so long as plugins are only using the publicly documented API): LSP diagnostics will continue to work as usual, as will pseudo-LSP clients like null-ls and nvim-lint. However, the latter can now use the new interface, which looks something like this: ```lua -- The namespace *must* be given a name. Anonymous namespaces will not work with diagnostics local ns = vim.api.nvim_create_namespace("foo") -- Generate diagnostics local diagnostics = generate_diagnostics() -- Set diagnostics for the current buffer vim.diagnostic.set(ns, diagnostics, bufnr) ``` Some public facing API utility methods were removed and internalized directly in `vim.diagnostic`: * `vim.lsp.util.diagnostics_to_items` ## API Design `vim.diagnostic` contains most of the same API as `vim.lsp.diagnostic` with `client_id` simply replaced with `namespace`, with some differences: * Generally speaking, functions that modify or add diagnostics require a namespace as their first argument, e.g. ```lua vim.diagnostic.set({namespace}, {bufnr}, {diagnostics}[, {opts}]) ``` while functions that read or query diagnostics do not (although in many cases one may be supplied optionally): ```lua vim.diagnostic.get({bufnr}[, {namespace}]) ``` * We use our own severity levels to decouple `vim.diagnostic` from LSP. These are designed similarly to `vim.log.levels` and currently include: ```lua vim.diagnostic.severity.ERROR vim.diagnostic.severity.WARN vim.diagnostic.severity.INFO vim.diagnostic.severity.HINT ``` In practice, these match the LSP diagnostic severity levels exactly, but we should treat this as an interface and not assume that they are the same. The "translation" between the two severity types is handled transparently in `vim.lsp.diagnostic`. * The actual "diagnostic" data structure is: (**EDIT:** Updated 2021-09-09): ```lua { lnum = <number>, col = <number>, end_lnum = <number>, end_col = <number>, severity = <vim.diagnostic.severity>, message = <string> } ``` This differs from the LSP definition of a diagnostic, so we transform them in the handler functions in vim.lsp.diagnostic. ## Configuration The `vim.lsp.with` paradigm still works for configuring how LSP diagnostics are displayed, but this is a specific use-case for the `publishDiagnostics` handler. Configuration with `vim.diagnostic` is instead done with the `vim.diagnostic.config` function: ```lua vim.diagnostic.config({ virtual_text = true, signs = false, underline = true, update_in_insert = true, severity_sort = false, }[, namespace]) ``` (or alternatively passed directly to `set()` or `show()`.) When the `namespace` argument is `nil`, settings are set globally (i.e. for *all* diagnostic namespaces). This is what user's will typically use for their local configuration. Diagnostic producers can also set configuration options for their specific namespace, although this is generally discouraged in order to respect the user's global settings. All of the values in the table passed to `vim.diagnostic.config()` are resolved in the same way that they are in `on_publish_diagnostics`; that is, the value can be a boolean, a table, or a function: ```lua vim.diagnostic.config({ virtual_text = function(namespace, bufnr) -- Only enable virtual text in buffer 3 return bufnr == 3 end, }) ``` ## Misc Notes * `vim.diagnostic` currently depends on `vim.lsp.util` for floating window previews. I think this is okay for now, although ideally we'd want to decouple these completely.
| * test: add test case for severity rangesGregory Anders2021-09-15
| |
| * refactor: move vim.lsp.diagnostic to vim.diagnosticGregory Anders2021-09-15
| | | | | | | | | | | | | | | | | | | | | | This generalizes diagnostic handling outside of just the scope of LSP. LSP clients are now a specific case of a diagnostic producer, but the diagnostic subsystem is decoupled from the LSP subsystem (or will be, eventually). More discussion at [1]. [1]: https://github.com/neovim/neovim/pull/15585
* | vim-patch:8.1.0793: incorrect error messages for functions that take a BlobSean Dewar2021-09-15
| | | | | | | | | | | | | | Problem: Incorrect error messages for functions that now take a Blob argument. Solution: Adjust the error messages. (Dominique Pelle, closes vim/vim#3846) https://github.com/vim/vim/commit/0d17f0d1c09fa6db306336695ba646c21ea24909
* | feat(decode_string): decode binary string with NULs to BlobSean Dewar2021-09-15
| | | | | | | | | | | | | | | | Strings that previously decoded into a msgpack special for representing BINs with NULs now convert to Blobs. It shouldn't be possible to decode into this special anymore after this change? Notably, Lua strings with NULs now convert to Blobs when passed to VimL.
* | feat(api): convert Blobs to API stringsSean Dewar2021-09-15
| | | | | | | | Note that these are not NUL-terminated; the API supports this.
* | feat(nlua): convert Blobs to stringsSean Dewar2021-09-15
|/
* feat(lua): make vim.mpack support vim.NIL and vim.empty_dict()Björn Linse2021-09-09
|
* feat(lua)!: register_keystroke_callback => on_keyJustin M. Keyes2021-09-09
| | | | | | | | | Analogous to nodejs's `on('data', …)` interface, here on_key is the "add listener" interface. ref 3ccdbc570d85 #12536 BREAKING_CHANGE: vim.register_keystroke_callback() is now an error.
* fix(lua): preserve argument lists which are not listsBjörn Linse2021-08-29
|
* tests(lua/on_yank): assert conditions that fail correctly #15495notomo2021-08-27
| | | | The test added in 274a3504a790a799b28ee89c75e29fb4dbdff41f does not fail if the code changes are reverted.
* fix(lua): verify buffer in highlight.on_yank (#15482)notomo2021-08-26
| | | | | Resolve an issue with deferred clearing of highlight failing if the buffer is deleted before the timeout by checking whether the buffer is valid first.
* Merge #15293 Vimscript "method" syntaxJustin M. Keyes2021-08-26
|\ | | | | Port VimL's method call syntax - vim-patch:8.1.{1638,1800,1803,1807,1809,1816,1820,1821,1828,1834,1835,1861,1863,1878,1879,1888,1909,1911,1912}
| * feat(v:lua): support calling v:lua as a methodSean Dewar2021-08-13
| |
| * fix(v:lua): fix emsg when calling v:lua directlySean Dewar2021-08-12
| | | | | | | | | | | | | | | | | | | | v:lua expressions are represented using vvlua_partial. As v:lua isn't intended to be called directly, it's given an empty pt_name. Because of this, calling v:lua directly like "v:lua()" will cause "E117: Unknown function: ", with an empty name. Instead, have call_func() show the name "v:lua" in the emsg.
* | fix(bufupdates): send correct updates for visual pasteThomas Vigouroux2021-08-25
| | | | | | | | | | | | One step further towards stable tree-sitter. Co-authored-by: Björn Linse <bjorn.linse@gmail.com>
* | feat(api): add lua C bindings for xdiff (#14536)Lewis Russell2021-08-22
|/ | | | | | | | | | | | | | | | * feat(api): add lua C bindings for xdiff * chore: opt.hunk_lines -> opt.result_type opt.on_hunk now takes precedence over opt.result_type * chore: fix indents Fix indents * chore: change how priv is managed Assign priv NULL and unconditionally apply XFREE_CLEAR to it when finished.
* fix(shared): do not treat empty tables as list in deep extend (#15094)Folke Lemaitre2021-07-19
| | | | | | | | | | An empty table was previously always treated as a list, which means that while merging tables, whenever an empty table was encountered it would always truncate any table on the left. `vim.tbl_deep_extend("force", { b = { a = 1 } }, { b = {} })` Before: `{ b = {} }` After: `{ b = { a = 1 } }`
* feat(vim.uri): Allow URI schemes other than file: without authorityTom Payne2021-07-10
|
* test(lsp): file URIs without a hostnameAlessandro Pezzoni2021-07-10
|
* fix(vim.opt): vimL map string values not trimmed (#14982)jadedpasta2021-07-04
| | | | | | | | | Options formatted as a list of comma-separated key-value pairs may have values that contain leading and trailing whitespace characters. For example, the `listchars` option has a default value of `"tab:> ,trail:-,nbsp:+"`. When converting this value to a lua table, leading and trailing whitespace should not be trimmed. Co-authored-by: Robert Hrusecky <robert.hrusecky@utexas.edu>
* Merge pull request #14779 from tjdevries/tjdevries/vim_opt_fixesTJ DeVries2021-06-29
|\ | | | | An assortment of various vim.opt fixups.
| * fix(vim.opt): Fix #14828 with empty values being incorrectly insertedTJ DeVries2021-06-29
| |
| * fix(vim.opt): Fix #14668 Now correctly handles unescaped commas in isfname styleTJ DeVries2021-06-29
| |
| * fix(vim.opt): Fix #14669 whichwrap now acts as expectedTJ DeVries2021-06-29
| |
| * fix(vim.opt): Add basic error handlingDavid Zhang2021-06-29
| |
| * fix(vim.opt): Get window options before setting.ckipp012021-06-29
| | | | | | | | | | | | | | This closes #14677, but I also am a little unsure if there are times where this may not be correct. However, this just changes the behavior that even if `was_set` was false, we still get for `nvim_win_get_option`.
| * fix(vim.opt): #14708 Now lets you put duplicate values in wildmodeTJ DeVries2021-06-29
| |
* | Merge pull request #14335 from chentau/extmark_delbytesBjörn Linse2021-06-29
|\ \ | |/ |/| Extmarks: manually zero out `curbuf->deleted_bytes2` on substitute and join
| * Manually zero out deleted_bytes2 when substituting and joining lineschentau2021-06-29
| |
* | refactor(tests): Simplify tests at functional/lua/runtime_specshadmansaleh2021-06-11
| |
* | feat(runtime): Allow lua to be used in syntaxshadmansaleh2021-06-11
| |
* | feat(runtime): Allow lua to be used in ftdetectshadmansaleh2021-06-11
| |
* | feat(runtime): Allow lua to be used in indentshadmansaleh2021-06-11
| |
* | feat(runtime): Allow lua to be used in ftpluginshadmansaleh2021-06-11
| |
* | feat(runtime): Allow lua to be used in compilershadmansaleh2021-06-11
| |
* | feat(runtime): Allow lua to be used in colorschemesshadmansaleh2021-06-11
|/ | | | * tests(runtime): move runtime/plugin tests to functional/lua/runtime_spec
* api: add nvim_win_callnotomo2021-06-10
|
* add tests in buffer_updatesjbyuki2021-06-09
|
* lua: Add vim.opt and fix scopes of vim.o (#13479)TJ DeVries2021-05-28
| | | | | | | | | | | | | * lua: Add vim.opt * fixup: cleaning * fixup: comments * ty clason * fixup: comments * this is the last commit. period.
* Merge pull request #14575 from vigoux/virtualedit-bytesThomas Vigouroux2021-05-20
|\ | | | | fix(bufupdate): send events when inserting with virtualedit
| * fix(bufupdate): send events when inserting with virtualeditThomas Vigouroux2021-05-18
| | | | | | | | | | Problem first raised https://github.com/nvim-treesitter/nvim-treesitter/issues/1304