kakoune

Fork of kakoune, an acceptable text editor
git clone git://git.laack.co/kakoune.git
Log | Files | Refs

troff.kak (2296B)


      1 # Detection
      2 # ‾‾‾‾‾‾‾‾‾
      3 
      4 hook global BufCreate .*\.\d+ %{
      5     set-option buffer filetype troff
      6 }
      7 
      8 # Initialization
      9 # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
     10 
     11 hook global WinSetOption filetype=troff %{
     12     require-module troff
     13 }
     14 
     15 hook -group troff-highlight global WinSetOption filetype=troff %{
     16     add-highlighter window/troff ref troff
     17     hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/troff }
     18 }
     19 
     20 provide-module troff %{
     21 
     22 # Highlighters
     23 # ‾‾‾‾‾‾‾‾‾‾‾‾
     24 
     25 add-highlighter shared/troff regions
     26 
     27 add-highlighter shared/troff/text default-region group
     28 add-highlighter shared/troff/text/ regex '(^\.)?\\".*?\n' 0:comment
     29 add-highlighter shared/troff/text/ regex '\\f[A-Z]' 0:attribute
     30 add-highlighter shared/troff/text/ regex '\\fB(.+?)\\f[A-Z]' 1:+b
     31 add-highlighter shared/troff/text/ regex '\\fI(.+?)\\f[A-Z]' 1:+i
     32 add-highlighter shared/troff/text/ regex '^\.[a-zA-Z]{1,2}\b' 0:meta
     33 add-highlighter shared/troff/text/ regex '^\.(PSPIC|PDFPIC|pdfhref)\b' 0:meta
     34 add-highlighter shared/troff/text/ regex '^\.\.$' 0:meta
     35 add-highlighter shared/troff/text/ regex '^\.TH\s+\N+' 0:title
     36 add-highlighter shared/troff/text/ regex '^\.NH(\s+\d+(\s+\d+)?)?\s*\n' 0:header
     37 add-highlighter shared/troff/text/ regex '^\.SH(\s+\d+)?\s*\n' 0:header
     38 add-highlighter shared/troff/text/ regex '^\.IR\s+(\S+)' 1:+i
     39 add-highlighter shared/troff/text/ regex '^\.BR\s+(\S+)' 1:+b
     40 add-highlighter shared/troff/text/ regex '^\.I\s+(\N+)' 1:+i
     41 add-highlighter shared/troff/text/ regex '^\.B\s+(\N+)' 1:+b
     42 add-highlighter shared/troff/text/ regex '(ftp:|http:|https:|www\.)+[^\s]+[\w]' 0:link
     43 
     44 add-highlighter shared/troff/pic region '^\.PS\b' '^\.PE\b' group
     45 add-highlighter shared/troff/pic/ regex '^(\.PS\b|\.PE\b)' 1:meta
     46 add-highlighter shared/troff/pic/ regex '^(copy)\s+' 1:keyword
     47 add-highlighter shared/troff/pic/ regex '\b(arc|arrow|box|circle|ellipse|line|move|spline)\b' 1:type
     48 add-highlighter shared/troff/pic/ regex '\b(above|at|below|by|center|chop|dashed|diam|diameter|down|dotted|fill|from|ht|height|invis|left|ljust|rad|radius|right|rjust|solid|then|to|up|wid|width|with)\b' 1:attribute
     49 add-highlighter shared/troff/pic/ regex '(\s+|\+|-|\*|/)(\d+(\.\d+)?)' 2:value
     50 add-highlighter shared/troff/pic/ regex '"[^"]*"' 0:string
     51 }