This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-14
Channels
- # adventofcode (107)
- # aleph (1)
- # announcements (8)
- # beginners (57)
- # boot (3)
- # braveandtrue (18)
- # calva (374)
- # cider (6)
- # cljdoc (8)
- # cljs-dev (140)
- # clojure (199)
- # clojure-berlin (5)
- # clojure-europe (3)
- # clojure-finland (1)
- # clojure-hamburg (4)
- # clojure-italy (17)
- # clojure-nl (16)
- # clojure-spec (2)
- # clojure-uk (70)
- # clojurescript (29)
- # component (2)
- # cursive (10)
- # datomic (44)
- # docker (1)
- # figwheel (3)
- # fulcro (13)
- # immutant (2)
- # juxt (5)
- # leiningen (53)
- # nrepl (3)
- # off-topic (7)
- # pedestal (3)
- # re-frame (7)
- # ring (3)
- # ring-swagger (5)
- # rum (5)
- # shadow-cljs (14)
- # spacemacs (6)
- # specter (12)
- # tools-deps (11)
- # unrepl (11)
- # vim (7)
btw I am in the process of porting some cljs to orchard
, stay tuned! đ Sooner or later we are going to have a cljs nrepl/lsp server going đ
@richiardiandrea, I am staying tuned!
This is a very interesting project as well: https://github.com/snoe/clojure-lsp?files=1
@mseddon: Now develop is using the cond
etc fixes. It's pretty nice! So nice that I published it. đ
@pez ah, uhoh! couldn't find pez.cljfmt.0.0.3-SNAPSHOT, when trying to build calva-lib
. Is that just a renamed version of cljfmt on master published to your local maven?
ah, no, a bit of detective work says it is the calva-fmt branch of your fork here https://github.com/PEZ/cljfmt/tree/calva-fmt/cljfmt đ
Thinking about it⊠with this build process I might not need to have my own Clojars entry for it. But maybe it gets a bit too complicated if people must clone that repo out as well and lein install and stuff, even if they are not going to hack on that part (I am hoping we shall need hack on that fork as little as possible.)
do you want me to just replace my formatter.cljs
into the one on calva-lib
? there seem to be quite a few changes, but mostly relating to whether you :refer
stuff, some old zprint
cruft, etc. I'm trying to work out if there's anything that actually wants to be kept from calva-lib
.
yeah I can't see anything major- I'll move the :exports from the old calva-fmt into lib
That :refer
sounds interesting. Might be that I have required clojure.string
because the new build conf uncovered that breakage.
About those comment blocks and various playground.clj*
files you might find. I have been thinking if maybe I should add a Calva command for automatically creating a playground file for the file I am editing and open it up, split view, so then you I can play and experiment there. And these files would be meant to be commited to the repo.
yeah, there was something like that for intellij/scala... i forget what they called them, 'worksheets' or something
Did you merge the crlf-dabble
branch into latest develop
when you created your crlf
branch?
although on the calva-lib side i've basically nuked formatter.cljs with the crlf one.
I'm a bit worried that I might have done something else important since I failed to fix the crlf thing.
I couldn't see much on the cljs side, but there were a bunch of tweaks with 'extraConfig' and things in the .ts side of clj-fmt, which I've tried to accomodate
you have a js object passed in called extraConfig, which gets merged into the config passed into formatter.cljs on the ts side
ah, okay, a few bits, (I love code restructures don't you? ;)), util/current-line-empty?
etc is missing in calva-lib, but I can move them over...
Maybe it is better to start from calva-lib fresh and apply the crlf things on it by hand.
basically it's down to my merge of clrf:formatter.cljs, I just nuked out some of those utility functions đ
I guess we will see when we diff things from what it looked like before you dropping that nuke.
I have mostly been busy getting the new build conf to work, so not all that many things could have happened with the actual code. đ
you're right though, it may be easier to just manually put the crlf changes back... đ
It's amazing how fast a branch can rot even with just one dev who has very little time with the project. đ
huh. more interestingness https://github.com/BetterThanTomorrow/calva-lib/blob/master/package.json
no version or publisher fields, but I assume this wants to resolve to "@cospaia/calva-lib": "^0.0.17"
The missing version field stops me from publishing junk on http://npmjs.com đ
but this crlf merge is going to be a nasty PR I suspect so I don't want to do a million other things as well đ
If I can assume correctly where the calva-fmt project is checked out I can do the link as part of the watch and release tasks.
@pez https://github.com/BetterThanTomorrow/calva-lib/pull/1 and https://github.com/BetterThanTomorrow/calva-fmt/pull/9 are now up!
check the review notes though, for some reason shadow-cljs
exports have nerfed and so we're back to a snake_case
api for TS, which sucks, and I'd like to remove that 'feature'.
With the old build conf you had to specify the function names manually, which wasn't too fun. Also that API sucked more since it wasn't namespaced at all.
ah, it was easy, forgot to pass :eol "\n"
during the tests. Okay, that ought to work now, back to the 6 new-index-at-top-level
failures.
I'd like for us to not revert the library API with this PR. The API will fatten when Calva starts to use it as well. snake_case is a price i am willing to pay.
But i think this one might be as simple as just configuring vscode to not indent. Just that i only thought about that option first time a few days ago.
đ phew. Anyway I am in no mad rush to merge+publish that crlf fix, take your time and check through, I may still be being an idiot somewhere. It should be good as far as I can tell though.
yick. so I've spent the day with the docs. vscode is.. rather lacking in many places in the API.
I am considering biting the bullet and building a full blown language server to deal with it
since the more I dig into the good extensions the more I see they gave up and did that đ
for example, solving the toplevel indent issue is pretty damn hard without performing a lot of extra work tracking the AST as the changes come in
plus also we don't really want to be passing the whole document across to the plugin for formatting long term because of fun performance issues
BUT, I can't even gain access to the tokenization information from the buffer, so that would have to be performed by us again, which is silly.
e.g. in emacs it's really quite easy to write a decent lisp formatter, because you can peek at the partial parse state across lines, we literally just have a blob of text, despite the fact somewhere in vscode, it knows the extent of folds, parenthesis, etc đ
Vscode language servers are constrained by the same API as language extensions, aren't they?
but e.g. if I know that the first character of a line is inside a string, I can wind back one line until we're not inside one
then lex it forwards to figure out where we are. Without that information locally lexing like that is just not possible
I think the main 'reason' for considering going the LSP route is that other editors also support it, like vim, sublime etc. so at least it's reusable.
hmm. although sort of all that data seems to be being maintained inside paredit, right?
so for e.g., one stupid solution to the line terminator is to just mash Ctrl+W to get the whole range of the toplevel expr, then look at the column of the selection start...
all of these contortions are silly, of course, because somewhere inside vscode, it knows where the parens are.
So when indenting the current form, it uses paredit to figure out what the current form is.
oh, also I am confused slightly about the (let [indent-token "0"] ,,,)
, in add-indent-token-if-empty-current-line
it looks to me that somehow it would barf on literal "0"'s in the text, but mysteriously it does not.
Haha, thatâs why I have asked for the community formatter to consider the cursor position.
@mseddon: you forgot about point 2 and 3 in https://github.com/BetterThanTomorrow/calva-fmt/wiki/How-to-Contribute#before-sending-pull-requests đ
FAIL in (format-text-at-range) (at C:475:6)
expected: (= "(foo)\n(defn bar\n [x]\n baz)" (:range-text (sut/format-text-at-range {:eol "\n", :all-text " (foo)\n(defn bar\n[x]\nbaz)", :range [2 26]})))
actual: (not (= "(foo)\n(defn bar\n [x]\n baz)" "(foo)\n (defn bar\n [x]\n baz)"))
FAIL in (format-text-at-idx) (at C:475:6)
expected: (= "(defn bar\n [x]\n\n baz)" (:range-text (sut/format-text-at-idx {:eol "\n", :all-text all-text, :idx 11})))
actual: (not (= "(defn bar\n [x]\n\n baz)" "(defn bar\n [x]\n \n baz)"))
I wonder if we can âadvertiseâ somewhere for someone with experience with it CI for vscode extensions.
the difference was somewhere i managed to omit the call to normalize-indents
, so everything wound up working as before for a bit
hi, is calva suppose to highlight code that wont compile?
so itâs something that is coming soon then?
i like the plugin its bette rthan then other ones
how do i switch linting on
is that a setting in the repl?
i get linting for bad tests
but not bad code :~
i see inthe docs now
sorry
thatâs better
in your video you showed things like inline evaluation
but the evaluation that I get is in the terminal
there are like 10 evaluate commands
and none of them mention inline
8 evaluate commands sorry
Generally the evaluation commands with alt+
after the chord are terminal equivalents of the inline ones.
i see
well thanks for your help
evaluate current selection was the one i was looking for đ
@pez, okay, so I've been poking around vscode internals all day. I think I have a good solution to a lot of the irritating fiddles we have with formatting atm, but it's going to take a while to put together. All the bits I need are there. Watch this space đ
I shall! It's a bunch of upfront work but I'll let you know when it (begins) to work đ
@christopher.paul, I most often evaluate current form instead, ctrl+alt+e
. So if you have the cursor right before or right after a form, that will be evaluated. (But evaluate selection comes in handy at times too, of course.)
@mseddon, Iâm a curious guy. đ What are the fiddles and what are the findings are two questions in my head right now.
Why do you need to force push to your crlf-fix
branch, btw? Github wonât show me the diffs when that has happened.
yea i think i prefer ctrl+alt+v space now
@pez I'll stack the updates until it passes code review, then squash the commits into a single one for merging, sound good?
that way we get a clean 1 commit per feature/fix, so we don't play untangle the commit history later
shouldnât need to force push, thatâs usually bad đ
that ought to work, although i got complained to for not squash/force pushing on another project. đ
Yes, people really have different prefs. But this is still a very small project so I think we can manage the history.
I think it is nice to be able to check the diffs on github just to orient myself on what it is I am pulling.
regarding the fiddles- the main issue is we're basically re-doing a lot of work vscode is doing incrementally in one big lump on newline... which just makes me cringe. It makes it really difficult to track where everything is from within the extension trivially
so I've figured out on paper and through some tests I can quite easily build an incremental lexer that works from editor events, that only redoes exactly the work it needs
but because it's incremental, I can build a data structure that will always let you correlate the clojure AST to a file offset
which suddenly means, for trivial format on type, we can use much simpler, incredibly quick formatting rules based on cljfmt, and drop to clj-fmt proper for 'full' formatting
you can squash commits without force pushing
iâve been there and got mysef in many messes
yes đ
do you do this stuff just in your free time, pez?
or is it your job đ
btw, the 'force push' thing comes from here https://github.com/todotxt/todo.txt-android/wiki/Squash-All-Commits-Related-to-a-Single-Issue-into-a-Single-Commit
iâm pretty sure you can squash your commits against your fork
then just do a PR
I think that what @christopher.paul and I are saying is that this is key: â If youâve already pushed commits to GitHubâ. If you havenât then no need to force.
you can always force to your fork i guess
but can then do a clean PR to origin
yeah, it's basically, once the PR is sent, the only way to squash without force is to close the the PR and open a new one
Hmmm, but I donât think we need to squash away earlier pushed commits when adding commits to a PR.
Personally I think it is totally OK to push all intermediate commits when preparing a PR.
But, yes, if it is a lot of commits involved and it has taken a while, maybe a rebase -i
and curating the history could be good. But subsequent commits after the PR is sent will be hard to follow if they are force pushed.
Awesome. Letâs hope so many people are throwing themselves at Calva contributions that we will feel the need to reconsider policies. đ
but I didn't write those tests, so it's possible there was a particular situation you were thinking of
The tests are a bit hard to âreadâ because of newlines being entered as escapes. I like how that is handled in cljfmt
.
pez, vscode doesnât seem to recognise this setting: âcalva.autoAdjustIndentâ
iâm trying to disable it as i like to use parinfer
is that definatly the right key?
I think some things around these tests have moved between my attempts to fix the crlf thing and now. Getting more and more convinced it is better to apply the crlf fixes on develop HEAD:
Calva isnât really very compatible with the parinfer extension, @christopher.paul. What error do you get with that setting?
There is some little parinfer built in to Calva, to compensate for this incompatibility. So you can get parens inferred with ctrl+alt+p
for instance. And indent stuff with parens being inferred meanwhile with ctrl+i
(dedent ctrl+shift+i
).
yea it seems pretty funny
i really like parinfer in other editors
I think that setting, calva.autoAdjustIndent
might have moved to Calva Formatter and I might have forgotten to remove it from Calva. (It is not obvious maybe, but when you install Calva you also install Calva Formatter and Calva Paredit and those have their own settings keys.
But VS Code doesnât have the API:s Parinfer needs so they canât really make it work fully as it is working in other editors.
And the parinfer extension that is there now competes with Calva Formatter (and often wins, because it is faster).
i wondered why shaun had said heâd come back to it later
i guess itâs easier to do in ato
Search for âFormat as you typeâ in settings to find the option to switch off Calva Formatterâs help with that. (Even if I think it is a better choice to settle with Calva Formatterâs on-command inferring of parens).
iâll stick with your one for now
parinfer greys out the closing parens
what do you think of that
i think itâs really nice if itâs doing them for you
Maybe Tonskyâs Clojure Warrior
is compatible with Calva⊠at least he is a Calva user and probably would have complained otherwise, Iâll try that extension now. It says it adds some coloring of the paren trail.
Nice! Trying it now. Will take me a while to get used to the coloring, but Iâll stick with it a while.
i dont like colors
i like one colour but the end ones faded
becuase different colours to me mean different context
sometimes blue sometimes green is hard for my brain
OMG. Now I can switch off VS Codeâs stupid highlighting of matching brackets. <-- @pedrorgirardi
OMG thank you @pez! VS Codeâs bracket highlighting tricks me. đ
the coloring is pretty helpful because it is based on intendation level so it gets easier to see when one form is not in the right level
maybe i just have to get used to it
the brackets are more eye catching than the code
Thatâs what I was addressing with that it might take me some time getting used to. Maybe a careful selection of colors will be easier on the eye: clojureWarrior.bracketColors
.
well used the to massively grey them out
so thatâs kind of nice )
@christopher.paul, this greys them out and keeps some of the nesting level info:
"clojureWarrior.bracketColors": [
"#fff",
"#ddd",
"#bbb",
"#999",
"#888",
"#777",
"#666",
]
iâd set them all to 777 đ
effectively I'm doing the same thing he does in his updateRainbowColors, but i cache the state of the lexer (inside string, etc) for each line,
but then i can know where all the brackets are, what symbol starts a term, and the indent level
oh, it's not needed for my little experiment- the idea here is to have a fast path formatOnType
https://github.com/weavejester/cljfmt/blob/master/cljfmt/resources/cljfmt/indents/clojure.clj
mostly because in those cases we don't have anywhere near the horrible problems of cursors jumping around
well, i will naturally write a script to transform those rules into a bit of json đ
But when you have it pinned down, Iâd like to see how it can be factored so that most of the âlogicâ is in cljs. đ
How about we divide the labour such that I apply your crlf fixes on develop HEAD and you focus on that incremental indenter?
I suspect I missed something you did in your work and accidentally removed it anyway đ
I have been the only one working with this stuff and that has âallowedâ me to be a bit sloppy with things.
How about this, @christopher.paul?
"clojureWarrior.bracketColors": [
"#666",
"#777",
"#888",
"#999",
"#bbb",
"#ddd",
"#fff",
]