fei6409/log-highlight.nvim

github github
syntax
stars 106
issues 0
subscribers 3
forks 8
CREATED

UPDATED


log-highlight.nvim

A simple and lightweight Neovim plugin that brings syntax highlighting to generic log files and provides straightforward configuration to manage filetype detection rules for your logs.

preview-1

preview-2

Installation

Use your favorite plugin manager to install the plugin.

lazy.nvim

{
    'fei6409/log-highlight.nvim',
    opts = {},
},

vim-plug

Plug 'fei6409/log-highlight.nvim'

Don't forget to add syntax on in your .vimrc, init.vim, or init.lua to enable syntax highlighting.

Configuration

Neovim

This plugin uses Neovim's built-in filetype detection mechanism.

By default, the log filetype is applied to files with a .log extension (e.g., sys.log) after setup.

You can customize the filetype detection patterns as follows:

require('log-highlight').setup {
    ---@type string|string[]
    -- File extensions
    extension = 'log',

    ---@type string|string[]
    -- File names or full file paths
    filename = {
        'syslog',
    },

    ---@type string|string[]
    -- File path glob patterns
    -- Note: In Lua, `%` escapes special characters to match them literally.
    pattern = {
        '%/var%/log%/.*',
        'console%-ramoops.*',
        'log.*%.txt',
        'logcat.*',
    },
}

Vim

By default, the log filetype is applied to files matching *.log or *_log.

To add custom patterns, add autocommands to your .vimrc like this:

" Example:
autocmd BufNewFile,BufRead /var/log/* set filetype=log

Release Notes

  • v1.0.1: Support lowercase and spdlog-style log levels
  • v1.0.0: Minor cleanup and official release
  • v0.0.2: More supports for HDL
  • v0.0.1: Initial release

Contributing

Bug reports, feature requests, and pull requests are welcome. When opening an issue or PR, please consider attaching a snippet of the relevant log pattern.

If you are submitting a pull request, please also consider adding new log samples to the samples/ directory:

  • For atomic patterns or small snippets, add them to patterns.log.
  • For longer, real-world log examples, create a new file.

This helps verify that new changes do not break existing syntax highlighting.

Acknowledgements

License

This project is licensed under the MIT License.