practicalli

practicalli-johnny 2023-10-17T15:58:42.341119Z

Practicalli Neovim updates • added a page on http://localhost:7777/neovim/neovim-basics/notifications/ (nvim-notify) • updated https://practical.li/neovim/repl-driven-development/ (Conjure, parinfer, testing, refactor tools) Note that Practicalli configurations for Conjure hide the HUD log popup that is otherwise shown by default when Conjure connects to the REPL. Personally I find it easier to rely on in-line evaluation results and show the log in a separate tab page and mostly When using Conjure with larger evaluation results, I use nrepl middleware to automatically tap> all results to portal, which provides additional tools to visualise and navigate the code.

Lucio Assis 2023-10-19T12:55:04.005269Z

Tks, I'll see what tweaks I can do. Parinfer has been working fine for the most part. The problem is when I have to paste some code, then I have to align things myself and can't just rely on lsp formatting.

Lucio Assis 2023-10-19T13:01:09.266209Z

This exemplifies what I mean. I'd like to paste that map as the value for :give-me and just hit SPC l f

alexdavis 2023-10-19T13:12:57.070579Z

I have a binding for 'parinfer off - paste - lsp-format - parinfer on' which works pretty well

["p"] = {
      function()
        vim.cmd "ParinferOff" -- turns Parinfer off
        vim.cmd 'normal! "+gP' -- pastes from clipboard
        vim.lsp.buf.format() -- formats the code
        vim.cmd "ParinferOn" -- turns Parinfer on
      end,
      desc = "Paste and format with Parinfer",
    },

practicalli-johnny 2023-10-19T15:55:59.423019Z

@luciolucio using the command :ParinferOff or :Parinfer toggle before pasting the code should keep the structure of the map. Saving the file will automatically format using the clojure LSP server and correct the indentation. (ah, that was essentially what Alex said 🙂 )

practicalli-johnny 2023-10-19T16:10:19.583259Z

If the default behaviour is not preferred, then try setting parinfer to paren mode. I added the following inside the return map in the plugins/community.lua file and this indents as you are expecting. I havent tried other scenarios yet...

{
    "gpanders/nvim-parinfer",
    ft = { "clojure" },
    config = function()
      vim.g.parinfer_force_balance = true
      vim.g.parinfer_comment_chars = ";;"
      vim.g.parinfer_mode = "paren"
    end,
  },

Lucio Assis 2023-10-19T20:08:12.328859Z

Thanks guys. I've tried something like Alex's suggestion for now.

Lucio Assis 2023-10-18T20:18:05.317489Z

Is there a simple way to switch to paredit?

practicalli-johnny 2023-10-19T00:24:42.769869Z

https://github.com/dundalek/parpar.nvim could be used to include both parinfer and paredit, although I remember having key binding issues when trying that with the Clojure pack I added to AstroCommunity. Either key bindings or something wasnt loading... I didnt spend time figuring that out yet. Or rather than use the AstroCommunity Clojure pack, add the conjure and paredit plugins via the user config, which again may require some wrangling of the key bindings. I found parinfer really easier to get working and get used to that I have not spent much time trying to get paredit to work. I would be interested in having a paredit config that works though... or even better a parpar config that works with AstroNvim.

alexdavis 2023-10-17T16:01:57.020909Z

small typo

,ls in horizontal split, ,ls in vertical tab

alexdavis 2023-10-17T16:02:06.775719Z

should be ,lv for vertical

practicalli-johnny 2023-10-17T16:02:48.986819Z

ooops... copy paste strikes again facepalm ... publishing a fix...

alexdavis 2023-10-17T16:11:19.325569Z

I'm going to set aside some time to learn your portal setup, I always use ,lv to pop up a conjure buffer and its not ideal, but portal is such a faff to setup. if theres a way to inject the setup into the repl start then that sounds super handy

practicalli-johnny 2023-10-17T16:21:51.623909Z

I use a custom user namespace to configure portal, which recieves all REPL evaluations using nREPL middleware (added via a Clojure CLI alias along with the library of course). I also publish mulog logs into portal for the complete experience.

practicalli-johnny 2023-10-17T16:23:09.828269Z

I have a dev/portal.clj file that starts up (only one instance) of portal and listens to all evals via the submit function, which is loaded from the dev/user.clj file as a require. The portal code could all be inside the dev/user.clj file but I separate out each tool config to make the user namespace easier to follow.

(ns portal
  (:require
   ;; Data inspector
   [portal.api :as inspect]))


;; ---------------------------------------------------------
;; Start Portal and capture all evaluation results

;; Open Portal window in browser with dark theme
;; 
;; Portal options:
;; - light theme {:portal.colors/theme :portal.colors/solarized-light}
;; - dark theme  {:portal.colors/theme :portal.colors/gruvbox}

(def instance
  "Open portal window if no portal sessions have been created.
   A portal session is created when opening a portal window"
  (or (seq (inspect/sessions))
      (inspect/open {:portal.colors/theme :portal.colors/gruvbox})))

;; Add portal as tapsource (add to clojure.core/tapset)
(add-tap #'portal.api/submit)
;; ---------------------------------------------------------

practicalli-johnny 2023-10-17T16:28:18.469239Z

Then I use an alias that includes the portal middleware and dev directory on the class path (as well as starting nrepl server with the cider extensions for cider or conjure) This is a simplified version of the :repl/reloaded alias from Practicalli Clojure CLI Config

:repl/inspect
  {:extra-paths ["dev" "test"]
   :extra-deps {nrepl/nrepl                  {:mvn/version "1.0.0"}
                cider/cider-nrepl            {:mvn/version "0.37.0"}
                djblue/portal                {:mvn/version "0.46.0"}   ; portal data inspector
                clj-commons/clj-yaml         {:mvn/version "1.0.27"}}  ; portal yaml support (optional)}
   :main-opts  ["--main" "nrepl.cmdline"
                "--middleware" "[cider.nrepl/cider-middleware,portal.nrepl/wrap-portal]"
                "--interactive"]}
Then is clojure -M:repl/inspect to start the repl, nrepl server, portal, etc

practicalli-johnny 2023-10-17T16:32:18.298279Z

This Portal (and mulog) code is generate when creating Clojure projects from https://practical.li/clojure/clojure-cli/projects/templates/practicalli/

alexdavis 2023-10-17T17:06:23.108249Z

Thanks! will also share with my team (who are slowly switching to vim + your config after they see me use it 😄 )

alexdavis 2023-10-17T17:07:37.996859Z

Actually while its on my mind, is there a way to jump to definition of a clojure library? I think this did work at some point (maybe when I was on emacs...) but now just gives an error when I try with gd

practicalli-johnny 2023-10-17T18:58:17.531339Z

I also seem to get an error or it opens an empty file with the library short form name. It's not something I've done since neovim. If I find anything I'll share it. It seems to work for symbols defined within the project though, maybe something at the LSP client end is not using all of the data feature m the lsp server... But I am just guessing