A command-line utility that displays files with Neovim's syntax highlighting in the terminal.
nvcat
is a CLI tool similar to Unix's cat
but with syntax highlighting powered by Neovim's syntax and treesitter engines. It leverages Neovim's capabilities to provide accurate syntax highlighting for a wide range of file formats directly in your terminal.
- Syntax highlighting using Neovim's highlighting engine
- Support for treesitter-based highlighting
- Optional line numbers
- Can use your existing Neovim configuration or run with a clean instance
![]() |
Viewing a Lua file with Tokyonight-night colorscheme |
---|
![]() |
Nvcat as fzf's preview, with my custom colorscheme. |
Prequisites:
- Neovim 0.10+ (must be accessible via
nvim
) - A terminal that supports true color
See the releases page for prebuilt binaries for Linux, macOS, and Windows.
Requires Go 1.22+
go install github.com/brianhuster/nvimcat@latest
Or clone and build manually:
git clone https://github.com/brianhuster/nvcat.git
cd nvcat
sudo make install
nvcat [options] <file>
-n
: Show line numbers-clean
: Don't load Neovim's config-v
: Show version information-h
: Show help information
You can configure Nvcat using Vimscript or Lua just the same as you would with Neovim. However, it is recommended to start from a scratch config, because LSP, plugins can cause unnecessary long startup time and other unexpected behaviors. Generally you would only need to set colorscheme, tabstop, or enable Treesitter highlighting
There are 2 ways to configure Nvcat:
1. Use Nvcat's config directory: $XDG_CONFIG_HOME/nvcat/init.lua
or $XDG_CONFIG_HOME/nvcat/init.vim
.
With this method, your Nvcat configuration will be seperated from your Neovim configuration, and it can be loaded even when the flag -clean
is given
Example:
--- ~/.config/nvcat/init.lua
vim.opt.rtp:append(path/to/your/colorscheme/runtimepath)
-- Add runtimepath directory containing 'parser/<your-treesitter-parsers>'
vim.opt.rtp:append("replace/with/your/actual/path")
vim.cmd.colorscheme("your-colorscheme")
vim.o.tabstop = 4
vim.api.nvim_create_autocmd("FileType", {
callback = function()
pcall(vim.treesitter.start)
end
})
Nvcat sets Vimscript variable g:nvcat
on startup, so you can use it to control which parts of your Neovim configuration should not be used by Nvcat.
Example:
--- ~/.config/nvim/init.lua
if vim.g.nvcat then
-- Nvcat configuration
else
-- LSP, plugins, etc.
end
nvcat
only supports legacy and Treesitter-based syntax highlighting engines. It does not support LSP-based highlighting.nvcat
doesn't change background colors, so you should use a color scheme that has a background color similar to your terminal's
