I am recently migrating from vimscript to lua with Nvim. While converting the keymappings, I ran into a problem with the following keymap:
[ init.vim ]
tmap <leader>e <C-\><C-n>
[ init.lua ] ( error )
map('t','<leader>e','<C-\><C-n>')
Whenever I reload with above keymap, Nvim will throw the following error:
I'm assuming that "\" might be the problem. If so, how do I refactor the keymap properly for it to work? Any feedback will be greatly appreciated.
It is most likely as the \ is used to escape special characters in the string. Try putting
map('t','<leader>e','<C-\\><C-n>')
This way you are telling Lua that you want the backslash character and not some other special character.
Related
When I try to decrypt this bytecode:
local crypt = '27\76\117\97\83\0\25\147\13\10\26\10\4\8\4\8\8\120\86\0\0\0\0\0\0\0\0\0\0\0\40\119\64\1\255\201\207\1\0\0\0\0\0\108\105\110\101\108\101\110\103\116\104\32\61\32\49\48\48\48\32\45\45\72\111\119\32\108\111\110\103\32\121\111\117\32\119\97\110\116\32\101\97\99\104\32\108\105\110\101\32\111\102\32\111\98\102\117\115\99\97\116\101\100\32\99\104\97\114\97\99\116\101\114\115\32\116\111\32\98\101\46\13\10\45\45\73\102\32\116\104\101\32\115\99\114\105\112\116\32\105\115\32\116\111\111\32\108\111\110\103\32\119\104\101\114\101\32\116\104\101\32\111\117\116\112\117\116\32\115\97\121\115\32\34\109\101\115\115\97\103\101\115\32\100\105\115\99\97\114\100\101\100\34\32\116\104\101\110\32\99\104\97\110\103\101\32\116\104\101\32\110\117\109\98\101\114\32\116\111\32\52\48\48\32\111\114\32\49\48\48\48\44\32\101\116\99\46\13\10\97\32\61\32\115\116\114\105\110\103\46\100\117\109\112\40\102\117\110\99\116\105\111\110\40\41\13\10\13\10\108\111\99\97\108\32\99\111\100\101\32\61\32\39\92\50\55\92\55\54\92\49\ 49\55\92\57\55\92\56\49\92\48\92\49\92\52\92\52\92\52\92\56\92\48\92\48\92\48\92\48\92\48\92\48\92\48\92\48\92\48\92\48\92\48\92\48\92\48\92\48\92\48\92\50\92\53\92\54\49\92\49\92\48\92\48\92\53\92\54\52\92\48\92\48\92\50\56\92\49\50\56\92\49\50\56\92\48\92\54\92\49\50\56\92\54\52\92\48\92\55\92\48\92\48\92\48\92\53\92\49\57\50\92\48\92\48\92\54\92\48\92\54\53\92\48\92\54\92\54\52\92\54\53\92\48\92\57\92\49\57\50\92\54\53\92\49\51\49\92\53\92\49\57\50\92\48\92\48\92\54\92\48\92\54\54\92\48\92\54\57\92\49\57\50\92\48\92\48\92\55\48\92\49\50\56\92\49\57\52\92\48\92\55\48\92\54\52\92\49\57\52\92\48\92\57\92\54\52\92\49\50\56\92\49\51\50\92\53\92\49\57\50\92\48\92\48\92\54\92\49\57\50\92\54\54\92\48\92\54\57\92\49\57\50\92\48\92\48\92\55\48\92\48\92\49\57\53\92\48\92\55\48\92\54\52\92\49\57\52\92\48\92\57\'
I get the following error: "unfinished string near 27LuaS". How can I fix this?
Add one \ at the beginning of the string
Remove the \ at the end of the string
Remove a line break in the middle of the string
The program then runs. If you write that string to a file, then you'll get truncated Lua 5.3 bytecode. It seems that your original script is incomplete.
Hello I am writing a scipt on ROBLOX and I have encountered a problem.
function showVictoryMessage(playerName)
local message = Instance.new("Message")
message.Text = playerName .." has won!"
message.Parent = game.Workspace
wait (2)
message.Destroy()
end
Upon running this function, or more specifically the "message.Destroy" command, I get the error: Error in script: '=' expected near '< eof >'
I have never seen this error before, and the ROBLOX wiki page on Lua errors doesn't mention it.
I would very much appreciate help in this, because I don't personally know anyone who has coded in Lua.
Looks like a syntax error. message.Destroy() should be message:Destroy() according to this Roblox wiki page http://wiki.roblox.com/index.php?title=API:Class/Instance/Destroy
Also see the section Explosions, Messages, and More at URL http://wiki.roblox.com/index.php?title=Basic_Scripting which provides similar syntax using the colon (:) operator.
See also Difference between . and : in Lua and explanation of "possible side-effects of calculations/access are calculated only once" with colon notation.
Instead of message.Destroy() it should be message:Destroy()
Remember that '.' are used directory-wise and ":' are used for inbuilt functions.
WOOOOOOOO! It was a syntax error. The correct command is message:Destroy. Cause why would object.Destroy work and message.Destroy not?
I have a Lua file that I decompiled using unluac. When I try to recompile the files without any changes I get the following error:
lua: main.lua:647: 'do' expected near '['
I really do not know the problem here, as the while do statement follows the correct format.
The error is on line 647 as stated above.
Source is here:
Full Pastebin Source
Expressions like while {}[1] do and if {}[1].parentFolderName then are invalid because of {}[1] reference. It needs to be ({})[1]. It's probably a result of some sort of automated processing, but you should be able to fix it manually.
Im trying to use idl to read a file, so im using the readcol command. However, in my file i use | as a delimiter, but continually get syntax errors. Heres my latest attempt:
readcol,'kcorrins.txt',uband, gband, rband, iband, zband, $
ubanderr, gbanerr, rbanderr, ibanderr, zbanderr, adjredshift, $
SKIPLINE=1, DELIMITER=|
could someone post an example of the proper syntax for using the delimiter in this way?
You need to quote the delimiter:
readcol,'kcorrins.txt',uband, gband, rband, iband, zband, $
ubanderr, gbanerr, rbanderr, ibanderr, zbanderr, adjredshift, $
SKIPLINE=1, DELIMITER='|'
I just installed macvim yesterday and I installed vim latex today.
One of the menu items is calling a broken function (TeX-Suite -> view).
When I click on the menu-time it makes this call:
:silent! call Tex_ViewLatex()
Question: Where can I find that function? Is there some way to figure out where it is defined?
Just for curiosity sake I removed the silent part and ran this:
:call Tex_ViewLatex()
Which produces:
Error detected while processing function Tex_ViewLaTeX:
line 34:
E121: Undefined variable: s:viewer
E116: Invalid arguments for function strlen(s:viewer)
E15: Invalid expression: strlen(s:viewer)
line 39:
E121: Undefined variable: appOpt
E15: Invalid expression: 'open '.appOpt.s:viewer.' $*.'.s:target
line 79:
E121: Undefined variable: execString
E116: Invalid arguments for function substitute(execString, '\V$*', mainfname, 'g'
)
E15: Invalid expression: substitute(execString, '\V$*', mainfname, 'g')
line 80:
E121: Undefined variable: execString
E116: Invalid arguments for function Tex_Debug
line 82:
E121: Undefined variable: execString
E15: Invalid expression: 'silent! !'.execString
Press ENTER or type command to continue
I suspect that if I could see the source function I could figure out what inputs are bad or what it is looking for.
Use the :verbose prefix command:
:verbose function Tex_ViewLaTeX
In the second line of output (just above the function's body) is the location of where the function was defined.
I installed gVim 7.2 on windows and latex-suite, and miktex too
I tried what you said, after compile and view, I can view the dvi files
The error message seemed like to indicate it's the view's problem
The document for latex-suite said the viewer for Macintosh is not set, maybe it's where the problem lies
I think you can try to set a few variables in your .vimrc file, to set up the proper viewing app for PDF files
And the source code for Tex_ViewLaTeX is here:
http://www.tedpavlic.com/research_related/tpavlic_masters_thesis/compiler.vim
By the way, I also installed MacVim on my Macbook Pro, however I never used vim for LaTeXing, because I find TextMate and its latex bundle is much superior than MacVim, you'll definately like it
One way to search would be to do a grep or vimgrep on directory tree where you thought the source file was located. Search for 'function Tex_ViewLatex' or 'function! Tex_ViewLatex'.
I believe in the usual install it would be in a .../ftplugin/latex-suite/compiler.vim file, as part of the latex-suite plugin. There are a couple ftplugin directories, so make sure you get right one (one is in tree of main vim install and other may be off your home .vim directory.
It seems there is a bug with the Tex_ViewLatex function on OS X. Check here for some info:
http://comments.gmane.org/gmane.comp.editors.vim.latex.devel/775
Put this in your .vimrc, solved the problem for me.
let g:Tex_ViewRule_pdf = 'open -a Preview.app'