summaryrefslogtreecommitdiffstats
path: root/.config/nvim/plugin/50-ftdetect.lua
blob: b824d4d5ad6c3a3d2a44a23feb28a53f1734e430 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
--
-- 50-ftdetect.lua
--
-- * Detects bash files and sets 'filetype'.
--

-- 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,
})