vim

For discussion on all things (neo)vim.
orestis 2020-08-06T10:13:03.445400Z

Hey vimers- vim was my first “programmer” editor and since then I went through various others (Xcode, JetBrains, Spacemacs, Emacs, VSCose). Now I’m thinking to circling back to vim, I think I still remember most commands :)

orestis 2020-08-06T10:14:10.447100Z

What’s a good way to get started? I see neovim is the way to go these days, and there’s a few Clojure related plugins already. Any other tips for modern vim development?

orestis 2020-08-06T10:14:54.448Z

FWIW I prefer GUIs to the terminal, looks like there’s a few neovim guis available.

dharrigan 2020-08-06T10:21:26.448300Z

I use neovim with conjure - works really well.

🎉 2
dharrigan 2020-08-06T10:21:35.448500Z

(coupled with clojure-lsp)

dharrigan 2020-08-06T10:22:23.449Z

There's a channel #conjure that may be helpful if you consider looking at it 🙂

orestis 2020-08-06T10:24:32.450600Z

What about non-Clojure stuff? I remember that 10 years ago I had a nice .vimrc file for fuzzy finders etc. What’s the consensus these days for quality of life plugins?

orestis 2020-08-06T10:25:17.452Z

(I backed neovim when it was announced thinking it will probably fail but it was a nice moonshot - glad to see it going strong!)

dharrigan 2020-08-06T10:25:58.452800Z

there are tonnes of modern plugins - like fzf for fuzzy searching, others include vim-clap, vim-which-key, vim-sandwich etc...

dharrigan 2020-08-06T10:26:41.453300Z

I use vim petty much as my go-to editor, for nearly everything. When I have to use Kotlin/Java, I jump into IntelliJ

Zoltan Kalmar 2020-08-06T11:08:25.454800Z

before install any plugin I recommend to try the vanilla way. There are a lot of articles about it: https://vimways.org/

1
Zoltan Kalmar 2020-08-06T11:09:24.455400Z

one of my favorite: https://vimways.org/2018/death-by-a-thousand-files/

dave 2020-08-06T12:30:04.456500Z

i use vim for everything, even including stuff like java where i've noticed that people tend to use IDEs i've found the experience of writing java in vim with LSP integration is surprisingly good

dave 2020-08-06T12:31:09.457400Z

even before i started integrating LSP into my vim setup, i had a reasonably good experience just editing java code ("blindly") in vim and running the project from the command line (via gradle, mvn, etc., or even just java) after i make changes

walterl 2020-08-06T12:52:48.458400Z

What @dave said. All of it. 👍 For me there was more C# than Java, though.

dave 2020-08-06T12:53:43.458800Z

i occasionally write C# at work, and i do it in vim 🙂

dave 2020-08-06T12:54:02.459300Z

without LSP integration, unfortunately, because the version of mono we use is so old, the LSP server doesn't support it 😑

walterl 2020-08-06T12:56:45.459400Z

That's hard to answer, since there are so many plugins, and such a wide variety of setups you can construct with them. All I can say is what works for me: https://github.com/walterl/dotfiles/blob/master/_config/nvim/init.vim#L72-L158 (I'm clearly not a purist like @kalmiz 😝)

walterl 2020-08-06T12:58:13.460500Z

Ha! Ditto. Luckily that's many years past for me 🙂

walterl 2020-08-06T13:00:05.462300Z

When I say I use vim for "everything"/"most things", it means that I have a keyboard shortcut to pop up nvim in a new terminal, setup for Markdown editing, so that I can write longer Slack messages (or emails) too. :neckbeard:

dave 2020-08-06T13:00:21.462500Z

ooh, i like that idea

dave 2020-08-06T13:01:22.463700Z

i have a vims (mnemonic: "vim scratch") shell alias that opens vim editing a file with a name like /tmp/scratch-20200806090055.adoc, or a different extension if i provide one, e.g. vims clj for a scratch clj file

❤️ 1
dave 2020-08-06T13:01:37.464100Z

a keyboard shortcut is the next level 😄

orestis 2020-08-06T14:12:07.465Z

Ok so neovim with Conjure works nicely. What do I gain with Clojure-lsp? Haven’t looked closely yet.

🎉 1
dharrigan 2020-08-06T14:23:15.465800Z

things like completion, autocomplete, jumping to different definitions

Olical 2020-08-06T14:32:55.466800Z

