2

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 Commented Jan 20, 2023 at 12:59

1 Answer 1

4

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' 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.