A fast and convenient Neovim plugin for quickly changing the filetype of the current buffer.
Requires Neovim >= 0.7
- 🚀 Quick filetype switching with an interactive picker
- 📋 Pinned filetypes shown first, rest listed alphabetically
- 🎯 Visual indicator for the current filetype
- ⚙️ Simple, minimal configuration
- 🔍 Support for all Neovim filetypes
{
"NewbieAndy/nvim-filetype",
cmd = "FTSelect",
keys = {
{ "<leader>ft", "<cmd>FTSelect<cr>", desc = "Select Filetype" },
},
}{
"NewbieAndy/nvim-filetype",
cmd = "FTSelect",
keys = {
{ "<leader>ft", "<cmd>FTSelect<cr>", desc = "Select Filetype" },
},
opts = {
-- Commonly used filetypes, prioritized in the selection list
filetypes = { "lua", "python", "javascript", "typescript" },
-- Whether to show all available filetypes
-- If false, only configured filetypes are shown
show_all_filetypes = true,
-- Icon displayed next to the current filetype
selected_icon = "✓",
},
}use { "NewbieAndy/nvim-filetype" }
-- Optional: customize with setup()
require("nvim-filetype").setup({
filetypes = { "lua", "python", "javascript" },
show_all_filetypes = true,
selected_icon = "✓",
})Plug 'NewbieAndy/nvim-filetype'
" Optional: customize with setup() after plug#end()
lua << EOF
require("nvim-filetype").setup({
filetypes = { "lua", "python", "javascript" },
show_all_filetypes = true,
selected_icon = "✓",
})
EOFrequire("nvim-filetype").setup({
-- Pinned filetypes always shown first, in the order listed
filetypes = {},
-- Show all available Neovim filetypes
-- When true: pinned first, then all others alphabetically
-- When false: only pinned filetypes are shown
show_all_filetypes = true,
-- Icon displayed next to the currently active filetype
selected_icon = "*",
})| Option | Type | Default | Description |
|---|---|---|---|
filetypes |
string[] |
{} |
Pinned filetypes always shown first |
show_all_filetypes |
boolean |
true |
Show all Neovim filetypes, or only pinned ones |
selected_icon |
string |
"*" |
Icon shown next to the current filetype |
require("nvim-filetype").setup({
filetypes = { "lua", "python", "javascript", "typescript" },
selected_icon = "✓",
})require("nvim-filetype").setup({
filetypes = { "lua", "python", "javascript", "typescript", "go", "rust" },
show_all_filetypes = false,
})After installation, use the following command to open the filetype picker:
:FTSelectAdd a keymapping for quick access:
vim.keymap.set("n", "<leader>ft", "<cmd>FTSelect<cr>", { desc = "Select Filetype" })Or in Vimscript:
nnoremap <leader>ft :FTSelect<CR>- Open any buffer
- Execute
:FTSelector use your keymapping - Type to filter filetypes (fuzzy matching supported if using a fuzzy picker)
- Select the desired filetype
- The buffer's filetype is immediately updated
The picker list order is: pinned (your filetypes config, in declared order) → all others alphabetically.
- Quick Syntax Highlighting: Change syntax highlighting without reopening files
- Testing Syntax: Test how code looks with different syntax highlighting
- File Identification: Help Neovim properly identify file types
- Development Workflow: Quickly switch between related filetypes (e.g., JavaScript ↔ TypeScript)
Ensure you have a UI picker installed. The plugin uses vim.ui.select(), which requires:
- A UI picker plugin like telescope.nvim with
telescope-ui-select.nvim, or - dressing.nvim for enhanced UI
Make sure the filetype you're selecting is valid. You can check available filetypes with:
:echo getcompletion('', 'filetype')If you have custom filetypes defined in your configuration, ensure they are properly loaded before calling :FTSelect.
Contributions are welcome! Feel free to:
- Report bugs
- Suggest new features
- Submit pull requests
This project is licensed under the MIT License - see the LICENSE file for details.
Thanks to all contributors and users of this plugin!