├── README.md ├── autoload ├── eqn.vim ├── groff_char.vim ├── pic.vim ├── requests.vim └── tbl.vim ├── compiler └── troff.vim ├── doc └── troff.txt ├── ftdetect └── troff.vim ├── ftplugin └── troff.vim ├── syntax └── troff.vim └── troff.ctags /README.md: -------------------------------------------------------------------------------- 1 | # vim-troff 2 | 3 | This is a syntax plugin for troff files. At the moment it is focused on groff but will eventually support heirloom, neatroff, and DWB. 4 | 5 | ## Getting Started 6 | 7 | ### Prerequisites 8 | 9 | None at the moment 10 | 11 | ### Installing 12 | 13 | Install this plugin with your favorite plugin manager 14 | 15 | vim-plugged 16 | 17 | ``` viml 18 | Plug 'Gavinok/vim-troff' 19 | ``` 20 | 21 | ## Usage 22 | 23 | The following extensions will automatically be set to troff 24 | 25 | - *.ms 26 | - *.mom 27 | - *.me 28 | - *.mm 29 | - *.tr 30 | - *.troff 31 | 32 | If you are using an unsupported extension ether set the file type manually using 33 | `setfiletype troff` add an autocommand to your vimrc like this: 34 | 35 | ``` 36 | autocmd! BufRead,BufNewFile *.yourextension setlocal filetype=troff 37 | ``` 38 | 39 | ## Contributing 40 | 41 | Please read [CONTRIBUTING.md](https://github.com/your/project/contributing.md) for details on our code of conduct, and the process for submitting pull requests to us. 42 | 43 | ## Authors 44 | 45 | * **Gavin Jaeger-Freeborn** - *Initial work* - [Gavinok](https://github.com/Gavinok) 46 | 47 | See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project. 48 | 49 | ## License 50 | 51 | Copyright (c) Gavin Jaeger-Freeborn. Distributed under the same terms as Vim itself. See :help license. 52 | 53 | ## Acknowledgments 54 | 55 | None at the moment 56 | -------------------------------------------------------------------------------- /autoload/eqn.vim: -------------------------------------------------------------------------------- 1 | " File: eqn.vim 2 | " Maintainer: Gavin Jaeger-Freeborn 3 | " Created: Mon 12 Oct 2020 02:02:01 PM 4 | " License: 5 | " Copyright (c) Gavin Jaeger-Freeborn. Distributed under the same terms as Vim itself. 6 | " See :help license 7 | " 8 | " Description: 9 | " Completion of eqn sections of troff files 10 | 11 | 12 | function! eqn#EqnComplete(shortcontext) 13 | return s:eqn_words + s:eqn_letters + s:eqn_marks 14 | endfunction 15 | 16 | " eqn {{{3 17 | let s:eqn_marks = [ 18 | \{'word': 'bar'}, 19 | \{'word': 'under'}, 20 | \{'word': 'under'}, 21 | \{'word': 'dot'}, 22 | \{'word': 'dotdot'}, 23 | \{'word': 'hat'}, 24 | \{'word': 'tilde'}, 25 | \{'word': 'vec'}, 26 | \{'word': 'dyad'}, 27 | \] 28 | 29 | let s:eqn_translations = [ 30 | \{'word': '>=' 31 | \,'menu': '≥'}, 32 | \{'word': '<=' 33 | \,'menu': '≤'}, 34 | \{'word': '==' 35 | \,'menu': '≡'}, 36 | \{'word': '!=' 37 | \,'menu': '≠'}, 38 | \{'word': '+-' 39 | \,'menu': '±'}, 40 | \{'word': '->' 41 | \,'menu': '→'}, 42 | \{'word': '<-' 43 | \,'menu': '←'}, 44 | \{'word': '<<' 45 | \,'menu': '<<'}, 46 | \{'word': '>>' 47 | \,'menu': '>>'}, 48 | \{'word': 'nothing' 49 | \,'menu': ''}, 50 | \{'word': 'sum' 51 | \,'menu': 'Σ'}, 52 | \{'word': 'inf' 53 | \,'menu': '∞ '}, 54 | \{'word': 'partial' 55 | \,'menu': '∂'}, 56 | \{'word': 'approx' 57 | \,'menu': '≈'}, 58 | \{'word': 'cdot' 59 | \,'menu': '⋅'}, 60 | \{'word': 'times' 61 | \,'menu': '×'}, 62 | \{'word': 'grad' 63 | \,'menu': '∇'}, 64 | \{'word': 'del' 65 | \,'menu': '∇'}, 66 | \{'word': 'prod' 67 | \,'menu': 'Π'}, 68 | \{'word': 'int' 69 | \,'menu': '∫'}, 70 | \{'word': 'half' 71 | \,'menu': '½'}, 72 | \{'word': 'prime' 73 | \,'menu': '′'}, 74 | \{'word': 'union' 75 | \,'menu': '∪'}, 76 | \{'word': 'inter' 77 | \,'menu': '∩'}, 78 | \] 79 | 80 | let s:eqn_letters = [ 81 | \{'word': 'alpha' 82 | \,'menu': 'α'}, 83 | \{'word': 'beta' 84 | \,'menu': 'β'}, 85 | \{'word': 'gamma' 86 | \,'menu': 'γ'}, 87 | \{'word': 'delta' 88 | \,'menu': 'δ'}, 89 | \{'word': 'epsilon' 90 | \,'menu': 'ε'}, 91 | \{'word': 'zeta' 92 | \,'menu': 'ζ'}, 93 | \{'word': 'eta' 94 | \,'menu': 'η'}, 95 | \{'word': 'theta' 96 | \,'menu': 'θ'}, 97 | \{'word': 'iota' 98 | \,'menu': 'ι'}, 99 | \{'word': 'kappa' 100 | \,'menu': 'κ'}, 101 | \{'word': 'lambda' 102 | \,'menu': 'λ'}, 103 | \{'word': 'mu' 104 | \,'menu': 'µ'}, 105 | \{'word': 'nu' 106 | \,'menu': 'ν'}, 107 | \{'word': 'xi' 108 | \,'menu': 'ξ'}, 109 | \{'word': 'omicron' 110 | \,'menu': 'ο'}, 111 | \{'word': 'pi' 112 | \,'menu': 'π'}, 113 | \{'word': 'rho' 114 | \,'menu': 'ρ'}, 115 | \{'word': 'sigma' 116 | \,'menu': 'σ'}, 117 | \{'word': 'tau' 118 | \,'menu': 'τ'}, 119 | \{'word': 'upsilon' 120 | \,'menu': 'υ'}, 121 | \{'word': 'phi' 122 | \,'menu': 'φ'}, 123 | \{'word': 'chi' 124 | \,'menu': 'χ'}, 125 | \{'word': 'psi' 126 | \,'menu': 'ψ'}, 127 | \{'word': 'omega' 128 | \,'menu': 'ω'}, 129 | \{'word': 'GAMMA' 130 | \,'menu': 'Γ'}, 131 | \{'word': 'DELTA' 132 | \,'menu': '∆'}, 133 | \{'word': 'THETA' 134 | \,'menu': 'Θ'}, 135 | \{'word': 'LAMBDA' 136 | \,'menu': 'Λ'}, 137 | \{'word': 'XI' 138 | \,'menu': 'Ξ'}, 139 | \{'word': 'PI' 140 | \,'menu': 'Π'}, 141 | \{'word': 'SIGMA' 142 | \,'menu': 'Σ'}, 143 | \{'word': 'UPSILON' 144 | \,'menu': 'ϒ'}, 145 | \{'word': 'PHI' 146 | \,'menu': 'Φ'}, 147 | \{'word': 'PSI' 148 | \,'menu': 'Ψ'}, 149 | \{'word': 'OMEGA' 150 | \,'menu': 'Ω'}, 151 | \] 152 | 153 | let s:eqn_words = [ 154 | \{'word': 'above' 155 | \,'info': 'Separate the pieces of a pile or matrix column.'}, 156 | \{'word': 'back' 157 | \,'abbr': 'back {n}' 158 | \,'info': 'Move backwards horizontally n 1/100’s of an em.'}, 159 | \{'word': 'bold' 160 | \,'info': 'Change to bold font.'}, 161 | \{'word': 'ccol' 162 | \,'info': 'Center a column of a matrix.'}, 163 | \{'word': 'col???' 164 | \,'info': 'Used with a preceding l or r to left or right adjust the columns of the matrix.'}, 165 | \{'word': 'cpile' 166 | \,'info': 'Make a centered pile (same as a pile).'}, 167 | \{'word': 'define' 168 | \,'info': 'Create a name for a frequently used string.'}, 169 | \{'word': 'delim' 170 | \,'info': 'Define two characters to mark the left and right ends of an eqn equation to be printed in line.'}, 171 | \{'word': 'down' 172 | \,'abbr': 'down {n}' 173 | \,'info': 'Move down n 1/100’s of an em.'}, 174 | \{'word': 'fat' 175 | \,'info': 'Widen the current font by overstriking it.'}, 176 | \{'word': 'font' 177 | \,'abbr': 'font {x}' 178 | \,'info': 'Change to font x, where x is the one-character name or the number of a font.'}, 179 | \{'word': 'from' 180 | \,'info': 'Used in summations, integrals and other similar constructions to signify the lower limit.'}, 181 | \{'word': 'fwd' 182 | \,'abbr': 'fwd {n}' 183 | \,'info': 'Move forward n 1/100’s of an em.'}, 184 | \{'word': 'gfont' 185 | \,'abbr': 'gfont {x}' 186 | \,'info': 'Set a global font x for all equations.'}, 187 | \{'word': 'gsize' 188 | \,'abbr': 'gsize {n}' 189 | \,'info': 'Set a global size for all equations.'}, 190 | \{'word': 'italic' 191 | \,'info': 'Change to italic font.'}, 192 | \{'word': 'lcol' 193 | \,'info': 'Left justify a column of a matrix.'}, 194 | \{'word': 'left' 195 | \,'info': 'Create large brackets, braces, bars, etc.'}, 196 | \{'word': 'lineup' 197 | \,'info': 'Line up marks in equations on different lines.'}, 198 | \{'word': 'lpile' 199 | \,'info': 'Left justify the elements of a pile.'}, 200 | \{'word': 'mark' 201 | \,'info': 'Remember the horizontal position in an equation. Used with lineup.'}, 202 | \{'word': 'matrix' 203 | \,'info': 'Create a matrix.'}, 204 | \{'word': 'ndefine' 205 | \,'info': 'Create a definition which only takes effect when neqn is running.'}, 206 | \{'word': 'over' 207 | \,'info': 'Make a fraction.'}, 208 | \{'word': 'pile' 209 | \,'info': 'Make a vertical pile with elements centered above one another.'}, 210 | \{'word': 'rcol' 211 | \,'info': 'Right adjust a column of a matrix.'}, 212 | \{'word': 'right' 213 | \,'info': 'Create large brackets, braces, bars, etc.'}, 214 | \{'word': 'roman' 215 | \,'info': 'Change to roman font.'}, 216 | \{'word': 'rpile' 217 | \,'info': 'Right justify the elements of a pile.'}, 218 | \{'word': 'size' 219 | \,'abbr': 'size {n}' 220 | \,'info': 'Change the size of the font to n.'}, 221 | \{'word': 'sqrt' 222 | \,'info': 'Draw a square root sign.'}, 223 | \{'word': 'sub' 224 | \,'info': 'Start a subscript.'}, 225 | \{'word': 'sup' 226 | \,'info': 'Start a superscript.'}, 227 | \{'word': 'tdefine' 228 | \,'info': 'Make a definition that will apply only for eqn.'}, 229 | \{'word': 'to' 230 | \,'info': 'Used in summations, integrals, and other similar constructions to signify the upper limit.'}, 231 | \{'word': 'up {n} ' 232 | \,'info': 'Move up n 1/100’s of an em.'}, 233 | \] 234 | " }}}3 "eqn 235 | -------------------------------------------------------------------------------- /autoload/groff_char.vim: -------------------------------------------------------------------------------- 1 | " File: char.vim 2 | " Maintainer: Gavin Jaeger-Freeborn 3 | " Created: Mon 12 Oct 2020 02:15:52 PM 4 | " License: 5 | " Copyright (c) Gavin Jaeger-Freeborn. Distributed under the same terms as Vim itself. 6 | " See :help license 7 | " 8 | " Description: Completion for groff chars 9 | " NOTE: currently only focused on groff 10 | 11 | " This allows for competion of gifs such as \[la] and \[Fn] 12 | function! groff_char#GroffCompleteGlyph(escape_sequence) " {{{ 13 | let postescape = '' 14 | if a:escape_sequence ==# '\\[' 15 | let postescape = ']' 16 | endif 17 | let namedglyph = [ 18 | \{'word': 'AN'.postescape, 'menu' :'∧', 'info':'logical and'}, 19 | \{'word': 'OR'.postescape, 'menu' :'∨', 'info':'logical or'}, 20 | \{'word': 'no'.postescape, 'menu' :'¬', 'info':'logical not + ***'}, 21 | \{'word': 'tno'.postescape, 'menu' :'¬', 'info':'text variant of ‘no’'}, 22 | \{'word': 'te'.postescape, 'menu' :'∃', 'info':'there exists'}, 23 | \{'word': 'fa'.postescape, 'menu' :'∀', 'info':'for all'}, 24 | \{'word': 'st'.postescape, 'menu' :'∋', 'info':'sucht that'}, 25 | \{'word': '3d'.postescape, 'menu' :'∴', 'info':'therefore'}, 26 | \{'word': 'tf'.postescape, 'menu' :'∴', 'info':'therefore'}, 27 | \{'word': 'or'.postescape, 'menu' :'|', 'info':'bitwise OR operator (as used in C) +'}, 28 | \{'word': '12'.postescape, 'menu' :'½', 'info':'1/2 symbol +'}, 29 | \{'word': '14'.postescape, 'menu' :'¼', 'info':'1/4 symbol +'}, 30 | \{'word': '34'.postescape, 'menu' :'¾', 'info':'3/4 symbol +'}, 31 | \{'word': '18'.postescape, 'menu' :'⅛', 'info':'1/8 symbol'}, 32 | \{'word': '38'.postescape, 'menu' :'⅜', 'info':'3/8 symbol'}, 33 | \{'word': '58'.postescape, 'menu' :'⅝', 'info':'5/8 symbol'}, 34 | \{'word': '78'.postescape, 'menu' :'⅞', 'info':'7/8 symbol'}, 35 | \{'word': 'S1'.postescape, 'menu' :'¹', 'info':'superscript 1'}, 36 | \{'word': 'S2'.postescape, 'menu' :'²', 'info':'superscript 2'}, 37 | \{'word': 'S3'.postescape, 'menu' :'³', 'info':'superscript 3'}, 38 | \{'word': 'pl'.postescape, 'menu' :'+', 'info':'plus in special font +'}, 39 | \{'word': 'mi'.postescape, 'menu' :'−', 'info':'minus in special font +'}, 40 | \{'word': '-+'.postescape, 'menu' :'∓', 'info':'minus-plus'}, 41 | \{'word': '+-'.postescape, 'menu' :'±', 'info':'plus-minus + ***'}, 42 | \{'word': 't+-'.postescape, 'menu' :'±', 'info':'text variant of \[+-]'}, 43 | \{'word': 'pc'.postescape, 'menu' :'·', 'info':'period centered'}, 44 | \{'word': 'md'.postescape, 'menu' :'⋅', 'info':'multiplication dot'}, 45 | \{'word': 'mu'.postescape, 'menu' :'×', 'info':'multiply sign + ***'}, 46 | \{'word': 'tmu'.postescape, 'menu' :'×', 'info':'text variant of \[mu]'}, 47 | \{'word': 'c*'.postescape, 'menu' :'⊗', 'info':'multiply sign in circle'}, 48 | \{'word': 'c+'.postescape, 'menu' :'⊕', 'info':'plus sign in circle'}, 49 | \{'word': 'di'.postescape, 'menu' :'÷', 'info':'division sign + ***'}, 50 | \{'word': 'tdi'.postescape, 'menu' :'÷', 'info':'text variant of \[di]'}, 51 | \{'word': 'f/'.postescape, 'menu' :'⁄', 'info':'bar for fractions'}, 52 | \{'word': '**'.postescape, 'menu' :'∗', 'info':'mathematical asterisk +'}, 53 | \{'word': '<='.postescape, 'menu' :'≤', 'info':'less or equal +'}, 54 | \{'word': '>='.postescape, 'menu' :'≥', 'info':'greater or equal +'}, 55 | \{'word': '<<'.postescape, 'menu' :'≪', 'info':'much less'}, 56 | \{'word': '>>'.postescape, 'menu' :'≫', 'info':'much greater'}, 57 | \{'word': 'eq'.postescape, 'menu' :'=', 'info':'equals in special font +'}, 58 | \{'word': '!='.postescape, 'menu' :'≠', 'info':'not equal +'}, 59 | \{'word': '=='.postescape, 'menu' :'≡', 'info':'equivalent +'}, 60 | \{'word': 'ne'.postescape, 'menu' :'≢', 'info':'not equivalent'}, 61 | \{'word': '=~'.postescape, 'menu' :'≅', 'info':'congruent, approx. equal'}, 62 | \{'word': '|='.postescape, 'menu' :'≃', 'info':'asymptot. equal to +'}, 63 | \{'word': 'ap'.postescape, 'menu' :'∼', 'info':'similar +'}, 64 | \{'word': '~~'.postescape, 'menu' :'≈', 'info':'almost equal to'}, 65 | \{'word': '~='.postescape, 'menu' :'≈', 'info':'almost equal to'}, 66 | \{'word': 'pt'.postescape, 'menu' :'∝', 'info':'proportional +'}, 67 | \{'word': 'es'.postescape, 'menu' :'∅', 'info':'empty set +'}, 68 | \{'word': 'mo'.postescape, 'menu' :'∈', 'info':'element of a set +'}, 69 | \{'word': 'nm'.postescape, 'menu' :'∉', 'info':'not element of set'}, 70 | \{'word': 'sb'.postescape, 'menu' :'⊂', 'info':'proper subset +'}, 71 | \{'word': 'nb'.postescape, 'menu' :'⊄', 'info':'not supset'}, 72 | \{'word': 'sp'.postescape, 'menu' :'⊃', 'info':'proper superset +'}, 73 | \{'word': 'nc'.postescape, 'menu' :'⊅', 'info':'not superset'}, 74 | \{'word': 'ib'.postescape, 'menu' :'⊆', 'info':'subset or equal +'}, 75 | \{'word': 'ip'.postescape, 'menu' :'⊇', 'info':'superset or equal +'}, 76 | \{'word': 'ca'.postescape, 'menu' :'∩', 'info':'intersection, cap +'}, 77 | \{'word': 'cu'.postescape, 'menu' :'∪', 'info':'union, cup +'}, 78 | \{'word': '/_'.postescape, 'menu' :'∠', 'info':'angle'}, 79 | \{'word': 'pp'.postescape, 'menu' :'⊥', 'info':'perpendicular'}, 80 | \{'word': 'is'.postescape, 'menu' :'∫', 'info':'integral +'}, 81 | \{'word': 'integral'.postescape, 'menu' :'∫', 'info':'integral ***'}, 82 | \{'word': 'sum'.postescape, 'menu' :'∑', 'info':'summation ***'}, 83 | \{'word': 'product'.postescape, 'menu' :'∏', 'info':'product ***'}, 84 | \{'word': 'coproduct'.postescape,'menu' :'∐', 'info':'coproduct ***'}, 85 | \{'word': 'gr'.postescape, 'menu' :'∇', 'info':'gradient +'}, 86 | \{'word': 'sr'.postescape, 'menu' :'√', 'info':'square root +'}, 87 | \{'word': 'sqrt'.postescape, 'menu' :'√', 'info':'square root'}, 88 | \{'word': 'lc'.postescape, 'menu' :'⌈', 'info':'left ceiling +'}, 89 | \{'word': 'rc'.postescape, 'menu' :'⌉', 'info':'right ceiling +'}, 90 | \{'word': 'lf'.postescape, 'menu' :'⌊', 'info':'left floor +'}, 91 | \{'word': 'rf'.postescape, 'menu' :'⌋', 'info':'right floor +'}, 92 | \{'word': 'if'.postescape, 'menu' :'∞', 'info':'infinity +'}, 93 | \{'word': 'Ah'.postescape, 'menu' :'ℵ', 'info':'aleph'}, 94 | \{'word': 'Im'.postescape, 'menu' :'ℑ', 'info':'Gothic I, imaginary'}, 95 | \{'word': 'Re'.postescape, 'menu' :'ℜ', 'info':'Gothic R, real'}, 96 | \{'word': 'wp'.postescape, 'menu' :'℘', 'info':'Weierstrass p'}, 97 | \{'word': 'pd'.postescape, 'menu' :'∂', 'info':'partial differentiation +'}, 98 | \{'word': '-h'.postescape, 'menu' :'ℏ', 'info':'Planck constant / 2pi (h-bar)'}, 99 | \{'word': 'hbar'.postescape, 'menu' :'ℏ', 'info':'Planck constant / 2pi (h-bar)'}, 100 | \] 101 | return namedglyph 102 | endfunction 103 | " }}} "GroffcompleteCandidates 104 | -------------------------------------------------------------------------------- /autoload/pic.vim: -------------------------------------------------------------------------------- 1 | " File: pic.vim 2 | " Maintainer: Gavin Jaeger-Freeborn 3 | " Created: Mon 12 Oct 2020 01:59:40 PM 4 | " License: 5 | " Copyright (c) Gavin Jaeger-Freeborn. Distributed under the same terms as Vim itself. 6 | " See :help license 7 | " 8 | " Description: 9 | " Completion for pic sections of troff files 10 | 11 | 12 | " you can find more of them at /home/gavinok/groff/doc/pic.pdf 13 | let s:pic_closed_primitives = [ 'box', 'circle', 'ellipse' ] 14 | let s:pic_open_primitives = [ 'arc', 'line', 'arrow', 'spline' ] 15 | let s:pic_closed_attributes = [ 16 | \'ht', 17 | \'height', 18 | \'wid', 19 | \'width', 20 | \'solid', 21 | \] 22 | let s:pic_closed_curve_attributes = [ 23 | \'rad', 24 | \'radius', 25 | \'diam', 26 | \'diameter', 27 | \] 28 | let s:pic_open_attributes = [ 29 | \'from', 30 | \'to', 31 | \'at', 32 | \] 33 | let s:pic_circle_attribute = [ 'diam', 'rad'] 34 | let s:pic_objects_attribute = [ 'colored', 'shaded', 'outlined', 'invis', 'dotted', 'dashed'] 35 | let s:pic_directions = ['down', 'up', 'right', 'left'] 36 | let s:pic_options = [ 'dashed', 'inves', 'at (' ] 37 | let s:pic_expressions = [ 38 | \{ 'word': 'sin(', 'info': 'sin(x)' }, 39 | \{ 'word': 'cos(', 'info': 'cos(x)' }, 40 | \{ 'word': 'atan2(', 'info': 'atan2(y, x)' }, 41 | \{ 'word': 'log(x)', 'info': 'log(x) (base 10)' }, 42 | \{ 'word': 'exp(x)', 'info': 'exp(x) (base 10, i.e. 10^x)' }, 43 | \{ 'word': 'sqrt(', 'info': 'sqrt(x)' }, 44 | \{ 'word': 'int(', 'info': 'int(x)' }, 45 | \{ 'word': 'rand()', 'info': 'rand() (return a random number between 0 and 1)' }, 46 | \{ 'word': 'rand(', 'info': 'rand(x) (return a random number between 1 and x; deprecated)' }, 47 | \{ 'word': 'srand(', 'info': 'srand(x) (set the random number seed)' }, 48 | \{ 'word': 'max(', 'info': 'max(e1, e2)' }, 49 | \{ 'word': 'min(', 'info': 'min(e1, e2)' }, 50 | \] 51 | let s:pic = s:pic_closed_primitives + s:pic_open_primitives 52 | 53 | " TODO: Improve pic completion <09-10-20 Gavin Jaeger-Freeborn> 54 | " used for completion in pic 55 | function! pic#PicComplete(context) abort " {{{ 56 | " 57 | let object = matchstr(a:context, '^\zs\k\+\ze\s\+$') 58 | if object =~# '\(box\|circle\|ellipse\)' 59 | return s:pic_closed_attributes + s:pic_objects_attribute + s:pic_options 60 | elseif object =~# '\(arc\|line\|arrow\|spline\)' 61 | return s:pic_open_attributes + s:pic_options 62 | endif 63 | " if a:context =~? '\(^\|^.*;\)$' 64 | return s:pic_open_primitives + s:pic_closed_primitives + s:pic_directions 65 | " endif 66 | return [] 67 | endfunction " }}} 68 | -------------------------------------------------------------------------------- /autoload/requests.vim: -------------------------------------------------------------------------------- 1 | " File: requests.vim 2 | " Maintainer: Gavin Jaeger-Freeborn 3 | " Created: Mon 12 Oct 2020 02:09:27 PM 4 | " License: 5 | " Copyright (c) Gavin Jaeger-Freeborn. Distributed under the same terms as Vim itself. 6 | " See :help license 7 | " 8 | " Description: 9 | " Display troff documentation and Completion for base troff requests 10 | " NOTE: focused on groff at the moment (compatibility with other troffs coming soon) 11 | 12 | 13 | " This gives options for completing base groff commands 14 | function! requests#GetRequests() 15 | " This gives options for completing base groff commands 16 | " base_macros "{{{ 17 | let base_macros = [ 18 | \{ 'word': 'ab' 19 | \, 'abbr': 'ab [string]' , 'info': 'Print string on standard error , exit program.' } , 20 | \{ 'word': 'ad' 21 | \, 'abbr': 'ad' , 'info': 'Begin line adjustment for output lines in current adjust mode.' } , 22 | \{ 'word': 'ad' 23 | \, 'abbr': 'ad [c]' , 'info': 'Start line adjustment in mode c (c=l,r,c,b,n).' } , 24 | \{ 'word': 'af' 25 | \, 'abbr': 'af [register] [c] ' , 'info': 'Assign format c to register (c=l,i,I,a,A).' } , 26 | \{ 'word': 'aln' 27 | \, 'abbr': 'aln [alias] [register] ' , 'info': 'Create alias name for register.' } , 28 | \{ 'word': 'als' 29 | \, 'abbr': 'als [alias] [object] ' , 'info': 'Create alias name for request, string, macro, or diversion object.' } , 30 | \{ 'word': 'am' 31 | \, 'abbr': 'am [macro]' , 'info': 'Append to macro until .. is encountered.' } , 32 | \{ 'word': 'am' 33 | \, 'abbr': 'am [macro] [end] ' , 'info': 'Append to macro until .end is called.' } , 34 | \{ 'word': 'am1' 35 | \, 'abbr': 'am1 [macro]' , 'info': 'Same as .am but with compatibility mode switched off during macro expansion.' } , 36 | \{ 'word': 'am1' 37 | \, 'abbr': 'am1 [macro] [end] ' , 'info': 'Same as .am but with compatibility mode switched off during macro expansion.' } , 38 | \{ 'word': 'ami' 39 | \, 'abbr': 'ami [macro]' , 'info': 'Append to a macro whose name is contained in the string register macro until .. is encountered.' } , 40 | \{ 'word': 'ami' 41 | \, 'abbr': 'ami [macro] [end] ' , 'info': 'Append to a macro indirectly. macro and end are string registers whose contents are interpolated for the macro name and the end macro, respectively.' } , 42 | \{ 'word': 'ami1' 43 | \, 'abbr': 'ami1 [macro]' , 'info': 'Same as .ami but with compatibility mode switched off during macro expansion.' } , 44 | \{ 'word': 'ami1' 45 | \, 'abbr': 'ami1 [macro] [end] ' , 'info': 'Same as .ami but with compatibility mode switched off during macro expansion.' } , 46 | \{ 'word': 'as' 47 | \, 'abbr': 'as [stringvar] [anything] ' , 'info': 'Append anything to stringvar.' } , 48 | \{ 'word': 'as1' 49 | \, 'abbr': 'as1 [stringvar] [anything] ' , 'info': 'Same as .as but with compatibility mode switched off during string expansion.' } , 50 | \{ 'word': 'asciify' 51 | \, 'abbr': 'asciify [diversion]' , 'info': 'Unformat ASCII characters, spaces, and some escape sequences in diversion.' } , 52 | \{ 'word': 'backtrace' 53 | \, 'abbr': 'backtrace ' , 'info': 'Print a backtrace of the input on stderr.' } , 54 | \{ 'word': 'bd' 55 | \, 'abbr': 'bd [font] [N] ' , 'info': 'Embolden font by N-1 units.' } , 56 | \{ 'word': 'bd' 57 | \, 'abbr': 'bd [S] [font] [N] ' , 'info': 'Embolden Special Font S when current font is font.' } , 58 | \{ 'word': 'blm' 59 | \, 'abbr': 'blm' , 'info': 'Unset the blank line macro.' } , 60 | \{ 'word': 'blm' 61 | \, 'abbr': 'blm [macro]' , 'info': 'Set the blank line macro to macro.' } , 62 | \{ 'word': 'box' 63 | \, 'abbr': 'box' , 'info': 'End current diversion.' } , 64 | \{ 'word': 'box' 65 | \, 'abbr': 'box [macro]' , 'info': 'Divert to macro, omitting a partially filled line.' } , 66 | \{ 'word': 'boxa' 67 | \, 'abbr': 'boxa' , 'info': 'End current diversion.' } , 68 | \{ 'word': 'boxa' 69 | \, 'abbr': 'boxa [macro]' , 'info': 'Divert and append to macro, omitting a partially filled line.' } , 70 | \{ 'word': 'bp' 71 | \, 'abbr': 'bp' , 'info': 'Eject current page and begin new page.' } , 72 | \{ 'word': 'bp' 73 | \, 'abbr': 'bp [±N]' , 'info': 'Eject current page; next page number ±N.' } , 74 | \{ 'word': 'br' 75 | \, 'abbr': 'br' , 'info': 'Line break.' } , 76 | \{ 'word': 'brp' 77 | \, 'abbr': 'brp' , 'info': 'Break output line; adjust if applicable.' } , 78 | \{ 'word': 'break' 79 | \, 'abbr': 'break' , 'info': 'Break out of a while loop.' } , 80 | \{ 'word': 'c2' 81 | \, 'abbr': 'c2' , 'info': 'Reset no-break control character to quotes ' } , 82 | \{ 'word': 'c2' 83 | \, 'abbr': 'c2 [c]' , 'info': 'Set no-break control character to c.' } , 84 | \{ 'word': 'cc' 85 | \, 'abbr': 'cc' , 'info': 'Reset control character to ‘.’.' } , 86 | \{ 'word': 'cc' 87 | \, 'abbr': 'cc [c]' , 'info': 'Set control character to c.' } , 88 | \{ 'word': 'ce' 89 | \, 'abbr': 'ce' , 'info': 'Center the next input line.' } , 90 | \{ 'word': 'ce' 91 | \, 'abbr': 'ce [N]' , 'info': 'Center following N input lines.' } , 92 | \{ 'word': 'cf' 93 | \, 'abbr': 'cf [filename]' , 'info': 'Copy contents of file filename unprocessed to stdout or to the diversion.' } , 94 | \{ 'word': 'cflags' 95 | \, 'abbr': 'cflags [mode] [c1] [c2] ...' , 'info': 'Treat characters c1, c2 , ... according to mode number.' } , 96 | \{ 'word': 'ch' 97 | \, 'abbr': 'ch [trap] [N] ' , 'info': 'Change trap location to N.' } , 98 | \{ 'word': 'char' 99 | \, 'abbr': 'char [c] [anything] ' , 'info': 'Define entity c as string anything.' } , 100 | \{ 'word': 'chop' 101 | \, 'abbr': 'chop [object]' , 'info': 'Chop the last character off macro, string, or diversion object.' } , 102 | \{ 'word': 'class' 103 | \, 'abbr': 'class [name] [c1] [c2] ...' , 'info': 'Assign a set of characters, character ranges, or classes c1, c2, ... to name.' } , 104 | \{ 'word': 'close' 105 | \, 'abbr': 'close [stream]' , 'info': 'Close the stream.' } , 106 | \{ 'word': 'color' 107 | \, 'abbr': 'color' , 'info': 'Enable colors.' } , 108 | \{ 'word': 'color' 109 | \, 'abbr': 'color [N]' , 'info': 'If N is zero disable colors, otherwise enable them.' } , 110 | \{ 'word': 'composite' 111 | \, 'abbr': 'composite [from] [to] ' , 'info': 'Map glyph name from to glyph name to while constructing a composite glyph name.' } , 112 | \{ 'word': 'continue' 113 | \, 'abbr': 'continue' , 'info': 'Finish the current iteration of a while loop.' }, 114 | \{ 'word': 'cp' 115 | \, 'abbr': 'cp' , 'info': 'Enable compatibility mode.' } , 116 | \{ 'word': 'cp' 117 | \, 'abbr': 'cp [N]' , 'info': 'If N is zero disable compatibility mode, otherwise enable it.' } , 118 | \{ 'word': 'cs' 119 | \, 'abbr': 'cs [font] [N] [M] ' , 'info': 'Set constant character width mode for font to N/36 ems with em M.' } , 120 | \{ 'word': 'cu' 121 | \, 'abbr': 'cu [N]' , 'info': 'Continuous underline in nroff, like .ul in troff.' } , 122 | \{ 'word': 'da' 123 | \, 'abbr': 'da' , 'info': 'End current diversion.' }, 124 | \{ 'word': 'da' 125 | \, 'abbr': 'da [macro]' , 'info': 'Divert and append to macro.' } , 126 | \{ 'word': 'de' 127 | \, 'abbr': 'de [macro]' , 'info': 'Define or redefine macro until .. is encountered.' } , 128 | \{ 'word': 'de' 129 | \, 'abbr': 'de [macro] [end] ' , 'info': 'Define or redefine macro until .end is called.' } , 130 | \{ 'word': 'de1' 131 | \, 'abbr': 'de1 [macro]' , 'info': 'Same as .de but with compatibility mode switched off during macro expansion.' } , 132 | \{ 'word': 'de1' 133 | \, 'abbr': 'de1 [macro] [end] ' , 'info': 'Same as .de but with compatibility mode switched off during macro expansion.' } , 134 | \{ 'word': 'defcolor' 135 | \, 'abbr': 'defcolor [color] [scheme] [component] ' , 'info': 'Define or redefine a color with name color. scheme can be rgb, cym, cymk, gray, or grey. component can be single components specified as fractions in the range 0 to 1 (default scaling indicator f), as a string of two-digit hexadecimal color components with a leading #, or as a string of four-digit hexadecimal components with two leading #. The color default cant be redefined.' }, 136 | \{ 'word': 'dei' 137 | \, 'abbr': 'dei [macro]' , 'info': 'Define or redefine a macro whose name is contained in the string register macro until .. is encountered.' } , 138 | \{ 'word': 'dei' 139 | \, 'abbr': 'dei [macro] [end] ' , 'info': 'Define or redefine a macro indirectly. macro and end are string registers whose contents are interpolated for the macro name and the end macro, respectively.' } , 140 | \{ 'word': 'dei1' 141 | \, 'abbr': 'dei1 [macro]' , 'info': 'Same as .dei but with compatibility mode switched off during macro expansion.' } , 142 | \{ 'word': 'dei1' 143 | \, 'abbr': 'dei1 [macro] [end] ' , 'info': 'Same as .dei but with compatibility mode switched off during macro expansion.' } , 144 | \{ 'word': 'device' 145 | \, 'abbr': 'device [anything]' , 'info': 'Write anything to the intermediate output as a device control function.' } , 146 | \{ 'word': 'devicem' 147 | \, 'abbr': 'devicem [name]' , 'info': 'Write contents of macro or string name uninterpreted to the intermediate output as a device control function.' } , 148 | \{ 'word': 'di' 149 | \, 'abbr': 'di' , 'info': 'End current diversion.' } , 150 | \{ 'word': 'di' 151 | \, 'abbr': 'di [macro] [Divert] [to] [macro].' , 'info': 'See groff_tmac(5) for more details.' } , 152 | \{ 'word': 'do' 153 | \, 'abbr': 'do [name]' , 'info': 'Interpret .name with compatibility mode disabled.' } , 154 | \{ 'word': 'ds' 155 | \, 'abbr': 'ds [stringvar] [anything] ' , 'info': 'Set stringvar to anything.' } , 156 | \{ 'word': 'ds1' 157 | \, 'abbr': 'ds1 [stringvar] [anything] ' , 'info': 'Same as .ds but with compatibility mode switched off during string expansion.' } , 158 | \{ 'word': 'dt' 159 | \, 'abbr': 'dt [N] [trap] ' , 'info': 'Set diversion trap to position N (default scaling indicator v).' } , 160 | \{ 'word': 'ec' 161 | \, 'abbr': 'ec' , 'info': 'Reset escape character to ‘\’.' } , 162 | \{ 'word': 'ec' 163 | \, 'abbr': 'ec [c]' , 'info': 'Set escape character to c.' } , 164 | \{ 'word': 'ecr' 165 | \, 'abbr': 'ecr' , 'info': 'Restore escape character saved with .ecs.' } , 166 | \{ 'word': 'ecs' 167 | \, 'abbr': 'ecs' , 'info': 'Save current escape character.' } , 168 | \{ 'word': 'el' 169 | \, 'abbr': 'el [anything]' , 'info': 'Else part for if-else (.ie) request.' } , 170 | \{ 'word': 'em' 171 | \, 'abbr': 'em [macro]' , 'info': 'The macro is run after the end of input.' } , 172 | \{ 'word': 'eo' 173 | \, 'abbr': 'eo' , 'info': 'Turn off escape character mechanism.' } , 174 | \{ 'word': 'ev' 175 | \, 'abbr': 'ev' , 'info': 'Switch to previous environment and pop it off the stack.' } , 176 | \{ 'word': 'ev' 177 | \, 'abbr': 'ev [env]' , 'info': 'Push down environment number or name env to the stack and switch to it.' } , 178 | \{ 'word': 'evc' 179 | \, 'abbr': 'evc [env]' , 'info': 'Copy the contents of environment env to the current environment. No pushing or popping.' } , 180 | \{ 'word': 'ex' 181 | \, 'abbr': 'ex' , 'info': 'Exit from roff processing.' } , 182 | \{ 'word': 'fam' 183 | \, 'abbr': 'fam' , 'info': 'Return to previous font family.' } , 184 | \{ 'word': 'fam' 185 | \, 'abbr': 'fam [name]' , 'info': 'Set the current font family to name.' } , 186 | \{ 'word': 'fc' 187 | \, 'abbr': 'fc' , 'info': 'Disable field mechanism.' } , 188 | \{ 'word': 'fc' 189 | \, 'abbr': 'fc [a]' , 'info': 'Set field delimiter to a and pad glyph to space.' } , 190 | \{ 'word': 'fc' 191 | \, 'abbr': 'fc [a] [b]' , 'info': 'Set field delimiter to a and pad glyph to b.' } , 192 | \{ 'word': 'fchar' 193 | \, 'abbr': 'fchar [c] [anything] ' , 'info': 'Define fallback character (or glyph) c as string anything.' } , 194 | \{ 'word': 'fcolor' 195 | \, 'abbr': 'fcolor' , 'info': 'Set fill color to previous fill color.' } , 196 | \{ 'word': 'fcolor' 197 | \, 'abbr': 'fcolor [c]' , 'info': 'Set fill color to c.' } , 198 | \{ 'word': 'fi' 199 | \, 'abbr': 'fi' , 'info': 'Fill output lines.' } , 200 | \{ 'word': 'fl' 201 | \, 'abbr': 'fl' , 'info': 'Flush output buffer.' } , 202 | \{ 'word': 'fp' 203 | \, 'abbr': 'fp [n] [font] ' , 'info': 'Mount font on position n.' } , 204 | \{ 'word': 'fp' 205 | \, 'abbr': 'fp [n] [internal] [external]' , 'info': 'Mount font with long external name to short internal name on position n.' } , 206 | \{ 'word': 'fschar' 207 | \, 'abbr': 'fschar [f] [c] [anything]' , 'info': 'Define fallback character (or glyph) c for font f as string anything.' } , 208 | \{ 'word': 'fspecial' 209 | \, 'abbr': 'fspecial [font]' , 'info': 'Reset list of special fonts for font to be empty.' } , 210 | \{ 'word': 'fspecial' 211 | \, 'abbr': 'fspecial [font] [s1] [s2] ...' , 'info': 'When the current font is font, then the fonts s1, s2, ... are special.' } , 212 | \{ 'word': 'ft' 213 | \, 'abbr': 'ft' , 'info': 'Return to previous font. Same as \ or \.' } , 214 | \{ 'word': 'ft' 215 | \, 'abbr': 'ft [font]' , 'info': 'Change to font name or number font; same as \f[font] escape sequence.' } , 216 | \{ 'word': 'ftr' 217 | \, 'abbr': 'ftr [font1] [font2]' , 'info': 'Translate font1 to font2.' } , 218 | \{ 'word': 'fzoom' 219 | \, 'abbr': 'fzoom [font]' , 'info': 'Dont magnify font.' } , 220 | \{ 'word': 'fzoom' 221 | \, 'abbr': 'fzoom [font] [zoom]' , 'info': 'Set zoom factor for font (in multiples of 1/1000th).' } , 222 | \{ 'word': 'gcolor' 223 | \, 'abbr': 'gcolor' , 'info': 'Set glyph color to previous glyph color.' } , 224 | \{ 'word': 'gcolor' 225 | \, 'abbr': 'gcolor [c]' , 'info': 'Set glyph color to c.' } , 226 | \{ 'word': 'hc' 227 | \, 'abbr': 'hc' , 'info': 'Remove additional hyphenation indicator character.' } , 228 | \{ 'word': 'hc' 229 | \, 'abbr': 'hc [c]' , 'info': 'Set up additional hyphenation indicator character c.' } , 230 | \{ 'word': 'hcode' 231 | \, 'abbr': 'hcode [c1] [code1] [c2 code2] ...' , 'info': 'Set the hyphenation code of character c1 to code1, that of c2 to code2, etc.' } , 232 | \{ 'word': 'hla' 233 | \, 'abbr': 'hla', 'info': 'lang Set the current hyphenation language to lang.' } , 234 | \{ 'word': 'hlm' 235 | \, 'abbr': 'hlm [n]' , 'info': 'Set the maximum number of consecutive hyphenated lines to n.' } , 236 | \{ 'word': 'hpf' 237 | \, 'abbr': 'hpf [file]', 'info': 'Read hyphenation patterns from file.' } , 238 | \{ 'word': 'hpfa' 239 | \, 'abbr': 'hpfa [file]' , 'info': 'Append hyphenation patterns from file.' } , 240 | \{ 'word': 'hpfcode' 241 | \, 'abbr': 'hpfcode [a] [b] [c] [d] ...' , 'info': 'Set input mapping for .hpf.' } , 242 | \{ 'word': 'hw' 243 | \, 'abbr': 'hw [words]' , 'info': 'List of words with exceptional hyphenation.' } , 244 | \{ 'word': 'hy' 245 | \, 'abbr': 'hy [N]' , 'info': 'Switch to hyphenation mode N.' } , 246 | \{ 'word': 'hym' 247 | \, 'abbr': 'hym [n]' , 'info': 'Set the hyphenation margin to n (default scaling indicator m).' } , 248 | \{ 'word': 'hys' 249 | \, 'abbr': 'hys [n]' , 'info': 'Set the hyphenation space to n.' } , 250 | \{ 'word': 'ie' 251 | \, 'abbr': 'ie [cond] [anything]' , 'info': 'If cond then anything else goto .el.' } , 252 | \{ 'word': 'if' 253 | \, 'abbr': 'if [cond] [anything]' , 'info': 'If cond then anything; otherwise do nothing.' } , 254 | \{ 'word': 'ig' 255 | \, 'abbr': 'ig' , 'info': 'Ignore text until .. is encountered.' } , 256 | \{ 'word': 'ig' 257 | \, 'abbr': 'ig [end]' , 'info': 'Ignore text until .end is called.' } , 258 | \{ 'word': 'in' 259 | \, 'abbr': 'in' , 'info': 'Change to previous indentation value.' } , 260 | \{ 'word': 'in' 261 | \, 'abbr': 'in [±N]' , 'info': 'Change indentation according to ±N (default scaling indicator m).' } , 262 | \{ 'word': 'it' 263 | \, 'abbr': 'it [N] [trap]' , 'info': 'Set an input-line count trap for the next N lines.' } , 264 | \{ 'word': 'itc' 265 | \, 'abbr': 'itc [N] [trap]' , 'info': 'Same as .it but dont count lines interrupted with \c.' } , 266 | \{ 'word': 'kern' 267 | \, 'abbr': 'kern' , 'info': 'Enable pairwise kerning.' } , 268 | \{ 'word': 'kern' 269 | \, 'abbr': 'kern [n]' , 'info': 'If n is zero, disable pairwise kerning, otherwise enable it.' } , 270 | \{ 'word': 'lc' 271 | \, 'abbr': 'lc' , 'info': 'Remove leader repetition glyph.' } , 272 | \{ 'word': 'lc' 273 | \, 'abbr': 'lc [c]' , 'info': 'Set leader repetition glyph to c.' } , 274 | \{ 'word': 'length' 275 | \, 'abbr': 'length [register] [anything]' , 'info': 'Write the length of the string anything to register.' } , 276 | \{ 'word': 'linetabs' 277 | \, 'abbr': 'linetabs' ,'info': 'Enable line-tabs mode (i.e., calculate tab positions relative to output line).' } , 278 | \{ 'word': 'linetabs' 279 | \, 'abbr': 'linetabs [n]' , 'info': 'If n is zero, disable line-tabs mode, otherwise enable it.' } , 280 | \{ 'word': 'lf' 281 | \, 'abbr': 'lf [N]' , 'info': 'Set input line number to N.' } , 282 | \{ 'word': 'lf' 283 | \, 'abbr': 'lf [N] [file]' , 'info': 'Set input line number to N and filename to file.' } , 284 | \{ 'word': 'lg' 285 | \, 'abbr': 'lg [N]' , 'info': 'Ligature mode on if N>0.' } , 286 | \{ 'word': 'll' 287 | \, 'abbr': 'll' , 'info': 'Change to previous line length.' } , 288 | \{ 'word': 'll' 289 | \, 'abbr': 'll [±N]' , 'info': 'Set line length according to ±N (default length 6.5i, default scaling indicator m).' } , 290 | \{ 'word': 'lsm' 291 | \, 'abbr': 'lsm' , 'info': 'Unset the leading spaces macro.' } , 292 | \{ 'word': 'lsm' 293 | \, 'abbr': 'lsm [macro]' , 'info': 'Set the leading spaces macro to macro.' } , 294 | \{ 'word': 'ls' 295 | \, 'abbr': 'ls' , 'info': 'Change to the previous value of additional intra-line skip.' } , 296 | \{ 'word': 'ls' 297 | \, 'abbr': 'ls [N]' , 'info': 'Set additional intra-line skip value to N, i.e., N-1 blank lines are inserted after each text output line.' } , 298 | \{ 'word': 'lt' 299 | \, 'abbr': 'lt [±N]' , 'info': 'Length of title (default scaling indicator m).' } , 300 | \{ 'word': 'mc' 301 | \, 'abbr': 'mc' , 'info': 'Margin glyph off.' } , 302 | \{ 'word': 'mc' 303 | \, 'abbr': 'mc [c]' , 'info': 'Print glyph c after each text line at actual distance from right margin.' } , 304 | \{ 'word': 'mc' 305 | \, 'abbr': 'mc [c] [N]' , 'info': 'Set margin glyph to c and distance to N from right margin (default scaling indicator m).' } , 306 | \{ 'word': 'mk' 307 | \, 'abbr': 'mk [register] ' , 'info': 'Mark current vertical position in register, or in an internal register used by .rt if no argument.' } , 308 | \{ 'word': 'mso' 309 | \, 'abbr': 'mso [file]' , 'info': 'The same as .so except that file is searched in the tmac directories.' } , 310 | \{ 'word': 'na' 311 | \, 'abbr': 'na' , 'info': 'No output-line adjusting.' } , 312 | \{ 'word': 'ne' 313 | \, 'abbr': 'ne' , 'info': 'Need a one-line vertical space.' } , 314 | \{ 'word': 'ne' 315 | \, 'abbr': 'ne [N]' , 'info': 'Need N vertical space (default scaling indicator v).' } , 316 | \{ 'word': 'nf' 317 | \, 'abbr': 'nf' , 'info': 'No filling or adjusting of output lines.' } , 318 | \{ 'word': 'nh' 319 | \, 'abbr': 'nh' , 'info': 'No hyphenation.' } , 320 | \{ 'word': 'nm' 321 | \, 'abbr': 'nm' , 'info': 'Number mode off.' } , 322 | \{ 'word': 'nm' 323 | \, 'abbr': 'nm [±N] [M [S] [I] ' , 'info': 'In line number mode, set number, multiple, spacing, and indentation.' } , 324 | \{ 'word': 'nn' 325 | \, 'abbr': 'nn' , 'info': 'Do not number next line.' } , 326 | \{ 'word': 'nn' 327 | \, 'abbr': 'nn [N]' , 'info': 'Do not number next N lines.' } , 328 | \{ 'word': 'nop' 329 | \, 'abbr': 'nop [anything]' , 'info': 'Always process anything.' } , 330 | \{ 'word': 'nr' 331 | \, 'abbr': 'nr [register] [±N] [M] ' , 'info': 'Define or modify register using ±N with auto-increment M.' } , 332 | \{ 'word': 'nroff' 333 | \, 'abbr': 'nroff' , 'info': 'Make the built-in conditions n true and t false.' } , 334 | \{ 'word': 'ns' 335 | \, 'abbr': 'ns' , 'info': 'Turn on no-space mode.' } , 336 | \{ 'word': 'nx' 337 | \, 'abbr': 'nx' , 'info': 'Immediately jump to end of current file.' } , 338 | \{ 'word': 'nx' 339 | \, 'abbr': 'nx [filename]' , 'info': 'Immediately continue processing with file file.' } , 340 | \{ 'word': 'open' 341 | \, 'abbr': 'open [stream] [filename]' , 'info': 'Open filename for writing and associate the stream named stream with it.' } , 342 | \{ 'word': 'opena' 343 | \, 'abbr': 'opena [stream] [filename]' , 'info': 'Like .open but append to it.' } , 344 | \{ 'word': 'os' 345 | \, 'abbr': 'os' , 'info': 'Output vertical distance that was saved by the sv request.' } , 346 | \{ 'word': 'output' 347 | \, 'abbr': 'output [string]' , 'info': 'Emit string directly to intermediate output, allowing leading whitespace if string starts with " (which is stripped off).' } , 348 | \{ 'word': 'pc' 349 | \, 'abbr': 'pc' , 'info': 'Reset page number character to ‘%’.' } , 350 | \{ 'word': 'pc' 351 | \, 'abbr': 'pc [c]' , 'info': 'Page number character.' } , 352 | \{ 'word': 'pev' 353 | \, 'abbr': 'pev' , 'info': 'Print the current environment and each defined environment state to stderr.' } , 354 | \{ 'word': 'pi' 355 | \, 'abbr': 'pi [program]' , 'info': 'Pipe output to program (nroff only).' } , 356 | \{ 'word': 'pl' 357 | \, 'abbr': 'pl' , 'info': 'Set page length to default 11i. The current page length is stored in register .p.' } , 358 | \{ 'word': 'pl' 359 | \, 'abbr': 'pl [±N]' , 'info': 'Change page length to ±N (default scaling indicator v).' } , 360 | \{ 'word': 'pm' 361 | \, 'abbr': 'pm' , 'info': 'Print macro names and sizes (number of blocks of 128 bytes).' } , 362 | \{ 'word': 'pm' 363 | \, 'abbr': 'pm [t]' , 'info': 'Print only total of sizes of macros (number of 128 bytes blocks).' } , 364 | \{ 'word': 'pn' 365 | \, 'abbr': 'pn [±N]' , 'info': 'Next page number N.' } , 366 | \{ 'word': 'pnr' 367 | \, 'abbr': 'pnr' , 'info': 'Print the names and contents of all currently defined number registers on stderr.' } , 368 | \{ 'word': 'po' 369 | \, 'abbr': 'po' , 'info': 'Change to previous page offset. The current page offset is available in register .o.' } , 370 | \{ 'word': 'po' 371 | \, 'abbr': 'po [±N]' , 'info': 'Page offset N.' } , 372 | \{ 'word': 'ps' 373 | \, 'abbr': 'ps' , 'info': 'Return to previous point size.' } , 374 | \{ 'word': 'ps' 375 | \, 'abbr': 'ps [±N]' , 'info': 'Point size; same as \s[±N].' } , 376 | \{ 'word': 'psbb' 377 | \, 'abbr': 'psbb [filename]' , 'info': 'Get the bounding box of a PostScript image filename.' } , 378 | \{ 'word': 'pso' 379 | \, 'abbr': 'pso [command]' , 'info': 'This behaves like the so request except that input comes from the standard output of command.' } , 380 | \{ 'word': 'ptr' 381 | \, 'abbr': 'ptr' , 'info': 'Print the names and positions of all traps (not including input line traps and diversion traps) on stderr.' } , 382 | \{ 'word': 'pvs' 383 | \, 'abbr': 'pvs' , 'info': 'Change to previous post-vertical line spacing.' } , 384 | \{ 'word': 'pvs' 385 | \, 'abbr': 'pvs [±N]' , 'info': 'Change post-vertical line spacing according to ±N (default scaling indicator p).' } , 386 | \{ 'word': 'rchar' 387 | \, 'abbr': 'rchar [c1] [c2] ...' , 'info': 'Remove the definitions of entities c1, c2, ...' } , 388 | \{ 'word': 'rd' 389 | \, 'abbr': 'rd [prompt]' , 'info': 'Read insertion.' } , 390 | \{ 'word': 'return' 391 | \, 'abbr': 'return' , 'info': 'Return from a macro.' } , 392 | \{ 'word': 'return' 393 | \, 'abbr': 'return [anything]' , 'info': 'Return twice, namely from the macro at the current level and from the macro one level higher.' }, 394 | \{ 'word': 'rfschar' 395 | \, 'abbr': 'rfschar [f] [c1] [c2] ...' , 'info': 'Remove the definitions of entities c1, c2, ... for font f.' } , 396 | \{ 'word': 'rj' 397 | \, 'abbr': 'rj [n]' , 'info': 'Right justify the next n input lines.' } , 398 | \{ 'word': 'rm' 399 | \, 'abbr': 'rm [name]' , 'info': 'Remove request, macro, diversion, or string name.' } , 400 | \{ 'word': 'rn' 401 | \, 'abbr': 'rn [old] [new]' , 'info': 'Rename request, macro, diversion, or string old to new.' }, 402 | \{ 'word': 'rnn' 403 | \, 'abbr': 'rnn [reg1] [reg2]' , 'info': 'Rename register reg1 to reg2.' } , 404 | \{ 'word': 'rr' 405 | \, 'abbr': 'rr [register]' , 'info': 'Remove register.' } , 406 | \{ 'word': 'rs' 407 | \, 'abbr': 'rs' , 'info': 'Restore spacing; turn no-space mode off.' } , 408 | \{ 'word': 'rt' 409 | \, 'abbr': 'rt' , 'info': 'Return (upward only) to vertical position marked by .mk on the current page.' } , 410 | \{ 'word': 'rt' 411 | \, 'abbr': 'rt [±N]' , 'info': 'Return (upward only) to specified distance from the top of the page (default scaling indicator v).' } , 412 | \{ 'word': 'schar' 413 | \, 'abbr': 'schar [c] [anything]' , 'info': 'Define global fallback character (or glyph) c as string anything.' } , 414 | \{ 'word': 'shc' 415 | \, 'abbr': 'shc' , 'info': 'Reset soft hyphen glyph to \(hy.' } , 416 | \{ 'word': 'shc' 417 | \, 'abbr': 'shc [c]' , 'info': 'Set the soft hyphen glyph to c.' } , 418 | \{ 'word': 'shift' 419 | \, 'abbr': 'shift [n]' , 'info': 'In a macro, shift the arguments by n positions.' } , 420 | \{ 'word': 'sizes' 421 | \, 'abbr': 'sizes [s1] [s2] ... sn [0] ' , 'info': 'Set available font sizes similar to the sizes command in a DESC file.' } , 422 | \{ 'word': 'so' 423 | \, 'abbr': 'so [filename]' , 'info': 'Include source file.' } , 424 | \{ 'word': 'sp' 425 | \, 'abbr': 'sp' , 'info': 'Skip one line vertically.' } , 426 | \{ 'word': 'sp' 427 | \, 'abbr': 'sp [N]' , 'info': 'Space vertical distance N up or down according to sign of N (default scaling indicator v).' } , 428 | \{ 'word': 'special' 429 | \, 'abbr': 'special' , 'info': 'Reset global list of special fonts to be empty.' } , 430 | \{ 'word': 'special' 431 | \, 'abbr': 'special [s1] [s2] ...' , 'info': 'Fonts s1, s2, etc. are special and are searched for glyphs not in the current font.' }, 432 | \{ 'word': 'spreadwarn' 433 | \, 'abbr': 'spreadwarn' , 'info': 'Toggle the spread warning on and off without changing its value.' } , 434 | \{ 'word': 'spreadwarn' 435 | \, 'abbr': 'spreadwarn [limit]' , 'info': 'Emit a warning if each space in an output line is widened by limit or more (default scaling indicator m).' } , 436 | \{ 'word': 'ss' 437 | \, 'abbr': 'ss [N]' , 'info': 'Set space glyph size to N/12 of the space width in the current font.' } , 438 | \{ 'word': 'ss' 439 | \, 'abbr': 'ss [N] [M]' , 'info': 'Set space glyph size to N/12 and sentence space size set to M/12 of the space width in the current font.' } , 440 | \{ 'word': 'sty' 441 | \, 'abbr': 'sty [n] [style]' , 'info': 'Associate style with font position n.' } , 442 | \{ 'word': 'substring' 443 | \, 'abbr': 'substring [xx] [n1] [n2]' , 'info': 'Replace the string named xx with the substring defined by the indices n1 and n2.' } , 444 | \{ 'word': 'sv' 445 | \, 'abbr': 'sv' , 'info': 'Save 1 v of vertical space.' } , 446 | \{ 'word': 'sv' 447 | \, 'abbr': 'sv [N]' , 'info': 'Save the vertical distance N for later output with os request (default scaling indicator v).' } , 448 | \{ 'word': 'sy' 449 | \, 'abbr': 'sy [command]-line' , 'info': 'Execute program command-line.' } , 450 | \{ 'word': 'ta' 451 | \, 'abbr': 'ta [T] [N]' , 'info': 'Set tabs after every position that is a multiple of N (default scaling indicator m).' } , 452 | \{ 'word': 'ta' 453 | \, 'abbr': 'ta [n1] [n2] ... nn T r1 r2 ... rn' , 'info': 'Set tabs at positions n1, n2, ..., nn, then set tabs at nn+m×rn+r1 through nn+m×rn+rn, where m increments from 0, 1, 2, ... to infinity.' }, 454 | \{ 'word': 'tc' 455 | \, 'abbr': 'tc' , 'info': 'Remove tab repetition glyph.' } , 456 | \{ 'word': 'tc' 457 | \, 'abbr': 'tc [c]' , 'info': 'Set tab repetition glyph to c.' } , 458 | \{ 'word': 'ti' 459 | \, 'abbr': 'ti [±N]' , 'info': 'Temporary indent next line (default scaling indicator m).' } , 460 | \{ 'word': 'tkf' 461 | \, 'abbr': 'tkf [font] [s1] [n1] [s2] [n2]' , 'info': 'Enable track kerning for font.' } , 462 | \{ 'word': 'tl' 463 | \, 'abbr': 'tl ’left’center’right' , 'info': 'Three-part title.' } , 464 | \{ 'word': 'tm' 465 | \, 'abbr': 'tm [anything]' , 'info': 'Print anything on stderr.' } , 466 | \{ 'word': 'tm1' 467 | \, 'abbr': 'tm1 [anything]' , 'info': 'Print anything on stderr, allowing leading whitespace if anything starts with " (which is stripped off).' } , 468 | \{ 'word': 'tmc' 469 | \, 'abbr': 'tmc [anything]' , 'info': 'Similar to .tm1 without emitting a final newline.' } , 470 | \{ 'word': 'tr' 471 | \, 'abbr': 'tr [abcd]...' , 'info': 'Translate a to b, c to d, etc. on output.' } , 472 | \{ 'word': 'trf' 473 | \, 'abbr': 'trf [filename]' , 'info': 'Transparently output the contents of file filename.' } , 474 | \{ 'word': 'trin' 475 | \, 'abbr': 'trin [abcd]...' , 'info': 'This is the same as the tr request except that the asciify request uses the character code (if any) before the character translation.' } , 476 | \{ 'word': 'trnt' 477 | \, 'abbr': 'trnt [abcd]...' , 'info': 'This is the same as the tr request except that the translations do not apply to text that is transparently throughput into a diversion with \!.' }, 478 | \{ 'word': 'troff' 479 | \, 'abbr': 'troff' , 'info': 'Make the built-in conditions t true and n false.' } , 480 | \{ 'word': 'uf' 481 | \, 'abbr': 'uf [font]' , 'info': 'Set underline font to font (to be switched to by .ul).' } , 482 | \{ 'word': 'ul' 483 | \, 'abbr': 'ul [N]' , 'info': 'Underline (italicize in troff) N input lines.' } , 484 | \{ 'word': 'unformat' 485 | \, 'abbr': 'unformat [diversion]' , 'info': 'Unformat space characters and tabs in diversion, preserving font information.' } , 486 | \{ 'word': 'vpt' 487 | \, 'abbr': 'vpt [n]' , 'info': 'Enable vertical position traps if n is non-zero, disable them otherwise.' } , 488 | \{ 'word': 'vs' 489 | \, 'abbr': 'vs' , 'info': 'Change to previous vertical base line spacing.' } , 490 | \{ 'word': 'vs' 491 | \, 'abbr': 'vs [±N]' , 'info': 'Set vertical base line spacing to ±N (default scaling indicator p).' } , 492 | \{ 'word': 'warn' 493 | \, 'abbr': 'warn [n]' , 'info': 'Set warnings code to n.' } , 494 | \{ 'word': 'warnscale' 495 | \, 'abbr': 'warnscale [si]' , 'info': 'Set scaling indicator used in warnings to si.' } , 496 | \{ 'word': 'wh' 497 | \, 'abbr': 'wh [N]' , 'info': 'Remove (first) trap at position N.' } , 498 | \{ 'word': 'wh' 499 | \, 'abbr': 'wh [N] [trap] ' , 'info': 'Set location trap; negative means from page bottom.' } , 500 | \{ 'word': 'while' 501 | \, 'abbr': 'while [cond] [anything] ' , 'info': 'While condition cond is true, accept anything as input.' } , 502 | \{ 'word': 'write' 503 | \, 'abbr': 'write [stream] [anything] ' , 'info': 'Write anything to the stream named stream.' } , 504 | \{ 'word': 'writec' 505 | \, 'abbr': 'writec [stream] [anything] ' , 'info': 'Similar to .write without emitting a final newline.' } , 506 | \{ 'word': 'writem' 507 | \, 'abbr': 'writem [stream] [xx] ' , 'info': 'Write contents of macro or string xx to the stream named stream.' } , 508 | \] " }}} 509 | return base_macros 510 | endfunction 511 | -------------------------------------------------------------------------------- /autoload/tbl.vim: -------------------------------------------------------------------------------- 1 | " File: tbl.vim 2 | " Maintainer: Gavin Jaeger-Freeborn 3 | " Created: Mon 12 Oct 2020 02:04:54 PM 4 | " License: 5 | " Copyright (c) Gavin Jaeger-Freeborn. Distributed under the same terms as Vim itself. 6 | " See :help license 7 | " 8 | " Description: 9 | " Completion for tbl sections 10 | " 11 | 12 | let s:tbl = ['allbox', 'box', 'center', 'delim(', 'doublebox', 'expand', 'frame', 'linesize(', ] 13 | let s:gnu_tbl = [ 'decimapoint(', 'nokeep', 'nospaces', 'nowarn', 'tab(' ] 14 | 15 | function! tbl#TblComplete(shortcontext) 16 | return s:tbl 17 | endfunction 18 | -------------------------------------------------------------------------------- /compiler/troff.vim: -------------------------------------------------------------------------------- 1 | " File: troff.vim 2 | " Maintainer: Gavin Jaeger-Freeborn 3 | " Created: Fri 09 Oct 2020 07:27:43 PM 4 | " License: 5 | " Copyright (c) Gavin Jaeger-Freeborn. Distributed under the same terms as Vim itself. 6 | " See :help license 7 | " 8 | " Description: 9 | " Compiler plugin for different versions of troff 10 | " 11 | " NOTE: STILL IN BETA 12 | 13 | if exists('current_compiler') 14 | finish 15 | endif 16 | let s:keepcpo= &cpoptions 17 | set cpoptions&vim 18 | 19 | if exists(':CompilerSet') != 2 " older Vim always used :setlocal 20 | command -nargs=* CompilerSet setlocal 21 | endif 22 | 23 | " decide compiler using one of these 24 | " let g:is_groff 25 | " let g:is_neatroff 26 | " let g:is_hearloom 27 | 28 | 29 | " If makefile exists and we are not asked to ignore it, we use standard make 30 | " (do not redefine makeprg) 31 | if exists('b:troff_ignore_makefile') || exists('b:troff_ignore_makefile') || 32 | \(!filereadable('Makefile') && !filereadable('makefile')) 33 | " If buffer-local variable set the troff program 34 | if exists('b:tex_flavor') 35 | let current_compiler = b:troff_flavor 36 | elseif exists('g:tex_flavor') 37 | let current_compiler = g:troff_flavor 38 | else 39 | let current_compiler = 'groff' 40 | endif 41 | let &l:makeprg=current_compiler 42 | else 43 | let current_compiler = 'make' 44 | endif 45 | 46 | let s:filter=globpath(&runtimepath, 'compiler/filter.sh') 47 | 48 | CompilerSet errorformat=%o:\ (%f):%l:%m, 49 | \%o:\ \ (%f):%l:%m, 50 | \%o:%f:%l:%m, 51 | \%o:\ %f:%l:%m, 52 | \%f:%l:\ macro\ %trror:%m, 53 | \%f:%l:%m, 54 | \%W%tarning:\ file\ '%f'\\,\ around\ line\ %l:,%Z%m 55 | 56 | let &cpoptions = s:keepcpo 57 | unlet s:keepcpo 58 | -------------------------------------------------------------------------------- /doc/troff.txt: -------------------------------------------------------------------------------- 1 | *troff.txt* A vim plugin to help modernize groff 2 | 3 | Author: Gavin Jaeger-Freeborn 4 | License: Same terms as Vim itself (see |license|) 5 | 6 | This plugin is only available if 'compatible' is not set. 7 | 8 | INTRODUCTION *troff-introduction* *troff* 9 | 10 | Whenever you edit a file with the extension .ms,.mom,.me,.mm,.tr,.troff,.tmac, 11 | this plugin will be automatically activated. 12 | 13 | NAVIGATION *troff-navigation* 14 | 15 | Navigating between macro files and troff files can often be tricky so be sure 16 | to add your macro directory to your 'path'. By default 17 | /usr/share/groff/current/tmac is appended to 'path' but you can set your own 18 | macro directory 19 | 20 | *troff-macro-dir* 21 | 22 | Directory used for storing macros defaults to /usr/share/groff/current/tmac if 23 | it exists. 24 | > 25 | let g:troff_macro_dir=/usr/share/groff/current/tmac 26 | < 27 | |:find| can then locate a macro file for you. 28 | 29 | For groff users you can also add your global macros by setting 30 | |g:groff_install_prefix| 31 | 32 | *troff-tags* 33 | 34 | In addition to setting the path |g:troff_macro_dir| is used to generate tags 35 | for jumping to the definition of a macro. For initial tag generation execute 36 | > 37 | :TroffGenTags 38 | < 39 | Once tags have been generated us to jump to the definition of the macro. 40 | The tag file is store at |g:troff_ctags_file| 41 | 42 | 43 | *troff-include* 44 | 45 | Settings for both 'include' and 'define' have been set for use with .so and 46 | .mso so you can use |include-search| and |definition-search| to jump to 47 | definitions with [ , [ , |:djump|, |:ijump| use completion with 48 | or and much more. 49 | 50 | COMPLETION *troff-completion* 51 | 52 | vim-troff comes with an 'omnifunc' for somewhat intelligent completion. It 53 | supports eqn, tbl, and pic, groff requests, and groff glyphs. In addition the 54 | omnifunc will try to determine the current macros for additional completion. 55 | by default the omnifunc is enabled. You can activate this completions with 56 | in insert mode. 57 | 58 | TEXTOBJ *troff-text-objects* 59 | 60 | vim-troff currently supports the following text objects: 61 | 62 | *troff-i-text-objects* 63 | `if` 64 | between `\f` escape sequences e.g `\f. , \f(.. , and \f[...]` 65 | `iF` 66 | between `\F` escape sequences e.g `\F. , \F(.. , and \F[...]` 67 | `im` 68 | between `\m` escape sequences e.g `\m. , \m(.. , and \m[...]` 69 | `iM` 70 | between `\M` escape sequences e.g `\M. , \M(.. , and \M[...]` 71 | 72 | *troff-a-text-objects* 73 | `af` 74 | arround `\f` escape sequences e.g `\f. , \f(.. , and \f[...]` 75 | `aF` 76 | arround `\F` escape sequences e.g `\F. , \F(.. , and \F[...]` 77 | `am` 78 | arround `\m` escape sequences e.g `\m. , \m(.. , and \m[...]` 79 | `aM` 80 | arround `\M` escape sequences e.g `\M. , \M(.. , and \M[...]` 81 | 82 | SYNTAX *troff-syntax* 83 | 84 | vim-troff adds multiple additions to the syntax such as spell checking and 85 | syntax folding for preprocessor sections. 86 | 87 | NOTE: currently vim-troff assumes that your troff implementation allows for 88 | more then 2 character macros and commands. 89 | 90 | *troff-eqn-conceal* 91 | vim-troff adds concealing similar to how |tex-conceal| works. To disable 92 | eqn concealing set 93 | > 94 | let g:troff_greek = 0 95 | let g:troff_math = 0 96 | let g:troff_subsup = 0 97 | < 98 | If you want to use a delimiter for inline eqn set |g:troff_eqndelim| to 99 | your desired delimiter. 100 | 101 | SETTINGS *troff-settings* 102 | 103 | Use the following settings to customize vim-trofff to your liking. 104 | 105 | Available options: ~ 106 | 107 | |g:groff_install_prefix| 108 | |g:troff_greek| 109 | |g:troff_math| 110 | |g:troff_subsup| 111 | |g:troff_eqndelim| 112 | |g:troff_macro_dir| 113 | |g:troff_ctags_file| 114 | |g:troff_text_obj_enabled| 115 | |g:troff_nospell_macros| 116 | 117 | ------------------------------------------------------------------------------ 118 | *g:groff_install_prefix* 119 | Default: 120 | let g:groff_install_prefix='/usr/share'~ 121 | 122 | This sets the prefix that vim-troff uses to look for macros to add to your 123 | 'path' 124 | *g:troff_greek* 125 | Default: 126 | let g:troff_greek = 1~ 127 | 128 | Enables |conceal| of greek letters in eqn 129 | 130 | *g:troff_subsup* 131 | Default: 132 | let g:troff_subsup = 1~ 133 | 134 | Enables |conceal| of subscripts and superscripts in eqn letters in eqn 135 | 136 | *g:troff_math* 137 | Default: 138 | let g:troff_math = 1~ 139 | 140 | Enables |conceal| of math symbols such as `prod` is shown as `∏` and 141 | superscripts in eqn letters in eqn 142 | 143 | *g:troff_eqndelim* 144 | Default: 145 | By default g:troff_eqndelim is not set 146 | 147 | Example: 148 | let g:troff_eqndelim = '@#'~ 149 | 150 | Enables |conceal| of math symbols between a delimiter in this example 151 | `@prod#` is shown as `∏` if |g:troff_math| is enabled. 152 | 153 | NOTE: This does not follow `delim off` 154 | 155 | *g:troff_macro_dir* 156 | Default: 157 | let g:troff_macro_dir='/usr/share/groff/current/tmac'~ 158 | 159 | Used for storing troff macro directories for adding to path and for tagging 160 | 161 | *g:troff_ctags_file* 162 | Default: 163 | let g:troff_ctags_file=$XDG_CACHE_HOME/vim-troff/tags~ 164 | or 165 | let g:troff_ctags_file=$HOME/.vim-troff/tags~ 166 | if $XDG_CACHE_HOME does not exist 167 | 168 | Used for storing troff macro directories for adding to path and for tagging 169 | 170 | *g:troff_text_obj_enabled* 171 | Default: 172 | let g:troff_text_obj_enabled = 1~ 173 | 174 | set to 0 to disable support for troff |text-objects| 175 | 176 | *g:troff_nospell_macros* 177 | Default: 178 | let g:troff_nospell_macros = 1~ 179 | 180 | avoids spellchecking macros and troff requests. 181 | eg 182 | > 183 | .NH 184 | hllo world 185 | < 186 | if 'spell' and |g:troff_nospell_macros| are enabled then only `hllo` 187 | will be highlighted. if |g:troff_nospell_macros| is disabled then `.NH` will 188 | also be highlighted. 189 | 190 | COMPATIBILITY *troff-compatibly* 191 | 192 | Currently vim-troff is focused on supporting groff and will slowly add 193 | compatibility for alternative troff implementations. 194 | 195 | *troff-plugin-compatibility* 196 | *troff-matchit* 197 | Additional settings are added to |matchit| to add support for jumping between 198 | certain macros and the start and end of a preprocessor. 199 | 200 | *troff-surround* 201 | vim-troff also adds support for tpope's surround plugin using E for eqn, T for 202 | tbl, P for pic, f for font, and \ as \[]. 203 | 204 | vim:tw=78:et:ft=help:norl: 205 | -------------------------------------------------------------------------------- /ftdetect/troff.vim: -------------------------------------------------------------------------------- 1 | " File: troff.vim 2 | " Maintainer: Gavin Jaeger-Freeborn 3 | " Created: Fri 09 Oct 2020 04:53:30 PM 4 | " License: 5 | " Copyright (c) Gavin Jaeger-Freeborn. Distributed under the same terms as Vim itself. 6 | " See :help license 7 | " 8 | " Description: 9 | " syntax detection for troff files 10 | autocmd! BufRead,BufNewFile *.ms,*.mom,*.me,*.mm,*.tr,*.troff,*.tmac,tmac.* setfiletype troff 11 | -------------------------------------------------------------------------------- /ftplugin/troff.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | " File: troff.vim 3 | " Maintainer: Gavin Jaeger-Freeborn 4 | " Created: Fri 14 Feb 2020 09:52:12 AM MST 5 | " License: 6 | " Copyright (c) Gavin Jaeger-Freeborn. Distributed under the same terms as Vim itself. 7 | " See :help license 8 | " 9 | " Description: 10 | " ftplugin for troff files 11 | 12 | if exists('b:did_ftplugin') 13 | finish 14 | endif 15 | let b:did_ftplugin = 1 16 | 17 | if !exists('g:troff_text_obj_enabled') 18 | let g:troff_text_obj_enabled = 1 19 | endif 20 | 21 | " TODO maybe add /usr/local/ucblib/doctools/tmac for heirloom users 22 | " groff paths {{{ " 23 | if !exists('g:groff_install_prefix') 24 | let g:groff_install_prefix='/usr/share/groff' 25 | endif 26 | " }}} "groff paths 27 | " neatroff paths {{{ " 28 | if !exists('g:neatroff_install_prefix') 29 | let g:neatroff_install_prefix='/opt/share/neatroff' 30 | endif 31 | " }}} "neatroff paths 32 | 33 | " Macro directories 34 | " TODO: add support for $GROFF_TMAC_PATH for better support<10-10-20 Gavin Jaeger-Freeborn> 35 | if !exists('g:troff_macro_dir') 36 | if isdirectory( g:neatroff_install_prefix ) 37 | let g:troff_macro_dir=g:neatroff_install_prefix . '/tmac' 38 | elseif isdirectory( g:groff_install_prefix ) 39 | let g:troff_macro_dir=g:groff_install_prefix . '/current/tmac' 40 | endif 41 | endif 42 | 43 | " tags {{{ 44 | " TODO: allow this to be set and automated <09-10-20 Gavin Jaeger-Freeborn> 45 | if !exists('g:troff_ctags_file') 46 | let usrhome = $HOME 47 | let cahome = exists('$XDG_CACHE_HOME') ? $XDG_CACHE_HOME : usrhome.'/.cache' 48 | let cadir = isdirectory(usrhome.'.vim-troff') 49 | \ ? usrhome.'.vim-troff' : cahome.'/vim-troff' 50 | call mkdir(cahome.'/vim-troff', 'p') 51 | let g:troff_ctags_file = cadir.'/tags' 52 | endif 53 | 54 | " This function is used to print the command used to create tags for the builtin troff macros 55 | function! TroffGenTags() 56 | let ctags_options='--langdef=troff --map-troff=+.ms --map-troff=+.tmac --map-troff="(tmac.*)" --kinddef-troff=t,tag,tags --regex-troff="/^\.(de|MAC)[[:blank:]]+(.+)/\2/t/{scope=ref}"' 57 | execute '!ctags -f ' . g:troff_ctags_file . ' ' . ctags_options . ' -R ' . g:troff_macro_dir . '/*' 58 | endfunction 59 | 60 | command! -nargs=0 TroffGenTags call TroffGenTags() 61 | 62 | " set ctags after opening troff files 63 | if filereadable(g:troff_ctags_file) 64 | execute 'setlocal tags+=' . g:troff_ctags_file 65 | endif 66 | " }}} "tags 67 | 68 | " TODO: Don't use groff functions for non groff requests <09-10-20 Gavin Jaeger-Freeborn> 69 | " uses base macros to provide documentation 70 | " GroffDoc {{{ 71 | function! GroffDoc(word) 72 | for req in requests#GetRequests() 73 | " echoerr req 74 | if a:word ==# req.word 75 | if has_key(req, 'info') 76 | echo req.info 77 | return 78 | endif 79 | endif 80 | endfor 81 | call GroffMan() 82 | endfunction 83 | 84 | command! -nargs=1 GroffDoc call GroffDoc() 85 | 86 | setlocal keywordprg=:GroffDoc 87 | " }}} "GroffDoc 88 | 89 | " Variables (used for omnifunc) {{{1 90 | " preprocessor definitions {{{ "2 91 | let s:general_macros = [ 92 | \{ 'word': 'EQ', 'icase': 1 }, 93 | \{ 'word': 'TS', 'icase': 1 }, 94 | \{ 'word': 'PS', 'icase': 1 }, 95 | \{ 'word': 'G1', 'icase': 1 }, 96 | \{ 'word': 'G2', 'icase': 1 }, 97 | \{ 'word': 'PSPIC' 98 | \, 'abbr': 'PSPIC [image.eps]', 'icase': 1 } 99 | \] 100 | " }}}2 "preprocessor definitions 101 | 102 | " TODO: reloctate mom macros to an autoload function <12-10-20 Gavin Jaeger-Freeborn> 103 | " mom {{{2 104 | let s:mom_prestart_macros = [ 105 | \{ 'word': 'TITLE "', 'info': 'TITLE [COVER | DOC_COVER] "" ["<2nd line>" ["<3rd line>" ... ] ]', 'icase': 1 }, 106 | \{ 'word': 'SUBTITLE "', 'info': 'SUBTITLE [COVER | DOC_COVER] "<subtitle>" ["<2nd line>" ["<3rd line>" ... ] ]', 'icase': 1 }, 107 | \{ 'word': 'AUTHOR "', 'icase': 1 }, 108 | \{ 'word': 'PRINTSTYLE', 'icase': 1 }, 109 | \{ 'word': 'COPYRIGHT', 'icase': 1 }, 110 | \{ 'word': 'COVERTITLE "', 'icase': 1 }, 111 | \{ 'word': 'HEADING_STYLE', 'icase': 1 }, 112 | \{ 'word': 'COPYRIGHT_STYLE', 'icase': 1 }, 113 | \{ 'word': 'CHAPTER', 'icase': 1 }, 114 | \{ 'word': 'CHAPTER_TITLE "', 'icase': 1 }, 115 | \{ 'word': 'DRAFT', 'icase': 1 }, 116 | \{ 'word': 'REVISION', 'icase': 1 }, 117 | \{ 'word': 'DOCTYPE', 'icase': 1 }, 118 | \{ 'word': 'COPYSTYLE', 'icase': 1 }, 119 | \{ 'word': 'FAMILY', 'icase': 1 }, 120 | \{ 'word': 'PT_SIZE', 'icase': 1 }, 121 | \{ 'word': 'START', 'icase': 1 }, 122 | \{ 'word': 'DOC_COVERTITLE "', 'icase': 1 }, 123 | \{ 'word': 'PDF_TITLE "', 'icase': 1 }, 124 | \{ 'word': 'TOC_HEADING "', 'icase': 1 }, 125 | \{ 'word': 'L_MARGIN', 'icase': 1 }, 126 | \{ 'word': 'R_MARGIN', 'icase': 1 } 127 | \] 128 | let s:mom_style_options = [ 129 | \{ 'word': 'FAMILY', 'icase': 1 }, 130 | \{ 'word': 'FONT', 'icase': 1 }, 131 | \{ 'word': 'UNDERSCORE', 'icase': 1 }, 132 | \{ 'word': 'SIZE', 'icase': 1 }, 133 | \{ 'word': 'COLOR', 'icase': 1 }, 134 | \{ 'word': 'QUAD', 'icase': 1 }, 135 | \{ 'word': 'SPACE_ABOVE', 'icase': 1 }, 136 | \{ 'word': 'SPACE_BENEATH', 'icase': 1 } 137 | \] 138 | let s:mom_poststart_macros = [ 139 | \{ 'word': 'IL', 'abbr': 'IL [ <measure> ]', 'info': 'set and turn on a left indent' }, 140 | \{ 'word': 'IR', 'abbr': 'IR [ <measure> ]', 'info': 'set and turn on a right indent'}, 141 | \{ 'word': 'IB', 'abbr': 'IB [ <measure> ]', 'info': 'set and turn on indents both left and right'}, 142 | \{ 'word': 'TI', 'abbr': 'TI [ <measure> ]', 'info': 'set and turn on a temporary (one line) indent'}, 143 | \{ 'word': 'HI', 'abbr': 'HI [ <measure> ]', 'info': 'set and turn on a hanging indent (TREATED LITERALY) '}, 144 | \{ 'word': 'IQ', 'info': 'quit (exit) all indents'}, 145 | \{ 'word': 'ILX', 'info': 'left indents off'}, 146 | \{ 'word': 'IRX', 'info': 'right indents off'}, 147 | \{ 'word': 'IBX', 'info': 'both left and right indents off'}, 148 | \ 149 | \{ 'word': 'HEADING', 'abbr': 'HEADING <level> "<heading text>"', 'info': 'Macro: HEADING <level> [ PARAHEAD ] [ NAMED <pdf-id> ] "<heading text>"', 'icase': 1 }, 150 | \ 151 | \{ 'word': 'LEFT', 'info': 'set line-by-line quad left', 'icase': 1 }, 152 | \{ 'word': 'RIGHT', 'info': 'set line-by-line quad right','icase': 1 }, 153 | \{ 'word': 'CENTER', 'info': 'set line-by-line quad centre','icase': 1 }, 154 | \{ 'word': 'QUAD', 'abbr': 'QUAD L | LEFT | R | RIGHT | C | CENTER | J | JUSTIFY', 'info': ' "justify" text left, centre, or right' }, 155 | \{ 'word': 'JUSTIFY', 'info': 'justify text to both margins' }, 156 | \{ 'word': 'BR', 'info': 'break a justified line'}, 157 | \{ 'word': 'SPREAD', 'info': 'force justify a line'}, 158 | \{ 'word': 'EL', 'info': ' break a line without advancing on the page'}, 159 | \ 160 | \{ 'word': 'UNDERSCORE', 'abbr': 'UNDERSCORE [ <distance below baseline> ] "<string>"', 'info': 'underscore' }, 161 | \{ 'word': 'UNDERSCORE2', 'abbr': 'UNDERSCORE2 [ <distance below baseline> [ <distance between rules> ] ] "<string>"', 'info': ' double underscore' }, 162 | \ 163 | \{ 'word': 'PP', 'icase': 1 }, 164 | \{ 'word': 'LINEBREAK', 'icase': 1 }, 165 | \{ 'word': 'SECTION', 'icase': 1 }, 166 | \{ 'word': 'LIST', 'abbr': 'LIST [ BULLET | DASH | ... ] [ <separator> ] [ <prefix> ] [ <anything> ]', 'info': 'Invoked by itself (ie with no argument), LIST initializes a list with bullets as the default enumerator. Afterward,s each block of input text preceded by .ITEM, on a line by itself, is treated as a list item. LIST [ BULLET | DASH | DIGIT | ALPHA | alpha | ROMAN<n> | roman<n> | USER <user-defined enumerator> | PLAIN | VARIABLE <character>] [ <separator> ] [ <prefix> ] [ <anything> ]}', 'icase': 1 }, 167 | \{ 'word': 'ITEM', 'icase': 1 }, 168 | \{ 'word': 'PP_FONT', 'icase': 1 }, 169 | \{ 'word': 'PARA_INDENT', 'icase': 1 }, 170 | \{ 'word': 'EPIGRAPH', 'icase': 1 }, 171 | \{ 'word': 'EL', 'icase': 1 } 172 | \] 173 | let s:mom_heading_options = [ 174 | \{ 'word': 'NUMBER', 'icase': 1 }, 175 | \] 176 | let s:mom_poststart_toggle_macros = [ 177 | \{ 'word': 'QUOTE', 'icase': 1 }, 178 | \{ 'word': 'FLOAT', 'icase': 1 }, 179 | \{ 'word': 'BLOCKQUOTE', 'icase': 1 }, 180 | \{ 'word': 'CODE', 'icase': 1 }, 181 | \{ 'word': 'JUSTIFY', 'icase': 1 }, 182 | \{ 'word': 'FOOTNOTE', 'icase': 1 }, 183 | \] 184 | " }}}2 "mom 185 | 186 | " TODO: reloctate ms macros to an autoload <12-10-20 Gavin Jaeger-Freeborn> 187 | " ms {{{ "2 188 | let s:ms_macros = [ 189 | \{ 'word': 'NH', 'icase': 1 }, 190 | \{ 'word': 'SH', 'icase': 1 }, 191 | \{ 'word': 'PP', 'icase': 1 }, 192 | \{ 'word': 'LP', 'icase': 1 }, 193 | \{ 'word': 'B' , 'icase': 1 }, 194 | \{ 'word': 'R' , 'icase': 1 }, 195 | \{ 'word': 'I' , 'icase': 1 }, 196 | \{ 'word': 'CW', 'icase': 1 }, 197 | \{ 'word': 'BI', 'icase': 1 }, 198 | \{ 'word': 'UL', 'icase': 1 }, 199 | \{ 'word': 'LG', 'icase': 1 }, 200 | \{ 'word': 'SM', 'icase': 1 }, 201 | \{ 'word': 'IP', 'icase': 1 }, 202 | \{ 'word': 'KS', 'icase': 1 }, 203 | \{ 'word': 'KE', 'icase': 1 }, 204 | \{ 'word': 'RS', 'icase': 1 }, 205 | \{ 'word': 'RE', 'icase': 1 }, 206 | \{ 'word': 'TL', 'icase': 1 }, 207 | \{ 'word': 'BX', 'icase': 1 }, 208 | \{ 'word': 'B1', 'icase': 1 }, 209 | \{ 'word': 'B2', 'icase': 1 } 210 | \] 211 | " ms registers {{{ "3 212 | let s:registers = [ 213 | \{ 'word': 'PS', 'icase': 1 }, 214 | \{ 'word': 'VS', 'icase': 1 }, 215 | \{ 'word': 'PSINCR', 'icase': 1 }, 216 | \{ 'word': 'GROWPS', 'icase': 1 } 217 | \] 218 | " }}}3 "ms registers 219 | " }}}2 "ms 220 | 221 | " font {{{ "2 222 | let s:font = [ 223 | \{ 'word': 'B', 'icase': 1 }, 224 | \{ 'word': 'I', 'icase': 1 }, 225 | \{ 'word': 'BI', 'icase': 1 }, 226 | \{ 'word': 'R', 'icase': 1 }, 227 | \{ 'word': 'P', 'icase': 1 } 228 | \] 229 | " }}}2 "font 230 | 231 | " TODO: add more escape sequences <10-08-20 Gavin Jaeger-Freeborn> 232 | " escapes {{{ "2 233 | let s:escapes = [ 234 | \{ 'word': 'f', 'abbr': '\f', 'info': 'Change to font with one-character name or one-digit number F.', 'icase': 1 }, 235 | \{ 'word': 'l', 'abbr': '\l’Nc’', 'info': 'Horizontal line drawing function (optionally using character c).', 'icase': 1 }, 236 | \{ 'word': 'L', 'abbr': '\L’Nc’', 'info': 'Vertical line drawing function (optionally using character c).', 'icase': 1 }, 237 | \{ 'word': 'D', 'abbr': '\D’charseq’', 'info': 'Draw a graphical element defined by the characters in charseq; see the groff Texinfo manual for details.', 'icase': 1 }, 238 | \{ 'word': '"', 'abbr': '\"', 'info': 'Start of a comment. Everything up to the end of the line is ignored.', 'icase': 1 }, 239 | \{ 'word': 'Z', 'abbr': '\Z’anything’', 'info': 'Print anything and then restore the horizontal and vertical position; anything may not contain tabs or leaders.', 'icase': 1 }, 240 | \{ 'word': '$*', 'abbr': '\$*', 'info': 'In a macro or string, the concatenation of all the arguments separated by spaces.', 'icase': 1 }, 241 | \{ 'word': '$@', 'abbr': '\$@', 'info': 'In a macro or string, the concatenation of all the arguments with each surrounded by double quotes, and separated by spaces.', 'icase': 1 }, 242 | \{ 'word': '$^', 'abbr': '\$^', 'info': 'In a macro, the representation of all parameters as if they were an argument to the ds request.', 'icase': 1 }, 243 | \{ 'word': '&', 'abbr': '\&', 'info': 'Non-printable, zero-width glyph. (used for escaping)', 'icase': 1 } 244 | \] 245 | " }}}2 "escapes 246 | 247 | " strings need work 248 | let s:strings = ['ce'] 249 | 250 | 251 | " }}}1 "Variables (used for omnifunc) 252 | 253 | " used to determine the macros used 254 | function! CheckMacros() 255 | if search('^\.\s*START\s*', 'bnW') > 0 256 | return 'mom_poststart' 257 | elseif search('^\.\s*START\s*', 'nW') > 0 || expand('%:e') ==# 'mom' 258 | return 'mom_prestart' 259 | elseif search('^\.\s*\(UL\|TL\|NH\|XP\|XN\)\s*', 'bnw') > 0 || expand('%:e') ==# 'ms' 260 | return 'ms' 261 | elseif search('^\.\s*[ilnp]p\s*', 'bnw') > 0 || expand('%:e') ==# 'ms' 262 | return 'me' 263 | endif 264 | endfunction 265 | 266 | " Omnifunc for use with groff (currently only supports ms macros) 267 | fun! GroffOmnifunc(findstart, base) " {{{ 268 | if a:findstart 269 | " set filetype 270 | let line = getline('.') 271 | let start = col('.') - 1 272 | let curline = line('.') 273 | let compl_begin = col('.') - 2 274 | while start >= 0 && line[start - 1] =~? '\k' 275 | let start -= 1 276 | endwhile 277 | let b:compl_context = getline('.')[0:compl_begin] 278 | return start 279 | else 280 | " calling a macro 281 | let res = [] 282 | let res2 = [] 283 | " a:base is very short - we need context 284 | " Shortcontext is context without a:base, useful for checking if we are 285 | " looking for objects and for what objects we are looking for 286 | let context = b:compl_context 287 | let shortcontext = substitute(context, a:base.'$', '', '') 288 | unlet! b:compl_context 289 | " echoerr a:base 290 | " echoerr shortcontext 291 | 292 | " let object = matchstr(shortcontext, '^\.\s*\zs\k\+\ze\s\+$') 293 | 294 | " if len(object) > 0 295 | " if search(object.'\s*\s*', 'bn') > 0 296 | " let object_type = 'Register' 297 | " elseif search(object.'\.\s*ds\s*', 'bn') > 0 298 | " let object_type = 'String' 299 | " elseif search(object.'\.\s*', 'bn') > 0 300 | " let object_type = 'Macro' 301 | " endif 302 | " endif 303 | 304 | " if !exists('object_type') 305 | " let object_type = '' 306 | " endif 307 | 308 | " if object_type == 'Macro' 309 | " let values = s:macros 310 | " elseif object_type == 'String' 311 | " let values = s:strings 312 | " elseif object_type == 'Register' 313 | " let values = s:registers 314 | " elseif object_type == 'Object' 315 | " let values = s:objes 316 | " endif 317 | let [line, col] = [line('.'), col('.')] 318 | let syntype = reverse(map(synstack(line, col), 'synIDattr(v:val,"name")')) 319 | for synt in syntype 320 | if synt ==# 'nroffEquation' 321 | let values = eqn#EqnComplete(shortcontext) 322 | if shortcontext =~? '\.\s*$' 323 | let values = [ { 'word': 'EN', 'icase': 1 } ] 324 | elseif shortcontext =~? '\\[$' 325 | let values = groff_char#GroffCompleteGlyph('\\[') 326 | if values == [] | unlet values | endif 327 | elseif shortcontext =~? '\\($' 328 | let values = groff_char#GroffCompleteGlyph('\\(') 329 | if values == [] | unlet values | endif 330 | endif 331 | elseif synt ==# 'nroffTable' 332 | let values = tbl#TblComplete(shortcontext) 333 | if shortcontext =~? '\.\s*$' 334 | let values = [ { 'word': 'TE', 'icase': 1 } ] 335 | elseif shortcontext =~# '\\f\([\|(\)$' 336 | let values = s:font 337 | elseif shortcontext =~? '\\[$' 338 | let values = groff_char#GroffCompleteGlyph('\\[') 339 | if values == [] | unlet values | endif 340 | elseif shortcontext =~? '\\($' 341 | let values = groff_char#GroffCompleteGlyph('\\(') 342 | if values == [] | unlet values | endif 343 | endif 344 | elseif synt ==# 'nroffPicture' 345 | let values = pic#PicComplete(shortcontext) 346 | if shortcontext =~? '\.\s*$' 347 | let values = [ { 'word': 'PE', 'icase': 1 } ] 348 | elseif shortcontext =~? '\\[$' 349 | let values = groff_char#GroffCompleteGlyph('\\[') 350 | if values == [] | unlet values | endif 351 | elseif shortcontext =~? '\\($' 352 | let values = groff_char#GroffCompleteGlyph('\\(') 353 | if values == [] | unlet values | endif 354 | endif 355 | if values == [] | unlet values | endif 356 | endif 357 | endfor 358 | 359 | " requests that can be used in all macros 360 | let s:macros = s:general_macros + requests#GetRequests() 361 | " add to the end of the completion 362 | if !exists('values') 363 | if shortcontext =~? '\.\s*$' 364 | let ft = CheckMacros() 365 | if exists('ft') 366 | if ft ==# 'mom_poststart' 367 | let s:macros = s:mom_poststart_macros + s:mom_poststart_toggle_macros + s:general_macros + requests#GetRequests() 368 | elseif ft ==# 'mom_prestart' 369 | let s:macros = s:mom_prestart_macros + s:general_macros + requests#GetRequests() 370 | elseif ft ==# 'ms' 371 | let s:macros = s:ms_macros + s:general_macros + requests#GetRequests() 372 | endif 373 | let values = s:macros 374 | endif 375 | elseif shortcontext =~# '\\$' 376 | let values = s:escapes 377 | elseif shortcontext =~# '\\f$' 378 | let values = s:font 379 | elseif shortcontext =~# '\\f\([\|(\)$' 380 | let values = s:font 381 | elseif shortcontext =~? '\\[$' 382 | let values = groff_char#GroffCompleteGlyph('\\[') 383 | if values == [] | unlet values | endif 384 | elseif shortcontext =~? '\\($' 385 | let values = groff_char#GroffCompleteGlyph('\\(') 386 | if values == [] | unlet values | endif 387 | elseif shortcontext =~# '^\.\s*nr\s\+$' 388 | let values = s:registers 389 | elseif shortcontext =~# '^\\n$' 390 | let values = s:registers 391 | elseif shortcontext =~# '^\\n\([\|(\)$' 392 | let values = s:registers 393 | elseif shortcontext =~# '^\.\s*ds\s\+$' 394 | let values = s:strings 395 | elseif shortcontext =~# '\\s$' 396 | let values = s:strings 397 | elseif shortcontext =~# '\\s\([\|(\)$' 398 | let values = s:strings 399 | endif 400 | endif 401 | 402 | if exists('values') 403 | for m in values 404 | if type(m) ==# v:t_dict 405 | if m['word'] =~? '^'.a:base 406 | call add(res, m) 407 | endif 408 | elseif m =~? '^'.a:base 409 | call add(res, m) 410 | endif 411 | endfor 412 | return res + res2 413 | endif 414 | endif 415 | endfunction " }}} 416 | 417 | " make optional 418 | setlocal omnifunc=GroffOmnifunc 419 | 420 | function! GroffMan() " {{{ 421 | let [line, col] = [line('.'), col('.')] 422 | " get the syntax type at the cursor 423 | let syntype = reverse(map(synstack(line, col), 'synIDattr(v:val,"name")')) 424 | for synt in syntype 425 | if synt ==# 'nroffEquation' 426 | Man eqn 427 | return 428 | elseif synt ==# 'nroffTable' 429 | Man tbl 430 | return 431 | elseif synt ==# 'nroffPicture' 432 | Man pic 433 | return 434 | endif 435 | endfor 436 | 437 | " TODO: add macro documentation <12-10-20 Gavin Jaeger-Freeborn> 438 | " let macro = CheckMacros() 439 | Man 7 groff 440 | endfunction " }}} 441 | 442 | " plugins {{{ "1 443 | " surround {{{2 444 | " prevent indenting anything 445 | let b:surround_indent = 1 446 | let b:surround_102 = "\\f[\1font: \1]\r\\f[P]" 447 | let b:surround_77 = "\\M[\1font: \1]\r\\M[]" 448 | let b:surround_109 = "\\m[\1font: \1]\r\\m[]" 449 | let b:surround_92 = "\\[\r]" 450 | let b:surround_69 = ".EQ\r.EN" 451 | let b:surround_80 = ".PS\r.PE" 452 | let b:surround_84 = ".TS\r.TE" 453 | " 2}}} "surround 454 | 455 | " TODO: support for mom and other macros <09-10-20 Gavin Jaeger-Freeborn> 456 | " matchit {{{ "2 457 | " matchit now supports ms macros 458 | let b:match_words = '^\.QS:^\.QE,' . '^\.RS:^\.RE,' . '^\.AB:^\.AE,' . '^\.KS:^\.KE,' . '^\.B1:^\.B2,' 459 | \. '^\.cstart:^\.cend,' "chem 460 | \. '^\.EQ:^\.EN,' . 'left:right,' "eqn 461 | \. '^\.G1:^\.G2,' . '^\.GS:^\.GE,' 462 | \. '^\.sqltbl:^\.sqlend,' "sqltbl 463 | \. '^\.``:^\.``,' " ghighlight 464 | \. '^\.IS:^\.IE,' . '^\.PS:^\.PE,' . '^\.R1:^\.R2,' . '^\.TS:^\.TE,. ^\.JS:^\.JE,' 465 | " 2}}} "matchit 466 | " 1}}} "plugins 467 | 468 | " TODO: Add options for automatic compilation 469 | " Automatically compile groff 470 | 471 | function! s:textobj_cancel() 472 | if v:operator ==# 'c' 473 | execute 'normal! u' 474 | endif 475 | endfunction 476 | 477 | " Escape Sequence Text-Objects {{{ " 478 | function! InsideEscapeSequence(escapetype) 479 | call search('\C\(.\|\n^\)\(\\\)\@<!\\' . a:escapetype . '\((..\|\[.\{-}]\|.\)', 'cW') 480 | normal! v 481 | " consider making an if for not being on this line 482 | call search('\C\(\\\)\@<!\\' . a:escapetype . '\((..\|\[.\{-}]\|.\)\(.\|$\n\)', 'becW') 483 | endfunction 484 | 485 | function! AroundEscapeSequence(escapetype) 486 | call search('\C\(\\\)\@<!\\' . a:escapetype . '\((..\|\[.\{-}]\|.\)', 'ecW') 487 | 488 | normal! v 489 | " consider making an if for not being on this line 490 | call search('\C\(\\\)\@<!\\' . a:escapetype . '\((..\|\[.\{-}]\|.\)\(.\|$\)', 'bW') 491 | call search('\C\(\\\)\@<!\\' . a:escapetype . '\((..\|\[.\{-}]\|.\)\(.\|$\)', 'bW') 492 | endfunction 493 | 494 | 495 | " If people are interested in \s±N \s(±N \s±(N ill add it 496 | " at the moment i am not sure of the best way to do this without overlapping 497 | " with is mapping ( inside sentence ) which is useful in troff 498 | 499 | " I am also considering adding support for \* escapes for strings if users are 500 | " interested. 501 | 502 | " TODO: add support for non escaped changes like .ft <20-10-20 Gavin Jaeger-Freeborn> 503 | if g:troff_text_obj_enabled 504 | " change inside/around font 505 | xmap if :<C-u>call InsideEscapeSequence('f')<CR> 506 | omap if :normal vif<CR> 507 | xmap af :<C-u>call AroundEscapeSequence('f')<CR> 508 | omap af :normal vaf<CR> 509 | 510 | " change inside/around font 511 | xmap iF :<C-u>call InsideEscapeSequence('F')<CR> 512 | omap iF :normal viF<CR> 513 | xmap aF :<C-u>call AroundEscapeSequence('F')<CR> 514 | omap aF :normal vaF<CR> 515 | 516 | " change inside/around color 517 | xmap im :<C-u>call InsideEscapeSequence('m')<CR> 518 | omap im :normal vim<CR> 519 | xmap am :<C-u>call AroundEscapeSequence('m')<CR> 520 | omap am :normal vam<CR> 521 | 522 | " change inside/around drawing color 523 | xmap iM :<C-u>call InsideEscapeSequence('M')<CR> 524 | omap iM :normal! vim<CR> 525 | xmap aM :<C-u>call AroundEscapeSequence('M')<CR> 526 | omap aM :normal! vaM<CR> 527 | endif 528 | " }}} Escape Sequence Text-Objects " 529 | 530 | " allow for sourcing local macro packages 531 | setlocal include=^\\.m\\?so 532 | 533 | " allow for searching for machine macros or strings 534 | let &l:define = '^\.\(de\|nr\|ds\)\s*' 535 | 536 | " add comment string for inline use 537 | setlocal commentstring=\\\"%s 538 | 539 | " TODO: clean up formatting <09-10-20 Gavin Jaeger-Freeborn> 540 | " TODO: add pic warnings <09-10-20 Gavin Jaeger-Freeborn> 541 | " Handle all kinds for tracebacks 542 | setlocal errorformat=%o:<standard\ input>\ (%f):%l:%m, 543 | \%o:\ <standard\ input>\ (%f):%l:%m, 544 | \%o:\ %f:%l:%m, 545 | \%o:%f:%l:%m, 546 | \%f:%l:\ macro\ %trror:%m, 547 | \%f:%l:%m, 548 | \%W%tarning:\ file\ '%f'\\,\ around\ line\ %l:,%Z%m 549 | 550 | " setlocal errorformat=%o:<standard\ input>\ (%f):%l:%m 551 | " setlocal errorformat+=%o:%f:%l:%m 552 | " setlocal errorformat+=%o:\ %f:%l:%m 553 | " setlocal errorformat+=refer:%f:%l:%m " invalid symbol 554 | " setlocal errorformat+=refer:%f:%l:%m " invalid symbol 555 | " setlocal errorformat+=%f:%l:\ macro\ %trror:%m " macro errors 556 | " setlocal errorformat+=%f:%l:%m " general errors 557 | " setlocal errorformat+=%W%tarning:\ file\ '%f'\\,\ around\ line\ %l:,%Z%m " warnings 558 | 559 | " vim:foldmethod=marker:foldlevel=0 560 | -------------------------------------------------------------------------------- /syntax/troff.vim: -------------------------------------------------------------------------------- 1 | " File: troff.vim 2 | " Maintainer: Gavin Jaeger-Freeborn <gavinfreeborn@gmail.com> 3 | " Created: Wed 22 Apr 2020 06:41:12 PM 4 | " License: 5 | " Copyright (c) Gavin Jaeger-Freeborn. Distributed under the same terms as Vim itself. 6 | " See :help license 7 | " 8 | " Description: 9 | " extended syntax support for troff 10 | 11 | " TODO: add better compatibility for older versions of troff <09-10-20 Gavin Jaeger-Freeborn> 12 | runtime! syntax/groff.vim 13 | 14 | " Make this optional 15 | if !exists('g:troff_greek') 16 | let g:troff_greek =1 17 | endif 18 | if !exists('g:troff_math') 19 | let g:troff_math =1 20 | endif 21 | if !exists('g:troff_supsub') 22 | let g:troff_supsub =1 23 | endif 24 | 25 | " TODO: support for using eqn delimiter <09-10-20 Gavin Jaeger-Freeborn> 26 | " concealing for eqn equations 27 | fun! s:TroffConceal(group,pat,cchar) " {{{ 28 | exe 'syn match '.a:group." '".a:pat."' contained conceal cchar=".a:cchar 29 | endfun 30 | 31 | if exists('g:troff_greek') 32 | call s:TroffConceal('roffGreek' ,'\<alpha\>' ,'α') 33 | call s:TroffConceal('roffGreek' ,'\<beta\>' ,'β') 34 | call s:TroffConceal('roffGreek' ,'\<gamma\>' ,'γ') 35 | call s:TroffConceal('roffGreek' ,'\<delta\>' ,'δ') 36 | call s:TroffConceal('roffGreek' ,'\<epsilon\>' ,'ϵ') 37 | call s:TroffConceal('roffGreek' ,'\<varepsilon\>' ,'ε') 38 | call s:TroffConceal('roffGreek' ,'\<zeta\>' ,'ζ') 39 | call s:TroffConceal('roffGreek' ,'\<eta\>' ,'η') 40 | call s:TroffConceal('roffGreek' ,'\<theta\>' ,'θ') 41 | call s:TroffConceal('roffGreek' ,'\<vartheta\>' ,'ϑ') 42 | call s:TroffConceal('roffGreek' ,'\<iota\>' ,'ι') 43 | call s:TroffConceal('roffGreek' ,'\<kappa\>' ,'κ') 44 | call s:TroffConceal('roffGreek' ,'\<lambda\>' ,'λ') 45 | call s:TroffConceal('roffGreek' ,'\<mu\>' ,'μ') 46 | call s:TroffConceal('roffGreek' ,'\<nu\>' ,'ν') 47 | call s:TroffConceal('roffGreek' ,'\<xi\>' ,'ξ') 48 | call s:TroffConceal('roffGreek' ,'\<pi\>' ,'π') 49 | call s:TroffConceal('roffGreek' ,'\<varpi\>' ,'ϖ') 50 | call s:TroffConceal('roffGreek' ,'\<rho\>' ,'ρ') 51 | call s:TroffConceal('roffGreek' ,'\<varrho\>' ,'ϱ') 52 | call s:TroffConceal('roffGreek' ,'\<sigma\>' ,'σ') 53 | call s:TroffConceal('roffGreek' ,'\<varsigma\>' ,'ς') 54 | call s:TroffConceal('roffGreek' ,'\<tau\>' ,'τ') 55 | call s:TroffConceal('roffGreek' ,'\<upsilon\>' ,'υ') 56 | call s:TroffConceal('roffGreek' ,'\<phi\>' ,'ϕ') 57 | call s:TroffConceal('roffGreek' ,'\<varphi\>' ,'φ') 58 | call s:TroffConceal('roffGreek' ,'\<chi\>' ,'χ') 59 | call s:TroffConceal('roffGreek' ,'\<psi\>' ,'ψ') 60 | call s:TroffConceal('roffGreek' ,'\<omega\>' ,'ω') 61 | call s:TroffConceal('roffGreek' ,'\<GAMMA\>' ,'Γ') 62 | call s:TroffConceal('roffGreek' ,'\<DELTA\>' ,'Δ') 63 | call s:TroffConceal('roffGreek' ,'\<THETA\>' ,'Θ') 64 | call s:TroffConceal('roffGreek' ,'\<LAMBDA\>' ,'Λ') 65 | call s:TroffConceal('roffGreek' ,'\<XI\>' ,'Ξ') 66 | call s:TroffConceal('roffGreek' ,'\<PI\>' ,'Π') 67 | call s:TroffConceal('roffGreek' ,'\<SIGMA\>' ,'Σ') 68 | call s:TroffConceal('roffGreek' ,'\<UPSILON\>' ,'Υ') 69 | call s:TroffConceal('roffGreek' ,'\<PHI\>' ,'Φ') 70 | call s:TroffConceal('roffGreek' ,'\<CHI\>' ,'Χ') 71 | call s:TroffConceal('roffGreek' ,'\<PSI\>' ,'Ψ') 72 | call s:TroffConceal('roffGreek' ,'\<OMEGA\>' ,'Ω') 73 | endif 74 | 75 | if exists('g:troff_math') 76 | call s:TroffConceal('roffMath' , '>= ' , '≥ ') 77 | call s:TroffConceal('roffMath' , '<= ' , '≤ ') 78 | call s:TroffConceal('roffMath' , '== ' , '≡ ') 79 | call s:TroffConceal('roffMath' , '!= ' , '≠ ') 80 | call s:TroffConceal('roffMath' , '\<int\>' , '∫') 81 | call s:TroffConceal('roffMath' , '\<inf\>' , '∞') 82 | call s:TroffConceal('roffMath' , '<-' , '←') 83 | call s:TroffConceal('roffMath' , '->' , '→') 84 | call s:TroffConceal('roffMath' , '\<partial\>' , '∂') 85 | call s:TroffConceal('roffMath' , '\<prime \>' , '′') 86 | call s:TroffConceal('roffMath' , '\<times\>' , '×') 87 | call s:TroffConceal('roffMath' , '\<prod\>' , '∏') 88 | call s:TroffConceal('roffMath' , '\<del\>' , '∇') 89 | call s:TroffConceal('roffMath' , '\<grad\>' , '∇') 90 | call s:TroffConceal('roffMath' , '\<inter\>' , '∩') 91 | call s:TroffConceal('roffMath' , '\<union\>' , '∪') 92 | call s:TroffConceal('roffMath' , '\<sum\>' , '∑') 93 | call s:TroffConceal('roffMath' , '\<sqrt\>' , '√') 94 | call s:TroffConceal('roffMath' , '\<over\>' , '/') 95 | endif 96 | 97 | if exists('g:troff_supsub') 98 | fun! s:SuperSub(group,leader,pat,cchar) 99 | " call Decho("SuperSub: group<".a:group."> leader<".a:leader."> pat<".a:pat."> cchar<".a:cchar.">") 100 | exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar 101 | exe 'syn match '.a:group."s '".a:pat ."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s' 102 | endfun 103 | 104 | call s:SuperSub('roffSuperscript',' sup ','\<0\>','⁰') 105 | call s:SuperSub('roffSuperscript',' sup ','\<1\>','¹') 106 | call s:SuperSub('roffSuperscript',' sup ','\<2\>','²') 107 | call s:SuperSub('roffSuperscript',' sup ','\<3\>','³') 108 | call s:SuperSub('roffSuperscript',' sup ','\<4\>','⁴') 109 | call s:SuperSub('roffSuperscript',' sup ','\<5\>','⁵') 110 | call s:SuperSub('roffSuperscript',' sup ','\<6\>','⁶') 111 | call s:SuperSub('roffSuperscript',' sup ','\<7\>','⁷') 112 | call s:SuperSub('roffSuperscript',' sup ','\<8\>','⁸') 113 | call s:SuperSub('roffSuperscript',' sup ','\<9\>','⁹') 114 | call s:SuperSub('roffSuperscript',' sup ','\<a\>','ᵃ') 115 | call s:SuperSub('roffSuperscript',' sup ','\<b\>','ᵇ') 116 | call s:SuperSub('roffSuperscript',' sup ','\<c\>','ᶜ') 117 | call s:SuperSub('roffSuperscript',' sup ','\<d\>','ᵈ') 118 | call s:SuperSub('roffSuperscript',' sup ','\<e\>','ᵉ') 119 | call s:SuperSub('roffSuperscript',' sup ','\<f\>','ᶠ') 120 | call s:SuperSub('roffSuperscript',' sup ','\<g\>','ᵍ') 121 | call s:SuperSub('roffSuperscript',' sup ','\<h\>','ʰ') 122 | call s:SuperSub('roffSuperscript',' sup ','\<i\>','ⁱ') 123 | call s:SuperSub('roffSuperscript',' sup ','\<j\>','ʲ') 124 | call s:SuperSub('roffSuperscript',' sup ','\<k\>','ᵏ') 125 | call s:SuperSub('roffSuperscript',' sup ','\<l\>','ˡ') 126 | call s:SuperSub('roffSuperscript',' sup ','\<m\>','ᵐ') 127 | call s:SuperSub('roffSuperscript',' sup ','\<n\>','ⁿ') 128 | call s:SuperSub('roffSuperscript',' sup ','\<o\>','ᵒ') 129 | call s:SuperSub('roffSuperscript',' sup ','\<p\>','ᵖ') 130 | call s:SuperSub('roffSuperscript',' sup ','\<r\>','ʳ') 131 | call s:SuperSub('roffSuperscript',' sup ','\<s\>','ˢ') 132 | call s:SuperSub('roffSuperscript',' sup ','\<t\>','ᵗ') 133 | call s:SuperSub('roffSuperscript',' sup ','\<u\>','ᵘ') 134 | call s:SuperSub('roffSuperscript',' sup ','\<v\>','ᵛ') 135 | call s:SuperSub('roffSuperscript',' sup ','\<w\>','ʷ') 136 | call s:SuperSub('roffSuperscript',' sup ','\<x\>','ˣ') 137 | call s:SuperSub('roffSuperscript',' sup ','\<y\>','ʸ') 138 | call s:SuperSub('roffSuperscript',' sup ','\<z\>','ᶻ') 139 | call s:SuperSub('roffSuperscript',' sup ','\<A\>','ᴬ') 140 | call s:SuperSub('roffSuperscript',' sup ','\<B\>','ᴮ') 141 | call s:SuperSub('roffSuperscript',' sup ','\<D\>','ᴰ') 142 | call s:SuperSub('roffSuperscript',' sup ','\<E\>','ᴱ') 143 | call s:SuperSub('roffSuperscript',' sup ','\<G\>','ᴳ') 144 | call s:SuperSub('roffSuperscript',' sup ','\<H\>','ᴴ') 145 | call s:SuperSub('roffSuperscript',' sup ','\<I\>','ᴵ') 146 | call s:SuperSub('roffSuperscript',' sup ','\<J\>','ᴶ') 147 | call s:SuperSub('roffSuperscript',' sup ','\<K\>','ᴷ') 148 | call s:SuperSub('roffSuperscript',' sup ','\<L\>','ᴸ') 149 | call s:SuperSub('roffSuperscript',' sup ','\<M\>','ᴹ') 150 | call s:SuperSub('roffSuperscript',' sup ','\<N\>','ᴺ') 151 | call s:SuperSub('roffSuperscript',' sup ','\<O\>','ᴼ') 152 | call s:SuperSub('roffSuperscript',' sup ','\<P\>','ᴾ') 153 | call s:SuperSub('roffSuperscript',' sup ','\<R\>','ᴿ') 154 | call s:SuperSub('roffSuperscript',' sup ','\<T\>','ᵀ') 155 | call s:SuperSub('roffSuperscript',' sup ','\<U\>','ᵁ') 156 | call s:SuperSub('roffSuperscript',' sup ','\<W\>','ᵂ') 157 | call s:SuperSub('roffSuperscript',' sup ','\<,\>','︐') 158 | call s:SuperSub('roffSuperscript',' sup ','\<:\>','︓') 159 | call s:SuperSub('roffSuperscript',' sup ','\<;\>','︔') 160 | call s:SuperSub('roffSuperscript',' sup ','\<+\>','⁺') 161 | call s:SuperSub('roffSuperscript',' sup ','\<-\>','⁻') 162 | call s:SuperSub('roffSuperscript',' sup ','\<<\>','˂') 163 | call s:SuperSub('roffSuperscript',' sup ','\<>\>','˃') 164 | call s:SuperSub('roffSuperscript',' sup ','\</\>','ˊ') 165 | call s:SuperSub('roffSuperscript',' sup ','\<(\>','⁽') 166 | call s:SuperSub('roffSuperscript',' sup ','\<)\>','⁾') 167 | call s:SuperSub('roffSuperscript',' sup ','\<\\>.','˙') 168 | call s:SuperSub('roffSuperscript',' sup ','\<=\>','˭') 169 | call s:SuperSub('roffSuperscript',' sup ','\<4\>','⁴') 170 | call s:SuperSub('roffSuperscript',' sup ','\<5\>','⁵') 171 | call s:SuperSub('roffSuperscript',' sup ','\<6\>','⁶') 172 | call s:SuperSub('roffSuperscript',' sup ','\<7\>','⁷') 173 | call s:SuperSub('roffSuperscript',' sup ','\<8\>','⁸') 174 | call s:SuperSub('roffSuperscript',' sup ','\<9\>','⁹') 175 | call s:SuperSub('roffSuperscript',' sup ','\<a\>','ᵃ') 176 | call s:SuperSub('roffSuperscript',' sup ','\<b\>','ᵇ') 177 | call s:SuperSub('roffSuperscript',' sup ','\<c\>','ᶜ') 178 | call s:SuperSub('roffSuperscript',' sup ','\<d\>','ᵈ') 179 | call s:SuperSub('roffSuperscript',' sup ','\<e\>','ᵉ') 180 | call s:SuperSub('roffSuperscript',' sup ','\<f\>','ᶠ') 181 | call s:SuperSub('roffSuperscript',' sup ','\<g\>','ᵍ') 182 | call s:SuperSub('roffSuperscript',' sup ','\<h\>','ʰ') 183 | call s:SuperSub('roffSuperscript',' sup ','\<i\>','ⁱ') 184 | call s:SuperSub('roffSuperscript',' sup ','\<j\>','ʲ') 185 | call s:SuperSub('roffSuperscript',' sup ','\<k\>','ᵏ') 186 | call s:SuperSub('roffSuperscript',' sup ','\<l\>','ˡ') 187 | call s:SuperSub('roffSuperscript',' sup ','\<m\>','ᵐ') 188 | call s:SuperSub('roffSuperscript',' sup ','\<n\>','ⁿ') 189 | call s:SuperSub('roffSuperscript',' sup ','\<o\>','ᵒ') 190 | call s:SuperSub('roffSuperscript',' sup ','\<p\>','ᵖ') 191 | call s:SuperSub('roffSuperscript',' sup ','\<r\>','ʳ') 192 | call s:SuperSub('roffSuperscript',' sup ','\<s\>','ˢ') 193 | call s:SuperSub('roffSuperscript',' sup ','\<t\>','ᵗ') 194 | call s:SuperSub('roffSuperscript',' sup ','\<u\>','ᵘ') 195 | call s:SuperSub('roffSuperscript',' sup ','\<v\>','ᵛ') 196 | call s:SuperSub('roffSuperscript',' sup ','\<w\>','ʷ') 197 | call s:SuperSub('roffSuperscript',' sup ','\<x\>','ˣ') 198 | call s:SuperSub('roffSuperscript',' sup ','\<y\>','ʸ') 199 | call s:SuperSub('roffSuperscript',' sup ','\<z\>','ᶻ') 200 | call s:SuperSub('roffSuperscript',' sup ','\<A\>','ᴬ') 201 | call s:SuperSub('roffSuperscript',' sup ','\<B\>','ᴮ') 202 | call s:SuperSub('roffSuperscript',' sup ','\<D\>','ᴰ') 203 | call s:SuperSub('roffSuperscript',' sup ','\<E\>','ᴱ') 204 | call s:SuperSub('roffSuperscript',' sup ','\<G\>','ᴳ') 205 | call s:SuperSub('roffSuperscript',' sup ','\<H\>','ᴴ') 206 | call s:SuperSub('roffSuperscript',' sup ','\<I\>','ᴵ') 207 | call s:SuperSub('roffSuperscript',' sup ','\<J\>','ᴶ') 208 | call s:SuperSub('roffSuperscript',' sup ','\<K\>','ᴷ') 209 | call s:SuperSub('roffSuperscript',' sup ','\<L\>','ᴸ') 210 | call s:SuperSub('roffSuperscript',' sup ','\<M\>','ᴹ') 211 | call s:SuperSub('roffSuperscript',' sup ','\<N\>','ᴺ') 212 | call s:SuperSub('roffSuperscript',' sup ','\<O\>','ᴼ') 213 | call s:SuperSub('roffSuperscript',' sup ','\<P\>','ᴾ') 214 | call s:SuperSub('roffSuperscript',' sup ','\<R\>','ᴿ') 215 | call s:SuperSub('roffSuperscript',' sup ','\<T\>','ᵀ') 216 | call s:SuperSub('roffSuperscript',' sup ','\<U\>','ᵁ') 217 | call s:SuperSub('roffSuperscript',' sup ','\<W\>','ᵂ') 218 | call s:SuperSub('roffSuperscript',' sup ','\<+\>','⁺') 219 | call s:SuperSub('roffSuperscript',' sup ','\<-\>','⁻') 220 | 221 | call s:SuperSub('roffSubscript',' sub ','\<0\>','₀') 222 | call s:SuperSub('roffSubscript',' sub ','\<1\>','₁') 223 | call s:SuperSub('roffSubscript',' sub ','\<2\>','₂') 224 | call s:SuperSub('roffSubscript',' sub ','\<3\>','₃') 225 | call s:SuperSub('roffSubscript',' sub ','\<4\>','₄') 226 | call s:SuperSub('roffSubscript',' sub ','\<5\>','₅') 227 | call s:SuperSub('roffSubscript',' sub ','\<6\>','₆') 228 | call s:SuperSub('roffSubscript',' sub ','\<7\>','₇') 229 | call s:SuperSub('roffSubscript',' sub ','\<8\>','₈') 230 | call s:SuperSub('roffSubscript',' sub ','\<9\>','₉') 231 | call s:SuperSub('roffSubscript',' sub ','\<a\>','ₐ') 232 | call s:SuperSub('roffSubscript',' sub ','\<e\>','ₑ') 233 | call s:SuperSub('roffSubscript',' sub ','\<h\>','ₕ') 234 | call s:SuperSub('roffSubscript',' sub ','\<i\>','ᵢ') 235 | call s:SuperSub('roffSubscript',' sub ','\<j\>','ⱼ') 236 | call s:SuperSub('roffSubscript',' sub ','\<k\>','ₖ') 237 | call s:SuperSub('roffSubscript',' sub ','\<l\>','ₗ') 238 | call s:SuperSub('roffSubscript',' sub ','\<m\>','ₘ') 239 | call s:SuperSub('roffSubscript',' sub ','\<n\>','ₙ') 240 | call s:SuperSub('roffSubscript',' sub ','\<o\>','ₒ') 241 | call s:SuperSub('roffSubscript',' sub ','\<p\>','ₚ') 242 | call s:SuperSub('roffSubscript',' sub ','\<r\>','ᵣ') 243 | call s:SuperSub('roffSubscript',' sub ','\<s\>','ₛ') 244 | call s:SuperSub('roffSubscript',' sub ','\<t\>','ₜ') 245 | call s:SuperSub('roffSubscript',' sub ','\<u\>','ᵤ') 246 | call s:SuperSub('roffSubscript',' sub ','\<v\>','ᵥ') 247 | call s:SuperSub('roffSubscript',' sub ','\<x\>','ₓ') 248 | call s:SuperSub('roffSubscript',' sub ','\<,\>','︐') 249 | call s:SuperSub('roffSubscript',' sub ','\<+\>','₊') 250 | call s:SuperSub('roffSubscript',' sub ','\<-\>','₋') 251 | call s:SuperSub('roffSubscript',' sub ','\</\>','ˏ') 252 | call s:SuperSub('roffSubscript',' sub ','\<(\>','₍') 253 | call s:SuperSub('roffSubscript',' sub ','\<)\>','₎') 254 | call s:SuperSub('roffSubscript',' sub ','\<\\>.','‸') 255 | call s:SuperSub('roffSubscript',' sub ','\<r\>','ᵣ') 256 | call s:SuperSub('roffSubscript',' sub ','\<v\>','ᵥ') 257 | call s:SuperSub('roffSubscript',' sub ','\<x\>','ₓ') 258 | call s:SuperSub('roffSubscript',' sub ','\\beta\>' ,'ᵦ') 259 | call s:SuperSub('roffSubscript',' sub ','\\delta\>','ᵨ') 260 | call s:SuperSub('roffSubscript',' sub ','\\phi\>' ,'ᵩ') 261 | call s:SuperSub('roffSubscript',' sub ','\\gamma\>','ᵧ') 262 | call s:SuperSub('roffSubscript',' sub ','\\chi\>' ,'ᵪ') 263 | delfun s:SuperSub 264 | endif 265 | hi def link roffMath Special 266 | " }}} "troff conceal 267 | 268 | " TODO: add support for underlining <10-10-20 Gavin Jaeger-Freeborn> 269 | " turn bolded text bold and italic text italic {{{ 270 | syn region nroffBold matchgroup=Delimiter start="\\fB\|\\f\[B\]" end="\\fP\|\\f\[P\?\]\|\\f\[R\]\|\\fR" contains=@Spell keepend concealends 271 | syn region nroffItalic matchgroup=Delimiter start="\\fI\|\\f\[I\]" end="\\fP\|\\f\[P\?\]\|\\f\[R\]\|\\fR" contains=@Spell keepend concealends 272 | 273 | hi def nroffBold term=bold cterm=bold gui=bold 274 | hi def nroffItalic term=italic cterm=italic gui=italic 275 | " }}} " 276 | 277 | " Avoids highlighting spelling in macro names 278 | " NoSpell {{{" 279 | syntax spell toplevel 280 | if !exists('g:troff_nospell_macros') || g:troff_nospell_macros 281 | syn region nroffEscArg start=/'/ end=/'/ contained contains=nroffEscape,@nroffSpecial,@NoSpell 282 | syn cluster nroffSpecial contains=nroffSpecialChar,nroffSpace,@NoSpell 283 | syn match nroffReqLeader /^[.']/ contains=@NoSpell nextgroup=nroffReqName skipwhite 284 | 285 | syn region nroffIgnore start=/^[.']\s*ig/ end=/^['.]\s*\./ 286 | syn match nroffReqLeader /[.']/ contains=@NoSpell contained nextgroup=nroffReqName skipwhite 287 | syn match nroffReqName /[^\t \\\[?]\+/ display contains=@NoSpell contained nextgroup=nroffReqArg 288 | syn region nroffReqArg start=/\S/ skip=/\\$/ end=/$/ contained contains=nroffEscape,@nroffSpecial,nroffString,nroffError,nroffSpaceError,nroffNumBlock,nroffComment,@NoSpell 289 | syn match nroffReqName /\(if\|ie\)/ display contains=@NoSpell contained nextgroup=nroffCond skipwhite 290 | syn match nroffReqName /el/ display contains=@NoSpell contained nextgroup=nroffReqLeader skipwhite 291 | syn match nroffReqname /[da]s/ display contains=@NoSpell contained nextgroup=nroffDefIdent skipwhite 292 | syn region nroffDefinition matchgroup=nroffSpecialChar start=/"/ matchgroup=NONE end=/\\"/me=e-2 skip=/\\$/ start=/\S/ end=/$/ contained contains=nroffDefSpecial,@NoSpell 293 | syn match nroffReqName /\(d[ei]\|am\)/ display contains=@NoSpell contained nextgroup=nroffIdent skipwhite 294 | syn match nroffReqName /als/ contains=@NoSpell contained nextgroup=nroffIdent skipwhite 295 | syn match nroffReqName /[rn]r/ contains=@NoSpell contained nextgroup=nroffIdent skipwhite 296 | syn match nroffReqName /\(rnn\|aln\)/ contains=@NoSpell contained nextgroup=nroffIdent skipwhite 297 | endif 298 | " }}} "NoSpell 299 | 300 | " Allow for folding of preprocessor sections 301 | " preprocessor folding {{{" 302 | syn region nroffEquation start=/^\.\s*EQ\>/ end=/^\.\s*EN\>/ contains=roffGreek,roffMath,roffSuperscript,roffSubscript fold 303 | 304 | if exists('g:troff_eqndelim') 305 | exec 'syn region nroffEquationDel matchgroup=Delimiter start="' . troff_eqndelim[0] .'" matchgroup=Delimiter end="' . troff_eqndelim[1] . '" contains=roffGreek,roffMath,roffSuperscript,roffSubscript concealends ' 306 | endif 307 | syn region nroffTable start=/^\.\s*TS\>/ end=/^\.\s*TE\>/ fold 308 | syn region nroffPicture start=/^\.\s*PS\>/ end=/^\.\s*PE\>/ fold 309 | syn region nroffRefer start=/^\.\s*\[\>/ end=/^\.\s*\]\>/ fold 310 | syn region nroffGrap start=/^\.\s*G1\>/ end=/^\.\s*G2\>/ fold 311 | syn region nroffGremlin start=/^\.\s*GS\>/ end=/^\.\s*GE|GF\>/ fold 312 | " }}} "preprocessor folding 313 | " vim:foldmethod=marker:foldlevel=0 314 | -------------------------------------------------------------------------------- /troff.ctags: -------------------------------------------------------------------------------- 1 | --langdef=troff 2 | --map-troff=+.ms 3 | --map-troff=+.tmac 4 | --map-troff="(tmac.*)" 5 | --kinddef-troff=t,tag,tags 6 | --regex-troff="/^\.(de|MAC)[[:blank:]]+(.+)/\2/t/{scope=ref}" 7 | --------------------------------------------------------------------------------