Skip to content

Instantly share code, notes, and snippets.

View chemzqm's full-sized avatar
🇨🇳
Focusing

Qiming zhao chemzqm

🇨🇳
Focusing
View GitHub Profile
@chemzqm
chemzqm / execute.js
Created March 28, 2021 12:42
Execute current file with auto execute support
const {Uri, commands, workspace, window, Mutex} = require('coc.nvim')
const path = require('path')
const programMap = {
javascript: 'node',
typescript: 'ts-node',
python: 'python'
}
let global_id = 0
@chemzqm
chemzqm / pack.js
Last active December 10, 2022 19:18
pack and unpack wxvpkg
const path = require('path')
const fs = require('fs')
const { execSync } = require('child_process')
let file = path.join(process.cwd(), 'core.wxvpkg')
if (fs.existsSync(file)) {
execSync(`rmtrash ${file}`)
}
let fd = fs.openSync(file, 'w')
@chemzqm
chemzqm / repl.js
Last active May 29, 2021 00:05
repl with coc.nvim
// Save the file to ~/.vim/coc-extensions
// Usage: xmap <silent> <TAB> <Plug>(coc-repl-sendtext)
const {commands, workspace} = require('coc.nvim')
exports.activate = context => {
let {nvim} = workspace
let terminal
context.subscriptions.push(commands.registerCommand('repl.openTerminal', async () => {
let filetype = await nvim.eval('&filetype')
let prog = ''
@chemzqm
chemzqm / Address.js
Created May 26, 2019 18:55
coc.nvim address extension.
const {sources} = require('coc.nvim')
const {spawn} = require('child_process')
const readline = require('readline')
exports.activate = async context => {
context.subscriptions.push(
sources.createSource({
// unique id
name: 'address',
// unsed in menu
@chemzqm
chemzqm / system.vim
Created April 11, 2019 11:17
system.vim
" ============================================================================
" Description: Some system commands for vim
" Author: Qiming Zhao <chemzqm@gmail.com>
" Licence: Vim licence
" Version: 0.3
" Last Modified: Jul 07, 2018
" ============================================================================
if exists('did_system_loaded') || v:version < 700
finish
@chemzqm
chemzqm / e.fish
Last active March 14, 2018 07:13
Quickly find a directory and file in terminal with fzy
# brew install ag
# brew install fzy
# Usage: e [part of filename]
function e
set -l file (ag . --silent -l -g '' | fzy -q $argv)
if test -z $file
return
else
nvim $file
end
@chemzqm
chemzqm / git-status.js
Created April 1, 2017 03:10
Gti status by node
#!/usr/bin/env node
var exec = require('child_process').exec
var Branch = new Promise(function(resolve, reject) {
exec('git symbolic-ref -q HEAD | cut -c 12-', function (err, stdout) {
if (err) return reject(err)
if (stdout.length) return resolve(stdout.replace('\n', ''))
exec('git rev-parse --short HEAD', function (err, stdout) {
if (err) return reject(err)
@chemzqm
chemzqm / promise.js
Created February 24, 2017 15:43
miniapp promise
var PENDING = 'pending'
var SEALED = 'sealed'
var FULFILLED = 'fulfilled'
var REJECTED = 'rejected'
var NOOP = function(){}
function isArray(value) {
return Object.prototype.toString.call(value) === '[object Array]'
}
@chemzqm
chemzqm / polyfill.js
Created February 24, 2017 15:31
miniapp polyfill
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
if (!Object.keys) {
Object.keys = (function() {
'use strict';
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'),
dontEnums = [
'toString',
'toLocaleString',
'valueOf',
@chemzqm
chemzqm / gist:faa1f6bac2eddc3c15026c1109a8e69f
Last active December 7, 2016 16:06
neovim startup log with python remote plugin
# Command used: nvim --startuptime tmp.txt
# no autocmd and no g:python...
times in msec
clock self+sourced self: sourced script
clock elapsed: other lines
000.009 000.009: --- NVIM STARTING ---
000.592 000.583: locale set