Commits

Dejan Noveski committed 87a3c1b

Added global settings - g:w3_validator_url which sets validator url if you run an instance localy and g:w3_apicall_timeout which sets API timeout

  • Participants
  • Parent commits 0c829ba

Comments (0)

Files changed (2)

 Copy w3cvalidate.vim file inside plugin directory, source it or restart Vim. Use :W3cValidate to validate
 the current buffer, or :W3cValidate "[url_here]" to validate a hosted page.
 
+The validator service url can be changed if you run an instance of it localy by setting  g:w3_validator_url  in .vimrc
+
+The script has API timeout default to 20 seconds. You can change it by setting  g:w3_apicall_timeout  in .vimrc
+
 == TODO ==
 
 Parsing the explanation messages for more verbose output.
     finish
 endif
 
+if !exists("g:w3_validator_url")
+    let g:w3_validator_url = "http://validator.w3.org/check"
+endif
+
+if !exists("g:w3_apicall_timeout")
+    let g:w3_apicall_timeout = 20
+endif
 
 function! s:W3cValidate(...)
 python << EOF
-import vim, urllib2, urllib, simplejson
+import vim, urllib2, urllib, simplejson, re
 
 OUTPUT = 'json'
 VERBOSE = 0
-TIMEOUT = 20
-URL = 'http://validator.w3.org/check'
+TIMEOUT = int(vim.eval("g:w3_apicall_timeout"))
+URL = vim.eval("g:w3_validator_url")
 
 
 fragment = ''.join(vim.current.buffer)
 try:
     response = urllib2.urlopen(URL, post_dat, TIMEOUT).read()
     messages = simplejson.loads(response).get("messages", [])
-
+    
     vim.command("call s:W3ScratchBufferOpen()")
     del vim.current.buffer[:]