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

Adding support for vim compiled with python3 support #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
24 changes: 12 additions & 12 deletions autoload/browserlink.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
let s:path = expand('<sfile>:p:h:h')

python <<NOMAS
python3 <<NOMAS
import sys
import time
import urllib2
from urllib.request import urlopen
import vim
import os
import subprocess
Expand All @@ -22,13 +22,13 @@ function! browserlink#EvaluateWord()
endfunction

function! browserlink#evaluateJS(js)
python urllib2.urlopen(urllib2.Request(vim.eval("g:bl_serverpath") + "/evaluate", vim.eval("a:js")))
python3 urlopen(urllib.Request(vim.eval("g:bl_serverpath") + "/evaluate", vim.eval("a:js")))
endfunction

function! browserlink#sendCommand(command)
python <<EOF
python3 <<EOF
try:
urllib2.urlopen(vim.eval("g:bl_serverpath") + "/" + vim.eval("a:command")).read()
urlopen(vim.eval("g:bl_serverpath") + "/" + vim.eval("a:command")).read()
except:
vim.command("call browserlink#startBrowserlink()")
EOF
Expand All @@ -48,8 +48,8 @@ endfunction

function! browserlink#getConsole()
normal ggdG
python <<EOF
data = urllib2.urlopen(vim.eval("g:bl_serverpath") + "/console").read()
python3 <<EOF
data = urlopen(vim.eval("g:bl_serverpath") + "/console").read()
for line in data.split("\n"):
vim.current.buffer.append(line)
EOF
Expand Down Expand Up @@ -83,8 +83,8 @@ function! browserlink#url2path(url)
endfunction

function! browserlink#getErrors()
python <<EOF
data = urllib2.urlopen(vim.eval("g:bl_serverpath") + "/errors").readlines()
python3 <<EOF
data = urlopen(vim.eval("g:bl_serverpath") + "/errors").readlines()
vim.command("let errors = %s" % [e.strip() for e in data])
EOF
set errorformat+=%f:%l:%m
Expand All @@ -101,13 +101,13 @@ EOF
endfunction

function! browserlink#clearErrors()
python <<EOF
urllib2.urlopen(vim.eval("g:bl_serverpath") + "/clearerrors")
python3 <<EOF
urlopen(vim.eval("g:bl_serverpath") + "/clearerrors")
EOF
endfunction

function! browserlink#traceLine()
python <<EOF
python3 <<EOF

line = vim.eval("getline('.')")
fragments = line.split('/')
Expand Down