Skip to content

Commit

Permalink
Support view expanded macro
Browse files Browse the repository at this point in the history
  • Loading branch information
maralla committed Aug 29, 2024
1 parent 3898de7 commit c25ff7d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion autoload/completor/popup.vim
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ func completor#popup#view(content, ft)
\ zindex: 32000,
\ filter: function('s:scroll_filter'),
\ filtermode: 'n',
\ padding: [1, 1, 1, 1],
\ padding: [0, 1, 0, 1],
\ border: [1, 1, 1, 1],
\ borderchars: ['', '', '', '', '', '', '', ''],
\ })
Expand Down
4 changes: 4 additions & 0 deletions pythonx/completers/lsp/ext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ def on_data(action, ft, data):
if not data:
return []

if ft == 'rust':
from .rust import on_data
return on_data(action, data)

return vim.Dictionary(data=data, action='view', ft=ft)
16 changes: 16 additions & 0 deletions pythonx/completers/lsp/ext/rust.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

from completor import vim
from ..models import Completion


Expand All @@ -8,13 +9,28 @@ def get_action_handler(action):
return ViewHir
if action == b'view_mir':
return ViewMir
if action == b'expand_macro':
return ExpandMacro

return ''


def on_data(action, data):
if action == b'expand_macro':
try:
data = [data[0]['expansion']]
except Exception:
return []
return vim.Dictionary(data=data, action='view', ft='rust')


class ViewHir(Completion):
method = 'rust-analyzer/viewHir'


class ViewMir(Completion):
method = 'rust-analyzer/viewMir'


class ExpandMacro(Completion):
method = 'rust-analyzer/expandMacro'

0 comments on commit c25ff7d

Please sign in to comment.