2

I successfully installed CoC in my Vim to have some code-suggestions/completions while coding in Rust.

It works fine, but I want to change the color and basic looks of the suggestion box.

I tried achieving this by editing the JSON file that's opened after executing :CocConfig. This is it's content:

{
    "suggest.completionItemKindLabels": {
        "keyword": "\u0000",
        "variable": "\ue79b",
        "value": "\uf89f",
        "operator": "\u03a8",
        "function": "\u0192",
        "reference": "\ufa46",
        "constant": "\uf8fe",
        "method": "\uf09a",
        "struct": "\ufb44",
        "class": "\uf0e8",
        "interface": "\uf417",
        "text": "\ue612",
        "enum": "\uf435",
        "enumMember": "\uf02b",
        "module": "\uf40d",
        "color": "\u0000",
        "property": "\ue624",
        "field": "\uf9be",
        "unit": "\uf475",
        "event": "\ufacd",
        "file": "\uf723",
        "folder": "\uf114",
        "snippet": "\ue60b",
        "typeParameter": "\uf728",
        "default": "\u0000"
    }
}

I tried to change the color of the suggestion-box with that code as a test, but nothing has changed (even after restarting Vim).

Am I doing something wrong?

Edit: vimrc file after suggestion Maxim Kim:

set nocompatible
" Initialisation de pathogen
call pathogen#infect()
call pathogen#helptags()

set number
set tabstop=4
set shiftwidth=4
set expandtab
set smartindent
set autoindent

filetype plugin indent on
syntax on
runtime! config/**/*.vim

autocmd VimEnter * NERDTree
autocmd BufWinEnter * NERDTreeMirror
"autocmd BufWinEnter * NERDTreeMinor

set guifont=Source\ Code\ Pro\ SemiBold:h16

let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
set laststatus=2

let g:airline_powerline_fonts = 1
let g:airline_theme='minimalist'

colorscheme afterglow


set guioptions-=r  "remove right-hand scroll bar
set guioptions-=L

set scrolloff=5


"nnoremap <ScrollWheelUp> k
"nnoremap <ScrollWheelDown> j

autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif


"OMNISHARP C# CONFIG
"" Use the vim-plug plugin manager: https://github.com/junegunn/vim-plug
" Remember to run :PlugInstall when loading this vimrc for the first time, so
" vim-plug downloads the plugins listed.
silent! if plug#begin('~/.vim/plugged')
Plug 'OmniSharp/omnisharp-vim'
Plug 'w0rp/ale'
call plug#end()
endif

" Note: this is required for the plugin to work
filetype plugin indent on

" Use the stdio OmniSharp-roslyn server
let g:OmniSharp_server_stdio = 1

" Set the type lookup function to use the preview window instead of echoing it
"let g:OmniSharp_typeLookupInPreview = 1

" Timeout in seconds to wait for a response from the server
let g:OmniSharp_timeout = 5

" Don't autoselect first omnicomplete option, show options even if there is only
" one (so the preview documentation is accessible). Remove 'preview' if you
" don't want to see any documentation whatsoever.
set completeopt=longest,menuone,preview

" Fetch full documentation during omnicomplete requests.
" By default, only Type/Method signatures are fetched. Full documentation can
" still be fetched when you need it with the :OmniSharpDocumentation command.
"let g:omnicomplete_fetch_full_documentation = 1

" Set desired preview window height for viewing documentation.
" You might also want to look at the echodoc plugin.
set previewheight=5

" Tell ALE to use OmniSharp for linting C# files, and no other linters.
let g:ale_linters = { 'cs': ['OmniSharp'] }

" Update semantic highlighting after all text changes
let g:OmniSharp_highlight_types = 3
" Update semantic highlighting on BufEnter and InsertLeave
" let g:OmniSharp_highlight_types = 2

augroup omnisharp_commands
    autocmd!

    " Show type information automatically when the cursor stops moving
    autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation()

    " The following commands are contextual, based on the cursor position.
    autocmd FileType cs nnoremap <buffer> gd :OmniSharpGotoDefinition<CR>
    autocmd FileType cs nnoremap <buffer> <Leader>fi :OmniSharpFindImplementations<CR>
    autocmd FileType cs nnoremap <buffer> <Leader>fs :OmniSharpFindSymbol<CR>
    autocmd FileType cs nnoremap <buffer> <Leader>fu :OmniSharpFindUsages<CR>

    " Finds members in the current buffer
    autocmd FileType cs nnoremap <buffer> <Leader>fm :OmniSharpFindMembers<CR>

    autocmd FileType cs nnoremap <buffer> <Leader>fx :OmniSharpFixUsings<CR>
    autocmd FileType cs nnoremap <buffer> <Leader>tt :OmniSharpTypeLookup<CR>
    autocmd FileType cs nnoremap <buffer> <Leader>dc :OmniSharpDocumentation<CR>
    autocmd FileType cs nnoremap <buffer> <C-\> :OmniSharpSignatureHelp<CR>
    autocmd FileType cs inoremap <buffer> <C-\> <C-o>:OmniSharpSignatureHelp<CR>

    " Navigate up and down by method/property/field
    autocmd FileType cs nnoremap <buffer> <C-k> :OmniSharpNavigateUp<CR>
    autocmd FileType cs nnoremap <buffer> <C-j> :OmniSharpNavigateDown<CR>

    " Find all code errors/warnings for the current solution and populate the quickfix window
    autocmd FileType cs nnoremap <buffer> <Leader>cc :OmniSharpGlobalCodeCheck<CR>
augroup END

" Contextual code actions (uses fzf, CtrlP or unite.vim when available)
nnoremap <Leader><Space> :OmniSharpGetCodeActions<CR>
" Run code actions with text selected in visual mode to extract method
xnoremap <Leader><Space> :call OmniSharp#GetCodeActions('visual')<CR>

" Rename with dialog
nnoremap <Leader>nm :OmniSharpRename<CR>
nnoremap <F2> :OmniSharpRename<CR>
" Rename without dialog - with cursor on the symbol to rename: `:Rename newname`
command! -nargs=1 Rename :call OmniSharp#RenameTo("<args>")

nnoremap <Leader>cf :OmniSharpCodeFormat<CR>

" Start the omnisharp server for the current solution
nnoremap <Leader>ss :OmniSharpStartServer<CR>
nnoremap <Leader>sp :OmniSharpStopServer<CR>

" Enable snippet completion
let g:OmniSharp_want_snippet=1



" For Rust
call plug#end()
Plug 'neoclide/coc.nvim', {'branch': 'release'}

call plug#end()

" Rust Pmenu color
 """ Customize colors
func! s:my_colors_setup() abort
    " this is an example
    hi Pmenu guibg=#000000 gui=NONE
    hi PmenuSel guibg=#000000 gui=NONE
    hi PmenuSbar guibg=#000000
    hi PmenuThumb guibg=#000000
endfunc

augroup colorscheme_coc_setup | au!
    au ColorScheme * call s:my_colors_setup()
augroup END

4

I don't use coc, so I will just share my vision on how you can try to fix this.

I assume that by suggestion box you mean regular vim Pmenu.

Try to make sure if it is actually Pmenu:

  1. run :hi Pmenu and check the colors:

enter image description here

  1. if it really is, then changing it would be simple, add to your vimrc
""" Customize colors
func! s:my_colors_setup() abort
    " this is an example
    hi Pmenu guibg=#d7e5dc gui=NONE
    hi PmenuSel guibg=#b7c7b7 gui=NONE
    hi PmenuSbar guibg=#bcbcbc
    hi PmenuThumb guibg=#585858
endfunc

augroup colorscheme_coc_setup | au!
    au ColorScheme * call s:my_colors_setup()
augroup END
  1. if it is not, then try to figure out what highlights coc uses either by looking into coc doc or coc source files or try to "look" into :hi command output:

enter image description here

  1. if found something related to coc, try to change color of the group using :hi coc-group guibg=red or smth similar. (coc-group is an example here).

  2. if you have found what coc highlight group you want to change -- make amends to 2. and you are ok

If it is not Pmenu (maybe it is float window of neovim or popup of vim) then you'll have to dig out how coc passes colors to them.

UPD

ColorScheme autocommand is triggered when colorscheme is changed. You change colorscheme before autocommand is defined.

  1. put colorscheme afterglow after augroup and autocommand definition
  2. NOTE that if you use terminal vim without termguicolors option, then gui colors wouldn't work. You have to add ctermbg and ctermfg parameters. (I don't know what palette do you use 16 or 256, for default palette colors consult https://jonasjacek.github.io/colors/ -- ctermbg=67 should be SteelBlue or smth)
    hi Pmenu ctermbg=black ctermfg=white
| improve this answer | |
  • Thanks a lot for your answer! That Pmenu is indeed what I want to change. However, I have added that to the bottom of my vimrc, restarted Vim, but nothing is changing. Added my full vimrc in the question – O'Niel Mar 30 at 10:07
  • @O'Niel updated – Maxim Kim Mar 30 at 10:24
  • Works perfectly! Thanks mate! And I'm using terminal Vim. Can't use MacVim because of this: vi.stackexchange.com/questions/22191/… – O'Niel Mar 30 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.