Closed augustocdias closed 2 years ago
Hi @augustocdias,
I'm not entirely sure what you've done with Tokyo Night I'm unfamiliar with it, and it's highlighting. By default, this plugin should shade a terminal buffer. A user should not tamper with the winhighlight
it sets, or it will not work. It isn't setup to handle multiple different sources applying a window highlight. I've never encountered an issue like this before, so not sure what else to suggest. It sounds like you've added some custom config for highlighting the window, which I would recommend removing.
I didn't add anything. I was doing that to debug. It is what you do to darken the buffers and I was trying manually to try to debug the issue. I don't have any manual highlighting on my config. What I'm saying is that neither trouble nor toggleterm windows are being darkened as they should.
@augustocdias can you provide a minimal configuration that reproduces this issue. Based on what you've described, I don't know how to help, since I can't reproduce this issue on my end.
If you load this config you'll notice that the toggleterm terminal is not darkened
local on_windows = vim.loop.os_uname().version:match('Windows')
local function join_paths(...)
local path_sep = on_windows and '\\' or '/'
local result = table.concat({ ... }, path_sep)
return result
end
vim.cmd([[set runtimepath=$VIMRUNTIME]])
local temp_dir
if on_windows then
temp_dir = vim.loop.os_getenv('TEMP')
else
temp_dir = '/tmp'
end
local fn = vim.fn
vim.cmd('set packpath=' .. join_paths(temp_dir, 'nvim', 'site'))
local package_root = join_paths(temp_dir, 'nvim', 'site', 'pack')
local install_path = join_paths(package_root, 'packer', 'start', 'packer.nvim')
local compile_path = join_paths(install_path, 'plugin', 'packer_compiled.lua')
fn.system({
'git',
'clone',
'--depth',
'1',
'https://github.com/wbthomason/packer.nvim',
install_path,
})
require('packer').startup({
{
'wbthomason/packer.nvim',
'akinsho/toggleterm.nvim',
'folke/tokyonight.nvim',
},
config = {
package_root = package_root,
compile_path = compile_path,
},
})
require('packer').sync()
require('toggleterm').setup({
size = function(term)
if term.direction == 'horizontal' then
return 15
elseif term.direction == 'vertical' then
return vim.o.columns * 0.4
end
end,
hide_numbers = false,
shade_terminals = true,
start_in_insert = true,
insert_mappings = false, -- no default mapping
persist_size = true,
direction = 'horizontal',
close_on_exit = true,
shell = vim.o.shell,
float_opts = {
border = 'curved',
highlights = {
border = 'Normal',
background = 'Normal',
},
},
})
function _G.set_terminal_keymaps()
local opts = { noremap = true }
vim.api.nvim_buf_set_keymap(0, 't', '<Esc>', [[<C-\><C-n>]], opts)
vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[<C-\><C-n>]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
end
vim.cmd('autocmd! TermOpen term://*toggleterm#* lua set_terminal_keymaps()')
vim.g.tokyonight_hide_inactive_statusline = false
vim.g.tokyonight_sidebars = { 'terminal', 'toggleterm', 'packer', 'NvimTree', 'trouble' }
vim.g.tokyonight_transparent = true
vim.g.tokyonight_style = 'night'
vim.g.tokyonight_dark_sidebar = true
vim.g.tokyight_dark_float = true
-- when using onedark, uncomment line 48 and comment this
vim.cmd([[colorscheme tokyonight]])
vim.api.nvim_set_keymap('n', '<F3>', ':ToggleTerm<CR>', { noremap = true })
@augustocdias I haven't tried the config yet but looking at
vim.g.tokyonight_sidebars = { 'terminal', 'toggleterm', 'packer', 'NvimTree', 'trouble' }
vim.g.tokyonight_dark_sidebar = true
These settings at a glance do not seem like they will be compatible with this plugin maybe, looking briefly at tokyo night it seems that that setting is trying to do a similar thing to what my plugin is already doing so it's duplicating the work. I think you should remove toggleterm from tokyo night's config and only rely on the highlighting that toggleterm provides. I don't think/wouldn't expect having 2 different highlighting mechanisms to work.
Even removing it, it is not being darkened.
@augustocdias you have to also remove terminal from the sidebars list
Still with issues...
I'm really not sure what is going on then. If you disable tokyonight does toggleterm work correctly, in which case the problem is an interaction of both plugins. As I mentioned they are both trying to change the window highlight which will definitely break each other, so you need to turn off one plugins winhighlight or the other. You can disable shade terminals for this plugin and use whatever tokyonight does or you can find a way to disable tokyonights behaviour. Can you verify what winhighlight you get inside the toggleterm buffer using echo &winhighlight
and paste the result here.
This is the output of it with TokyoNight on:
Normal:DarkenedPanel,EndOfBuffer:DarkenedPanel,VertSplit:DarkenedPanel,StatusLine:DarkenedStatusline,StatusLineNC:DarkenedStatuslineNC,SignColumn:DarkenedPanel
This is without any theme:
Normal:DarkenedPanel,EndOfBuffer:DarkenedPanel,VertSplit:DarkenedPanel,StatusLine:DarkenedStatusline,StatusLineNC:DarkenedStatuslineNC,SignColumn:DarkenedPanel
As you can see both are the same
I still don't see it darkened...
I don't know if it is relevant, but I'm using neovim nightly and I've tested this in alacritty and in iTerm.
@augustocdias just to clarify does it work without tokyonight installed and secondly are you using termguicolors
?
It does not work even without Tokyo night or any theme installed and yes I'm using termguicolor
I disabled theshade_terminals
flag from toggleterm and it started to respect the option from the theme (which for me is what I want), but the default shading is not working anyway... I can help you investigate if you want, otherwise you can close the issue.
@augustocdias that's good that that works. Tbh I'm seeing shading on my end and I believe it's also working for other users so I'm happy to close this out since I think the most likely cause might be down to something about your setup/config. Since things are how you want it on your end, I'll close this out.
Yeah. Just a final note:
Tks for devoting your time on this plug-in. It is really helpful for me and improved a lot my workflow :) I love it.
Hi all! I'm trying to get it working but I can't find a way to darken toggleterm windows. If anybody has a working config, do you mind sharing the dots? Thanks!
@metalelf0 Just following the above instruction, turn off shade_terminals
in the toggleterm configuration and add toggleterm to vim.g.tokyonight_sidebars
.
first, toggle to open terminal then see it transparent. While you focus on another buffer then come back to term, it becomes dark.
I know this is old but for anyone who is running into this, this not a bug with toggleterm but rather a conflict with the way some themes (folke/tokyonight) handle backgrounds when they have transparency set to true
the real solution to avoid any jank with this theme specifically is to use:
local colors = require("tokyonight.colors").setup()
local toggleterm = require("toggleterm")
toggleterm.setup({
shade_terminals = false,
highlights = {
Normal = {
guibg = colors.bg_dark
}
}
})
No need to add toggleterm to sidebars or anything like that.
@TimothyCates very very very helpful, I never thought of just importing the color pallette (I'm using a different colorscheme but the same idea worked perfectly). It would be nice if toggleterm used its own custom highlight groups that other plugins could overwrite, but this works!
I'm using neovim 0.6 (HEAD) and somehow the background of toggleterm is not being darkened. Even though it is correctly "set".
I use TokyoNight theme and I configured toggleterm to act as a sidebar (which effectively makes the background darker) by setting the
winhighlight
. From what I could understand from toggleterm, it does the same.If I query this value when toggleterm is open it is set as expected but the colours are not being respected. If I call the
setlocal
manually with it open, the window will be darkened as expected.I suspect this is something to do with the way the windows is created/opened, because I'm having the same issue with trouble, but not with NvimTree.