blob: 9809fec38393de3811469a9dd99e659cb83f9353 [file] [log] [blame]
Bram Moolenaar3df01732017-02-17 22:47:16 +01001" Vim filetype plugin
2" Language: awk, nawk, gawk, mawk
3" Maintainer: Antonio Colombo <azc100@gmail.com>
Bram Moolenaard58a3bf2020-09-28 21:48:16 +02004" Last Change: 2020 Sep 28
Bram Moolenaar3df01732017-02-17 22:47:16 +01005
6" This plugin was prepared by Mark Sikora
Bram Moolenaard58a3bf2020-09-28 21:48:16 +02007" This plugin was updated as proposed by Doug Kearns
Bram Moolenaar3df01732017-02-17 22:47:16 +01008
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
Bram Moolenaard58a3bf2020-09-28 21:48:16 +020017let s:cpo_save = &cpo
18set cpo&vim
Bram Moolenaar3df01732017-02-17 22:47:16 +010019
Bram Moolenaard58a3bf2020-09-28 21:48:16 +020020setlocal comments=:#
Bram Moolenaar3df01732017-02-17 22:47:16 +010021setlocal commentstring=#\ %s
Bram Moolenaard58a3bf2020-09-28 21:48:16 +020022setlocal 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