IFC vim syntax highlighting

I mentioned there is a vim syntax highlighting configuration in File::IFC, I'll attach it here. It helps make an IFC file a little bit easier to read:

To use it, download the file and rename it to ~/.vim/syntax/ifc.vim

Then edit your ~/.vimrc file and makes sure it says something like this somewhere:

syntax on

au BufRead,BufNewFile *.ifc set filetype=ifc

MoultCoenatomkarincaArv

Comments

  • edited March 2020

    Awesome work! For those on Vim who want a quick fix, another solution is :set syntax=stp. This sets the syntax highlighting to the STEP syntax.

    This is what it looks like:


    Arv
  • In further attempts at making IFC files easier to read, I implemented a tool that builds a DAG for any IFC file and reorders the entities using a depth first sort. This places referenced entities before the entities where they are referenced, and generally puts entities that have lots of references (like IFCOWNERHISTORY) towards the front.

    MoultJesusbilltheoryshaw
  • @brunopostle very cool! Something to add to the wiki, perhaps?

  • edited June 2020

    I also made one for geany . It needs some more work, but here it is already...
    You need to add this file to .config/geany/filedefs and after that inside geany, go to Tools->Configuration Files->filetype_extensions.conf and add a line like this: IFC=*.ifc

    JesusbillHjalti
  • edited July 2020

    For vscode users there is now also a nice extension available : ifc-syntax

    It also do syntax enlighting for express files :

    JesusbillMoulttheoryshawCoen
  • Should these (both geany and vscode syntax highlights) be added to the wiki? It looks cool!

  • @Moult said:
    Should these (both geany and vscode syntax highlights) be added to the wiki? It looks cool!

    IFC syntax Highlighting

    MoultJesusbillArv
  • @Moult If you mean markdown styles or similar things, I'm not sure about IFC, but other languages have styles, and some platforms implemented them, for instance, Discord:

    https://gist.github.com/matthewzring/9f7bbfd102003963f9be7dbcf7d40e51

  • Thanks @Cyril - I've also added the Notepad++ one from earlier.
    @ReD_CoDE no worries, @Cyril has added the page :)

  • I missed about these styles, awesome. Damn on Linux I use kwrite ... Nothing out there ?!?

  • edited September 2022

    I am a bit late to the party, however here is also my theme:

    It's a solarized light theme for notepad++
    The file is saved here

    vpajicmatthew_fullerArv
  • Hi Everyone

    For my own convenience I wrapped the vim highlight in a plugin.
    https://github.com/petrisch/vim-ifc
    @brunopostle since you did the job actually, you can also fork it back and we can keep yours as the "official".
    I wasn't shure about the commentstring. I have copied it over from rust, but I don't know if // is actually a comment in IFC?
    Is there any indentation rules for IFC?
    Anyway a tree-sitter or LSP Plugin would be the real deal, but thats a bt more effort :-)

  • Great! IFC has comments like C that can span multiple lines:

    /* this is
    a comment */
    

    There is no indentation, but sometimes there are spaces after the step id:

    #101=IFCSOMETHING();
    #102 = IFCSOMETHING();
    #103 =IFCSOMETHING();
    
  • hm, I'm not shure if

    setlocal comments=s0:/*!,m:\ ,ex:*/,s1:/*,mb:*,ex:*/,:///,://!,://
    setlocal commentstring=//%s
    

    Covers that correctly. It doesn't highlight correctly for me, but that could be a colorscheme issue.
    On the other hand I have no idea what this regexy thing does :-)
    About the indentation, I don't think we can cover that with vimscript.
    Does that have a different meaning? I hope not.

  • This original syntax file was mashed together from other files, I suspect that the //%s entry isn't necessary.

  • When I was trying to enter 'ifc syn' into the search field inside visual studio code I stumbled upon 'step syntax' some entries below 'ifc syntax' which seemed like Dion's vim quickfix at first, but it seems it also offers to follow the references and occurences of entities in the file.

  • Following refs would be useful, the standard stp highlighting only has two colours here

  • Just committed a new version. Had to realise, that the comments were not defined in the syntax.
    This should now highlight the comments correctly.
    I therefore also changed the ifcGID to "Label". Don't know what it actually is called. Should probably search for a IFC format specification.

  • Nice! I have this in my .vimrc:

    set iskeyword+=#
    autocmd CursorMoved * exe printf('match IncSearch /\V\<%s\>/', escape(expand('<cword>'), '/\'))
    

    This highlights all occurrences of the word under the cursor while treating local IDs (starting with #) as words (not as two words - hashtag and number). You can also navigate the occurrences with * and #. Might be a useful addition to the highlighting.

    Arv
  • Has anyone created or seen an SPF highlighting definition in the KDE syntax definition format? Would be great to have it included in the KDE syntax repository. I guess these are used by many KDE tools like kwrite (@bernd) but also beyond, for example by Pandoc through the Haskell library skylighting. Just want to ask before carving out some time and getting my own hands dirty.

Sign In or Register to comment.