This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-06
Channels
- # announcements (4)
- # beginners (132)
- # calva (37)
- # chlorine-clover (60)
- # cider (1)
- # clara (12)
- # clj-kondo (40)
- # cljs-dev (109)
- # clojure (76)
- # clojure-dev (19)
- # clojure-europe (8)
- # clojure-france (17)
- # clojure-nl (4)
- # clojure-sg (1)
- # clojure-spec (14)
- # clojure-uk (7)
- # clojurescript (98)
- # conjure (96)
- # cursive (15)
- # data-science (2)
- # datalog (11)
- # datomic (24)
- # emacs (17)
- # figwheel-main (3)
- # fulcro (45)
- # jobs-discuss (1)
- # kaocha (3)
- # malli (2)
- # nrepl (1)
- # off-topic (135)
- # portal (2)
- # re-frame (17)
- # reagent (11)
- # reitit (4)
- # sci (60)
- # shadow-cljs (75)
- # spacemacs (3)
- # sql (32)
- # tools-deps (79)
- # vim (88)
- # xtdb (4)
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 :)
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?
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?
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 @UQQBVBQJ1 😝)
(I backed neovim when it was announced thinking it will probably fail but it was a nice moonshot - glad to see it going strong!)
there are tonnes of modern plugins - like fzf for fuzzy searching, others include vim-clap, vim-which-key, vim-sandwich etc...
I use vim petty much as my go-to editor, for nearly everything. When I have to use Kotlin/Java, I jump into IntelliJ
before install any plugin I recommend to try the vanilla way. There are a lot of articles about it: https://vimways.org/
one of my favorite: https://vimways.org/2018/death-by-a-thousand-files/
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
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
without LSP integration, unfortunately, because the version of mono we use is so old, the LSP server doesn't support it 😑
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.
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
Ok so neovim with Conjure works nicely. What do I gain with Clojure-lsp? Haven’t looked closely yet.
I get completion and jumping to namespaces from Conjure. How is completion different from autocomplete?
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)
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.)
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.
(you may have already dismissed it for other reasons too, but yeah, thought it was a feature worth mentioning)
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
I have looked at conjure, but it doesn't fit my criteria for features/complexity tradeoff right now
funny thing, the initial motivation was when I switched to being a senior engineer and mentoring other devs
I realized that I couldn't pull up to pair with Amy and show her how to do something in sublimetext!
I was using emacs at the time as well, and CIDER was breaking every week
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
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
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
orzo code - lots of meaningless tiny pieces with poorly defined relationships
do you @noisesmith have a .vimrc file somewhere publicly? I don't get the :reload
arg thing
oh - that's not vim, that's clojure (require 'some.ns :reload)
there's also :reload-all
which recursively reloads
@U4GEXTNGZ 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)))
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
and after a repl restart, that single line fully recreates my testing flow to iterate again
then the test failures remind me of what I was working on, and I can ignore the tools and just do my flow
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
I’d love to see a screencast of your workflow @noisesmith
I might even have time for that soon haha
If I understand correctly you launch a whatever REPL that allows you to type stuff, then use the editor to just simulate the typing
but if I'm being honest I'm overdue to spend some time on my own long term software projects anyway
and those will involve Clojure
and I can actually afford to take time off, I've been careful with money
Sorry to hear that. Curious to see your long term projects though. Best of luck! And thanks for the orzo code term :)
@noisesmith I'd love to see such a screencast too 🙂
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
I use :grep
with ag
as my grepprg
then the standard :cope
to browse and jump to results, C-I / C-O to go forward and back through recent jumps
and :tabe
to keep groups of buffers organized
finally q:
to browse recent :
commands as an editable buffer isntead of the crappy :
mode keybindings
Sorry to hear that. Curious to see your long term projects though. Best of luck! And thanks for the orzo code term :)
@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.
clojure.repl/source is right there of course (as well as
to find the specific object that contains your function)
user=> (require '[ :as io])
nil
user=> (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=>
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
I did do exactly this with regexps in an old version of Conjure 😄 the new nREPL based one just leans on nREPL
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
I'm sure that's something fireplace, conjure, etc. all have implemented already
I tried that and ran into a vim bug. If you search the github issue tracker for my name it's my only one.
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
Right. You can do it in two steps. I think you can't put it on the path is what I'm thinking of.
oh, right, it would be nice if this was one op if you do it frequently
It's become a core part of my workflow to jump and tweak. Couldn't imagine having it be a 3+ step process
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