You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NeoVim:仅在活动窗格显示cursorline,规避插件输入框异常显示

解决Telescope输入框显示cursorline的问题

方案一:针对Telescope文件类型单独设置

修改原有的CursorLine自动命令组,添加针对TelescopePrompt文件类型的规则,直接关闭该类型缓冲区的cursorline:

augroup CursorLine
    au!
    au VimEnter,WinEnter,BufWinEnter * setlocal cursorline
    au WinLeave * setlocal nocursorline
    " 关闭Telescope输入框的cursorline
    au FileType TelescopePrompt setlocal nocursorline
augroup END

方案二:仅在普通缓冲区开启cursorline(更通用)

通过判断缓冲区类型(&buftype),只在普通文件缓冲区(非prompt、help、quickfix等特殊窗口)开启cursorline,从根源避免插件窗口触发cursorline:

augroup CursorLine
    au!
    au VimEnter,WinEnter,BufWinEnter * if &buftype ==# '' | setlocal cursorline | endif
    au WinLeave * setlocal nocursorline
augroup END

为什么之前的配置无效?

你之前尝试的autocmd VimEnter,WinEnter,BufWinEnter Telescope* setlocal nocursorline无效,是因为Telescope的输入框窗口在触发WinEnter事件时,缓冲区的文件名或文件类型可能还未完成初始化,导致匹配规则无法命中。而FileType事件是在缓冲区的文件类型被明确设置后才触发,能精准匹配到Telescope的输入框;通过&buftype判断则是更通用的方式,覆盖所有特殊类型的窗口。

内容的提问来源于stack exchange,提问作者Minmin Khant

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 07:35:23