Skip to content
This repository was archived by the owner on Dec 1, 2020. It is now read-only.

Can't change namespace color showing as phpRegion #90

Closed
ghost opened this issue Mar 15, 2019 · 10 comments
Closed

Can't change namespace color showing as phpRegion #90

ghost opened this issue Mar 15, 2019 · 10 comments
Labels

Comments

@ghost
Copy link

ghost commented Mar 15, 2019

I would first off like to thank you for this amazing plugin.

My problem is I can't style the namespace at the top as it's showing as phpRegion that goes for the \and ;too

phpRegion

I would like it to match the use statements below and if possible style the ; a different color too.

How do I go about this?

@StanAngeloff
Copy link
Owner

Try adding a syntax extension:

function! PhpSyntaxOverride()
  syn keyword phpInclude namespace contained nextgroup=phpUseClass skipwhite skipempty
endfunction

augroup phpSyntaxOverride
  autocmd!
  autocmd FileType php call PhpSyntaxOverride()
augroup END

Does this work for you?

@ghost
Copy link
Author

ghost commented Mar 15, 2019

Hi @StanAngeloff thanks for getting back to me.

Sorry it was a bit late when I posted my comment so I don't think I was as descriptive as I should have been.

The code you posted hasn't had any effect on the color and they're still showing as phpRegion

I would like to change App\Http\Controllers\Authto yellow and color the separators the same color as the use statements below and if possible also change the semicolon color as they are all showing as phpRegion

@StanAngeloff
Copy link
Owner

Very odd, I was able to pop the snippet above in my .vimrc and the namespace … statement was coloured the same a the use … lines. I'll have a think on possible workarounds.

@ghost
Copy link
Author

ghost commented Mar 15, 2019

@StanAngeloff I just tested it with a different theme as I heavily modified it last night.

Now I able to get get the text color to match thank you.

My only problem is now is the separator for the namespace doesn't match the ones below and the semicolon is taking on the same color.

How do I style the \ and ; independently.

separatorandsemicolon

Thank you for taking the time to help me I appreciate it.

@StanAngeloff
Copy link
Owner

Can you pop this in your .vimrc:

" Synstack {{{

" Show the stack of syntax highlighting classes affecting whatever is under the cursor.
function! SynStack()
  echo join(map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")'), " > ")
endfunc

nnoremap <F7> :call SynStack()<CR>

" }}}

then restart and press <F7> over the \ inside the namespace statement. For me this results in the following message: phpRegion > phpUseClass > phpUseNamespaceSeparator and the colour is picked up correctly.

As for colouring the ; at the end of the line, I don't think this is easily doable just for namespace and use statements, sorry.

@ghost
Copy link
Author

ghost commented Mar 15, 2019

@StanAngeloff just tested with your function and it's still only showing phpRegion

What about changing the color of all php semicolons? I would be happy with that.

Thanks again for helping me debug this.

@StanAngeloff
Copy link
Owner

As for the semicolon, try adding:

syn match phpSemi /;/ contained containedin=phpRegion
hi phpSemi guifg=#ff0000 guibg=NONE gui=NONE

to your PhpSyntaxOverride() function. If you are using a terminal that doesn't support 24-bit colours, guifg won't have any effect, use ctermfg instead.

I'm out of ideas about the namespace thingie, I'm using stable Neovim which seems to honour the overrides.

@StanAngeloff
Copy link
Owner

BTW, have you upgraded php.vim recently? The namespace colouring was added as part of #31 which is a while ago, but if you haven't upgraded since, well…

@ghost
Copy link
Author

ghost commented Mar 15, 2019

It's working thank you very much. I'm confused though hoping you can explain what is happening as i'm new to vim.

I was editing my init.vim in NeoVim and apparently sourcing it was causing the problem, as I opened Sublime and did my editing there, closed iTerm and open it and it's working as expected, but as soon as I source my init.vim the coloring gets messed up again and goes away.

@StanAngeloff
Copy link
Owner

Sorry for the late reply, I misplaced GitHub's notification and only just realised there was a reply to this issue.

I was editing my init.vim in NeoVim and apparently sourcing it was causing the problem, as I opened Sublime and did my editing there, closed iTerm and open it and it's working as expected, but as soon as I source my init.vim the coloring gets messed up again and goes away.

I'm not sure what's going on to be fair. Is it possible you have two init.vim files, one getting sourced during start-up and the second one potentially clashing with it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant