aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/diagnostic_spec.lua
Commit message (Collapse)AuthorAge
* fix(diagnostic): virtual_text prefix function should have index and total ↵Jongwook Choi2023-10-27
| | | | | | | | | | | | | (#25801) The prefix option of the diagnostic virtual text can be a function, but previously it was only a function of diagnostic. This function should also have additional parameters index and total, more consistently and similarily as in the prefix function for `vim.diagnostic.open_float()`. These additional parameters will be useful when there are too many number of diagnostics in a single line.
* fix(diagnostic): always return copies of diagnostic items (#25010)Evgeni Chasnovski2023-09-06
|
* feat(diagnostic): filter diagnostics by specific severities (#24736)Michael Strobel2023-08-16
| | | Allow users to filter diagnostics by specifying severities
* 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.
* 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.
* feat(diagnostic): add support for tagsLewis Russell2023-03-30
| | | | | | The LSP spec supports two tags that can be added to diagnostics: unnecessary and deprecated. Extend vim.diagnostic to be able to handle these.
* feat(diagnostic): vim.diagnostic.is_disabled() #21527Raphael2023-01-12
|
* feat(highlight): add DiagnosticOk (and associated) highlight groups (#21286)Oliver Marriott2022-12-28
| | | | | | The existing groups, Error, Hint, Info, Warn cover many use cases, but neglect the occasion where a diagnostic message should communicate a non-informative (not a Hint or Info) event. DiagnosticOk covers this with a generic green colorscheme.
* fix(diagnostic): clear stale cache on reset (#21454)Mathias Fußenegger2022-12-17
| | | | | | | | | | | | | The BufWipeout autocmd is not 100% reliable and may leave stale entries in the cache. This is sort of a hack/workaround to ensure `vim.diagnostic.reset` calls don't fail if there are stale cache entries but instead clears them Fixes errors like Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/diagnostic.lua:1458: Invalid buffer id: 22 stack traceback: [C]: in function 'nvim_exec_autocmds' /usr/share/nvim/runtime/lua/vim/diagnostic.lua:1458: in function 'reset'
* feat(diagnostic): add `suffix` option to `virt_text` config (#21140)beardedsakimonkey2022-11-20
| | | | | | | This introduces a `suffix` option to the `virt_text` config in `vim.diagnostic.config()`. The suffix can either be a string which is appended to the diagnostic message or a function returning such. The function receives a `diagnostic` argument, which is the diagnostic table of the last diagnostic (the one whose message is rendered as virt text).
* feat(diagnostic): add `suffix` option to `open_float()` (#21130)beardedsakimonkey2022-11-20
| | | | | | | | | | | Closes #18687 This introduces a `suffix` option to `vim.diagnostic.open_float()` (and consequently `vim.diagnostic.config()`) that appends some text to each diagnostic in the float. It accepts the same types as `prefix`. For multiline diagnostics, the suffix is only appended to the last line. By default, the suffix will render the diagnostic error code, if any.
* perf(diagnostic): use api variable and improve validate (#21111)Raphael2022-11-19
| | | | | * fix(diagnostic): use api variable and improve validate * fix: fix test case
* feat(test): add Lua forms for API methods (#20152)Lewis Russell2022-11-14
|
* feat(diagnostic): pass diagnostics as data to DiagnosticChanged autocmd (#20173)Gregory Anders2022-09-13
|
* fix(diagnostic): remove buf from cache on `BufWipeout` (#20099)Sean Dewar2022-09-06
| | | | | | | | | | | | | | Doing so on `BufDelete` has issues: - `BufDelete` is also fired for listed buffers that are made unlisted. - `BufDelete` is not fired for unlisted buffers that are deleted. This means that diagnostics will be lost for a buffer that becomes unlisted. It also means that if an entry exists for an unlisted buffer, deleting that buffer later will not remove its entry from the cache (and you may see "Invalid buffer id" errors when using diagnostic functions if it was wiped). Instead, remove a buffer from the cache if it is wiped out. This means simply `:bd`ing a buffer will not clear its diagnostics now.
* fix(lsp): clean the diagnostic cache when buffer delete (#19449)Raphael2022-08-29
| | | Co-authored-by: Gregory Anders <greg@gpanders.com>
* fix(diagnostic): check for negative column value (#18868)mohsen2022-06-08
|
* fix(diagnostic): use nvim_exec_autocmds to trigger DiagnosticChanged (#18188)Gregory Anders2022-04-20
| | | | | Use nvim_exec_autocmds to issue the DiagnosticChanged autocommand, rather than nvim_buf_call, which has some side effects when drawing statuslines.
* feat: use nvim_buf_set_extmark for vim.highlight (#16963)Michael Lingelbach2022-01-15
| | | | | | | | | Closes https://github.com/neovim/neovim/issues/13647 This allows customizing the priority of the highlights. * Add default priority of 50 * Use priority of 200 for highlight on yank * use priority of 40 for highlight references (LSP)
* fix(diagnostic): improve validation for list arguments (#16855)Gregory Anders2022-01-01
| | | | | | Function arguments that expect a list should explicitly use tbl_islist rather than just checking for a table. This helps catch some simple errors where a single table item is passed as an argument, which passes validation (since it's a table), but causes other errors later on.
* refactor(diagnostic): remove bufnr parameter from open_float (#16579)Gregory Anders2021-12-08
| | | | | | | | | | | | | | The overwhelming majority of use cases for `open_float` are to view diagnostics from the current buffer in a floating window. Thus, most use cases will just `0` or `nil` as the first argument, which makes the argument effectively useless and wasteful. In the cause of optimizing for the primary use case, make the `bufnr` parameter an optional parameter in the options table. This still allows using an alternative buffer for those that wish to do so, but makes the "primary" use case much easier. The old signature is preserved for backward compatibility, though it can likely be fully deprecated at some point.
* fix(diagnostic): escape special chars in file names (#16527)Matthew Toohey2021-12-05
| | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: Gregory Anders <greg@gpanders.com>
* feat(diagnostic): use `scope = 'line'` by default for `open_float()` (#16456)cbarrete2021-11-28
| | | | | Closes #16453 Co-authored-by: Cédric Barreteau <cbarrete@users.noreply.github.com>
* test(diagnostic): diagnostics passed to set() should be an arrayGregory Anders2021-11-27
|
* test(diagnostic): uncomment equality checkGregory Anders2021-11-24
|
* fix(diagnostic): resolve buffer number in get() (#16407)Gregory Anders2021-11-22
|
* fix(diagnostics): don't allow 0 bufnr for metatable index (#16405)Gregory Anders2021-11-22
| | | | | | | | | | | | | | | | | | | | 04bfd20bb introduced a subtle bug where using 0 as the buffer number in the diagnostic cache resets the cache for the current buffer. This happens because we were not checking to see if the _resolved_ buffer number already existed in the cache; rather, when the __index metamethod was called we assumed the index did not exist so we set its value to an empty table. The fix for this is to check `rawget()` for the resolved buffer number to see if the index already exists. However, the reason this bug was introduced in the first place was because we are simply being too clever by allowing a 0 buffer number as the index which is automatically resolved to a real buffer number. In the interest of minimizing metatable magic, remove this "feature" by requiring the buffer number index to always be a valid buffer. This ensures that the __index metamethod is only ever called for non-existing buffers (which is what we wanted originally) as well as reduces some of the cognitive overhead for understanding how the diagnostic cache works. The tradeoff is that all public API functions must now resolve 0 buffer numbers to the current buffer number.
* fix(diagnostic): remove invalid buffers from cache (#16397)smolck2021-11-21
| | | | | | | | | Errors were being caused by invalid buffers being kept around in diagnostic_cache, so add a metatable to diagnostic_cache which attaches to new buffers in the cache, removing them after they are invalidated. Closes #16391. Co-authored-by: Gregory Anders <8965202+gpanders@users.noreply.github.com>
* fix(diagnostic): fix navigation with diagnostics placed past end of lineGregory Anders2021-11-19
|
* fix(diagnostic): deepcopy diagnostics before clamping line numbersGregory Anders2021-11-19
| | | | | | | | | | | | | | The current 'clamp_line_numbers' implementation modifies diagnostics in place, which can have adverse downstream side effects. Before clamping line numbers, make a copy of the diagnostic. This commit also merges the 'clamp_line_numbers' method into a new 'get_diagnostics' local function which also implements the more general "get" method. The public 'vim.diagnostic.get()' API now just uses this function (without clamping). This has the added benefit that other internal API functions that need to use get() no longer have to go through vim.validate. Finally, reorganize the source code a bit by grouping all of the data structures together near the top of the file.
* Merge pull request #16328 from gpanders/diagnostic-prefix-hiGregory Anders2021-11-16
|\
| * refactor(diagnostic)!: rename 'show_header' to 'header'Gregory Anders2021-11-15
| | | | | | | | | | | | Rename the `show_header` option in `open_float` to simply `header` and allow users to specify both the header string as well as the highlight group.
| * feat(diagnostic): allow 'prefix' option to return highlightGregory Anders2021-11-15
| | | | | | | | | | Extend the 'prefix' option for `open_float` to also provide an optional highlight group for the prefix string.
* | refactor(diagnostic): make bufnr arguments consistent (#16323)Gregory Anders2021-11-16
|/ | | | | | | Make the bufnr argument have similar semantics across API functions; namely, a nil value means "all buffers" while 0 means "current buffer". This increases the flexibility of the API by allowing functions such as enable() and disable() to apply globally or per-namespace, rather than only on a specific buffer.
* feat(diagnostic): add 'prefix' option to open_float (#16321)Gregory Anders2021-11-14
| | | | The 'prefix' option accepts a function or a string that is used to add a prefix string to each diagnostic displayed in the floating window.
* feat(diagnostic): do not require namespace for hide() and show() (#16261)Gregory Anders2021-11-09
| | | | | | | Also fix a few other small bugs regarding saving and restoring extmarks. In particular, now that the virtual text and underline handlers have their own dedicated namespaces, they should be responsible for saving and restoring their own extmarks. Also fix the wrong argument ordering in the call to `clear_diagnostic_cache` in the `on_detach` callback.
* fix(diagnostic): fix option resolution in open_float (#16229)Gregory Anders2021-11-04
|
* refactor(diagnostic): make display handlers generic (#16137)Gregory Anders2021-10-29
| | | | | | | Rather than treating virtual_text, signs, and underline specially, introduce the concept of generic "handlers", of which those three are simply the defaults bundled with Nvim. Handlers are called in `vim.diagnostic.show()` and `vim.diagnostic.hide()` and are used to handle how diagnostics are displayed.
* fix(diagnostic): handle diagnostics placed past the end of line (#16095)Gregory Anders2021-10-19
|
* refactor(diagnostic)!: replace 'show_*' functions with 'open_float' (#16057)Gregory Anders2021-10-19
| | | | | | | | | | | | | | | | | | | | 'show_line_diagnostics()' and 'show_position_diagnostics()' are almost identical; they differ only in the fact that the latter also accepts a column to form a full position, rather than just a line. This is not enough to justify two separate interfaces for this common functionality. Renaming this to simply 'show_diagnostics()' is one step forward, but that is also not a good name as the '_diagnostics()' suffix is redundant. However, we cannot name it simply 'show()' since that function already exists with entirely different semantics. Instead, combine these two into a single 'open_float()' function that handles all of the cases of showing diagnostics in a floating window. Also add a "float" key to 'vim.diagnostic.config()' to provide global values of configuration options that can be overridden ephemerally. This makes the float API consistent with the rest of the diagnostic API. BREAKING CHANGE
* fix(diagnostic): do not override existing config settings #16043Gregory Anders2021-10-17
| | | | | | | | | | | When using `true` as the value of a configuration option, the option is configured to use default values. For example, if a user configures virtual text to include the source globally (using vim.diagnostic.config) and a specific namespace or producer configures virtual text with `virt_text = true`, the user's global configuration is overriden. Instead, interpret a value of `true` to mean "use existing settings if defined, otherwise use defaults".
* fix: support severity_sort option for show_diagnostic functions (#15948)Gregory Anders2021-10-07
| | | Support the severity_sort option for show_{line,position}_diagnostics.
* test(diagnostic): add test case for signsGregory Anders2021-10-02
|
* 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()
* 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
|