Skip to content

Commit f1d40d0

Browse files
authored
Merge pull request #624 from Shougo/ui
[RFC] Replace UI
2 parents 67475c7 + 4573296 commit f1d40d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1519
-6003
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
sudo: false
2-
dist: trusty
1+
dist: xenial
32

43
language: python
54

65
python:
76
- 3.6
7+
- 3.7
88

99
install:
1010
- eval "$(curl -Ss https://raw.githubusercontent.com/neovim/bot-ci/master/scripts/travis-setup.sh) nightly-x64"

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ export THEMIS_HOME := ./vim-themis
55

66

77
install: vim-themis
8-
pip install pynvim --upgrade
9-
pip install pytest --upgrade
10-
pip install flake8 --upgrade
11-
pip install mypy --upgrade
12-
pip install vim-vint --upgrade
8+
pip install --upgrade -r test/requirements.txt
139

1410
lint:
1511
vint --version

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ denite.nvim
33

44
[![Build Status](https://travis-ci.org/Shougo/denite.nvim.svg?branch=master)](https://travis-ci.org/Shougo/denite.nvim)
55

6+
Note: Denite.nvim does not define any of default mappings. You need to define
7+
them.
8+
69

710
## About
811

@@ -88,9 +91,28 @@ You must install "pynvim" module with pip
8891
**Note:** You need to do 1. and 2. with the common-arch files (x86 or x64).
8992

9093

94+
## Examples
95+
96+
```vim
97+
" Define mappings
98+
autocmd FileType denite call s:denite_my_settings()
99+
function! s:denite_my_settings() abort
100+
nnoremap <silent><buffer><expr> <CR>
101+
\ denite#do_map('do_action')
102+
nnoremap <silent><buffer><expr> d
103+
\ denite#do_map('do_action', 'delete')
104+
nnoremap <silent><buffer><expr> p
105+
\ denite#do_map('do_action', 'preview')
106+
nnoremap <silent><buffer><expr> q
107+
\ denite#do_map('quit')
108+
nnoremap <silent><buffer><expr> i
109+
\ denite#do_map('open_filter_buffer')
110+
nnoremap <silent><buffer><expr> <Space>
111+
\ denite#do_map('toggle_select').'j'
112+
endfunction
113+
```
114+
115+
91116
## Screenshots
92117

93-
![file/rec source](https://user-images.githubusercontent.com/13142418/34324674-b8ddd5b8-e840-11e7-9b77-d94e1b084bda.gif)
94-
![SpaceVim Guide](https://user-images.githubusercontent.com/13142418/34324752-e5a89900-e842-11e7-9f87-6d8789ba3871.gif)
95-
![colorscheme source](https://user-images.githubusercontent.com/13142418/34324786-f4dd39a2-e843-11e7-97ef-7a48ee04d27b.gif)
96-
![floating window](https://user-images.githubusercontent.com/1239245/54329573-8b047380-4655-11e9-8b9a-ab4a91f4768f.gif)
118+
![denite new UI](https://user-images.githubusercontent.com/1239245/58742567-a155ea80-8460-11e9-9925-09082def2c80.gif)

autoload/denite.vim

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,6 @@ function! denite#get_status(name) abort
2222
return !exists('b:denite_statusline') ? '' :
2323
\ get(b:denite_statusline, a:name, '')
2424
endfunction
25-
function! denite#get_status_mode() abort
26-
return denite#get_status('mode')
27-
endfunction
28-
function! denite#get_status_sources() abort
29-
return denite#get_status('sources')
30-
endfunction
31-
function! denite#get_status_path() abort
32-
return denite#get_status('path')
33-
endfunction
34-
function! denite#get_status_linenr() abort
35-
return denite#get_status('linenr')
36-
endfunction
3725

3826
function! s:start(sources, user_context) abort
3927
if denite#initialize()
@@ -46,10 +34,52 @@ function! s:start(sources, user_context) abort
4634
call setpos('.', pos)
4735

4836
let args = [a:sources, a:user_context]
49-
return denite#util#rpcrequest('_denite_start', args)
37+
return denite#util#rpcrequest('_denite_start', args, v:false)
5038
endfunction
5139

5240
function! denite#do_action(context, action_name, targets) abort
5341
let args = [a:context, a:action_name, a:targets]
54-
return denite#util#rpcrequest('_denite_do_action', args)
42+
return denite#util#rpcrequest('_denite_do_action', args, v:false)
43+
endfunction
44+
45+
function! denite#do_map(name, ...) abort
46+
let args = denite#util#convert2list(get(a:000, 0, []))
47+
let esc = (mode() ==# 'i' ? "\<C-o>" : '')
48+
return printf(esc . ":\<C-u>call denite#_call_map(%s, %s, %s)\<CR>",
49+
\ string(a:name), 'v:false', string(args))
50+
endfunction
51+
function! denite#_call_map(name, is_async, args) abort
52+
let is_filter = &l:filetype ==# 'denite-filter'
53+
54+
if is_filter
55+
call denite#filter#_move_to_parent(a:is_async)
56+
endif
57+
58+
if &l:filetype !=# 'denite'
59+
return
60+
endif
61+
62+
let args = denite#util#convert2list(a:args)
63+
64+
call denite#util#rpcrequest(
65+
\ (a:is_async ? '_denite_do_async_map' : '_denite_do_map'),
66+
\ [bufnr('%'), a:name, args], a:is_async)
67+
68+
if is_filter
69+
let denite_statusline = get(b:, 'denite_statusline', {})
70+
71+
call win_gotoid(g:denite#_filter_winid)
72+
73+
if &l:filetype ==# 'denite-filter'
74+
let b:denite_statusline = denite_statusline
75+
else
76+
stopinsert
77+
endif
78+
endif
79+
endfunction
80+
function! denite#call_map(name, ...) abort
81+
call denite#_call_map(a:name, v:false, get(a:000, 0, []))
82+
endfunction
83+
function! denite#call_async_map(name, ...) abort
84+
call denite#_call_map(a:name, v:true, get(a:000, 0, []))
5585
endfunction

autoload/denite/_main.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# ============================================================================
2+
# FILE: _main.py
3+
# AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
4+
# License: MIT license
5+
# ============================================================================
6+
7+
import sys
8+
import io
9+
10+
from importlib.util import find_spec
11+
if find_spec('pynvim'):
12+
from pynvim import attach
13+
else:
14+
from neovim import attach
15+
16+
17+
def attach_vim(serveraddr):
18+
if len(serveraddr.split(':')) == 2:
19+
serveraddr, port = serveraddr.split(':')
20+
port = int(port)
21+
vim = attach('tcp', address=serveraddr, port=port)
22+
else:
23+
vim = attach('socket', path=serveraddr)
24+
25+
# sync path
26+
for path in vim.call(
27+
'globpath', vim.options['runtimepath'],
28+
'rplugin/python3', 1).split('\n'):
29+
sys.path.append(path)
30+
# Remove current path
31+
del sys.path[0]
32+
33+
return vim
34+
35+
36+
class RedirectStream(io.IOBase):
37+
def __init__(self, handler):
38+
self.handler = handler
39+
40+
def write(self, line):
41+
self.handler(line)
42+
43+
def writelines(self, lines):
44+
self.handler('\n'.join(lines))
45+
46+
47+
def main(serveraddr):
48+
vim = attach_vim(serveraddr)
49+
from denite.child import Child
50+
from denite.util import error_tb
51+
stdout = sys.stdout
52+
sys.stdout = RedirectStream(lambda data: vim.out_write(data))
53+
sys.stderr = RedirectStream(lambda data: vim.err_write(data))
54+
try:
55+
child = Child(vim)
56+
child.main_loop(stdout)
57+
except Exception as exc:
58+
error_tb(vim, 'Error in child: %r' % exc)
59+
60+
61+
if __name__ == '__main__':
62+
main(sys.argv[1])

autoload/denite/custom.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,14 @@ endfunction
118118
function! denite#custom#_call_action(kind, name, context) abort
119119
let custom = denite#custom#_get().action
120120

121+
let new_context = {}
121122
for key in denite#util#split(a:kind)
122123
if has_key(custom, key) && has_key(custom[key], a:name)
123-
call call(custom[key][a:name][0], [a:context])
124+
let new_context = call(custom[key][a:name][0], [a:context])
124125
endif
125126
endfor
127+
128+
return new_context
126129
endfunction
127130

128131
function! s:set_custom(dest, name_or_dict, value) abort

0 commit comments

Comments
 (0)