Plugins not working when using NVim (Windows 10)

Hi :wave:

I recently installed two plugins (Telescope & Lazy.vim) for nvim, they work perfectly if I’m editing the init.lua file, but when I try to use them in other directory or file, they won’t work. Why does this happen?

VIDEO I USED TO INSTALL THE PLUGINS: https://www.youtube.com/watch?v=zHTeCSVAFNY&list=PLsz00TDipIffreIaUNk64KxTIkQaGguqn

Notes

I’m on Windows 10. I ran the :source % command as the video above said and it worked, but not in other directories/files.

init.lua file content (at ~/.config/nvim/init.lua):

-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  local lazyrepo = "https://github.com/folke/lazy.nvim.git"
  local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
  if vim.v.shell_error ~= 0 then
    vim.api.nvim_echo({
      { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
      { out, "WarningMsg" },
      { "\nPress any key to exit..." },
    }, true, {})
    vim.fn.getchar()
    os.exit(1)
  end
end
vim.opt.rtp:prepend(lazypath)

require('lazy.view.config').keys.close = '<Esc>'
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"

-- Setup lazy.nvim
require("lazy").setup({
  spec = {
		{
    			'nvim-telescope/telescope.nvim', tag = '0.1.5',
      		        dependencies = { 'nvim-lua/plenary.nvim' }
    		},
  },
  install = { colorscheme = { "habamax" } },
  checker = { enabled = true },
})

local builtin = require("telescope.builtin")
vim.keymap.set('n', '<C-p>', builtin.find_files, {})

Plugins installed: Telescope & Lazy vim

When I try to open Telescope (with ctrl + p), it doesn’t open.

Welcome. As a new user, note that this forum is not very active, consider using github discussions: Use https://github.com/neovim/neovim/discussions

It is hard for me to answer your question as I don’t use Windows 10 or Lazy.nvim, but it should surely work (I have things working for Windows 11 and a different plugin manager). The first thing you could do is check if the plugins are actually being loaded when you start nvim from a different directory. I think Lazy.nvim provides some command to open a list of loaded plugins? Either way, it sounds like your init.lua is not being sourced automatically for some reason. But if it is at the path you indicated (~/.config/nvim/init.lua) I think it should work, so the issue requires more debugging.

Oops, scratch that! The path on Windows is different, it should be something like this (Windows 11):

C:\Users\<username>\AppData\Local\nvim\init.lua

Replace <username> with your Windows user name.