Should we consider trimming down the helptext from neil / neil -h and putting detailed subcommand usage in neil SUBCOMMAND -h ?
I was considering adding a new paragraph to the neil dep helptext (ref https://github.com/babashka/neil/issues/108), but it's already long.
--
Right now:
1. We have a global hand-crafted helptext
2. neil dep add has its own helptext - neil dep add -h
3. neil dep search has its own helptext - neil dep search -h
4. Other subcommands don't seem to have any subcommand helptext.
A first step could be to move the neil dep upgrade docs into neil dep upgrade -b.
Thoughts?
yes
is it possible to install a local neil development version with bbin - that runs src/babashka/neil.clj directly, rather than the generated neil script? (when I won't have to bb gen-script locally)
--
Right now, when bbin install . --as neil-dev from the neil repo, I get this in ~/.babashka/bbin/bin/neil-dev:
(def script-root "/home/teodorlu/dev/babashka/neil")
(def script-main-opts-first "-f")
(def script-main-opts-second "/home/teodorlu/dev/babashka/neil/neil")
I'd prefer this:
(def script-root "/home/teodorlu/dev/babashka/neil")
(def script-main-opts-first "-m")
(def script-main-opts-second "babashka.neil/-main")manually editing the bbin shim to run -m babashka.neil/-main is enough for me right now π
yeah, editing the -f would be the solution
PR: Move neil dep upgrade helptext into subcommand
https://github.com/babashka/neil/pull/155
Thread π
I'm happy with the neil dep versions -h helptext:
$ neil-dev dep upgrade -h
Usage: neil dep upgrade [lib] [options]
neil dep upgrade [options] Upgrade all libraries
neil dep upgrade LIB [options] Upgrade a single library
neil dep upgrade --lib LIB [options] Upgrade a single library
Options:
--lib Fully qualified library name.
--dry-run dep upgrade only. Prevents updates to deps.edn.
--alias <alias> Add to alias <alias>.
--no-aliases Prevents updates to alias :extra-deps when upgrading.
Examples:
neil dep upgrade ; upgrade all deps.
neil dep upgrade --dry-run ; print deps that would be upgraded.
neil dep upgrade --alias lint` ; update only deps for the `lint` alias.
neil dep upgrade :lib clj-kondo/clj-kondo ; update a single dep.But I still think the global helptext is a bit too verbose:
$ neil-dev -h
Usage: neil <subcommand> <options>
Most subcommands support the options:
--alias Override alias name.
--deps-file Override deps.edn file name.
Subcommands:
add
dep Alias for `neil dep add`.
test adds cognitect test runner to :test alias.
build adds tools.build build.clj file and :build alias.
kaocha adds kaocha test runner to :kaocha alias.
nrepl adds nrepl server to :nrepl alias.
dep
add: Adds --lib, a fully qualified symbol, to deps.edn :deps.
Run `neil dep add --help` to see all options.
search: Search Clojars for a string in any attribute of an artifact
Run `neil dep search --help` to see all options.
upgrade: Upgrade libs in the deps.edn file.
Run `neil dep upgrade --help` to see all options.
update: Alias for `upgrade`.
license
list Lists commonly-used licenses available to be added to project. Takes an optional search string to filter results.
search Alias for `list`
add Writes license text to a file
Options:
--license The key of the license to use (e.g. epl-1.0, mit, unlicense). --license option name may be elided when license key is provided as first argument.
--file The file to write. Defaults to 'LICENSE'.
new
Create a project using deps-new
Run `neil new --help` to see all options.
version
Commands for managing the :version key in the deps.edn project config.
Run `neil version --help` to see all options.
test
Run tests. Assumes `neil add test`. Run `neil test --help` to see all options.I like the neil dep add docs from neil -h. They are quick to skim.
I think it would be good to get the neil dep SUBCOMMAND docs down to one line each. But we still need to let the user know they can get subcommand docs.
Yep
Merged, lots better already - agreed with the other points
This seems to be working for installing a development version of neil with #babashka-bbin - and it doesn't require re-running gen-script on changes:
$ bbin install . --as neil-dev --main-opts '["-m" babashka.neil/-main]'
Should we add those to the ## Dev section of the README below the local brew installation instructions?Oh nice, I didn't know that. Yes please!
would it help to have a code style/formatting guide for the source code in bb and friends? could be helpful for contributors as I myself found my formatter rearranging stuff i dont wanna change.
if we can suggest a tool and config, i for one would be happy to follow it and think of one less thing when contributing π
I don't really care about formatting
The thing is I have a tendency to format the file before saving and it moves things around unrelated to my changes
as long as it's the same as my emacs does it :P
I can try to adopt clojure-lsp cljfmt
in my own editor
if that helps you
Yeah if you can get your emacs conf to a file Iβm happy too!
I donβt really care about the formatting rules just that if I can have access to a rule set Iβm happy
This is what I'm using to format my buffer:
(defun iwb ()
"Indent whole buffer."
(interactive)
(delete-trailing-whitespace)
(indent-region (point-min) (point-max) nil)
(untabify (point-min) (point-max)))and I think it depends on the mode, e.g. clojure-mode , how it formats
I guess clojure-mode hooks into that
I don't know actually which part is responsible for doing that :)
@ericdallo do you know?
Indent-region will call the indent-region-function variable, which could be some Elisp package or lsp-mode for example.
I'd suggest try clojure-lsp formatting that uses cljfmt under the hood, via lsp-format-buffer
I find myself doing that on clj-kondo multiple times and needing to rollback to not change a lot of stuff :p
ok, fine, I'll change to lsp-format-buffer instead
If using clojure-lsp, you could even setup a CI that runs clojure-lsp format to make sure things are formatted as well, it's what we do in Nubank and clojure-lsp related projects
is cljfmt also supported for other editors?
You mean only cljfmt without clojure-lsp?
oh right, clojure-lsp also works in vim of course
facepalm
does clojure-lsp does something with the clj-kondo analysis to enhance cljfmt formatting?
ATM no, but will do after I merge a PR that will check :style/indent metadata to format like cider
:-D
does cider also use cljfmt somehow?
cider is dependent on a JVM REPL. does it not format CLJS code when you don't have a REPL? so many questions...
AFAIK it does its own way of formatting following ClojureStyleGuide
Good question haha
and tonsky also has other opinions on formatting
I'm fine with going with clojure-lsp. I think I only see differences in with-let etc compared to my emacs formatter
Hence I was hoping for a config and I can adapt my setup to it π
Totally configurable via .cljfmt.edn if you want
@rahul080327 if you will use clojure-lsp formatting, we will have the same one
from now on I'll use that
Even if not using in editor, possible to use via cli like Cursive users do
Cursive does not support formatting?
Yeah I use zprint via the cli, will make it behave like default cljfmt
ok
Or this is an opportunity to try cljfmt, will change after years. Couldnβt find a good native image back then
@ericdallo can I call (lsp-format-buffer) from a keyboard shortcut, but fall back to something else when I'm not connected to lsp?
@rahul080327 dude, use clojure-lsp native image
But it shells to cljfmt I think
of course not, it's fully self-contained
Ah really, I couldnβt get lsp formatting to work, will poke more
@rahul080327 if you use clojure-lsp from vim you should be able to call lsp-format-buffer or so right
Yeah I tried that and remember some errors with cljfmt
@borkdude lsp-format-buffer expects LSP is connect so you would need to create a custom function that check if LSP is connected (there is a function for that) and if not call other function. Why you would not be connected to LSP though?
well, e.g. in elisp
do you have a conditional at hand?
doom-emacs does that automatically and bind to SPC c f (code format), but it probably has smart checks
(when (lsp--capability "documentFormattingProvider")
(lsp-format-buffer))(defun iwb ()
"Indent whole buffer."
(interactive)
(delete-trailing-whitespace)
(if (lsp--capability "documentFormattingProvider")
(lsp-format-buffer)
(indent-region (point-min) (point-max) nil))
(untabify (point-min) (point-max)))a better check would be checking if (lsp-workspaces) is t
(require 'lsp)
(defun iwb ()
"Indent whole buffer."
(interactive)
(delete-trailing-whitespace)
(if (and (lsp-workspaces)
(lsp--capability "documentFormattingProvider"))
(lsp-format-buffer)
(indent-region (point-min) (point-max) nil))
(untabify (point-min) (point-max)))
(global-set-key (kbd "<f7>") 'iwb)@borkdude you probably don't need that custom function as lsp-mode already does that automatically if you have lsp-enable-indentation set to t
it would set indent-region-function to lsp-format-buffer
I usually format my whole buffer
not just one region
anyway this works
me too, but anyway, that would work
lsp formatting works! awesome.
@rahul080327 yay! issue solved then
yep!
> @borkdude you probably don't need that custom function as lsp-mode already does that automatically if you have lsp-enable-indentation set to t
Is this the mode where lsp formats while you're typing? I'd rather not :)
oh, you are right, I have that disabled for that reason and I'm discussing with lsp-mode folks to disable it by default.
@ericdallo does cljfmt support exporting configs inside dependencies so your macro users get the same formatting everywhere?
no, not natively in cljfmt, but if using via clojure-lsp you could:
β’ use clojure-lsp export feature like clj-kondo via :classpath-config-paths and use the setting :cljfmt to configure custom format
β’ use style/indent after that PR I mentioned is merged, next release
I'm looking forward to the docs
Oh that's awesome, you just copied clj-kondo's way of doing :)
That's convenient
Yep :) We use at nubank and with that we use the same convention for formatting/hooks and everything for more than 1000 projects
It's almost like these tools are getting popular
> is cljfmt also supported for other editors? Calva uses cljfmt as its formatting engine.
@borkdude added this little config and i think you'd like that too? https://github.com/lispyclouds/dotfiles/blob/main/.cljfmt.edn
rest all i think im cool with cljfmt's defaults, im used to aligning the map key values but can also see issues so will make peace with it ππΎ
@ericdallo would be cool if zprint could be supported too, its config is quite the thing π
Yeah, there is a issue for that, I'll probably do that in the future, one more deps though
yeah its very ideal to have it, love clojure-lsp as it is already! its indispensable ππΎ