Skip to content

ctfrancia/severityhl.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

SeverityHL.nvim

A Neovim plugin that highlights important keywords in your code based on their severity level. Never miss a FIXME or TODO again!

✨ Features

  • 🎯 Smart Highlighting: Automatically highlights keywords based on severity levels
  • 🎨 Customizable Colors: Define your own highlight groups and colors
  • ⚡ Real-time Updates: Highlights update as you type
  • 🔧 Runtime Configuration: Add/remove keywords without restarting
  • 📁 Filetype Filtering: Apply highlighting only to specific file types
  • 💪 Case Sensitivity: Toggle case-sensitive matching
  • 🌈 Theme Compatible: Works with any colorscheme

🚀 Installation

Using vim.pack.add() (Neovim 0.10+)

vim.pack.add("https://github.com/ctfrancia/severityhl.nvim")

Using lazy.nvim

{
  "ctfrancia/severityhl.nvim",
  config = function()
    require("severityhl").setup()
  end
}
use {
  "ctfrancia/severityhl.nvim",
  config = function()
    require("severityhl").setup()
  end
}

Using vim-plug

Plug 'ctfrancia/severityhl.nvim'

" Add to your init.vim or init.lua
lua require("severityhl").setup()

Using build in package manager

vim.pack.add({
	"https://github.com/ctfrancia/severityhl.nvim",
})

require("severityhl").setup()

Manual Installation (Built-in Package Manager)

# Create plugin directory
mkdir -p ~/.config/nvim/pack/plugins/start/severityhl.nvim

# Clone the repository
git clone https://github.com/ctfrancia/severityhl.nvim ~/.config/nvim/pack/plugins/start/severityhl.nvim

⚙️ Configuration

Default Setup

require("severityhl").setup()

Custom Configuration

require("severityhl").setup({
  keywords = {
    -- High severity (red background)
    high = {
      words = { "FIXME", "BUG", "ERROR", "HACK", "XXX" },
      highlight = "SeverityHigh"
    },
    -- Medium severity (yellow background)
    medium = {
      words = { "TODO", "WARNING", "WARN", "DEPRECATED" },
      highlight = "SeverityMedium"
    },
    -- Low severity (blue background)
    low = {
      words = { "NOTE", "INFO", "OPTIMIZE", "REVIEW" },
      highlight = "SeverityLow"
    }
  },
  -- Apply to all file types (empty table means all)
  filetypes = {},
  -- Case insensitive by default
  case_sensitive = false
})

Advanced Configuration Examples

Custom Colors:

require("severityhl").setup({
  keywords = {
    critical = {
      words = { "CRITICAL", "URGENT" },
      highlight = "MyCritical"
    }
  }
})

-- Define custom highlight
vim.api.nvim_set_hl(0, "MyCritical", {
  fg = "#ffffff",
  bg = "#ff0000",
  bold = true,
  italic = true
})

Filetype Specific:

require("severityhl").setup({
  -- Only highlight in these file types
  filetypes = { "lua", "python", "javascript", "typescript" },
  case_sensitive = true
})

Minimal Setup:

require("severityhl").setup({
  keywords = {
    urgent = {
      words = { "FIXME", "TODO" },
      highlight = "SeverityHigh"
    }
  }
})

🎮 Usage

Commands

Command Description
:SeverityHighlighterRefresh Manually refresh highlighting
:SeverityHighlighterToggleCase Toggle case sensitivity
:SeverityHighlighterAdd <severity> <word> Add a keyword to a severity level
:SeverityHighlighterRemove <severity> <word> Remove a keyword from a severity level

Runtime API

local severity = require("severityhl")

-- Add new keywords
severity.add_keyword("high", "URGENT")
severity.add_keyword("medium", "REFACTOR")

-- Remove keywords
severity.remove_keyword("low", "NOTE")

-- Toggle case sensitivity
severity.toggle_case_sensitive()

-- Refresh highlighting
severity.refresh()

Examples in Code

The plugin will automatically highlight these patterns:

-- High severity (red)
-- FIXME: This needs immediate attention
-- BUG: Critical issue here
-- ERROR: Something is broken
-- HACK: Temporary solution
-- XXX: Dangerous code

-- Medium severity (yellow)  
-- TODO: Implement this feature
-- WARNING: Potential issue
-- DEPRECATED: Use new API instead

-- Low severity (blue)
-- NOTE: Important information
-- INFO: Additional context
-- OPTIMIZE: Performance improvement needed

🎨 Default Colors

The plugin comes with sensible defaults that work with most colorschemes:

  • High Severity: Bright red text on dark red background
  • Medium Severity: Orange text on dark orange background
  • Low Severity: Blue text on dark blue background

All highlights include bold formatting for better visibility.

🔧 Customization

Adding New Severity Levels

require("severityhl").setup({
  keywords = {
    -- Keep existing levels
    high = {
      words = { "FIXME", "BUG" },
      highlight = "SeverityHigh"
    },
    -- Add custom level
    security = {
      words = { "SECURITY", "VULN", "XSS" },
      highlight = "SecurityIssue"
    }
  }
})

-- Define custom highlight
vim.api.nvim_set_hl(0, "SecurityIssue", {
  fg = "#ff6b6b",
  bg = "#4a1c1c",
  bold = true
})

Language Specific Keywords

-- Different configurations for different languages
vim.api.nvim_create_autocmd("FileType", {
  pattern = "python",
  callback = function()
    require("severityhl").add_keyword("high", "# FIXME")
    require("severityhl").add_keyword("medium", "# TODO")
  end
})

vim.api.nvim_create_autocmd("FileType", {
  pattern = "javascript",
  callback = function()
    require("severityhl").add_keyword("high", "// FIXME")
    require("severityhl").add_keyword("medium", "// TODO")
  end
})

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Inspired by various TODO highlighting plugins
  • Built for the Neovim community

Happy coding! 🎉

About

highlight words in your neovim based on severity

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages