aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/decoration.c
Commit message (Collapse)AuthorAge
* perf(column): only invalidate lines affected by added signLuuk van Baal2023-11-29
|
* fix(decorations): do not apply sign highlight id as range attr idLuuk van Baal2023-11-29
|
* refactor(decor): remove sign conditions that are always trueLuuk van Baal2023-11-28
|
* fix(column): redraw and update signcols for paired extmarkLuuk van Baal2023-11-28
| | | | | | Problem: Signcolumn width does not increase when ranged sign does not start at sentinel line. Solution: Handle paired range of added sign when checking signcols.
* refactor: iwyu (#26269)zeertzjq2023-11-28
|
* feat(decoration): allow conceal_char to be a composing charbfredl2023-11-28
| | | | | | | | decor->text.str pointer must go. This removes it for conceal char, in preparation for a larger PR which will also handle the sign case. By actually allowing composing chars for a conceal chars, this becomes a feature and not just a refactor, as a bonus.
* build(IWYU): fix includes for undo_defs.hdundargoc2023-11-27
|
* docs: small fixes (#26154)dundargoc2023-11-27
|
* build: rework IWYU mapping filesdundargoc2023-11-25
| | | | | Create mapping to most of the C spec and some POSIX specific functions. This is more robust than relying files shipped with IWYU.
* fix(column): apply numhl signs when 'signcolumn' is "no" (#26167)luukvbaal2023-11-23
|
* feat(extmarks): add sign name to extmark "details" arrayLuuk van Baal2023-11-22
| | | | | | | | Problem: Unable to identify legacy signs when fetching extmarks with `nvim_buf_get_extmarks()`. Solution: Add "sign_name" to the extmark detail array. Add some misc. changes as follow-up to #25724
* fix(decorations): fix imbalanced sign countbfredl2023-11-22
|
* refactor(decorations): break up Decoration struct into smaller piecesbfredl2023-11-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the monolithic Decoration struct. Before this change, each extmark could either represent just a hl_id + priority value as a inline decoration, or it would take a pointer to this monolitic 112 byte struct which has to be allocated. This change separates the decorations into two pieces: DecorSignHighlight for signs, highlights and simple set-flag decorations (like spell, ui-watched), and DecorVirtText for virtual text and lines. The main separation here is whether they are expected to allocate more memory. Currently this is not really true as sign text has to be an allocated string, but the plan is to get rid of this eventually (it can just be an array of two schar_T:s). Further refactors are expected to improve the representation of each decoration kind individually. The goal of this particular PR is to get things started by cutting the Gordian knot which was the monolithic struct Decoration. Now, each extmark can either contain chained indicies/pointers to these kinds of objects, or it can fit a subset of DecorSignHighlight inline. The point of this change is not only to make decorations smaller in memory. In fact, the main motivation is to later allow them to grow _larger_, but on a dynamic, on demand fashion. As a simple example, it would be possible to augment highlights to take a list of multiple `hl_group`:s, which then would trivially map to a chain of multiple DecorSignHighlight entries. One small feature improvement included with this refactor itself, is that the restriction that extmarks cannot be removed inside a decoration provider has been lifted. These are instead safely lifetime extended on a "to free" list until the current iteration of screen drawing is done. NB: flags is a mess. but DecorLevel is useless, this slightly less so
* refactor(sign): store 'signcolumn' width range when it is setLuuk van Baal2023-11-21
| | | | | Problem: Minimum and maximum signcolumn width is determined each redraw. Solution: Determine and store 'signcolumn' range when option is set.
* refactor(sign): move legacy signs to extmarksLuuk van Baal2023-11-17
| | | | | | | | | | | | | | | | | | | | Problem: The legacy signlist data structures and associated functions are redundant since the introduction of extmark signs. Solution: Store signs defined through the legacy commands in a hashmap, placed signs in the extmark tree. Replace signlist associated functions. Usage of the legacy sign commands should yield no change in behavior with the exception of: - "orphaned signs" are now always removed when the line it is placed on is deleted. This used to depend on the value of 'signcolumn'. - It is no longer possible to place multiple signs with the same identifier in a single group on multiple lines. This will now move the sign instead. Moreover, both signs placed through the legacy sign commands and through |nvim_buf_set_extmark()|: - Will show up in both |sign-place| and |nvim_buf_get_extmarks()|. - Are displayed by increasing sign identifier, left to right. Extmark signs used to be ordered decreasingly as opposed to legacy signs.
* build: remove PVSdundargoc2023-11-12
| | | | | | | We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable.
* feat(extmarks): add 'invalidate' property to extmarksLuuk van Baal2023-11-08
| | | | | | | | Problem: No way to have extmarks automatically removed when the range it is attached to is deleted. Solution: Add new 'invalidate' property that will hide a mark when the entirety of its range is deleted. When "undo_restore" is set to false, delete the mark from the buffer instead.
* feat(extmarks): add "undo_restore" flag to opt out of undo-restoringbfredl2023-11-05
| | | | | | | | | | | | | | | It is a design goal of extmarks that they allow precise tracking of changes across undo/redo, including restore the exact positions after a do/undo or undo/redo cycle. However this behavior is not useful for all usecases. Many plugins won't keep marks around for long after text changes, but uses them more like a cache until some external source (like LSP semantic highlights) has fully updated to changed text and then will explicitly readjust/replace extmarks as needed. Add a "undo_restore" flag which is true by default (matches existing behavior) but can be set to false to opt-out of this behavior. Delete dead u_extmark_set() code.
* build(iwyu): add a few more _defs.h mappings (#25435)zeertzjq2023-09-30
|
* fix(ui): handle virtual text with multiple hl in more cases (#25304)zeertzjq2023-09-22
|
* fix(extmarks): fix win_col virt_text drawn on wrong screen line (#25264)zeertzjq2023-09-20
|
* fix(extmarks): overlay virt_text position after 'showbreak' (#25175)zeertzjq2023-09-15
| | | Also make virt_text_hide work properly.
* fix(extmarks): properly handle virt_text on next screen line (#25166)zeertzjq2023-09-15
| | | | TODO: virt_text_hide doesn't work for the first char on a wrapped screen line, and it's not clear how to fix that.
* feat(extmark): support proper multiline rangesbfredl2023-09-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The removes the previous restriction that nvim_buf_set_extmark() could not be used to highlight arbitrary multi-line regions The problem can be summarized as follows: let's assume an extmark with a hl_group is placed covering the region (5,0) to (50,0) Now, consider what happens if nvim needs to redraw a window covering the lines 20-30. It needs to be able to ask the marktree what extmarks cover this region, even if they don't begin or end here. Therefore the marktree needs to be augmented with the information covers a point, not just what marks begin or end there. To do this, we augment each node with a field "intersect" which is a set the ids of the marks which overlap this node, but only if it is not part of the set of any parent. This ensures the number of nodes that need to be explicitly marked grows only logarithmically with the total number of explicitly nodes (and thus the number of of overlapping marks). Thus we can quickly iterate all marks which overlaps any query position by looking up what leaf node contains that position. Then we only need to consider all "start" marks within that leaf node, and the "intersect" set of that node and all its parents. Now, and the major source of complexity is that the tree restructuring operations (to ensure that each node has T-1 <= size <= 2*T-1) also need to update these sets. If a full inner node is split in two, one of the new parents might start to completely overlap some ranges and its ids will need to be moved from its children's sets to its own set. Similarly, if two undersized nodes gets joined into one, it might no longer completely overlap some ranges, and now the children which do needs to have the have the ids in its set instead. And then there are the pivots! Yes the pivot operations when a child gets moved from one parent to another.
* fix(extmarks): make empty "conceal" respect &conceallevel = 1 (#24785)zeertzjq2023-08-19
| | | This treats extmark conceal more like matchadd() conceal.
* perf(extmarks): avoid unnecessary marktree traversal with folds (#24306)zeertzjq2023-07-11
| | | | | | | | | | | | | | | | | | | Extreme testcase: ```lua vim.cmd([[ call setline(1, ['', '', '']) 2,3fold ]]) local ns = vim.api.nvim_create_namespace('') for _ = 1, 100000 do vim.api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{ '' }}} }) end local start_time = vim.uv.hrtime() vim.api.nvim_win_text_height(0, {}) local stop_time = vim.uv.hrtime() print(stop_time - start_time) ``` Before this PR: 21542011 After this PR: 43874
* fix(column): don't overflow sign column with extmark signs (#23854)zeertzjq2023-06-01
|
* fix(extmarks): don't show virt lines for end mark (#23792)zeertzjq2023-05-28
|
* fix(extmarks): make right_align and win_col work on wrapped line (#23759)zeertzjq2023-05-27
|
* fix(ui): adjust the cursor when inserting virtual textIbby2023-05-22
| | | | | | | | Credit to: Jesse Bakker https://github.com/neovim/neovim/pull/20130#issuecomment-1369652743 Co-authored-by: Jesse Bakker <github@jessebakker.com>
* vim-patch:9.0.0130: cursor position wrong when inserting around virtual textIbby2023-05-22
| | | | | | | | | Problem: Cursor position wrong when inserting around virtual text. Solution: Update the cursor position properly. https://github.com/vim/vim/commit/1f4ee19eefecd8f70b7cbe8ee9db8ace6352e23e Co-authored-by: tom-anders <13141438+tom-anders@users.noreply.github.com>
* fix: disallow removing extmarks in on_lines callbacks (#23219)Lewis Russell2023-04-27
| | | | | | | | | | fix(extmarks): disallow removing extmarks in on_lines callbacks decor_redraw_start (which runs before decor_providers_invoke_lines) gets references for the extmarks on a specific line. If these extmarks are deleted in on_lines callbacks then this results in a heap-use-after-free error. Fixes #22801
* refactor: uncrustifydundargoc2023-04-26
| | | | Notable changes: replace all infinite loops to `while(true)` and remove `int` from `unsigned int`.
* feat(api): evaluate 'statuscolumn' with nvim_eval_statusline()Luuk van Baal2023-04-05
|
* vim-patch:9.0.0194: cursor displayed in wrong position after removing text ↵zeertzjq2023-03-17
| | | | | | | | | | | prop (#22706) Problem: Cursor displayed in wrong position after removing text prop. (Ben Jackson) Solution: Invalidate the cursor position. (closes vim/vim#10898) https://github.com/vim/vim/commit/326c5d36e7cb8526330565109c17b4a13ff790ae Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor(extmarks): some minor internal API changesbfredl2023-03-16
| | | | | | | | | extranges and a bunch of other improvements are coming for 0.10 This gets in some minor surrounding API changes to avoid rebase conflicts until then. - decorations will be able to be specific to windows - adjust deletion API to fit with extranges
* fix(extmarks): don't leak memory on error (#22507)zeertzjq2023-03-05
|
* fix(decoration): don't show signcolumn for non-sign_text extmark (#22135)Lewis Russell2023-02-05
| | | Fixes: #22127
* fix(extmarks): problems with folded virtual lines (#21930)luukvbaal2023-01-23
| | | | | | | | | | | | | | Problem: When a folded line has virtual lines attached, the following problems occur: - The virtual lines are drawn empty. - The 'foldtext' line is drawn empty. - The cursor is drawn incorrectly. Solution: Check whether virtual lines belong to a folded line. Fix #17027 Fix #19557 Fix #21837 Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* refactor: replace char_u with char 24 (#21823)dundargoc2023-01-18
| | | | | refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
* build: allow IWYU to fix includes for all .c filesdundargoc2022-11-15
| | | | | | | | | | Allow Include What You Use to remove unnecessary includes and only include what is necessary. This helps with reducing compilation times and makes it easier to visualise which dependencies are actually required. Work on https://github.com/neovim/neovim/issues/549, but doesn't close it since this only works fully for .c files and not headers.
* feat(extmarks): allow preventing spellchecking with spell = falseThomas Vigouroux2022-11-12
|
* refactor: fix clang-tidy warningsdundargoc2022-11-06
| | | | | | | | Enable and fix bugprone-misplaced-widening-cast warning. Fix some modernize-macro-to-enum and readability-else-after-return warnings, but don't enable them. While the warnings can be useful, they are in general too noisy to enable.
* fix(redraw): make redrawdebug=nodelta handle all the casesbfredl2022-09-22
| | | | | | Before only win_line lines were considered. this applies nodelta to all screen elements. Causes some failures, which might indeed indicate excessive redraws.
* feat(extmarks,ts,spell): full support for spellingThomas Vigouroux2022-09-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added 'spell' option to extmarks: Extmarks with this set will have the region spellchecked. - Added 'noplainbuffer' option to 'spelloptions': This is used to tell Neovim not to spellcheck the buffer. The old behaviour was to spell check the whole buffer unless :syntax was set. - Added spelling support to the treesitter highlighter: @spell captures in highlights.scm are used to define regions which should be spell checked. - Added support for navigating spell errors for extmarks: Works for both ephemeral and static extmarks - Added '_on_spell_nav' callback for decoration providers: Since ephemeral callbacks are only drawn for the visible screen, providers must implement this callback to instruct Neovim which regions in the buffer need can be spell checked. The callback takes a start position and an end position. Note: this callback is subject to change hence the _ prefix. - Added spell captures for built-in support languages Co-authored-by: Lewis Russell <lewis6991@gmail.com> Co-authored-by: Björn Linse <bjorn.linse@gmail.com>
* refactor: replace char_u with charDundar Göc2022-08-31
| | | | Work on https://github.com/neovim/neovim/issues/459
* refactor: remove redundant castsDundar Göc2022-08-27
|
* vim-patch:8.1.2057: the screen.c file is much too bigLewis Russell2022-08-19
| | | | | | | | | | | | | | | Problem: The screen.c file is much too big. Solution: Split it in three parts. (Yegappan Lakshmanan, closes vim/vim#4943) https://github.com/vim/vim/commit/7528d1f6b5422750eb778dfb550cfd0b0e540964 This is an approximation vim-patch 8.1.2057. Applying the patch directly isn't feasible since our version of screen.c has diverged too much, however we still introduce drawscreen.c and drawline.c: - screen.c is now a much smaller file used for low level screen functions - drawline.c contains everything needed for win_line() - drawscreen.c contains everything needed for update_screen() Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* refactor(signs): handle non-sign attrs separately (#19784)Lewis Russell2022-08-16
|
* fix(signs): priority of extmark signs (#19718)Lewis Russell2022-08-11
|