If I get you right I don't think this is possible (or really cumbersome to do) with existing :syntax commands.
: foo bar ; <-- foo is defined and highlighted as statement then anywhere else in the text: bla bla bla foo bla bla <-- foo should be highlighted as statement Although, text properties with external text analyzer might be a good fit for it. понедельник, 14 декабря 2020 г. в 08:04:27 UTC+3, Ron Aaron: > I explained exactly what I mean in the original post. > > Yes, of course I'm talking about a specific file type, but the specific > type is unimportant since it's something I'm creating and not something in > the vim syntax files. > > What I intend is simply that if the user types in (the file being created) > something like: > > * : foo bar ;* > > Then "*foo*" becomes a syntax keyword. The criteria for becoming a > keyword in this context is that it is preceded by a colon, and delimited by > white-space. Thus 'bar' is not a keyword, nor is ": foo". Think of the > leading colon-space as a function declarator. > > What I can't figure out is how to trap "foo" without trapping the leading > colon-space. > > On Sunday, December 13, 2020 at 5:28:28 PM UTC+2 Charles Campbell wrote: > >> Ron Aaron wrote: >> > Is this possible w/ vim's syntax highlighting? >> > >> > On Wednesday, December 9, 2020 at 10:56:35 AM UTC+2 Ron Aaron wrote: >> > >> > Hi all - >> > >> > I want to have a keyword (user-defined function) highlighted by my >> > syntax file. >> > >> > The code looks like this: >> > >> > : foo blah blah ; >> > >> > In this case I want "foo" to be scooped up. What I'm doing now is >> > this: >> > >> > syn match colonDef "^\s*:\s\+\zs\S\+" >> > >> > That highlights the correct thing (e.g. 'foo') where it's defined, >> > but I can't figure out how to get it to be highlighted elsewhere >> > in the code (e.g. when simply 'foo' appears without a leading colon). >> > >> > How can I accomplish this? >> > >> > >> What do you mean by "vim's syntax highlighting"? Assuming no filetype, >> say in a file called "joe.coffee", you could type >> >> syn keyword colonDef foo >> hi link colonDef Statement >> >> and foo would be highlighted as Statement in your file. >> >> Somehow I don't think you're really meaning "vim's syntax highlighting", >> but rather "vim's syntax highlighting for the XYZ filetype". Naturally, >> that missing information greatly affects things. Syntax highlighting >> involves groups, containment, matches, regions, etc. My guess is that >> you want your modified "colonDef" highlighting to occur in some region >> defined by the filetype's syntax highlighting, but you've defined a >> match that is not contained in that region. To find out what that region >> is named, you could try my plugin: >> http://www.drchip.org/astronaut/vim/index.html#HILINKS and use :HLT!, >> move the cursor about, and you'll see a trace explaining what syntax and >> highlighting regions/etc are involved. Additionally, there's issues of >> priority involved, but often you can use "containedin=..." to get what >> you want. >> >> Once you've done that, you could place a file in your >> .vim/after/syntax/XYZ.vim file the extra directions giving the >> additional highlighting you want. >> >> Regards, >> Chip Campbell >> > -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/bcde1c7b-1b39-4de8-aba5-7ed26cb2c795n%40googlegroups.com.
