haringsrob/nvim_context_vt

github github
editing-supports plugin
star 111
stars
alert-circle 3
open issues
users 3
subscribers
git-branch 8
forks
CREATED

2021-04-24

UPDATED

yesterday

packer

require('packer').startup(function()
  use 'haringsrob/nvim_context_vt'
end)

paq

require "paq" { 
  'haringsrob/nvim_context_vt'
}

Nvim context vt

Shows virtual text of the current context at the end of:

  • functions
  • methods
  • if statements
  • foreach statements
  • classes

Debug

If a context expected is not shown you can try to use :lua require 'nvim_context_vt'.showDebug() to get current and parent node info.

Mandatory jif

example

How to install

Install treesitter, then use your favourite package manager.

There are no dependencies.

Advanced usage

You can use a callback to change the virtual text content.

require('nvim_context_vt').setup {
  custom_text_handler = function(node)
    return 'my custom virtual text'
  end,
}

If you return nil, no virtual text will be displayed. You can use it to filter out node type which you don't to want virtual text to appear.

require('nvim_context_vt').setup {
  custom_text_handler = function(node)
    if node:type() == 'function' then
      return nil
    end
    return ts_utils.get_node_text(node)[1]
  end,
}