fwiw, I don't use any LSP but I've heard very good things, I think it can complement other tools really well (as @dharrigan is pointing out!). Neovim 0.5+ will have a built in LSP client too! So you won't need to install CoC etc (although I guess there will be tradeoffs)

dave 2020-08-06T14:42:59.467400Z

completion and linting are the main things i get out of clojure-lsp

2020-08-06T15:03:18.469400Z

I am sort of a neanderthal - I like the facilities of the repl itself. I use the very good :terminal provided by neovim, plus neoterm which provides simple commands for sending a region to one of the terminals (eg. the current form). It doesn't automatically change to the namespace I'm in, but gives me the direct repl experience (actual log of things I ran and printouts, etc.)

2020-08-06T15:04:28.470500Z

I use fzf for finding files in other people's projects, in my own projects my namespace layout is sane so I don't need it :D

2020-08-06T15:04:43.470800Z

I use :grep with ag as my grepprg

2020-08-06T15:05:19.471400Z

then the standard :cope to browse and jump to results, C-I / C-O to go forward and back through recent jumps

2020-08-06T15:05:32.471700Z

and :tabe to keep groups of buffers organized

Olical 2020-08-06T15:06:15.472500Z

Not trying to sell you on it or make you switch but for the record: Conjure keeps a log buffer with trimmed snippets in comments of what you ran and the resulting stdout / err and results as data within a Clojure buffer that you can edit and re-eval etc 😄 I felt like all the other tools lacked that easy access to history and context behind your evals, the log buffer tries to address that.

2020-08-06T15:06:19.472800Z

finally q: to browse recent : commands as an editable buffer isntead of the crappy : mode keybindings

Olical 2020-08-06T15:06:49.472900Z

(you may have already dismissed it for other reasons too, but yeah, thought it was a feature worth mentioning)

2020-08-06T15:07:18.473100Z

terminal also gives me an identical UI to a repl on staging via ssh, a clj stdio repl, an nrepl client, or a socket repl

2020-08-06T15:07:42.473300Z

I have looked at conjure, but it doesn't fit my criteria for features/complexity tradeoff right now

Olical 2020-08-06T15:07:57.473500Z

Yep, sounds totally fine to me

Olical 2020-08-06T15:08:05.473700Z

Your setup sounds super simple but effective, I like it

Olical 2020-08-06T15:08:13.473900Z

Less to go wrong too!

2020-08-06T15:08:40.474100Z

funny thing, the initial motivation was when I switched to being a senior engineer and mentoring other devs

2020-08-06T15:09:01.474300Z

I realized that I couldn't pull up to pair with Amy and show her how to do something in sublimetext!

1
2020-08-06T15:09:33.474600Z

I was using emacs at the time as well, and CIDER was breaking every week

2020-08-06T15:10:10.474800Z

what I realized was that if I used a less "magical" toolset, I learned things that were guaranteed to work if the coworker was using clojure, period

👍 2
2020-08-06T15:11:38.475Z

and I realized that the things that were total deal breaker needed features were provided by the :reload arg to require , load-file, doc , javadoc , apropos, find-doc

2020-08-06T15:13:39.475400Z

and that the kind of code that was written by people who use "jump to source" as an instant shortcut is too often absolute shit

2020-08-06T15:13:55.475600Z

orzo code - lots of meaningless tiny pieces with poorly defined relationships

timo 2020-08-06T15:15:25.476Z

do you @noisesmith have a .vimrc file somewhere publicly? I don't get the :reload arg thing

2020-08-06T15:15:48.476200Z

oh - that's not vim, that's clojure (require 'some.ns :reload)

timo 2020-08-06T15:15:59.476400Z

ah right

timo 2020-08-06T15:16:10.476600Z

didn't know that actually

timo 2020-08-06T15:16:13.476800Z

thanks

2020-08-06T15:16:23.477Z

there's also :reload-all which recursively reloads

timo 2020-08-06T15:16:40.477200Z

good to use basic stuff, in the end one knows more stuff:)

2020-08-06T15:17:24.477400Z

