0.0.11 • Published 2 years ago

inline-math v0.0.11

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

Inline Math for VS Code provides instant math evaluation, anywhere you type! Incredibly useful for quick arithmetic, trigonometry, even unit conversion!

Inline Math follows your cursor and tries to find a valid math expression within the current line. If you highlight some text, it looks within the selection (and works accross multiple lines, too!)

The inlay message can be configured with a custom template, and the hover message can be toggled on/off

Commands

CommandDescription
Toggle Inline MathDisable/Enable inline math
Copy Math ResultCopy the currently shown evaluations to the clipboard

Settings

SettingDefaultDescription
enabledtrueEnables the extension
delay500Delay, in milliseconds, after cusor stops moving until calculation starts - 0 will be instant but try a higher value if you run into performance issues
messageTemplate$source = $resultTemplate used for all inline messages. Interpolates $source, $result
messageMaxChars30Max length of $source replacement in messageTemplate. Result will never be truncated
hoverMessagetrueToggle showing the hover message or not
margin2chDistance between the end of current line and the start of inline message (Supports CSS sizes like ch)
padding2px 1chInner padding of the inline message
borderRadius5pxBorder radius of the inline message
fontFamily''Font family of inline message
fontSize0.85emFont size of inline message
fontWeightnormalFont weight of inline message
fontStyleItalictrueMakes inline message italic

Colors

ColorDefaultDescription
inlineMath.background#00b7e420Background color
inlineMath.backgroundLight#00b7e420Background color (Only in light themes)
inlineMath.foreground#00b7e4Text color
inlineMath.foregroundLight#00b7e4Text color (Only in light themes)

Technical details

Inline Math works by searching subsets of your current line, split on every space. This is to limit the complexity of parsing every possible expression within the current line, but allows you to see results that are in the middle of unrelated code. Each subset, from largest to smallest, is parsed by mathjs and if successful, shows a result. Results are cached to prevent unnecessary calculations (although subset results are not cached right now, pending some profiling...).

Acknowledgements

  • Inline Math borrows heavily, in code structure and style, from Error Lens

  • Under the hood, all evaluation is done with mathjs

Other bits

  • Please report any bugs or make suggestions via Github Issues

  • Contributions are welcome and this extension is in active development

  • Released under the MIT License, free to do whatever you like with it