blob: 785088ff9b26c803cf6cae36272615b07fe493ca [file] [log] [blame]
Bram Moolenaar3df01732017-02-17 22:47:16 +01001" Vim filetype plugin
Bram Moolenaar3132cdd2020-11-05 20:41:49 +01002" Language: awk, nawk, gawk, mawk
3" Maintainer: Doug Kearns <dougkearns@gmail.com>
4" Previous Maintainer: Antonio Colombo <azc100@gmail.com>
5" Last Change: 2020 Sep 28
Bram Moolenaar3df01732017-02-17 22:47:16 +01006
7" This plugin was prepared by Mark Sikora
Bram Moolenaard58a3bf2020-09-28 21:48:16 +02008" This plugin was updated as proposed by Doug Kearns
Bram Moolenaar3df01732017-02-17 22:47:16 +01009
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
Bram Moolenaard58a3bf2020-09-28 21:48:16 +020018let s:cpo_save = &cpo
19set cpo&vim
Bram Moolenaar3df01732017-02-17 22:47:16 +010020
Bram Moolenaard58a3bf2020-09-28 21:48:16 +020021setlocal comments=:#
Bram Moolenaar3df01732017-02-17 22:47:16 +010022setlocal commentstring=#\ %s
Bram Moolenaard58a3bf2020-09-28 21:48:16 +020023setlocal 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
Christian Brabandtf7ac0ef2023-09-06 20:41:25 +020040 " Disabled by default for security reasons.
41 if get(g:, 'awk_exec', get(g:, 'plugin_exec', 0))
42 let path = system("gawk 'BEGIN { printf ENVIRON[\"AWKPATH\"] }'")
43 let path = substitute(path, '^\.\=:\|:\.\=$\|:\.\=:', ',,', 'g') " POSIX cwd
44 let path = substitute(path, ':', ',', 'g')
Bram Moolenaard58a3bf2020-09-28 21:48:16 +020045
Christian Brabandtf7ac0ef2023-09-06 20:41:25 +020046 let &l:path = path
47 endif
Bram Moolenaard58a3bf2020-09-28 21:48:16 +020048 let b:undo_ftplugin .= " | setl inc< path<"
49endif
50
51if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
52 let b:browsefilter = "Awk Source Files (*.awk,*.gawk)\t*.awk;*.gawk\n" .
53 \ "All Files (*.*)\t*.*\n"
54endif
55
56let &cpo = s:cpo_save
57unlet s:cpo_save
58
59" vim: nowrap sw=2 sts=2 ts=8