summaryrefslogtreecommitdiffstats
path: root/autoload/polyglot
diff options
context:
space:
mode:
Diffstat (limited to 'autoload/polyglot')
-rw-r--r--autoload/polyglot/detect.vim12
-rw-r--r--autoload/polyglot/ft.vim2
-rw-r--r--autoload/polyglot/init.vim6
3 files changed, 17 insertions, 3 deletions
diff --git a/autoload/polyglot/detect.vim b/autoload/polyglot/detect.vim
index cac826cf..2b1900e6 100644
--- a/autoload/polyglot/detect.vim
+++ b/autoload/polyglot/detect.vim
@@ -134,6 +134,18 @@ func! polyglot#detect#Fs(...)
set ft=forth | return
endfunc
+func! polyglot#detect#Frag(...)
+ if a:0 != 1 && did_filetype()
+ return
+ endif
+ for lnum in range(1, min([line("$"), 50]))
+ let line = getline(lnum)
+ if line =~# '\s*\(#version\|precision\|uniform\|varying\|vec[234]\)'
+ set ft=glsl | return
+ endif
+ endfor
+endfunc
+
func! polyglot#detect#Re(...)
if a:0 != 1 && did_filetype()
return
diff --git a/autoload/polyglot/ft.vim b/autoload/polyglot/ft.vim
index 56012da1..2ba69ed1 100644
--- a/autoload/polyglot/ft.vim
+++ b/autoload/polyglot/ft.vim
@@ -1,7 +1,7 @@
" Vim functions for file type detection
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2021 Nov 27
+" Last Change: 2021 Dec 17
" These functions are moved here from runtime/filetype.vim to make startup
" faster.
diff --git a/autoload/polyglot/init.vim b/autoload/polyglot/init.vim
index 1457f11a..353da7e4 100644
--- a/autoload/polyglot/init.vim
+++ b/autoload/polyglot/init.vim
@@ -2319,7 +2319,8 @@ if !has_key(g:polyglot_is_disabled, 'jsx')
endif
if !has_key(g:polyglot_is_disabled, 'javascript')
- au BufNewFile,BufRead *._js,*.bones,*.cjs,*.es,*.es6,*.frag,*.gs,*.jake,*.javascript,*.js,*.jsb,*.jscad,*.jsfl,*.jsm,*.jss,*.jsx,*.mjs,*.njs,*.pac,*.sjs,*.ssjs,*.xsjs,*.xsjslib,Jakefile setf javascript
+ au! BufNewFile,BufRead,BufWritePost *.frag call polyglot#detect#Frag()
+ au BufNewFile,BufRead *._js,*.bones,*.cjs,*.es,*.es6,*.gs,*.jake,*.javascript,*.js,*.jsb,*.jscad,*.jsfl,*.jsm,*.jss,*.jsx,*.mjs,*.njs,*.pac,*.sjs,*.ssjs,*.xsjs,*.xsjslib,Jakefile setf javascript
au BufNewFile,BufRead *.flow setf flow
endif
@@ -2339,7 +2340,8 @@ endif
if !has_key(g:polyglot_is_disabled, 'glsl')
au! BufNewFile,BufRead,BufWritePost *.fs call polyglot#detect#Fs()
- au BufNewFile,BufRead *.comp,*.fp,*.frag,*.frg,*.fsh,*.fshader,*.geo,*.geom,*.glsl,*.glslf,*.glslv,*.gs,*.gshader,*.rchit,*.rmiss,*.shader,*.tesc,*.tese,*.vert,*.vrx,*.vsh,*.vshader setf glsl
+ au! BufNewFile,BufRead,BufWritePost *.frag call polyglot#detect#Frag()
+ au BufNewFile,BufRead *.comp,*.fp,*.frg,*.fsh,*.fshader,*.geo,*.geom,*.glsl,*.glslf,*.glslv,*.gs,*.gshader,*.rchit,*.rmiss,*.shader,*.tesc,*.tese,*.vert,*.vrx,*.vsh,*.vshader setf glsl
endif
if !has_key(g:polyglot_is_disabled, 'git')