Closed grezp closed 1 year ago
It doesn't work because packer needs to remap the keys in order for lazy loading to work. Is there a reason why you can't load your keymap inside config = ...
?
If you don't want your keymap to be overwritten, then you can remove the keys inside the packer recipe and do one of the following instead:
module = "telescope"
. This will automatically lazy-load telescope when you require it.cmd = "Telescope"
in your recipe, then change your keymap to call vim.cmd.Telescope("fd")
instead.
As the title suggest, lazy loading keys does not work as expected. If the map is defined inside a config table, then it works as expected. However, if the map is defined before or after packer startup, then the key mapping does not work.
nvim --version
:Features: +acl +iconv +tui See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: " /home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"
Run :checkhealth for more info
vim.g.mapleader = ' '
vim.keymap.set( 'n', 'f',
function()
require('telescope.builtin').fd {
hidden = false, -- don't show hidden files
no_ignore = false, -- don't show ignore files
sorting_strategy = 'ascending',
find_command = {
'fd',
'--type',
'f',
'--strip-cwd-prefix'
},
}
end,
{noremap = true}
)
local install_path = vim.fn.stdpath'data'..'/site/pack/packer/opt/packer.nvim' if vim.fn.isdirectory(install_path) == 0 then os.execute('git clone https://github.com/wbthomason/packer.nvim '..install_path) vim.cmd'packadd packer.nvim' end
require'packer'.startup(function() use'wbthomason/packer.nvim' use{ 'nvim-telescope/telescope.nvim', requires = { 'nvim-lua/popup.nvim', 'nvim-lua/plenary.nvim', }, keys = { 'f',
},
}
end)
vim.g.mapleader = ' '
local install_path = vim.fn.stdpath'data'..'/site/pack/packer/opt/packer.nvim' if vim.fn.isdirectory(install_path) == 0 then os.execute('git clone https://github.com/wbthomason/packer.nvim '..install_path) vim.cmd'packadd packer.nvim' end
require'packer'.startup(function() use'wbthomason/packer.nvim' use{ 'nvim-telescope/telescope.nvim', requires = { 'nvim-lua/popup.nvim', 'nvim-lua/plenary.nvim', }, keys = { 'f',
},
}
end)
vim.keymap.set( 'n', 'f',
function()
require('telescope.builtin').fd {
hidden = false, -- don't show hidden files
no_ignore = false, -- don't show ignore files
sorting_strategy = 'ascending',
find_command = {
'fd',
'--type',
'f',
'--strip-cwd-prefix'
},
}
end,
{noremap = true}
)
vim.g.mapleader = ' '
local install_path = vim.fn.stdpath'data'..'/site/pack/packer/opt/packer.nvim' if vim.fn.isdirectory(install_path) == 0 then os.execute('git clone https://github.com/wbthomason/packer.nvim '..install_path) vim.cmd'packadd packer.nvim' end
require'packer'.startup(function() use'wbthomason/packer.nvim' use{ 'nvim-telescope/telescope.nvim', requires = { 'nvim-lua/popup.nvim', 'nvim-lua/plenary.nvim', }, keys = { 'f',
},
config = function()
vim.keymap.set(
'n',
'f',
function()
require('telescope.builtin').fd {
hidden = false, -- don't show hidden files
no_ignore = false, -- don't show ignore files
sorting_strategy = 'ascending',
find_command = {
'fd',
'--type',
'f',
'--strip-cwd-prefix'
},
}
end,
{noremap = true}
)
end,
}
end)