loctvl842 / monokai-pro.nvim

Monokai Pro theme for Neovim written in Lua, with multiple filters: Pro, Classic, Machine, Octagon, Ristretto, Spectrum
MIT License
424 stars 40 forks source link

Adding the 'background_clear' option for bufferline results in errors. #117

Open 0xF5T9 opened 5 months ago

0xF5T9 commented 5 months ago

I copied the example configurations to my .lua file it it worked fine.

-- ...
transparent_background = true, -- I want transparent background
background_clear = {
    -- "float_win",
    "toggleterm",
    "telescope",
    -- "which-key",
    "renamer",
    "notify",
    -- "nvim-tree",
    -- "neo-tree",
    -- "bufferline", -- better used if background of `neo-tree` or `nvim-tree` is cleared
  },
-- ...

Then I uncommented nvim-tree and neo-tree, and it worked. My nvim tree is now transparent.

-- ...
transparent_background = true, -- I want transparent background
background_clear = {
    -- "float_win",
    "toggleterm",
    "telescope",
    -- "which-key",
    "renamer",
    "notify",
    "nvim-tree",
    "neo-tree",
    -- "bufferline", -- better used if background of `neo-tree` or `nvim-tree` is cleared
  },
-- ...

I tried the same with bufferline, but it resulted in errors.

-- ...
transparent_background = true, -- I want transparent background
background_clear = {
    -- "float_win",
    "toggleterm",
    "telescope",
    -- "which-key",
    "renamer",
    "notify",
    "nvim-tree",
    "neo-tree",
    "bufferline", -- errors on nvim open
  },
-- ...

image

I'm new to Vim and trying to get a monokai-pro-themed neovim with transparent backgrounds.

0xF5T9 commented 5 months ago

Also, when I configure the bufferline tab style to slope, the tab indicator has a weird white color, which doesn't happen with the buffers (on the left). This only happen when I enable the transparent option. I'm not sure if these are bugs or I am doing something wrong. If anyone know please light me.

image

loctvl842 commented 4 months ago

Can I have an overview of your neovim configuration? May be it's easier for me to debug from yours. @0xF5T9

0xF5T9 commented 4 months ago

Can I have an overview of your neovim configuration? May be it's easier for me to debug from yours. @0xF5T9

I'm using LazyVim. I'm sure I've installed LazyVim successfully without any errors. Then I created ui.lua file in nvim\lua\plugins, which will be automatically loaded by LazyVim. Here is my current ui.lua. It has already omitted the background_clear option, otherwise it will throw the above errors.

local configs = {}

-- Specifies whether to install monokai-pro
-- https://github.com/loctvl842/monokai-pro.nvim
local install_monokai_pro = true -- *
if install_monokai_pro then
    local monokai_pro_config = {
        -- Install monokai-pro colorscheme
        {
            "loctvl842/monokai-pro.nvim",
            opts = {
                transparent_background = true,
                terminal_colors = true,
                devicons = true, -- highlight the icons of `nvim-web-devicons`
                styles = {
                    comment = { italic = true },
                    keyword = { italic = true },       -- any other keyword
                    type = { italic = true },          -- (preferred) int, long, char, etc
                    storageclass = { italic = true },  -- static, register, volatile, etc
                    structure = { italic = true },     -- struct, union, enum, etc
                    parameter = { italic = true },     -- parameter pass in function
                    annotation = { italic = true },
                    tag_attribute = { italic = true }, -- attribute of tag in reactjs
                },
                filter = "pro",                        -- classic | octagon | pro | machine | ristretto | spectrum
                -- Enable this will disable filter option
                day_night = {
                    enable = false,            -- turn off by default
                    day_filter = "pro",        -- classic | octagon | pro | machine | ristretto | spectrum
                    night_filter = "spectrum", -- classic | octagon | pro | machine | ristretto | spectrum
                },
                inc_search = "background",     -- underline | background
                plugins = {
                    bufferline = {
                        underline_selected = false,
                        underline_visible = false,
                    },
                    indent_blankline = {
                        context_highlight = "default", -- default | pro
                        context_start_underline = false,
                    },
                },
            },
        },
    }
    table.insert(configs, monokai_pro_config)
end

