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 / complete.vim
Last active April 4, 2024 07:21
My supertab, complex plugin completion is quite confusing
" Take <tab> for word complete only
" The 'complete' option controls where the keywords are searched (include files, tag files, buffers, and more).
" The 'completeopt' option controls how the completion occurs (for example, whether a menu is shown).
if exists('did_completes_me_loaded') || v:version < 700
finish
endif
let did_completes_me_loaded = 1
function! s:completes_me(shift_tab)
@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 / defineProperty.js
Created November 3, 2015 08:37
Object.defineProperty
// ES 15.2.3.6 Object.defineProperty ( O, P, Attributes )
// Partial support for most common case - getters, setters, and values
!(function() {
if (!Object.defineProperty ||
!(function () { try { Object.defineProperty({}, 'x', {}); return true; } catch (e) { return false; } } ())) {
var orig = Object.defineProperty;
Object.defineProperty = function (o, prop, desc) {
// In IE8 try built-in implementation for defining properties on DOM prototypes.
if (orig) { try { return orig(o, prop, desc); } catch (e) {} }
@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 / 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 / open.vim
Last active May 9, 2019 16:28
Open url in vim
" ============================================================================
" Description: Open url under cursor or git repository of a module
" Author: Qiming Zhao <chemzqm@gmail.com>
" Licence: Vim licence
" Version: 0.1
" Last Modified: January 16, 2016
" ============================================================================
if exists('did_open_loaded') || v:version < 700
finish
@chemzqm
chemzqm / simple_pairs.vim
Last active May 9, 2019 16:28
Fixed simple_pairs
" ============================================================================
" Description: Insert pair charactor automaticly
" Author: Qiming Zhao <chemzqm@gmail.com>
" Licence: Vim licence
" Version: 0.1
" Last Modified: Sep 13, 2016
" ============================================================================
if exists('did_simple_pairs_loaded') | finish | endif
let did_simple_pairs_loaded = 1
let s:pairs = {'(': ')', '[': ']', '{': '}', '"': '"', "'": "'", '`' : '`'}
@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 / 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',