ErichDonGubler / vim-sublime-monokai

Vim Monokai color scheme that tries to be as faithful as possible to Sublime's Monokai syntax highlighting
MIT License
151 stars 101 forks source link

Question: package, import, etc in Java not getting highlighted - how can I debug this? #11

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi guys -

Could you help me debug what's going on with my setup? I'm not too familiar with creating syntax highlighting definitions in Vim yet. The import list and package are not getting highlighted at all in Java in my setup. C# and typescript I don't have this issue with.

If I use other colorschemes I see package and import getting highlighted, so wondering if it's an issue with the copy of this colorscheme?

What I did:

  1. I downloaded https://github.com/google/ijaas
  2. I made this temporary vimrc file with the following content:
    
    " set the runtime path to include Vundle and initialize
    set nocompatible
    filetype off
    set rtp+=~/.vim/bundle/Vundle.vim
    call vundle#begin()
    Plugin 'VundleVim/Vundle.vim'
    Plugin 'rudes/vim-java'
    Plugin 'ErichDonGubler/vim-sublime-monokai'

call vundle#end() filetype plugin indent on

set encoding=utf-8

syntax on set bg=dark

set termguicolors let g:sublimemonokai_term_italic = 1 colorscheme sublimemonokai



3. Opened `src/com/google/devtools/intellij/ijaas/BaseHandler.java` from IJAAS project

4. Got this :( 
![image](https://user-images.githubusercontent.com/44413051/59797222-3d7b5080-92ad-11e9-9810-ace2e35f87d6.png)

5. If I use other out of the box colorschemes like `darkblue` or `koehler`, I don't have this problem - `defaultblue` screenshot as example below.
![image](https://user-images.githubusercontent.com/44413051/59797273-53891100-92ad-11e9-9c48-472046255aff.png)

### My environment
1. vim 8.1.1561
2. I compiled it from source using directions from here: https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source
3. I use terminator, but I was able to reproduce this in Guake terminal as well.
4. Looking at my bundle, looks like `vim-sublime-monokai` is on commit `9cc47869c530df83926790a914bb3523496de178`

Thanks!
ErichDonGubler commented 5 years ago

Hey there! I just pushed up a fix to this issue...I was doing well and everything, setting up my own sandbox environment to reproduce this fully...and then I noticed that this issue also happened with my own setup. D'oh!

So, this was definitely a missing feature in this theme. If you refer to the commit that I marked as resolving this (https://github.com/ErichDonGubler/vim-sublime-monokai/commit/0a5df59324c43d44b74d39f94077d55e589573ae), the relevant group is javaExternal. Since you're interested in knowing how to debug this yourself (perhaps for future PRs? :smile:), I'll teach you what I know! I have two main techniques, neither of which I will claim are perfect or complete:

  1. I have a custom function in my vimrc that prints out the highlight group stack for the position under the cursor. This gets me 95% of the way to figuring out how things are being grouped and usually lets me write the correct highlight statements:

    fun! s:SyntaxStack()
        if !exists('*synstack')
            return
        endif
        return map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
    endfunc
    command! -nargs=0 EchoHighlightingGroup echo s:SyntaxStack()
    
    " This is my preferred mapping -- don't feel like you need to use this.
    nnoremap <leader>0 :EchoHighlightingGroup<CR>

    If the above doesn't immediately make sense, a good first round of learning might come from the vim docs for syntax, particularly the highlight section.

  2. Perusing the source for some highlighting plugins for languages has been necessary where, in some VERY rare cases, my synstack binding above doesn't show a group I'm pretty sure is being highlighted. If you ever have to use this technique and your sanity feels challenged at some point...know that it's normal, and that I'd be more than happy to help you out. In that case, feel free to make an issue here again or to reach out to me via email -- it's $MY_GITHUB_USERNAME at gmail dot com. :slightly_smiling_face: