├── .gitignore ├── LICENSE ├── README.md ├── autoload └── ncm2_github.vim ├── ncm2-plugin └── ncm2_github.vim └── pythonx └── ncm2_github.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.pyc 3 | __pycache__ 4 | /node_modules 5 | /doc/tags 6 | /.envrc 7 | /test.vim 8 | /nvim.log* 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2018 roxma@qq.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the "Software"), 5 | to deal in the Software without restriction, including without limitation 6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the 8 | Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included 11 | in all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 15 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 18 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 19 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![ncm2-github](https://user-images.githubusercontent.com/4538941/43352281-0bae43f0-9254-11e8-8933-fc343c1d64d8.gif) 2 | -------------------------------------------------------------------------------- /autoload/ncm2_github.vim: -------------------------------------------------------------------------------- 1 | if get(s:, 'loaded', 0) 2 | finish 3 | endif 4 | let s:loaded = 1 5 | 6 | let g:ncm2_github#token = '' 7 | let g:ncm2_github#proc = yarp#py3('ncm2_github') 8 | let g:ncm2_github#proc.on_load = 'ncm2_github#on_load' 9 | 10 | func! ncm2_github#init() 11 | call ncm2#register_source(g:ncm2_github#repo_source) 12 | call ncm2#register_source(g:ncm2_github#issue_source) 13 | call ncm2#register_source(g:ncm2_github#link_source) 14 | call ncm2#register_source(g:ncm2_github#user_source) 15 | call ncm2#register_source(g:ncm2_github#emoji_source) 16 | endfunc 17 | 18 | func! ncm2_github#on_load() 19 | let g:ncm2_github#repo_source.ready = 1 20 | let g:ncm2_github#issue_source.ready = 1 21 | let g:ncm2_github#link_source.ready = 1 22 | let g:ncm2_github#user_source.ready = 1 23 | endfunc 24 | 25 | func! ncm2_github#on_warmup(ctx) 26 | call g:ncm2_github#proc.jobstart() 27 | endfunc 28 | 29 | " github repo 30 | 31 | let g:ncm2_github#repo_source = extend( 32 | \ get(g:, 'ncm2_github#repo_source', {}), { 33 | \ 'name': 'github-repo', 34 | \ 'ready': 0, 35 | \ 'scope': ['gitcommit', 'markdown', 'magit'], 36 | \ 'priority': 8, 37 | \ 'mark': 'gh', 38 | \ 'on_complete': 'ncm2_github#on_complete_repo', 39 | \ 'on_warmup': 'ncm2_github#on_warmup', 40 | \ 'word_pattern': '[\w.-]+', 41 | \ 'complete_length': -1, 42 | \ 'complete_pattern': ['\b(\w+)\/'] 43 | \ }, 'keep') 44 | 45 | func! ncm2_github#on_complete_repo(ctx) 46 | call g:ncm2_github#proc.try_notify('on_complete_repo', 47 | \ a:ctx, 48 | \ g:ncm2_github#token) 49 | endfunc 50 | 51 | " github issue 52 | 53 | " # character doesn't work well with abbreviation match 54 | let g:ncm2_github#issue_source = extend( 55 | \ get(g:, 'ncm2_github#issue_source', {}), { 56 | \ 'name': 'github-issue', 57 | \ 'ready': 0, 58 | \ 'scope': ['gitcommit', 'markdown', 'magit'], 59 | \ 'priority': 8, 60 | \ 'mark': 'gh', 61 | \ 'matcher': {'name': 'combine', 62 | \ 'matchers': [ 63 | \ {'name': 'abbrfuzzy', 'key': 'menu'}, 64 | \ {'name': 'prefix', 'key': 'word'}, 65 | \ ]}, 66 | \ 'on_complete': 'ncm2_github#on_complete_issue', 67 | \ 'on_warmup': 'ncm2_github#on_warmup', 68 | \ 'complete_pattern': ['(?