USING: accessors calendar calendar.format io kernel multiline prettyprint sequences sorting splitting tr vocabs ; IN: factor.vim.fgen ALIAS: wr write [=[ " Vim syntax file " Language: Factor " Maintainer: Alex Chapman " Last Change: ]=] wr now >gmt { YYYY " " MONTH " " DD } formatted [=[ " Minimum Version: 600 " To regenerate: ]=] wr { [=[ USING: io.encodings.utf8 io.files parser ; ]=] [=[ "resource:misc/vim/syntax/factor/generated.vim" utf8 ]=] [=[ "resource:misc/factor.vim.fgen" parse-file ]=] [=[ with-file-writer]=] } [ wr ] each [=[ if exists('b:factorsyn_no_generated') finish endif ]=] wr nl [=[ command -nargs=+ -bar HiLink hi def link function s:syn_keyword_factor_word(group, ...) execute 'HiLink' a:group 'factorWord' execute 'syn' 'cluster' 'factorWord' 'add=' . a:group endfunction command -nargs=+ -bar SynKeywordFactorWord \ call s:syn_keyword_factor_word() ]=] wr nl : (vocab-name>syntax-group-name) ( string -- string ) "_" "___" "-" "__" "." "_" [ replace ] 2tri@ ; : vocab-name>syntax-group-name ( string -- string ) (vocab-name>syntax-group-name) "factorWord_" prepend ; : write-syn-keyword ( string seq seq -- ) "syn keyword " wr [ wr ] 2dip [ bl [ bl ] [ wr ] interleave ] unless-empty [ bl [ bl ] [ "|" "\\|" replace wr ] interleave ] unless-empty ; : write-keywords ( vocab -- ) lookup-vocab [ name>> ] [ vocab-words [ name>> ] map ] bi natural-sort [ [ vocab-name>syntax-group-name [ "SynKeywordFactorWord " wr wr " | " wr ] keep ] dip { "contained" } write-syn-keyword nl ] [ drop ] if* ; f ! Uncomment to highlight all words from all vocabularies. ! Note that factor/generated.vim grows from ~16k to ~100k. ! drop t [ loaded-vocab-names ] [ { "alien" "arrays" "assocs" "byte-arrays" "classes" "classes.maybe" "combinators" "continuations" "definitions" "destructors" "generic" "growable" "io" "io.encodings" "io.encodings.binary" "io.encodings.utf8" "io.files" "kernel" "layouts" "make" "math" "math.order" "memory" "namespaces" "sequences" "sets" "sorting" "splitting" "strings" "strings.parser" "syntax" "vectors" } ] if [ write-keywords ] each nl [=[ delcommand HiLink delcommand SynKeywordFactorWord ]=] wr nl [=[ let b:factor_syn_no_generated = 1 ]=] wr nl ! Modeline is broken up to prevent detection here. [=[ " vim]=] wr [=[ :set ft=vim sw=2:]=] wr nl ! vim:set ft=factor: