1
0
mirror of https://github.com/amix/vimrc synced 2025-07-12 14:15:00 +08:00

Add support for Coc.nvim.

This commit is contained in:
Kurtis Moxley
2022-05-19 01:29:28 +08:00
parent 4ef73a3898
commit 9e29fd54b4
37 changed files with 16228 additions and 0 deletions

View File

@ -0,0 +1,73 @@
/*
* Used for prompt popup on vim
*/
const readline = require("readline")
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
escapeCodeTimeout: 0
})
rl.setPrompt('')
let value = process.argv[2]
if (value) {
rl.write(value)
}
rl.on('line', input => {
let text = input.replace(/"/g, '\\"')
console.log(createSequences(JSON.stringify(['call', 'CocPopupCallback', ['confirm', text]])))
process.exit()
})
function createSequences(str) {
return '\033]51;' + str + '\x07'
}
process.stdin.on('keypress', (_, key) => {
if (key) {
let k = getKey(key)
if (k == '<bs>') {
return
}
if (k == '<cr>') {
process.exit()
return
}
if (k == '<esc>') {
console.log(createSequences(JSON.stringify(['call', 'CocPopupCallback', ['exit', '']])))
process.exit()
return
}
if (k) {
console.log(createSequences(JSON.stringify(['call', 'CocPopupCallback', ['send', k]])))
}
}
})
function getKey(key) {
if (key.sequence == '\u001b') {
return '<esc>'
}
if (key.sequence == '\r') {
return '<cr>'
}
if (key.sequence == '\t') {
return key.shift ? '<s-tab>' : '<tab>'
}
// handle them can cause bug with terminal
// if (key.name == 'backspace') {
// return '<bs>'
// }
// if (key.name == 'left') {
// return '<left>'
// }
// if (key.name == 'right') {
// return '<right>'
// }
if (key.name == 'up') {
return '<up>'
}
if (key.name == 'down') {
return '<down>'
}
return ''
}

View File

@ -0,0 +1,12 @@
#!/bin/bash
terminateTree() {
for cpid in $(pgrep -P $1); do
terminateTree $cpid
done
kill -9 $1 > /dev/null 2>&1
}
for pid in $*; do
terminateTree $pid
done