-- Bufferline configurations
local bufferline_module = require("bufferline")
if bufferline_module then
    vim.opt.termguicolors = true
    local bufferline_config = {
        "akinsho/bufferline.nvim",
        opts = {
            options = {
                separator_style = "slope", -- Change tab style

                -- Hide powershell terminal buffer by default
                custom_filter = function(buf_number, buf_numbers)
                    if string.find(vim.fn.bufname(buf_number), "powershell.exe") then
                        return false
                    end

                    return true
                end,
            },
        },
    }
    table.insert(configs, bufferline_config)
end

return configs

My init.lua

require("config.lazy") -- bootstrap lazy.nvim, LazyVim and your plugins

-- Set monokai-pro colorscheme
if require("monokai-pro") then
    vim.cmd([[colorscheme monokai-pro]])
end

-- Configure terminal shell to PowerShell
vim.o.shell = "powershell.exe"
vim.o.shellxquote = ""
vim.o.shellcmdflag = "-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command "
vim.o.shellquote = ""
vim.o.shellpipe = "| Out-File -Encoding UTF8 %s"
vim.o.shellredir = "| Out-File -Encoding UTF8 %s"
vim.o.guifont = "JetBrainsMono Nerd Font Mono:h12"

vim.cmd("set nornu")        -- Disable relative line number
vim.cmd("set tabstop=4")    -- Set tabstop
vim.cmd("set shiftwidth=4") -- Set shiftwidth
vim.cmd("set expandtab")    -- Use space instead of tab characters
loctvl842 commented 4 months ago

I have just fixed this problem and added new highlight groups for the tabs. Please update the latest release and give me a feedback. I really recommend not using transparent_background

0xF5T9 commented 4 months ago

I have just fixed this problem and added new highlight groups for the tabs. Please update the latest release and give me a feedback. I really recommend not using transparent_background

Hi, thanks for the update. adding 'background_clear' for bufferline no longer crash nvim but it looks like this: image

I've decided to give up on transparent backgrounds, but then I found this plugin. To my surprise, it worked nicely with the theme. It looks exactly how I wanted: image

There's only 1 minor artifact though, I don't know what this part is called, but it does not fit well with bufferline slope style. image

Anyway, it looks almost perfect now, and I am satisfied. Here is my current lua file, if it helps.

local configs = {}

-- Specifies whether to install monokai-pro
-- https://github.com/loctvl842/monokai-pro.nvim
local install_monokai_pro = true -- *
if install_monokai_pro then
    local monokai_pro_config = {
        -- Transparent
        {
            "xiyaowong/transparent.nvim",
            opts = {
                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
            },
        },
        -- Install monokai-pro colorscheme
        {
            "loctvl842/monokai-pro.nvim",
            opts = {
                transparent_background = false,
                terminal_colors = true,
                devicons = true, -- highlight the icons of `nvim-web-devicons`
                styles = {
                    comment = { italic = true },
                    keyword = { italic = true },       -- any other keyword
                    type = { italic = true },          -- (preferred) int, long, char, etc
                    storageclass = { italic = true },  -- static, register, volatile, etc
                    structure = { italic = true },     -- struct, union, enum, etc
                    parameter = { italic = true },     -- parameter pass in function
                    annotation = { italic = true },
                    tag_attribute = { italic = true }, -- attribute of tag in reactjs
                },
                filter = "pro",                        -- classic | octagon | pro | machine | ristretto | spectrum
                -- Enable this will disable filter option
                day_night = {
                    enable = false,            -- turn off by default
                    day_filter = "pro",        -- classic | octagon | pro | machine | ristretto | spectrum
                    night_filter = "spectrum", -- classic | octagon | pro | machine | ristretto | spectrum
                },
                inc_search = "background",     -- underline | background
                plugins = {
                    bufferline = {
                        underline_selected = false,
                        underline_visible = false,
                    },
                    indent_blankline = {
                        context_highlight = "default", -- default | pro
                        context_start_underline = false,
                    },
                },
            },
        },
    }
    table.insert(configs, monokai_pro_config)
end

-- Bufferline configurations
local bufferline_module = require("bufferline")
if bufferline_module then
    vim.opt.termguicolors = true
    local bufferline_config = {
        "akinsho/bufferline.nvim",
        opts = {
            options = {
                separator_style = "slope", -- Change tab style

                -- Hide powershell terminal buffer by default
                custom_filter = function(buf_number, buf_numbers)
                    if string.find(vim.fn.bufname(buf_number), "powershell.exe") then
                        return false
                    end

                    return true
                end,
            },
        },
    }
    table.insert(configs, bufferline_config)
end

return configs