Re: syn region question
On Sat, Aug 14, 2010 at 11:02 PM, Benjamin R. Haskell v...@benizi.com wrote: You left out the second instruction... :echo orig_syntax :syn list vhdlStatement The ':echo' gives you the original syntax entry for vhdlStatement. The ':syn' command gives you the current entry. (So you can compare them.) You are right. I've added them Right. But they aren't listed in that :echo orig_syntax, are they? (They shouldn't be -- they were added to the new list.) Correct. I now see that the match is as specified You also have to set foldmethod=syntax. Sorry, probably could've added it to that file: :set fdm=syntax Thanks. It folds now on the specified words. Rgds, Jeri -- You received this message from the vim_use 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
Re: syn region question
Hi Ben, On Fri, Aug 13, 2010 at 8:45 PM, Benjamin R. Haskell v...@benizi.com wrote: The attached file seems to do what you want, w.r.t. both the multiple block keywords, and not modifying the original $VIMRUNTIME/syntax/vhdl.vim. To use it, put it in your ~/.vim/after/syntax/ directory (create if needed) as 'vhdl.vim'. I've put the file in my after\syntax directory. FYI I'm using gVim on WXP and WVista For some insight into how it works, do: :echo orig_syntax when I type :echo original_syntax then I noticed that entity is still reported in the vhdlStatement list. Then I've modified the line of block_words into let block_keywords = [ 'if', 'else', 'entity', 'zab', 'end' , 'inout' , 'bar'] Then give the same command again :echo original_syntax Then also end and inout are still in the list. It also says that only if and else are in the match group. At least that's my understanding of the lines that comes after all the vhdl keywords match /\\(if\|else\)\/ links to statement zab and bar are now highlighted as vhdl keywords Essentially, the file gets the original vhdlStatement list of keywords, and recreates it, filtering out the keywords you want to use as folding block indicators. (The attached file uses the list: 'if', 'else', 'entity', and 'zab'. You should be able to modify block_keywords to whatever you want.) Then it does two things: one is to fill in the answer to your question above. Instead of creating the individual matches/regions 'vhdlFoo', 'vhdlBar', and 'vhdlFooBarFold', it just adds them as matches in vhdlStatement, and adds the single region 'vhdlBlockFold': The folding of code starting with if or entity or else or zab doesn't happen. Rgds, Jeri -- You received this message from the vim_use 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
Re: syn region question
On Sat, 14 Aug 2010, Jeri Raye wrote: Hi Ben, On Fri, Aug 13, 2010 at 8:45 PM, Benjamin R. Haskell wrote: The attached file seems to do what you want, [...] [...] For some insight into how it works, do: :echo orig_syntax when I type :echo original_syntax then I noticed that entity is still reported in the vhdlStatement list. Then I've modified the line of block_words into let block_keywords = [ 'if', 'else', 'entity', 'zab', 'end' , 'inout' , 'bar'] Then give the same command again :echo original_syntax Then also end and inout are still in the list. You left out the second instruction... :echo orig_syntax :syn list vhdlStatement The ':echo' gives you the original syntax entry for vhdlStatement. The ':syn' command gives you the current entry. (So you can compare them.) It also says that only if and else are in the match group. At least that's my understanding of the lines that comes after all the vhdl keywords match /\\(if\|else\)\/ links to statement zab and bar are now highlighted as vhdl keywords Right. But they aren't listed in that :echo orig_syntax, are they? (They shouldn't be -- they were added to the new list.) Essentially, the file gets the original vhdlStatement list of keywords, and recreates it, filtering out the keywords you want to use as folding block indicators. (The attached file uses the list: 'if', 'else', 'entity', and 'zab'. You should be able to modify block_keywords to whatever you want.) Then it does two things: one is to fill in the answer to your question above. Instead of creating the individual matches/regions 'vhdlFoo', 'vhdlBar', and 'vhdlFooBarFold', it just adds them as matches in vhdlStatement, and adds the single region 'vhdlBlockFold': The folding of code starting with if or entity or else or zab doesn't happen. You also have to set foldmethod=syntax. Sorry, probably could've added it to that file: :set fdm=syntax -- Best, Ben -- You received this message from the vim_use 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
Re: syn region question
On 14/08/10 23:02, Benjamin R. Haskell wrote: On Sat, 14 Aug 2010, Jeri Raye wrote: Hi Ben, On Fri, Aug 13, 2010 at 8:45 PM, Benjamin R. Haskell wrote: The attached file seems to do what you want, [...] [...] For some insight into how it works, do: :echo orig_syntax when I type :echo original_syntax then I noticed that entity is still reported in the vhdlStatement list. Then I've modified the line of block_words into let block_keywords = [ 'if', 'else', 'entity', 'zab', 'end' , 'inout' , 'bar'] Then give the same command again :echo original_syntax Then also end and inout are still in the list. You left out the second instruction... :echo orig_syntax :syn list vhdlStatement The ':echo' gives you the original syntax entry for vhdlStatement. The ':syn' command gives you the current entry. (So you can compare them.) It also says that only if and else are in the match group. At least that's my understanding of the lines that comes after all the vhdl keywords match /\\(if\|else\)\/ links to statement zab and bar are now highlighted as vhdl keywords Right. But they aren't listed in that :echo orig_syntax, are they? (They shouldn't be -- they were added to the new list.) Essentially, the file gets the original vhdlStatement list of keywords, and recreates it, filtering out the keywords you want to use as folding block indicators. (The attached file uses the list: 'if', 'else', 'entity', and 'zab'. You should be able to modify block_keywords to whatever you want.) Then it does two things: one is to fill in the answer to your question above. Instead of creating the individual matches/regions 'vhdlFoo', 'vhdlBar', and 'vhdlFooBarFold', it just adds them as matches in vhdlStatement, and adds the single region 'vhdlBlockFold': The folding of code starting with if or entity or else or zab doesn't happen. You also have to set foldmethod=syntax. Sorry, probably could've added it to that file: :set fdm=syntax :setlocal fdm=syntax You don't want to make it the new default for all files of all filetypes, do you? Best regards, Tony. -- Chemicals, n.: Noxious substances from which modern foods are made. -- You received this message from the vim_use 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
Re: syn region question
On Sun, 15 Aug 2010, Tony Mechelynck wrote: On 14/08/10 23:02, Benjamin R. Haskell wrote: [...] You also have to set foldmethod=syntax. Sorry, probably could've added it to that file: :set fdm=syntax :setlocal fdm=syntax You don't want to make it the new default for all files of all filetypes, do you? Personally, yes. I use :set fdm=syntax in my .vimrc. But, point taken: using :setl instead of :set is better advice. -- Best, Ben -- You received this message from the vim_use 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
Re: syn region question
entity is a VHDL word, as well as if. foo is a made up word. It's also for the VHDL reserved words process, case, architecture. I can't believe VIM can't fold reserved words? Or is this a bug? I did change entity into entit (so removing the y char) in the given syn region. When I now type entit in my VHDL file the word is not higlighted as a VHDL word and the folding goes ok. Why doesn't it work for real VHDL words? Rgds, Jeri -- You received this message from the vim_use 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
Re: syn region question
On 13 Aug 2010, at 08:04, Jeri Raye wrote: entity is a VHDL word, as well as if. foo is a made up word. It's also for the VHDL reserved words process, case, architecture. I can't believe VIM can't fold reserved words? Or is this a bug? I did change entity into entit (so removing the y char) in the given syn region. When I now type entit in my VHDL file the word is not higlighted as a VHDL word and the folding goes ok. Why doesn't it work for real VHDL words? Are they declared as 'syntax keyword'? If so, I think that trumps any attempt to redefine them as regions/matches/etc. I had that problem when writing a syntax file for another language; declaring keywords highlights them unconditionally, irrespective of context, and prevents their use in higher level semantic contexts. In the end I got rid of all keywords and declared everything with syntax match' and 'syntax region'. Regards, Andy -- Andrew Long andrew dot long at mac dot com PGP.sig Description: This is a digitally signed message part
Re: syn region question
Hi Andrew! On Fr, 13 Aug 2010, Andrew Long wrote: Are they declared as 'syntax keyword'? If so, I think that trumps any attempt to redefine them as regions/matches/etc. I had that problem when writing a syntax file for another language; declaring keywords highlights them unconditionally, irrespective of context, and prevents their use in higher level semantic contexts. In the end I got rid of all keywords and declared everything with syntax match' and 'syntax region'. Yes, see :h :syn-priority for the priority how syntax items match. regards, Christian -- You received this message from the vim_use 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
Re: syn region question
Hi Andrew, On Fri, Aug 13, 2010 at 1:21 PM, Christian Brabandt cbli...@256bit.org wrote: Hi Andrew! On Fr, 13 Aug 2010, Andrew Long wrote: Are they declared as 'syntax keyword'? Yes they are. If so, I think that trumps any attempt to redefine them as regions/matches/etc. I had that problem when writing a syntax file for another language; declaring keywords highlights them unconditionally, irrespective of context, and prevents their use in higher level semantic contexts. In the end I got rid of all keywords and declared everything with syntax match' and 'syntax region'. Yes, see :h :syn-priority for the priority how syntax items match. Could you give an example on how you worked around it with syntax match and syntax region? Rgds, Jeri -- You received this message from the vim_use 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
Re: syn region question
I can imagine something like this: sy match vhdlFoo \foo\ sy match vhdlBar \bar\ sy region vhdlFooBarFold \ start= \ end= \ fold transparent \ keepend What to fill in for the start and end parameter of the region, to get the folding as: +-- x lines: foo -- Rgds, Jeri -- You received this message from the vim_use 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
Re: syn region question
On Fri, 13 Aug 2010, Jeri Raye wrote: I can imagine something like this: sy match vhdlFoo \foo\ sy match vhdlBar \bar\ sy region vhdlFooBarFold \ start= \ end= \ fold transparent \ keepend What to fill in for the start and end parameter of the region, to get the folding as: +-- x lines: foo -- The attached file seems to do what you want, w.r.t. both the multiple block keywords, and not modifying the original $VIMRUNTIME/syntax/vhdl.vim. To use it, put it in your ~/.vim/after/syntax/ directory (create if needed) as 'vhdl.vim'. For some insight into how it works, do: :echo orig_syntax :syn list vhdlStatement Essentially, the file gets the original vhdlStatement list of keywords, and recreates it, filtering out the keywords you want to use as folding block indicators. (The attached file uses the list: 'if', 'else', 'entity', and 'zab'. You should be able to modify block_keywords to whatever you want.) Then it does two things: one is to fill in the answer to your question above. Instead of creating the individual matches/regions 'vhdlFoo', 'vhdlBar', and 'vhdlFooBarFold', it just adds them as matches in vhdlStatement, and adds the single region 'vhdlBlockFold': syn region vhdlFooBarFold \ start=\z(\foo\|bar\\) \ end=\end\s\+\z1 ...etc... -- Best, Ben -- You received this message from the vim_use 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 redir = original_syntax silent syn list vhdlStatement redir END syn clear vhdlStatement hi def link vhdlStatement Statement let block_keywords = [ 'if', 'else', 'entity', 'zab' ] for line in split(original_syntax, \n) let skippable = 0 for pat in ['^---','^\s*$','^\s\+match\','^\s\+links to'] if match(line, pat) = 0 let skippable += 1 endif endfor if !skippable let line=substitute(line, '^vhdlStatement\s\+xxx', '', '') let line=substitute(line, '^\s\+', '', '') for kword in filter(split(line, '\s\+'), index(block_keywords, v:val) 0) exe :syn keyword vhdlStatement .kword endfor endif endfor let match_block_keywords = '\'.join(block_keywords,'\|').'\' exe ':syn match vhdlStatement /'.match_block_keywords.'/' exe ':syn region vhdlBlockFold start=/\z('.match_block_keywords.'\)/ end=/\end\s\+\z1/ fold transparent keepend'
Re: syn region question
On Fri, 13 Aug 2010, Benjamin R. Haskell wrote: [...] The attached file seems to do what you want, w.r.t. [...] not modifying the original $VIMRUNTIME/syntax/vhdl.vim. Hmm. I think I might have conflated two threads. I think you're already using an 'after' directory. It still solves your initial 'keyword' and 'match' problem, though. Essentially, there doesn't seem to be a nice way to remove a syntax keyword. So it doesn't even try. Instead, it recreates the original set of keywords minus the ones you want to remove. -- Best, Ben -- You received this message from the vim_use 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
Re: syn region question
On Fri, 13 Aug 2010, Benjamin R. Haskell wrote: On Fri, 13 Aug 2010, Jeri Raye wrote: [...] The attached file seems to do what you want, w.r.t. [...] not modifying the original $VIMRUNTIME/syntax/vhdl.vim. Hmm. I think I might have conflated two threads. I think you're already using an 'after' directory. It still solves your initial 'keyword' and 'match' problem, though. Essentially, there doesn't seem to be a nice way to remove a syntax keyword. So it doesn't even try. Instead, it recreates the original set of keywords minus the ones you want to remove. -- Best, Ben -- You received this message from the vim_use 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