A simple and lightweight Neovim plugin that brings syntax highlighting to generic log files and provides straight-forward configuration to manage the log filetype detection.
Although this plugin is still working in progress, the major features are in
place already.
Feel free to give it a try by following the installation and
configuration.
Missing syntax highlighting will be added sooooon (based on the logs I read or
find).
More detailed documentation is on the way (though not much to say given this
plugin is quite simple).
Use your favorite plugin manager to download and configure the plugin:
{
'fei6409/log-highlight.nvim',
config = function()
require('log-highlight').setup {}
end,
},
use {
'fei6409/log-highlight.nvim',
config = function()
require('log-highlight').setup {}
end,
},
Plug 'fei6409/log-highlight.nvim'
Don't forget to add syntax on
in your .vimrc
, init.vim
or init.lua
to
allow syntax highlighting to work.
This plugin makes use of Neovim's built-in filetype detection mechanism.
By default, log
filetype will apply to files with log
extension (e.g.
sys.log
, my_log
etc.) after setting up.
You can customize the filetype detection patterns like below:
require('log-highlight').setup {
-- The following options support either a string or a table of strings.
-- The file extensions.
extension = 'log',
-- The file names or the full file paths.
filename = {
'messages',
},
-- The file path glob patterns, e.g. `.*%.lg`, `/var/log/.*`.
-- Note: `%.` is to match a literal dot (`.`) in a pattern in Lua, but most
-- of the time `.` and `%.` here make no observable difference.
pattern = {
'/var/log/.*',
'messages%..*',
},
}
By default, log
filetype will apply to files if the name matches *.log
or
*_log
.
To allow more customized patterns, add autocommands in your .vimrc
like below.
" Example:
autocmd BufNewFile,BufRead /var/log/* set filetype=log
- v0.0.1: Initial release
- v0.0.2: More supports for HDL
Bug reports, feature requests and pull requests are welcome.
Please also consider attaching a snippet of the log patterns when doing so.
If you're sending pull requests, please also consider adding the log samples in
samples/
:
- For atomic patterns or smaller pieces, add them to
patterns.log
. - For longer snippets of real-world logs, create a new log file.
That would be helpful for me to examine if new changes break any existing syntax highlighting.