Skip to content

πŸ”΄ Make TypeScript errors prettier and human-readable in Neovim πŸŽ€

License

Notifications You must be signed in to change notification settings

youyoumu/pretty-ts-errors.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

pretty-ts-errors.nvim

A Neovim plugin that enhances TypeScript errors by formatting them into readable, markdown-formatted.

recording_2025-03-22_17-23-21.mp4

Requirements

Installation

-- pretty-ts-errors.lua
return {
  {
    "youyoumu/pretty-ts-errors.nvim",
    opts = {
      -- your configuration options
    },
  },
}

Installing the CLI Tool

The plugin requires the pretty-ts-errors-markdown CLI tool. You can install it using npm:

npm install -g pretty-ts-errors-markdown

Configuration

Here's the default configuration:

{
  executable = "pretty-ts-errors-markdown", -- Path to the executable
  float_opts = {
    border = "rounded",        -- Border style for floating windows
    max_width = 80,            -- Maximum width of floating windows
    max_height = 20,           -- Maximum height of floating windows
  },
  auto_open = true,            -- Automatically show errors on hover
}

Usage

Commands

The plugin provides the following commands:

  • :PrettyTsError - Show the formatted error under the cursor in a floating window
  • :PrettyTsErrors - Open a split window with all TypeScript errors in the current buffer
  • :PrettyTsToggleAuto - Toggle automatic error display on hover

Keybindings

Add these to your configuration:

-- Show error under cursor
vim.keymap.set('n', '<leader>te', function() require('pretty-ts-errors').show_formatted_error() end, { desc = "Show TS error" })

-- Show all errors in file
vim.keymap.set('n', '<leader>tE', function() require('pretty-ts-errors').open_all_errors() end, { desc = "Show all TS errors" })

-- Toggle auto-display
vim.keymap.set('n', '<leader>tt', function() require('pretty-ts-errors').toggle_auto_open() end, { desc = "Toggle TS error auto-display" })

How It Works

The plugin intercepts TypeScript diagnostics from the LSP server and passes them to the CLI tool, which formats them into readable markdown. This markdown is then displayed in Neovim using floating windows or buffer splits.

Credits

This project is powered by and inspired by:

  • pretty-ts-errors - The original VS Code extension that improves TypeScript error messages
  • pretty-ts-errors-markdown - A fork of pretty-ts-errors that outputs errors in markdown format, which this plugin uses as a CLI dependency

Thanks to the original authors for creating these fantastic tools that make working with TypeScript more pleasant!

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

πŸ”΄ Make TypeScript errors prettier and human-readable in Neovim πŸŽ€

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages