Closed RononDex closed 3 years ago
With :OmniSharpHighlightEcho
I just keep getting "Identifier" pretty much everywhere.
Meaning the highlighting groups that Omnisharp overlays are actually less detailed than the default ones
Is there any way to get more specific highlighting groups?
The semantic OmniSharp-vim highlighting uses text properties (Vim) and namespaces (neovim) to add server-provided highlighting on top of the standard vim syntax highlighting. So that's what you're seeing when you load vim: for the first few seconds, the server is not yet available as it spins up, and there is just the vim syntax highlighting available. Once the server is available, OmniSharp-vim provides semantic highlighting on top, and that is what :OmniSharpHighlightEcho
is displaying.
If you want to turn off the semantic highlighting and just keep syntax highlighting, add this to your .vimrc:
let g:OmniSharp_highlighting = 0
If you are using semantic highlighting, you can fine-tune which groups are highlighted with which colours, this is described in the README: https://github.com/OmniSharp/omnisharp-vim#semantic-highlighting
I don't know what those lv14
and lv15
highlight groups are, I suspect they are coming from another plugin.
With :OmniSharpHighlightEcho I just keep getting "Identifier" pretty much everywhere. Meaning the highlighting groups that Omnisharp overlays are actually less detailed than the default ones
Is there any way to get more specific highlighting groups?
No, we just have what the server provides (the same groups that vscode has access to).
Ah tanks, that's useful. So basically Omnisharp can create a dictionary of Roslyn tags to highlighting groups :+1:
Yep, that's it
I found the predefined default mapping here: https://github.com/OmniSharp/omnisharp-vim/blob/master/autoload/OmniSharp/actions/highlight.vim
Would it be okay for me to create a PR with some "better" default mappings? Like "EnumName", "ClassName" , ... mapped to "Type" by default instead of "Identifier"?
That sounds pretty subjective...
Perhaps if you do it, include the words "Feedback wanted" and we can leave it open for a while, and see anyone else has strong feelings on the issue?
That sounds pretty subjective...
Yeah I agree.
Perhaps if you do it, include the words "Feedback wanted" and we can leave it open for a while, and see anyone else has strong feelings on the issue?
I can see if I can put something together in the next few days
Actually after trying some things out I agree. I'm just playing with these currently, and different colours for NamespaceName
/ClassName
do help with code readability:
let g:OmniSharp_highlight_groups = {
\ 'ExcludedCode': 'NonText',
\ 'ClassName': 'Type',
\ 'EnumName': 'Type',
\ 'NamespaceName': 'Include',
\ 'RegexComment': 'Comment',
\ 'RegexCharacterClass': 'Character',
\ 'RegexAnchor': 'Type',
\ 'RegexQuantifier': 'Number',
\ 'RegexGrouping': 'Macro',
\ 'RegexAlternation': 'Identifier',
\ 'RegexText': 'String',
\ 'RegexSelfEscapedCharacter': 'Delimiter',
\ 'RegexOtherEscape': 'Delimiter'
\}
Edit: Added Regex groups
Where there others you had been considering?
The ones I came up with so far are
let g:OmniSharp_highlight_groups = {
\ 'Comment': 'Comment',
\ 'Keyword': 'Keyword',
\ 'StringLiteral': 'String',
\ 'ClassName': 'StorageClass',
\ 'DelegateName': 'StorageClass',
\ 'EnumName': 'StorageClass',
\ 'InterfaceName': 'StorageClass',
\ 'ModuleName': 'StorageClass',
\ 'StructName': 'StorageClass',
\ 'ConstantName': 'Constant',
\ 'NamespaceName': 'Include',
\ 'ExcludedCode': 'NonText'
\}
I disagree with several of these.
Comment
: Vim's standard syntax already highlights comments correctlyKeyword
: Vim's standard syntax highlights better than roslyn's here. Roslyn calls both public
and bool
"Keyword".StringLiteral
: Already highlightedHave you found any problems with the standard highlighting for the above?
ConstantName
: Do you really want constants highlighted differently to variables/properties? It looks strange to me, I've never seen it done in e.g. VS or VSCode.Then you have most of the remaining groups highlighted as StorageClass
, meaning there is no differentiation between classes/enums/interfaces, which I find much more useful.
After reading over :help group-name I think we should highlight classes and structs as Typedef
and delegates/enums/interfaces/modules as Structure
:
let g:OmniSharp_highlight_groups = {
\ 'ExcludedCode': 'NonText',
\ 'ClassName': 'Typedef',
\ 'StructName': 'Typedef',
\ 'DelegateName': 'Structure',
\ 'EnumName': 'Structure',
\ 'InterfaceName': 'Structure',
\ 'ModuleName': 'Structure',
\ 'NamespaceName': 'Include',
\ 'RegexComment': 'Comment',
\ 'RegexCharacterClass': 'Character',
\ 'RegexAnchor': 'Type',
\ 'RegexQuantifier': 'Number',
\ 'RegexGrouping': 'Macro',
\ 'RegexAlternation': 'Identifier',
\ 'RegexText': 'String',
\ 'RegexSelfEscapedCharacter': 'Delimiter',
\ 'RegexOtherEscape': 'Delimiter'
\}
I agree with pretty much everything you said, its just what I found to work well with my colorscheme :)
Is there any way to turn off highlighting only for specific groups? What I want is to turn off highlighting for the Identifier group, but I couldn't figure out how to do this from the documentation. Essentially, I want to have them in the white color instead of blue from the color scheme.
I've tried doing this but it didn't work:
highlight Identifier guibg=Black guifg=White
I'm not the most experienced with vim configuration, so I don't know exactly what I'm doing.
If you want to stop OmniSharp-vim from highlighting any particular semantic types, set them to 0 like this:
let g:OmniSharp_highlight_groups = {
\ 'Comment': 'NonText',
\ 'XmlDocCommentName': 'Identifier',
\ 'XmlDocCommentText': 'NonText',
\ 'LocalName': 0,
\ 'PropertyName': 0
\}
To actually change a vim highlight group as you're describing, you are actually overriding part of your colorscheme, so make sure you do it after setting the colorscheme in your .vimrc:
highlight link Identifier Normal
" or
highlight Identifier ctermfg=white guifg=white ctermbg=black guibg=black
There's a bit more info about highlighting configuration in our wiki article: https://github.com/OmniSharp/omnisharp-vim/wiki/Highlighting-configuration
So I found issues with the way omnisharp-vim marks the text in different "highlight" classes:
For example, the highlight class on the usings is not set:
Whereas the "async" keyword for example is being set as csAsync and Keyword:
And variable names are set as "lv14" ??
Although I tried to set the lv14, lv15 etc (it seems kinda random which one gets used, it seems to even change between files) and was unable to do so. It seems the "hi" commands such like
gets ignored.
Funny thing is, when I open a .cs file for the first time in vim, it first shows the correctly defined colors. However, as soon as omnisharp server started the colors change back to default.
I used this command to get the highlight class below the cursor: