forked from nathom/filetype.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
40 lines (34 loc) · 1.1 KB
/
init.lua
File metadata and controls
40 lines (34 loc) · 1.1 KB
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
if vim.g.did_load_filetypes then
return
end
vim.g.did_load_filetypes = 1
-- Re export specific properties
local re_export = {}
re_export.add = require('filetype.resolve').add
re_export.add_ignored_extension = require('filetype.resolve').add_ignored_extension
re_export.resolve = require('filetype.resolve').resolve
-- Create filetypedetect augroup
vim.api.nvim_create_augroup('filetypedetect', { clear = false })
-- General autocmd for filetype detection
vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, {
group = 'filetypedetect',
callback = re_export.resolve,
})
-- ftdetect auto-commands should be sourced after our auto command
if vim.g.source_ftdetect and not vim.g.did_load_ftdetect then
vim.cmd([[
augroup filetypedetect
runtime! ftdetect/*.vim
runtime! ftdetect/*.lua
augroup END
]])
vim.g.did_load_ftdetect = 1
end
-- If no filetype is set, then use the user's default filetype
if vim.g.default_filetype then
vim.api.nvim_create_autocmd('BufEnter', {
group = 'filetypedetect',
command = [[if &ft == '' | set ft=]] .. vim.g.default_filetype .. [[ | endif]],
})
end
return re_export