Leveraging editor.action.insertSnippet from a different plugin

I am attempting to enhance the functionality of VS Code by adding buttons to the status bar that automatically insert code snippets. I am utilizing this Extension for this purpose. Additionally, I have configured keybindings in my keybindings.json file which are working perfectly fine.

{
    "key": "alt+x l",
    "command": "editor.action.insertSnippet",
    "when": "editorTextFocus && editorLangId == 'markdown'",
    "args": {
        "snippet": "[Text](URL)$0"
    }
}

Unfortunately, I am facing challenges with passing arguments correctly to achieve the same results using the extension. I have experimented with different variations in my settings.json, but without any success. Although the button is displayed and the insertSnippet command is executed, the arguments are not passed successfully as intended.

        {
            "alignment": "left",
            "priority": -9996,
            "text": "$(file-media)",
            "tooltip": "Insert image reference",
            "command": "editor.action.insertSnippet",
            "arguments":["{\"snippet\": \"[Text](URL)$0\"}"],
            "filterLanguageRegex": "markdown"
        }

I appreciate your assistance in advance!

Answer №1

Just a heads up for anyone who comes across this issue in the future:

The commands extension requires an array of commands, and the 'insertSnippet' command specifically needs an object with the "snippet" key. Here is the correct format to use:

{
  "alignment": "left",
  "priority": -9996,
  "text": "$(file-media)",
  "tooltip": "Insert image reference",
  "command": "editor.action.insertSnippet",
  "arguments":[{
    "snippet": "[Text](URL)$0"
  }],
  "filterLanguageRegex": "markdown"
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Establish the predefined date for the air-datepicker

I am currently utilizing the air-datepicker inline feature. My objective is to establish the starting date for it. Below is the script detailing my attempt: export function load_datepickers_inline():void { const search_legs_0_datepicker = $("#search_leg ...

Updating a subscribed observable does not occur when pushing or nexting a value from an observable subject

Help needed! I've created a simple example that should be working, but unfortunately it's not :( My onClick() function doesn't seem to trigger the console.log as expected. Can someone help me figure out what I'm doing wrong? @Component ...

Unable to extract nested JSON data using JSON_TABLE in Oracle SQL

I am currently utilizing Oracle 12c(12.2) to extract json data from a table. SELECT jt.name, jt.employee_id, jt.company FROM JSON_TABLE ( BFILENAME ('DB_DIR', 'vv.json') I have encountered an issue with nested data in the j ...

What is the correct method for accessing an array within an object that is nested inside an array within a JSON file in Angular?

In my Angular controller code, everything is functioning properly except for the $scope.Product. I am unable to access the array of product details. Here is the relevant code snippet: .controller('aboutCtrl', function ($scope, aboutService) { ...

What is the secret to getting this nested observable to function correctly?

Currently, I am working on an autocomplete feature that dynamically filters a list of meals based on the user's input: export class MealAutocompleteComponent { mealCtrl = new FormControl() filteredMeals: Observable<Array<Meal>> live ...

Can you provide the C# class that corresponds to this JSON data?

JSON Data: [ { "ProspectNo": "1000000073", "MakerId": "C136771", "MkrDate": "2015/11/26", "TranID": null, "ScoreData": { "Client Experience": "1", "Stability & Ownership": "7", ...

The attribute 'NameNews' is not recognized in the specified type when running ng build --prod

Definition export interface INewsModule{ IDNews:number; IDCategoery:number; NameNews:string; TopicNews:string; DateNews?:Date; ImageCaption:string; ImageName:string ; } Implementation import { Component, OnInit, Input, I ...

What is the best approach for MongoDB documents: keep fields with empty values or omit them entirely

For my current project, I am delving into MongoDB for the first time and I find myself pondering the best approach for handling blank or unset values in a document. When it comes to pairs that are expected to have values in the future, which method is more ...

Combining Postgres with JSON lists in a join operation

I am encountering difficulties when attempting to merge a JSON list in postgres 9.4 Below is the issue I am facing: Table Structure: CREATE TABLE players ( id serial NOT NULL, player json, CONSTRAINT players_pkey PRIMARY KEY (id) ) CREATE TABLE m ...

Retrieving the maximum values from JSON data using D3

Currently, I am working with D3 and JSON data by using a function that looks like this: d3.json("http://api.json", function(jsondata) { var data = jsondata.map(function(d) { return d.number; }); After executing this, the value of the data becomes ["2", ...

Exploring the power of makeStyles in Material UI when combined with TypeScript

I am currently in the process of converting a JavaScript template to Typescript. Here is an example of my accordionStyle.ts file: import { primaryColor, grayColor } from "../../material-dashboard-pro-react"; const accordionStyle = (theme?:an ...

The powerful combination of harp.gl and Angular NG

We've integrated harp.gl into our ng Angular application, but we're encountering issues when trying to connect to data sources that previously worked in our yarn demo. The datasource is created as follows: const dataSource = new OmvDataSour ...

Encountering an issue while developing a Discord bot using TypeScript

Hello, I'm currently working on creating a nick command for my discord bot in TypeScript, but I encountered an error. Here is the issue: Error: Expression expected.ts (1109) When I replace const mentionedMember = message? message.mentions.members? ...

React-query v5 - Updating or fetching outdated query

I am currently using the Tanstack/react-query v5.12.2 library and I am facing an issue with invalidating or refetching an inactive query using the useQueryClient() function. It seems that something has changed in version 5 of the library. I have tried sett ...

Could you provide insight into the reason behind debounce being used for this specific binding?

function debounce(fn, delay) { var timer return function () { var context = this var args = arguments clearTimeout(timer) timer = setTimeout(function () { fn.apply(context, args) }, delay) ...

Error in Visual Studio with Angular 2 build: 'Promise' name not found

I recently started exploring Angular2 and followed the instructions provided in this quickstart guide: https://angular.io/guide/quickstart Everything seems to be working well after running npm install, but now I want to work on it within Visual Studio usi ...

Encountering a compilation error while trying to utilize a union type in a function parameter within an

As stated on https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html, it is recommended to utilize multiple types for a parameter in a function (refer to the union part) /* OK */ interface Moment { utcOffset(): number; ...

Every time I attempt to add data to the database, I am encountering the issue of receiving 'undefined' values for every row

I'm struggling to save the JSON array returned by my output to a database in Node.js. Whenever I attempt to insert it into the database, all rows display 'undefined' values. What other options can I explore? I also need the output as a JSON ...

Creating a Blob or ArrayBuffer in Ionic 2 and Cordova: Step-by-Step Guide

Is there a way to generate a blob or an arrayBuffer with TypeScript when using the Camera.getPicture(options) method? I am currently working on an Ionic 2/Cordova project. var options = { quality: 90, destinationType: Camera.DestinationType.FILE_ ...

What is the best way to set up initial state in react-native-day-picker?

I have been experimenting with implementing react-native-calendar into my project. Here is the code snippet I am working on: import React from 'react'; import {Calendar} from 'react-native-day-picker'; const MyCalendar = () => { ...