mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-08 19:43:52 -05:00
Reduce startup time by avoiding calling slow au!
This commit is contained in:
@@ -185,7 +185,7 @@ func! polyglot#detect#Pm()
|
|||||||
let &ft = g:filetype_pm | return
|
let &ft = g:filetype_pm | return
|
||||||
endif
|
endif
|
||||||
if polyglot#shebang#Detect() | return | endif
|
if polyglot#shebang#Detect() | return | endif
|
||||||
set ft=perl | au! BufWritePost <buffer> ++once call polyglot#detect#Pm()
|
set ft=perl | au BufWritePost <buffer> ++once call polyglot#detect#Pm()
|
||||||
return
|
return
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ func! polyglot#detect#Pl()
|
|||||||
let &ft = g:filetype_pl | return
|
let &ft = g:filetype_pl | return
|
||||||
endif
|
endif
|
||||||
if polyglot#shebang#Detect() | return | endif
|
if polyglot#shebang#Detect() | return | endif
|
||||||
set ft=perl | au! BufWritePost <buffer> ++once call polyglot#detect#Pl()
|
set ft=perl | au BufWritePost <buffer> ++once call polyglot#detect#Pl()
|
||||||
return
|
return
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -231,7 +231,7 @@ func! polyglot#detect#T()
|
|||||||
let &ft = g:filetype_t | return
|
let &ft = g:filetype_t | return
|
||||||
endif
|
endif
|
||||||
if polyglot#shebang#Detect() | return | endif
|
if polyglot#shebang#Detect() | return | endif
|
||||||
set ft=perl | au! BufWritePost <buffer> ++once call polyglot#detect#T()
|
set ft=perl | au BufWritePost <buffer> ++once call polyglot#detect#T()
|
||||||
return
|
return
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -259,6 +259,6 @@ func! polyglot#detect#Html()
|
|||||||
set ft=xhtml | return
|
set ft=xhtml | return
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
set ft=html | au! BufWritePost <buffer> ++once call polyglot#detect#Html()
|
set ft=html | au BufWritePost <buffer> ++once call polyglot#detect#Html()
|
||||||
return
|
return
|
||||||
endfunc
|
endfunc
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -395,7 +395,7 @@ def rule_to_code(rule)
|
|||||||
if rule.has_key?("filetype")
|
if rule.has_key?("filetype")
|
||||||
if rule.has_key?("fallback")
|
if rule.has_key?("fallback")
|
||||||
return <<~EOS
|
return <<~EOS
|
||||||
set ft=#{rule["filetype"]} | au! BufWritePost <buffer> ++once call polyglot#detect##{camelize(rule["extensions"].first)}()
|
set ft=#{rule["filetype"]} | au BufWritePost <buffer> ++once call polyglot#detect##{camelize(rule["extensions"].first)}()
|
||||||
return
|
return
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
@@ -564,7 +564,7 @@ def generate_ftdetect(packages, heuristics)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if set_globs.size > 0
|
if set_globs.size > 0
|
||||||
autocommands << " au! BufNewFile,BufRead #{set_globs.join(",")} #{set_command}\n"
|
autocommands << " au BufNewFile,BufRead #{set_globs.join(",")} #{set_command}\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -583,13 +583,13 @@ def generate_ftdetect(packages, heuristics)
|
|||||||
|
|
||||||
show_warnings(all_filetypes, expected_filetypes)
|
show_warnings(all_filetypes, expected_filetypes)
|
||||||
|
|
||||||
ftdetect = File.read('ftdetect/polyglot.vim')
|
ftdetect = File.read('filetype.vim')
|
||||||
|
|
||||||
starting = '" DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE'
|
starting = '" DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE'
|
||||||
ending = '" DO NOT EDIT CODE ABOVE, IT IS GENERATED WITH MAKEFILE'
|
ending = '" DO NOT EDIT CODE ABOVE, IT IS GENERATED WITH MAKEFILE'
|
||||||
|
|
||||||
File.write(
|
File.write(
|
||||||
'ftdetect/polyglot.vim',
|
'filetype.vim',
|
||||||
ftdetect.gsub(/(?<=#{starting}\n)(.*)(?=#{ending})/m) { output }
|
ftdetect.gsub(/(?<=#{starting}\n)(.*)(?=#{ending})/m) { output }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ call TestExtension("sh", "bash3", "#! /bin/bash2.3")
|
|||||||
call TestExtension("sh", "bash4", "#!/usr/bin/env bash")
|
call TestExtension("sh", "bash4", "#!/usr/bin/env bash")
|
||||||
call TestExtension("sh", "bash6", "#!/usr/bin/env -i -=split-string foo=bar bash -l foo")
|
call TestExtension("sh", "bash6", "#!/usr/bin/env -i -=split-string foo=bar bash -l foo")
|
||||||
call TestExtension("sh", "bash1", "#!/bin/bash")
|
call TestExtension("sh", "bash1", "#!/bin/bash")
|
||||||
|
" This is defined only by vim-native scripts.vim for now
|
||||||
call TestExtension("sh", "bash7", ":")
|
call TestExtension("sh", "bash7", ":")
|
||||||
|
|
||||||
" Vim help file
|
" Vim help file
|
||||||
|
|||||||
Reference in New Issue
Block a user