summaryrefslogtreecommitdiffstats
path: root/.config/nvim/plugin/50-ftdetect.lua
blob: 49fc6d647b291e30f49b63ffc1c78c5b0f2ab619 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
--
-- Filetype detection plugin
--

-- Detect bash files
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
	desc = "Detect bash file",
	group = vim.g.dotfiles.augroup,
	pattern = "*",
	callback = function()
		if
			string.find(vim.api.nvim_buf_get_name(0), "%.bash$")
			or string.find(vim.api.nvim_buf_get_lines(0, 0, 1, false)[1] or "", "^#!/usr/bin/bash")
		then
			vim.bo.filetype = "bash"
		end
	end,
})