www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - New vim d.vim syntax highlighting script

reply Jason Mills <jmills cs.mun.ca> writes:
I have uploaded a new d.vim syntax highlighting script to vim.org. Get 
it at http://www.vim.org/scripts/script.php?script_id=379

Change:

+ Improved syntax synchronization, especially for /* */ style comments.
+ Fixed a bug that caused some identifiers and numbers to highlight as 
octal number errors (thanks to Frank Benoit).
+ Added new scope keyword.
+ Strings now know about and highlight the modifiers r, d, c, and w.
+ Changed hexadecimal floating point definitions to match current D 
spec: _ is a valid digit, i is a valid suffix, and only decimal digits 
are allowed after the hex exponent p.
+ Changed binary number definitions so integer suffixes are allowed.


Please email me all bug reports and suggestions. Include the word vim in 
the subject line so it is filtered out from all the other spam I get.

Jason
Mar 12 2006
next sibling parent Dawid =?UTF-8?B?Q2nEmcW8YXJraWV3aWN6?= <dawid.ciezarkiewicz gmail.com> writes:
Jason Mills wrote:

 I have uploaded a new d.vim syntax highlighting script to vim.org. Get
 it at http://www.vim.org/scripts/script.php?script_id=379
Thank for your work. :)
Mar 12 2006
prev sibling next sibling parent reply David Ferenczi <raggae ferenczi.net> writes:
Thank you very much for your work!

Recently I was playing around a bit with the d.vim script trying to get some
features work. I didn't have much time, and so were the results, as well.
Since I'm not familiar with vim scripts my assumptions and additions may be
totally wrong.

1. Highlighting operators:
I saw the operator names in the script, thus I presumed that the operators
should have also been highlighted, but somehow it didn't work for me. So I
added a quick and dirty hack:

---------8<----------------------------
" Operators
syn match dOperator             "[~+!%\/=\(\)\[\]\<\>&\{\},?;.:\-\*]"
---------8<----------------------------

I know it's quite far from elegant, but it worked - at least - for me.

Could you please give me a short explanation how the operator highlighting
is intended to work?

2. Highlighting function names:
I was thinking about how to implement, and also look at other scripts to get
some ideas, but most likely the learning curve cannot be avoided in this
case. ;-) A tip could be useful though, how the correct implementation
would look like.

Regards,
David



Jason Mills wrote:

 I have uploaded a new d.vim syntax highlighting script to vim.org. Get
 it at http://www.vim.org/scripts/script.php?script_id=379
 
 Change:
 
 + Improved syntax synchronization, especially for /* */ style comments.
 + Fixed a bug that caused some identifiers and numbers to highlight as
 octal number errors (thanks to Frank Benoit).
 + Added new scope keyword.
 + Strings now know about and highlight the modifiers r, d, c, and w.
 + Changed hexadecimal floating point definitions to match current D
 spec: _ is a valid digit, i is a valid suffix, and only decimal digits
 are allowed after the hex exponent p.
 + Changed binary number definitions so integer suffixes are allowed.
 
 
 Please email me all bug reports and suggestions. Include the word vim in
 the subject line so it is filtered out from all the other spam I get.
 
 Jason
Mar 13 2006
parent reply Jason Mills <jmills cs.mun.ca> writes:
David Ferenczi wrote:
 Thank you very much for your work!
 
 Recently I was playing around a bit with the d.vim script trying to get some
 features work. I didn't have much time, and so were the results, as well.
 Since I'm not familiar with vim scripts my assumptions and additions may be
 totally wrong.
 
 1. Highlighting operators:
 I saw the operator names in the script, thus I presumed that the operators
 should have also been highlighted, but somehow it didn't work for me. So I
 added a quick and dirty hack:
The option you are talking about is d_hl_operator_overload. When set to true, the specially named class member functions that implement the operators are highlighted (e.g. opNeg), not the operator the method refers to (e.g. - ).
 ---------8<----------------------------
 " Operators
 syn match dOperator             "[~+!%\/=\(\)\[\]\<\>&\{\},?;.:\-\*]"
 ---------8<----------------------------
 
 I know it's quite far from elegant, but it worked - at least - for me.
I will add this, or some variant of it, in the next update. Most likely I'll provide an option to enable to disable operator highlighting.
 Could you please give me a short explanation how the operator highlighting
 is intended to work?
