Fork me on GitHub
#vim
<
2019-11-20
>
martinklepsch00:11:36

@dominicm Agree that tree-sitter is super interesting! And also all the Lua stuff is super cool, Lua is a really fun (and weird). I think for the tree-sitter grammer stuff you wouldn’t need Lua though since it just takes some JSON as input for the parser? Could totally be missing the point here πŸ˜…

sogaiu00:11:18

fennel looks fun too

martinklepsch00:11:05

Yeah, sooo much! I’ve used it to write a toy-ish CLI time tracker, getting back that REPL really unblocked my Lua learning at that point πŸ˜„

martinklepsch00:11:41

With all the Neovim Lua support it could be really cool, seems @olical is even playing around with Fennel/Lua in Conjure https://github.com/Olical/conjure/commits/master

sogaiu00:11:48

cool! yeah, i have my fingers crossed that Olical's fennel / conjure efforts work out.

Olical09:11:49

Cc @martinklepsch My Fennel project that I'll use to rewrite my Neovim config as well as Conjure's Lua and VimL is coming along nicely. I've got a lovely train ride up from London to Edinburgh this Friday to get that sorted and write a post up. Focusing on "replace all viml and lua with a Lisp" for now, then it'll grow into conjure. The plugin / library I'm building is called aniseed. It makes compiling directories of fennel to Lua ahead of time when they change (for your dotfiles) easy, as well as providing mappings for evaluating ranges / selections / motions / files. Conjure plugins will then be a nice mix of Clojure that hooks into Conjure's JVM as well as fennel that gets compiled for you. Fun times ahead! I think this side track or language experimentation will pay off massively in future changes to conjure. I've been shying away from fancier UI features because I don't feel comfortable solving things in viml or Lua.

sogaiu14:11:19

thanks for the update! hope you have a productive ride πŸ™‚

dominicm00:11:04

I'm just thinking about getting something now, rather than later

dominicm00:11:12

lpeg can parse clojure/core.clj in 20ms

dominicm00:11:20

just checking that in luajit

sogaiu00:11:19

wow, that's pretty nice -- i test with clojure/core.clj as my "biggest" clojure file for a program that uses rewrite-clj, and i can definitely feel its weight there.

dominicm00:11:11

yeah, exactly

dominicm00:11:23

I'd prefer it to be closer to 5ms

sogaiu00:11:18

i haven't found much that comes close to the size of clojure.core -- do you come across that much that's similar in size?

dominicm00:11:31

sometimes πŸ™‚

sogaiu00:11:00

i guess i'd better go searching for more data

dominicm01:11:39

luajit is 12ms

dominicm01:11:52

@sogaiu depends on your tool's purpose.

dominicm01:11:12

I was thinking of using this for highlighting, so it needs to be fast.

sogaiu01:11:34

my current use case is invocation from an editor -- doing things like detecting the expression around or to the left of the cursor

sogaiu01:11:22

if you have to do the whole buffer, i guess it would have to be fast

dominicm01:11:22

oh, same thing then πŸ˜„

dominicm01:11:28

oh, maybe not.

dominicm01:11:39

what do you do with the detected expression?

sogaiu01:11:57

the idea is to allow editors to not have to reimplement all of this type of functionality

sogaiu01:11:21

provide pieces that can be built upon so behaviors can be consistent

dominicm01:11:36

what type of functionality πŸ™‚

sogaiu01:11:56

find an appropriate ns, detect expression, find close top-levels, etc.

sogaiu01:11:09

these things vary across editors

dominicm01:11:24

so, to find the close top-level you need the whole buffer right?

sogaiu01:11:46

i have a hack that may make it a bit less -- though i have no proof that it works in general

sogaiu01:11:04

ah actually, that's for detecting the expression -- not the top-level

sogaiu01:11:11

you're right, you need the whole darn thing

sogaiu01:11:42

so it does need to be fast

sogaiu01:11:20

but typical clojure source files don't seem to be that large

sogaiu01:11:29

at least for what i've tested on, it doesn't seem too bad

dominicm01:11:34

now I'm curious to find the largest file I have

sogaiu01:11:34

didn't someone recently fetch some significant portion of clojars (or was it metadata of clojars)?

dominicm01:11:16

I may have figured out how that is done, yeah

dominicm01:11:23

rsync usage is unmetered on clojars, so go crazy

dominicm01:11:32

that is, 42415 loc

sogaiu01:11:06

clojure/core.clj is a measly 7892 loc

dominicm01:11:26

11720 in core.cljs

sogaiu01:11:46

he he -- you are up-to-date πŸ™‚

sogaiu01:11:49

i had to pull

