Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update the config file #73

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/config/pyvimrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def configure(editor):
editor_buffer = editor.current_editor_buffer

if editor_buffer is not None:
if editor_buffer.filename is None:
if editor_buffer.get_display_name() is None:
editor.show_message("File doesn't have a filename. Please save first.")
return
else:
Expand All @@ -63,7 +63,7 @@ def configure(editor):
# `CommandLineInterface.run_in_terminal` to go to the background and
# not destroy the window layout.
def execute():
call(['python', editor_buffer.filename])
call(['python', editor_buffer.get_display_name()])
six.moves.input('Press enter to continue...')

editor.cli.run_in_terminal(execute)
10 changes: 9 additions & 1 deletion pyvim/lexer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import unicode_literals

from prompt_toolkit.layout.lexers import Lexer
from pygments.lexers import get_lexer_for_mimetype
from pygments.lexers import get_lexer_for_filename
from pygments.token import Token
from pygments.util import ClassNotFound
Expand Down Expand Up @@ -28,7 +29,14 @@ def get_tokens(self, cli, text):
try:
lexer = get_lexer_for_filename(location, stripnl=False, stripall=False, ensurenl=False)
except ClassNotFound:
pass
try:
import magic
mimetype = magic.from_file(location, mime=True)
lexer = get_lexer_for_mimetype(mimetype)
except ClassNotFound:
pass
else:
return lexer.get_tokens(text)
else:
return lexer.get_tokens(text)

Expand Down