tpope / vim-fireplace

fireplace.vim: Clojure REPL support
https://www.vim.org/scripts/script.php?script_id=4978
1.75k stars 139 forks source link

More info about cider-nrepl setup in README? #399

Open mars0i opened 2 years ago

mars0i commented 2 years ago

Hi, I'm completely new to vim-fireplace. I've been using Clojure for many years, and vim for many more years, but I've gone without this kind of tool for a very long time. I'm a little confused about how to set up cider-nrepl for vim-fireplace. So this is a personal help request, but I'm submitting an issue because it might also be a request for an addition to the README file..

The README says:

First, set up cider-nrepl. (If you skip this step, only a subset of functionality will be available.)

I want all the functionality! The cider-nrepl README says:

Please refer to the documentation site for information on how to setup cider-nrepl or how to leverage its nREPL API.

The cider-nrepl documentation site gives information about how to use cider-nrepl inside Clojure (via Leiningen, Boot, and using deps.edn, for example). There's also a Makefile in the cider-nrepl repo, though nothing suggested I should run it, and after I got it to run--an env var needed to be set--the make process hung.

Is that what you mean by setting up cider-nrepl to use with vim-fireplace? Get Leiningen (for example) to pull down the cider-nrepl jar and pom? I've done that, but I'm not sure whether or not I've done what's needed for vim-fireplace to use cider-nrepl.

Apologies for my cluelessness. Since I've never (OK, rarely) used this kind of tool, I don't know what to expect it to do.

For example, if I highlight a function name and type K, I get the docstring--ok, good. If I highlight the definition and type [d, I get "E388: Couldn't find definition". I don't know whether that's because I haven't set up cider-nrepl properly, or whether maybe something in my existing vim config is interfering.

Thanks!

tpope commented 2 years ago

You're not alone; this is a common pain point. I'm updating the README to point directly to the usage documentation.

For example, if I highlight a function name and type K, I get the docstring--ok, good. If I highlight the definition and type [d, I get "E388: Couldn't find definition". I don't know whether that's because I haven't set up cider-nrepl properly, or whether maybe something in my existing vim config is interfering.

This is definitely your config. My guess would be you have 'timeout' set too low.

mars0i commented 2 years ago

Thanks very much. Thanks for updating the README. I had already found a version of that page when I submitted the issue, but I appreciate that the link now goes directly there.

About [d, I don't think it's a timeout (assume you mean timeoutlen in vim--finally figured that out--but it doesn't help). There's something more fundamental I don't understand about using fireplace. You don't need to answer here. I'll probably figure it out. ([d works with names that don't include a hyphen. When there's a hyphen, [d reads only up until it. Highlighting the whole name let's K read it and return the docstring, but that doesn't work with [d, and I get the E388 error. This is true both for my own definitions and for clojure.core.)

mars0i commented 2 years ago

Oh, and to followup on my initial question and README suggestion: Is it necessary to include something like :plugins [[cider/cider-nrepl "0.28.3"]] in project.clj or profiles.clj (for Leiningen) all of the time? i.e. by "set up cider-nrepl', you mean configure it to load the plugin repeatedly via Leiningen or deps.edn or Boot or whatever? I'm sure this seems obvious to many people, but someone starting out with fireplace might not have any idea about plugins or what cider-nrepl does. (That the cider-nrepl docs are oriented toward Emacs doesn't help.)

Thanks again! (And in general, thank you for fireplace.)

tpope commented 2 years ago

When there's a hyphen, [d reads only up until it.

That's 'iskeyword', which should be set correctly by the ftplugin. Make sure :filetype reports plugin:ON and check :verbose set iskeyword?.

Is it necessary to include something like :plugins [[cider/cider-nrepl "0.28.3"]] in project.clj or profiles.clj (for Leiningen) all of the time?

For full functionality yes. Notably it is required for ClojureScript support. We try to make do without it when we can, because as you note, setting it up can be challenging for rookies and veterans alike.

mars0i commented 2 years ago

OK--thanks very much!

I'll check iskeyword? [Over the years I gradually built up a confused/confusing vim configuration, and I'm in the process of switching to a more rational system, but that means that I've intentionally disabled some things until I figure out what they do. And need to enable some things I never did before.]

OK, good--thanks for the exaplanation about the plugin. That kind of all makes sense to me. I'm not using Clojurescript at the moment, so I might not notice the difference. It's clear to me that my vim is talking to nrepl, which confused me. I'll add the plugin. Can't hurt.

mars0i commented 2 years ago

Adding filetype plugin on did the trick. Thanks, and sorry about that. I spend a lot of time using vim but not a log of time understanding its config.