mirror of
1
0
Fork 0
This commit is contained in:
vsooda 2015-09-08 07:47:27 +00:00
commit 96e0a361e9
45 changed files with 4890 additions and 0 deletions

35
my_configs.vim Normal file
View File

@ -0,0 +1,35 @@
nnoremap <F9> :exe 'NERDTreeToggle'<CR>
"set pastetoggle=<F2>
set mouse=
"for outside paste mistake
nnoremap <F2> :set invpaste paste?<CR>
imap <F2> <C-O>:set invpaste paste?<CR>
set pastetoggle=<F2>
"let Tlist_Use_Split_Window = 1
"sudo apt-get install ncurses-term
"export TERM=xterm-256color(.bashrc)
"let g:rehash256 = 1
:set nu
"colorscheme monokai
colorscheme molokai
let g:molokai_original = 1
"let NERDTreeWinPos='left'
"vertical indent, use <leader>ig to activatee
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size=1
let g:indent_guides_auto_colors = 0
hi IndentGuidesOdd guibg=darkgrey ctermbg=darkgrey
hi IndentGuidesEven guibg=darkgrey ctermbg=darkgrey
inoremap {} {<esc>o}<esc>O
map <leader>1 :tabnext 1<CR>
map <leader>2 :tabnext 2<CR>
map <leader>3 :tabnext 3<CR>
map <leader>4 :tabnext 4<CR>
map <leader>5 :tabnext 5<CR>
map <leader>6 :tabnext 6<CR>
map <leader>7 :tabnext 7<CR>
map <leader>8 :tabnext 8<CR>
"let g:clang_library_path = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/'

View File

@ -0,0 +1,6 @@
*~
*.sw?
*.py[cod]
.ropeproject
doc/tags
.cache

View File

@ -0,0 +1,3 @@
[submodule "jedi"]
path = jedi
url = https://github.com/davidhalter/jedi.git

View File

@ -0,0 +1,6 @@
language: python
install:
- pip install --quiet --use-mirrors pytest
script:
- vim --version
- py.test

View File

@ -0,0 +1,52 @@
Main Authors
============
David Halter (@davidhalter) <davidhalter88@gmail.com>
Contributors (in order of contributions)
========================================
Patrice Peterson (@runiq)
tek (@tek)
heavenshell (@heavenshell) <heavenshell.jp@gmail.com>
Danilo Bargen (@dbrgn) <gezuru@gmail.com>
mattn (@mattn) <mattn.jp@gmail.com>
Enrico Batista da Luz (@ricobl) <rico.bl@gmail.com>
coot (@coot) <mszamot@gmail.com>
Artur Dryomov (@ming13) <artur.dryomov@gmail.com>
andviro (@andviro)
Jean-Louis Fuchs (@ganwell) <ganwell@fangorn.ch>
Mathieu Comandon (@strycore) <strider@strycore.com>
Nick Hurley (@todesschaf) <hurley@todesschaf.org>
gpoulin (@gpoulin)
Akinori Hattori (@hattya)
Luper Rouch (@flupke)
Matthew Moses (@mlmoses) <moses.matthewl@gmail.com>
Tyler Wymer (@twymer)
Artem Nezvigin (@artnez)
rogererens (@rogererens)
Emily Strickland (@emilyst) <mail@emily.st>
Tin Tvrtković (@Tinche) <tinchester@gmail.com>
Zekeriya Koc (@zekzekus) <zekzekus@gmail.com>
ethinx (@ethinx) <eth2net@gmail.com>
Wouter Overmeire (@lodagro) <lodagro@gmail.com>
Stephen J. Fuhry (@fuhrysteve) <fuhrysteve@gmail.com>
Sheng Yun (@ShengYun) <uewing@gmail.com>
Yann Thomas-Gérard (@inside) <inside@gmail.com>
Colin Su (@littleq0903) <littleq0903@gmail.com>
Arthur Jaron (@eyetracker)
Justin M. Keyes (@justinmk)
nagev (@np1)
Chris Lasher (@gotgenes) <chris.lasher@gmail.com>
Doan Thanh Nam (@tndoan)
Markus Koller (@toupeira)
Justin Cheevers @justincheevers
Talha Ahmed (@talha81) <talha.ahmed@gmail.com>
Matthew Tylee Atkinson (@matatk)
Pedro Ferrari (@petobens)
Daniel Hahler (@blueyed)
Dave Honneffer (@pearofducks)
@something are github user names.

View File

@ -0,0 +1,9 @@
We <3 pull requests!
1. Fork the Repo on github.
2. Add yourself to AUTHORS.txt
3. Add a test if possible.
4. Push to your fork and submit a pull request.
Please use PEP8 as a Python code style. For VIM, just stick try to style your
code similar to the jedi-vim code that's there.

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) <2013> <David Halter and others, see AUTHORS.txt>
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.

View File

@ -0,0 +1,227 @@
#################################################
jedi-vim - awesome Python autocompletion with VIM
#################################################
.. image:: https://travis-ci.org/davidhalter/jedi-vim.png?branch=master
:target: https://travis-ci.org/davidhalter/jedi-vim
:alt: Travis-CI build status
jedi-vim is a VIM binding to the autocompletion library
`Jedi <http://github.com/davidhalter/jedi>`_.
Here are some pictures:
.. image:: https://github.com/davidhalter/jedi/raw/master/docs/_screenshots/screenshot_complete.png
Completion for almost anything (Ctrl+Space).
.. image:: https://github.com/davidhalter/jedi/raw/master/docs/_screenshots/screenshot_function.png
Display of function/class bodies, docstrings.
.. image:: https://github.com/davidhalter/jedi/raw/master/docs/_screenshots/screenshot_pydoc.png
Documentation (Pydoc) support (with highlighting, Shift+k).
There is also support for goto and renaming.
Get the latest from `github <http://github.com/davidhalter/jedi-vim>`_.
Documentation
=============
Documentation is available in your vim: ``:help jedi-vim``. You can also look
it up `on github <http://github.com/davidhalter/jedi-vim/blob/master/doc/jedi-vim.txt>`_.
You can read the Jedi library documentation `here <http://jedi.jedidjah.ch>`_.
If you want to report issues, just use the github issue tracker. In case of
questions about the software, please use `stackoverflow
<https://stackoverflow.com>`_ and tag your question with ``jedi-vim``.
Contributing
============
We love Pull Requests! Read the instructions in ``CONTRIBUTING.md``.
Features
========
The Jedi library understands most of Python's core features. From decorators to
generators, there is broad support.
Apart from that, jedi-vim supports the following commands
- Completion ``<C-Space>``
- Goto assignments ``<leader>g`` (typical goto function)
- Goto definitions ``<leader>d`` (follow identifier as far as possible,
includes imports and statements)
- Show Documentation/Pydoc ``K`` (shows a popup with assignments)
- Renaming ``<leader>r``
- Usages ``<leader>n`` (shows all the usages of a name)
- Open module, e.g. ``:Pyimport os`` (opens the ``os`` module)
Installation
============
You might want to use `pathogen <https://github.com/tpope/vim-pathogen>`_ or
`vundle <https://github.com/gmarik/vundle>`_ to install jedi in VIM. Also you
need a VIM version that was compiled with ``+python``, which is typical for most
distributions on Linux. The Python version compiled into VIM must be 2.6 or later
(you can check this from within VIM using ``:python import sys; print sys.version`` )
The first thing you need after that is an up-to-date version of Jedi. You can
either get it via ``pip install jedi`` or with ``git submodule update --init``
in your jedi-vim repository.
Example Installation Command using Pathogen:
.. code-block:: sh
cd ~/.vim/bundle/ && git clone --recursive https://github.com/davidhalter/jedi-vim.git
On Arch Linux, you can also install jedi-vim from official repositories as `vim-jedi
<https://www.archlinux.org/packages/community/any/vim-jedi/>`__. It is also available
on `Debian (≥8) <https://packages.debian.org/vim-python-jedi>`__ and `Ubuntu (≥14.04)
<http://packages.ubuntu.com/vim-python-jedi>`__ as vim-python-jedi. On Fedora Linux,
it is available as `vim-jedi <https://apps.fedoraproject.org/packages/vim-jedi>`__.
Note that the `python-mode <https://github.com/klen/python-mode>`_ VIM plugin seems
to conflict with jedi-vim, therefore you should disable it before enabling
jedi-vim.
To enjoy the full features of jedi-vim, you should have VIM >= 7.3, compiled with
``+conceal`` (which is not the case on some platforms, including OS X). If your VIM
does not meet these requirements, the parameter recommendation list may not appear
when you type an open bracket after a function name. Please read
`the documentation <http://github.com/davidhalter/jedi-vim/blob/master/doc/jedi-vim.txt>`_
for details.
Settings
========
Jedi is by default automatically initialized. If you don't want that I suggest
you disable the auto-initialization in your ``.vimrc``:
.. code-block:: vim
let g:jedi#auto_initialization = 0
There are also some VIM options (like ``completeopt`` and key defaults) which
are automatically initialized, but you can skip this:
.. code-block:: vim
let g:jedi#auto_vim_configuration = 0
You can make jedi-vim use tabs when going to a definition etc:
.. code-block:: vim
let g:jedi#use_tabs_not_buffers = 1
If you are a person who likes to use VIM-splits, you might want to put this in your ``.vimrc``:
.. code-block:: vim
let g:jedi#use_splits_not_buffers = "left"
This options could be "left", "right", "top", "bottom" or "winwidth". It will decide the direction where the split open.
Jedi automatically starts the completion, if you type a dot, e.g. ``str.``, if
you don't want this:
.. code-block:: vim
let g:jedi#popup_on_dot = 0
Jedi selects the first line of the completion menu: for a better typing-flow
and usually saves one keypress.
.. code-block:: vim
let g:jedi#popup_select_first = 0
Jedi displays function call signatures in insert mode in real-time, highlighting
the current argument. The call signatures can be displayed as a pop-up in the
buffer (set to 1, the default), which has the advantage of being easier to refer
to, or in Vim's command line aligned with the function call (set to 2), which
can improve the integrity of Vim's undo history.
.. code-block:: vim
let g:jedi#show_call_signatures = "1"
Here are a few more defaults for actions, read the docs (``:help jedi-vim``) to
get more information. If you set them to ``""``, they are not assigned.
.. code-block:: vim
NOTE: subject to change!
let g:jedi#goto_command = "<leader>d"
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = ""
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#rename_command = "<leader>r"
Finally, if you don't want completion, but all the other features, use:
.. code-block:: vim
let g:jedi#completions_enabled = 0
FAQ
===
I don't want the docstring window to popup during completion
------------------------------------------------------------
This depends on the ``completeopt`` option. Jedi initializes it in its
``ftplugin``. Add the following line to your ``.vimrc`` to disable it:
.. code-block:: vim
autocmd FileType python setlocal completeopt-=preview
I want <Tab> to do autocompletion
---------------------------------
Don't even think about changing the Jedi command to ``<Tab>``,
use `supertab <https://github.com/ervandew/supertab>`_!
The completion is waaay too slow!
---------------------------------
Completion of complex libraries (like Numpy) should only be slow the first time
you complete it. After that, the results should be cached and very fast.
If it's still slow, in case you've installed the python-mode VIM plugin, disable
it. It seems to conflict with jedi-vim. See issue `#163
<https://github.com/davidhalter/jedi-vim/issues/163>`__.
Testing
=======
jedi-vim is being tested with a combination of `vspec
<https://github.com/kana/vim-vspec>`_ and `py.test <http://pytest.org/>`_.
The tests are in the ``test`` subdirectory, you can run them calling::
py.test
The tests are automatically run with `travis
<https://travis-ci.org/davidhalter/jedi-vim>`_.

View File

@ -0,0 +1,23 @@
if !jedi#init_python()
finish
endif
if g:jedi#auto_initialization
if g:jedi#completions_enabled
" We need our own omnifunc, so this overrides the omnifunc set by
" $VIMRUNTIME/ftplugin/python.vim.
setlocal omnifunc=jedi#completions
" map ctrl+space for autocompletion
if g:jedi#completions_command == "<C-Space>"
" In terminals, <C-Space> sometimes equals <Nul>.
imap <buffer> <Nul> <C-Space>
smap <buffer> <Nul> <C-Space>
endif
if g:jedi#completions_command != ""
execute "inoremap <expr> <buffer> ".g:jedi#completions_command." jedi#complete_string(0)"
" A separate mapping for select mode: deletes and completes.
execute "snoremap <expr> <buffer> ".g:jedi#completions_command." '\<C-g>c'.jedi#complete_string(0)"
endif
endif
endif

View File

@ -0,0 +1,32 @@
if !jedi#init_python()
finish
endif
if g:jedi#show_call_signatures > 0 && has('conceal')
" +conceal is the default for vim >= 7.3
let s:e = g:jedi#call_signature_escape
let s:full = s:e.'jedi=.\{-}'.s:e.'.\{-}'.s:e.'jedi'.s:e
let s:ignore = s:e.'jedi.\{-}'.s:e
exe 'syn match jediIgnore "'.s:ignore.'" contained conceal'
setlocal conceallevel=2
syn match jediFatSymbol "\*_\*" contained conceal
syn match jediFat "\*_\*.\{-}\*_\*" contained contains=jediFatSymbol
syn match jediSpace "\v[ ]+( )@=" contained
exe 'syn match jediFunction "'.s:full.'" keepend extend '
\ .' contains=jediIgnore,jediFat,jediSpace'
\ .' containedin=pythonComment,pythonString,pythonRawString'
unlet! s:e s:full s:ignore
hi def link jediIgnore Ignore
hi def link jediFatSymbol Ignore
hi def link jediSpace Normal
if exists('g:colors_name')
hi def link jediFunction CursorLine
hi def link jediFat TabLine
else
hi jediFunction term=NONE cterm=NONE ctermfg=6 guifg=Black gui=NONE ctermbg=0 guibg=Grey
hi jediFat term=bold,underline cterm=bold,underline gui=bold,underline ctermbg=0 guibg=#555555
endif
endif

View File

