Created
October 30, 2024 07:53
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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