Unclosed brackets highlight color in Vim - vim

How can I customize the highlight color for the unclosed bracket in Vim?
This is how Vim highlights an unclosed bracket when the cursor is not over the same line as the bracket:
This is nice, but when I move the cursor over the line where the bracket lies, this is how it looks:
Now, I barely can see where the bracket is. How can I change this? By the way, I'm using :set cursorline option to highlight the current line.

The CursorLine highlight group has more "weight" than other highlight groups, including Error which can lead to that kind of situation where the background color of Error is overruled.
The solution I've found while working on my colorscheme is to set the foreground and background colors of Error to the inverse of what I want: red on black vs black on red and use the reverse value for cterm and gui:
hi Error ctermbg=NONE ctermfg=131 guibg=NONE guifg=#af5f5f cterm=reverse gui=reverse
And make sure CursorLine doesn't set any foreground color:
hi CursorLine ctermbg=236 ctermfg=NONE guibg=#303030 guifg=NONE cterm=NONE gui=NONE
It works pretty well:
You'll need to edit the colorscheme you are using and, if possible, send a pull request to its author.

Related

How to change Coc Vim Pmenu Syntax

I have an issue where the pmenu generated by the coc.vim have colors that do not align well with my desired background color for the pmenu.
This is my generic pmenu. Note that the color scheme is just a black foreground and a green background:
This is specifically the hint box that comes up when I write a function or method that Coc Vim recognizes and I press tab to autocomplete. This is how I want it to look, mostly all black color scheme with the pmenu background I configured:
Here is the ugly one. This one shows up when I do the SHIFT + K to bring up the help/documentation on a function/method after the fact:
Is this a configuration issue with vim or with coc? Here is the configuration file I source with my .vimrc file :
hi Pmenu ctermfg=black ctermbg=DarkGreen
hi PmenuSel ctermfg=white ctermbg=DarkGreen
hi CocErrorSign ctermfg=red guibg=red
hi CocErrorFloat ctermfg=white ctermbg=red
hi CocInfoSign ctermfg=blue
hi CocInfoFloat ctermfg=white ctermbg=blue
hi CocWarningSign ctermfg=white ctermbg=yellow
" I have tried all of the below, but to no avail
" hi CocHighlightText ctermfg=black ctermbg=DarkGreen
" hi CocHintSign ctermfg=black ctermbg=DarkGreen
" hi CocHintHighlight ctermfg=black ctermbg=DarkGreen
" hi CocHintVirtualText ctermfg=black
Trying really hard to understand the help page with coc. I think this is the issue:
I think that coc is using some of the syntax highlighting that comes with my vim and imposing it on the help box, though I am unsure. I want to remove this behavior. I tried CocHighlightText, since the help page mentioned symbols (not sure what that is) but it didn't seem to work. How can I configure the hint box color scheme when I press SHIFT + K?
I found a couple related highlighting groups:
highlight CocFloating ctermfg={fg color} ctermbg={bg color} gui={gui color}
highlight CocErrorFloat ctermfg={fg color} ctermbg={bg color} gui={gui color}
highlight CocMenueSel ctermfg={fg color} ctermbg={bg color} gui={gui color}
I think that CocFloating might be the one you are looking for, this is the one that changes coc's pmenu text and background. CocMenuSel changes the selected entry colors of coc's pmenu, and CocErrorFloat changes the colors of error messages from when you hover over errors.
There are also some more popup menu highlight groups if you do :h CocPum
Delet or comment this lines. So the pmenu will follow your color scheme.
"hi Pmenu ctermfg=black ctermbg=DarkGreen
"hi PmenuSel ctermfg=white ctermbg=DarkGreen

How to underline (rather than highlight) the current line in vim?

I believe it's possible to get an underline under the current line, rather than a highlight.
This adds the highlight in my .vimrc:
set cursorline
This is what I've tried adding to get an underline:
:highlight CursorLine gui=underline cterm=underline
But it appears to make no difference.
I'm using vim 7.4.629 on Centos 6.7 through putty, if that helps.
try :hi clear CursorLine to clear the current cusorline hl, then :hi CursorLine gui=underline cterm=underline
The color of underline is same as your ctermfg or guifg. You can either live with your "colorful" underline, or add cterm/guifg to make the underlined text and the underline same color.
:set cursorline
was the best solution for me, you can combine it with removing the cursorLine as the answer above mentions
For me it works best to highlight the cursor line only in Insert mode. To do so, I use the action snippet to activate cursor underlining (full line) whenever Insert mode is activated and later deactivating it upon leaving the mode.
au InsertEnter * set cul
au InsertLeave * set nocul

VIM Background color issue

I want my vim background to be dark but as you can see it's not, its half black half grey, im using ubuntu 15.10 with latest vim version. How to fix this?
pic
If you want your background was of all the same colour, which is set in your colorsheme, you need to comment the line about highlighting nonText.
" highlight Normal ctermbg=black
" highlight nonText ctermbg=black
If you wish to override the settings in your colorscheme, just uncomment the line about highlighting Normal
highlight Normal ctermbg=black
highlight nonText ctermbg=black
If you want to see the current settings of the highlighting, you can use :highlight command.
Read more in help
:h highlight-groups

Highlighting the current line number in vim

Is there a way to highlight only the current line number (in the left hand coloumn) in vim, without highlighting the background of the current line? Ideally, I would Like to make the current line number bold.
There are two groups that determine highlighting of line displayed when &cursorline option is active: CursorLine and CursorLineNR. First is used to highlight the whole line, second for the line number. So to achieve what you want you must
Clear the highlighting of CursorLine: just hi clear CursorLine after any :colorscheme and set background= call.
hi clear CursorLine
augroup CLClear
autocmd! ColorScheme * hi clear CursorLine
augroup END
Set the highlighting of CursorLineNR if it is not set in your colorscheme:
hi CursorLineNR cterm=bold
augroup CLNRSet
autocmd! ColorScheme * hi CursorLineNR cterm=bold
augroup END
(better to check whether it is already set in the colorscheme, maybe it will look better in that case).
You can join both autocommands in one of course.
CursorLineNR has been added relatively recently around version 7.3.488.
You want to look at
:se cursorline
and perhaps even/also
:se cursorcolumn
This is what worked for me:
highlight CursorLine cterm=NONE ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE
set cursorline
I'm just using this in my .vimrc after having set the color scheme. Of course you could also set a specific background color but setting all of them to NONE just highlights the line number (i.e. makes it brighter).
I guess you could just use :hi CursorLine cterm=NONE but I just wanted to make sure I'm making everything transparent (gvim included).
With CursorLineNR I was then able to set the foreground and background colors of the highlighted number.
I'm only writing this because for me it worked without any autocommands and it may be what most people require.
You can set cursorline to highlight only the numbers
'cursorlineopt' 'culopt' string (default: "number,line")
local to window
{not available when compiled without the +syntax
feature}
Comma separated list of settings for how 'cursorline' is displayed.
Valid values:
"line" Highlight the text line of the cursor with
CursorLine hl-CursorLine.
"screenline" Highlight only the screen line of the cursor with
CursorLine hl-CursorLine.
"number" Highlight the line number of the cursor with
CursorLineNr hl-CursorLineNr.
And to override your colorscheme use autocmd
So, the following works:
set cursorline
set cursorlineopt=number
autocmd ColorScheme * highlight CursorLineNr cterm=bold term=bold gui=bold
This worked for me to highlight the line number and not the rest of the line:
highlight CursorLineNr cterm=NONE ctermbg=15 ctermfg=8 gui=NONE guibg=#ffffff guifg=#d70000
The help for highlight-groups does not mention an exclusive "number of current line" syntax group, so the official answer might be no.
You may want to take a look in the cursorline option which highlights the entire line, if it helps.

CursorLine highlight in ViM, highlight only line number and spaces/tabs on beginning /end of the line

I use ViM's :highlight CursorLine to change bg color on the current line. But sometimes the text not readable.
I would like a highlight that could only change the background color for the whole line except the text (counting the spaces/tabs in between chars as text).
Is it doable? If yes, how?
As for as I know, there might be no direct support of setting how the cursorline is highlighted.
But, I've got a trick for doing what you want. That is, after we highlight the cursorline, we can change the color settings of heading/trailing spaces in a line as current "background" and "foreground".
:match NoHighLight /^\s\+|\s\+$/
:highlight NoHighLight guibg=background guifg=foreground
A obvious drawback is the part from "the end of the line" to "the boundary of the vim window" will still be painted as the color of cursorline's setting. If it is ugly for you, you can just change the highlight setting of cursorline by only setting its guifg, like:
:highlight CursorLine guifg=red guibg=background
Maybe there are other neat solutions existed, but that is what I can come up with now. :)
Hope that helps a bit.
I have found a solution -
With regard to #Zhaojun's answer: it's not what I wanted (also /^\s\+|\s\+$/ doesn't do much, maybe it should be /^\s\+\|\s\+$/)
The solution I found is (just example color for elflord color scheme)
:highlight CursorLine gui=none guibg=grey10
:set CursorLine
:highlight NoHighLight guibg=background
:match NoHighLight /\S\+\(\s\+\|$\)/
it's however not working well for trailing spaces at he end of line, but I usually delete them
to make them visible I use the following
:highlight EndSpaces guibg=green
:match EndSpaces /\s\+$/

Resources