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

making it work with torch #40

Open kwon-young opened 8 years ago

kwon-young commented 8 years ago

Hi, I would like to use this plugin with the framework torch. For now, i installed the plugin with vim-plug and the plugin doesn't seem to work well. After rapidly reading the doc, i set these settings in my vimrc:

let g:lua_interpreter_path = '/home/username/torch/install/bin/qlua'
let g:lua_internal = 0
let g:lua_complete_omni = 1

Torch installation embed a custom lua interpreter, however i'm a new to lua so i don't really know how to configure the plugin to make things work.

When i try the omni completion, i have the following error:

E121: Undefined Variable: Torch

Also the gf mapping doesn't really work

vzhong commented 8 years ago

Hi @kwon-young ,

I would really love to use this plugin with Torch as well. I can reproduce your error with a fresh install of Torch. After digging around a bit, I think the problem is happening in

https://github.com/xolox/vim-lua-ftplugin/blob/master/autoload/xolox/lua.vim#L447

Namely, the returned output list variable has two elements that are:

Torch 7.0  Copyright (C) 2001-2011 Idiap, NEC Labs, NYU
Torch 7.0  Copyright (C) 2001-2011 Idiap, NEC Labs, NYU

Then, these two lines are passed to the eval call and we end up with the Undefined Variable: Torch error.

@xolox do you have any pointers on how we can debug this further?

Edit: Ah ok! I think I know what is happening. This vimscript takes as output everything that is printed by omnicomplete.lua. However, one of the Torch scripts prints Torch 7.0 ... to stdout when included.

vzhong commented 8 years ago

So, this plugin works if you comment out the print statement in the beginning of ~/torch/install/share/lua/5.1/env/init.lua (your path will likely vary).