Skip to content

๐ŸŒ… Twilight is a Lua plugin for Neovim 0.5 that dims inactive portions of the code you're editing using TreeSitter.

License

Notifications You must be signed in to change notification settings

zhengpd/twilight.nvim

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

30 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒ… Twilight

Twilight is a Lua plugin for Neovim 0.5 that dims inactive portions of the code you're editing.

The plugin was heavily inspired by Limelight, but uses TreeSitter for better dimming.

Pairs well with zen-mode.

image

โšก๏ธ Requirements

  • Neovim >= 0.5.0

๐Ÿ“ฆ Installation

Install the plugin with your preferred package manager:

-- Lua
use {
  "folke/twilight.nvim",
  config = function()
    require("twilight").setup {
      -- your configuration comes here
      -- or leave it empty to use the default settings
      -- refer to the configuration section below
    }
  end
}
" Vim Script
Plug 'folke/twilight.nvim'

lua << EOF
  require("twilight").setup {
    -- your configuration comes here
    -- or leave it empty to use the default settings
    -- refer to the configuration section below
  }
EOF

โš™๏ธ Configuration

Twilight comes with the following defaults:

{
  dimming = {
    alpha = 0.25, -- amount of dimming
    -- we try to get the foreground from the highlight groups or fallback color
    color = { "Normal", "#ffffff" },
    term_bg = "#000000", -- if guibg=NONE, this will be used to calculate text color
    inactive = false, -- when true, other windows will be fully dimmed (unless they contain the same buffer)
  },
  context = 10, -- amount of lines we will try to show around the current line
  treesitter = true, -- use treesitter when available for the filetype
  -- treesitter is used to automatically expand the visible text,
  -- but you can further control the types of nodes that should always be fully expanded
  expand = { -- for treesitter, we we always try to expand to the top-most ancestor with these types
    "function",
    "method",
    "table",
    "if_statement",
  },
  expand_opts = {
    -- only expand to minimal scope of nodes in "expand" option
    minimal_scope = false
  },
  exclude = {}, -- exclude these filetypes
}

๐Ÿš€ Usage

You can manually trigger Twilight using the commands:

  • Twilight: toggle twilight
  • TwilightEnable: enable twilight
  • TwilightDisable: disable twilight

๐Ÿง˜ Zen Mode Integration

If you have zen-mode installed, then Twilight is activated automatically. Refer to the Zen Mode documentation to disable.

About

๐ŸŒ… Twilight is a Lua plugin for Neovim 0.5 that dims inactive portions of the code you're editing using TreeSitter.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 97.5%
  • Vim Script 2.5%