Skip to content
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

Implement virtual text support for vim #3915

Merged
merged 1 commit into from
Oct 2, 2021

Conversation

vimpostor
Copy link
Contributor

This implements virtual text support for vim 8.2. It requires the text property and the popup feature.
Screenshot_20210923_020429

Copy link
Contributor

@hsanson hsanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but tests fail on vint linter:

========================================
Running Vint to lint our code
========================================
Vint warnings/errors follow:

autoload/ale/virtualtext.vim:52:30: unexpected token: # (see vim-jp/vim-vimlparser)

I verified it does not break things in nvim but I do not have vim 8.2 to test. Appreciated if others that use vim 8.2 can check how this works for them.

@vimpostor
Copy link
Contributor Author

Looks good but tests fail on vint linter:

========================================
Running Vint to lint our code
========================================
Vint warnings/errors follow:

autoload/ale/virtualtext.vim:52:30: unexpected token: # (see vim-jp/vim-vimlparser)

Well, the linter is wrong, see :h literal-Dict. However, I have changed the code now to not use literal-Dicts to silence the linter gods (Make every key an explicit string):

diff --git a/autoload/ale/virtualtext.vim b/autoload/ale/virtualtext.vim
index 3e5c342f..2cd3a14d 100644
--- a/autoload/ale/virtualtext.vim
+++ b/autoload/ale/virtualtext.vim
@@ -49,7 +49,7 @@ function! ale#virtualtext#Clear() abort
         call nvim_buf_clear_highlight(l:buffer, s:ns_id, 0, -1)
     else
         if s:last_popup != -1
-            call prop_remove(#{type: 'ale'})
+            call prop_remove({'type': 'ale'})
             call popup_close(s:last_popup)
             let s:last_popup = -1
         endif
@@ -69,17 +69,17 @@ function! ale#virtualtext#ShowMessage(message, hl_group) abort
         call nvim_buf_set_virtual_text(l:buffer, s:ns_id, l:line-1, [[l:prefix.a:message, a:hl_group]], {})
     else
         let l:left_pad = col('$')
-        call prop_add(l:line, l:left_pad, #{
-        \ type: 'ale',
+        call prop_add(l:line, l:left_pad, {
+        \ 'type': 'ale',
         \})
-        let s:last_popup = popup_create(l:prefix.a:message, #{
-        \ line: -1,
-        \ padding: [0, 0, 0, 1],
-        \ mask: [[1, 1, 1, 1]],
-        \ textprop: 'ale',
-        \ highlight: a:hl_group,
-        \ fixed: 1,
-        \ wrap: 0
+        let s:last_popup = popup_create(l:prefix.a:message, {
+        \ 'line': -1,
+        \ 'padding': [0, 0, 0, 1],
+        \ 'mask': [[1, 1, 1, 1]],
+        \ 'textprop': 'ale',
+        \ 'highlight': a:hl_group,
+        \ 'fixed': 1,
+        \ 'wrap': 0
         \})
     endif
 endfunction

This requires the textprop and popupwin feature (vim 8.2).

Fixes dense-analysis#3906
@hsanson hsanson merged commit 708e810 into dense-analysis:master Oct 2, 2021
@blayz3r
Copy link

blayz3r commented Aug 7, 2022

looks like vim has a virtual text API now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants