summaryrefslogtreecommitdiff
path: root/vim/.vim/ftdetect/robot.vim
blob: b8ef1267d30f8196408e3bb1d0766d4e81d3001c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"=============================================================================
" File:         ftdetect/robot.vim
" Author:       Michael Foukarakis
" Version:      0.2
" Created:      Tue 21 Dec 2010 09:08:35 AM EET
" Last Update:  Sat Sep 14, 2013 10:53 BST
"------------------------------------------------------------------------
" Description:
"   Filetype detection plugin for Robot files.
" WARNING:
"   Overrides all default file type checks.
"------------------------------------------------------------------------
" Installation:
"   - Requires Vim7+
"   - Drop this file into {rtp}/ftdetect
"   - Use the '# -*- coding: robot -*-' in the first line of robot files
"     or set the g:robot_syntax_for_txt global variable
"     to explicitly tell vim about filetype.
" History:      - Replaced setf with setlocal filetype, much more sane.
" TODO:         Missing features go here.
"=============================================================================
let s:cpo_save=&cpo
set cpo&vim

" Try to guess when dealing with .html, .txt, or .rst files:
au BufNewFile,BufRead *.txt call s:FTrobot()
au BufNewFile,BufRead *.rst call s:FTrobot()
au BufNewFile,BufRead *.html call s:FTrobot()
" No resorting to heuristics for .robot files:
au BufNewFile,BufRead *.robot setlocal filetype=robot

func! s:FTrobot()
    let b:topl = getline(1)
    if (exists("g:robot_syntax_for_txt") && g:robot_syntax_for_txt)
    \ || b:topl =~ '\*\*\*.\{-}\*\*\*'
    \ || b:topl =~ '^# -\*- coding: robot -\*-$'
        setlocal filetype=robot
    endif
endfunc

"------------------------------------------------------------------------
let &cpo=s:cpo_save
" vim700: set fdm=marker: