From ff3c9c0c480af558e214b18251a5c451f49fe90b Mon Sep 17 00:00:00 2001 From: Wu Yongwei Date: Sun, 12 Jul 2020 14:34:08 +0800 Subject: [PATCH] Support autodetection of ARM assembly. --- autoload/arm/ft.vim | 20 ++++++++++++++++++++ ftdetect/arm.vim | 1 + 2 files changed, 21 insertions(+) create mode 100644 autoload/arm/ft.vim create mode 100644 ftdetect/arm.vim diff --git a/autoload/arm/ft.vim b/autoload/arm/ft.vim new file mode 100644 index 0000000..505414a --- /dev/null +++ b/autoload/arm/ft.vim @@ -0,0 +1,20 @@ +let s:cpo_save = &cpo +set cpo&vim + +function! arm#ft#FTarm() + let head = ' '.getline(1).' '.getline(2).' '.getline(3).' '.getline(4). + \' '.getline(5).' ' + " Can't use setf, as we need to overrule the default filetype setting + if matchstr(head, '\s\.arch\s\+armv4') != '' + set filetype=armv4 + elseif matchstr(head, '\s\.arch\s\+armv5') != '' + set filetype=armv5 + elseif matchstr(head, '\s\.arch\s\+arm') != '' + set filetype=arm + elseif matchstr(head, '\s\.cpu\s\+arm') != '' + set filetype=arm + endif +endfunction + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/ftdetect/arm.vim b/ftdetect/arm.vim new file mode 100644 index 0000000..aa022de --- /dev/null +++ b/ftdetect/arm.vim @@ -0,0 +1 @@ +au BufRead *.[sS] call arm#ft#FTarm()