-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6dd6760
Showing
8 changed files
with
225 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: [lukas-reineke] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Pull request check | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: JohnnyMorganz/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
args: --check . | ||
|
||
block-fixup: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Block Fixup Commit Merge | ||
uses: 13rac1/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT Licence | ||
|
||
Copyright (c) 2021 Lukas Reineke | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# cmp-rg | ||
|
||
[ripgrep](https://github.com/BurntSushi/ripgrep) source for [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) | ||
|
||
## Dependencies | ||
|
||
You need to have `rg` and `sort` installed. | ||
|
||
## Install | ||
|
||
Use your favourite plugin manager to install. | ||
|
||
#### Example with Packer | ||
|
||
[wbthomason/packer.nvim](https://github.com/wbthomason/packer.nvim) | ||
|
||
```lua | ||
-- init.lua | ||
require("packer").startup( | ||
function() | ||
use "lukas-reineke/cmp-rg" | ||
end | ||
) | ||
``` | ||
|
||
#### Example with Plug | ||
|
||
[junegunn/vim-plug](https://github.com/junegunn/vim-plug) | ||
|
||
```vim | ||
" init.vim | ||
call plug#begin('~/.vim/plugged') | ||
Plug 'lukas-reineke/cmp-rg' | ||
call plug#end() | ||
``` | ||
|
||
## Setup | ||
|
||
Add `rg` to your cmp sources | ||
|
||
```lua | ||
require'cmp'.setup { | ||
sources = { | ||
{ name = 'rg' } | ||
} | ||
} | ||
``` | ||
|
||
For more options see `:help cmp-rg` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local ok, cmp = pcall(require, "cmp") | ||
|
||
if ok then | ||
cmp.register_source("rg", require("cmp-rg").new()) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
*cmp-rg.txt* ripgrep source for nvim-cmp | ||
|
||
|
||
Author: Lukas Reineke <[email protected]> | ||
Version: 1.0.0 | ||
|
||
============================================================================== | ||
CONTENTS *cmp-rg* | ||
|
||
1. Options |cmp-rg-options| | ||
2. Highlights |cmp-rg-highlights| | ||
3. Setup |cmp-rg-setup| | ||
4. Variables |cmp-rg-variables| | ||
5. Commands |cmp-rg-commands| | ||
6. Changelog |cmp-rg-changelog| | ||
7. License |cmp-rg-license| | ||
|
||
============================================================================== | ||
1. OPTIONS *cmp-rg-options* | ||
|
||
------------------------------------------------------------------------------ | ||
pattern *cmp-rg-pattern* | ||
|
||
The pattern to search for matches with ripgrep. | ||
|
||
Default: "[a-zA-Z_-]+" ~ | ||
|
||
------------------------------------------------------------------------------ | ||
additional_arguments *cmp-rg-additional_arguments* | ||
|
||
Any additional arguments you want to pass to ripgrep. | ||
|
||
Default: "" ~ | ||
|
||
------------------------------------------------------------------------------ | ||
cwd *cmp-rg-cwd* | ||
|
||
Directory from where ripgrep will search. | ||
|
||
Default: Current working directory ~ | ||
|
||
============================================================================== | ||
6. CHANGELOG *cmp-rg-changelog* | ||
|
||
1.0.0 | ||
* First release | ||
|
||
============================================================================== | ||
7. LICENSE *cmp-rg-license* | ||
|
||
The MIT Licence | ||
http://www.opensource.org/licenses/mit-license.php | ||
|
||
Copyright (c) 2021 Lukas Reineke | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
|
||
============================================================================== | ||
vim:tw=78:ts=8:ft=help:norl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
local source = {} | ||
|
||
source.new = function() | ||
return setmetatable({}, { __index = source }) | ||
end | ||
|
||
source.complete = function(self, request, callback) | ||
local q = string.sub(request.context.cursor_before_line, request.offset) | ||
local pattern = request.option.pattern or "[a-zA-Z_-]+" | ||
local additional_arguments = request.option.additional_arguments or "" | ||
local items = {} | ||
|
||
local function on_event(job_id, data, event) | ||
if event == "stdout" then | ||
for _, label in ipairs(data) do | ||
table.insert(items, { label = label }) | ||
end | ||
callback { items = items, isIncomplete = true } | ||
end | ||
|
||
if event == "stderr" then | ||
vim.cmd "echohl Error" | ||
vim.cmd('echomsg "' .. table.concat(data, "") .. '"') | ||
vim.cmd "echohl None" | ||
end | ||
|
||
if event == "exit" then | ||
callback { items = items, isIncomplete = false } | ||
end | ||
end | ||
|
||
vim.fn.jobstart( | ||
string.format( | ||
"rg --no-filename --no-heading --no-line-number --color never --only-matching %s %s%s . | sort -u", | ||
additional_arguments, | ||
q, | ||
pattern | ||
), | ||
{ | ||
on_stderr = on_event, | ||
on_stdout = on_event, | ||
on_exit = on_event, | ||
cwd = request.option.cwd or vim.fn.getcwd(), | ||
} | ||
) | ||
end | ||
|
||
return source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
line_endings = "Unix" | ||
indent_type = "Spaces" | ||
indent_width = 4 | ||
no_call_parentheses = true |