xolox / vim-lua-ftplugin

Lua file type plug-in for the Vim text editor
http://peterodding.com/code/vim/lua-ftplugin
187 stars 27 forks source link

completion suggests all the standard library contents #28

Open actionless opened 10 years ago

actionless commented 10 years ago

u can see how it looks when trying to complete "beautiful." from awesome wm: https://cdn.mediacru.sh/c7BApzUbecpu.png

also take a look on the first line (version) -- it's for some reason 5.2 while i set to use 5.1:

let g:lua_interpreter_path = '/usr/sbin/lua5.1'
let g:lua_compiler_name = '/usr/sbin/luac5.1'
xolox commented 10 years ago

I'm not really sure how / why the prefix of what you type is not filtering the list of completion suggestions. Clearly it's supposed to do that :-) (and it does so for me). Does this happen only when you type a dot or does it also happen when you type in the whole line beautiful. and then press Ctrl-X - Ctrl-O?


About the second point: You're probably running a version of Vim that embeds Lua. In that case the lua_interpreter_path setting is not used. You can check by running the following Vim command (while editing a Lua script):

:verbose LuaCheckGlobals

This will print some output about the internal state of the plug-in that makes it easy to debug problems. If the messages scroll off the screen you can recall them with Vim's :messages command. The messages should contain one of the following lines:

I'm guessing in your case it will report the first line, explaining the differing version numbers.

xolox commented 10 years ago

Please pull the latest version from GitHub (you can also download a ZIP archive if you like), restart Vim, execute :set verbose=1 and try once more to complete beautiful.. Afterwards please run :messages to recall the debugging information that the plug-in reported and post the output here on GitHub. Hopefully that will provide me with a hint about what is going wrong :-). Thanks!

actionless commented 10 years ago

Does this happen only when you type a dot or does it also happen when you type in the whole line beautiful. and then press Ctrl-X - Ctrl-O?

in both cases

I'm guessing in your case it will report the first line, explaining the differing version numbers.

so i executed in vim :verbose LuaCheckGlobals:

lua.vim 0.7.24: Running '/home/lie/.vim/bundle/vim-lua-ftplugin/misc/lua-ftplugin/globals.lua' using Lua Interface for Vim ../usr/sbin/luac5.1: cannot open : No such file or directory
$ file /usr/sbin/luac5.1
/usr/sbin/luac5.1: ELF 64-bit LSB exec...

and post the output here on GitHub

so i updated using Vundle and executed action sequence you described above (i excluded part in the center):

lua.vim 0.7.24: Matched completion prefix 'beautiful.'.
lua.vim 0.7.24: Got package.path from Lua Interface for Vim
lua.vim 0.7.24: Got package.cpath from Lua Interface for Vim
lua.vim 0.7.24: Transformed /usr/share/lua/5.2/?.lua -> /usr/share/lua/5.2/**/*.lua
lua.vim 0.7.24: Transformed '/usr/share/lua/5.2/alt_getopt.lua' -> 'alt_getopt'
lua.vim 0.7.24: Transformed '/usr/share/lua/5.2/ldoc/builtin/coroutine.lua' -> 'ldoc.builtin.coroutine'
lua.vim 0.7.24: Transformed '/usr/share/lua/5.2/ldoc/builtin/debug.lua' -> 'ldoc.builtin.debug'
lua.vim 0.7.24: Transformed '/usr/share/lua/5.2/ldoc/builtin/global.lua' -> 'ldoc.builtin.global'
<<.............>>
lua.vim 0.7.24: Transformed '/usr/lib/lua/5.2/lgi/corelgilua51.so' -> 'lgi.corelgilua51'
lua.vim 0.7.24: Transformed '/usr/lib/lua/5.2/lxc/core.so' -> 'lxc.core'
lua.vim 0.7.24: Transformed '/usr/lib/lua/5.2/lxp.so' -> 'lxp'
lua.vim 0.7.24: Transformed '/usr/lib/lua/5.2/mime/core.so' -> 'mime.core'
lua.vim 0.7.24: Transformed '/usr/lib/lua/5.2/socket/core.so' -> 'socket.core'
lua.vim 0.7.24: Transformed '/usr/lib/lua/5.2/socket/serial.so' -> 'socket.serial'
lua.vim 0.7.24: Transformed '/usr/lib/lua/5.2/socket/unix.so' -> 'socket.unix'
lua.vim 0.7.24: Failed to parse search path entry: /usr/lib/lua/5.2/loadall.so
lua.vim 0.7.24: Refusing to expand dangerous search path entry: ./?.so
lua.vim 0.7.24: Collected 120 module names for omni completion in 0.26 seconds.
lua.vim 0.7.24: Running '/home/lie/.vim/bundle/vim-lua-ftplugin/misc/lua-ftplugin/omnicomplete.lua' using Lua Interface for Vim ..
lua.vim 0.7.24: Collected 586 variables for omni completion in 0.41 seconds.
lua.vim 0.7.24: Completing 0 omni variable(s) matching filter.
lua.vim 0.7.24: Matched completion prefix 'beautiful.'.
lua.vim 0.7.24: Completing all 586 omni variable(s).

so, finally, it looks like it not honor those options:

let g:lua_interpreter_path = '/usr/sbin/lua5.1'
let g:lua_compiler_name = '/usr/sbin/luac5.1'
xolox commented 9 years ago

so, finally, it looks like it not honor those options

As I mentioned before, when the Lua Interface for Vim is enabled the file type plug-in will not use the external interpreter. If this really bothers you then you can set the g:lua_internal option to false (0). However this doesn't seem to be directly related to the issue you reported here (unless I'm confused).

The issue at hand seems to be that xolox#lua#omnifunc() is somehow not correctly communicating the completion prefix to Vim (using the s:getcompletionprefix() function). Except it is because the second to last message you quoted says Matched completion prefix 'beautiful.'. So clearly the plug-in is matching the right completion prefix. But when Vim then calls back into the plug-in it doesn't pass the expected prefix because we see Completing all 586 omni variable(s) (it should have been a message like Completing N omni variable(s) matching filter where N is a variable number).

Given all of the logging output I added and you quoted, I still don't get what's going on here :-(. It almost seems like a bug in Vim, or a really weird interaction between multiple plug-ins.