From e4387a47276081ba1d514ce81e1ac8132ace2ba6 Mon Sep 17 00:00:00 2001 From: ryanss Date: Sat, 21 Feb 2015 16:20:44 -0500 Subject: Fix #28 Add Python3 support --- ftplugin/hackernews.vim | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'ftplugin/hackernews.vim') diff --git a/ftplugin/hackernews.vim b/ftplugin/hackernews.vim index 7604ca5..86c3293 100644 --- a/ftplugin/hackernews.vim +++ b/ftplugin/hackernews.vim @@ -8,8 +8,12 @@ " Version: 0.1.1 -if !has('python') - echo "HackerNews.vim Error: Requires Vim compiled with +python" +if has('python') + command! -nargs=1 Python python +elseif has('python3') + command! -nargs=1 Python python3 +else + echo "HackerNews.vim Error: Requires Vim compiled with +python or +python3" finish endif @@ -19,10 +23,10 @@ endif " Import Python code -execute "python import sys" -execute "python sys.path.append(r'" . expand(":p:h") . "')" +execute "Python import sys" +execute "Python sys.path.append(r'" . expand(":p:h") . "')" -python << EOF +Python << EOF if 'hackernews' not in sys.modules: import hackernews else: @@ -32,14 +36,14 @@ EOF " Load front page -execute "python hackernews.main()" +execute "Python hackernews.main()" -noremap o :python hackernews.link() -noremap O :python hackernews.link(external=True) -noremap gx :python hackernews.link(external=True) -noremap u u:python hackernews.recall_pos() -noremap :python hackernews.recall_pos() +noremap o :Python hackernews.link() +noremap O :Python hackernews.link(external=True) +noremap gx :Python hackernews.link(external=True) +noremap u u:Python hackernews.recall_pos() +noremap :Python hackernews.recall_pos() " Helper motion to browse front page easier -- cgit v1.2.3