@timok here's a trick you might like: (do (require 'my.sut.ns :reload-all) (doto 'my.sut.ns-test (require :reload) (in-ns) (clojure.test/run-tests)))

2020-08-06T15:17:57.477600Z

if I do that all in one line, iterating my tests for the current ns I'm working on is just a question of up-arrow followed by newline in the repl

timo 2020-08-06T15:18:36.477900Z

I will try that out

2020-08-06T15:18:39.478100Z

and after a repl restart, that single line fully recreates my testing flow to iterate again

2020-08-06T15:19:31.478300Z

then the test failures remind me of what I was working on, and I can ignore the tools and just do my flow

timo 2020-08-06T15:20:30.478500Z

sounds good and I want to become a neanderthal as well:)

timo 2020-08-06T15:20:48.478700Z

using too many plugins that kind of not work the way I want them

2020-08-06T15:32:14.478900Z

I'm not trying to start a new religion, but I'm happy to assist if you want to know how to do a particular task directly with the clojure repl

👍 1
orestis 2020-08-06T15:53:10.480100Z

I get completion and jumping to namespaces from Conjure. How is completion different from autocomplete?

orestis 2020-08-06T16:31:20.480900Z

I’d love to see a screencast of your workflow @noisesmith

2020-08-06T16:32:07.481100Z

I might even have time for that soon haha

timo 2020-08-06T16:32:29.481400Z

that'd be awesome

orestis 2020-08-06T16:32:55.482600Z

If I understand correctly you launch a whatever REPL that allows you to type stuff, then use the editor to just simulate the typing

orestis 2020-08-06T16:33:19.483200Z

Hope you have time due to vacation ;)

2020-08-06T16:39:22.483500Z

it's a scheduled layoff, Funding CIrcle is laying off all US engineering

😢 2
2020-08-06T16:39:47.483700Z

but if I'm being honest I'm overdue to spend some time on my own long term software projects anyway

2020-08-06T16:39:54.483900Z

and those will involve Clojure

2020-08-06T16:40:08.484100Z

and I can actually afford to take time off, I've been careful with money

dominicm 2020-08-06T17:08:18.487700Z

@noisesmith I've been considering something similar recently. Things like jump to definition would be my big miss, but I experimented with having my repl handle that a little while ago.

2020-08-06T17:12:54.488500Z

clojure.repl/source is right there of course (as well as <http://clojure.java.io/resource|clojure.java.io/resource> to find the specific object that contains your function)

2020-08-06T17:14:05.488800Z

user=&gt; (require '[<http://clojure.java.io|clojure.java.io> :as io])
nil
user=&gt; (io/resource "clojure/core.clj")
#object[java.net.URL 0x74e81ce0 "jar:file:/home/justin/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar!/clojure/core.clj"]
user=&gt;

2020-08-06T17:14:54.489400Z

I might even write a little helper that turns "jar:file:/home/justin/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar!/clojure/core.clj" into a path nvim can open

2020-08-06T17:15:29.489800Z

I'm sure that's something fireplace, conjure, etc. all have implemented already

dominicm 2020-08-06T17:29:19.490700Z

I tried that and ran into a vim bug. If you search the github issue tracker for my name it's my only one.

2020-08-06T17:33:13.491500Z

in my neovim :e /home/justin/.m2/repository/org/clojure/clojure/1.10.1.jar works as expected, and from there I can open clojure/core.clj as a second step

dominicm 2020-08-06T17:36:08.492400Z

Right. You can do it in two steps. I think you can't put it on the path is what I'm thinking of.

dominicm 2020-08-06T17:36:50.493Z

I was trying to setup all the stuff for gf etc to work out of the box.

2020-08-06T17:37:39.493400Z

oh, right, it would be nice if this was one op if you do it frequently

Olical 2020-08-06T19:51:42.493500Z

I did do exactly this with regexps in an old version of Conjure 😄 the new nREPL based one just leans on nREPL

dominicm 2020-08-06T19:52:34.494500Z

It's become a core part of my workflow to jump and tweak. Couldn't imagine having it be a 3+ step process

Olical 2020-08-06T19:53:16.494600Z

https://github.com/Olical/conjure/blob/d9d514db3ef7fcf36bacc402aba511663a73bfbc/fnl/conjure/client/clojure/nrepl/action.fnl#L147-L159 if you squint and ignore the fennel you can sort of see what Conjure does for this now

walterl 2020-08-06T19:57:10.495Z

@noisesmith I'd love to see such a screencast too 🙂

2020-08-06T20:02:41.496Z

my hot take (see the convo in #off-topic for way too much detail) is that a dev flow where I need to jump around that much is a sign of a design problem / failure to encapsulate properly