0

I have a full lua config on my Neovim setup.
It seems we can't have both init.vim and init.lua on the same setup.

I am trying to setup fugitive-gitlab.vim, but it provides vimscript instructions.
Both fugitive-gitlab and fugitive are successfully installed via Lazy.nvim.

When configuring as per the installation instructions here:

let g:fugitive_gitlab_domains = {'ssh://my-ssh.gitlab.com': 'https://my.gitlab.com'}

I tried to translate that to the following lua function:

function ConfigGitlab()
    vim.g.fugitive_gitlab_domains['ssh://[email protected]:121112'] = 'https://gitlab.company.com:3344'
end

But when I call this, I get:

Error detected while processing /Users/v4g4x/.config/nvim/init.lua:
E5113: Error while calling lua chunk: /Users/v4g4x/.config/nvim/lua/core/gitlab.lua:3: attempt to index field 'fugitive_gitlab_domains' (a nil value)

Clearly, I'm not converting from Vimscript to Lua correctly. Any help on how this may be done?

2

1 Answer 1

1

In general to convert init.vim into init.lua the nvim-lua-guide helps or directly from the Neovim documentation Lua-guide page.

But of course some knowledge of Lua too :-)

I would do:

vim.g.fugitive_gitlab_domains = { ['ssh://[email protected]:121112'] = 'https://gitlab.company.com:3344'

Remark: In general a dictionary in Lua is defined like:

mydict = { mykey1 = myvalue1, mykey2 = myvalue2}

e.g.

name2age = { foo = 42, bar = 84 }

But when the keys are not identifiers you have to rely on the following syntax:

mydict = { ['my key 1'] = myvalue2, ['my key 2'] = myvalue2}
2
  • Yup, this worked! Thanks a lot! Mar 11 at 15:35
  • Welcome to Vim :-) Thanks for the feedback! Mar 11 at 15:59

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.