1# vim:fileencoding=utf-8:noet
2from __future__ import (unicode_literals, division, absolute_import, print_function)
3
4try:
5	import vim
6except ImportError:
7	vim = object()
8
9from powerline.bindings.vim import bufvar_exists
10from powerline.segments.vim import window_cached
11
12
13@window_cached
14def nerdtree(pl):
15	'''Return directory that is shown by the current buffer.
16
17	Highlight groups used: ``nerdtree:path`` or ``file_name``.
18	'''
19	if not bufvar_exists(None, 'NERDTreeRoot'):
20		return None
21	path_str = vim.eval('getbufvar("%", "NERDTreeRoot").path.str()')
22	return [{
23		'contents': path_str,
24		'highlight_groups': ['nerdtree:path', 'file_name'],
25	}]
26