The source of the

I’ve been switching notes a lot lately. It can be roughly divided into three categories:

  1. Macos cheat
  2. Impression of notes
  3. Bear, UIysses
  4. vscode

Each has its own advantages and disadvantages. Eventually I want to use vscode + git as a diary. Vscode provides an impeccable writing experience and interface for markdown, and the flaws are obvious: it can’t be synchronized like any other diary. Therefore, in the daily code word experience, it is often edited by the company’s computer. Forget push, go back to open it with your own computer, and nothing is written.

To address these pain points, we have the auto-diary plugin.

The plugin currently supports direct search for installation in the vscode plugin marketplace

This plug-in mainly solves the synchronization problem mentioned above. It mainly does the following things:

  1. Check whether the.auto-diary. Json configuration file exists in the workspace root path
  2. If you have a configuration file, the remote repository is updated when you first enter the workspace
  3. When a document is written, if a file is saved, it is automatically committed and pushed to a remote repository

There are still some limitations to plugins, but I can think of the following:

  1. For programmers who know Git
  2. Simultaneous editing is not supported (involving conflict issues), but there is nothing wrong with multiple machines
  3. Should not be, to be found (submit feedback address: issues)

Record the plug-in writing process

Environment preparation and development debugging mode

Tools required for global installation

yarn global add yo generator-code vsce
Copy the code

Once installed, use Yo to generate the template project

yo code
Copy the code

Select as prompted (deduct the recommended options from the official website for your reference) :

#? What type of extension do you want to create? New Extension (TypeScript)
#? What's the name of your extension? HelloWorld
### Press <Enter> to choose default for all options below ###

#? What's the identifier of your extension? helloworld
#? What's the description of your extension? LEAVE BLANK
#? Enable stricter TypeScript checking in 'tsconfig.json'? Yes
#? Setup linting using 'tslint'? Yes
#? Initialize a git repository? Yes
#? Which package manager to use? npm
Copy the code

One difference is that I chose to use YARN as the package manager, which is a matter of personal preference.

Now that the template is basically set up, go to your working directory:

cd ./helloworld
Copy the code

Dependencies are already downloaded when the template project is created.

Open the entry file extension.ts, which contains many detailed comments. Note here:

  1. If vscode is red, it may be that vscode.d.ts is not downloading correctly, delete node_modules and try downloading dependencies again
  2. Nodejs ecosystem toolkit, testing is available straight out of the box, like the better-known shell.js
  3. The official API address can be taken a good look, vscode this package exposed all available interfaces.

The next step is to write your own code.

There is one caveat to the debugging section. In the default template project, the plug-in is activated by typing the Hello World command in the command palette. Therefore, you need to enter a command after each Reload window to activate the plugin during debugging. Here you can change the activation mode of the plug-in. Below is a list of supported activation methods:

I used the circled part to indicate that the working directory will activate the plug-in if it contains a specific file, which is exactly the same as the configuration file in the directory.

All right, here we go. Start by opening the vscode debug panel. Select the first one and hit Start. (by default, you are familiar with vscode debugging function ~~)

Then a debug editor interface pops up and you can debug. If the code is updated, just reload the debug editor.

Release the plugin

To start, you need to sign up for an account on Microsoft’s own Azure Devops site. Since I’ve been doing this for a long time, I’m going to write the steps clearly:

  1. Click the link above to find the button for registering or logging in (Microsoft account can be used directly)
  2. After logging in, you will be prompted to add an organization
  3. When you see the admin panel, click Security in your profile
  4. Create a Personal Access Token (be sure to give the appropriate permissions, there will be a striking screenshot in the tutorial)
  5. The token created by copying is saved and will probably be used again, but you won’t see it next time.

After obtaining the token, the local operation continues.

Create a publisher (use the token above)

vsce create-publisher <publisher-name>
Copy the code

Package the plug-in (print a package that can be installed locally and publish it without relying on this step)

vsce package
Copy the code

Release the plugin

vsce publish
Copy the code

When you see a sign of success, say you’re done, and then go to the official plugin market.

Things that might need fixing later, documentation, plugin logos, etc.

reference

  • Plug-in address

  • Official: Write the first plug-in

  • Official: Plugin release

Original address: Vkiller. Club/P /31