Coder Social home page Coder Social logo

transparent.nvim's Introduction

transparent.nvim

Remove all background colors to make nvim transparent.

demo


Installation

xiyaowong/transparent.nvim

Same as other normal plugins, use your favourite plugin manager to install.

NOTE:
It is recommended not to lazy load this plugin to avoid some strange phenomena.
The execution of each function in the plugin is very fast and the time consumption can be ignored.

Usage

All available options:

require("transparent").setup({ -- Optional, you don't have to run setup.
  groups = { -- table: default groups
    'Normal', 'NormalNC', 'Comment', 'Constant', 'Special', 'Identifier',
    'Statement', 'PreProc', 'Type', 'Underlined', 'Todo', 'String', 'Function',
    'Conditional', 'Repeat', 'Operator', 'Structure', 'LineNr', 'NonText',
    'SignColumn', 'CursorLine', 'CursorLineNr', 'StatusLine', 'StatusLineNC',
    'EndOfBuffer',
  },
  extra_groups = {}, -- table: additional groups that should be cleared
  exclude_groups = {}, -- table: groups you don't want to clear
})

Normally, you don't need to call setup. There are two better ways for configuration.

g:transparent_groups

Add additional highlight groups by explicitly assigning the variable g:transparent_groups.

For example, if you want to add group ExtraGroup, you can do it like this:

vim.g.transparent_groups = vim.list_extend(vim.g.transparent_groups or {}, { "ExtraGroup" })
-- vimscript: let g:transparent_groups = extend(get(g:, 'transparent_groups', []), ["ExtraGroup"])

You can execute this statement anywhere and as many times as you want, without worrying about whether the plugin has already been loaded or not.

Here is an example about akinsho/bufferline.nvim. Simply copy it and paste it after initializing bufferline in your configuration.

vim.g.transparent_groups = vim.list_extend(
  vim.g.transparent_groups or {},
  vim.tbl_map(function(v)
    return v.hl_group
  end, vim.tbl_values(require('bufferline.config').highlights))
)

clear_prefix

Some plugins define highlights dynamically, especially the highlights of icons. e.g. BufferLineDevIcon*, lualine_*_DevIcon*.

So, this plugin provide a helper function clear_prefix. It will clear all highlight groups starting with the prefix.

For some plugins of ui, you would like to clear all highlights. At this point you should use clear_prefix.

e.g.

  • akinsho/bufferline.nvim
require('transparent').clear_prefix('BufferLine')
  • nvim-neo-tree/neo-tree.nvim
require('transparent').clear_prefix('NeoTree')
  • nvim-lualine/lualine.nvim
require('transparent').clear_prefix('lualine')

This plugin will provide a global variable: g:transparent_enabled(lua: vim.g.transparent_enabled)

Some plugins or themes support setting transparency, and you can use this variable as a flag.
eg: require("tokyonight").setup{ transparent = vim.g.transparent_enabled }

NOTE: The plugin will cache and automatically apply transparency settings, so you only need to call the following command.

FAQ

How to enable transparent for plugin panels?

You can try adding this highlight group to the options:

{
  extra_groups = {
    "NormalFloat", -- plugins which have float panel such as Lazy, Mason, LspInfo
    "NvimTreeNormal" -- NvimTree
  },
}

Floating windows?

It is not recommended to set the floating window to be transparent, it will become very weird, and everything will be mixed together.

For more information: https://github.com/xiyaowong/transparent.nvim/issues?q=label%3A%22float+window%22+sort%3Aupdated-desc

Commands

:TransparentEnable
:TransparentDisable
:TransparentToggle

Migration Guide 2023/3/20

  1. remove enable=true in your config.

  2. start Neovim

  3. Run :TransparentEnable

It's done, the status of enable will cached and the transparent effect is applyed on you neovim, enjoy :)

Aknowledgement

vim-transparent

transparent.nvim's People

Contributors

xiyaowong avatar akring avatar utx0 avatar ansidev avatar yodaembedding avatar acehinnnqru avatar graves501 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.