This repository has been archived by the owner on Nov 12, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
19 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
" ======================================================================= | ||
" File: pyrepl.vim | ||
" Version: 0.1.6 | ||
" Version: 0.1.7 | ||
" Description: Vim plugin that provides a Python REPL inside a buffer. | ||
" Maintainer: Bogdan Popa <[email protected]> | ||
" License: Copyright (C) 2011 Bogdan Popa | ||
|
@@ -93,11 +93,26 @@ class PyREPL(object): | |
return self.tq_literal in string | ||
return '"""' in string or "'''" in string | ||
|
||
def match_indentation(self): | ||
try: | ||
previous_line = self.block[-1] | ||
if not previous_line: return "" | ||
except IndexError: | ||
return "" | ||
indent_level = self.count_char(previous_line, " ") | ||
if previous_line[-1] == ":": | ||
return "{0} ".format(" " * indent_level) | ||
else: | ||
return " " * indent_level | ||
|
||
def insert_prompt(self, block=False): | ||
"Inserts a prompt at the end of the buffer." | ||
vim.current.buffer.append( | ||
"... " if block else ">>> " | ||
) | ||
if block: | ||
vim.current.buffer.append( | ||
"... {0} ".format(self.match_indentation()) | ||
) | ||
else: | ||
vim.current.buffer.append(">>> ") | ||
vim.command("normal! G$") | ||
vim.command("startinsert") | ||
|
||
|