Skip to content

Instantly share code, notes, and snippets.

@roderik333
Created October 30, 2024 07:53
Show Gist options
  • Save roderik333/d910f0870b4e23b887210fdd6971b365 to your computer and use it in GitHub Desktop.
Save roderik333/d910f0870b4e23b887210fdd6971b365 to your computer and use it in GitHub Desktop.
Custom filetype and icon for htmldjango in oil file explorer - for Astronvim / neovim / nvim
return {
{
"stevearc/oil.nvim",
dependencies = "nvim-tree/nvim-web-devicons",
config = function()
require("oil").setup({
default_file_explorer = true,
})
local function setup_djhtml_icon()
local has_devicons, devicons = pcall(require, "nvim-web-devicons")
if has_devicons then
local html_icon, html_color = devicons.get_icon(".html", "html", { default = true })
devicons.set_icon({
djhtml = {
icon = html_icon,
color = "#e34c26",
name = "HTMLDjango",
},
})
end
end
setup_djhtml_icon()
end,
-- Keymap is defined in astrocore
},
}
vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
group = vim.api.nvim_create_augroup("filetype_django", { clear = true }),
desc = "Change filetype to htmldjango",
callback = function()
if vim.fn.expand("%:e") == "djhtml" then
vim.bo.filetype = "htmldjango"
end
end,
})
vim.filetype.add({
extension = {
djhtml = "htmldjango",
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment