Fix detecting conf filetype, closes #641

This commit is contained in:
Adam Stankiewicz
2020-12-29 23:40:05 +01:00
parent 47dcae9131
commit 1150adc4db
4 changed files with 15 additions and 10 deletions

View File

@@ -7,4 +7,4 @@ test:
@ scripts/test
dev:
@ find scripts autoload/polyglot ftdetect tests . -type f -maxdepth 1 | DEV=1 entr bash -c 'make && make test'
@ find scripts autoload/polyglot ftdetect tests . -type f -maxdepth 1 | DEV=1 entr bash -c 'make'

View File

@@ -449,6 +449,11 @@ func! polyglot#shebang#VimDetect()
endif
if line1 =~ '^# ' || getline(2) =~ '^# ' || getline(3) =~ '^# ' || getline(4) =~ '^# ' || getline(5) =~ '^# '
setf FALLBACK conf
return 1
endif
return 1
endfunc

View File

@@ -2659,13 +2659,13 @@ func! s:Observe(fn)
augroup END
endfunc
au BufNewFile,BufRead,StdinReadPost * if expand("<afile>:e") == "" |
au BufNewFile,BufRead,StdinReadPost,BufWritePost * if expand("<afile>:e") == "" |
\ call polyglot#shebang#Detect() | endif
au BufWinEnter * if &ft == "" && expand("<afile>:e") == "" |
\ call s:Observe('shebang#Detect') | endif
au FileType * au! polyglot-observer
au BufWritePost * au! polyglot-observer
augroup END
@@ -3528,7 +3528,6 @@ if exists("did_load_filetypes") && exists("g:polyglot_disabled")
runtime! extras/filetype.vim
endif
let s:runtime = resolve($VIMRUNTIME)
let s:base = resolve(expand('<sfile>:p:h:h'))

View File

@@ -113,9 +113,9 @@ def sort_packages(packages)
each_child = lambda { |n, &b|
[
implicit_dependencies[n] || [],
packages[n]["dependencies"] || [],
packages[n]["after"] || []
].flatten.each(&b)
packages[n] ? packages[n]["dependencies"] || [] : [],
packages[n] ? packages[n]["after"] || [] : []
].flatten.each { |e| b.call(e) if packages[e] }
}
TSort.tsort(each_node, each_child).map { |a| packages[a] }
@@ -248,11 +248,11 @@ def load_languages
end
def load_packages
YAML.load_stream(File.read('packages.yaml'))
YAML.load_stream(File.read('packages.yaml')) || []
end
def load_heuristics
YAML.load_stream(File.read('heuristics.yaml'))
YAML.load_stream(File.read('heuristics.yaml')) || []
end
def parse_remote(remote)
@@ -486,6 +486,7 @@ def extract(packages)
)
FileUtils.rm_rf(all_dirs)
Dir.mkdir('extras') unless File.exists?('extras')
for dir in Dir.glob("*", base: "autoload")
if dir != "polyglot"