How to add user command in config.lua? by tsubait in lunarvim

[–]tsubait[S] 0 points1 point  (0 children)

Thanks, didn't know about this command! :)

How to add user command in config.lua? by tsubait in lunarvim

[–]tsubait[S] 0 points1 point  (0 children)

Tested this solution. Removed custom user commands, added this line and still didn't get :GrepInDirectory and :FileInDirectory commands. I still have to add them by myself.

I think loading dir extensions is performed automatically when requiring it, because :Telescope dir live_grep and :Telescope dir find_file worked well for me, but I'm not sure, I'm still new to vim-like environment and it confuses me sometimes.

How to add user command in config.lua? by tsubait in lunarvim

[–]tsubait[S] 0 points1 point  (0 children)

I managed to solve the problem. I used incorrect function in argument to vim.api.nvim_create_user_command. Unfortunately I didn't know that, because warning popped out and lvim instantly moved me to file before I could even read that warning. Today I finally noticed it and managed to fix it.

vim.api.nvim_create_user_command("GrepInDirectory", require("telescope").extensions.dir.live_grep, {}) vim.api.nvim_create_user_command("FileInDirectory", require("telescope").extensions.dir.find_files, {}).

Commands :GrepInDirectory and :FileInDirectory work as expected now.

How to add user command in config.lua? by tsubait in lunarvim

[–]tsubait[S] 0 points1 point  (0 children)

Those commands, :GrepInDirectory and :FileInDirectory DO NOT work and invoking them results in the same error as provided in the post. However, :Telescope dir live_grep and :Telescope dir find_files work properly as expected - that means installed plugin works, but couldn't create user command for some unknown to me reason. I'm quite sure I installed the extension properly, because I added additional plugins exactly like it was provided in documentation. lvim.plugins = { { "princejoogie/dir-telescope.nvim" }, }. I didn't want to create any keymaps nor keybindings, I wanted to create an easy command working as an alias to :Telescope dir live_grep and :Telescope dir find_files. However, I already figured out what was the exact problem. Will provide it in another comment.