https://github.com/andersevenrud/nvim_context_vt
Virtual text context for neovim treesitter
https://github.com/andersevenrud/nvim_context_vt
context context-clues lua neovim neovim-plugin treesitter virtual-text
Last synced: 7 months ago
JSON representation
Virtual text context for neovim treesitter
- Host: GitHub
- URL: https://github.com/andersevenrud/nvim_context_vt
- Owner: andersevenrud
- License: mit
- Created: 2021-04-24T21:28:49.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-16T20:06:13.000Z (over 1 year ago)
- Last Synced: 2024-10-29T18:07:36.259Z (about 1 year ago)
- Topics: context, context-clues, lua, neovim, neovim-plugin, treesitter, virtual-text
- Language: Lua
- Homepage:
- Size: 3.03 MB
- Stars: 376
- Watchers: 6
- Forks: 16
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - andersevenrud/nvim_context_vt - Shows virtual text of the current context. (Editing Support / Scrollbar)
- awesome-neovim-sorted - andersevenrud/nvim_context_vt
README
# nvim_context_vt
Shows virtual text of the current context after functions, methods, statements, etc.

## How to install
Use your favourite package manager and install [treesitter](https://github.com/nvim-treesitter/nvim-treesitter)
alongside this plugin. No configuration is required out of the box.
## Advanced usage
To customize the behavior use the setup function:
```lua
require('nvim_context_vt').setup({
-- Enable by default. You can disable and use :NvimContextVtToggle to maually enable.
-- Default: true
enabled = true,
-- Override default virtual text prefix
-- Default: '-->'
prefix = '',
-- Override the internal highlight group name
-- Default: 'ContextVt'
highlight = 'CustomContextVt',
-- Disable virtual text for given filetypes
-- Default: { 'markdown' }
disable_ft = { 'markdown' },
-- Disable display of virtual text below blocks for indentation based languages like Python
-- Default: false
disable_virtual_lines = false,
-- Same as above but only for spesific filetypes
-- Default: {}
disable_virtual_lines_ft = { 'yaml' },
-- How many lines required after starting position to show virtual text
-- Default: 1 (equals two lines total)
min_rows = 1,
-- Same as above but only for spesific filetypes
-- Default: {}
min_rows_ft = {},
-- Custom virtual text node parser callback
-- Default: nil
custom_parser = function(node, ft, opts)
local utils = require('nvim_context_vt.utils')
-- If you return `nil`, no virtual text will be displayed.
if node:type() == 'function' then
return nil
end
-- This is the standard text
return opts.prefix .. ' ' .. utils.get_node_text(node)[1]
end,
-- Custom node validator callback
-- Default: nil
custom_validator = function(node, ft, opts)
-- Internally a node is matched against min_rows and configured targets
local default_validator = require('nvim_context_vt.utils').default_validator
if default_validator(node, ft) then
-- Custom behaviour after using the internal validator
if node:type() == 'function' then
return false
end
end
return true
end,
-- Custom node virtual text resolver callback
-- Default: nil
custom_resolver = function(nodes, ft, opts)
-- By default the last node is used
return nodes[#nodes]
end,
})
```
## Commands
* `:NvimContextVtToggle` - Enable/disable context virtual text
## Debug
If you don't see the expected context vitual text, run `:NvimContextVtDebug` to print out the
context tree. Use this information to open a pull-request or an issue to add support.
## License
MIT