@ -0,0 +1,428 @@
scriptencoding utf-8
" ------------------------------------------------------------------------
" Settings initialization
" ------------------------------------------------------------------------
let s:deprecations = {
\ 'get_definition_command': 'goto_definitions_command',
\ 'pydoc': 'documentation_command',
\ 'related_names_command': 'usages_command',
\ 'autocompletion_command': 'completions_command',
\ 'show_function_definition': 'show_call_signatures',
\ }
let s:default_settings = {
\ 'use_tabs_not_buffers': 0,
\ 'use_splits_not_buffers': 1,
\ 'auto_initialization': 1,
\ 'auto_vim_configuration': 1,
\ 'goto_command': "'<leader>d'",
\ 'goto_assignments_command': "'<leader>g'",
\ 'goto_definitions_command': "''",
\ 'completions_command': "'<C-Space>'",
\ 'call_signatures_command': "'<leader>n'",
\ 'usages_command': "'<leader>n'",
\ 'rename_command': "'<leader>r'",
\ 'popup_on_dot': 1,
\ 'documentation_command': "'K'",
\ 'show_call_signatures': 1,
\ 'call_signature_escape': "'=`='",
\ 'auto_close_doc': 1,
\ 'max_doc_height': 30,
\ 'popup_select_first': 1,
\ 'quickfix_window_height': 10,
\ 'completions_enabled': 1,
\ 'force_py_version': "'auto'"
\ }
for [key, val] in items(s:deprecations)
if exists('g:jedi#'.key)
echom "'g:jedi#".key."' is deprecated. Please use 'g:jedi#".val."' instead. Sorry for the inconvenience."
exe 'let g:jedi#'.val.' = g:jedi#'.key
endif
endfor
for [key, val] in items(s:default_settings)
if !exists('g:jedi#'.key)
exe 'let g:jedi#'.key.' = '.val
endif
endfor
" ------------------------------------------------------------------------
" Python initialization
" ------------------------------------------------------------------------
let s:script_path = fnameescape(expand('<sfile>:p:h:h'))
function! s:init_python()
if g:jedi#force_py_version != 'auto'
" Always use the user supplied version.
try
return jedi#force_py_version(g:jedi#force_py_version)
catch
throw "Could not setup g:jedi#force_py_version: ".v:exception
endtry
endif
" Handle "auto" version.
if has('nvim') || (has('python') && has('python3'))
" Neovim usually has both python providers. Skipping the `has` check
" avoids starting both of them.
" Get default python version from interpreter in $PATH.
let s:def_py = system('python -c '.shellescape('import sys; sys.stdout.write(str(sys.version_info[0]))'))
if v:shell_error != 0 || !len(s:def_py)
if !exists("g:jedi#squelch_py_warning")
echohl WarningMsg
echom "Warning: jedi-vim failed to get Python version from sys.version_info: " . s:def_py
echom "Falling back to version 2."
echohl None
endif
let s:def_py = 2
elseif &verbose
echom "jedi-vim: auto-detected Python: ".s:def_py
endif
" Make sure that the auto-detected version is available in Vim.
if !has('nvim') || has('python'.(s:def_py == 2 ? '' : s:def_py))
return jedi#force_py_version(s:def_py)
endif
endif
if has('python')
call jedi#setup_py_version(2)
elseif has('python3')
call jedi#setup_py_version(3)
else
throw "jedi-vim requires Vim with support for Python 2 or 3."
endif
return 1
endfunction
function! jedi#init_python()
if !exists('s:_init_python')
try
let s:_init_python = s:init_python()
catch
if !exists("g:jedi#squelch_py_warning")
echohl WarningMsg
echom "Error: jedi-vim failed to initialize Python: ".v:exception." (in ".v:throwpoint.")"
echohl None
endif
let s:_init_python = 0
endtry
endif
return s:_init_python
endfunction
function! jedi#setup_py_version(py_version)
if a:py_version == 2
let cmd_init = 'pyfile'
let cmd_exec = 'python'
elseif a:py_version == 3
let cmd_init = 'py3file'
let cmd_exec = 'python3'
else
throw "jedi#setup_py_version: invalid py_version: ".a:py_version
endif
try
execute cmd_init.' '.s:script_path.'/initialize.py'
execute 'command! -nargs=1 PythonJedi '.cmd_exec.' <args>'
return 1
catch
throw "jedi#setup_py_version: ".v:exception
endtry
endfunction
function! jedi#force_py_version(py_version)
let g:jedi#force_py_version = a:py_version
return jedi#setup_py_version(a:py_version)
endfunction
function! jedi#force_py_version_switch()
if g:jedi#force_py_version == 2
call jedi#force_py_version(3)
elseif g:jedi#force_py_version == 3
call jedi#force_py_version(2)
else
throw "Don't know how to switch from ".g:jedi#force_py_version."!"
endif
endfunction
" Helper function instead of `python vim.eval()`, and `.command()` because
" these also return error definitions.
function! jedi#_vim_exceptions(str, is_eval)
let l:result = {}
try
if a:is_eval
let l:result.result = eval(a:str)
else
execute a:str
let l:result.result = ''
endif
catch
let l:result.exception = v:exception
let l:result.throwpoint = v:throwpoint
endtry
return l:result
endfunction
if !jedi#init_python()
" Do not define any functions when Python initialization failed.
finish
endif
" ------------------------------------------------------------------------
" functions that call python code
" ------------------------------------------------------------------------
function! jedi#goto()
PythonJedi jedi_vim.goto(mode="goto")
endfunction
function! jedi#goto_assignments()
PythonJedi jedi_vim.goto(mode="assignment")
endfunction
function! jedi#goto_definitions()
PythonJedi jedi_vim.goto(mode="definition")
endfunction
function! jedi#usages()
PythonJedi jedi_vim.goto(mode="related_name")
endfunction
function! jedi#rename(...)
PythonJedi jedi_vim.rename()
endfunction
function! jedi#rename_visual(...)
PythonJedi jedi_vim.rename_visual()
endfunction
function! jedi#completions(findstart, base)
PythonJedi jedi_vim.completions()
endfunction
function! jedi#enable_speed_debugging()
PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False)
endfunction
function! jedi#enable_debugging()
PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout)
endfunction
function! jedi#disable_debugging()
PythonJedi jedi_vim.jedi.set_debug_function(None)
endfunction
function! jedi#py_import(args)
PythonJedi jedi_vim.py_import()
endfun
function! jedi#py_import_completions(argl, cmdl, pos)
PythonJedi jedi_vim.py_import_completions()
endfun
" ------------------------------------------------------------------------
" show_documentation
" ------------------------------------------------------------------------
function! jedi#show_documentation()
PythonJedi if jedi_vim.show_documentation() is None: vim.command('return')
let bn = bufnr("__doc__")
if bn > 0
let wi=index(tabpagebuflist(tabpagenr()), bn)
if wi >= 0
" If the __doc__ buffer is open in the current tab, jump to it
silent execute (wi+1).'wincmd w'
else
silent execute "sbuffer ".bn
endif
else
split '__doc__'
endif
setlocal modifiable
setlocal noswapfile
setlocal buftype=nofile
silent normal! ggdG
silent $put=l:doc
silent normal! 1Gdd
setlocal nomodifiable
setlocal nomodified
setlocal filetype=rst
if l:doc_lines > g:jedi#max_doc_height " max lines for plugin
let l:doc_lines = g:jedi#max_doc_height
endif
execute "resize ".l:doc_lines
" quit comands
nnoremap <buffer> q ZQ
execute "nnoremap <buffer> ".g:jedi#documentation_command." ZQ"
" highlight python code within rst
unlet! b:current_syntax
syn include @rstPythonScript syntax/python.vim
" 4 spaces
syn region rstPythonRegion start=/^\v {4}/ end=/\v^( {4}|\n)@!/ contains=@rstPythonScript
" >>> python code -> (doctests)
syn region rstPythonRegion matchgroup=pythonDoctest start=/^>>>\s*/ end=/\n/ contains=@rstPythonScript
let b:current_syntax = "rst"
endfunction
" ------------------------------------------------------------------------
" helper functions
" ------------------------------------------------------------------------
function! jedi#add_goto_window(len)
set lazyredraw
cclose
let height = min([a:len, g:jedi#quickfix_window_height])
execute 'belowright copen '.height
set nolazyredraw
if g:jedi#use_tabs_not_buffers == 1
noremap <buffer> <CR> :call jedi#goto_window_on_enter()<CR>
endif
au WinLeave <buffer> q " automatically leave, if an option is chosen
redraw!
endfunction
function! jedi#goto_window_on_enter()
let l:list = getqflist()
let l:data = l:list[line('.') - 1]
if l:data.bufnr
" close goto_window buffer
normal ZQ
PythonJedi jedi_vim.new_buffer(vim.eval('bufname(l:data.bufnr)'))
call cursor(l:data.lnum, l:data.col)
else
echohl WarningMsg | echo "Builtin module cannot be opened." | echohl None
endif
endfunction
function! s:syn_stack()
if !exists("*synstack")
return []
endif
return map(synstack(line('.'), col('.') - 1), 'synIDattr(v:val, "name")')
endfunc
function! jedi#do_popup_on_dot_in_highlight()
let highlight_groups = s:syn_stack()
for a in highlight_groups
if a == 'pythonDoctest'
return 1
endif
endfor
for a in highlight_groups
for b in ['pythonString', 'pythonComment', 'pythonNumber']
if a == b
return 0
endif
endfor
endfor
return 1
endfunc
function! jedi#configure_call_signatures()
if g:jedi#show_call_signatures == 2 " Command line call signatures
autocmd InsertEnter <buffer> let g:jedi#first_col = s:save_first_col()
endif
autocmd InsertLeave <buffer> PythonJedi jedi_vim.clear_call_signatures()
autocmd CursorMovedI <buffer> PythonJedi jedi_vim.show_call_signatures()
endfunction
" Determine where the current window is on the screen for displaying call
" signatures in the correct column.
function! s:save_first_col()
if bufname('%') ==# '[Command Line]' || winnr('$') == 1
return 0
endif
let startwin = winnr()
let winwidth = winwidth(0)
if winwidth == &columns
return 0
elseif winnr('$') == 2
return startwin == 1 ? 0 : (winwidth(1) + 1)
elseif winnr('$') == 3
if startwin == 1
return 0
endif
let ww1 = winwidth(1)
let ww2 = winwidth(2)
let ww3 = winwidth(3)
if ww1 + ww2 + ww3 + 2 == &columns
if startwin == 2
return ww1 + 1
else
return ww1 + ww2 + 2
endif
elseif startwin == 2
if ww2 + ww3 + 1 == &columns
return 0
else
return ww1 + 1
endif
else " startwin == 3
if ww2 + ww3 + 1 == &columns
return ww2 + 1
else
return ww1 + 1
endif
endif
endif
return 0
endfunction
function! jedi#complete_string(is_popup_on_dot)
if a:is_popup_on_dot && !(g:jedi#popup_on_dot && jedi#do_popup_on_dot_in_highlight())
return ''
endif
if pumvisible() && !a:is_popup_on_dot
return "\<C-n>"
else
return "\<C-x>\<C-o>\<C-r>=jedi#complete_opened(".a:is_popup_on_dot.")\<CR>"
endif
endfunction
function! jedi#complete_opened(is_popup_on_dot)
if pumvisible()
" Only go down if it is visible, user-enabled and the longest
" option is set.
if g:jedi#popup_select_first && stridx(&completeopt, 'longest') > -1
return "\<Down>"
endif
if a:is_popup_on_dot
" Prevent completion of the first entry with dot completion.
return "\<C-p>"
endif
endif
return ""
endfunction
"PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False)
"PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout)
" vim: set et ts=4:

View File

@ -0,0 +1,60 @@
import os
import subprocess
import urllib
import zipfile
import pytest
VSPEC_URL = 'https://github.com/kana/vim-vspec/archive/1.4.1.zip'
CACHE_FOLDER = '.cache'
VSPEC_FOLDER = os.path.join(CACHE_FOLDER, 'vim-vspec-1.4.1')
VSPEC_RUNNER = os.path.join(VSPEC_FOLDER, 'bin/vspec')
TEST_DIR = 'test'
class IntegrationTestFile(object):
def __init__(self, path):
self.path = path
def run(self):
output = subprocess.check_output(
[VSPEC_RUNNER, '.', VSPEC_FOLDER, self.path])
for line in output.splitlines():
if line.startswith(b'not ok') or line.startswith(b'Error'):
pytest.fail("{} failed:\n{}".format(
self.path, output.decode('utf-8')), pytrace=False)
def __repr__(self):
return "<%s: %s>" % (type(self), self.path)
def pytest_configure(config):
if not os.path.isdir(CACHE_FOLDER):
os.mkdir(CACHE_FOLDER)
if not os.path.exists(VSPEC_FOLDER):
name, hdrs = urllib.urlretrieve(VSPEC_URL)
z = zipfile.ZipFile(name)
for n in z.namelist():
dest = os.path.join(CACHE_FOLDER, n)
destdir = os.path.dirname(dest)
if not os.path.isdir(destdir):
os.makedirs(destdir)
data = z.read(n)
if not os.path.isdir(dest):
with open(dest, 'w') as f:
f.write(data)
z.close()
os.chmod(VSPEC_RUNNER, 0o777)
def pytest_generate_tests(metafunc):
"""
:type metafunc: _pytest.python.Metafunc
"""
def collect_tests():
for f in os.listdir(TEST_DIR):
if f.endswith('.vim'):
yield IntegrationTestFile(os.path.join(TEST_DIR, f))
metafunc.parametrize('case', list(collect_tests()))

View File

@ -0,0 +1,508 @@
*jedi-vim.txt* - For Vim version 7.3 - Last change: 2014/07/29
__ _______ _______ __ ____ ____ __ .___ ___.~
| | | ____|| \ | | \ \ / / | | | \/ |~
| | | |__ | .--. || | _____\ \/ / | | | \ / |~
.--. | | | __| | | | || | |______\ / | | | |\/| |~
| `--' | | |____ | '--' || | \ / | | | | | |~
\______/ |_______||_______/ |__| \__/ |__| |__| |__|~
jedi-vim - awesome Python autocompletion with Vim
==============================================================================
Contents *jedi-vim-contents*
1. Introduction |jedi-vim-introduction|
2. Installation |jedi-vim-installation|
2.0. Requirements |jedi-vim-installation-requirements|
2.1. Manually |jedi-vim-installation-manually|
2.2. Using Pathogen |jedi-vim-installation-pathogen|
2.3. Using Vundle |jedi-vim-installation-vundle|
2.4. Installing from Repositories |jedi-vim-installation-repos|
3. Supported Python features |jedi-vim-support|
4. Usage |jedi-vim-usage|
5. Mappings |jedi-vim-keybindings|
5.1. Start completion |g:jedi#completions_command|
5.2. Go to definition |g:jedi#goto_command|
5.3. Go to assignment |g:jedi#goto_assignments_command|
5.4 Go to definition (deprecated) |g:jedi#goto_definitions_command|
5.5. Show documentation |g:jedi#documentation_command|
5.6. Rename variables |g:jedi#rename_command|
5.7. Show name usages |g:jedi#usages_command|
5.8. Open module by name |:Pyimport|
6. Configuration |jedi-vim-configuration|
6.1. auto_initialization |g:jedi#auto_initialization|
6.2. auto_vim_configuration |g:jedi#auto_vim_configuration|
6.3. popup_on_dot |g:jedi#popup_on_dot|
6.4. popup_select_first |g:jedi#popup_select_first|
6.5. auto_close_doc |g:jedi#auto_close_doc|
6.6. show_call_signatures |g:jedi#show_call_signatures|
6.7. use_tabs_not_buffers |g:jedi#use_tabs_not_buffers|
6.8. squelch_py_warning |g:jedi#squelch_py_warning|
6.9. completions_enabled |g:jedi#completions_enabled|
6.10. use_splits_not_buffers |g:jedi#use_splits_not_buffers|
6.11. force_py_version |g:jedi#force_py_version|
7. Testing |jedi-vim-testing|
8. Contributing |jedi-vim-contributing|
9. License |jedi-vim-license|
==============================================================================
1. Introduction *jedi-vim-introduction*
Jedi-vim is a Vim binding to the awesome Python autocompletion library
`jedi`. Among jedi's (and, therefore, jedi-vim's) features are:
- Completion for a wide array of Python features (see |jedi-vim-support|)
- Robust in dealing with syntax errors and wrong indentation
- Parses complex module/function/class structures
- Infers function arguments from Sphinx/Epydoc strings
- Doesn't execute Python code
- Supports Virtualenv
- Supports Python 2.5+ and 3.2+
By leveraging this library, jedi-vim adds the following capabilities to Vim:
- Displaying function/class bodies
- "Go to definition" command
- Displaying docstrings
- Renaming and refactoring
- Looking up related names
==============================================================================
2. Installation *jedi-vim-installation*
------------------------------------------------------------------------------
2.0. Requirements *jedi-vim-installation-requirements*
First of all, jedi-vim requires Vim to be compiled with the `+python` option.
The jedi library has to be installed for jedi-vim to work properly. You can
install it first, by using e.g. your distribution's package manager, or by
using pip: >
pip install jedi
However, you can also install it as a git submodule if you don't want to use
jedi for anything but this plugin. How to do this is detailed below.
It is best if you have VIM >= 7.3, compiled with the `+conceal` option. With
older versions, you will probably not see the parameter recommendation list
for functions after typing the open bracket. Some platforms (including OS X
releases) do not ship a VIM with `+conceal`. You can check if your VIM has the
feature with >
:ver
and look for "`+conceal`" (as opposed to "`-conceal`") or >
:echo has('conceal')
which will report 0 (not included) or 1 (included). If your VIM lacks this
feature and you would like function parameter completion, you will need to
build your own VIM, or use a package for your operating system that has this
feature (such as MacVim on OS X, which also contains a console binary).
------------------------------------------------------------------------------
2.1. Installing manually *jedi-vim-installation-manually*
1a. Get the latest repository from Github: >
git clone http://github.com/davidhalter/jedi-vim path/to/bundles/jedi-vim
1b. If you want to install jedi as a submodule instead, issue this command: >
git clone --recursive http://github.com/davidhalter/jedi-vim
2. Put the plugin files into their respective folders in your vim runtime
directory (usually ~/.vim). Be sure to pay attention to the directory
structure!
3. Update the Vim help tags with >
:helptags <path/to/vimruntime>/doc
------------------------------------------------------------------------------
2.1. Installing using Pathogen *jedi-vim-installation-pathogen*
Pathogen simplifies installation considerably.
1.a Clone the git repository into your bundles directory: >
git clone http://github.com/davidhalter/jedi-vim path/to/bundles/jedi-vim
1b. Again, if you want to install jedi as a submodule, use this command
instead: >
git clone --recursive http://github.com/davidhalter/jedi-vim
------------------------------------------------------------------------------
2.3. Installing using Vundle *jedi-vim-installation-vundle*
1. Vundle automatically downloads subrepositories as git submodules, so you
will automatically get the jedi library with the jedi-vim plugin. Add the
following to the Bundles section in your .vimrc file: >
Plugin 'davidhalter/jedi-vim'
2. Issue the following command in Vim: >
:PluginInstall
Help tags are generated automatically, so you should be good to go.
------------------------------------------------------------------------------
2.4. Installing from Repositories *jedi-vim-installation-repos*
Some Linux distributions have jedi-vim packages in their official
repositories. On Arch Linux, install vim-jedi. On Debian (8+) or Ubuntu
(14.04+) install vim-python-jedi.
==============================================================================
3. Supported Python features *jedi-vim-support*
The Jedi library does all the hard work behind the scenes. It supports
completion of a large number of Python features, among them:
- Builtins
- Multiple `return`s or `yield`s
- Tuple assignments/array indexing/dictionary indexing
- `with`-statement/exception handling
- `*args` and `**kwargs`
- Decorators, lambdas, closures
- Generators, iterators
- Some descriptors: `property`/`staticmethod`/`classmethod`
- Some magic methods: `__call__`, `__iter__`, `__next__`, `__get__`,
`__getitem__`, `__init__`
- `list.append()`, `set.add()`, `list.extend()`, etc.
- (Nested) list comprehensions and ternary expressions
- Relative `import`s
- `getattr()`/`__getattr__`/`__getattribute__`
- Function annotations (py3k feature, are being ignored at the moment, but are
parsed)
- Class decorators (py3k feature, are being ignored at the moment, but are
parsed)
- Simple/usual `sys.path` modifications
- `isinstance` checks for `if`/`while`/`assert` case, that doesnt work with
Jedi
- And more...
Note: This list is not necessarily up to date. For a complete list of
features, please refer to the Jedi documentation at http://jedi.jedidjah.ch.
==============================================================================
4. Usage *jedi-vim-usage*
With the default settings, autocompletion can be triggered by typing
<Ctrl-Space>. The first entry will automatically be selected, so you can press
<Return> to insert it into your code or keep typing and narrow down your
completion options. The usual <C-X><C-O> and <C-P>/<C-N> keybindings work as
well. Autocompletion is also triggered by typing a period in insert mode.
Since periods rarely occur in Python code outside of method/import lookups,
this is handy to have (but can be disabled).
When it encounters a new module, jedi might take a few seconds to parse that
module's contents. Afterwards, the contents are cached and completion will be
almost instantaneous.
==============================================================================
5. Key Bindings *jedi-vim-keybindings*
All keybindings can be mapped by setting the appropriate global option. For
example, to set the keybinding for starting omnicompletion to <C-N> instead of
<Ctrl-Space>, add the following setting to your .vimrc file: >
let g:jedi#completions_command = "<C-N>"
Note: If you have |g:jedi#auto_initialization| set to 0, you have to create
a mapping yourself by calling a function: >
" Using <C-N> for omnicompletion
inoremap <silent> <buffer> <C-N> <c-x><c-o>
" Use <localleader>r (by default <\-r>) for renaming
nnoremap <silent> <buffer> <localleader>r :call jedi#rename()<cr>
" etc.
Note: You can set commands to '', which means that they are empty and not
assigned. It's an easy way to "disable" functionality of jedi-vim.
------------------------------------------------------------------------------
5.1. `g:jedi#completions_command` *g:jedi#completions_command*
Function: n/a; see above
Default: <Ctrl-Space> Start completion
Performs autocompletion (or omnicompletion, to be precise).
Note: If you want to use <Tab> for completion, please install Supertab:
https://github.com/ervandew/supertab.
------------------------------------------------------------------------------
5.2. `g:jedi#goto_command` *g:jedi#goto_command*
Function: `jedi#goto()`
Default: <leader>d Go to definition (or assignment)
This function first tries |jedi#goto_definitions|, and falls back to
|jedi#goto_assignments| for builtin modules. It produces an error if nothing
could be found.
NOTE: this implementation is subject to change.
Ref: https://github.com/davidhalter/jedi/issues/570
This command tries to find the original definition of the function/class under
the cursor. Just like the `jedi#goto_assignments()` function, it does not work
if the definition isn't in a Python source file.
The difference between `jedi#goto_assignments()` and `jedi#goto_definitions()`
is that the latter performs recursive lookups. Take, for example, the
following module structure: >
# file1.py:
from file2 import foo
# file2.py:
from file3 import bar as foo
# file3.py
def bar():
pass
The `jedi#goto_assignments()` function will take you to the >
from file2 import foo
statement in file1.py, while the `jedi#goto_definitions()` function will take
you all the way to the >
def bar():
line in file3.py.
------------------------------------------------------------------------------
5.3. `g:jedi#goto_assignments_command` *g:jedi#goto_assignments_command*
Function: `jedi#goto_assignments()`
Default: <leader>g Go to assignment
This function finds the first definition of the function/class under the
cursor. It produces an error if the definition is not in a Python file.
------------------------------------------------------------------------------
5.4. `g:jedi#goto_definitions_command` *g:jedi#goto_definitions_command*
Function: `jedi#goto_definitions()`
Default: - Go to original definition
NOTE: Deprecated. Use |g:jedi#goto_command| / |jedi#goto()| instead, which
currently uses this internally.
------------------------------------------------------------------------------
5.5. `g:jedi#documentation_command` *g:jedi#documentation_command*
Function: `jedi#show_documentation()`
Default: <K> Show pydoc documentation
This shows the pydoc documentation for the item currently under the cursor.
The documentation is opened in a horizontally split buffer. The height of this
buffer is controlled by `g:jedi#max_doc_height` (set by default to 30).
------------------------------------------------------------------------------
5.6. `g:jedi#rename_command` *g:jedi#rename_command*
Function: `jedi#rename()`
Default: <leader>r Rename variables
Jedi-vim deletes the word currently under the cursor and puts Vim in insert
mode, where the user is expected to enter the new variable name. Upon leaving
insert mode, jedi-vim then renames all occurences of the old variable name
with the new one. The number of performed renames is displayed in the command
line.
------------------------------------------------------------------------------
5.7. `g:jedi#usages_command` *g:jedi#usages_command*
Function: `jedi#usages()`
Default: <leader>n Show usages of a name.
The quickfix window is populated with a list of all names which point to the
definition of the name under the cursor.
------------------------------------------------------------------------------
5.8. Open module by name *:Pyimport*
Function: `jedi#py_import(args)`
Default: :Pyimport e.g. `:Pyimport os` shows os.py in VIM.
Simulate an import and open that module in VIM.
==============================================================================
6. Configuration *jedi-vim-configuration*
Note: You currently have to set these options in your .vimrc. Setting them in
an ftplugin (e.g. ~/.vim/ftplugin/python/jedi-vim-settings.vim) will not work
because jedi-vim is not set up as an filetype plugin, but as a "regular"
plugin.
------------------------------------------------------------------------------
6.1. `g:jedi#auto_initialization` *g:jedi#auto_initialization*
Upon initialization, jedi-vim performs the following steps:
1. Set the current buffers 'omnifunc' to its own completion function
`jedi#completions`
2. Create mappings to commands specified in |jedi-vim-keybindings|
3. Call `jedi#configure_call_signatures()` if
`g:jedi#show_call_signatures` is set
You can disable the default initialization routine by setting this option to
0. Beware that you have to perform the above steps yourself, though.
Options: 0 or 1
Default: 1 (Perform automatic initialization)
------------------------------------------------------------------------------
6.2. `g:jedi#auto_vim_configuration` *g:jedi#auto_vim_configuration*
Jedi-vim sets 'completeopt' to `menuone,longest,preview` by default, if
'completeopt' is not changed from Vim's default.
It also remaps <Ctrl-C> to <Esc> in insert mode.
If you want to keep your own configuration, disable this setting.
Options: 0 or 1
Default: 1 (Set 'completeopt' and mapping as described above)
------------------------------------------------------------------------------
6.3. `g:jedi#popup_on_dot` *g:jedi#popup_on_dot*
Jedi-vim automatically starts completion upon typing a period in insert mode.
However, when working with large modules, this can slow down your typing flow
since you have to wait for jedi to parse the module and show the completion
menu. By disabling this setting, completion is only started when you manually
press the completion key.
Options: 0 or 1
Default: 1 (Start completion on typing a period)
------------------------------------------------------------------------------
6.4. `g:jedi#popup_select_first` *g:jedi#popup_select_first*
Upon starting completion, jedi-vim can automatically select the first entry
that pops up (without actually inserting it).
This leads to a better typing flow: As you type more characters, the entries
in the completion menu are narrowed down. If they are narrowed down enough,
you can just press <Return> to insert the first match.
Options: 0 or 1
Default: 1 (Automatically select first completion entry)
------------------------------------------------------------------------------
6.5. `g:jedi#auto_close_doc` *g:jedi#auto_close_doc*
When doing completion, jedi-vim shows the docstring of the currently selected
item in a preview window. By default, this window is being closed after
insertion of a completion item.
Set this to 0 to leave the preview window open even after leaving insert mode.
This could be useful if you want to browse longer docstrings.
Options: 0 or 1
Default: 1 (Automatically close preview window upon leaving insert mode)
------------------------------------------------------------------------------
6.6. `g:jedi#show_call_signatures` *g:jedi#show_call_signatures*
Jedi-vim can display a small window detailing the arguments of the currently
completed function and highlighting the currently selected argument. This can
be disabled by setting this option to 0. Setting this option to 2 shows call
signatures in the command line instead of a popup window.
Options: 0, 1, or 2
Default: 1 (Show call signatures window)
Note: 'showmode' must be disabled for command line call signatures to be
visible.
Note: This setting is ignored if |g:jedi#auto_initialization| is set to 0. In
that case, if you want to see call signatures, you have to set it up
manually by calling a function in your configuration file: >
call jedi#configure_call_signatures()
------------------------------------------------------------------------------
6.7. `g:jedi#use_tabs_not_buffers` *g:jedi#use_tabs_not_buffers*
You can make jedi-vim open a new tab if you use the "go to", "show
definition", or "related names" commands. When you leave this at the default
(0), they open in the current buffer instead.
Options: 0 or 1
Default: 0 (Command output is put in a new tab)
------------------------------------------------------------------------------
6.8. `g:jedi#squelch_py_warning` *g:jedi#squelch_py_warning*
When Vim has not been compiled with +python, jedi-vim shows a warning to that
effect and aborts loading itself. Set this to 1 to suppress that warning.
Options: 0 or 1
Default: 0 (Warning is shown)
------------------------------------------------------------------------------
6.9. `g:jedi#completions_enabled` *g:jedi#completions_enabled*
If you don't want Jedi completion, but all the other features, you can disable
it in favor of another completion engine (that probably also uses Jedi, like
YCM).
Options: 0 or 1
Default: 1
------------------------------------------------------------------------------
6.10. `g:jedi#use_splits_not_buffers` *g:jedi#use_splits_not_buffers*
If you want to open new split for "go to", you could set this option to the
direction which you want to open a split with.
Options: top, left, right, bottom or winwidth
Default: "" (not enabled by default)
Note: with the 'winwidth' option the window is split vertically or horizontally
depending on the width of the window relative to 'textwidth'. This essentially
means that if the window is big enough it will be split vertically but if it is
small a horizontal split happens.
------------------------------------------------------------------------------
6.11. `g:jedi#force_py_version` *g:jedi#force_py_version*
If you have installed both python 2 and python 3, you can force which one jedi
should use by setting this variable. It forces the internal Vim command, which
will be used for every jedi call to the respective python interpreter.
The variable can be set in the .vimrc like this to force python 3:
let g:jedi#force_py_version = 3
This variable can be switched during runtime using the following function:
Function: `jedi#force_py_version_switch()`
or set directly using this function, which has the same name as the variable:
Function: `jedi#force_py_version(py_version)`
Options: 2 or 3
Default: "auto" (will use sys.version_info from "python" in your $PATH)
==============================================================================
7. Testing *jedi-vim-testing*
jedi-vim is being tested with a combination of vspec
https://github.com/kana/vim-vspec and py.test http://pytest.org/.
The tests are in the test subdirectory, you can run them calling::
py.test
The tests are automatically run with `travis
<https://travis-ci.org/davidhalter/jedi-vim>`_.
==============================================================================
8. Contributing *jedi-vim-contributing*
We love Pull Requests! Read the instructions in `CONTRIBUTING.md`.
==============================================================================
9. License *jedi-vim-license*
Jedi-vim is licensed with the MIT license.
vim: textwidth=78 tabstop=8 filetype=help:norightleft:

View File

@ -0,0 +1,44 @@
if !jedi#init_python()
finish
endif
" ------------------------------------------------------------------------
" Initialization of jedi-vim
" ------------------------------------------------------------------------
if g:jedi#auto_initialization
" goto / get_definition / usages
if g:jedi#goto_command != ''
execute "nnoremap <buffer> ".g:jedi#goto_command." :call jedi#goto()<CR>"
endif
if g:jedi#goto_assignments_command != ''
execute "nnoremap <buffer> ".g:jedi#goto_assignments_command." :call jedi#goto_assignments()<CR>"
endif
if g:jedi#goto_definitions_command != ''
execute "nnoremap <buffer> ".g:jedi#goto_definitions_command." :call jedi#goto_definitions()<CR>"
endif
if g:jedi#usages_command != ''
execute "nnoremap <buffer> ".g:jedi#usages_command." :call jedi#usages()<CR>"
endif
" rename
if g:jedi#rename_command != ''
execute "nnoremap <buffer> ".g:jedi#rename_command." :call jedi#rename()<CR>"
execute "vnoremap <buffer> ".g:jedi#rename_command." :call jedi#rename_visual()<CR>"
endif
" documentation/pydoc
if g:jedi#documentation_command != ''
execute "nnoremap <silent> <buffer>".g:jedi#documentation_command." :call jedi#show_documentation()<CR>"
endif
if g:jedi#show_call_signatures > 0 && has('conceal')
call jedi#configure_call_signatures()
endif
if g:jedi#completions_enabled == 1
inoremap <silent> <buffer> . .<C-R>=jedi#complete_string(1)<CR>
endif
if g:jedi#auto_close_doc
" close preview if its still open after insert
autocmd InsertLeave <buffer> if pumvisible() == 0|pclose|endif
endif
endif

View File

@ -0,0 +1,22 @@
''' ------------------------------------------------------------------------
Python initialization
---------------------------------------------------------------------------
here we initialize the jedi stuff '''
import vim
# update the system path, to include the jedi path
import sys
import os
# vim.command('echom expand("<sfile>:p:h:h")') # broken, <sfile> inside function
# sys.path.insert(0, os.path.join(vim.eval('expand("<sfile>:p:h:h")'), 'jedi'))
sys.path.insert(0, os.path.join(vim.eval('expand(s:script_path)'), 'jedi'))
# to display errors correctly
import traceback
# update the sys path to include the jedi_vim script
sys.path.insert(0, vim.eval('expand(s:script_path)'))
import jedi_vim
sys.path.pop(1)

@ -0,0 +1 @@
Subproject commit 66557903ae4c1174eb437a8feeeb718e69d5fa3a

View File

@ -0,0 +1,643 @@
"""
The Python parts of the Jedi library for VIM. It is mostly about communicating
with VIM.
"""
import traceback # for exception output
import re
import os
import sys
from shlex import split as shsplit
try:
from itertools import zip_longest
except ImportError:
from itertools import izip_longest as zip_longest # Python 2
is_py3 = sys.version_info[0] >= 3
if is_py3:
unicode = str
class PythonToVimStr(unicode):
""" Vim has a different string implementation of single quotes """
__slots__ = []
def __new__(cls, obj, encoding='UTF-8'):
if is_py3 or isinstance(obj, unicode):
return unicode.__new__(cls, obj)
else:
return unicode.__new__(cls, obj, encoding)
def __repr__(self):
# this is totally stupid and makes no sense but vim/python unicode
# support is pretty bad. don't ask how I came up with this... It just
# works...
# It seems to be related to that bug: http://bugs.python.org/issue5876
if unicode is str:
s = self
else:
s = self.encode('UTF-8')
return '"%s"' % s.replace('\\', '\\\\').replace('"', r'\"')
class VimError(Exception):
def __init__(self, message, throwpoint, executing):
super(type(self), self).__init__(message)
self.message = message
self.throwpoint = throwpoint
self.executing = executing
def __str__(self):
return self.message + '; created by: ' + repr(self.executing)
def _catch_exception(string, is_eval):
"""
Interface between vim and python calls back to it.
Necessary, because the exact error message is not given by `vim.error`.
"""
e = 'jedi#_vim_exceptions(%s, %s)'
result = vim.eval(e % (repr(PythonToVimStr(string, 'UTF-8')), is_eval))
if 'exception' in result:
raise VimError(result['exception'], result['throwpoint'], string)
return result['result']
def vim_command(string):
_catch_exception(string, 0)
def vim_eval(string):
return _catch_exception(string, 1)
def no_jedi_warning():
vim.command('echohl WarningMsg'
'| echom "Please install Jedi if you want to use jedi-vim."'
'| echohl None')
def echo_highlight(msg):
vim_command('echohl WarningMsg | echom "{}" | echohl None'.format(
msg.replace('"', '\\"')))
import vim
try:
import jedi
except ImportError:
no_jedi_warning()
jedi = None
else:
try:
version = jedi.__version__
except Exception as e: # e.g. AttributeError
echo_highlight("Could not load jedi python module: {}".format(e))
jedi = None
else:
if isinstance(version, str):
# the normal use case, now.
from jedi import utils
version = utils.version_info()
if version < (0, 7):
echo_highlight('Please update your Jedi version, it is too old.')
def catch_and_print_exceptions(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except (Exception, vim.error):
print(traceback.format_exc())
return None
return wrapper
def _check_jedi_availability(show_error=False):
def func_receiver(func):
def wrapper(*args, **kwargs):
if jedi is None:
if show_error:
no_jedi_warning()
return
else:
return func(*args, **kwargs)
return wrapper
return func_receiver
@catch_and_print_exceptions
def get_script(source=None, column=None):
jedi.settings.additional_dynamic_modules = \
[b.name for b in vim.buffers if b.name is not None and b.name.endswith('.py')]
if source is None:
source = '\n'.join(vim.current.buffer)
row = vim.current.window.cursor[0]
if column is None:
column = vim.current.window.cursor[1]
buf_path = vim.current.buffer.name
encoding = vim_eval('&encoding') or 'latin1'
return jedi.Script(source, row, column, buf_path, encoding)
@_check_jedi_availability(show_error=False)
@catch_and_print_exceptions
def completions():
row, column = vim.current.window.cursor
# Clear call signatures in the buffer so they aren't seen by the completer.
# Call signatures in the command line can stay.
if vim_eval("g:jedi#show_call_signatures") == '1':
clear_call_signatures()
if vim.eval('a:findstart') == '1':
count = 0
for char in reversed(vim.current.line[:column]):
if not re.match('[\w\d]', char):
break
count += 1
vim.command('return %i' % (column - count))
else:
base = vim.eval('a:base')
source = ''
for i, line in enumerate(vim.current.buffer):
# enter this path again, otherwise source would be incomplete
if i == row - 1:
source += line[:column] + base + line[column:]
else:
source += line
source += '\n'
# here again hacks, because jedi has a different interface than vim
column += len(base)
try:
script = get_script(source=source, column=column)
completions = script.completions()
signatures = script.call_signatures()
out = []
for c in completions:
d = dict(word=PythonToVimStr(c.name[:len(base)] + c.complete),
abbr=PythonToVimStr(c.name),
# stuff directly behind the completion
menu=PythonToVimStr(c.description),
info=PythonToVimStr(c.docstring()), # docstr
icase=1, # case insensitive
dup=1 # allow duplicates (maybe later remove this)
)
out.append(d)
strout = str(out)
except Exception:
# print to stdout, will be in :messages
print(traceback.format_exc())
strout = ''
completions = []
signatures = []
show_call_signatures(signatures)
vim.command('return ' + strout)
@_check_jedi_availability(show_error=True)
@catch_and_print_exceptions
def goto(mode="goto", no_output=False):
"""
:param str mode: "related_name", "definition", "assignment", "auto"
:return: list of definitions/assignments
:rtype: list
"""
script = get_script()
try:
if mode == "goto":
definitions = [x for x in script.goto_definitions()
if not x.in_builtin_module()]
if not definitions:
definitions = script.goto_assignments()
elif mode == "related_name":
definitions = script.usages()
elif mode == "definition":
definitions = script.goto_definitions()
elif mode == "assignment":
definitions = script.goto_assignments()
except jedi.NotFoundError:
echo_highlight("Cannot follow nothing. Put your cursor on a valid name.")
definitions = []
else:
if no_output:
return definitions
if not definitions:
echo_highlight("Couldn't find any definitions for this.")
elif len(definitions) == 1 and mode != "related_name":
# just add some mark to add the current position to the jumplist.
# this is ugly, because it overrides the mark for '`', so if anyone
# has a better idea, let me know.
vim_command('normal! m`')
d = list(definitions)[0]
if d.in_builtin_module():
if d.is_keyword:
echo_highlight("Cannot get the definition of Python keywords.")
else:
echo_highlight("Builtin modules cannot be displayed (%s)."
% d.desc_with_module)
else:
if d.module_path != vim.current.buffer.name:
result = new_buffer(d.module_path)
if not result:
return []
vim.current.window.cursor = d.line, d.column
else:
# multiple solutions
lst = []
for d in definitions:
if d.in_builtin_module():
lst.append(dict(text=PythonToVimStr('Builtin ' + d.description)))
else:
lst.append(dict(filename=PythonToVimStr(d.module_path),
lnum=d.line, col=d.column + 1,
text=PythonToVimStr(d.description)))
vim_eval('setqflist(%s)' % repr(lst))
vim_eval('jedi#add_goto_window(' + str(len(lst)) + ')')
return definitions
@_check_jedi_availability(show_error=True)
@catch_and_print_exceptions
def show_documentation():
script = get_script()
try:
definitions = script.goto_definitions()
except jedi.NotFoundError:
definitions = []
except Exception:
# print to stdout, will be in :messages
definitions = []
print("Exception, this shouldn't happen.")
print(traceback.format_exc())
if not definitions:
echo_highlight('No documentation found for that.')
vim.command('return')
else:
docs = ['Docstring for %s\n%s\n%s' % (d.desc_with_module, '=' * 40, d.docstring())
if d.docstring() else '|No Docstring for %s|' % d for d in definitions]
text = ('\n' + '-' * 79 + '\n').join(docs)
vim.command('let l:doc = %s' % repr(PythonToVimStr(text)))
vim.command('let l:doc_lines = %s' % len(text.split('\n')))
return True
@catch_and_print_exceptions
def clear_call_signatures():
# Check if using command line call signatures
if vim_eval("g:jedi#show_call_signatures") == '2':
vim_command('echo ""')
return
cursor = vim.current.window.cursor
e = vim_eval('g:jedi#call_signature_escape')
# We need two turns here to search and replace certain lines:
# 1. Search for a line with a call signature and save the appended
# characters
# 2. Actually replace the line and redo the status quo.
py_regex = r'%sjedi=([0-9]+), (.*?)%s.*?%sjedi%s'.replace('%s', e)
for i, line in enumerate(vim.current.buffer):
match = re.search(py_regex, line)
if match is not None:
# Some signs were added to minimize syntax changes due to call
# signatures. We have to remove them again. The number of them is
# specified in `match.group(1)`.
after = line[match.end() + int(match.group(1)):]
line = line[:match.start()] + match.group(2) + after
vim.current.buffer[i] = line
vim.current.window.cursor = cursor
@_check_jedi_availability(show_error=False)
@catch_and_print_exceptions
def show_call_signatures(signatures=()):
if vim_eval("has('conceal') && g:jedi#show_call_signatures") == '0':
return
if signatures == ():
signatures = get_script().call_signatures()
clear_call_signatures()
if not signatures:
return
if vim_eval("g:jedi#show_call_signatures") == '2':
return cmdline_call_signatures(signatures)
for i, signature in enumerate(signatures):
line, column = signature.bracket_start
# signatures are listed above each other
line_to_replace = line - i - 1
# because there's a space before the bracket
insert_column = column - 1
if insert_column < 0 or line_to_replace <= 0:
# Edge cases, when the call signature has no space on the screen.
break
# TODO check if completion menu is above or below
line = vim_eval("getline(%s)" % line_to_replace)
params = [p.description.replace('\n', '') for p in signature.params]
try:
# *_*PLACEHOLDER*_* makes something fat. See after/syntax file.
params[signature.index] = '*_*%s*_*' % params[signature.index]
except (IndexError, TypeError):
pass
# This stuff is reaaaaally a hack! I cannot stress enough, that
# this is a stupid solution. But there is really no other yet.
# There is no possibility in VIM to draw on the screen, but there
# will be one (see :help todo Patch to access screen under Python.
# (Marko Mahni, 2010 Jul 18))
text = " (%s) " % ', '.join(params)
text = ' ' * (insert_column - len(line)) + text
end_column = insert_column + len(text) - 2 # -2 due to bold symbols
# Need to decode it with utf8, because vim returns always a python 2
# string even if it is unicode.
e = vim_eval('g:jedi#call_signature_escape')
if hasattr(e, 'decode'):
e = e.decode('UTF-8')
# replace line before with cursor
regex = "xjedi=%sx%sxjedix".replace('x', e)
prefix, replace = line[:insert_column], line[insert_column:end_column]
# Check the replace stuff for strings, to append them
# (don't want to break the syntax)
regex_quotes = r'''\\*["']+'''
# `add` are all the quotation marks.
# join them with a space to avoid producing '''
add = ' '.join(re.findall(regex_quotes, replace))
# search backwards
if add and replace[0] in ['"', "'"]:
a = re.search(regex_quotes + '$', prefix)
add = ('' if a is None else a.group(0)) + add
tup = '%s, %s' % (len(add), replace)
repl = prefix + (regex % (tup, text)) + add + line[end_column:]
vim_eval('setline(%s, %s)' % (line_to_replace, repr(PythonToVimStr(repl))))
@catch_and_print_exceptions
def cmdline_call_signatures(signatures):
def get_params(s):
return [p.description.replace('\n', '') for p in s.params]
if len(signatures) > 1:
params = zip_longest(*map(get_params, signatures), fillvalue='_')
params = ['(' + ', '.join(p) + ')' for p in params]
else:
params = get_params(signatures[0])
text = ', '.join(params).replace('"', '\\"').replace(r'\n', r'\\n')
# Allow 12 characters for ruler/showcmd - setting noruler/noshowcmd
# here causes incorrect undo history
max_msg_len = int(vim_eval('&columns')) - 12
max_num_spaces = (max_msg_len - len(signatures[0].call_name)
- len(text) - 2) # 2 accounts for parentheses
if max_num_spaces < 0:
return # No room for the message
_, column = signatures[0].bracket_start
num_spaces = min(int(vim_eval('g:jedi#first_col +'
'wincol() - col(".")')) +
column - len(signatures[0].call_name),
max_num_spaces)
spaces = ' ' * num_spaces
try:
index = [s.index for s in signatures if isinstance(s.index, int)][0]
escaped_param = params[index].replace(r'\n', r'\\n')
left = text.index(escaped_param)
right = left + len(escaped_param)
vim_command(' echon "%s" | '
'echohl Function | echon "%s" | '
'echohl None | echon "(" | '
'echohl jediFunction | echon "%s" | '
'echohl jediFat | echon "%s" | '
'echohl jediFunction | echon "%s" | '
'echohl None | echon ")"'
% (spaces, signatures[0].call_name, text[:left],
text[left:right], text[right:]))
except (TypeError, IndexError):
vim_command(' echon "%s" | '
'echohl Function | echon "%s" | '
'echohl None | echon "(" | '
'echohl jediFunction | echon "%s" | '
'echohl None | echon ")"'
% (spaces, signatures[0].call_name, text))
@_check_jedi_availability(show_error=True)
@catch_and_print_exceptions
def rename():
if not int(vim.eval('a:0')):
vim_command('augroup jedi_rename')
vim_command('autocmd InsertLeave <buffer> call jedi#rename(1)')
vim_command('augroup END')
vim_command("let s:jedi_replace_orig = expand('<cword>')")
vim_command('normal! diw')
vim_command("let s:jedi_changedtick = b:changedtick")
vim_command('startinsert')
else:
# Remove autocommand.
vim_command('autocmd! jedi_rename InsertLeave')
# Get replacement, if there is something on the cursor.
# This won't be the case when the user ends insert mode right away,
# and `<cword>` would pick up the nearest word instead.
if vim_eval('getline(".")[getpos(".")[2]-1]') != ' ':
replace = vim_eval("expand('<cword>')")
else:
replace = None
cursor = vim.current.window.cursor
# Undo new word, but only if something was changed, which is not the
# case when ending insert mode right away.
if vim_eval('b:changedtick != s:jedi_changedtick') == '1':
vim_command('normal! u') # Undo new word.
vim_command('normal! u') # Undo diw.
vim.current.window.cursor = cursor
if replace:
return do_rename(replace)
def rename_visual():
replace = vim.eval('input("Rename to: ")')
orig = vim.eval('getline(".")[(getpos("\'<")[2]-1):getpos("\'>")[2]]')
do_rename(replace, orig)
def do_rename(replace, orig=None):
if not len(replace):
echo_highlight('No rename possible without name.')
return
if orig is None:
orig = vim_eval('s:jedi_replace_orig')
# Save original window / tab.
saved_tab = int(vim_eval('tabpagenr()'))
saved_win = int(vim_eval('winnr()'))
temp_rename = goto(mode="related_name", no_output=True)
# Sort the whole thing reverse (positions at the end of the line
# must be first, because they move the stuff before the position).
temp_rename = sorted(temp_rename, reverse=True,
key=lambda x: (x.module_path, x.start_pos))
buffers = set()
for r in temp_rename:
if r.in_builtin_module():
continue
if os.path.abspath(vim.current.buffer.name) != r.module_path:
result = new_buffer(r.module_path)
if not result:
echo_highlight("Jedi-vim: failed to create buffer window for {}!".format(r.module_path))
continue
buffers.add(vim.current.buffer.name)
# Save view.
saved_view = vim_eval('string(winsaveview())')
# Replace original word.
vim.current.window.cursor = r.start_pos
vim_command('normal! c{:d}l{}'.format(len(orig), replace))
# Restore view.
vim_command('call winrestview(%s)' % saved_view)
# Restore previous tab and window.
vim_command('tabnext {:d}'.format(saved_tab))
vim_command('{:d}wincmd w'.format(saved_win))
if len(buffers) > 1:
echo_highlight('Jedi did {:d} renames in {:d} buffers!'.format(
len(temp_rename), len(buffers)))
else:
echo_highlight('Jedi did {:d} renames!'.format(len(temp_rename)))
@_check_jedi_availability(show_error=True)
@catch_and_print_exceptions
def py_import():
# args are the same as for the :edit command
args = shsplit(vim.eval('a:args'))
import_path = args.pop()
text = 'import %s' % import_path
scr = jedi.Script(text, 1, len(text), '')
try:
completion = scr.goto_assignments()[0]
except IndexError:
echo_highlight('Cannot find %s in sys.path!' % import_path)
else:
if completion.in_builtin_module():
echo_highlight('%s is a builtin module.' % import_path)
else:
cmd_args = ' '.join([a.replace(' ', '\\ ') for a in args])
new_buffer(completion.module_path, cmd_args)
@catch_and_print_exceptions
def py_import_completions():
argl = vim.eval('a:argl')
try:
import jedi
except ImportError:
print('Pyimport completion requires jedi module: https://github.com/davidhalter/jedi')
comps = []
else:
text = 'import %s' % argl
script = jedi.Script(text, 1, len(text), '')
comps = ['%s%s' % (argl, c.complete) for c in script.completions()]
vim.command("return '%s'" % '\n'.join(comps))
@catch_and_print_exceptions
def new_buffer(path, options=''):
# options are what you can to edit the edit options
if vim_eval('g:jedi#use_tabs_not_buffers') == '1':
_tabnew(path, options)
elif not vim_eval('g:jedi#use_splits_not_buffers') == '1':
user_split_option = vim_eval('g:jedi#use_splits_not_buffers')
split_options = {
'top': 'topleft split',
'left': 'topleft vsplit',
'right': 'botright vsplit',
'bottom': 'botright split',
'winwidth': 'vs'
}
if user_split_option == 'winwidth' and vim.current.window.width <= 2 * int(vim_eval("&textwidth ? &textwidth : 80")):
split_options['winwidth'] = 'sp'
if user_split_option not in split_options:
print('g:jedi#use_splits_not_buffers value is not correct, valid options are: %s' % ','.join(split_options.keys()))
else:
vim_command(split_options[user_split_option] + " %s" % path)
else:
if vim_eval("!&hidden && &modified") == '1':
if vim_eval("bufname('%')") is None:
echo_highlight('Cannot open a new buffer, use `:set hidden` or save your buffer')
return False
else:
vim_command('w')
vim_command('edit %s %s' % (options, escape_file_path(path)))
# sometimes syntax is being disabled and the filetype not set.
if vim_eval('!exists("g:syntax_on")') == '1':
vim_command('syntax enable')
if vim_eval("&filetype != 'python'") == '1':
vim_command('set filetype=python')
return True
@catch_and_print_exceptions
def _tabnew(path, options=''):
"""
Open a file in a new tab or switch to an existing one.
:param options: `:tabnew` options, read vim help.
"""
path = os.path.abspath(path)
if vim_eval('has("gui")') == '1':
vim_command('tab drop %s %s' % (options, escape_file_path(path)))
return
for tab_nr in range(int(vim_eval("tabpagenr('$')"))):
for buf_nr in vim_eval("tabpagebuflist(%i + 1)" % tab_nr):
buf_nr = int(buf_nr) - 1
try:
buf_path = vim.buffers[buf_nr].name
except (LookupError, ValueError):
# Just do good old asking for forgiveness.
# don't know why this happens :-)
pass
else:
if buf_path == path:
# tab exists, just switch to that tab
vim_command('tabfirst | tabnext %i' % (tab_nr + 1))
# Goto the buffer's window.
vim_command('exec bufwinnr(%i) . " wincmd w"' % (buf_nr + 1))
break
else:
continue
break
else:
# tab doesn't exist, add a new one.
vim_command('tabnew %s' % escape_file_path(path))
def escape_file_path(path):
return path.replace(' ', r'\ ')
def print_to_stdout(level, str_out):
print(str_out)

View File

@ -0,0 +1,33 @@
"jedi-vim - Omni Completion for python in vim
" Maintainer: David Halter <davidhalter88@gmail.com>
"
" This part of the software is just the vim interface. The really big deal is
" the Jedi Python library.
if !exists("g:jedi#auto_vim_configuration") || g:jedi#auto_vim_configuration
" jedi-vim doesn't work in compatible mode (vim script syntax problems)
if &compatible
set nocompatible
endif
" jedi-vim really needs, otherwise jedi-vim cannot start.
filetype plugin on
" Change completeopt, but only if it has Vim's default value.
let s:save_completeopt=&completeopt
set completeopt&
let s:default_completeopt=&completeopt
let &completeopt=s:save_completeopt
if s:default_completeopt == &completeopt
set completeopt=menuone,longest,preview
endif
if len(mapcheck('<C-c>', 'i')) == 0
inoremap <C-c> <ESC>
endif
endif
" Pyimport command
command! -nargs=1 -complete=custom,jedi#py_import_completions Pyimport :call jedi#py_import(<q-args>)
" vim: set et ts=4:

View File

@ -0,0 +1,3 @@
[pytest]
# Ignore all files
norecursedirs = *

View File

@ -0,0 +1,52 @@
let g:jedi#completions_command = 'X'
source plugin/jedi.vim
describe 'completions'
before
new
set filetype=python
end
after
bd!
end
it 'import'
" X is the completion command
normal oimporX
Expect getline('.') == 'import'
normal a subproX
Expect getline('.') == 'import subprocess'
end
it 'exception'
normal oIndentationErrX
Expect getline('.') == 'IndentationError'
normal a().filenaX
Expect getline('.') == 'IndentationError().filename'
end
it 'dot_open'
normal oraisX ImpXErrX()
Expect getline('.') == 'raise ImportError()'
end
it 'cycling through entries'
" testing select_first doesn't seem to work in ex mode
execute "normal oraise impX\<C-n>\<C-n>\<C-n>"
Expect getline('.') == 'raise ImportWarning'
let g:jedi#popup_select_first = 0
execute "normal oraise impX\<C-n>\<C-n>\<C-n>"
Expect getline('.') == 'raise ImportWarning'
let g:jedi#popup_select_first = 1
" -longest completes the first one
set completeopt -=longest
execute "normal oraise baseX"
Expect getline('.') == 'raise BaseException'
set completeopt +=longest
end
end
" vim: et:ts=4:sw=4

View File

@ -0,0 +1,21 @@
let g:jedi#completions_command = 'X'
let g:jedi#completions_enabled = 0
source plugin/jedi.vim
describe 'completions_disabled'
before
new
set filetype=python
end
after
bd!
end
it 'typing'
normal oraise ImportErrX
Expect getline('.') == 'raise ImportErrX'
end
end
" vim: et:ts=4:sw=4

View File

@ -0,0 +1,31 @@
source plugin/jedi.vim
describe 'documentation docstrings'
before
set filetype=python
end
after
bd!
bd!
end
it 'simple'
put = 'ImportError'
normal GK
Expect bufname('%') == "'__doc__'"
Expect &filetype == 'rst'
let content = join(getline(1,'$'), "\n")
Expect stridx(content, "Import can't find module") > 0
normal K
Expect bufname('%') == ''
end
it 'no documentation'
put = 'x = 2'
normal o<ESC>GK
Expect bufname('%') == ''
end
end
" vim: et:ts=4:sw=4

View File

@ -0,0 +1,180 @@
let mapleader = '\'
source plugin/jedi.vim
source test/utils.vim
describe 'goto_simple'
before
new " open a new split
set filetype=python
put =[
\ 'def a(): pass',
\ 'b = a',
\ 'c = b',
\ ]
normal! ggdd
normal! G$
Expect line('.') == 3
end
after
bd!
end
it 'goto_definitions'
silent normal \d
Expect line('.') == 1
"Expect col('.') == 5 " not working yet.
end
it 'goto_assignments'
silent normal \g
Expect line('.') == 2
Expect col('.') == 1
" cursor before `=` means that it stays there.
silent normal \g
Expect line('.') == 2
Expect col('.') == 1
" going to the last line changes it.
normal! $
silent normal \g
Expect line('.') == 1
Expect col('.') == 5
end
end
describe 'goto_with_tabs'
before
set filetype=python
let g:jedi#use_tabs_not_buffers = 1
end
after
bd!
bd!
end
it 'follow_import'
put = ['import subprocess', 'subprocess']
silent normal G\g
Expect getline('.') == 'import subprocess'
Expect line('.') == 2
Expect col('.') == 8
silent normal G\d
Expect CurrentBufferIsModule('subprocess') == 1
Expect line('.') == 1
Expect col('.') == 1
Expect tabpagenr('$') == 2
Expect winnr('$') == 1
tabprevious
Expect bufname('%') == ''
end
it 'multi_definitions'
" This used to behave differently. Now we don't have any real multi
" definitions.
" put = ['import tokenize']
" silent normal G$\d
" Expect CurrentBufferIsModule('tokenize') == 1
" Expect CurrentBufferIsModule('token') == 0
" execute "normal \<CR>"
" Expect tabpagenr('$') == 2
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('token') == 1
" bd
" silent normal G$\d
" execute "normal j\<CR>"
" Expect tabpagenr('$') == 2
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('tokenize') == 1
end
end
describe 'goto_with_buffers'
before
set filetype=python
let g:jedi#use_tabs_not_buffers = 0
end
after
bd!
bd!
set nohidden
end
it 'no_new_tabs'
put = ['import os']
normal G$
call jedi#goto_assignments()
python jedi_vim.goto()
Expect CurrentBufferIsModule('os') == 0
" Without hidden, it's not possible to open a new buffer, when the old
" one is not saved.
set hidden
call jedi#goto_assignments()
Expect CurrentBufferIsModule('os') == 1
Expect winnr('$') == 1
Expect tabpagenr('$') == 1
Expect line('.') == 1
Expect col('.') == 1
end
it 'multi_definitions'
" set hidden
" put = ['import tokenize']
" silent normal G$\d
" Expect CurrentBufferIsModule('tokenize') == 0
" Expect CurrentBufferIsModule('token') == 0
" execute "normal \<CR>"
" Expect tabpagenr('$') == 1
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('token') == 1
" bd
" silent normal G$\d
" execute "normal j\<CR>"
" Expect tabpagenr('$') == 1
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('tokenize') == 1
end
end
describe 'goto_with_splits'
before
set filetype=python
let g:jedi#use_splits_not_buffers = 'left'
end
after
bd!
bd!
end
it 'follow_import'
put = ['import subprocess', 'subprocess']
silent normal G\g
Expect getline('.') == 'import subprocess'
Expect line('.') == 2
Expect col('.') == 8
silent normal G\d
Expect CurrentBufferIsModule('subprocess') == 1
Expect line('.') == 1
Expect col('.') == 1
Expect winnr('$') == 2
wincmd l
Expect bufname('%') == ''
end
end
" vim: et:ts=4:sw=4

View File

@ -0,0 +1,32 @@
source plugin/jedi.vim
source test/utils.vim
describe 'pyimport'
before
let g:jedi#use_tabs_not_buffers = 1
end
after
bd!
bd!
end
it 'open_tab'
Pyimport os
Expect CurrentBufferIsModule('os') == 1
Pyimport subprocess
Expect CurrentBufferIsModule('subprocess') == 1
" the empty tab is sometimes also a tab
Expect tabpagenr('$') >= 2
end
it 'completion'
" don't know how to test this directly
"execute "Pyimport subproc\<Tab>"
"Expect CurrentBufferIsModule('subprocess') == 1
Expect jedi#py_import_completions('subproc', 0, 0) == 'subprocess'
Expect jedi#py_import_completions('subprocess', 0, 0) == 'subprocess'
Expect jedi#py_import_completions('zip', 0, 0) == "zipfile\nzipimport"
end
end

View File

@ -0,0 +1,66 @@
source plugin/jedi.vim
describe 'signatures'
before
set filetype=python
end
after
bd!
bd!
end
it 'simple'
normal oabs(
" equals doautocmd CursorMovedI
Python jedi_vim.show_call_signatures()
Expect getline(1) == '=`=jedi=0, =`= (*_*number*_*) =`=jedi=`='
doautocmd InsertLeave
Expect getline(1) == ''
end
it 'no signature'
normal ostr
Python jedi_vim.show_call_signatures()
Expect getline(1, '$') == ['', 'str ']
end
it 'signatures disabled'
let g:jedi#show_call_signatures = 0
normal ostr(
Python jedi_vim.show_call_signatures()
Expect getline(1, '$') == ['', 'str( ']
let g:jedi#show_call_signatures = 1
end
it 'command line simple'
let g:jedi#show_call_signatures = 2
call jedi#configure_call_signatures()
normal oabs(
redir => msg
Python jedi_vim.show_call_signatures()
redir END
Expect msg == "\nabs(number)"
redir => msg
doautocmd InsertLeave
redir END
Expect msg == "\n\n"
end
it 'command line no signature'
let g:jedi#show_call_signatures = 2
call jedi#configure_call_signatures()
normal ostr
redir => msg
Python jedi_vim.show_call_signatures()
redir END
Expect msg == "\n"
end
end

View File

@ -0,0 +1,11 @@
function! CurrentBufferIsModule(module_name)
return EndsWith(bufname('%'), a:module_name.'.py')
endfunction
function EndsWith(string, end)
let l:should = len(a:string) - strlen(a:end)
return l:should == stridx(a:string, a:end, should)
endfunction
" vim: et:ts=4:sw=4

View File

@ -0,0 +1,2 @@
def test_integration(case, monkeypatch, pytestconfig):
case.run()

View File

@ -0,0 +1 @@
doc/tags

View File

@ -0,0 +1,71 @@
# Indent Guides
Indent Guides is a plugin for visually displaying indent levels in Vim.
<img src="http://i.imgur.com/ONgoj.png" width="448" height="448" alt="" />
## Features:
* Can detect both tab and space indent styles.
* Automatically inspects your colorscheme and picks appropriate colors (gVim only).
* Will highlight indent levels with alternating colors.
* Full support for gVim and basic support for Terminal Vim.
* Seems to work on Windows gVim 7.3 (haven't done any extensive tests though).
* Customizable size for indent guides, eg. skinny guides (soft-tabs only).
* Customizable start indent level.
* **NEW:** Highlight support for files with a mixture of tab and space indent styles.
## Requirements
* Vim 7.2+
## Installation
To install the plugin just copy `autoload`, `plugin`, `doc` directories into your `.vim` directory.
Alternatively if you have [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332) installed, just clone this repo into a subdirectory of your `.vim/bundle` directory like so:
cd ~/.vim/bundle
git clone git://github.com/nathanaelkane/vim-indent-guides.git
## Usage
The default mapping to toggle the plugin is `<Leader>ig`
### gVim
**This plugin should work with gVim out of the box, no configuration needed.** It will automatically inspect your colorscheme and pick appropriate colors.
### Setting custom indent colors
Here's an example of how to define custom colors instead of using the ones the plugin automatically generates for you. Add this to your `.vimrc` file:
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=3
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=4
Alternatively you can add the following lines to your colorscheme file.
hi IndentGuidesOdd guibg=red ctermbg=3
hi IndentGuidesEven guibg=green ctermbg=4
### Terminal Vim
At the moment Terminal Vim only has basic support. This means is that colors won't be automatically calculated based on your colorscheme. Instead, some preset colors are used depending on whether `background` is set to `dark` or `light`.
When `set background=dark` is used, the following highlight colors will be defined:
hi IndentGuidesOdd ctermbg=black
hi IndentGuidesEven ctermbg=darkgrey
Alternatively, when `set background=light` is used, the following highlight colors will be defined:
hi IndentGuidesOdd ctermbg=white
hi IndentGuidesEven ctermbg=lightgrey
If for some reason it's incorrectly defining light highlight colors instead of dark ones or vice versa, the first thing you should check is that the `background` value is being set correctly for your colorscheme. Sometimes it's best to manually set the `background` value in your `.vimrc`, for example:
colorscheme desert256
set background=dark
Alternatively you can manually setup the highlight colors yourself, see `:help indent_guides_auto_colors` for an example.
## Help
`:help indent-guides`
## Screenshots
<img src="http://i.imgur.com/7tMBl.png" width="448" height="448" alt="" />
<img src="http://i.imgur.com/EvrqK.png" width="448" height="448" alt="" />
<img src="http://i.imgur.com/hHqp2.png" width="448" height="448" alt="" />

View File

@ -0,0 +1,879 @@
" Author: Nate Kane <nathanaelkane AT gmail DOT com>
" Homepage: http://github.com/nathanaelkane/vim-indent-guides
"
" Return hex string equivalent to given decimal string or number.
"
" Example: color_helper#dec_to_hex(255, 2)
" Returns: 'FF'
"
" Example: color_helper#dec_to_hex(255, 5)
" Returns: '000FF'
"
function! color_helper#dec_to_hex(arg, padding)
return toupper(printf('%0' . a:padding . 'x', a:arg + 0))
endfunction
"
" Return number equivalent to given hex string ('0x' is optional).
"
" Example: color_helper#hex_to_dec('FF')
" Returns: 255
"
" Example: color_helper#hex_to_dec('88')
" Returns: 136
"
" Example: color_helper#hex_to_dec('00')
" Returns: 0
"
function! color_helper#hex_to_dec(arg)
return (a:arg =~? '^0x') ? a:arg + 0 : ('0x'.a:arg) + 0
endfunction
"
" Converts a given hex color string into an rgb list (eg. [red, green, blue]).
"
" Example: color_helper#hex_color_to_rgb('#0088FF')
" Returns: [0, 136, 255]
"
function! color_helper#hex_color_to_rgb(hex_color)
let l:rgb = []
if a:hex_color =~ g:indent_guides_color_hex_pattern
let l:red = color_helper#hex_to_dec(strpart(a:hex_color, 1, 2))
let l:green = color_helper#hex_to_dec(strpart(a:hex_color, 3, 2))
let l:blue = color_helper#hex_to_dec(strpart(a:hex_color, 5, 2))
let l:rgb = [l:red, l:green, l:blue]
end
return l:rgb
endfunction
"
" Converts a given rgb list (eg. [red, green, blue]) into a hex color string.
"
" Example: color_helper#rgb_color_to_hex([0, 136, 255])
" Returns: '#0088FF'
"
function! color_helper#rgb_color_to_hex(rgb_color)
let l:hex_color = '#'
let l:hex_color .= color_helper#dec_to_hex(a:rgb_color[0], 2) " red
let l:hex_color .= color_helper#dec_to_hex(a:rgb_color[1], 2) " green
let l:hex_color .= color_helper#dec_to_hex(a:rgb_color[2], 2) " blue
return l:hex_color
endfunction
"
" Returns a ligtened color using the given color and the percent to lighten it
" by.
"
" Example: color_helper#hex_color_lighten('#000000', 0.10)
" Returns: '#191919'
"
function! color_helper#hex_color_lighten(color, percent)
let l:rgb = color_helper#hex_color_to_rgb(a:color)
let l:rgb_lightened = []
for i in l:rgb
call add(l:rgb_lightened, float2nr(i + ((255 - i) * a:percent)))
endfor
return color_helper#rgb_color_to_hex(l:rgb_lightened)
endfunction
"
" Returns a darkened color using the given color and the percent to darken it
" by.
"
" Example: color_helper#hex_color_darken('#FFFFFF', 0.10)
" Returns: '#E5E5E5'
"
function! color_helper#hex_color_darken(color, percent)
let l:rgb = color_helper#hex_color_to_rgb(a:color)
let l:rgb_darkened = []
for i in l:rgb
call add(l:rgb_darkened, float2nr(i * (1 - a:percent)))
endfor
return color_helper#rgb_color_to_hex(l:rgb_darkened)
endfunction
"
" Returns a hex color code for the given color name.
"
" Example: color_helper#color_name_to_hex('darkslategray')
" Returns: '#2F4F4F'
"
function! color_helper#color_name_to_hex(color_name)
let l:hex_code = ''
let l:color_name = tolower(a:color_name)
let l:color_list = {
\ 'alice blue' : '#F0F8FF',
\ 'aliceblue' : '#F0F8FF',
\ 'antique white' : '#FAEBD7',
\ 'antiquewhite' : '#FAEBD7',
\ 'antiquewhite1' : '#FFEFDB',
\ 'antiquewhite2' : '#EEDFCC',
\ 'antiquewhite3' : '#CDC0B0',
\ 'antiquewhite4' : '#8B8378',
\ 'aquamarine' : '#7FFFD4',
\ 'aquamarine1' : '#7FFFD4',
\ 'aquamarine2' : '#76EEC6',
\ 'aquamarine3' : '#66CDAA',
\ 'aquamarine4' : '#458B74',
\ 'azure' : '#F0FFFF',
\ 'azure1' : '#F0FFFF',
\ 'azure2' : '#E0EEEE',
\ 'azure3' : '#C1CDCD',
\ 'azure4' : '#838B8B',
\ 'beige' : '#F5F5DC',
\ 'bisque' : '#FFE4C4',
\ 'bisque1' : '#FFE4C4',
\ 'bisque2' : '#EED5B7',
\ 'bisque3' : '#CDB79E',
\ 'bisque4' : '#8B7D6B',
\ 'black' : '#000000',
\ 'blanched almond' : '#FFEBCD',
\ 'blanchedalmond' : '#FFEBCD',
\ 'blue violet' : '#8A2BE2',
\ 'blue' : '#0000FF',
\ 'blue1' : '#0000FF',
\ 'blue2' : '#0000EE',
\ 'blue3' : '#0000CD',
\ 'blue4' : '#00008B',
\ 'blueviolet' : '#8A2BE2',
\ 'brown' : '#A52A2A',
\ 'brown1' : '#FF4040',
\ 'brown2' : '#EE3B3B',
\ 'brown3' : '#CD3333',
\ 'brown4' : '#8B2323',
\ 'burlywood' : '#DEB887',
\ 'burlywood1' : '#FFD39B',
\ 'burlywood2' : '#EEC591',
\ 'burlywood3' : '#CDAA7D',
\ 'burlywood4' : '#8B7355',
\ 'cadet blue' : '#5F9EA0',
\ 'cadetblue' : '#5F9EA0',
\ 'cadetblue1' : '#98F5FF',
\ 'cadetblue2' : '#8EE5EE',
\ 'cadetblue3' : '#7AC5CD',
\ 'cadetblue4' : '#53868B',
\ 'chartreuse' : '#7FFF00',
\ 'chartreuse1' : '#7FFF00',
\ 'chartreuse2' : '#76EE00',
\ 'chartreuse3' : '#66CD00',
\ 'chartreuse4' : '#458B00',
\ 'chocolate' : '#D2691E',
\ 'chocolate1' : '#FF7F24',
\ 'chocolate2' : '#EE7621',
\ 'chocolate3' : '#CD661D',
\ 'chocolate4' : '#8B4513',
\ 'coral' : '#FF7F50',
\ 'coral1' : '#FF7256',
\ 'coral2' : '#EE6A50',
\ 'coral3' : '#CD5B45',
\ 'coral4' : '#8B3E2F',
\ 'cornflower blue' : '#6495ED',
\ 'cornflowerblue' : '#6495ED',
\ 'cornsilk' : '#FFF8DC',
\ 'cornsilk1' : '#FFF8DC',
\ 'cornsilk2' : '#EEE8CD',
\ 'cornsilk3' : '#CDC8B1',
\ 'cornsilk4' : '#8B8878',
\ 'cyan' : '#00FFFF',
\ 'cyan1' : '#00FFFF',
\ 'cyan2' : '#00EEEE',
\ 'cyan3' : '#00CDCD',
\ 'cyan4' : '#008B8B',
\ 'dark blue' : '#00008B',
\ 'dark cyan' : '#008B8B',
\ 'dark goldenrod' : '#B8860B',
\ 'dark gray' : '#A9A9A9',
\ 'dark green' : '#006400',
\ 'dark grey' : '#A9A9A9',
\ 'dark khaki' : '#BDB76B',
\ 'dark magenta' : '#8B008B',
\ 'dark olive green' : '#556B2F',
\ 'dark orange' : '#FF8C00',
\ 'dark orchid' : '#9932CC',
\ 'dark red' : '#8B0000',
\ 'dark salmon' : '#E9967A',
\ 'dark sea green' : '#8FBC8F',
\ 'dark slate blue' : '#483D8B',
\ 'dark slate gray' : '#2F4F4F',
\ 'dark slate grey' : '#2F4F4F',
\ 'dark turquoise' : '#00CED1',
\ 'dark violet' : '#9400D3',
\ 'dark yellow' : '#BBBB00',
\ 'darkblue' : '#00008B',
\ 'darkcyan' : '#008B8B',
\ 'darkgoldenrod' : '#B8860B',
\ 'darkgoldenrod1' : '#FFB90F',
\ 'darkgoldenrod2' : '#EEAD0E',
\ 'darkgoldenrod3' : '#CD950C',
\ 'darkgoldenrod4' : '#8B6508',
\ 'darkgray' : '#A9A9A9',
\ 'darkgreen' : '#006400',
\ 'darkgrey' : '#A9A9A9',
\ 'darkkhaki' : '#BDB76B',
\ 'darkmagenta' : '#8B008B',
\ 'darkolivegreen' : '#556B2F',
\ 'darkolivegreen1' : '#CAFF70',
\ 'darkolivegreen2' : '#BCEE68',
\ 'darkolivegreen3' : '#A2CD5A',
\ 'darkolivegreen4' : '#6E8B3D',
\ 'darkorange' : '#FF8C00',
\ 'darkorange1' : '#FF7F00',
\ 'darkorange2' : '#EE7600',
\ 'darkorange3' : '#CD6600',
\ 'darkorange4' : '#8B4500',
\ 'darkorchid' : '#9932CC',
\ 'darkorchid1' : '#BF3EFF',
\ 'darkorchid2' : '#B23AEE',
\ 'darkorchid3' : '#9A32CD',
\ 'darkorchid4' : '#68228B',
\ 'darkred' : '#8B0000',
\ 'darksalmon' : '#E9967A',
\ 'darkseagreen' : '#8FBC8F',
\ 'darkseagreen1' : '#C1FFC1',
\ 'darkseagreen2' : '#B4EEB4',
\ 'darkseagreen3' : '#9BCD9B',
\ 'darkseagreen4' : '#698B69',
\ 'darkslateblue' : '#483D8B',
\ 'darkslategray' : '#2F4F4F',
\ 'darkslategray1' : '#97FFFF',
\ 'darkslategray2' : '#8DEEEE',
\ 'darkslategray3' : '#79CDCD',
\ 'darkslategray4' : '#528B8B',
\ 'darkslategrey' : '#2F4F4F',
\ 'darkturquoise' : '#00CED1',
\ 'darkviolet' : '#9400D3',
\ 'darkyellow' : '#BBBB00',
\ 'deep pink' : '#FF1493',
\ 'deep sky blue' : '#00BFFF',
\ 'deeppink' : '#FF1493',
\ 'deeppink1' : '#FF1493',
\ 'deeppink2' : '#EE1289',
\ 'deeppink3' : '#CD1076',
\ 'deeppink4' : '#8B0A50',
\ 'deepskyblue' : '#00BFFF',
\ 'deepskyblue1' : '#00BFFF',
\ 'deepskyblue2' : '#00B2EE',
\ 'deepskyblue3' : '#009ACD',
\ 'deepskyblue4' : '#00688B',
\ 'dim gray' : '#696969',
\ 'dim grey' : '#696969',
\ 'dimgray' : '#696969',
\ 'dimgrey' : '#696969',
\ 'dodger blue' : '#1E90FF',
\ 'dodgerblue' : '#1E90FF',
\ 'dodgerblue1' : '#1E90FF',
\ 'dodgerblue2' : '#1C86EE',
\ 'dodgerblue3' : '#1874CD',
\ 'dodgerblue4' : '#104E8B',
\ 'firebrick' : '#B22222',
\ 'firebrick1' : '#FF3030',
\ 'firebrick2' : '#EE2C2C',
\ 'firebrick3' : '#CD2626',
\ 'firebrick4' : '#8B1A1A',
\ 'floral white' : '#FFFAF0',
\ 'floralwhite' : '#FFFAF0',
\ 'forest green' : '#228B22',
\ 'forestgreen' : '#228B22',
\ 'gainsboro' : '#DCDCDC',
\ 'ghost white' : '#F8F8FF',
\ 'ghostwhite' : '#F8F8FF',
\ 'gold' : '#FFD700',
\ 'gold1' : '#FFD700',
\ 'gold2' : '#EEC900',
\ 'gold3' : '#CDAD00',
\ 'gold4' : '#8B7500',
\ 'goldenrod' : '#DAA520',
\ 'goldenrod1' : '#FFC125',
\ 'goldenrod2' : '#EEB422',
\ 'goldenrod3' : '#CD9B1D',
\ 'goldenrod4' : '#8B6914',
\ 'gray' : '#BEBEBE',
\ 'gray0' : '#000000',
\ 'gray1' : '#030303',
\ 'gray10' : '#1A1A1A',
\ 'gray100' : '#FFFFFF',
\ 'gray11' : '#1C1C1C',
\ 'gray12' : '#1F1F1F',
\ 'gray13' : '#212121',
\ 'gray14' : '#242424',
\ 'gray15' : '#262626',
\ 'gray16' : '#292929',
\ 'gray17' : '#2B2B2B',
\ 'gray18' : '#2E2E2E',
\ 'gray19' : '#303030',
\ 'gray2' : '#050505',
\ 'gray20' : '#333333',
\ 'gray21' : '#363636',
\ 'gray22' : '#383838',
\ 'gray23' : '#3B3B3B',
\ 'gray24' : '#3D3D3D',
\ 'gray25' : '#404040',
\ 'gray26' : '#424242',
\ 'gray27' : '#454545',
\ 'gray28' : '#474747',
\ 'gray29' : '#4A4A4A',
\ 'gray3' : '#080808',
\ 'gray30' : '#4D4D4D',
\ 'gray31' : '#4F4F4F',
\ 'gray32' : '#525252',
\ 'gray33' : '#545454',
\ 'gray34' : '#575757',
\ 'gray35' : '#595959',
\ 'gray36' : '#5C5C5C',
\ 'gray37' : '#5E5E5E',
\ 'gray38' : '#616161',
\ 'gray39' : '#636363',
\ 'gray4' : '#0A0A0A',
\ 'gray40' : '#666666',
\ 'gray41' : '#696969',
\ 'gray42' : '#6B6B6B',
\ 'gray43' : '#6E6E6E',
\ 'gray44' : '#707070',
\ 'gray45' : '#737373',
\ 'gray46' : '#757575',
\ 'gray47' : '#787878',
\ 'gray48' : '#7A7A7A',
\ 'gray49' : '#7D7D7D',
\ 'gray5' : '#0D0D0D',
\ 'gray50' : '#7F7F7F',
\ 'gray51' : '#828282',
\ 'gray52' : '#858585',
\ 'gray53' : '#878787',
\ 'gray54' : '#8A8A8A',
\ 'gray55' : '#8C8C8C',
\ 'gray56' : '#8F8F8F',
\ 'gray57' : '#919191',
\ 'gray58' : '#949494',
\ 'gray59' : '#969696',
\ 'gray6' : '#0F0F0F',
\ 'gray60' : '#999999',
\ 'gray61' : '#9C9C9C',
\ 'gray62' : '#9E9E9E',
\ 'gray63' : '#A1A1A1',
\ 'gray64' : '#A3A3A3',
\ 'gray65' : '#A6A6A6',
\ 'gray66' : '#A8A8A8',
\ 'gray67' : '#ABABAB',
\ 'gray68' : '#ADADAD',
\ 'gray69' : '#B0B0B0',
\ 'gray7' : '#121212',
\ 'gray70' : '#B3B3B3',
\ 'gray71' : '#B5B5B5',
\ 'gray72' : '#B8B8B8',
\ 'gray73' : '#BABABA',
\ 'gray74' : '#BDBDBD',
\ 'gray75' : '#BFBFBF',
\ 'gray76' : '#C2C2C2',
\ 'gray77' : '#C4C4C4',
\ 'gray78' : '#C7C7C7',
\ 'gray79' : '#C9C9C9',
\ 'gray8' : '#141414',
\ 'gray80' : '#CCCCCC',
\ 'gray81' : '#CFCFCF',
\ 'gray82' : '#D1D1D1',
\ 'gray83' : '#D4D4D4',
\ 'gray84' : '#D6D6D6',
\ 'gray85' : '#D9D9D9',
\ 'gray86' : '#DBDBDB',
\ 'gray87' : '#DEDEDE',
\ 'gray88' : '#E0E0E0',
\ 'gray89' : '#E3E3E3',
\ 'gray9' : '#171717',
\ 'gray90' : '#E5E5E5',
\ 'gray91' : '#E8E8E8',
\ 'gray92' : '#EBEBEB',
\ 'gray93' : '#EDEDED',
\ 'gray94' : '#F0F0F0',
\ 'gray95' : '#F2F2F2',
\ 'gray96' : '#F5F5F5',
\ 'gray97' : '#F7F7F7',
\ 'gray98' : '#FAFAFA',
\ 'gray99' : '#FCFCFC',
\ 'green yellow' : '#ADFF2F',
\ 'green' : '#00FF00',
\ 'green1' : '#00FF00',
\ 'green2' : '#00EE00',
\ 'green3' : '#00CD00',
\ 'green4' : '#008B00',
\ 'greenyellow' : '#ADFF2F',
\ 'grey' : '#BEBEBE',
\ 'grey0' : '#000000',
\ 'grey1' : '#030303',
\ 'grey10' : '#1A1A1A',
\ 'grey100' : '#FFFFFF',
\ 'grey11' : '#1C1C1C',
\ 'grey12' : '#1F1F1F',
\ 'grey13' : '#212121',
\ 'grey14' : '#242424',
\ 'grey15' : '#262626',
\ 'grey16' : '#292929',
\ 'grey17' : '#2B2B2B',
\ 'grey18' : '#2E2E2E',
\ 'grey19' : '#303030',
\ 'grey2' : '#050505',
\ 'grey20' : '#333333',
\ 'grey21' : '#363636',
\ 'grey22' : '#383838',
\ 'grey23' : '#3B3B3B',
\ 'grey24' : '#3D3D3D',
\ 'grey25' : '#404040',
\ 'grey26' : '#424242',
\ 'grey27' : '#454545',
\ 'grey28' : '#474747',
\ 'grey29' : '#4A4A4A',
\ 'grey3' : '#080808',
\ 'grey30' : '#4D4D4D',
\ 'grey31' : '#4F4F4F',
\ 'grey32' : '#525252',
\ 'grey33' : '#545454',
\ 'grey34' : '#575757',
\ 'grey35' : '#595959',
\ 'grey36' : '#5C5C5C',
\ 'grey37' : '#5E5E5E',
\ 'grey38' : '#616161',
\ 'grey39' : '#636363',
\ 'grey4' : '#0A0A0A',
\ 'grey40' : '#666666',
\ 'grey41' : '#696969',
\ 'grey42' : '#6B6B6B',
\ 'grey43' : '#6E6E6E',
\ 'grey44' : '#707070',
\ 'grey45' : '#737373',
\ 'grey46' : '#757575',
\ 'grey47' : '#787878',
\ 'grey48' : '#7A7A7A',
\ 'grey49' : '#7D7D7D',
\ 'grey5' : '#0D0D0D',
\ 'grey50' : '#7F7F7F',
\ 'grey51' : '#828282',
\ 'grey52' : '#858585',
\ 'grey53' : '#878787',
\ 'grey54' : '#8A8A8A',
\ 'grey55' : '#8C8C8C',
\ 'grey56' : '#8F8F8F',
\ 'grey57' : '#919191',
\ 'grey58' : '#949494',
\ 'grey59' : '#969696',
\ 'grey6' : '#0F0F0F',
\ 'grey60' : '#999999',
\ 'grey61' : '#9C9C9C',
\ 'grey62' : '#9E9E9E',
\ 'grey63' : '#A1A1A1',
\ 'grey64' : '#A3A3A3',
\ 'grey65' : '#A6A6A6',
\ 'grey66' : '#A8A8A8',
\ 'grey67' : '#ABABAB',
\ 'grey68' : '#ADADAD',
\ 'grey69' : '#B0B0B0',
\ 'grey7' : '#121212',
\ 'grey70' : '#B3B3B3',
\ 'grey71' : '#B5B5B5',
\ 'grey72' : '#B8B8B8',
\ 'grey73' : '#BABABA',
\ 'grey74' : '#BDBDBD',
\ 'grey75' : '#BFBFBF',
\ 'grey76' : '#C2C2C2',
\ 'grey77' : '#C4C4C4',
\ 'grey78' : '#C7C7C7',
\ 'grey79' : '#C9C9C9',
\ 'grey8' : '#141414',
\ 'grey80' : '#CCCCCC',
\ 'grey81' : '#CFCFCF',
\ 'grey82' : '#D1D1D1',
\ 'grey83' : '#D4D4D4',
\ 'grey84' : '#D6D6D6',
\ 'grey85' : '#D9D9D9',
\ 'grey86' : '#DBDBDB',
\ 'grey87' : '#DEDEDE',
\ 'grey88' : '#E0E0E0',
\ 'grey89' : '#E3E3E3',
\ 'grey9' : '#171717',
\ 'grey90' : '#E5E5E5',
\ 'grey91' : '#E8E8E8',
\ 'grey92' : '#EBEBEB',
\ 'grey93' : '#EDEDED',
\ 'grey94' : '#F0F0F0',
\ 'grey95' : '#F2F2F2',
\ 'grey96' : '#F5F5F5',
\ 'grey97' : '#F7F7F7',
\ 'grey98' : '#FAFAFA',
\ 'grey99' : '#FCFCFC',
\ 'honeydew' : '#F0FFF0',
\ 'honeydew1' : '#F0FFF0',
\ 'honeydew2' : '#E0EEE0',
\ 'honeydew3' : '#C1CDC1',
\ 'honeydew4' : '#838B83',
\ 'hot pink' : '#FF69B4',
\ 'hotpink' : '#FF69B4',
\ 'hotpink1' : '#FF6EB4',
\ 'hotpink2' : '#EE6AA7',
\ 'hotpink3' : '#CD6090',
\ 'hotpink4' : '#8B3A62',
\ 'indian red' : '#CD5C5C',
\ 'indianred' : '#CD5C5C',
\ 'indianred1' : '#FF6A6A',
\ 'indianred2' : '#EE6363',
\ 'indianred3' : '#CD5555',
\ 'indianred4' : '#8B3A3A',
\ 'ivory' : '#FFFFF0',
\ 'ivory1' : '#FFFFF0',
\ 'ivory2' : '#EEEEE0',
\ 'ivory3' : '#CDCDC1',
\ 'ivory4' : '#8B8B83',
\ 'khaki' : '#F0E68C',
\ 'khaki1' : '#FFF68F',
\ 'khaki2' : '#EEE685',
\ 'khaki3' : '#CDC673',
\ 'khaki4' : '#8B864E',
\ 'lavender blush' : '#FFF0F5',
\ 'lavender' : '#E6E6FA',
\ 'lavenderblush' : '#FFF0F5',
\ 'lavenderblush1' : '#FFF0F5',
\ 'lavenderblush2' : '#EEE0E5',
\ 'lavenderblush3' : '#CDC1C5',
\ 'lavenderblush4' : '#8B8386',
\ 'lawn green' : '#7CFC00',
\ 'lawngreen' : '#7CFC00',
\ 'lemon chiffon' : '#FFFACD',
\ 'lemonchiffon' : '#FFFACD',
\ 'lemonchiffon1' : '#FFFACD',
\ 'lemonchiffon2' : '#EEE9BF',
\ 'lemonchiffon3' : '#CDC9A5',
\ 'lemonchiffon4' : '#8B8970',
\ 'light blue' : '#ADD8E6',
\ 'light coral' : '#F08080',
\ 'light cyan' : '#E0FFFF',
\ 'light goldenrod yellow' : '#FAFAD2',
\ 'light goldenrod' : '#EEDD82',
\ 'light gray' : '#D3D3D3',
\ 'light green' : '#90EE90',
\ 'light grey' : '#D3D3D3',
\ 'light magenta' : '#FFBBFF',
\ 'light pink' : '#FFB6C1',
\ 'light red' : '#FFBBBB',
\ 'light salmon' : '#FFA07A',
\ 'light sea green' : '#20B2AA',
\ 'light sky blue' : '#87CEFA',
\ 'light slate blue' : '#8470FF',
\ 'light slate gray' : '#778899',
\ 'light slate grey' : '#778899',
\ 'light steel blue' : '#B0C4DE',
\ 'light yellow' : '#FFFFE0',
\ 'lightblue' : '#ADD8E6',
\ 'lightblue1' : '#BFEFFF',
\ 'lightblue2' : '#B2DFEE',
\ 'lightblue3' : '#9AC0CD',
\ 'lightblue4' : '#68838B',
\ 'lightcoral' : '#F08080',
\ 'lightcyan' : '#E0FFFF',
\ 'lightcyan1' : '#E0FFFF',
\ 'lightcyan2' : '#D1EEEE',
\ 'lightcyan3' : '#B4CDCD',
\ 'lightcyan4' : '#7A8B8B',
\ 'lightgoldenrod' : '#EEDD82',
\ 'lightgoldenrod1' : '#FFEC8B',
\ 'lightgoldenrod2' : '#EEDC82',
\ 'lightgoldenrod3' : '#CDBE70',
\ 'lightgoldenrod4' : '#8B814C',
\ 'lightgoldenrodyellow' : '#FAFAD2',
\ 'lightgray' : '#D3D3D3',
\ 'lightgreen' : '#90EE90',
\ 'lightgrey' : '#D3D3D3',
\ 'lightmagenta' : '#FFBBFF',
\ 'lightpink' : '#FFB6C1',
\ 'lightpink1' : '#FFAEB9',
\ 'lightpink2' : '#EEA2AD',
\ 'lightpink3' : '#CD8C95',
\ 'lightpink4' : '#8B5F65',
\ 'lightred' : '#FFBBBB',
\ 'lightsalmon' : '#FFA07A',
\ 'lightsalmon1' : '#FFA07A',
\ 'lightsalmon2' : '#EE9572',
\ 'lightsalmon3' : '#CD8162',
\ 'lightsalmon4' : '#8B5742',
\ 'lightseagreen' : '#20B2AA',
\ 'lightskyblue' : '#87CEFA',
\ 'lightskyblue1' : '#B0E2FF',
\ 'lightskyblue2' : '#A4D3EE',
\ 'lightskyblue3' : '#8DB6CD',
\ 'lightskyblue4' : '#607B8B',
\ 'lightslateblue' : '#8470FF',
\ 'lightslategray' : '#778899',
\ 'lightslategrey' : '#778899',
\ 'lightsteelblue' : '#B0C4DE',
\ 'lightsteelblue1' : '#CAE1FF',
\ 'lightsteelblue2' : '#BCD2EE',
\ 'lightsteelblue3' : '#A2B5CD',
\ 'lightsteelblue4' : '#6E7B8B',
\ 'lightyellow' : '#FFFFE0',
\ 'lightyellow1' : '#FFFFE0',
\ 'lightyellow2' : '#EEEED1',
\ 'lightyellow3' : '#CDCDB4',
\ 'lightyellow4' : '#8B8B7A',
\ 'lime green' : '#32CD32',
\ 'limegreen' : '#32CD32',
\ 'linen' : '#FAF0E6',
\ 'magenta' : '#FF00FF',
\ 'magenta1' : '#FF00FF',
\ 'magenta2' : '#EE00EE',
\ 'magenta3' : '#CD00CD',
\ 'magenta4' : '#8B008B',
\ 'maroon' : '#B03060',
\ 'maroon1' : '#FF34B3',
\ 'maroon2' : '#EE30A7',
\ 'maroon3' : '#CD2990',
\ 'maroon4' : '#8B1C62',
\ 'medium aquamarine' : '#66CDAA',
\ 'medium blue' : '#0000CD',
\ 'medium orchid' : '#BA55D3',
\ 'medium purple' : '#9370DB',
\ 'medium sea green' : '#3CB371',
\ 'medium slate blue' : '#7B68EE',
\ 'medium spring green' : '#00FA9A',
\ 'medium turquoise' : '#48D1CC',
\ 'medium violet red' : '#C71585',
\ 'mediumaquamarine' : '#66CDAA',
\ 'mediumblue' : '#0000CD',
\ 'mediumorchid' : '#BA55D3',
\ 'mediumorchid1' : '#E066FF',
\ 'mediumorchid2' : '#D15FEE',
\ 'mediumorchid3' : '#B452CD',
\ 'mediumorchid4' : '#7A378B',
\ 'mediumpurple' : '#9370DB',
\ 'mediumpurple1' : '#AB82FF',
\ 'mediumpurple2' : '#9F79EE',
\ 'mediumpurple3' : '#8968CD',
\ 'mediumpurple4' : '#5D478B',
\ 'mediumseagreen' : '#3CB371',
\ 'mediumslateblue' : '#7B68EE',
\ 'mediumspringgreen' : '#00FA9A',
\ 'mediumturquoise' : '#48D1CC',
\ 'mediumvioletred' : '#C71585',
\ 'midnight blue' : '#191970',
\ 'midnightblue' : '#191970',
\ 'mint cream' : '#F5FFFA',
\ 'mintcream' : '#F5FFFA',
\ 'misty rose' : '#FFE4E1',
\ 'mistyrose' : '#FFE4E1',
\ 'mistyrose1' : '#FFE4E1',
\ 'mistyrose2' : '#EED5D2',
\ 'mistyrose3' : '#CDB7B5',
\ 'mistyrose4' : '#8B7D7B',
\ 'moccasin' : '#FFE4B5',
\ 'navajo white' : '#FFDEAD',
\ 'navajowhite' : '#FFDEAD',
\ 'navajowhite1' : '#FFDEAD',
\ 'navajowhite2' : '#EECFA1',
\ 'navajowhite3' : '#CDB38B',
\ 'navajowhite4' : '#8B795E',
\ 'navy blue' : '#000080',
\ 'navy' : '#000080',
\ 'navyblue' : '#000080',
\ 'old lace' : '#FDF5E6',
\ 'oldlace' : '#FDF5E6',
\ 'olive drab' : '#6B8E23',
\ 'olivedrab' : '#6B8E23',
\ 'olivedrab1' : '#C0FF3E',
\ 'olivedrab2' : '#B3EE3A',
\ 'olivedrab3' : '#9ACD32',
\ 'olivedrab4' : '#698B22',
\ 'orange red' : '#FF4500',
\ 'orange' : '#FFA500',
\ 'orange1' : '#FFA500',
\ 'orange2' : '#EE9A00',
\ 'orange3' : '#CD8500',
\ 'orange4' : '#8B5A00',
\ 'orangered' : '#FF4500',
\ 'orangered1' : '#FF4500',
\ 'orangered2' : '#EE4000',
\ 'orangered3' : '#CD3700',
\ 'orangered4' : '#8B2500',
\ 'orchid' : '#DA70D6',
\ 'orchid1' : '#FF83FA',
\ 'orchid2' : '#EE7AE9',
\ 'orchid3' : '#CD69C9',
\ 'orchid4' : '#8B4789',
\ 'pale goldenrod' : '#EEE8AA',
\ 'pale green' : '#98FB98',
\ 'pale turquoise' : '#AFEEEE',
\ 'pale violet red' : '#DB7093',
\ 'palegoldenrod' : '#EEE8AA',
\ 'palegreen' : '#98FB98',
\ 'palegreen1' : '#9AFF9A',
\ 'palegreen2' : '#90EE90',
\ 'palegreen3' : '#7CCD7C',
\ 'palegreen4' : '#548B54',
\ 'paleturquoise' : '#AFEEEE',
\ 'paleturquoise1' : '#BBFFFF',
\ 'paleturquoise2' : '#AEEEEE',
\ 'paleturquoise3' : '#96CDCD',
\ 'paleturquoise4' : '#668B8B',
\ 'palevioletred' : '#DB7093',
\ 'palevioletred1' : '#FF82AB',
\ 'palevioletred2' : '#EE799F',
\ 'palevioletred3' : '#CD6889',
\ 'palevioletred4' : '#8B475D',
\ 'papaya whip' : '#FFEFD5',
\ 'papayawhip' : '#FFEFD5',
\ 'peach puff' : '#FFDAB9',
\ 'peachpuff' : '#FFDAB9',
\ 'peachpuff1' : '#FFDAB9',
\ 'peachpuff2' : '#EECBAD',
\ 'peachpuff3' : '#CDAF95',
\ 'peachpuff4' : '#8B7765',
\ 'peru' : '#CD853F',
\ 'pink' : '#FFC0CB',
\ 'pink1' : '#FFB5C5',
\ 'pink2' : '#EEA9B8',
\ 'pink3' : '#CD919E',
\ 'pink4' : '#8B636C',
\ 'plum' : '#DDA0DD',
\ 'plum1' : '#FFBBFF',
\ 'plum2' : '#EEAEEE',
\ 'plum3' : '#CD96CD',
\ 'plum4' : '#8B668B',
\ 'powder blue' : '#B0E0E6',
\ 'powderblue' : '#B0E0E6',
\ 'purple' : '#A020F0',
\ 'purple1' : '#9B30FF',
\ 'purple2' : '#912CEE',
\ 'purple3' : '#7D26CD',
\ 'purple4' : '#551A8B',
\ 'red' : '#FF0000',
\ 'red1' : '#FF0000',
\ 'red2' : '#EE0000',
\ 'red3' : '#CD0000',
\ 'red4' : '#8B0000',
\ 'rosy brown' : '#BC8F8F',
\ 'rosybrown' : '#BC8F8F',
\ 'rosybrown1' : '#FFC1C1',
\ 'rosybrown2' : '#EEB4B4',
\ 'rosybrown3' : '#CD9B9B',
\ 'rosybrown4' : '#8B6969',
\ 'royal blue' : '#4169E1',
\ 'royalblue' : '#4169E1',
\ 'royalblue1' : '#4876FF',
\ 'royalblue2' : '#436EEE',
\ 'royalblue3' : '#3A5FCD',
\ 'royalblue4' : '#27408B',
\ 'saddle brown' : '#8B4513',
\ 'saddlebrown' : '#8B4513',
\ 'salmon' : '#FA8072',
\ 'salmon1' : '#FF8C69',
\ 'salmon2' : '#EE8262',
\ 'salmon3' : '#CD7054',
\ 'salmon4' : '#8B4C39',
\ 'sandy brown' : '#F4A460',
\ 'sandybrown' : '#F4A460',
\ 'sea green' : '#2E8B57',
\ 'seagreen' : '#2E8B57',
\ 'seagreen1' : '#54FF9F',
\ 'seagreen2' : '#4EEE94',
\ 'seagreen3' : '#43CD80',
\ 'seagreen4' : '#2E8B57',
\ 'seashell' : '#FFF5EE',
\ 'seashell1' : '#FFF5EE',
\ 'seashell2' : '#EEE5DE',
\ 'seashell3' : '#CDC5BF',
\ 'seashell4' : '#8B8682',
\ 'sienna' : '#A0522D',
\ 'sienna1' : '#FF8247',
\ 'sienna2' : '#EE7942',
\ 'sienna3' : '#CD6839',
\ 'sienna4' : '#8B4726',
\ 'sky blue' : '#87CEEB',
\ 'skyblue' : '#87CEEB',
\ 'skyblue1' : '#87CEFF',
\ 'skyblue2' : '#7EC0EE',
\ 'skyblue3' : '#6CA6CD',
\ 'skyblue4' : '#4A708B',
\ 'slate blue' : '#6A5ACD',
\ 'slate gray' : '#708090',
\ 'slate grey' : '#708090',
\ 'slateblue' : '#6A5ACD',
\ 'slateblue1' : '#836FFF',
\ 'slateblue2' : '#7A67EE',
\ 'slateblue3' : '#6959CD',
\ 'slateblue4' : '#473C8B',
\ 'slategray' : '#708090',
\ 'slategray1' : '#C6E2FF',
\ 'slategray2' : '#B9D3EE',
\ 'slategray3' : '#9FB6CD',
\ 'slategray4' : '#6C7B8B',
\ 'slategrey' : '#708090',
\ 'snow' : '#FFFAFA',
\ 'snow1' : '#FFFAFA',
\ 'snow2' : '#EEE9E9',
\ 'snow3' : '#CDC9C9',
\ 'snow4' : '#8B8989',
\ 'spring green' : '#00FF7F',
\ 'springgreen' : '#00FF7F',
\ 'springgreen1' : '#00FF7F',
\ 'springgreen2' : '#00EE76',
\ 'springgreen3' : '#00CD66',
\ 'springgreen4' : '#008B45',
\ 'steel blue' : '#4682B4',
\ 'steelblue' : '#4682B4',
\ 'steelblue1' : '#63B8FF',
\ 'steelblue2' : '#5CACEE',
\ 'steelblue3' : '#4F94CD',
\ 'steelblue4' : '#36648B',
\ 'tan' : '#D2B48C',
\ 'tan1' : '#FFA54F',
\ 'tan2' : '#EE9A49',
\ 'tan3' : '#CD853F',
\ 'tan4' : '#8B5A2B',
\ 'thistle' : '#D8BFD8',
\ 'thistle1' : '#FFE1FF',
\ 'thistle2' : '#EED2EE',
\ 'thistle3' : '#CDB5CD',
\ 'thistle4' : '#8B7B8B',
\ 'tomato' : '#FF6347',
\ 'tomato1' : '#FF6347',
\ 'tomato2' : '#EE5C42',
\ 'tomato3' : '#CD4F39',
\ 'tomato4' : '#8B3626',
\ 'turquoise' : '#40E0D0',
\ 'turquoise1' : '#00F5FF',
\ 'turquoise2' : '#00E5EE',
\ 'turquoise3' : '#00C5CD',
\ 'turquoise4' : '#00868B',
\ 'violet red' : '#D02090',
\ 'violet' : '#EE82EE',
\ 'violetred' : '#D02090',
\ 'violetred1' : '#FF3E96',
\ 'violetred2' : '#EE3A8C',
\ 'violetred3' : '#CD3278',
\ 'violetred4' : '#8B2252',
\ 'wheat' : '#F5DEB3',
\ 'wheat1' : '#FFE7BA',
\ 'wheat2' : '#EED8AE',
\ 'wheat3' : '#CDBA96',
\ 'wheat4' : '#8B7E66',
\ 'white smoke' : '#F5F5F5',
\ 'white' : '#FFFFFF',
\ 'whitesmoke' : '#F5F5F5',
\ 'yellow green' : '#9ACD32',
\ 'yellow' : '#FFFF00',
\ 'yellow1' : '#FFFF00',
\ 'yellow2' : '#EEEE00',
\ 'yellow3' : '#CDCD00',
\ 'yellow4' : '#8B8B00',
\ 'yellowgreen' : '#9ACD32',
\}
if has_key(l:color_list, l:color_name)
let l:hex_code = l:color_list[l:color_name]
endif
return l:hex_code
endfunction

View File

@ -0,0 +1,284 @@
" Author: Nate Kane <nathanaelkane AT gmail DOT com>
" Homepage: http://github.com/nathanaelkane/vim-indent-guides
"
" Toggles the indent guides on and off.
"
function! indent_guides#toggle()
call indent_guides#init_matches()
if empty(w:indent_guides_matches)
call indent_guides#enable()
else
call indent_guides#disable()
endif
endfunction
"
" Called from autocmds, keeps indent guides enabled or disabled when entering
" other buffers and windows.
"
function! indent_guides#process_autocmds()
if g:indent_guides_autocmds_enabled
call indent_guides#enable()
else
call indent_guides#disable()
end
endfunction
"
" Enables the indent guides for the current buffer and any other buffer upon
" entering it.
"
function! indent_guides#enable()
let g:indent_guides_autocmds_enabled = 1
if &diff || indent_guides#exclude_filetype()
call indent_guides#clear_matches()
return
end
call indent_guides#init_script_vars()
call indent_guides#highlight_colors()
call indent_guides#clear_matches()
" loop through each indent level and define a highlight pattern
" will automagically figure out whether to use tabs or spaces
for l:level in range(s:start_level, s:indent_levels)
let l:group = 'IndentGuides' . ((l:level % 2 == 0) ? 'Even' : 'Odd')
let l:column_start = (l:level - 1) * s:indent_size + 1
let l:soft_pattern = indent_guides#indent_highlight_pattern(g:indent_guides_soft_pattern, l:column_start, s:guide_size)
let l:hard_pattern = indent_guides#indent_highlight_pattern('\t', l:column_start, s:indent_size)
" define the higlight patterns and add to matches list
if g:indent_guides_space_guides
call add(w:indent_guides_matches, matchadd(l:group, l:soft_pattern))
end
call add(w:indent_guides_matches, matchadd(l:group, l:hard_pattern))
endfor
endfunction
"
" Disables the indent guides for the current buffer and any other buffer upon
" entering it.
"
function! indent_guides#disable()
let g:indent_guides_autocmds_enabled = 0
call indent_guides#clear_matches()
endfunction
"
" Clear all highlight matches for the current window.
"
function! indent_guides#clear_matches()
call indent_guides#init_matches()
if !empty(w:indent_guides_matches)
let l:index = 0
for l:match_id in w:indent_guides_matches
try
call matchdelete(l:match_id)
catch /E803:/
" Do nothing
endtry
call remove(w:indent_guides_matches, l:index)
let l:index += l:index
endfor
endif
endfunction
"
" Automagically calculates and defines the indent highlight colors.
"
function! indent_guides#highlight_colors()
if s:auto_colors
if has('gui_running')
call indent_guides#gui_highlight_colors()
else
call indent_guides#basic_highlight_colors()
endif
endif
endfunction
"
" Defines some basic indent highlight colors that work for Terminal Vim and
" gVim when colors can't be automatically calculated.
"
function! indent_guides#basic_highlight_colors()
let l:cterm_colors = (&g:background == 'dark') ? ['darkgrey', 'black'] : ['lightgrey', 'white']
let l:gui_colors = (&g:background == 'dark') ? ['grey15', 'grey30'] : ['grey70', 'grey85']
exe 'hi IndentGuidesEven guibg=' . l:gui_colors[0] . ' guifg=' . l:gui_colors[1] . ' ctermbg=' . l:cterm_colors[0] . ' ctermfg=' . l:cterm_colors[1]
exe 'hi IndentGuidesOdd guibg=' . l:gui_colors[1] . ' guifg=' . l:gui_colors[0] . ' ctermbg=' . l:cterm_colors[1] . ' ctermfg=' . l:cterm_colors[0]
endfunction
"
" Automagically calculates and defines the indent highlight colors for gui
" vim.
"
function! indent_guides#gui_highlight_colors()
let l:hi_normal_guibg = ''
" capture the backgroud color from the normal highlight
if s:hi_normal =~ s:color_hex_bg_pat
" hex color code is being used, eg. '#FFFFFF'
let l:hi_normal_guibg = matchstr(s:hi_normal, s:color_hex_bg_pat)
elseif s:hi_normal =~ s:color_name_bg_pat
" color name is being used, eg. 'white'
let l:color_name = matchstr(s:hi_normal, s:color_name_bg_pat)
let l:hi_normal_guibg = color_helper#color_name_to_hex(l:color_name)
else
" background color could not be detected, default to basic colors
call indent_guides#basic_highlight_colors()
endif
if l:hi_normal_guibg =~ s:color_hex_pat
" calculate the highlight background colors
let l:hi_odd_bg = indent_guides#lighten_or_darken_color(l:hi_normal_guibg)
let l:hi_even_bg = indent_guides#lighten_or_darken_color(l:hi_odd_bg)
" define the new highlights
exe 'hi IndentGuidesOdd guibg=' . l:hi_odd_bg . ' guifg=' . l:hi_even_bg
exe 'hi IndentGuidesEven guibg=' . l:hi_even_bg . ' guifg=' . l:hi_odd_bg
end
endfunction
"
" Takes a color and darkens or lightens it depending on whether a dark or light
" colorscheme is being used.
"
function! indent_guides#lighten_or_darken_color(color)
let l:new_color = ''
if (&g:background == 'dark')
let l:new_color = color_helper#hex_color_lighten(a:color, s:change_percent)
else
let l:new_color = color_helper#hex_color_darken (a:color, s:change_percent)
endif
return l:new_color
endfunction
"
" Define default highlights.
"
function! indent_guides#define_default_highlights()
hi default clear IndentGuidesOdd
hi default clear IndentGuidesEven
endfunction
"
" Init the w:indent_guides_matches variable.
"
function! indent_guides#init_matches()
let w:indent_guides_matches = exists('w:indent_guides_matches') ? w:indent_guides_matches : []
endfunction
"
" We need to initialize these vars every time a buffer is entered while the
" plugin is enabled.
"
function! indent_guides#init_script_vars()
if &l:shiftwidth > 0 && &l:expandtab
let s:indent_size = &l:shiftwidth
else
let s:indent_size = &l:tabstop
endif
let s:guide_size = indent_guides#calculate_guide_size()
let s:hi_normal = indent_guides#capture_highlight('Normal')
" remove 'font=<value>' from the s:hi_normal string (only seems to happen on Vim startup in Windows)
let s:hi_normal = substitute(s:hi_normal, ' font=[A-Za-z0-9:]\+', "", "")
" shortcuts to the global variables - this makes the code easier to read
let s:debug = g:indent_guides_debug
let s:indent_levels = g:indent_guides_indent_levels
let s:auto_colors = g:indent_guides_auto_colors
let s:color_hex_pat = g:indent_guides_color_hex_pattern
let s:color_hex_bg_pat = g:indent_guides_color_hex_guibg_pattern
let s:color_name_bg_pat = g:indent_guides_color_name_guibg_pattern
let s:start_level = g:indent_guides_start_level
" str2float not available in vim versions <= 7.1
if has('float')
let s:change_percent = g:indent_guides_color_change_percent / str2float('100.0')
else
let s:change_percent = g:indent_guides_color_change_percent / 100.0
endif
if s:debug
echo 's:indent_size = ' . s:indent_size
echo 's:guide_size = ' . s:guide_size
echo 's:hi_normal = ' . s:hi_normal
echo 's:indent_levels = ' . s:indent_levels
echo 's:auto_colors = ' . s:auto_colors
echo 's:change_percent = ' . string(s:change_percent)
echo 's:color_hex_pat = ' . s:color_hex_pat
echo 's:color_hex_bg_pat = ' . s:color_hex_bg_pat
echo 's:color_name_bg_pat = ' . s:color_name_bg_pat
echo 's:start_level = ' . s:start_level
endif
endfunction
"
" Calculate the indent guide size. Ensures the guide size is less than or
" equal to the actual indent size, otherwise some weird things can occur.
"
" NOTE: Currently, this only works when soft-tabs are being used.
"
function! indent_guides#calculate_guide_size()
let l:guide_size = g:indent_guides_guide_size
if l:guide_size == 0 || l:guide_size > s:indent_size
let l:guide_size = s:indent_size
endif
return l:guide_size
endfunction
"
" Captures and returns the output of highlight group definitions.
"
" Example: indent_guides#capture_highlight('normal')
" Returns: 'Normal xxx guifg=#323232 guibg=#ffffff'
"
function! indent_guides#capture_highlight(group_name)
redir => l:output
exe "silent hi " . a:group_name
redir END
let l:output = substitute(l:output, "\n", "", "")
return l:output
endfunction
"
" Returns a regex pattern for highlighting an indent level.
"
" Example: indent_guides#indent_highlight_pattern(' ', 1, 4)
" Returns: /^ *\%1v\zs *\%5v\ze/
"
" Example: indent_guides#indent_highlight_pattern('\s', 5, 2)
" Returns: /^\s*\%5v\zs\s*\%7v\ze/
"
" Example: indent_guides#indent_highlight_pattern('\t', 9, 2)
" Returns: /^\t*\%9v\zs\t*\%11v\ze/
"
function! indent_guides#indent_highlight_pattern(indent_pattern, column_start, indent_size)
let l:pattern = '^' . a:indent_pattern . '*\%' . a:column_start . 'v\zs'
let l:pattern .= a:indent_pattern . '*\%' . (a:column_start + a:indent_size) . 'v'
let l:pattern .= '\ze'
return l:pattern
endfunction
"
" Detect if any of the buffer filetypes should be excluded.
"
function! indent_guides#exclude_filetype()
for ft in split(&ft, '\.')
if index(g:indent_guides_exclude_filetypes, ft) > -1
return 1
end
endfor
return 0
endfunction

View File

@ -0,0 +1,339 @@
*indent_guides.txt* A plugin for visually displaying indent levels in Vim.
*indent-guides*
____ __ __ ______ _ __
/ _/____ ____/ /___ ____ / /_ / ____/__ __(_)____/ /___ _____
/ / / __ \/ __ // _ \/ __ \/ __/ / / __ / / / / // __ // _ \/ ___/
_/ / / / / / /_/ // __/ / / / /_ / /_/ // /_/ / // /_/ // __(__ )
/___//_/ /_/\__,_/ \___/_/ /_/\__/ \____/ \__,_/_/ \__,_/ \___/____/
Author: Nate Kane <nathanaelkane AT gmail DOT com>
Version: 1.7
Last Change: 07 Mar 2013
==============================================================================
CONTENTS *indent-guides-contents*
1. Introduction.......................... |indent-guides-introduction|
2. Commands.............................. |indent-guides-commands|
3. Options............................... |indent-guides-options|
4. Mappings.............................. |indent-guides-mappings|
5. Terminal Vim.......................... |indent-guides-terminal-vim|
6. About................................. |indent-guides-about|
7. Changelog............................. |indent-guides-changelog|
8. License............................... |indent-guides-license|
==============================================================================
1. INTRODUCTION *indent-guides-introduction*
Indent Guides is a plugin for visually displaying indent levels in Vim.
This plugin should work with gVim out of the box, no configuration needed.
Features:~
* Can detect both tab and space indent styles.
* Automatically inspects your colorscheme and picks appropriate colors (gVim
only).
* Will highlight indent levels with alternating colors.
* Full support for gVim and basic support for Terminal Vim.
* Seems to work on Windows gVim 7.3 (haven't done any extensive tests
though).
* Customizable size for indent guides, eg. skinny guides (soft-tabs only).
* Customizable start indent level.
* Highlight support for files with a mixture of tab and space indent styles.
==============================================================================
2. COMMANDS *indent-guides-commands*
------------------------------------------------------------------------------
:IndentGuidesToggle *:IndentGuidesToggle*
Toggles the indent guides on and off.
------------------------------------------------------------------------------
:IndentGuidesEnable *:IndentGuidesEnable*
Enables the indent guides for the current buffer and any other buffer upon
entering it.
------------------------------------------------------------------------------
:IndentGuidesDisable *:IndentGuidesDisable*
Disables the indent guides for the current buffer and any other buffer upon
entering it.
==============================================================================
3. OPTIONS *indent-guides-options*
------------------------------------------------------------------------------
*'indent_guides_indent_levels'*
Use this option to control how many indent levels to display guides for.
Default: 30. Values: integer.
>
let g:indent_guides_indent_levels = 30
<
------------------------------------------------------------------------------
*'indent_guides_auto_colors'*
Use this option to control whether or not the plugin automatically calculates
the highlight colors. Will use the current colorscheme's background color as a
base color.
Default: 1. Values: 0 or 1.
>
let g:indent_guides_auto_colors = 1
<
If you set this option to 0, be sure to manually define some highlight colors
in an autocmd.
>
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=3
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=4
<
Alternatively you can add the following lines to your colorscheme file.
>
hi IndentGuidesOdd guibg=red ctermbg=3
hi IndentGuidesEven guibg=green ctermbg=4
<
------------------------------------------------------------------------------
*'indent_guides_color_change_percent'*
Use this option to control the percent at which the highlight colors will be
lightened or darkened.
Default: 10 (10%). Values: between 0 and 100.
>
let g:indent_guides_color_change_percent = 10
<
------------------------------------------------------------------------------
*'indent_guides_guide_size'*
Use this option to customize the size of the indent guide. By default the
value is set to 0, which will set the guide size to be the same as the
|shiftwidth|. Setting this value to be larger than the |shiftwidth| is essentially
the same as setting it to 0.
A common use of this setting is to create skinny indent guides, which look
great with a |shiftwidth| of 4 or more.
NOTE: This option only works for soft-tabs (spaces) and not hard-tabs.
Default: 0. Values: between 0 and |shiftwidth|.
>
let g:indent_guides_guide_size = 1
<
------------------------------------------------------------------------------
*'indent_guides_start_level'*
Use this option to control which indent level to start showing guides from.
Default: 1. Values: between 1 and g:|indent_guides_indent_levels|.
>
let g:indent_guides_start_level = 2
<
------------------------------------------------------------------------------
*'indent_guides_space_guides'*
Use this option to control whether the plugin considers spaces as indention.
Default: 1. Values: 0 or 1.
>
let g:indent_guides_space_guides = 0
<
------------------------------------------------------------------------------
*'indent_guides_soft_pattern'*
Use this option to explicitly specify a pattern for soft indentation. For
example to match spaces only in the beginning of line use ' ' pattern.
Default: '\s'. Values: Vim regexp.
>
let g:indent_guides_soft_pattern = ' '
<
------------------------------------------------------------------------------
*'indent_guides_enable_on_vim_startup'*
Use this option to control whether the plugin is enabled on Vim startup.
Default: 0. Values: 0 or 1.
>
let g:indent_guides_enable_on_vim_startup = 0
<
------------------------------------------------------------------------------
*'indent_guides_exclude_filetypes'*
Use this option to specify a list of filetypes to disable the plugin for.
Default: ['help']. Values: list of strings.
>
let g:indent_guides_exclude_filetypes = ['help', 'nerdtree']
<
------------------------------------------------------------------------------
*'indent_guides_default_mapping'*
Use this option to control whether the default mapping (<Leader>ig) gets set.
Default: 1. Values: 0 or 1.
>
let g:indent_guides_default_mapping = 0
<
==============================================================================
4. MAPPINGS *indent-guides-mappings*
The default mapping for toggling indent guides is <Leader>ig. You can easily
map it to other keys. For example:
>
:nmap <silent> <Leader>ig <Plug>IndentGuidesToggle
<
You can also map some other commands that are not mapped by default. For
example:
>
:nmap <silent> <Leader>ie <Plug>IndentGuidesEnable
:nmap <silent> <Leader>id <Plug>IndentGuidesDisable
<
==============================================================================
5. TERMINAL VIM *indent-guides-terminal-vim*
At the moment Terminal Vim only has basic support. This means is that colors
won't be automatically calculated based on your colorscheme. Instead, some
preset colors are used depending on whether `background` is set to `dark` or
`light`.
When `set background=dark` is used, the following highlight colors will be
defined:
>
hi IndentGuidesOdd ctermbg=black
hi IndentGuidesEven ctermbg=darkgrey
<
Alternatively, when `set background=light` is used, the following highlight
colors will be defined:
>
hi IndentGuidesOdd ctermbg=white
hi IndentGuidesEven ctermbg=lightgrey
<
If for some reason it's incorrectly defining light highlight colors instead of
dark ones or vice versa, the first thing you should check is that the
`background` value is being set correctly for your colorscheme. Sometimes it's
best to manually set the `background` value in your `.vimrc`, for example:
>
colorscheme desert256
set background=dark
<
Alternatively you can manually setup the highlight colors yourself, see
|indent_guides_auto_colors| for an example.
==============================================================================
6. ABOUT *indent-guides-about*
Why did I build this plugin?~
* I believe indent guides make nested code easier to read and understand.
* Other editors have them and it's high time Vim did.
* None of the existing indent guide plugins on the market suited my needs.
* I wanted to learn me some VimL.
Links:~
* Github: https://github.com/nathanaelkane/vim-indent-guides
* Bugs & Issues: https://github.com/nathanaelkane/vim-indent-guides/issues
Credits:~
* Matt Wozniski (godlygeek) for letting me use the list of color names and
hex codes from his CSApprox plugin.
Contact:~
* Twitter: @nathanaelkane
* Email: <nathanaelkane AT gmail DOT com>
Bug reports, feedback, suggestions etc are welcomed.
==============================================================================
7. CHANGELOG *indent-guides-changelog*
1.8 (pending release)~
* Added option g:|indent_guides_soft_pattern| to control the pattern for
soft indentation (thanks @sergey-vlasov).
* Added option g:|indent_guides_default_mapping| to control whether the
default mapping (<Leader>ig) gets set (thanks @suy).
* Set size of indent guide to `tabstop` value when `shiftwidth=0` or
`noexpandtab` is used (thanks @darkfeline and @wilywampa).
1.7~
* Added way to override the default mapping (thanks @xuhdev).
* Added option g:|indent_guides_exclude_filetypes| to specify a list of
filetypes to disable the plugin for.
* Disable the plugin when in a diff.
* Various bug fixes.
1.6~
* Added option g:|indent_guides_space_guides| to control whether spaces are
considered as indention (thanks @scoz).
* Added 'doc/tags' to gitignore (thanks @lenniboy).
* Fixed E803 ID not found spam (thanks @mutewinter).
* Fixed str2float issue with Vim 7.1 (thanks @acx0).
1.5~
* Added highlight support for files with a mixture of tab and space indent
styles (thanks @graywh).
* Added -bar to all the :commands so they can chain with other :commands
(thanks @graywh).
* No longer overriding pre-defined custom highlight colors (thanks @graywh).
* Using str2float to work around a float bug in some versions of Vim 7.2
(thanks @voidus).
1.4~
* Added the new plugin option g:|indent_guides_enable_on_vim_startup|.
* Improved Windows support.
1.3~
* Changed the default value of g:|indent_guides_color_change_percent| to 10.
* Added support for gVim themes that don't specify a `hi Normal guibg`
color.
1.2~
* Customizable size for indent guides, eg. skinny guides (soft-tabs only).
* Customizable start indent level.
* Refactored some internal logic.
1.1~
* Added basic support for Terminal Vim. See |indent-guides-terminal-vim| for
more information.
* Cut down on rgb to hex color conversions by adding a big dictionary of
color names and hex codes.
* Various bug fixes.
1.0~
* First public version.
==============================================================================
8. LICENSE *indent-guides-license*
The MIT Licence
http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2010-2013 Nate Kane
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=2:ft=help:norl:

View File

@ -0,0 +1,86 @@
" Author: Nate Kane <nathanaelkane AT gmail DOT com>
" Homepage: http://github.com/nathanaelkane/vim-indent-guides
if exists('g:loaded_indent_guides') || &cp
finish
endif
let g:loaded_indent_guides = 1
call indent_guides#define_default_highlights()
function! s:IndentGuidesToggle()
call indent_guides#toggle()
endfunction
function! s:IndentGuidesEnable()
call indent_guides#enable()
endfunction
function! s:IndentGuidesDisable()
call indent_guides#disable()
endfunction
" Commands
command! -bar IndentGuidesToggle call s:IndentGuidesToggle()
command! -bar IndentGuidesEnable call s:IndentGuidesEnable()
command! -bar IndentGuidesDisable call s:IndentGuidesDisable()
"
" Initializes a given variable to a given value. The variable is only
" initialized if it does not exist prior.
"
function s:InitVariable(var, value)
if !exists(a:var)
if type(a:value) == type("")
exec 'let ' . a:var . ' = ' . "'" . a:value . "'"
else
exec 'let ' . a:var . ' = ' . a:value
endif
endif
endfunction
" Fixed global variables
let g:indent_guides_autocmds_enabled = 0
let g:indent_guides_color_hex_pattern = '#[0-9A-Fa-f]\{6\}'
let g:indent_guides_color_hex_guibg_pattern = 'guibg=\zs' . g:indent_guides_color_hex_pattern . '\ze'
let g:indent_guides_color_name_guibg_pattern = "guibg='\\?\\zs[0-9A-Za-z ]\\+\\ze'\\?"
" Configurable global variables
call s:InitVariable('g:indent_guides_indent_levels', 30)
call s:InitVariable('g:indent_guides_auto_colors', 1)
call s:InitVariable('g:indent_guides_color_change_percent', 10) " ie. 10%
call s:InitVariable('g:indent_guides_guide_size', 0)
call s:InitVariable('g:indent_guides_start_level', 1)
call s:InitVariable('g:indent_guides_enable_on_vim_startup', 0)
call s:InitVariable('g:indent_guides_debug', 0)
call s:InitVariable('g:indent_guides_space_guides', 1)
call s:InitVariable('g:indent_guides_soft_pattern', '\s')
call s:InitVariable('g:indent_guides_default_mapping', 1)
if !exists('g:indent_guides_exclude_filetypes')
let g:indent_guides_exclude_filetypes = ['help']
endif
" Default mapping
if !hasmapto('<Plug>IndentGuidesToggle', 'n') && maparg('<Leader>ig', 'n') == ''
\ && g:indent_guides_default_mapping != 0
nmap <silent><unique> <Leader>ig <Plug>IndentGuidesToggle
endif
" Plug mappings
nnoremap <unique><script> <Plug>IndentGuidesToggle :IndentGuidesToggle<CR>
nnoremap <unique><script> <Plug>IndentGuidesEnable :IndentGuidesEnable<CR>
nnoremap <unique><script> <Plug>IndentGuidesDisable :IndentGuidesDisable<CR>
" Auto commands
augroup indent_guides
autocmd!
if g:indent_guides_enable_on_vim_startup
autocmd VimEnter * :IndentGuidesEnable
endif
autocmd BufEnter,WinEnter,FileType * call indent_guides#process_autocmds()
" Trigger BufEnter and process modelines.
autocmd ColorScheme * doautocmd indent_guides BufEnter
augroup END

View File

@ -0,0 +1,47 @@
vim:tw=78:ts=2:sw=0:et:nolist
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@ -0,0 +1,47 @@
vim:tw=78:ts=2:sw=2:et:nolist
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@ -0,0 +1,47 @@
vim:tw=78:ts=2:sw=2:noet:nolist
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@ -0,0 +1,24 @@
vim:tw=78:ts=2:sw=4:noet:nolist
test
test
test
test
test
test
test
test
test
test test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@ -0,0 +1,47 @@
vim:tw=78:ts=4:sw=4:et:nolist
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@ -0,0 +1,47 @@
vim:tw=78:ts=4:sw=4:noet:nolist
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@ -0,0 +1,24 @@
vim:tw=78:ts=8:sw=2:noet:nolist
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@ -0,0 +1,47 @@
vim:tw=78:ts=8:sw=8:et:nolist
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@ -0,0 +1,47 @@
vim:tw=78:ts=8:sw=8:noet:nolist
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

View File

@ -0,0 +1,26 @@
# Molokai Color Scheme for Vim
Molokai is a Vim port of the monokai theme for TextMate originally created by Wimer Hazenberg.
By default, it has a dark gray background based on the version created by Hamish Stuart Macpherson for the E editor.
![Gray Background](http://www.winterdom.com/weblog/content/binary/WindowsLiveWriter/MolokaiforVim_8602/molokai_normal_small_3.png)
![Molokai Original](http://www.winterdom.com/weblog/content/binary/WindowsLiveWriter/MolokaiforVim_8602/molokai_original_small_3.png)
256-Color terminals are also supported, though there are some differences with the Gui version. Only the dark gray background style is supported on terminal vim at this time.
## Installation
Copy the file on your .vim/colors folder.
If you prefer the scheme to match the original monokai background color, put this in your .vimrc file:
```
let g:molokai_original = 1
```
There is also an alternative scheme under development for color terminals which attempts to bring the 256 color version as close as possible to the the default (dark) GUI version. To access, add this to your .vimrc:
```
let g:rehash256 = 1
```

View File

@ -0,0 +1,276 @@
" Vim color file
"
" Author: Tomas Restrepo <tomas@winterdom.com>
" https://github.com/tomasr/molokai
"
" Note: Based on the Monokai theme for TextMate
" by Wimer Hazenberg and its darker variant
" by Hamish Stuart Macpherson
"
hi clear
if version > 580
" no guarantees for version 5.8 and below, but this makes it stop
" complaining
hi clear
if exists("syntax_on")
syntax reset
endif
endif
let g:colors_name="molokai"
if exists("g:molokai_original")
let s:molokai_original = g:molokai_original
else
let s:molokai_original = 0
endif
hi Boolean guifg=#AE81FF
hi Character guifg=#E6DB74
hi Number guifg=#AE81FF
hi String guifg=#E6DB74
hi Conditional guifg=#F92672 gui=bold
hi Constant guifg=#AE81FF gui=bold
hi Cursor guifg=#000000 guibg=#F8F8F0
hi iCursor guifg=#000000 guibg=#F8F8F0
hi Debug guifg=#BCA3A3 gui=bold
hi Define guifg=#66D9EF
hi Delimiter guifg=#8F8F8F
hi DiffAdd guibg=#13354A
hi DiffChange guifg=#89807D guibg=#4C4745
hi DiffDelete guifg=#960050 guibg=#1E0010
hi DiffText guibg=#4C4745 gui=italic,bold
hi Directory guifg=#A6E22E gui=bold
hi Error guifg=#E6DB74 guibg=#1E0010
hi ErrorMsg guifg=#F92672 guibg=#232526 gui=bold
hi Exception guifg=#A6E22E gui=bold
hi Float guifg=#AE81FF
hi FoldColumn guifg=#465457 guibg=#000000
hi Folded guifg=#465457 guibg=#000000
hi Function guifg=#A6E22E
hi Identifier guifg=#FD971F
hi Ignore guifg=#808080 guibg=bg
hi IncSearch guifg=#C4BE89 guibg=#000000
hi Keyword guifg=#F92672 gui=bold
hi Label guifg=#E6DB74 gui=none
hi Macro guifg=#C4BE89 gui=italic
hi SpecialKey guifg=#66D9EF gui=italic
hi MatchParen guifg=#000000 guibg=#FD971F gui=bold
hi ModeMsg guifg=#E6DB74
hi MoreMsg guifg=#E6DB74
hi Operator guifg=#F92672
" complete menu
hi Pmenu guifg=#66D9EF guibg=#000000
hi PmenuSel guibg=#808080
hi PmenuSbar guibg=#080808
hi PmenuThumb guifg=#66D9EF
hi PreCondit guifg=#A6E22E gui=bold
hi PreProc guifg=#A6E22E
hi Question guifg=#66D9EF
hi Repeat guifg=#F92672 gui=bold
hi Search guifg=#000000 guibg=#FFE792
" marks
hi SignColumn guifg=#A6E22E guibg=#232526
hi SpecialChar guifg=#F92672 gui=bold
hi SpecialComment guifg=#7E8E91 gui=bold
hi Special guifg=#66D9EF guibg=bg gui=italic
if has("spell")
hi SpellBad guisp=#FF0000 gui=undercurl
hi SpellCap guisp=#7070F0 gui=undercurl
hi SpellLocal guisp=#70F0F0 gui=undercurl
hi SpellRare guisp=#FFFFFF gui=undercurl
endif
hi Statement guifg=#F92672 gui=bold
hi StatusLine guifg=#455354 guibg=fg
hi StatusLineNC guifg=#808080 guibg=#080808
hi StorageClass guifg=#FD971F gui=italic
hi Structure guifg=#66D9EF
hi Tag guifg=#F92672 gui=italic
hi Title guifg=#ef5939
hi Todo guifg=#FFFFFF guibg=bg gui=bold
hi Typedef guifg=#66D9EF
hi Type guifg=#66D9EF gui=none
hi Underlined guifg=#808080 gui=underline
hi VertSplit guifg=#808080 guibg=#080808 gui=bold
hi VisualNOS guibg=#403D3D
hi Visual guibg=#403D3D
hi WarningMsg guifg=#FFFFFF guibg=#333333 gui=bold
hi WildMenu guifg=#66D9EF guibg=#000000
hi TabLineFill guifg=#1B1D1E guibg=#1B1D1E
hi TabLine guibg=#1B1D1E guifg=#808080 gui=none
if s:molokai_original == 1
hi Normal guifg=#F8F8F2 guibg=#272822
hi Comment guifg=#75715E
hi CursorLine guibg=#3E3D32
hi CursorLineNr guifg=#FD971F gui=none
hi CursorColumn guibg=#3E3D32
hi ColorColumn guibg=#3B3A32
hi LineNr guifg=#BCBCBC guibg=#3B3A32
hi NonText guifg=#75715E
hi SpecialKey guifg=#75715E
else
hi Normal guifg=#F8F8F2 guibg=#1B1D1E
hi Comment guifg=#7E8E91
hi CursorLine guibg=#293739
hi CursorLineNr guifg=#FD971F gui=none
hi CursorColumn guibg=#293739
hi ColorColumn guibg=#232526
hi LineNr guifg=#465457 guibg=#232526
hi NonText guifg=#465457
hi SpecialKey guifg=#465457
end
"
" Support for 256-color terminal
"
if &t_Co > 255
if s:molokai_original == 1
hi Normal ctermbg=234
hi CursorLine ctermbg=235 cterm=none
hi CursorLineNr ctermfg=208 cterm=none
else
hi Normal ctermfg=252 ctermbg=233
hi CursorLine ctermbg=234 cterm=none
hi CursorLineNr ctermfg=208 cterm=none
endif
hi Boolean ctermfg=135
hi Character ctermfg=144
hi Number ctermfg=135
hi String ctermfg=144
hi Conditional ctermfg=161 cterm=bold
hi Constant ctermfg=135 cterm=bold
hi Cursor ctermfg=16 ctermbg=253
hi Debug ctermfg=225 cterm=bold
hi Define ctermfg=81
hi Delimiter ctermfg=241
hi DiffAdd ctermbg=24
hi DiffChange ctermfg=181 ctermbg=239
hi DiffDelete ctermfg=162 ctermbg=53
hi DiffText ctermbg=102 cterm=bold
hi Directory ctermfg=118 cterm=bold
hi Error ctermfg=219 ctermbg=89
hi ErrorMsg ctermfg=199 ctermbg=16 cterm=bold
hi Exception ctermfg=118 cterm=bold
hi Float ctermfg=135
hi FoldColumn ctermfg=67 ctermbg=16
hi Folded ctermfg=67 ctermbg=16
hi Function ctermfg=118
hi Identifier ctermfg=208 cterm=none
hi Ignore ctermfg=244 ctermbg=232
hi IncSearch ctermfg=193 ctermbg=16
hi keyword ctermfg=161 cterm=bold
hi Label ctermfg=229 cterm=none
hi Macro ctermfg=193
hi SpecialKey ctermfg=81
hi MatchParen ctermfg=233 ctermbg=208 cterm=bold
hi ModeMsg ctermfg=229
hi MoreMsg ctermfg=229
hi Operator ctermfg=161
" complete menu
hi Pmenu ctermfg=81 ctermbg=16
hi PmenuSel ctermfg=255 ctermbg=242
hi PmenuSbar ctermbg=232
hi PmenuThumb ctermfg=81
hi PreCondit ctermfg=118 cterm=bold
hi PreProc ctermfg=118
hi Question ctermfg=81
hi Repeat ctermfg=161 cterm=bold
hi Search ctermfg=0 ctermbg=222 cterm=NONE
" marks column
hi SignColumn ctermfg=118 ctermbg=235
hi SpecialChar ctermfg=161 cterm=bold
hi SpecialComment ctermfg=245 cterm=bold
hi Special ctermfg=81
if has("spell")
hi SpellBad ctermbg=52
hi SpellCap ctermbg=17
hi SpellLocal ctermbg=17
hi SpellRare ctermfg=none ctermbg=none cterm=reverse
endif
hi Statement ctermfg=161 cterm=bold
hi StatusLine ctermfg=238 ctermbg=253
hi StatusLineNC ctermfg=244 ctermbg=232
hi StorageClass ctermfg=208
hi Structure ctermfg=81
hi Tag ctermfg=161
hi Title ctermfg=166
hi Todo ctermfg=231 ctermbg=232 cterm=bold
hi Typedef ctermfg=81
hi Type ctermfg=81 cterm=none
hi Underlined ctermfg=244 cterm=underline
hi VertSplit ctermfg=244 ctermbg=232 cterm=bold
hi VisualNOS ctermbg=238
hi Visual ctermbg=235
hi WarningMsg ctermfg=231 ctermbg=238 cterm=bold
hi WildMenu ctermfg=81 ctermbg=16
hi Comment ctermfg=59
hi CursorColumn ctermbg=236
hi ColorColumn ctermbg=236
hi LineNr ctermfg=250 ctermbg=236
hi NonText ctermfg=59
hi SpecialKey ctermfg=59
if exists("g:rehash256") && g:rehash256 == 1
hi Normal ctermfg=252 ctermbg=234
hi CursorLine ctermbg=236 cterm=none
hi CursorLineNr ctermfg=208 cterm=none
hi Boolean ctermfg=141
hi Character ctermfg=222
hi Number ctermfg=141
hi String ctermfg=222
hi Conditional ctermfg=197 cterm=bold
hi Constant ctermfg=141 cterm=bold
hi DiffDelete ctermfg=125 ctermbg=233
hi Directory ctermfg=154 cterm=bold
hi Error ctermfg=222 ctermbg=233
hi Exception ctermfg=154 cterm=bold
hi Float ctermfg=141
hi Function ctermfg=154
hi Identifier ctermfg=208
hi Keyword ctermfg=197 cterm=bold
hi Operator ctermfg=197
hi PreCondit ctermfg=154 cterm=bold
hi PreProc ctermfg=154
hi Repeat ctermfg=197 cterm=bold
hi Statement ctermfg=197 cterm=bold
hi Tag ctermfg=197
hi Title ctermfg=203
hi Visual ctermbg=238
hi Comment ctermfg=244
hi LineNr ctermfg=239 ctermbg=235
hi NonText ctermfg=239
hi SpecialKey ctermfg=239
endif
end
" Must be at the end, because of ctermbg=234 bug.
" https://groups.google.com/forum/#!msg/vim_dev/afPqwAFNdrU/nqh6tOM87QUJ
set background=dark