New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RDY] support buffer-associated highlighting by plugins #1817
Conversation
@bfredl This will be very appreciated! 👍 |
👍 |
I first thought, just take take whatever datastructure that stores matchaddpos matches in window_T and replicade that in buffer_T. Unfortunately that will not scale well for a lot of added highlights as currently a single linked list is used to store all matches (regexp or pos based) in a window. For every point in the screen where match highlight can change, the entire list must be traversed, giving O(N*N) complexity where N is the number of position matches. The struct storing a single matchaddpos item is also quite "fat", as it was originaly meant to contain regexp matcher logic and not a single/a few position matches. So my current plan is instead:
Thoughts/Suggestions/Objections? |
What happens when the text is edited? |
I'm not sure if @bfredl plans to cover that, but my guess is that this feature is more useful for read-only buffers. |
Same as for |
Marks also follow line moves (but not column moves, AFAICT). |
After digging yet deeper into |
👍 Looks like you found some clearly redundant blocks |
Yes, should probably go along with some screen tests of hlsearch/matchaddpos ( took some iterations before getting rid of some drawing errors ) |
Closest in implemention of exsisting features might be the |
If you figure out a way to move signs when a new line is inserted at the line the sign is at, that would be awesome. |
99d481e
to
403fa0d
Compare
Now there is a kind-of working prototype, quite messy/inefficient code and such, but now you can do (translate to your api client of choice) I will do some work to cleanup the implementation, but right now I would appreciate feedback on the api design. Would it be a better interface to accept an array of |
Btw, why can't one just do something like |
FWIW, I made a branch of nvim-ipy to test this. There is a bit of "impendance mismatch" right now when implementing terminal output parsing (IPython protocol represents colored output as terminal ANSI sequences), as one for this usecase would want to specify the attributes directly and not a "semantic" highlight group |
@bfredl I'm using this PR into my private branch where I implement buffer terminal emulator for nvim. Except for some minor adjustments, it is working well for me. |
This fixes a bug I introduced in diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 26f172c..c9b5b72 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -6719,6 +6719,10 @@ int hl_combine_attr(int char_attr, int prim_attr)
return prim_attr;
}
+ if (prim_attr == 0) {
+ return char_attr;
+ }
+
// Find the entry for char_attr
char_aep = syn_cterm_attr2entry(char_attr);
Without it there may be invalid reads when you call this function(after you rebase) |
629ce4f
to
b1c764b
Compare
@brcolow Thanks, updated! |
On a general note, please comment on the "Files changed" tab rather than a commit if possible; this makes the comment survive rebases and also makes github keep track which comments are addressed or not. |
I think this is starting to get quite RDY, I've added some argument validation and checked it works with multibyte text (it uses byte-based indexing for columns, just like |
@bfredl Will do, thanks (didn't know about that difference). |
1970c08
to
c628e89
Compare
I will go ahead and merge this soon, if there is no more comments. |
Just in case: clint.py is complaining a bunch on |
yes, I asked about it above. |
don't worry about kvec.h lint errors. |
All test pass except for the kvec linter errors. might be some grammer error left in the docs, but let's merge this. |
support buffer-associated highlighting by external plugins
As discussed in #1767, this aims to implement a variant of
matchaddpos
, but matches tied to a specific buffer and not the current window.No actual code for the feature yet, just started with cleanup/refactor of the exisiting code.