0

One of my packages needs me to set up the PATH and one variable. In my vimscript code I had:

let $PATH.=':/usr/lib64/openjdk-11/bin/'
let $MYVIMRC='/home/luis/.config/nvim/init.vim'

But I can't figure out how to do this in an init.lua file. If I try to wrap around vim.cmd([[]]) the package still does not detect these changes.

1
  • Not sure what's happening, but maybe you can try to do it directly in command mode, like: :lua vim.cmd([[ let $PATH.='blablabla' ]]) and check it by :echo $PATH
    – Lai32290
    Commented Jan 20, 2023 at 12:59

1 Answer 1

1

Neovim has an API for getting and setting environment variables in Lua: vim.env.

Using vim.env, you can add to your path with this:

vim.env.PATH = vim.env.PATH .. ':/usr/lib64/openjdk-11/bin/'

In the same vein, you can set $MYVIMRC with:

vim.env.MYVIMRC = '/home/luis/.config/nvim/init.vim'

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.