Skip to content

Faria22/ftmemo.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ftmemo.nvim

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.

Features

  • 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

Installation

Using lazy.nvim

{
  'Faria22/ftmemo.nvim',
  config = function()
    require('ftmemo').setup()
  end,
}
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()

Usage

The plugin works automatically once installed. When you manually set a filetype for a file:

:set filetype=rust

The plugin will remember this setting and automatically apply it the next time you open the same file.

Configuration

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
})

Commands

  • :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

How it Works

  1. Detection: The plugin monitors filetype changes using Neovim's autocommands
  2. Storage: When a manual filetype change is detected, it's saved to a JSON file in your Neovim data directory
  3. Restoration: When opening a file, the plugin checks if there's a saved filetype and applies it
  4. Persistence: All mappings are stored persistently and survive Neovim restarts
  5. Cleanup: Invalid mappings for non-existent files are automatically cleaned up on startup

Examples

# 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'

License

MIT License - see LICENSE file for details.

About

Remembers manually set filetypes per file across sessions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages