How to use env variables inside which-key plugin mapping? [SOLVED]

The example below is not working (error is given when neovim is opened not recognising $env_var) how can I let him recognise the env_var?

g = {

name = "+grep",

a = { "Telescope grep_string", "Grep on all dirs" },

s = { "Telescope grep_string search_dirs={"$env_var/dir1/dir2/dir3/"} cr>", "Grep on dir" },

},

Thanks

3 points · 7 comments · view on lemmy.world

7 Comments

lckdscl@whiskers.bim.boats · 2 pts · 2y (6 replies)

Vimscript: "Telescope grep_string search_dirs=["$HOME/.config"]"

Lua: require("telescope.builtin").grep_string({ search_dirs = { os.get_env("HOME") .. "/.config" } })

dafunkkk@lemmy.world · 1 pts · 2y (5 replies)

tried this but still not woking (tried with and without .. )

s = { "Telescope grep_string search_dirs={os.get_env("prj_path") .. "/dir1/dir2/dir3/"} cr>", "Grep on dir3" }

what's wrong?

lckdscl@whiskers.bim.boats · 1 pts · 2y (4 replies)

You're mixing Lua with Vimscript, the stuff with in double quotes should be in Vimscript

s = { "Telescope grep_string search_dirs=['$prj_path/dir1/dir2/dir3/'] cr>", "Grep on dir3" }

dafunkkk@lemmy.world · 1 pts · 2y (3 replies)

I'm very sorry, but I don't understad how should I do to let it work in lua (I'm using init.vim but this part is under lua << EOF)

nicolas@hachyderm.io · 1 pts · 2y (1 reply)

@dafunkkk @lckdscl I would advise you to either read neovim’s lua guides:
https://neovim.io/doc/user/lua.html
https://neovim.io/doc/user/lua-guide.html#lua-guide
or have a look at some video tutorials, e.g. https://www.youtube.com/watch?v=w7i4amO_zaE&list=PLm323Lc7iSW_wuxqmKx_xxNtJC_hJbQ7R&index=6
If you really want to build your own neovim configuration, you will need to get comfortable with lua.

dafunkkk@lemmy.world · 0 pts · 2y

yeah, just asking here for quick solutions (don't want to spend tons of time reading all the guides)

dafunkkk@lemmy.world · 1 pts · 2y

ok, got it

  s = { "Telescope grep_string search_dirs=['$prj_path/dir1/dir2/dir3/']", "Grep on dir3" },

this works....many Thanks!!!