Scratchpad to format small snippets

Hello !

In my day to day work I often have to write small snippets to illustrate ticket tech strategy.

I was wondering if you guys knew a cool way to have quick scratchpad where I could manipulate the snippet, format it, and have minimal syntax coloration.

This is usually handled by LSP, but sometimes having a full lsp running is not practical, with all the overhead of typescript config for example.

Main formats are JSON, typescript and soon Rust.

Cheers

5 points · 5 comments · view on lemmy.world

5 Comments

aistina@lemmy.world · 2 pts · 3y (2 replies)

I think Neoformat lets you format a buffer without saving it, without the need for an LSP. So you could:

:enew 
:set syntax=json
(Write some code)
:Neoformat <formatter-name>

https://github.com/sbdchd/neoformat

Paria_Stark@lemmy.world · 3 pts · 3y (1 reply)

Wow it actually looks like exactly what I am looking for. Thanks !

aistina@lemmy.world · 2 pts · 3y

You’re welcome! Glad I could help.

MinFapper@lemmy.world · 1 pts · 3y (1 reply)

Why not just invoke prettier from the command line?

Paria_Stark@lemmy.world · 1 pts · 3y

I could do this, but i would love a solution where I do not have to write a tmp file, and instead do everything in a temporary buffer

Yearly1845@reddthat.com · 1 pts · 3y
[ removed ]