wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
18.09k stars 808 forks source link

When using Neovim in wezterm, there will be borders around it that cannot be filled. #5561

Open Thirdwinter opened 5 months ago

Thirdwinter commented 5 months ago

What Operating System(s) are you seeing this problem on?

Windows

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

wezterm 20240520-135708-b8f94c47

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

It's like this image

To Reproduce

No response

Configuration

Configurations that may be relevant I tried changing the configuration in it, but it didn't work well, at least one border couldn't be filled


   initial_cols = 108,
   initial_rows = 29,
   window_padding = {
      left = '5pt',
      right = '5pt',
      top = '5pt',
      bottom = '0pt',
   },

### Expected Behavior

Able to be fully filled

### Logs

_No response_

### Anything else?

_No response_
ekarious commented 5 months ago

I made a vim autocmd to remove then when I enter Neovim and add them back when I exit. Currently using AstroNvim but this can be converted easily to a normal nvim autocmds:

NOTE: You will need to put the window_padding on one line !

Note that I am currently using the sd command which is a cross-platform remplacement for the sed command available on unix systems as I'm am currently using Windows Powershell.

On VimEnter

{
    event = "VimEnter",
    desc = "Remove WezTerm padding when entering Neovim",
    group = "removeshellspaddings",
    command = ":silent !sd -F '{ left = 20, right = 20, top = 15, bottom = 15 }' '{ left = 0, right = 0, top = 0, bottom = 0 }' '<add your wezterm config file path here>'"
},

On VimLeavePre

{
    event = "VimLeavePre",
    desc = "Add WezTerm padding padding back when exiting Neovim",
    group = "addshellspaddings",
    command = ":silent !sd -F '{ left = 0, right = 0, top = 0, bottom = 0 }' '{ left = 20, right = 20, top = 15, bottom = 15 }' '<add your wezterm config file path here>'"
},

It could be way easier if wezterm could have a command with the wezterm CLI.

ekarious commented 5 months ago

With normal autocmds on neovim and using sed, it would probably look like this:

-- Commands when Vim start
vim.api.nvim_create_autocmd("VimEnter", {
  command = ":silent !sed -i -e 's/{ left = 20, right = 20, top = 15, bottom = 15 }/{ left = 0, right = 0, top = 0, bottom = 0 }/g' '<add your wezterm config file path here>'",
})

-- Commands when just before Vim exits
vim.api.nvim_create_autocmd("VimLeavePre", {
  command = ":silent !sed -i -e 's/{ left = 0, right = 0, top = 0, bottom = 0 }/{ left = 20, right = 20, top = 15, bottom = 15 }/g' '<add your wezterm config file path here>'",
})
Thirdwinter commented 5 months ago

Sorry, maybe I did something wrong and this didn't work. I also tried to directly change the padding of wezterm to 0, and then started neovim, but the bottom edge was still not filled.


return {
  -- Commands when Vim start
  vim.api.nvim_create_autocmd("VimEnter", {
    command = ":silent !sed -i -e 's/{ left = 5, right = 5, top = 5, bottom = 0 }/{ left = 0, right = 0, top = 0, bottom = 0 }/g' 'C:/Users/86136/.config/wezterm/config/appearance.lua'",
  }),

  -- Commands when just before Vim exits
  vim.api.nvim_create_autocmd("VimLeavePre", {
    command = ":silent !sed -i -e 's/{ left = 0, right = 0, top = 0, bottom = 0 }/{ left = 5, right = 5, top = 5, bottom = 0 }/g' 'C:/Users/86136/.config/wezterm/config/appearance.lua'",
  }),
}
Thirdwinter commented 5 months ago

I tried this approach and it worked, but there were still unfilled areas at the bottom and on the right.

vim.api.nvim_create_autocmd("VimEnter", {
  command = ":e C:/Users/86136/.config/wezterm/config/appearance.lua | %s/{ left = 5, right = 5, top = 5, bottom = 0 }/{ left = 0, right = 0, top = 0, bottom = 0 }/g | w",
})
vim.api.nvim_create_autocmd("VimLeavePre", {
  command = ":e C:/Users/86136/.config/wezterm/config/appearance.lua | %s/{ left = 0, right = 0, top = 0, bottom = 0 }/{ left = 5, right = 5, top = 5, bottom = 0 }/g | w",
})
ekarious commented 5 months ago

