Permalink
Browse files

Bug fix: Properly escape Vim script strings in omnicomplete.lua

  • Loading branch information...
1 parent 2f29afe commit b4f29a5bfd4c0ccceef626116664cfd840b76a54 @xolox committed May 12, 2013
Showing with 8 additions and 3 deletions.
  1. +2 −2 autoload/xolox/lua.vim
  2. +6 −1 misc/lua-ftplugin/omnicomplete.lua
View
@@ -1,9 +1,9 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: April 30, 2013
+" Last Change: May 12, 2013
" URL: http://peterodding.com/code/vim/lua-ftplugin
-let g:xolox#lua#version = '0.7.3'
+let g:xolox#lua#version = '0.7.4'
let s:miscdir = expand('<sfile>:p:h:h:h') . '/misc/lua-ftplugin'
let s:omnicomplete_script = s:miscdir . '/omnicomplete.lua'
let s:globals_script = s:miscdir . '/globals.lua'
@@ -29,7 +29,12 @@ local function addmatch(word, kind, desc)
if not desc then
print(string.format("{'word':'%s','kind':'%s'}", word, kind))
else
- print(string.format("{'word':'%s','kind':'%s','menu':'%s'}", word, kind, (desc:gsub('\n', ' '))))
+ -- Make sure we generate valid Vim script expressions (this is probably
+ -- still not right).
+ desc = desc:gsub('\n', '\\n')
+ :gsub('\r', '\\r')
+ :gsub("'", "''")
+ print(string.format("{'word':'%s','kind':'%s','menu':'%s'}", word, kind, desc))
end
end

0 comments on commit b4f29a5

Please sign in to comment.