text stringlengths 0 2.02k |
|---|
**TJ DeVries:** Oh, so maybe I should take a step back... So Neovim's LSP client is just Lua code that's inside of Neovim. |
**Jerod Santo:** It's an LSP client. It does not have its own language server in there. |
**TJ DeVries:** Right, that's correct. So it doesn't know how to answer any of the questions. It only knows how to ask... |
**Jerod Santo:** I thought maybe it had a set number of language that it already had all of the stuff ready to go. |
**TJ DeVries:** No, it does not. We have nvim-lspconfig, which is just like a repo that helps you get some of those running, but you need to figure out how to install those and make them executable on your machine. Being a package manager is not what we're good at. We're good at being a text editor. |
**Jerod Santo:** Okay. |
**TJ DeVries:** Someone else can figure that out and do that, and there are various plugins to help you install... But Neovim just has basically a bunch of Lua code that knows how to handle the responses and ask the right questions. You need to install separate executables to do that. |
**Nick Nisi:** And to that end I'm using something called lspinstall, that handles installing those and then using lspconfig to configure them for Neovim. |
**TJ DeVries:** Yeah. It'll just install it for you, and stuff. So we leave that to other people; you can handle that. I'm sure there'll be one for specific distros, or specifically for Nix, or there's one for Docker containers... There's a lot of different ways that you can do that that's not our strong suit. We try a... |
**Jerod Santo:** Gotcha. Well, let's move on to tree-sitter, because another cool technology -- they seem like they're similar, right? I mean, you're talking about the syntax tree, about language... Help us understand tree-sitter and how it's different than LSP. |
**TJ DeVries:** Yeah, so this is a really common question, so it's a good one, for sure. A really high-level way that you should start thinking about both technologies is that tree-sitter only deals with one particular file, and it only deals with the text that is in that file. It has no additional information. An LSP ... |
The second aspect is tree-sitter is built in a lot of ways specifically to run inside of your text editor, as opposed to an LSP, which is some external process. So tree-sitter at a high level, for those who don't know, is effectively a library for writing error-recovering incremental parsers, and it's very good at doin... |
So that's the first part. And then the second bit that's very important is that it's incremental. So it does not reparse the whole tree, which is awesome for when you're typing keystrokes in a very large file, because you're going to smash 80 keystrokes; you don't wanna reparse the entire file 80 times, instead of actu... |
**Jerod Santo:** \[52:14\] I'm with you. |
**TJ DeVries:** Okay. So once again, tree-sitter only focuses on exactly that file. So this is cool, because this lets you do things like -- you can request highlights for the file by asking the tree questions, and basically getting back named nodes. You can write queries in this scheme-like language; it will return to... |
So this is like a really great improvement, and it allows you to write much better and powerful syntax highlighting than you could with just regexes, which is like the built-in Vim syntax engine... And it prevents you from getting these situations where -- I don't know if you've ever had this, but in certain complicate... |
So that's sort of like the first level of tree-sitter. And it doesn't communicate over the wire. Tree-sitter is running inside of Neovim. It's embedded inside of Neovim. Now, the parsers and the queries and things like that - those are external to Neovim, and can be configured by users. I have my own custom grammar for... |
**Jerod Santo:** And is the engine something that was built by the Neovim team, or are you actually embedding somebody else's -- is tree-sitter its own project? |
**TJ DeVries:** Yes, tree-sitter is its own project. It was originally made for Atom, but several other editors now have used it because it is designed to be a library to be embedded inside of other editors... So it's very fast and performant, and they've spent a lot of time making it really awesome, and the tree-sitte... |
**Nick Nisi:** To get started with it, kind of similar to lspconfig, you have to install a separate plugin. Is that just to help with the configuration then? I think that's where I had confusion, was because I was like "I thought that it was built-in, but I have to install this plugin." |
**TJ DeVries:** Yeah, so to be clear about it - you actually don't have to install plugins for either. You can start up the server by yourself for LSP. It just is a little bit more boilerplate, so that's why we have lspconfig. But it's certainly possible to do. Lspconfig literally only has configurations. |
**Nick Nisi:** Gotcha. |
**TJ DeVries:** But for tree-sitter you also don't necessarily have to install the plugin. It'll just be more complicated. It would involve you downloading a grammar file, running tree-sitter to generate the bindings, because it's a separate executable to generate these bindings... And then creating your .so shared exe... |
\[56:05\] So the engine, all of the interior things to do, like get the tree and have it parse incrementally as you type in all of that kind of stuff - that's inside of Neovim all the time. Someday my goal would be we would at least ship tree-sitter grammars inside of Neovim for C, Lua and Vimscript, because those are ... |
**Jerod Santo:** So it sounds like tree-sitter is driving a lot of the innovation around these cool, new plugins that I keep seeing that are Neovim only, not Vim as well, because of the tree-sitter support. |
**TJ DeVries:** Yeah, I can give you a really cool example of a few things that people have been doing with tree-sitter that are much further beyond just highlighting... |
**Jerod Santo:** Please do. |
**TJ DeVries:** So a relatively straightforward and easy to understand one is a plugin called nvim-ts-context-commentstring, I think, off the top of my head; I don't remember exactly the name. But what it does is tree-sitter tells you what language you are currently inside of, and those languages can be embedded in sid... |
**Jerod Santo:** Yes. |
**TJ DeVries:** So nvim-ts-context-commentstring - all it does is it'll just update the comment string option, which is a built-in option, depending on which language tree-sitter currently detects. So if it detects that you're inside of JavaScript land, it'll set it to // %s. If it detects that you're inside of HTML, i... |
**Jerod Santo:** Right. |
**Nick Nisi:** That's cool. |
**Jerod Santo:** That one just honestly rocked my world, because I've had that problem in my life forever. |
**TJ DeVries:** Yeah. And so this is even cooler, because it doesn't just work for those languages. In Lua you can write FFI code, which is actually C, and it is somewhat deterministic how you start and end those cdef blocks. So you can actually write a tree-sitter query that tells Neovim "Hey, inside of this string it... |
**Jerod Santo:** That's awesome stuff. |
**TJ DeVries:** That's one example. I'll give you another one that I think is for me very fun. I use a snippets plugin called LuaSnip and it's kind of interesting. I've just been exploring that lately... But it allows you to sort of run Lua code as you're expanding your snippets to sort of generate what the next text s... |
\[01:00:01.17\] So I actually wrote a Lua snippet that will ask tree-sitter basically - it has a custom query that I wrote inside of Golang that will ask tree-sitter "Hey, what is the return type of this function?" So it can query the tree, it gets back the current node that you're in, it asks for "Hey, what is the nea... |
So it's very cool, because I can just type "ie" for if error, expand my snippet, and correspondingly, the right signature is generated as a return value. These are the kinds of things that make me very, very excited about tree-sitter, and why I say it's cool to get better highlighting... We look at our highlighting all... |
**Jerod Santo:** Goodness gracious. That is really neat. We're getting tight here, but we've teased Telescope a few times... Let's hit the nail on the head. Tell everybody about your-- |
**Nick Nisi:** Let's peer into it. |
**Jerod Santo:** Ooh, there you go, Nick... |
**TJ DeVries:** \[laughs\] |
**Jerod Santo:** That's why we pay you the big bucks. |
**TJ DeVries:** \[laughs\] So Telescope is a fuzzy finder that I started and I've had a lot of contributors to over the past year. I cannot thank enough the contributors to the project. In just over the last year it's gotten over 3,000 stars and nearly 130 contributors, and I think that by itself is somewhat of a testa... |
But in terms of what Telescope is and why I made it - I partially made it just to explore writing some stuff in Lua as a way to push our API and boundaries to find out what we should be including in Neovim core. But as I was working on it, some of the things that I've struggled with doing in the past with fuzzy finders... |
For example, I love fzf. It's a very awesome tool. I use it all the time on the fly, but it's very difficult to do something like pass a function through fzf, because you have to encode it in some way, and then decode it again later, because fzf processes STDIN and STDOUT. So Telescope is all Lua from the top of the st... |
So my main goal for making it was just to basically create the most extensible fuzzy finder that I could imagine. Every part of Telescope is configurable. The sorting algorithm is just an interface of a function, so you can have fzy soring, fzf, strict matching, N-gram matching... You can write whatever you want to do,... |
The previewers are all just Lua functions, so some of them -- like, if you're previewing buffers, it just literally opens the preview in a Neovim buffer, so you get exactly the same highlighting as you would if you open the file, because it is literally you opening the file. |
\[01:03:59.17\] The ability to sort, and how you're sorting those, and when you filter them - those are all configurable. The display, and UI, and different themes - they're all individually configurable, and what my goal was was to make the most configurable fuzzy finder that I could do, with an easy API to basically ... |
**Jerod Santo:** So on my to-do list was to yank Nick's fzf Neovim setup and use it for myself. Should I just bypass that? Is Telescope ready for me? Should I just use it right away, or is it still baking? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.