text stringlengths 0 2.02k |
|---|
[1318.62 --> 1330.60] I mean, JavaScript's ability to be embedded easily inside of a C application is not, I think, considered one of its strong suits, as well as sort of its minimalism, right? |
[1330.68 --> 1334.94] I mean, Lua can be run and is run inside of some like Linux kernels. |
[1335.30 --> 1346.68] So the portability and the size and all of these other things are really great features, as well as like NeoVim, I guess, like pinned in a way to Lua 5.1, |
[1346.68 --> 1349.34] which is the language is complete. |
[1349.60 --> 1350.28] There's no changes. |
[1350.56 --> 1352.50] There's no new things being added to the language. |
[1352.70 --> 1363.02] There's no things being removed, which is really nice for writing a plugin now and having it work in 15 years as opposed to not throwing shade at anything in JavaScript. |
[1363.02 --> 1372.96] But I feel like it is a common problem that I see people talk about on the internet that yesterday my NPM build worked and tomorrow it does not. |
[1373.42 --> 1375.84] Not to mention, you know, changes within the language itself. |
[1375.84 --> 1382.02] So there's a lot of things about Lua that provide sort of an incredible match with NeoVim. |
[1382.34 --> 1393.40] Like I said, embeddability, size, portability, and the fact that it's sort of static are really great things for us in terms of shipping a small binary that can work in a lot of places. |
[1393.94 --> 1397.68] Yeah, it almost seems like Lua was purpose built for use cases like this one. |
[1397.68 --> 1401.90] Yes, that is exactly what the design principles of Lua are. |
[1402.20 --> 1404.82] One of the primary design principles is embeddability. |
[1405.42 --> 1409.24] So, yes, this is exactly the case where you would want to use Lua. |
[1409.42 --> 1413.94] You do not want to use Lua to write your 10 million line monolith. |
[1413.94 --> 1416.48] That is not the purpose of the language. |
[1416.66 --> 1427.14] The purpose of the language is to be embedded inside of other languages to provide relatively safe and easy ways to script and extend something, right? |
[1427.16 --> 1435.78] Like you're not going to have a memory like leak in the same way or a memory problem with like writing C to script your editor or something like that. |
[1435.88 --> 1441.38] That's not exactly the same kind of fun experience, at least for me. |
[1442.02 --> 1442.46] Right. |
[1442.46 --> 1454.76] Now, Nick, I know that you've been porting your Vim config over to Lua in the last couple of weeks because, as TJ mentioned, NeoVim, you can configure it in Vim script and you can also configure it in Lua. |
[1455.28 --> 1457.98] You can have an init.vim or an init.lua. |
[1458.06 --> 1458.98] Is that the same file name? |
[1459.32 --> 1460.28] Yeah, you can have either one. |
[1460.56 --> 1461.40] You should not have both. |
[1461.88 --> 1464.94] But, Nick, you've had both here for a while or I don't know how you've been managing that. |
[1465.12 --> 1466.10] What's been your experience? |
[1466.22 --> 1468.52] Because I don't think you've used Lua previous to this. |
[1468.54 --> 1468.96] Is that right? |
[1469.36 --> 1469.82] That's true. |
[1469.82 --> 1471.54] I have not used Lua before this. |
[1471.54 --> 1476.72] And I initially was hesitant to even start because I was just like, I don't want to learn Lua. |
[1476.94 --> 1479.12] I don't have any practical application for it. |
[1479.18 --> 1481.80] But then I was like, wait a minute, I'm learning Vim script. |
[1482.02 --> 1484.48] I don't have any practical application for that outside of this. |
[1484.98 --> 1489.66] The thing that really pushed me into it, as I mentioned, I've been kind of a recent convert to that. |
[1489.66 --> 1498.54] I know that a lot of people have been using nightlies of NeoVim, like, I guess, 0.5, maybe I'd call it, the Lua support version for a while. |
[1498.66 --> 1502.06] But I only recently jumped on that and started using it. |
[1502.40 --> 1505.36] And it was because I saw some cool plugins that I wanted to use. |
[1505.36 --> 1520.94] And so it initially just started out with me installing the nightly of NeoVim and then just having my init.vim and putting in, like, a Lua require to open up the configuration for, like, a specific plugin and be able to use that. |
[1520.94 --> 1525.34] And I kind of didn't like that as I started adding more and more plugins. |
[1525.48 --> 1528.34] I didn't like that I just kept calling out to Lua for that. |
[1528.42 --> 1539.62] And so I started, like, I just went in as an experiment to see, like, what it would take to translate my, like, at the time, 600-something line of init.vim into init.lua. |
[1539.88 --> 1545.84] At the end of it, it came out as, like, 240 lines of Lua, which was pretty surprising. |
[1545.84 --> 1551.00] But that's because I, like, split out plugins into its own plugins.lua that set up all of that. |
[1551.04 --> 1552.30] But that was still only, like, 50 lines. |
[1552.38 --> 1553.96] Like, I lost 200 lines in there somewhere. |
[1554.54 --> 1556.88] And I feel like it's more powerful now. |
[1557.32 --> 1559.48] And that's losing, not like losing your car keys. |
[1559.54 --> 1560.88] That's like losing weight, you know? |
[1560.94 --> 1562.10] That's the kind of losing you want to do. |
[1562.26 --> 1562.60] Exactly. |
[1562.78 --> 1562.96] Yeah. |
[1563.98 --> 1570.80] But I guess from your perspective, TJ, would you say that there's a big benefit to converting, like, your configuration to Lua? |
[1570.80 --> 1577.02] Or is this, was the primary intention to be more, like, for plugin authors to be able to write more robust plugins? |
[1577.56 --> 1577.72] Yeah. |
[1577.84 --> 1582.74] So there's, like, a couple, I guess, sort of aspects to chat about, like, in that area. |
[1582.92 --> 1594.30] The first one is I don't think that we have yet implemented everything in NeoVim to make it, like, super elegant and easy to write your entire configuration in Lua. |
[1594.50 --> 1596.62] Like, that's going to take time. |
[1596.72 --> 1600.22] Like, I have a work-in-progress PR for auto commands, for example. |
[1600.22 --> 1600.58] Yeah. |
[1600.76 --> 1604.02] That would allow you to directly pass Lua refs inside. |
[1604.26 --> 1611.36] And, like, NeoVim in the C code will hold a reference to that Lua ref until it's ready to release it and then release it. |
[1611.62 --> 1611.84] Nice. |
[1611.88 --> 1613.84] But that requires, like, a lot of changes. |
[1614.26 --> 1616.94] But that's a story for a different day if we want. |
[1617.18 --> 1623.06] But the point being, you still basically have to write your auto commands in VimScript, even if you're, like, inside of Lua. |
[1623.18 --> 1625.52] I have a lot of in Vim execs in there for that stuff. |
[1625.66 --> 1626.20] Yeah, exactly. |
[1626.20 --> 1630.42] So, like, that doesn't really give you any necessarily gain. |
[1630.52 --> 1634.80] So, there's some parts of my config that are still in VimScript and probably will be for a long time. |
[1634.96 --> 1640.38] I mean, the other part, too, is, like, if it's working really great for you, I don't see any reason to change it over. |
[1640.38 --> 1647.04] Like, it's going to work well, like, to do a lot of the set operations or, like, simple things like that. |
[1647.20 --> 1650.50] Like, VimScript is a DSL for doing those. |
[1650.62 --> 1654.92] It will work probably nicer than we can sometimes do inside of Lua. |
[1655.20 --> 1667.38] Although some of them have sort of been mitigated by things like Vim.opt, which allows you to sort of use Lua and MetaTables to set Vim options more, like, ergonomically, I guess. |
[1667.38 --> 1674.42] So, I would say, like, there are things that are nice about setting up your config in Lua. |
[1674.60 --> 1682.98] Like, you know, you can use closures really easily and there's a lot of ergonomics about passing around functions or doing validation or whatever that is. |
[1683.36 --> 1689.44] But I don't see, like, a whole lot of gain of, like, just switching over to init.lua right now. |
[1689.44 --> 1696.20] I think a lot more of the benefits are about extending, like, particular parts of your, you know, configuration. |
[1696.64 --> 1705.64] Maybe you have a complicated function that, you know, shelled out to some commands and parsed some strings and then would do something within a certain buffer of a certain file type. |
[1706.02 --> 1709.98] Well, that might be a lot nicer to write in Lua than it is in VimScript, right? |
[1709.98 --> 1716.52] But, like, changing set number to Vim.opt.number equals true, I don't know. |
[1716.58 --> 1720.84] That doesn't really strike me as, like, wow, that's so mind-blowing. |
[1722.06 --> 1723.12] Pulling me out right now. |
[1723.44 --> 1727.66] So, maybe someday I would say, like, without hesitation, you should just port it over. |
[1727.76 --> 1736.92] But I think the primary focuses are much more about scripting the editor in a more sort of deep and customizable way than just, like, setting options, if that makes sense. |
[1736.92 --> 1748.54] For sure. And, yeah, I think that from that translation, a big thing that I really liked, like, yeah, auto commands and things like that, I'm just, like, basically it's just a string of Lua in my config that's being run. |
[1748.84 --> 1757.62] But other things, like, I use a plugin, I've used a plugin for years called Vim Startify that lets me kind of configure what the Vim Start screen looks like. |
[1757.62 --> 1760.32] And, you know, it shows the recently used files and things like that. |
[1760.40 --> 1767.28] But it has a big, like, object that you configure and tell it exactly what you want it to show and do and all of that. |
[1767.82 --> 1776.98] And doing that in VimScript, like, I've always just hated that syntax because you have to, like, as you put things on a new line, you have to have the forward or the backslash on it everywhere. |
[1777.22 --> 1778.50] And it was just really annoying. |
[1778.50 --> 1783.32] But things like that, being able to use, like, a Lua, do you call that a table? |
[1783.62 --> 1783.78] Yeah. |
[1784.10 --> 1789.64] Yeah, a Lua table to hold all of that information and then just be able to access it from Vim. |
[1789.84 --> 1796.32] And I can do things like access other, like, objects like that through, like, the, I think it's underscore capital G for, like, the global. |
[1796.32 --> 1801.56] And then being able to access from Lua Vim functions through Vim.fn. |
[1801.78 --> 1804.26] Like, that stuff is really cool, being able to do all of that. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.