<commit_before>" File:        brolink.vim
" Version:     2.5.0
" Description: Links VIM to your browser for live/responsive editing.
" Maintainer:  <NAME> <<EMAIL>> <http://github.com/jaxbot>
" Homepage:    http://jaxbot.me/
" Repository:  https://github.com/jaxbot/brolink.vim 
" License:     Copyright (C) 2014 <NAME>
"              Released under the MIT license 
"			   ======================================================================
"              

if exists("g:bl_loaded") || &cp
    finish
endif
let g:bl_loaded = "si"

if !exists("g:bl_serverpath") 
	let g:bl_serverpath = "http://127.0.0.1:9001"
endif

let g:bl_state = 0

python <<NOMAS
import sys
import time
import urllib2
import vim
NOMAS

function! s:EvaluateSelection()
	call s:evaluateJS(s:get_visual_selection()) 
endfunction

function! s:EvaluateBuffer()
	call s:evaluateJS(join(getline(1,'$')," "))
endfunction

function! s:EvaluateWord()
	call s:evaluateJS(expand("<cword>") . "()")
endfunction

function! s:evaluateJS(js) 
	python urllib2.urlopen(urllib2.Request(vim.eval("g:bl_serverpath") + "/evaluateJS", vim.eval("a:js")))
endfunction

function! s:sendCommand(command)
	python urllib2.urlopen(vim.eval("g:bl_serverpath") + "/" + vim.eval("a:command"))
endfunction

function! s:get_visual_selection()
  let [lnum1, col1] = getpos("'<")[1:2]
  let [lnum2, col2] = getpos("'>")[1:2]
  let lines = getline(lnum1, lnum2)
  let lines[-1] = lines[-1][: col2 - 2]
  let lines[0] = lines[0][col1 - 1:]
  return join(lines, " ")
endfunction

function! s:setupHandlers() 
    au BufWritePost *.html,*.js,*.php :BLReloadPage
    au BufWritePost *.css :BLReloadCSS	
endfunction

command! -range -nargs=0 BLEvaluateSelection call s:EvaluateSelection()
command!        -nargs=0 BLEvaluateBuffer    call s:EvaluateBuffer()
command!        -nargs=0 BLEvaluateWord      call s:EvaluateWord()
command!        -nargs=1 BLEval              call s:evaluateJS(<f-args>)
command!        -nargs=0 BLReloadPage        call s:sendCommand("reloadPage")
command!        -nargs=0 BLReloadCSS         call s:sendCommand("reloadCSS")

if !exists("g:bl_no_mappings")<commit_msg>Make it fail silently<commit_after>" File:        brolink.vim
" Version:     2.5.0
" Description: Links VIM to your browser for live/responsive editing.
" Maintainer:  <NAME> <<EMAIL>> <http://github.com/jaxbot>
" Homepage:    http://jaxbot.me/
" Repository:  https://github.com/jaxbot/brolink.vim 
" License:     Copyright (C) 2014 <NAME>
"              Released under the MIT license 
"			   ======================================================================
"              

if exists("g:bl_loaded") || &cp
    finish
endif
let g:bl_loaded = "si"

if !exists("g:bl_serverpath") 
	let g:bl_serverpath = "http://127.0.0.1:9001"
endif

let g:bl_state = 0

python <<NOMAS
import sys
import time
import urllib2
import vim
NOMAS

function! s:EvaluateSelection()
	call s:evaluateJS(s:get_visual_selection()) 
endfunction

function! s:EvaluateBuffer()
	call s:evaluateJS(join(getline(1,'$')," "))
endfunction

function! s:EvaluateWord()
	call s:evaluateJS(expand("<cword>") . "()")
endfunction

function! s:evaluateJS(js) 
	python urllib2.urlopen(urllib2.Request(vim.eval("g:bl_serverpath") + "/evaluateJS", vim.eval("a:js")))
endfunction

function! s:sendCommand(command)
	python <<EOF
try:
	urllib2.urlopen(vim.eval("g:bl_serverpath") + "/" + vim.eval("a:command"))
except:
	# who cares!
	pass
EOF
endfunction

function! s:get_visual_selection()
  let [lnum1, col1] = getpos("'<")[1:2]
  let [lnum2, col2] = getpos("'>")[1:2]
  let lines = getline(lnum1, lnum2)
  let lines[-1] = lines[-1][: col2 - 2]
  let lines[0] = lines[0][col1 - 1:]
  return join(lines, " ")
endfunction

function! s:setupHandlers() 
    au BufWritePost *.html,*.js,*.php :BLReloadPage
    au BufWritePost *.css :BLReloadCSS	
endfunction

command! -range -nargs=0 BLEvaluateSelection call s:EvaluateSelection()
command!        -nargs=0 BLEvaluateBuffer    call s:EvaluateBuffer()
command!        -nargs=0 BLEvaluateWord      call s:EvaluateWord()
command!        -nargs=1 BLEval              call s:evaluateJS(<f-args>)
command!        -nargs=0 BLReloadPage        call s:sendCommand("reloadPage")
command!        -nargs=0 BLReloadCSS         call s:sendCommand("reloadCSS")

if !exists("g:bl_no_mappings")
{'fraction_non_alphanumeric': 0.17734447539461468, 'fraction_numerical': 0.02181987000928505, 'mean_word_length': 4.160479041916168, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7176658', 'n_tokens_mistral': 1617, 'n_tokens_neox': 1528, 'n_words': 325}