sogaiu01:11:05

thing is, how typical is that?

dominicm01:11:23

I jump to source into these files

dominicm01:11:43

the 42k is pretty extreme tbh, I was surprised to find that

sogaiu01:11:01

yes, i do jump-to-source in my deps too -- but i rarely eval expressions

dominicm01:11:15

woah, vis, an editor which uses lpeg for higlighting. Makes mince meat out of that 42k loc file

dominicm01:11:30

ha, but it's highlighting does not handle unicode properly

dominicm01:11:04

~/src                                                                 0.94s 01:09:11
❯ tokei **/*.clj{,s,c}               
-------------------------------------------------------------------------------
 Language            Files        Lines         Code     Comments       Blanks
-------------------------------------------------------------------------------
 Clojure              5882       743420       619406        37019        86995
 ClojureC             1505       517672       421894        33381        62397
 ClojureScript        4552      1487768      1233528        50189       204051
 Dockerfile              1            5            4            0            1
 Edn                     2           31           25            6            0
-------------------------------------------------------------------------------
 Total               11942      2748896      2274857       120595       353444
-------------------------------------------------------------------------------
That took a while to run

sogaiu01:11:04

i've given up for the moment on highlighting of large files -- try opening a clj-kondo analysis file for a project and its deps some time πŸ™‚

dominicm01:11:36

I think this 42k loc file might be generated. It's a list of place names in the UK.

sogaiu01:11:29

nice, didn't know about tokei

sogaiu01:11:16

(that's an odd name -- the characters and pronunciation used at the repository readme are for "clock" (at least in japanese), but if you change the name slightly it would have been "statistics"...strange)

sogaiu01:11:02

i don't have even a tenth -- though i don't think it's counting correctly:

$ tokei **/*.clj{,s,c}
-------------------------------------------------------------------------------
 Language            Files        Lines         Code     Comments       Blanks
-------------------------------------------------------------------------------
 Clojure               299        20633        16013         1744         2876
 ClojureC                8          772          532           50          190
 ClojureScript           1            2            2            0            0
-------------------------------------------------------------------------------
 Total                 308        21407        16547         1794         3066
-------------------------------------------------------------------------------

sogaiu01:11:54

$ find | grep \\.cljs$ | wc -l
13183

dominicm01:11:16

I have a lot of code. Mine includes a lot of stuff in target folders.

dominicm01:11:35

oh, lpeg is included with neovim now

sogaiu01:11:56

hurray for built-in goodies πŸ™‚

sogaiu01:11:26

$ find | grep \\.cljc$ | wc -l
2733

sogaiu01:11:35

may be i'm not invoking tokei correctly?

sogaiu01:11:45

$ find | grep \\.clj$ | wc -l
15712

dominicm01:11:30

might be to do with shell settings not expanding the same way mine does

dominicm01:11:40

it's possible I have something turned on especially

sogaiu01:11:00

may be so -- will try the default invocation

sogaiu01:11:53

-------------------------------------------------------------------------------
 Language            Files        Lines         Code     Comments       Blanks
-------------------------------------------------------------------------------
 Clojure              6835      1275323      1019262        92211       163850
 ClojureC             1692       308692       250172        17327        41193
 ClojureScript        8471      2162893      1864853        70179       227861
-------------------------------------------------------------------------------

sogaiu01:11:10

totals are off -- because i just kept 3 rows

sogaiu01:11:47

this includes duplicates though -- so unless tokei prunes, the numbers are inflated

dominicm01:11:03

yeah, same as mine, inflated πŸ™‚

dominicm01:11:20

it's just fun really πŸ™‚

dominicm01:11:52

@martinklepsch https://neovim.io/doc/user/lua.html looks like treesitter uses .so files, so a C api?

dominicm01:11:19

the treesitter nvim api, is exposed via the built-in lua engine

martinklepsch08:11:57

Yeah I guess it’s both in the end. What I was thinking is that you can write grammars in any language as the canonical format they are described in is JSON. How you then interact with tree sitter is probably a different thing, C or Lua as you said.

dominicm10:11:17

I'm not sure if it is json or not. The above seems to imply that a .so is produced to represent the parser. I'm guessing that atom is just using some API to create the parser from json.

dominicm10:11:48

https://tree-sitter.github.io/tree-sitter/creating-parsers maybe they're doing on the fly compilation? nodejs is a dependency for developing a new parser. tree-sitter converts javascript into a C parser, and then compiles that.

sheluchin12:11:15

I'm finding vim-fireplace is constantly timing out and requiring me to restart the server and reconnect to cljs. I'm using it with Fulcro 3. Anyone else getting this behaviour?