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