是否可以为CtrlP插件的弹出窗口设置单独的颜色方案?

 花痴-耐你们_304 发布于 2022-12-04 12:00

认为这是我第一次遇到vimscript,我检查了插件代码.它有以下几行代码:

fu! ctrlp#init(type, ...)
    if exists('s:init') || s:iscmdwin() | retu | en
    let [s:ermsg, v:errmsg] = [v:errmsg, '']
    let [s:matches, s:init] = [1, 1]
    cal s:Reset(a:0 ? a:1 : {})
    noa cal s:Open()
    cal s:SetWD(a:0 ? a:1 : {})
    gal s:MapNorms()
    cal s:MapSpecs()
    cal ctrlp#syntax()
    cal ctrlp#setlines(s:settype(a:type))
    cal s:SetDefTxt()
    cal s:BuildPrompt(1)
    if s:keyloop | cal s:KeyLoop() | en
endf

如果我colorscheme atom在函数中放置或类似的东西,它会改变整个缓冲区的颜色方案,而不是只改变弹出窗口的颜色方案.有没有办法配置CtrlP使用单独的配色方案?当然,我并不打算将配置放到插件代码中,因此我也在寻找一种解决方案,使我可以将设置放入我的设置中.vimrc,例如使用autocmd.

1 个回答
  • +1查看源代码并实际尝试一些东西.

    -1不看插件的文档:

    Highlighting:~
    * For the CtrlP buffer:
        CtrlPNoEntries : the message when no match is found (Error)
        CtrlPMatch     : the matched pattern (Identifier)
        CtrlPLinePre   : the line prefix '>' in the match window
        CtrlPPrtBase   : the prompt's base (Comment)
        CtrlPPrtText   : the prompt's text (|hl-Normal|)
        CtrlPPrtCursor : the prompt's cursor when moving over the text (Constant)
    
    * In extensions:
        CtrlPTabExtra  : the part of each line that's not matched against (Comment)
        CtrlPBufName   : the buffer name an entry belongs to (|hl-Directory|)
        CtrlPTagKind   : the kind of the tag in buffer-tag mode (|hl-Title|)
        CtrlPqfLineCol : the line and column numbers in quickfix mode (Comment)
        CtrlPUndoT     : the elapsed time in undo mode (|hl-Directory|)
        CtrlPUndoBr    : the square brackets [] in undo mode (Comment)
        CtrlPUndoNr    : the undo number inside [] in undo mode (String)
        CtrlPUndoSv    : the point where the file was saved (Comment)
        CtrlPUndoPo    : the current position in the undo tree (|hl-Title|)
        CtrlPBookmark  : the name of the bookmark (Identifier)
    
    Statuslines:~
    * Highlight groups:
        CtrlPMode1 : 'file' or 'path' or 'line', and the current mode (Character)
        CtrlPMode2 : 'prt' or 'win', 'regex', the working directory (|hl-LineNr|)
        CtrlPStats : the scanning status (Function)
    

    编辑

    看看你最喜欢的colorscheme,如果写得很好,你应该找到一堆看起来像这样的线:

    hi Whatever ctermbg=235 ctermfg=250 guibg=#262626 guifg=#bcbcbc cterm=NONE gui=NONE
    

    你需要做的很简单:

      复制其中一条线,

      将突出显示组名称更改WhateverCtrlPNoEntries,

      调整颜色值以适合您的口味,

      重复.

    如果您希望您的colorscheme是独立的,您需要在一个单独的文件中定义所有这些CtrlP高亮,这些文件将像任何其他插件一样加载,但在启动过程的后期:

    ~/.vim/after/plugin/mycolorscheme.vim
    

    2022-12-11 02:58 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有