mirror of
https://github.com/jessebot/dot_files.git
synced 2025-10-01 01:48:43 +00:00
only change filetype to unix if buffer is modifiable
This commit is contained in:
parent
83d617307c
commit
c2371a1d7f
1 changed files with 6 additions and 2 deletions
|
@ -6,9 +6,13 @@ local autocmd = vim.api.nvim_create_autocmd
|
|||
|
||||
-- on file enter, set file format to unix
|
||||
autocmd({"BufEnter", "BufWinEnter"}, {
|
||||
pattern = {"*yaml", "*yml", "*tpl"},
|
||||
pattern = {"*"},
|
||||
callback = function()
|
||||
vim.cmd("set fileformat=unix")
|
||||
-- verify the buffer is modifiable before setting fileformat
|
||||
local modifiable = vim.api.nvim_buf_get_option(0, 'modifiable')
|
||||
if modifiable then
|
||||
vim.cmd("set fileformat=unix")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue