xref: /vim-8.2.3635/runtime/ftplugin/awk.vim (revision d0bce504)
1" Vim filetype plugin
2" Language:		awk, nawk, gawk, mawk
3" Maintainer:		Doug Kearns <[email protected]>
4" Previous Maintainer:	Antonio Colombo <[email protected]>
5" Last Change:		2020 Sep 28
6
7" This plugin was prepared by Mark Sikora
8" This plugin was updated as proposed by Doug Kearns
9
10" Only do this when not done yet for this buffer
11if exists("b:did_ftplugin")
12  finish
13endif
14
15" Don't load another plugin for this buffer
16let b:did_ftplugin = 1
17
18let s:cpo_save = &cpo
19set cpo&vim
20
21setlocal comments=:#
22setlocal commentstring=#\ %s
23setlocal formatoptions-=t formatoptions+=croql
24
25setlocal define=function
26setlocal suffixesadd+=.awk
27
28let b:undo_ftplugin = "setl fo< com< cms< def< sua<" .
29		    \ " | unlet! b:browsefilter"
30
31" TODO: set this in scripts.vim?
32if exists("g:awk_is_gawk")
33  setlocal include=@include
34  setlocal suffixesadd+=.gawk
35  if has("unix") || has("win32unix")
36    setlocal formatprg=gawk\ -f-\ -o/dev/stdout
37    let b:undo_ftplugin .= " | setl fp<"
38  endif
39
40  let path = system("gawk 'BEGIN { printf ENVIRON[\"AWKPATH\"] }'")
41  let path = substitute(path, '^\.\=:\|:\.\=$\|:\.\=:', ',,', 'g') " POSIX cwd
42  let path = substitute(path, ':', ',', 'g')
43
44  let &l:path = path
45  let b:undo_ftplugin .= " | setl inc< path<"
46endif
47
48if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
49  let b:browsefilter = "Awk Source Files (*.awk,*.gawk)\t*.awk;*.gawk\n" .
50		     \ "All Files (*.*)\t*.*\n"
51endif
52
53let &cpo = s:cpo_save
54unlet s:cpo_save
55
56" vim: nowrap sw=2 sts=2 ts=8
57