This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-29
Channels
- # babashka (4)
- # babashka-sci-dev (96)
- # beginners (79)
- # calva (26)
- # cider (5)
- # clerk (2)
- # clj-kondo (23)
- # clojars (14)
- # clojure (54)
- # clojure-europe (8)
- # clojure-sweden (3)
- # clojurescript (76)
- # datomic (12)
- # deps-new (6)
- # emacs (20)
- # events (3)
- # exercism (1)
- # fulcro (11)
- # funcool (12)
- # hugsql (14)
- # hyperfiddle (6)
- # kaocha (1)
- # lambdaisland (1)
- # lsp (22)
- # malli (1)
- # matcher-combinators (6)
- # nbb (6)
- # off-topic (128)
- # polylith (12)
- # re-frame (4)
- # reagent (1)
- # releases (4)
- # shadow-cljs (8)
- # tools-build (13)
- # tools-deps (13)
- # tree-sitter (5)
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?
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 🙂
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 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.
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?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 😄
The thing is I have a tendency to format the file before saving and it moves things around unrelated to my changes
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)))
@UKFSJSM38 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
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
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
cider is dependent on a JVM REPL. does it not format CLJS code when you don't have a REPL? so many questions...
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 😅
@U7ERLH6JX if you will use clojure-lsp formatting, we will have the same one
Yeah I use zprint via the cli, will make it behave like default cljfmt
Or this is an opportunity to try cljfmt, will change after years. Couldn’t find a good native image back then
@UKFSJSM38 can I call (lsp-format-buffer)
from a keyboard shortcut, but fall back to something else when I'm not connected to lsp?
@U7ERLH6JX dude, use clojure-lsp
native image
But it shells to cljfmt I think
Ah really, I couldn’t get lsp formatting to work, will poke more
@U7ERLH6JX 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
@U04V15CAJ 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?
doom-emacs does that automatically and bind to SPC c f
(code format), but it probably has smart checks
(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)))
(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)
@U04V15CAJ you probably don't need that custom function as lsp-mode already does that automatically if you have lsp-enable-indentation
set to t
@U7ERLH6JX yay! issue solved then
> @U04V15CAJ 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.
@UKFSJSM38 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
Yep :) We use at nubank and with that we use the same convention for formatting/hooks and everything for more than 1000 projects
> is cljfmt also supported for other editors? Calva uses cljfmt as its formatting engine.
@U04V15CAJ 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 🙏:skin-tone-5:
@UKFSJSM38 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 🙏:skin-tone-5: