summaryrefslogtreecommitdiff
path: root/.config/coc/extensions/node_modules/coc-pairs
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2024-12-05 13:34:46 -0500
committerJacob McDonnell <jacob@jacobmcdonnell.com>2024-12-05 13:34:46 -0500
commit5849e2ad7323f086bd6edf221b29e3f0b2b7cbd3 (patch)
treebb437c98f3661b5a3ac9d721dadd2c7b6e629692 /.config/coc/extensions/node_modules/coc-pairs
parent6e5c51a6ee731e17e81cc5e23867dbd4ddc006e0 (diff)
Removed Useless Configs
Diffstat (limited to '.config/coc/extensions/node_modules/coc-pairs')
-rw-r--r--.config/coc/extensions/node_modules/coc-pairs/Readme.md46
-rw-r--r--.config/coc/extensions/node_modules/coc-pairs/lib/index.js215
-rw-r--r--.config/coc/extensions/node_modules/coc-pairs/package.json79
3 files changed, 0 insertions, 340 deletions
diff --git a/.config/coc/extensions/node_modules/coc-pairs/Readme.md b/.config/coc/extensions/node_modules/coc-pairs/Readme.md
deleted file mode 100644
index 461e20e..0000000
--- a/.config/coc/extensions/node_modules/coc-pairs/Readme.md
+++ /dev/null
@@ -1,46 +0,0 @@
-# coc-pairs
-
-Auto pair extension for [coc.nvim](https://github.com/neoclide/coc.nvim).
-
-**Note** you can use other vim auto pairs plugins with coc.nvim, it's a
-simplified implementation to make auto pairs work like in VSCode.
-
-**Note** `b:coc_paires` have renamed to `b:coc_pairs`
-
-For enhanced `<CR>` experience, checkout `:h coc#on_enter()`.
-
-## Tips
-
-- You should disable/remove other auto pair plugins for this extension work as expected.
-- When you type a paired character which is just the next character, it would just move to the right by one column.
-- When the previous content ends with two inserting characters, the characters would just be inserted without inserting the paired character. This makes inserting triple quotes easier.
-- `'` only pairs when the character before is not a word character.
-- for `<` to insert paired `>`, the previous character should not be an empty space.
-
-## Install
-
-In vim/neovim, run this command:
-
-```
-:CocInstall coc-pairs
-```
-
-## Features
-
-- Insert pair characters automatically.
-- Buffer local pairs, ex: `autocmd FileType tex let b:coc_pairs = [["$", "$"]]`
-
-## Options
-
-- `pairs.disableLanguages`, list of language ids to disable this extension, default: `[]`.
-- `pairs.enableCharacters`, list of enabled characters, default: `` ["(", "[", "{", "<", "'", "\"", "`"] ``.
-- `pairs.enableBackspace`, enable imap for backspace to remove paired characters,
- default: `true`, won't work when `<bs>` is already mapped.
-
-To disable characters for a specified filetypes, you can use `b:coc_pairs_disabled`, ex:
-
- autocmd FileType markdown let b:coc_pairs_disabled = ['`']
-
-## License
-
-MIT
diff --git a/.config/coc/extensions/node_modules/coc-pairs/lib/index.js b/.config/coc/extensions/node_modules/coc-pairs/lib/index.js
deleted file mode 100644
index b2d78ff..0000000
--- a/.config/coc/extensions/node_modules/coc-pairs/lib/index.js
+++ /dev/null
@@ -1,215 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.isWord = exports.wait = exports.byteSlice = exports.activate = void 0;
-const coc_nvim_1 = require("coc.nvim");
-const pairs = new Map();
-pairs.set('{', '}');
-pairs.set('[', ']');
-pairs.set('(', ')');
-pairs.set('<', '>');
-pairs.set('"', '"');
-pairs.set("'", "'");
-pairs.set('`', '`');
-async function activate(context) {
- let { subscriptions } = context;
- const config = coc_nvim_1.workspace.getConfiguration('pairs');
- const disableLanguages = config.get('disableLanguages');
- const characters = config.get('enableCharacters');
- const alwaysPairCharacters = config.get('alwaysPairCharacters', []);
- let enableBackspace = config.get('enableBackspace');
- if (enableBackspace) {
- let map = (await coc_nvim_1.workspace.nvim.call('maparg', ['<bs>', 'i']));
- if (map && !map.startsWith('coc#_insert_key'))
- enableBackspace = false;
- }
- if (characters.length == 0)
- return;
- const { nvim, isVim } = coc_nvim_1.workspace;
- const localParis = new Map();
- // remove paired characters when possible
- async function onBackspace() {
- let { nvim } = coc_nvim_1.workspace;
- let res = await nvim.eval('[getline("."),col("."),synIDattr(synID(line("."), col(".") - 2, 1), "name"),bufnr("%")]');
- if (res) {
- let [line, col, synname, bufnr] = res;
- if (col > 1 && !/string/i.test(synname)) {
- let buf = Buffer.from(line, 'utf8');
- if (col - 1 < buf.length) {
- let pre = buf.slice(col - 2, col - 1).toString('utf8');
- let next = buf.slice(col - 1, col).toString('utf8');
- let local = localParis.get(bufnr);
- if (local && local.find(arr => arr[0] == pre && arr[1] == next)) {
- await nvim.eval(`feedkeys("\\<C-G>U\\<right>\\<bs>\\<bs>", 'in')`);
- if (isVim)
- nvim.command('redraw', true);
- return;
- }
- if (characters.includes(pre) && pairs.get(pre) == next) {
- await nvim.eval(`feedkeys("\\<C-G>U\\<right>\\<bs>\\<bs>", 'in')`);
- if (isVim)
- nvim.command('redraw', true);
- return;
- }
- }
- }
- }
- await nvim.eval(`feedkeys("\\<bs>", 'in')`);
- if (isVim)
- nvim.command('redraw', true);
- return '';
- }
- async function insertPair(character, pair) {
- let samePair = character == pair;
- let arr = await nvim.eval(`[bufnr("%"),get(b:,"coc_pairs_disabled",[]),coc#util#cursor(),&filetype,getline("."),mode(),get(get(g:,'context_filetype#filetypes',{}),&filetype,v:null)]`);
- let filetype = arr[3];
- if (disableLanguages.indexOf(filetype) !== -1)
- return character;
- let line = arr[4];
- let mode = arr[5];
- if (mode.startsWith('R'))
- return character;
- let chars = arr[1];
- let context = arr[6];
- if (chars && chars.length && chars.indexOf(character) !== -1)
- return character;
- let pos = { line: arr[2][0], character: arr[2][1] };
- let pre = line.slice(0, pos.character);
- let rest = line.slice(pos.character);
- let previous = pre.length ? pre[pre.length - 1] : '';
- if (alwaysPairCharacters.indexOf(character) == -1 && rest && isWord(rest[0]))
- return character;
- if (character == '<' && (previous == ' ' || previous == '<')) {
- return character;
- }
- if (samePair && rest[0] == character && rest[1] != character) {
- // move position
- await nvim.eval(`feedkeys("\\<C-G>U\\<Right>", 'in')`);
- return '';
- }
- if (samePair && pre && (isWord(previous) || previous == character))
- return character;
- // Only pair single quotes if previous character is not word.
- if (character === "'" && pre.match(/.*\w$/)) {
- return character;
- }
- if (context) {
- try {
- let res = await nvim.call('context_filetype#get');
- if (res && res.filetype) {
- filetype = res.filetype;
- }
- }
- catch (e) {
- // ignore error
- }
- }
- // Rust: don't pair single quotes that are part of lifetime annotations such as `Foo::<'a, 'b>` or `bar: &'a str`
- if (filetype === 'rust' && character === "'" &&
- (pre.endsWith('<') || rest.startsWith('>') || pre.endsWith('&'))) {
- return character;
- }
- if ((filetype === 'vim' || filetype === 'help') && character === '"' && pos.character === 0) {
- return character;
- }
- if (samePair && pre.length >= 2 && previous == character && pre[pre.length - 2] == character) {
- if (pre[pre.length - 3] == character) {
- if (character == '"') {
- nvim.command(`call feedkeys('"""'."${'\\<C-G>U\\<Left>'.repeat(3)}", 'in')`, true);
- }
- else {
- nvim.command(`call feedkeys("${character.repeat(3)}${'\\<C-G>U\\<Left>'.repeat(3)}", 'in')`, true);
- }
- return;
- }
- return character;
- }
- if (character == '"') {
- nvim.command(`call feedkeys('""'."\\<C-G>U\\<Left>", 'in')`, true);
- }
- else {
- nvim.command(`call feedkeys("${character}${pair}${'\\<C-G>U\\<Left>'.repeat(pair.length)}", 'in')`, true);
- }
- return '';
- }
- async function closePair(character) {
- let [cursor, filetype, line] = await nvim.eval('[coc#util#cursor(),&filetype,getline(".")]');
- if (disableLanguages.indexOf(filetype) !== -1)
- return character;
- let rest = line.slice(cursor[1]);
- if (rest[0] == character) {
- nvim.command(`call feedkeys("\\<C-G>U\\<Right>", 'in')`, true);
- return '';
- }
- return character;
- }
- nvim.pauseNotification();
- for (let character of characters) {
- if (pairs.has(character)) {
- subscriptions.push(coc_nvim_1.workspace.registerExprKeymap('i', character, insertPair.bind(null, character, pairs.get(character)), false));
- }
- let matched = pairs.get(character);
- if (matched != character) {
- subscriptions.push(coc_nvim_1.workspace.registerExprKeymap('i', matched, closePair.bind(null, matched), false));
- }
- }
- if (enableBackspace) {
- subscriptions.push(coc_nvim_1.workspace.registerExprKeymap('i', '<bs>', onBackspace, false));
- }
- // tslint:disable-next-line: no-floating-promises
- nvim.resumeNotification(false, true);
- async function createBufferKeymap(doc) {
- if (!doc)
- return;
- let pairs = doc.getVar('pairs', null);
- if (!pairs || !pairs.length)
- return;
- localParis.set(doc.bufnr, pairs);
- nvim.pauseNotification();
- for (let p of pairs) {
- if (Array.isArray(p) && p.length == 2) {
- let [character, matched] = p;
- subscriptions.push(coc_nvim_1.workspace.registerExprKeymap('i', character, insertPair.bind(null, character, matched), true));
- if (matched != character) {
- subscriptions.push(coc_nvim_1.workspace.registerExprKeymap('i', matched, closePair.bind(null, matched), true));
- }
- }
- }
- // tslint:disable-next-line: no-floating-promises
- nvim.resumeNotification(false, true);
- }
- const buf = await coc_nvim_1.workspace.nvim.buffer;
- await createBufferKeymap(coc_nvim_1.workspace.getDocument(buf.id));
- coc_nvim_1.workspace.onDidOpenTextDocument(async (e) => {
- await createBufferKeymap(coc_nvim_1.workspace.getDocument(e.uri));
- });
-}
-exports.activate = activate;
-function byteSlice(content, start, end) {
- let buf = Buffer.from(content, 'utf8');
- return buf.slice(start, end).toString('utf8');
-}
-exports.byteSlice = byteSlice;
-function wait(ms) {
- return new Promise(resolve => {
- setTimeout(() => {
- resolve(undefined);
- }, ms);
- });
-}
-exports.wait = wait;
-function isWord(character) {
- let code = character.charCodeAt(0);
- if (code > 128)
- return false;
- if (code == 95)
- return true;
- if (code >= 48 && code <= 57)
- return true;
- if (code >= 65 && code <= 90)
- return true;
- if (code >= 97 && code <= 122)
- return true;
- return false;
-}
-exports.isWord = isWord;
-//# sourceMappingURL=index.js.map \ No newline at end of file
diff --git a/.config/coc/extensions/node_modules/coc-pairs/package.json b/.config/coc/extensions/node_modules/coc-pairs/package.json
deleted file mode 100644
index 5ca4f21..0000000
--- a/.config/coc/extensions/node_modules/coc-pairs/package.json
+++ /dev/null
@@ -1,79 +0,0 @@
-{
- "name": "coc-pairs",
- "version": "1.3.2",
- "description": "Auto pair extension for coc.nvim",
- "main": "lib/index.js",
- "publisher": "chemzqm",
- "repository": {
- "type": "git",
- "url": "https://github.com/neoclide/coc-pairs.git"
- },
- "keywords": [
- "coc.nvim",
- "autopair"
- ],
- "engines": {
- "coc": "^0.0.80"
- },
- "scripts": {
- "clean": "rimraf lib",
- "build": "tsc -p tsconfig.json",
- "prepare": "tsc -p tsconfig.json"
- },
- "activationEvents": [
- "*"
- ],
- "contributes": {
- "configuration": {
- "type": "object",
- "properties": {
- "pairs.disableLanguages": {
- "type": "array",
- "items": {
- "type": "string"
- },
- "default": [],
- "description": "A list of languages IDs to disable this extension on"
- },
- "pairs.enableCharacters": {
- "type": "array",
- "items": {
- "type": "string"
- },
- "default": [
- "(",
- "[",
- "{",
- "<",
- "'",
- "\"",
- "`"
- ],
- "description": "Enabled character list for keymap."
- },
- "pairs.alwaysPairCharacters": {
- "type": "array",
- "items": {
- "type": "string"
- },
- "default": [],
- "description": "Characters that should be paired without check for next character."
- },
- "pairs.enableBackspace": {
- "type": "boolean",
- "description": "Remap your backspce to delete paired characters when necessary, won't work when <bs> already mapped.",
- "default": true
- }
- }
- }
- },
- "author": "chemzqm@gmail.com",
- "license": "MIT",
- "devDependencies": {
- "@chemzqm/tsconfig": "^0.0.3",
- "@types/node": "^12.12.0",
- "coc.nvim": "^0.0.81-next.8",
- "typescript": "^4.1.3"
- },
- "dependencies": {}
-}