talbergs / context.nvim

Show code context

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nvim-treesitter-context

Lightweight alternative to context.vim implemented with nvim-treesitter.

Install

Plug 'nvim-treesitter/nvim-treesitter'
Plug 'romgrk/nvim-treesitter-context'

Screenshot

theme

Notes

This plugins uses the new neovim WinScrolled event when available to update its context window. Make sure to have a recent neovim build to get this behavior. The fallback behavior is to update its content on CursorMoved.

Configuration

(Default values are shown below)

require'treesitter-context'.setup{
    enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
    throttle = true, -- Throttles plugin updates (may improve performance)
    max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
    patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries.
        -- For all filetypes
        -- Note that setting an entry here replaces all other patterns for this entry.
        -- By setting the 'default' entry below, you can control which nodes you want to
        -- appear in the context window.
        default = {
            'class',
            'function',
            'method',
            -- 'for', -- These won't appear in the context
            -- 'while',
            -- 'if',
            -- 'switch',
            -- 'case',
        },
        -- Example for a specific filetype.
        -- If a pattern is missing, *open a PR* so everyone can benefit.
        --   rust = {
        --       'impl_item',
        --   },
    },
    exact_patterns = {
        -- Example for a specific filetype with Lua patterns
        -- Treat patterns.rust as a Lua pattern (i.e "^impl_item$" will
        -- exactly match "impl_item" only)
        -- rust = true, 
    }
}

Commands

TSContextEnable, TSContextDisable and TSContextToggle.

Appearance

Use the highlight group TreesitterContext to change the colors of the context. Per default it links to NormalFloat.

About

Show code context

License:MIT License


Languages

Language:Lua 99.7%Language:Vim Script 0.2%Language:Makefile 0.1%