Neovim: Customizing Telescope 🔭

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we're going to talk about customizing telescope if you don't know telescope is a plug-in for neo of m that works much like fcf from a user standpoint it's got many of the same features and you can port much of your fcf stuff over to telescope and one of the great things about telescope is that the api is so clean and approachable and usable you can just get in there go through the code and customize things as you want to write extensions and do whatever you need to do it's very intuitive makes a lot of sense the telescope documentation is really good and you can go through that i'm going to show you some of the customizations that i've done show you how you can do your own so let's get started i'm in my local clone of the telescope repo so let me show you some of the cool stuff in telescope that you may or may not have seen this is help this is a built-in for telescope it's really great fcf has a similar feature you can go in here and just search for something in help and if you find it just like fcf you select what you want and hit enter and it'll open it up for you that's very nice and again you had that in fcf and i'll just show you hey similar but you'll note that there's no preview although you potentially could set one up another nice built-in is commands and this shows you all the different commands that are available to you if you actually select one it will run the command tree sitter module info we have to pick our module okay all right so let's try another command here we can try get status and you see it runs fugitive git status for you another one you can look through here and see that you have a different telescope key maps here and then you can select one and guess what it opened it up for us that's very nice you can just switch from one picker to another those are some nice built-ins you may want to customize things like searching for your notes and you want to determine what that means where your notes are where things should search you don't always want to search within your current working directory or within your project you may want something from somewhere else and it's very easy to point telescope and the underlying commands to where you want and we'll see that when we get to the code you can see here that i have browse notes now this is the file browser the telescope offers and in here you can go through your notes and open one or even create one now with search notes you can go through and just search your notes you can decide what is a note and put that into your search directories so that only those directories get searched here i'm searching my actual vim runtime path and some documentation and some cheat sheets and some other items and that's all i want when i do search notes live grip just allows you to search within your project this is a built-in sometimes you want to just type in something you type in action okay now we have everything that has action and then we can search for setup and filter further you can also see here that you can search your project for git files if you are in a git repo in here i have a custom picker setup to search through my vim run time i'm constantly editing and updating my config files for neovam and other things like that this way if i want to get to my javascript file type plugin while i'm in there then i have it right here my rust file type plugin whatever i want to get to and i have a few different ones this is a file browser for my invin config stuff so you can see here i have this little folder plugin status line etc and these are some of the files that we will be looking in shortly all right so there isn't much to installing telescope i assume you probably already have it installed and now you want to customize it but we can still take a look at what you need to do to install it and what you might want to go with it here you can see that i have this telescope github plug-in and telescope itself and it's just as simple as with packer just putting use telescope you also need plenary and with telescope you don't have to put anything special in there you can just say use and go for it or if you're using a different plugin manager just plug and organization and repo we can just take a quick look here at some other stuff that i have and plenary gets brought in because get signs requires it so as long as you get it in here then it's fine you can put this also under telescope one thing you might want are dev icons i didn't really want them for telescope however for the lsp status segment of my status line i did want to have some dev icons so i'm using a patched version of source code pro when you set up nvim web dev icons and you have the font installed then automatically telescope and other plugins will just pick these up magically you'll start having dev icons in certain places not super necessary although it can be fun to troll your friends and co-workers with icons that may or may not belong in certain areas let's take a look at my telescope configuration here i'm jumping around using marks pretty handy for files that you always want to open from anywhere anytime you might have seen earlier where i had a little rg prompt to search for things it's right there and so if i wanted to search for the word telescope within telescope i am going to get a lot of stuff okay and all this does is it takes the grip string built in but i'm passing in a few options so instead of searching for the word under cursor which is the default functionality for grip string i'm wrapping it in my own function called grep prompt which uses grip string but gives me that prompt at the bottom like you saw there okay but i still can use grip string and you see it searches for the word function all right and if we go down to grip notes i mentioned this before i am telling live grip i want to search for my string and i want to look in these different directories here and that's it so you just take a function and you wrap it around a built-in and then pass things in as options and you can do that by setting it up this way or like we saw before with setting them up within the body of the require for project files what i do is if it is a get repository then i want to use the built-in git files picker but i pass in my own title get files which actually is just the normal title i was messing with it and then the prompt prefix if you're not in a git repository then i want to just use regular find files here we are in a get repo because we are in the telescope repo even though i am in a different file my location is in the telescope repo all i do is check to see if i'm in a git repo if i am then i want to use git files if i'm not then i want to use find files here we have the find notes and find notes was the file browser this here or i can go through and pick a file and you get the nice preview vm cheat sheet so that it shows up in the search actually and you can see here that i'm using a custom prompt that icon there is a notes icon from nerd fonts that's part of my patched font and so i stuck that in there shorten the path and said hey i want to search in notes and then we talked earlier about my runtime path so that's this here where i'm able to just search for whatever i want it's in my bim runtime path and i have that setup to just search in vim now this is incomplete i needed to search in the neovim config runtime path as well have this separate one because for a while i wanted them separate because i had different things and i hadn't finished combining them and hooking things up and there's still a few things over in vim but i just didn't want to confuse and this is kind of a motivation to get with it here and so in bim config and then i have a general file explorer that i want to be able to use from anywhere and just start from my home directory and just go for it this just starts from my home directory and then i want to find my vim dev folder plugins and then telescope which we're in now all right and for the most part i have defaults here but this is very straightforward it's documented but sometimes it's nice to see an example but i can show you now is here i am requiring telescope in my init.vim file which is entirely lua so even this vim script is wrapped in vim command i am just throwing it all in there so that it gets parsed by lewis so that i can just take this whole entire thing and move it to init.lua there's still a few things i need to work out before i do that and get rid of it i'm taking this opportunity to clean things out i appreciate you watching please like and subscribe there is more content coming your way really soon thank you for watching [Music] you
Info
Channel: Code Smell
Views: 20,745
Rating: undefined out of 5
Keywords: Neovim Customizing Telescope, vim, nvim, joel palmer, code smell, nvim-telescope
Id: nQIJghSU9TU
Channel Id: undefined
Length: 14min 48sec (888 seconds)
Published: Wed May 12 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.