Closed DanielCardonaRojas closed 1 year ago
@DanielCardonaRojas Hey thanks I appreciate it! I personally use packer and have not used lazy. When I get the chance I'll give this a look . Lazy seems to be taking over as the go-to plugin manager AFAIK :)
Actually I think this works fine with:
return {
"Everduin94/nvim-quick-switcher",
}
I think I was trying to apply the opts here which I don't think makes sense. I think this can be closed.
Hey sorry I took forever to get back to you on this! Glad to hear its working, feel free to reach out if you have any other comments or questions.
Hey, I've just moved from vscode to astrovim and I'm still learning how to use lazy.
It would be really helpful if you could give a little more context. Which file that return goes into?
I tried adding the string to my config init.lua but I just get errors when I open nvim.
if vim.loader and vim.fn.has "nvim-0.9.1" == 1 then vim.loader.enable() end
for _, source in ipairs {
"astronvim.bootstrap",
"astronvim.options",
"astronvim.lazy",
"astronvim.autocmds",
"astronvim.mappings",
<--- I tried adding it here but get errors.
} do
local status_ok, fault = pcall(require, source)
if not status_ok then vim.api.nvim_err_writeln("Failed to load " .. source .. "\n\n" .. fault) end
end
if astronvim.default_colorscheme then
if not pcall(vim.cmd.colorscheme, astronvim.default_colorscheme) then
require("astronvim.utils").notify(
("Error setting up colorscheme: `%s`"):format(astronvim.default_colorscheme),
vim.log.levels.ERROR
)
end
end
-- Enable showing hidden files in AstroVim Explorer
vim.g.astro_galaxy_browsing_explore_hidden = 1
require("astronvim.utils").conditional_func(astronvim.user_opts("polish", nil, false), true)
Okay so I think I installed it now but I have no idea where to put the options. I mean out of the box it seems to do nothing? I guess I need to set up the options specified in the readme but as a beginner there's no context. I don't know where to put those settings.
So I looked in my plugin status and I can see it's not loaded:
but it is there. I am currently in an html file I'm not sure how to get the plugin loaded.
@TheDevelolper - Hey there, I have not used lazy before but I'll try to update the docs when I get the chance.
Quick switcher is slightly unique in the sense that it just exposes lua functions. i.e. it doesn't have a setup function and you just bind the functions to hot-keys.
As an example, you could run something like this in command mode require('nvim-quick-switcher').find('.service.ts')
So for a setup/keymap example, I have a file called nvim-quick-switcher.lua
that looks something like this
local keymap = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }
-- Tests
keymap("n", "<leader>ot", "<cmd>:lua require('nvim-quick-switcher').find('.+test|.+spec', { regex = true, prefix='full' })<CR>", opts)
-- Angular
keymap("n", "<leader>oy", "<cmd>:lua require('nvim-quick-switcher').find('.service.ts')<CR>", opts)
keymap("n", "<leader>ou", "<cmd>:lua require('nvim-quick-switcher').find('.component.ts')<CR>", opts)
keymap("n", "<leader>oo", "<cmd>:lua require('nvim-quick-switcher').find('.component.html')<CR>", opts)
keymap("n", "<leader>op", "<cmd>:lua require('nvim-quick-switcher').find('.module.ts')<CR>", opts)
-- SvelteKit
keymap("n", "<leader>oso", "<cmd>:lua require('nvim-quick-switcher').find('*page.svelte', { maxdepth = 1, ignore_prefix = true })<CR>", opts)
keymap("n", "<leader>osi", "<cmd>:lua require('nvim-quick-switcher').find('*layout.svelte', { maxdepth = 1, ignore_prefix = true })<CR>", opts)
So if lazy has somewhere you can run arbitrary code or call keymap
that might be the place to do it.
What worked for me: Create a file in plugins folder with any name (quick-switcher.lua for example) and set keys you want
return {
"Everduin94/nvim-quick-switcher",
keys = {
{
"<leader>oo",
"<cmd>:lua require('nvim-quick-switcher').find('.component.html')<CR>",
desc = "Open template file",
},
{
"<leader>ou",
"<cmd>:lua require('nvim-quick-switcher').find('.component.ts')<CR>",
desc = "Open Component File",
},
{
"<leader>op",
"<cmd>:lua require('nvim-quick-switcher').find('.module.ts')<CR>",
desc = "Open Module File",
},
{
"<leader>oy",
"<cmd>:lua require('nvim-quick-switcher').find('.service.ts')<CR>",
desc = "Open Service File",
},
},
}
This plugin looks great I think its a very cool idea. Unfortunately I was trying to integrate this with LazyVim and got some setup issues that I'm not quite sure how to fix. Would be great to get some documentation for lazy package manager.