0

I'm trying to setup neovim config using lua config.

I want to use vim-terminator to run current file.

I've my config file in this branch in the repo.

I've added the below config of vim-terminator plugin.

let g:terminator_runfile_map = {
            \ "javascript": "node",
            \ "python": "python -u",
            \ "c": "gcc $dir$fileName -o $dir$fileNameWithoutExt && $dir$fileNameWithoutExt",
            \ "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
            \ }

I get the below error -

  Error detected while processing /home/rajkumar/.config/nvim/init.lua:
  E5113: Error while calling lua chunk: vim/_init_packages.lua:0: /home/rajkumar/.config/nvim/lua/v
  im-terminator/init.lua:1: '=' expected near 'g'
  stack traceback:
          [C]: in function 'error'
          vim/_init_packages.lua: in function <vim/_init_packages.lua:0>
          [C]: in function 'require'
  "." is a directory
  Press ENTER or type command to continue

enter image description here

I'm novice in lua. Not sure how to fix this error. Any Idea what I'm missing in my config.

1
  • This is not lua code, this is viml. To configure nvim with lua, at least go through basic lua tutorial? Commented Sep 28, 2022 at 2:17

1 Answer 1

3
let g:terminator_runfile_map = {
            \ "javascript": "node",
            \ "python": "python -u",
            \ "c": "gcc $dir$fileName -o $dir$fileNameWithoutExt && $dir$fileNameWithoutExt",
            \ "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
            \ }

is not valid Lua code. let g:terminator_runfile_map = ... is Vim script.

If you require this file it is executed as Lua code and hence Lua would first complain about a missing = between let and g because an identifyer alone is not a valid Lua expression.

You're confusing two scripting languages here.

vim.g.terminator_runfile_map = {
  javascript = "node",
  python = "python -u",
  c = "c": "gcc $dir$fileName -o $dir$fileNameWithoutExt && $dir$fileNameWithoutExt",
  fortran = "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
 }

would be a Lua equivalent. I don't know if this makes sense in nvim context though.

Sign up to request clarification or add additional context in comments.

1 Comment

Can't edit but looks like a typo -- c = "c": "gcc ... should be c = "gcc ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.