├── denops └── @ddc-sources │ └── rg │ ├── deno.json │ └── main.ts ├── README.md ├── deno.jsonc ├── LICENSE └── doc └── ddc-source-rg.txt /denops/@ddc-sources/rg/deno.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@shougo/ddc-source-rg", 3 | "exports": { 4 | ".": "./main.ts" 5 | }, 6 | "publish": { 7 | "include": [ 8 | "**/*.ts" 9 | ] 10 | }, 11 | "imports": { 12 | "@shougo/ddc-vim": "jsr:@shougo/ddc-vim@~10.0.0", 13 | "@denops/std": "jsr:@denops/std@~8.0.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ddc-source-rg: rg completion for ddc.vim 2 | 3 | A ddc.vim source for `rg`. 4 | 5 | **Note: "rg" binary must be installed in your `$PATH`!!** 6 | 7 | ## Dependencies 8 | 9 | - https://github.com/BurntSushi/ripgrep 10 | 11 | ## Configuration 12 | 13 | ```vim 14 | call ddc#custom#patch_global('sources', ['rg']) 15 | 16 | call ddc#custom#patch_global('sourceOptions', #{ 17 | \ rg: #{ 18 | \ mark: 'rg', 19 | \ minAutoCompleteLength: 4, 20 | \ }, 21 | \ }) 22 | ``` 23 | 24 | ## License 25 | 26 | MIT 27 | -------------------------------------------------------------------------------- /deno.jsonc: -------------------------------------------------------------------------------- 1 | { 2 | "lock": false, 3 | "tasks": { 4 | "cache": "deno install --reload", 5 | "check": "deno check denops/**/*.ts", 6 | "fmt": "deno fmt denops", 7 | "lint": "deno lint denops", 8 | "lint-fix": "deno lint --fix denops", 9 | "test": "deno test -A --doc --parallel --shuffle denops/**/*.ts", 10 | "test:publish": "deno publish --dry-run --allow-dirty --set-version 0.0.0", 11 | "update": "deno outdated --recursive", 12 | "upgrade": "deno outdated --recursive --update" 13 | }, 14 | "workspace": [ 15 | "./denops/@ddc-sources/rg" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT license 2 | 3 | Copyright (c) Shougo Matsushita 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------------- /doc/ddc-source-rg.txt: -------------------------------------------------------------------------------- 1 | *ddc-source-rg.txt* rg completion for ddc.vim 2 | 3 | Author: Shougo 4 | License: MIT license 5 | 6 | CONTENTS *ddc-source-rg-contents* 7 | 8 | Introduction |ddc-source-rg-introduction| 9 | Install |ddc-source-rg-install| 10 | Examples |ddc-source-rg-examples| 11 | 12 | 13 | ============================================================================== 14 | INTRODUCTION *ddc-source-rg-introduction* 15 | 16 | A ddc.vim source for `rg` for completing words. 17 | 18 | Note: "rg" binary must be installed in your `$PATH`!! 19 | 20 | Note: It may be slow in huge project directory. 21 | 22 | 23 | ============================================================================== 24 | INSTALL *ddc-source-rg-install* 25 | 26 | Please install both "ddc.vim" and "denops.vim". 27 | 28 | https://github.com/Shougo/ddc.vim 29 | https://github.com/vim-denops/denops.vim 30 | 31 | And you must install "rg" binary. 32 | 33 | https://github.com/BurntSushi/ripgrep 34 | 35 | 36 | ============================================================================== 37 | EXAMPLES *ddc-source-rg-examples* 38 | > 39 | call ddc#custom#patch_global('sources', ['rg']) 40 | 41 | call ddc#custom#patch_global('sourceOptions', #{ 42 | \ rg: #{ 43 | \ mark: 'rg', 44 | \ minAutoCompleteLength: 4, 45 | \ }, 46 | \ }) 47 | < 48 | 49 | ============================================================================== 50 | vim:tw=78:ts=8:ft=help:norl:noet:fen:noet: 51 | -------------------------------------------------------------------------------- /denops/@ddc-sources/rg/main.ts: -------------------------------------------------------------------------------- 1 | import type { Item } from "@shougo/ddc-vim/types"; 2 | import { BaseSource } from "@shougo/ddc-vim/source"; 3 | 4 | import type { Denops } from "@denops/std"; 5 | import * as fn from "@denops/std/function"; 6 | 7 | type Params = { 8 | cmd: string; 9 | args: string[]; 10 | }; 11 | 12 | export class Source extends BaseSource { 13 | override async gather(args: { 14 | denops: Denops; 15 | completeStr: string; 16 | sourceParams: Params; 17 | }): Promise { 18 | const cwd = await fn.getcwd(args.denops) as string; 19 | const input = args.completeStr.replaceAll(/([\\\[\]^$.*])/g, "\\$1"); 20 | const cmd = [ 21 | args.sourceParams.cmd, 22 | ...args.sourceParams.args, 23 | input + "[a-zA-Z0-9_-]+", 24 | cwd, 25 | ]; 26 | 27 | const command = new Deno.Command( 28 | cmd[0], 29 | { 30 | args: cmd.slice(1), 31 | }, 32 | ); 33 | 34 | const { stdout } = await command.output(); 35 | 36 | const lines = new TextDecoder().decode(stdout).split(/\r?\n/); 37 | const items = [...new Set(lines)] 38 | .filter((line) => line.length != 0) 39 | .map((word: string) => ({ word })); 40 | 41 | return items; 42 | } 43 | 44 | override params(): Params { 45 | return { 46 | cmd: "rg", 47 | args: [ 48 | "--no-filename", 49 | "--no-heading", 50 | "--no-line-number", 51 | "--color", 52 | "never", 53 | "--only-matching", 54 | "--word-regexp", 55 | "--ignore-case", 56 | ], 57 | }; 58 | } 59 | } 60 | --------------------------------------------------------------------------------