Skip to content

SylvanFranklin/omni-preview.nvim

Repository files navigation

Omni-Preview.nvim

Provides a master list of nvim preview plugins for different filetypes and a command to tie them together. The goal is to get everything working quickly, while keeping open advanced configuration. Simple plugin + Awesome list of previews.

demo.mp4

Important

Still in early stages and lacking support for many plugins, PR's to support your plugin are super welcome! I'll try to add as many as I can.

Builtin:

  • Simple files: .png, .svg, .tiff, .jpeg, .html, .pdfs, etc.

Works out of the box with third party

  • CSV
  • Latex (just by finding a corresponding pdf file, look into vimtex for more)
  • Markdown
  • Typst
  • ...More coming soon

Install

Lazy.nvim

{
    "sylvanfranklin/omni-preview.nvim",
    opts = {}
}

Packer.nvim

use {
    'sylvanfranklin/omni-preview.nvim',
    config = function()
        require 'omni-preview'.setup {}
    end,
}

Installing Previews

Simply installing plugins as dependencies calls .setup which is usually enough for most of these pugins to work. If for some reason it doesn't you can manually call .setup() on each of them.

For example with Lazy

{
    "sylvanfranklin/omni-preview",
    dependencies = {
        -- Typst
        { 'chomosuke/typst-preview.nvim', lazy = true },
        -- CSV
        { 'hat0uma/csvview.nvim',         lazy = true },
    },
    opts = {},
}

Override default settings Sometimes these plugins have behavior that you want to change, simply call setup on them yourself.

{
    "sylvanfranklin/omni-preview",
    dependencies = {
        -- for markdown
        { "toppair/peek.nvim", lazy = true, build = "deno task --quiet build:fast" } 
    },
    config = function()
        require("omni-preview").setup()
        require("peek").setup({ app = "browser" })
    end
}

Usage

One command to rule them all :OmniPreview {args}

Three intuitive subcommands :OmniPreview start, :OmniPreview stop, :OmniPreview toggle.

There is no default keymapping for the, I recommend setting:

vim.keymap.set("n", "<leader>p", ":OmniPreview toggle<CR>", { silent = true })

I often just close the preview manually since some of them don't have defined stop behavior, for instance system level preview tools. Maybe there is some way to close these efficiently but I'm not all that aware of it.

Filetypes

Remember to add these as dependencies or set them up manually with .setup if you want your own preferences. The Lazy package manager will call default setup functions on everything defined as a depencency. While this does save some complexity, it also often means less than desirable default behavior. Because of this I like to set things up individually.

Typst

{ 'chomosuke/typst-preview.nvim', lazy = true }, 

Markdown

  • peek.nvim Best all around in my experience.
{ "toppair/peek.nvim", lazy = true, build = "deno task --quiet build:fast" },
{ "wallpants/github-preview.nvim", lazy = true },
{"iamcco/markdown-preview.nvim", lazy = true}
  • markview.nvim In editor conceal based preview (also requires treesitter and dev icons)
{ "OXY2DEV/markview.nvim", lazy = true}

HTML

    {
        'barrett-ruth/live-server.nvim',
        build = 'pnpm add -g live-server',
        cmd = { 'LiveServerStart', 'LiveServerStop' },
        config = true
    }

CSV

{ 'hat0uma/csvview.nvim', lazy = true } 

Other

    {'tigion/nvim-asciidoc-preview', lazy = true}

For images and other types I just use the unix open command. You can override that behavior by passing a filetype and start and stop string or function.

require("omni-preview").setup({
    previews = {
        { trig = "pdf", start = "zathura" -- , stop=... }
    }
})

ROADMAP 🌾

Lot's of work to do, this is early days.

  • Mason like UI and registry
  • Telescope like picker to support multiple types of previews
  • More config options for more plugins
  • More coverage of LaTeX
  • Support for multiple previews on a single filetype

Alternatives

  • The OG knap, requires a bit more tinkering to get certain previews working.
  • Live support for many types live-preview.nvim. I might try to intergrate this in omni soon.

go give stars to the authors of these and the preview plugins, they are the real heros.

About

Manage previews for all filetypes in neovim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages