Fork me on GitHub
#vim
<
2017-11-17
>
dominicm07:11:44

I wonder if you could capture the output from the terminal by attaching a handler temporarily. That would allow you to send something like:

(let [{:keys [file line column]} (meta <cword>)]
  (str file ":" line ":" column))
And then open that

dominicm09:11:35

Apparently I lied yesterday. Not 50k, only 20k.

dave12:11:25

FWIW, when i started using ctags, i found my usage of jump-to-source dropped dramatically to 0

dave12:11:48

the ctags aren't totally precise, but they get the job done and don't require a REPL connection

dave12:11:11

another caveat is that you can't jump into the source for a dependency jar like you can with jump-to-source, but i find that it's pretty rare that i need to do that

dave12:11:45

rare enough that i'm usually happy opening a browser and finding the source in github

dominicm14:11:22

I suppose, thinking about it, having namespaces & aliases is actually harmful to ctags and grep/ack.

dominicm14:11:30

elisp & vimscript do not have this problem, at all.

jebberjeb14:11:44

@dominicm re capturing terminal output, I think you could definitely do that. I think you could start up a socket repl in the running process, start another job to do that in the background if you wanted it to happen silently.

jebberjeb14:11:22

@dave do you need to do anything special to get ctags working well with Clojure? I’ve never really gotten a handle on using ctags.

dominicm14:11:56

@jebberjeb I think it might be the ultimate hack if you got it working.

dave14:11:17

@jebberjeb i did have to configure it a bit. i have this file saved as ~/.ctags: https://github.com/daveyarwood/dotfiles/blob/master/ctags

dave14:11:35

works like a charm

dominicm14:11:06

@dave I'm a little surprised you don't have deftask in there 😉

dominicm14:11:15

Is Boot mandatory at adzerk?

dave14:11:22

hmm, that's a good point. i should add that. in practice, i haven't needed to jump to task definitions much, but i don't see why they shouldn't have ctags support

dave14:11:32

i'm also missing defelem for hoplon 🙂

dave14:11:01

boot isn't mandatory, but we're all a bit fanatical about it, so we always use it

dominicm14:11:04

I've stopped having to re-justify the switch from leiningen to boot. Most recently it was "I want live reloading sass without hassle"

dave14:11:14

for us (if i can make an assumption about the rest of the the team), it's mostly a philosophical question. we just prefer to have greater control over our build tasks

dave14:11:09

in the beginning though, our justification was probably "our coworkers micha & alan built this really cool build tool for clojure, let's use it"

dave14:11:24

i have to say, it's super convenient having the brains behind boot and hoplon sitting directly across from me when i run into a boot or hoplon issue 😄

dave14:11:40

i can imagine boot would be a harder sell otherwise

dominicm14:11:43

Yeah. I can imagine. We have the same with yada.

dominicm14:11:55

I'm supposedly the only person who can understand boot at JUXT

dave14:11:41

yada is intriguing. i keep looking for an excuse to try it out on a project

dominicm14:11:11

Not sure what your internal default is, but good excuses include: - 0 copy streaming responses (e.g. images, videos, SSE) - painless HTML semantics (accept json, edn, etc. all "just" work) - painless CORS

dave14:11:16

that sounds compelling. we maybe could have used that when we started writing our primary user-facing web app in clojure+clojurescript 🙂

dave14:11:27

there was some amount of finagling to get CORS working right

dave14:11:46

we're also tinkering a bit with streaming large amounts of JSON objects for our API. that also took some finagling to figure out how to stream stuff out of the database and through ring

dave14:11:06

i might have a look at yada the next time i'm looking at these types of things

dominicm14:11:30

Oh, yeah. Yada already does the streaming JSON thing, both in & out afaik.

dominicm14:11:03

I think it needs a little hint though, as clojure doesn't have a way of representing that naturally.

dominicm14:11:16

It was very useful a little while ago when working on doing large JSON streaming.

dave14:11:15

cool, that sounds promising

jebberjeb15:11:34

@dominicm hrm, looks like file/line info is there in Clojurescript meta as well. That’s nice.

jebberjeb15:11:36

So you just search the classpath for the first file that matches the filename, I guess?

dominicm15:11:14

In clojurescript, the file metadata is an absolute path, so you need different behaviour for cljs & clj.

dominicm15:11:22

But yes for clj search the classpath.

jebberjeb15:11:25

that’s not hard, why is there no library for that? There must be some edge cases that doesn’t cover? Or some common useful cases?

dominicm15:11:31

There's also a catch if you're using boot, which is that you need to search the fake class path.

dominicm15:11:39

There is, it's called cider-nrepl 😄

jebberjeb15:11:47

I was actually looking at it yesterday after we talked. I can’t remember if it just uses meta info, or it tries any other tricks, but I’ll look again.

dominicm15:11:02

It uses meta + some additional information about whether it's running inside boot.

dominicm15:11:53

I was talking about forking cider-nrepl to remove the nrepl-specific parts earlier, in order to use it as a plain library in #unrepl

jebberjeb15:11:36

Yeah really feels like those type of things should be extracted into libs.

jebberjeb15:11:46

Alright, enough screwing around. The logical thing to do here is give ctags a try 🙂

dominicm15:11:17

Spending time on Slack is productive time

jebberjeb15:11:46

oh I can do both 🙂

jebberjeb15:11:02

hmm, just ran exuberant ctags on a small codebase w/ clj, cljs, cljc using @dave’s config and it worked just fine. That’s a nice compromise I guess. No jumping into jars, but at least it’s something.

dave15:11:56

i'm a pretty big fan of ctags, overall -- it works for all kinds of programming languages

dave15:11:22

once you have the keybindings internalized, it's crazy powerful

jebberjeb15:11:24

@dave do you just use exuberant ctags, or other tag generating programs?

dave15:11:58

just ctags. every now and then (when i notice tags are missing), i run ctags -R src (or whatever the source directory is called in the project i'm working on)

dave15:11:18

there are plugins that will do that for you automatically, i just haven't explored them yet

dave15:11:59

i also use vim-tagbar, which is very useful: https://github.com/majutsushi/tagbar

dave15:11:29

it's nice when you're editing a large file with lots of methods, classes, functions, etc. and you just want a quick overview of what's in the file

dave15:11:48

or you want to jump to a method, etc.

jebberjeb15:11:32

thanks for the tips

jebberjeb15:11:14

so, I guess it doesn’t play nicely with symbols that have namespace aliases, huh

dominicm15:11:12

It probably doesn't with :refer [a] :rename {a b} either I suspect.

dave15:11:52

yeah, i've noticed that

dave15:11:18

i've gotten in the habit of highlighting just the part after the / and typing <C-t>

dave15:11:38

kinda lame -- would be a nice thing to fix

dominicm15:11:00

:refer :all ftw? 😂

dave15:11:10

let's bring back :use

dave15:11:22

it will solve all of our problems

dave15:11:45

we will be forced to give functions unique names across namespaces 😂

dave15:11:52

making ctags work perfectly

jebberjeb15:11:53

This seems to be working decently well. I suppose it’s a simple matter to just split the <cword> on / and use the last bit of it in some Vimscript.

dominicm15:11:33

When I browse cider.el, my grepping always gets me the right one, because everything is cider--stacktrace-does-blah.

dave15:11:56

@jebberjeb if you happened to write that bit of vimscript, i would happily steal it for my config 😄

dave15:11:58

i guess it might also be the case that there is some kind of vim configuration option for ctags that would let us strip off everything through / when looking up clojure tags

dominicm15:11:12

Oh yeah that's g:obscure_some_var, it's just in :help duh.

dave15:11:23

of course!

dave15:11:24

@jebberjeb @dominicm how many people use vim where you work? at adzerk, i'm in the minority

dave15:11:23

micha, jarrod and i use (neo)vim, and everyone else uses emacs/spacemacs. although now that i think of it, there are only 6 of us, so that's a 50/50 split 😄

dominicm15:11:50

On my current project, it's 3 vimmers, 3 emacs, 1 cursive.

dominicm15:11:59

In the company, the skew goes way more towards emacs.

dave15:11:47

when alan was at adzerk, he used emacs, so he was the tie-breaker

dave15:11:49

now we're tied again

dave15:11:05

so, next junior dev we hire, i will brainwash into using vim

jebberjeb15:11:33

Let’s see, currently at Cognitect besides myself I think there are 3-4 that use it. But I want to say that everyone besides me also splits time with Intellij.

jebberjeb15:11:17

Paul DeGrandis is a pretty committed vimmer.

jebberjeb15:11:48

It’s mostly split between Emacs & Intellij

dominicm16:11:59

@dave 2 vimmers in my company were brainwashed by me. Malcolm Sparks tried to get them using Emacs, then left me to help them. So I switched them to Vim so I could help.

dave16:11:05

that's great

dominicm16:11:03

It's so strange looking up american people, because you have so many locations which are named the same as those in Britain. Paul is apparently in Exeter, which is where I used to live. I was also born in Birmingham.

dave16:11:39

hah, i have the same experience going the other way

dave16:11:27

durham, for example

jebberjeb16:11:51

I grew up in St. Petersburg.

jebberjeb16:11:03

(Florida :))

dave16:11:07

it occasionally throws me off when i google something about durham and get information relevant to durham, uk

dominicm16:11:36

Ah, yes. Durham. Quite infamous here. "For cambridge rejects" is all I know.

dominicm16:11:09

I don't think we have one of those in the UK @jebberjeb?

jebberjeb16:11:31

second largest city in Russia 🙂

dominicm16:11:00

Ah, didn't know that. I'm not well travelled.

jebberjeb16:11:15

It’s US sibling is not quite so grand.

jebberjeb16:11:47

@dominicm have you gone to vimberlin?

dominicm16:11:59

@jebberjeb I hadn't heard of it. Anything about it of note?

jebberjeb16:11:30

Maybe I should call it Vimfest. It happens in Berlin. I think the user group that hosts it is called vimberlin.

dominicm16:11:24

I only know of vim-jp

jebberjeb16:11:48

@dave Here’s what I ended up with

" Strip off the symbol's namespace
function! SanitizeTag(word)
  return (split(a:word, '/')[-1])
endfunction

nnoremap <leader>tt :exe ":tag ".SanitizeTag(expand("<cword>"))<cr>

dave17:11:15

@jebberjeb nicely done! i just gave it a whirl and it works great. i even remapped <C-]> instead of <leader>tt, and it seems to be a drop-in replacement for the default <C-]> behavior 🙂

jebberjeb17:11:27

I should do that and just stick w/ defaults.

jebberjeb17:11:50

that’s just really pinky intensive 🙂