neovimneovim-plugintelescope.nvim

My neovim config stopped working, but I have tried other configs and templates and it did not work as well


My neovim returns the following error message everytime I try to open it:

Error detected while processing /home/garamog/dotfiles/nvim/.config/nvim/init.lua:                                                      
E5113: Error while calling lua chunk: /home/garamog/.config/nvim/lua/garamog/remaps.lua:46: module 'telescope.builtin' not found:       
        no field package.preload['telescope.builtin']                                                                                   
        no file './telescope/builtin.lua'                                                                                               
        no file '/usr/share/luajit-2.1/telescope/builtin.lua'                                                                           
        no file '/usr/local/share/lua/5.1/telescope/builtin.lua'                                                                        
        no file '/usr/local/share/lua/5.1/telescope/builtin/init.lua'                                                                   
        no file '/usr/share/lua/5.1/telescope/builtin.lua'                                                                              
        no file '/usr/share/lua/5.1/telescope/builtin/init.lua'                                                                         
        no file './telescope/builtin.so'                                                                                                
        no file '/usr/local/lib/lua/5.1/telescope/builtin.so'                                                                           
        no file '/usr/lib64/lua/5.1/telescope/builtin.so'                                                                               
        no file '/usr/local/lib/lua/5.1/loadall.so'                                                                                     
        no file './telescope.so'                                                                                                        
        no file '/usr/local/lib/lua/5.1/telescope.so'                                                                                   
        no file '/usr/lib64/lua/5.1/telescope.so'                                                                                       
        no file '/usr/local/lib/lua/5.1/loadall.so'                                                                                     
stack traceback:                                                                                                                        
        [C]: in function 'require'                                                                                                      
        /home/garamog/.config/nvim/lua/garamog/remaps.lua:46: in main chunk                                                             
        [C]: in function 'require'                                                                                                      
        /home/garamog/.config/nvim/lua/garamog/init.lua:1: in main chunk                                                                
        [C]: in function 'require'                                                                                                      
        /home/garamog/dotfiles/nvim/.config/nvim/init.lua:1: in main chunk                                                              
Press ENTER or type command to continue

The file ~/.config/nvim/lua/garamog/remaps.lua is as follows:

vim.g.mapleader = " "
local map = vim.keymap.set
-------------- Editor -----------------
map("n", "<leader>so", ":w<CR>:so<CR>", { desc = "Save and source file." })

--map("n", "<leader>po", ":Ex<CR>")

--Splitig buffers
map("n", "<leader>hs", ":split<CR>", { desc = "" })
map("n", "<leader>vs", ":vsplit<CR>")

map("n", "<leader>ss", ":w<CR>")
map("n", "<leader>hl", ":nohlsearch<CR>")

-- esc clears highlights
map("n", "<Esc>", "<cmd>noh<CR>", { desc = "General Clear highlights" })

-- Ctrl+C to copy whole file.
map("n", "<C-s>", "<cmd>w<CR>", { desc = "General Save file" })
map("n", "<C-c>", "<cmd>%y+<CR>", { desc = "General Copy whole file" })



------- Moves Items in visual mode  ---------
map("v", "J", ":m '>+1<CR>gv=gv")
map("v", "K", ":m '<-2<CR>gv=gv")

------- Joining lines makes the cursor stay where it was ---------
map("n", "J", "mzJ`z")

------- Moves maintaining the cursor in the middle of the screen ---------
map('n', '<C-d>', '<C-d>zz')
map('n', '<C-u>', '<C-u>zz')
map('n', 'n', 'nzzzv')
map('n', 'N', 'Nzzzv')
map('x', '<leader>p', "\"_dp")

------- Clipboard ---------
map('n', '<leader>y', "\"+y", {desc = "Saves to clipboard"})
map('v', '<leader>y', "\"+y", {desc = "Saves to clipboard (visual mode)"})
map('n', '<leader>Y', "\"+Y", {desc = "Saves current line to clipboard"})
map('n', '<leader>p', "\"+p", {desc = "Pastes from clipboard"})
map('n', '<leader>P', "\"+P", {desc = "Pastes back from clipboard"})

------- Telescope Remaps ---------
local builtin = require("telescope.builtin")
map("n", "<C-p>", builtin.find_files, {})
-- map("n", "<leader>fg", builtin.live_grep, {})
map("n", "<leader>fb", builtin.buffers, {})
map("n", "<leader>fh", builtin.help_tags, {})

-- telescope
map("n", "<leader>fw", "<cmd>Telescope live_grep<CR>", { desc = "telescope live grep" })
map("n", "<leader>fb", "<cmd>Telescope buffers<CR>", { desc = "telescope find buffers" })
map("n", "<leader>fh", "<cmd>Telescope help_tags<CR>", { desc = "telescope help page" })
map("n", "<leader>ma", "<cmd>Telescope marks<CR>", { desc = "telescope find marks" })
map("n", "<leader>fo", "<cmd>Telescope oldfiles<CR>", { desc = "telescope find oldfiles" })
map("n", "<leader>fz", "<cmd>Telescope current_buffer_fuzzy_find<CR>", { desc = "telescope find in current buffer" })
map("n", "<leader>cm", "<cmd>Telescope git_commits<CR>", { desc = "telescope git commits" })
map("n", "<leader>gt", "<cmd>Telescope git_status<CR>", { desc = "telescope git status" })
map("n", "<leader>pt", "<cmd>Telescope terms<CR>", { desc = "telescope pick hidden term" })
-- map("n", "<leader>th", "<cmd>Telescope themes<CR>", { desc = "telescope nvchad themes" })
map("n", "<C-p>", "<cmd>Telescope find_files<cr>", { desc = "telescope find files" })
map( "n", "<leader>fa", "<cmd>Telescope find_files follow=true no_ignore=true hidden=true<CR>", { desc = "telescope find all files" })

------- Neotree ---------
map('n', '<leader>po', ':Neotree source=filesystem reveal=true position=left <CR>')

------- Copilot ---------
map('n', '<leader>cd', ':Copilot disable<CR>')
map('n', '<leader>ce', ':Copilot enable<CR>')


------- Terminal --------
-- terminal
map("t", "<C-x>", "<C-\\><C-N>", { desc = "terminal escape terminal mode" })

The interesting part is that when I remove all the telescope mappings, it loads the config.

Another thing is that I using my custom nvchad config, it didn't even load the config neither returned and error message. When trying to clone the default nvchad config, it sort of worked, but only up to a certain number of plugins.

I have also tried multiple times to rm the local files such as ~/.local/share/nvim and ~/.local/state/nvim and ~/.cache as well.

My dotfiles I am using Fedora 40.

Let me know if I can provide any relevant information.


Solution

  • Modules are not available before lazy loads them.

    To fix this add require('garamog.remaps') to end of your init.lua then you will get issue that you need to remap leader before initialzing lazy for that remove vim.g.mapleader = " " from remaps.lua and add it before calling require('lazy').setup

    vim.cmd('set expandtab')
    vim.cmd('set tabstop=1')
    vim.cmd('set softtabstop=1')
    vim.cmd('set shiftwidth=1')
    vim.g.mapleader = " "
    
    
    require('garamog.set')
    
    ---------- Lazy - Package Manager ------------
    local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
    if not (vim.uv or vim.loop).fs_stat(lazypath) then
      vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable", -- latest stable release
        lazypath,
      })
    end
    vim.opt.rtp:prepend(lazypath)
    
    require("lazy").setup('plugins')
    
    require('garamog.remaps')