Warning: Undefined array key 1 in /home/np29546/public_html/elmerice/wiki/inc/auth.php on line 78

Warning: Cannot modify header information - headers already sent by (output started at /home/np29546/public_html/elmerice/wiki/inc/auth.php:78) in /home/np29546/public_html/elmerice/wiki/inc/auth.php on line 431

Warning: Cannot modify header information - headers already sent by (output started at /home/np29546/public_html/elmerice/wiki/inc/auth.php:78) in /home/np29546/public_html/elmerice/wiki/inc/actions.php on line 38
tips:editors [Elmer/Ice Wiki]

Highlighting for Emacs

Thanks to Carlos Martin and Basile de Fleurian we can offer additional settings for Emacs (a GNU licenses text editor) for automatic highlighting of Solver Input File Syntax (SIF). Just add the following lines to your .emacs file (should reside in your home-directory):

(require 'generic-x) ;; we need this
(define-generic-mode
  'sif-mode                                                             ;; name of the mode to create
  '("!" "#")                                                            ;; comments start with '!' or "#'
  '("Header" "Constants" "Material" "End" "Boundary Condition"
    "Simulation" "Body" "Body Force" "Initial Condition" "Equation")    ;; some keywords
  '(("=" . 'font-lock-operator)                                         ;; This doesn't do anything!   
    ("Solver [0-9]+" . 'font-lock-keyword-face)                         ;; Highlights Solver sections 
    ("$$" . 'font-lock-builtin)                                         ;; or this!
    ("Real" "Logical" "String" "Integer" . 'font-lock-type-face)        ;; or this
    ("\\(\$[a-zA-Z]+\\)" . 'font-lock-function-name-face))
  '("\\.sif$")                                                          ;; files for which to activate this mode
  "A mode for sif files"                                                ;; doc string for this mode
  )

Highlighting for Vim

There is several settings for Vim for automatic highlighting of Solver Input File Syntax (SIF).

  1. There is an elmer-vim plugin available here https://github.com/ettaka/vim-elmer
  2. Alernatively use the following codes developped by F. Gillet-Chaulet:

Under .vim/ folder (should reside in your home-directory), just add:

  • the following lines to your filetype.vim
augroup filetypedetect
au BufNewFile,BufRead *.sif setf sif
augroup END
"
  • the file sif.vim under .vim/syntax/
if version < 600
	syn clear
elseif exists("b:current_syntax")
	finish
endif

syn case    ignore


syn keyword SifType Real Integer Logical String File Procedure MATC

syn match  SifNumber            display "[+-]\=\<\d\+\>"
syn match  SifFloat           "\<\d\+\(\.\d*\)\=\([edED][-+]\=\d\+\)\=[ij]\=\>"
syn match  SifFloat           "\.\d\+\([edED][-+]\=\d\+\)\=[ij]\=\>"
syn region  SifString         start=+"+ end=+"+ oneline


syn match SifComment "!.*"

syn region SifSolvers start="Linear" end="="
syn region SifSolvers start="nonlinear" end="="

syn match SifSolverHeader "Exec\s*Solver\s*="
syn match SifSolverHeader "Variable\s*="
syn match SifSolverHeader "Variable\s*Dofs\s*="
syn match SifSolverHeader "Equation\s*="
syn match SifSolverHeader "procedure\s*="

syn match SiftargetBC "Target\s*Boundaries\s*="

syntax match MatcFunction "\$\sfunction"  

syn keyword SifUnit Simulation Header End
syn match  SifUnit "Body\s*\d\+"
syn match  SifUnit "Material\s*\d\+"
syn match  SifUnit "Solver\s*\d\+"
syn match  SifUnit "Equation\s*\d\+"
syn match  SifUnit "Initial\s*Condition\s*\d\+"
syn match  SifUnit "Body\s*Force\s*\d\+"
syn match  SifUnit "Boundary\s*Condition\s*\d\+"


hi def SifBold cterm=bold

if version >= 508 || !exists("did_sif_syntax_inits")
	if version < 508
		let did_sif_syntax_inits = 1
		command -nargs=+ HiLink hi link <args>
	else
		command -nargs=+ HiLink hi def link <args>
	endif

   HiLink SifNumber          Number
   HiLink SifFloat           Float
   HiLink SifString          String
   HiLink SifComment         Comment
   HiLink SifUnit            Special
   HiLink SifSolvers         Keyword
   HiLink SifSolverHeader    SifBold
   HiLink MatcFunction       SifBold 
   HiLink SiftargetBC        SifBold
   HiLink SifType            Type
   
   delcommand HiLink
endif

let b:current_syntax = "sif"
tips/editors.txt · Last modified: 2018/05/16 07:02 by fgillet
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0