This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-29
Channels
- # babashka (64)
- # beginners (60)
- # calva (10)
- # circleci (3)
- # clj-kondo (62)
- # cljdoc (6)
- # clojars (2)
- # clojure (152)
- # clojure-europe (19)
- # clojure-nl (3)
- # clojure-uk (18)
- # clojurescript (50)
- # clojureverse-ops (12)
- # core-async (21)
- # cursive (6)
- # data-science (1)
- # datomic (17)
- # events (14)
- # fulcro (64)
- # graalvm (20)
- # graphql (5)
- # honeysql (14)
- # jackdaw (3)
- # jobs (1)
- # jobs-discuss (22)
- # kaocha (2)
- # lsp (9)
- # luminus (8)
- # malli (30)
- # meander (31)
- # other-languages (1)
- # polylith (8)
- # re-frame (15)
- # shadow-cljs (85)
- # specter (2)
- # sql (11)
- # tools-deps (56)
- # vim (39)
- # vscode (7)
- # xtdb (16)
If you use Conjure and/or run your REPL in a vim terminal, how do you handle (scan/read) very long lines?
E.g. logging keys of an initialized Duct system: (log/info "initialized system" {:system (keys system)})
. I have a log line of that that's 1536 characters long, and obviously not that easy to read through. How would you "consume" a line like that in vim?
Currently I yank and paste the list of keys into a :new
buffer, :set ft=clojure
, and use my mapping to <Cmd>%!jet --pretty<CR>
. Feels like there should be an easier way, and set wrap
isn't it. 😝
That's usually my first port of call too, and certainly easier to navigate than a single, massive line, but quite similar in result to set wrap
.
Or <prefix>e!
to eval in place and replace the original code / data with a clojure.pprint
formatted result 😄
I use that a looooot and it only rarely lets me down when there's a reader macro that Clojure barfs on.
the goal is to manually verify, you mean?
@nbtheduke In this specific case I was just looking to see if a specific key was there, but I'm thinking about the general problem of looking for something in very long output lines. Like Ring requests/responses.
I think the Conjure log buffer is writable, so couldn't you just highlight the long line in the Conjure buffer and use %!jet --pretty
to write it back to the buffer, prettified?
I guess %!jet --pretty
would do the whole buffer, actually. You would want to use !jet --pretty
if you have something highlighted.
I have similar bindings set up to prettify/minify JSON and write it back to the buffer:
""""""""""""""""""""""""""""""
" => JSON
"""""""""""""""""""""""""""""""
" magically format/minify json in the current buffer
nnoremap <leader>jf :%!jq -S '.'<CR>
nnoremap <leader>jm :%!jq -c '.'<CR>
" or just the current visual selection
vnoremap <leader>jf :!jq -S '.'<CR>
vnoremap <leader>jm :!jq -c '.'<CR>
Hmm, the equivalent doesn't seem to work for jet
. I think maybe jet
doesn't work quite like jq
?
I set up some simple mappings to pipe selected text (or the whole buffer) through jet
, either to prettify it or to compact it. I like it!
One caveat is that you have to put the EDN on its own line. Note how here in this fake log line, I have to go into insert mode and press enter to push the EDN down to the next line.
If I end up doing this enough, I'll probably add another mapping to automate the part where I go into insert mode and press enter to push it down onto the next line, and then select til the end of the line.
I like the direction you (and @U8QBZBHGD) are going. Will have to play around with it a bit more.
If all else fails, macro it up 😎
:vmap <leader>E y:vnew<CR>P:set ft=clojure <Bar> %!jet --pretty<CR>zR
Result of tinkering with this a bit:
" "If all else fails, macro it up 8-)" - @walterl
"
" Adapted from @walterl's macro:
" :vmap <leader>E y:vnew<CR>P:set ft=clojure <Bar> %!jet --pretty<CR>zR
"
" Opens a new clojure buffer in a split containing the prettified EDN
function! PrettyJetSplit() abort
vnew
normal! p
set ft=clojure
nnoremap <buffer> q :bdel!<CR>
%!jet --pretty
normal! zR
endfunction
vnoremap <silent> <leader>EF y:call PrettyJetSplit()<CR>
" Shortcut: in normal mode, placing your cursor inside the top level of an EDN
" map and using this mapping results in visually selecting the EDN map and doing
" the PrettyJetSplit thing above.
nnoremap <silent> <leader>EF va}y:call PrettyJetSplit()<CR>
I was wondering whether this is a good use case for a scratch buffer, but it's probably better as-is, so it can be :w
ritten to a file if necessary
Is anyone using vim-iced with Fulcro (or at least shadow-cljs)? I'm running into troubles connecting to my editor and suspect it's got something to do with iced
, but I can't find any docs that really cover my use case.
Some brief discussion/details on my issue: https://clojurians.slack.com/archives/C68M60S4F/p1627572500148900
a question for conjure vimmers: What mappings do you use for comfortable clojure development?
Besides the Conjure defaults, of which I use quite a few, I also use these: https://github.com/walterl/dotfiles/blob/master/_config/nvim/ftplugin/clojure/clojure.vim
And these https://github.com/walterl/dotfiles/blob/master/_config/nvim/init.vim#L214-L283 and below too 😝
https://github.com/eraserhd/parinfer-rust, https://github.com/tpope/vim-surround and https://github.com/Olical/conjure/ provide all the mappings I need 🙂
If all else fails, macro it up 😎
:vmap <leader>E y:vnew<CR>P:set ft=clojure <Bar> %!jet --pretty<CR>zR
#TIL "coc.preferences.jumpCommand": "split",
🤯
https://github.com/neoclide/coc.nvim/blob/master/doc/coc.txt#L825-L830