A Neovim plugin that persistently remembers when you manually set the filetype for a specific file (e.g., via :set filetype=rust), and automatically restores that filetype the next time the same file is opened.
- Automatic Detection: Detects when you manually change a file's filetype
- Persistent Storage: Remembers filetype settings across Neovim sessions
- Smart Restoration: Automatically applies saved filetypes when opening files
- Manual Management: Commands to view and clear saved filetype mappings
Using lazy.nvim
{
'Faria22/ftmemo.nvim',
config = function()
require('ftmemo').setup()
end,
}Using packer.nvim
use {
'Faria22/ftmemo.nvim',
config = function()
require('ftmemo').setup()
end,
}Using vim-plug
Plug 'Faria22/ftmemo.nvim'Then add to your Neovim configuration:
require('ftmemo').setup()The plugin works automatically once installed. When you manually set a filetype for a file:
:set filetype=rustThe plugin will remember this setting and automatically apply it the next time you open the same file.
The plugin can be configured by passing options to the setup() function:
require('ftmemo').setup({
enabled = true, -- Enable/disable the plugin
storage_file = vim.fn.stdpath('data') .. '/ftmemo.json', -- Where to store filetype mappings
debug = false, -- Enable debug logging
}):FtMemoShow- Display all saved filetype mappings:FtMemoClear- Clear the saved filetype for the current file and clear the current buffer's filetype:FtMemoCleanup- Clean up saved mappings for files that no longer exist
- Detection: The plugin monitors filetype changes using Neovim's autocommands
- Storage: When a manual filetype change is detected, it's saved to a JSON file in your Neovim data directory
- Restoration: When opening a file, the plugin checks if there's a saved filetype and applies it
- Persistence: All mappings are stored persistently and survive Neovim restarts
- Cleanup: Invalid mappings for non-existent files are automatically cleaned up on startup
# Open a file without extension
nvim myfile
# Manually set the filetype
:set filetype=python
# Close and reopen the file
:q
nvim myfile
# The filetype will automatically be set to 'python'MIT License - see LICENSE file for details.