See my first comment.
 2. Highlighting function names:
 I was thinking about how to implement, and also look at other scripts to get
 some ideas, but most likely the learning curve cannot be avoided in this
 case. ;-) A tip could be useful though, how the correct implementation
 would look like.
I'm afraid I'm not a vim syntax script expert either. So, I can't offer much in the way of tips. Implementing this would be a learning experience for me as well. Nevertheless, I will look into implementing some sort of method name highlighting for the next update. What type of support would you like to see? Here are some options: 1. Highlight only class method names in the class definition. This is relatively easy. 2. Highlight method and function names where used. This maybe difficult. Do you know of any languages where vim highlights the method/function names? Jason
Mar 13 2006
parent reply David Ferenczi <raggae ferenczi.net> writes:
 1. Highlighting operators:
 I saw the operator names in the script, thus I presumed that the
 operators should have also been highlighted, but somehow it didn't work
 for me. So I added a quick and dirty hack:
The option you are talking about is d_hl_operator_overload. When set to true, the specially named class member functions that implement the operators are highlighted (e.g. opNeg), not the operator the method refers to (e.g. - ).
Thank you very much, now I understand.
 ---------8<----------------------------
 " Operators
 syn match dOperator             "[~+!%\/=\(\)\[\]\<\>&\{\},?;.:\-\*]"
 ---------8<----------------------------
 
 I know it's quite far from elegant, but it worked - at least - for me.
I will add this, or some variant of it, in the next update. Most likely I'll provide an option to enable to disable operator highlighting.
I'm glad if I could contribute some.
 
 2. Highlighting function names:
 I was thinking about how to implement, and also look at other scripts to
 get some ideas, but most likely the learning curve cannot be avoided in
 this case. ;-) A tip could be useful though, how the correct
 implementation would look like.
I'm afraid I'm not a vim syntax script expert either. So, I can't offer much in the way of tips. Implementing this would be a learning experience for me as well. Nevertheless, I will look into implementing some sort of method name highlighting for the next update. What type of support would you like to see? Here are some options: 1. Highlight only class method names in the class definition. This is relatively easy. 2. Highlight method and function names where used. This maybe difficult.
Th first one would be essential, the socond rather nice to have.
 Do you know of any languages where vim highlights the method/function
 names?
I searched for it, and there were many scripts with a "Function" keyword defined. I didn't have the time to go through the list, I tried to pick up some languages, which I know. Python seemed to be a good example for impelementing the first type of function name highlighting, and since sometimes I use Python, I can also confirm that it works. David
Mar 14 2006
parent lanael <lanael_member pathlink.com> writes:
Thanks for the new vim syntax file.

Here is a hacked compiler file for dmd with a usable errorformat string.
Save it as dmd.vim in vim/compiler/

------------------------------->8----------------------------------
" Vim compiler file
" Compiler:	dmd - Digital Mars D language 
" Maintainer:	marc Michel
" Last Change:	2005/08/10

if exists("current_compiler")
finish
endif
let current_compiler = "dmd"

" A workable errorformat for the Digital Mars D compiler

setlocal errorformat=%f\(%l\)\:%m,%-Gdmd\ %m,%-G%.%#errorlevel

" default make
setlocal makeprg=make

------------------------------->8----------------------------------
Mar 16 2006
prev sibling parent jicman <jicman_member pathlink.com> writes:
Thanks Jason.


Jason Mills says...
I have uploaded a new d.vim syntax highlighting script to vim.org. Get 
it at http://www.vim.org/scripts/script.php?script_id=379

Change:

+ Improved syntax synchronization, especially for /* */ style comments.
+ Fixed a bug that caused some identifiers and numbers to highlight as 
octal number errors (thanks to Frank Benoit).
+ Added new scope keyword.
+ Strings now know about and highlight the modifiers r, d, c, and w.
+ Changed hexadecimal floating point definitions to match current D 
spec: _ is a valid digit, i is a valid suffix, and only decimal digits 
are allowed after the hex exponent p.
+ Changed binary number definitions so integer suffixes are allowed.


Please email me all bug reports and suggestions. Include the word vim in 
the subject line so it is filtered out from all the other spam I get.

Jason
Mar 13 2006