helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.72k stars 2.51k forks source link

Weird highlight of space when using tmux with helix #11772

Closed HernandoR closed 1 month ago

HernandoR commented 1 month ago

while using tmux with helix, it seems highliging space chars. image

vim with tmux is fine: image

helix outside of tmux is fine image

my tmux config is as follows i dont identify any thing relating to space display. hoping anyone can point a direction

#==========================================
# URL: https://github.com/HernandoR/k-tmux
# Author:  HernandoR
# Version: 0.1.2
# Email: lzhen.cn@outlook.com
# ReadMe: README.md
# Donation: NA
# Last_modify: 2023-09-16
#==========================================
# URL: https://github.com/wklken/k-tmux
# Author:  wklken
# Version: 0.1.1
# Email: wklken@yeah.net
# ReadMe: README.md
# Donation: http://www.wklken.me/pages/donation.html
# Last_modify: 2015-08-06
#==========================================
# Dependecny:
#    1. brew install reattach-to-user-namespace
#    2. gem install tmuxinator
#    3. vim: christoomey/vim-tmux-navigator

#--------------------------- base config begin -------------------------------

# 全局设置
setw -g xterm-keys on
# Using set -gq instead of set -g will silence the unknown option error, while still setting it on old versions of tmux
set -gq status-utf8 on                             # enable utf-8
# set-option -g default-terminal "screen-256color"  # use 256 colors
set-option -sa terminal-overrides ",xterm*:Tc"

set-option -g history-limit 100000                # scrollback buffer n lines
set-option -g display-time 5000                   # 提示信息的持续时间;设置足够的时间以避免看不清提示,单位为毫秒
set-option -g repeat-time 1000                    # 控制台激活后的持续时间;设置合适的时间以避免每次操作都要先激活控制台,单位为毫秒
set-option -sg escape-time 10                     # nvim advice
set-option -g focus-events on                     # nvim advice
set-window-option -g display-panes-time 3000
set-option -g renumber-windows on                 # window 0, 1, 2, remove 1, renumber to 0, 1

# Set window notifications
setw -g monitor-activity on
set -g visual-activity on

# use C-a, since it's on the home row and easier to hit than C-b
set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix
# make `ctrl+a ctrl+a` to move to beginning of the line
bind a send-prefix

# bind a reload key: prefix+r
bind R source-file ~/.tmux.conf \; display-message "Config reloaded.."

# -------------------------------- session begin --------------------------------
bind -r ( switch-client -p
bind -r ) switch-client -n
# -------------------------------- session end --------------------------------

# -------------------------------- window begin --------------------------------
set-option -g base-index 1                        #窗口的初始序号;默认为0,这里设置为1

set-window-option -g pane-base-index 1            # panes index start at 1, setw means set-window-option
set-window-option -g other-pane-height 25
set-window-option -g other-pane-width 80

# [prefix-c] 创建新窗口
bind-key c new-window -c "#{pane_current_path}" -c "#{pane_current_path}"
# [prefix-数字] 切换窗口
# [prefix-p] 切换窗口

# [prefix-t/T] 切换窗口
bind-key t next-window
bind-key T previous-window
bind-key N previous-window
# bind-key space next-window
# bind-key bspace previous-window

# [prefix-Ctrl-o] 窗口轮转
bind-key C-o rotate-window

# -------------------------------- window end --------------------------------

# -------------------------------- pane begin --------------------------------
# use vim-like keys for splits and windows
# v / s 竖直、水平分割window为pane
unbind '"'
unbind %
# 窗口切割  split windows like vim.  - Note: vim's definition of a horizontal/vertical split is reversed from tmux's
# [prefix-v] / [prefix-s] 垂直/水平分割窗口
# bind-key v split-window -h -c "#{pane_current_path}"
# bind-key s split-window -v -c "#{pane_current_path}"

# key bindings for horizontal and vertical panes
# 键 [\|] 和 [_-] 少敲一个shift键
bind-key \\ split-window -h -c "#{pane_current_path}"
bind-key - split-window -v -c "#{pane_current_path}"

# 窗口间切换
# [prefix-hjkl] pane之间移动
unbind-key h
bind-key -r h select-pane -L
unbind-key j
bind-key -r j select-pane -D
unbind-key k
bind-key -r k select-pane -U
unbind-key l
bind-key -r l select-pane -R
# smart pane switching with awareness of vim splits
# [Ctrl-hjkl] pane之间移动
bind -r -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-h) || tmux select-pane -L"
bind -r -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-j) || tmux select-pane -D"
bind -r -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-k) || tmux select-pane -U"
bind -r -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys C-l) || tmux select-pane -R"
# [Ctrl-l] 左右两个切  [Ctrl-\] 最近的两个切换
bind -r -n C-\\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)(vim|vi)$' && tmux send-keys 'C-\\') || tmux select-pane -l"
bind C-l send-keys 'C-l'

# [prefix-q] 展示窗口数字并选择跳转
bind-key q display-panes
# bind-key a last-pane # 绑什么好?

# 窗口大小调整
# resize panes using PREFIX H, J, K, L
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

# layout
# [prefix-space]
# bind-key + select-layout main-horizontal
# bind-key = select-layout main-vertical

# -------------------------------- pane end --------------------------------

# -------------------------------- move/copy/paste begin --------------------------------
# use vi mode
# vi is good  把 Tmux 设为 vi 模式,使其与 Vim 的操作更加接近
setw -g mode-keys vi

set -s set-clipboard on

# [ 进入复制,space键开始选择问题  方向键移动, / 回车复制  / ] 黏贴
bind-key [ copy-mode
bind-key ] run " tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"

# Copy and paste like in vim
# p 换成paste
unbind p
bind p run " tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"
bind -n C-v run " tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"

# the following vi-copy bindings match my vim settings
#   see https://github.com/gpakosz/.vim.git
# Setup 'v' to begin selection as in Vim
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle

bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel " tmux save-buffer - | xclip -i -sel clipboard"
bind-key -T copy-mode-vi Escape send-keys -X cancel
bind-key -T copy-mode-vi H send-keys -X start-of-line
bind-key -T copy-mode-vi L send-keys -X end-of-line

# Update default binding of `Enter` to also use copy-pipe
unbind-key -T copy-mode-vi Enter
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel " tmux save-buffer - | xclip -i -sel clipboard"
# bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel " tmux save-buffer - | xclip -i -sel clipboard"

# for osx
# Enable native Mac OS X copy/paste  对于mac用户,可以复制到系统剪贴板
set-option -g default-command "/bin/bash -c 'which reattach-to-user-namespace >/dev/null && exec reattach-to-user-namespace $SHELL -l || exec $SHELL -l'"
# -------------------------------- move/copy/paste end --------------------------------

# -------------------------------- mouse begin --------------------------------
# mouse behavior
# Using set -gq instead of set -g will silence the unknown option error, while still setting it on old versions of tmux
#setw -gq mode-mouse on
#set -gq mouse-select-pane on
#set -gq mouse-resize-pane on
#set -gq mouse-select-window on

# luice: after tmux 2.1, the mouse mode changed into:
set-option -g mouse on
# -------------------------------- mouse end --------------------------------

# -------------------------------- status line begin  --------------------------------
# 颜色
# set-option -g status-bg black
# set-option -g status-fg white

set -g status-bg '#4e4e4e'
set -g status-fg '#bbbbbb'
set -g status-left-style fg='#bbbbbb'
set -g status-left-style bg='#4e4e4e'
set -g status-right-style fg='#bbbbbb'
set -g status-right-style bg='#4e4e4e'

set -g status-left-length 90
set -g status-right-length 60

# 对齐方式
set-option -g status-justify centre

# 左下角
# set-option -g status-left '#[bg=black,fg=green][#[fg=cyan]#S#[fg=green]]'
set-option -g status-left "S-#S:W-#I:P-#P"

# 窗口列表
setw -g automatic-rename on
# set-window-option -g window-status-current-fg magenta
set-window-option -g window-status-format '#[dim]#I:#[dim]#W#[fg=grey,dim]'
set-window-option -g window-status-current-format '[#[fg=white,bold]#I#[fg=white,bold]:#[fg=white,bold]#W#[fg=dim]]'

# 右下角
set -g status-right '#[fg=green][#[fg=white]%m-%d %H:%M#[fg=green]]'

# -------------------------------- status line end --------------------------------
# -------------------------------- color begin --------------------------------

# pane border colors
set-option -g pane-active-border-style fg='#55ff55'
set-option -g pane-border-style fg='#555555'
# set -g pane-border-fg colour245
# set -g pane-active-border-fg colour39

# -------------------------------- color end --------------------------------

#--------------------------- base config end -------------------------------
b52es commented 1 month ago

I think it's not a Helix issue. My tmux.conf includes this:

set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"

And that's OK.