GithubHelp home page GithubHelp logo

dlesbre / vscode-generic-input-method Goto Github PK

View Code? Open in Web Editor NEW

This project forked from konn/vscode-generic-input-method

0.0 0.0 0.0 1.05 MB

Generic Input Method for VSCode, mainly focusing on Unicode Symbol input for Theorem Provers, and YaTeX-like image completion for LaTeX

License: BSD 3-Clause "New" or "Revised" License

TypeScript 100.00%

vscode-generic-input-method's Introduction

Generic Input Method for VSCode

Visual Studio Marketplace Visual Studio Marketplace

This extension provides a generic input method within VSCode. It can be used as a YaTeX-like image completion for LaTeX or Unicode Math input for theorem provers such as Agda or Lean.

Features

  • YaTeX-like image-completion for LaTeX
    • Since version 0.0.8, LaTeX-related functionalities are moved to CaTeX extension.
  • Unicode Math input for Markdown
  • Ability to configure your own custom input methods!
  • Automatic configuration update

Demos

Unicode Math Input

GIF Anime

Configuration

You can define and/or modify input methods in generic-input-method.input-methods. This must be an array of input method. Each input method is defined as follows:

{
  // Unique name for the input method
  "name": "Example Math Input",

  // Languages where the IM is activated.
  "languages": ["markdown", "latex"],

  // Characters to trigger conversion
  "triggers": ["\\"],

  // How to render each items?
  // Available: "string" or "snippet"; other extension can add more.
  // `string` just prints the content of "body" property.
  // See `defaults/images.json` for examples.
  // You can also define custom expander for render.
  "renderMode": "string",

  // Suffix for a text-editor command;
  // you can invoke it as `extension.complete.custom.example-math`.
  "commandName": "custom.example-math",

  // An array of items or a reference to the default dictionary.
  "dictionary": [
    // Default Math dictionary shipped with this extension
    "defaults/math.json",

    // Push `\||-` to input `\Vvdash`.
    // Shows `⊪` as a preview.
    { "label": "|||-", "body": "\\Vvdash", "description": "⊪" }
  ]
}

Currently, you can only refer to the default dictionaries shipped with the generic-input-method extension.

External API

This extension provides an API to un/register custom input methods.

Registering a new Input Method dynamically

import { extensions, ExtensionContext } from "vscode";

function async activate(context: ExtensionContext) {
  let ims = extensions.getExtension("mr-konn.generic-input-method");
  if (gim) {
    const api: any = await gim.activate();
    const im: any = {
      name: "My Great IM Dynamically Registered",
      languages: ["redtt"],
      triggers: ["\\"],
      dictionary: ["defaults/math.json", { label: "to", body: "→" }]
    };
    api.registerInputMethod(im);
  }
}

See CaTeX and redtt-diagnostics for an example usage.

Invoking Input Method Forcedly

You can use api.invokeInputMethod(editor?, nameOrIM?) to invoke an input method, regardless of the language of editor.

TODOs

  • Cool screenshot GIFs
  • Underlining converted input
  • Contextual completion based on scopes
  • Split LaTeX-related input methods as an external extension?

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.