npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

coc-pretty-ts-errors

v0.0.17

Published

coc-pretty-ts-errors

Downloads

223

Readme

coc-pretty-ts-errors

Inspired by https://github.com/yoavbls/pretty-ts-errors. This CoC extension is a port of the original extension to work with CoC.

Based on https://github.com/hexh250786313/pretty-ts-errors-markdown.

https://github.com/hexh250786313/coc-pretty-ts-errors/assets/26080416/cae19b18-e4cb-4fee-8739-caec87a588c6

Features

  • Show TypeScript error messages in a more readable format.

  • You can choose to use doHover or diagnostic floating window to display error message by option pretty-ts-errors.mode.

  • There are two ways to highlight code blocks, one is to use the highlight group PrettyTsErrorType to highlight a single color, and the other is to use ts syntax highlight. |pretty-ts-errors.codeBlockHighlightType | screenshot | description | |---|---|---| |"prettytserr" | | Use highlight group PrettyTsErrorType to highlight a single color. | | "typescript" | | Use ts syntax highlight. And for correct syntax highlight it will extra add a "type Type = " before type definition in code blocks. |

    ※ Personally, I prefer to use prettytserr to highlight a single color, because it is more readable and does not affect the original code.

Usage

Make sure you have coc.nvim and coc-tsserver installed.

And make sure your coc.nvim includes the pr https://github.com/neoclide/coc.nvim/commit/9c079ad79d66d4ede7886cc4094a822352559502 which gives diagnostic floating window highlight.

Then run the following command:

:CocInstall coc-pretty-ts-errors

Configuration

Here are the available configuration options for coc-pretty-ts-errors:

  • pretty-ts-errors.enable: (Boolean, default: true) Enable or disable the coc-pretty-ts-errors extension.
  • pretty-ts-errors.showLink: (Boolean, default: false) Show ref links in error message.
  • pretty-ts-errors.mode: (0 | 1 | 2, default: 1) Display mode of the error message.
  • pretty-ts-errors.codeBlockHighlightType: ("prettytserr" | "typescript", default: "prettytserr") The way to highlight code block.
  • pretty-ts-errors.serverName: (String, default: "tsserver") The name of the language server. Set it to 'tsserver' if youse coc-tsserver. Otherwise, set it to your customized typescript language server name.
  • pretty-ts-errors.sourceName: (String) The name of the source. Same as serverName by default.

Q & A

Q1: :CocList diagnostics has additional error messages from coc-pretty-ts-errors.

A1: When choosing to display error messages in the diagnostic floating window (mode 0 and 2), it will cause :CocList diagnostics to have additional error messages from coc-pretty-ts-errors. These error messages are formatted copies of the original errors, and there is currently no good way to remove these messages (the same problem also occurs in the diagnostics virtual text at the end of the line). Therefore, I personally recommend using mode 1 with :call CocActionAsync('doHover').

Q2: The alignment of the markdown list format is a bit strange, and sometimes the indentation is too much.

A2: coc.nvim issue: https://github.com/neoclide/coc.nvim/issues/4882

Q3: When to use serverName and sourceName

A3: Examples:

  • When using coc-tsserver , both serverName and sourceName are "tsserver"

  • When using a customized typescript "languageserver", you need to modify serverName and sourceName to the corresponding values, such as typescript-language-server

    // coc-settings.json
    "pretty-ts-errors.serverName": "my-tsserver",
                                   ~~~~~~~~~~~~~          Your customized typescript language server name.
    "pretty-ts-errors.sourceName": "typescript",
                                   ~~~~~~~~~~~~~          You have to know the source name of your customized typescript language server from its documentation.
                                                          Like coc-tsserver is "tsserver" and typescript-language-server is "typescript".
    "languageserver": {
        "my-tsserver": {
        ~~~~~~~~~~~~~          `serverName` is from here.
            "enable": true,
            "command": "typescript-language-server",
            "args": ["--stdio"],
    
            ...
            ...other options
    
        }
    }