blob: 1bca3ad3cf6b71de711be4ac160a797f6ab390af [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
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