Then I do not know how to fix that. I never notice the gap in my instance of Neovim. Perhaps because I use a dark background.

We will need @wez knowledge for this one.

wez commented 5 months ago

I'm sorry to say that I don't understand the issue. From what you shared, you've configured padding on the edges that you've indicated with arrows in the image, so it looks how I'd expect.

There's not enough of a description of what you're trying, what you expect to see and what is happening here for me to understand the issue that you're having.

Thirdwinter commented 5 months ago

很抱歉,我不明白这个问题。从您分享的内容来看,您已在图像中用箭头指示的边缘配置了填充,因此看起来符合我的预期。

对于您正在尝试的操作、您希望看到的操作以及此处发生的情况,我没有足够的描述来了解您遇到的问题。

using neovim in wezterm just like this: image right and bottom can see background color ,not i want

and in wt using neovim: image

I think this is reasonable

akthe-at commented 5 months ago

@Thirdwinter are you using a tiling window manager that could be adding padding

akthe-at commented 5 months ago

Also, I forgot to ask if you played with config.line_height and font size variations?

Thirdwinter commented 5 months ago

@akthe-at These are not used. I tried setting line_height to 1.1, but that didn't have much effect.

local wezterm = require('wezterm')
local platform = require('utils.platform')

local font = 'Maple Mono Light'
local font_size = platform().is_win and 10 or 9

return {
   -- line_height = 1.1,
   font = wezterm.font(font),
   font_size = font_size,
   warn_about_missing_glyphs = false,
   freetype_load_target = 'Normal',
   freetype_render_target = 'Light',
}
haku527 commented 5 months ago

for Linux and macOS system, you can use bg.nvim by using ascii escape code to sync background color

set padding to 0 looks awful to me,so for windows system,i use neovide gui

haku527 commented 5 months ago

@Thirdwinter a workaround is just use the same color scheme

image

AtifChy commented 5 months ago

can i toggle wezterm opacity automatically using vim autocmd?

Thirdwinter commented 5 months ago

@AtifChy I think this is not a good solution. The solution I use now is to select a good-looking background image in wezterm, and then choose a theme with good transparency support in Neovim. Similar to this image And then, @wez I have to mention the transparency setting. I tried to test it on my friend's computer. The wezterm, configuration file, and operating system are the same. The only difference is the hardware. However, my low-end screen cannot display the transparency effect. Adjusting the transparency parameter can only darken the background.

Sakamitsu commented 1 month ago

There’s an approach without specifying the path to the wezterm configuration. It also works if for some reason nvim doesn't see the path or there is no way to use this solution (the tab title doesn't change in wsl when you open nvim). However, the bottom padding will still remain for me.

wezterm configuration

local padding = {
  left = '1cell',
  right = '1cell',
  top = '0.5cell',
  bottom = '0.5cell',
}

wezterm.on('user-var-changed', function(window, pane, name, value)
  if name == "NVIM_ENTER" then
    local overrides = window:get_config_overrides() or {}
    if value == "1" then
      overrides.window_padding = {
        left = 0,
        right = 0,
        top = 0,
        bottom = 0
      }
    else
      overrides.window_padding = padding
    end
    window:set_config_overrides(overrides)
  end
end)

neovim configuration

local autocmd = vim.api.nvim_create_autocmd

autocmd("VimEnter", {
  callback = function()
    --NVIM_ENTER=1
    vim.cmd([[call chansend(v:stderr, "\033]1337;SetUserVar=NVIM_ENTER=MQ==\007")]])
  end,
})

autocmd("VimLeavePre", {
  callback = function()
    --NVIM_ENTER=0
    vim.cmd([[call chansend(v:stderr, "\033]1337;SetUserVar=NVIM_ENTER=MA==\007")]])
  end,
})
abdelbk commented 1 week ago

@Sakamitsu Thank you ! It works great. For the bottom padding, it has to be Neovim's command prompt height.