From 3030db8ff09ab6da0f1f941518ef5c071053c5f8 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Sun, 15 Sep 2019 14:01:27 +0700 Subject: Update 2019-09-15 --- vim/.vim/scripts.vim | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ vim/.vim/vimrc | 1 + 2 files changed, 56 insertions(+) create mode 100644 vim/.vim/scripts.vim (limited to 'vim') diff --git a/vim/.vim/scripts.vim b/vim/.vim/scripts.vim new file mode 100644 index 0000000..6221c55 --- /dev/null +++ b/vim/.vim/scripts.vim @@ -0,0 +1,55 @@ +" Additional scripts' filetype detections + +" This file is called by an autocommand for every file that has just been +" loaded into a buffer. It checks if the type of file can be recognized by +" the file contents. The autocommand is in $VIMRUNTIME/filetype.vim. +" +" Note that the pattern matches are done with =~# to avoid the value of the +" 'ignorecase' option making a difference. Where case is to be ignored use +" =~? instead. Do not use =~ anywhere. + +" Only do the rest when the FileType autocommand has not been triggered yet. +if did_filetype() + finish +endif + +" Line continuation is used here, remove 'C' from 'cpoptions' +let s:cpo_save = &cpo +set cpo&vim + +let s:line1 = getline(1) +if s:line1 =~# "^#!" + " A script that starts with "#!". + " Check for a line like "#!/usr/bin/env VAR=val bash". Turn it into + " "#!/usr/bin/bash" to make matching easier. + if s:line1 =~# '^#!\s*\S*\' + let s:name = substitute(s:line1, '^#!.*\\s\+\(\i\+\).*', '\1', '') + elseif s:line1 =~# '^#!\s*[^/\\ ]*\>\([^/\\]\|$\)' + let s:name = substitute(s:line1, '^#!\s*\([^/\\ ]*\>\).*', '\1', '') + else + let s:name = substitute(s:line1, '^#!\s*\S*[/\\]\(\i\+\).*', '\1', '') + endif + + " GNU Octave + if s:name =~# 'octave' + set ft=octave + endif + unlet s:name +endif + +" Restore 'cpoptions' +let &cpo = s:cpo_save +unlet s:cpo_save s:line1 diff --git a/vim/.vim/vimrc b/vim/.vim/vimrc index e93cb2b..b8c5ed3 100755 --- a/vim/.vim/vimrc +++ b/vim/.vim/vimrc @@ -16,6 +16,7 @@ set omnifunc=syntaxcomplete#Complete set diffopt+=algorithm:patience autocmd BufWinEnter * let w:m1=matchadd('ColorColumn', '\%<81v.\%>80v', -1) autocmd BufNewFile,BufRead *.PAS setlocal filetype=pascal +autocmd BufNewFile,BufRead *.m setlocal filetype=octave autocmd FileType c,h,go,glsl setlocal cindent cinoptions=(0 noexpandtab shiftwidth=8 autocmd FileType rst setlocal shiftwidth=3 autocmd FileType css,javascript,python,perl6 setlocal shiftwidth=4 -- cgit 1.4.1