Giter VIP home page Giter VIP logo

typst-preview.nvim's Introduction

✨ Typst Preview for Neovim ✨

The Neovim plugin for Enter-tainer/typst-preview.

trimmed.mp4

💪 Features

  • Low latency preview: preview your document instantly on type. The incremental rendering technique makes the preview latency as low as possible.
  • Cross jump between code and preview. You can click on the preview to jump to the corresponding code location and have the preview follow your cursor in Neovim.

📦 Installation

Lazy.nvim:

{
  'chomosuke/typst-preview.nvim',
  lazy = false, -- or ft = 'typst'
  version = '0.1.*',
  build = function() require 'typst-preview'.update() end,
}

Packer.nvim:

use {
  'chomosuke/typst-preview.nvim',
  tag = 'v0.1.*',
  run = function() require 'typst-preview'.update() end,
}

vim-plug:

Plug 'chomosuke/typst-preview.nvim', {'tag': 'v0.1.*', do: ':TypstPreviewUpdate'}

🚀 Usage

Commands / Functions:

  • :TypstPreviewUpdate or require 'typst-preview'.update():
    • Download the necessary binaries to vim.fn.fnamemodify(vim.fn.stdpath 'data' .. '/typst-preview/', ':p').
    • This must be run before any other commands can be run.
      • If you followed the installation instructions, your package manager should automatically run this for you.
  • :TypstPreview:
    • Start the preview.
  • :TypstPreviewStop:
    • Stop the preview.
  • :TypstPreviewToggle:
    • Toggle the preview.
  • :TypstPreviewFollowCursor or require 'typst-preview'.set_follow_cursor(true):
    • Scroll preview as cursor moves.
    • This is on by default.
  • :TypstPreviewNoFollowCursor or require 'typst-preview'.set_follow_cursor(false):
    • Don't scroll preview as cursor moves.
  • :TypstPreviewFollowCursorToggle or require 'typst-preview'.set_follow_cursor(not init.get_follow_cursor()).
  • :TypstPreviewSyncCursor or require 'typst-preview'.sync_with_cursor():
    • Scroll preview to the current cursor position. This can be used in combination with :TypstPreviewNoFollowCursor so that the preview only scroll to the current cursor position when you want it to.

⚙️ Configuration

This plugin should work out of the box with no configuration. Call to setup() is not required.

Default

require 'typst-preview'.setup {
  -- Setting this true will enable printing debug information with print()
  debug = false,

  -- Custom format string to open the output link provided with %s
  -- Example: open_cmd = 'firefox %s -P typst-preview --class typst-preview'
  open_cmd = nil,

  -- Provide the path to binaries for dependencies.
  -- Setting this will skip the download of the binary by the plugin.
  -- Warning: Be aware that your version might be older than the one
  -- required.
  dependencies_bin = {
          ['typst-preview'] = nil,
          ['websocat'] = nil
  },

  -- Setting this to 'always' will invert black and white in the preview
  -- Setting this to 'auto' will invert depending if the browser has enable
  -- dark mode
  invert_colors = 'never',

  -- This function will be called to determine the root of the typst project
  get_root = function(bufnr_of_typst_buffer)
    return vim.fn.getcwd()
  end,
}

❓ Comparison with other tools

The author of Enter-tainer/typst-preview wrote a good comparison here.

  • niuiic/typst-preview.nvim: Since niuiic/typst-preview.nvim uses typst-lsp, it has similar advantages and disadvantages of typst-lsp mentioned here:
    • Higher latency due to the PDF reader having a delay.
    • Does not support cross jump between code and preview.

💻 Contribution

All PRs are welcome.

Credit

This plugin wouldn't be possible without the work of Enter-tainer/typst-preview. If you like this plugin enough to star it, please consider staring Enter-tainer/typst-preview as well.

typst-preview.nvim's People

Contributors

chomosuke avatar axiomofchoices avatar m4cey avatar fr4nk1incs avatar lamprospitsillos avatar nino avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.