Added lua/plugins/clojure.lua to the Practicalli AstroNvim User Config as an example of how to customise the Clojure workflow and use alternative tools. Includes Paredit, ParPar (to use parinfer & paredit together) and nvim-treesitter-sexp.
I will be trying these plugins out over the next week and see what is useful and if there are key mapping conflicts.
Note: the clojure.lua is not enabled by default, comment the if statement at the top of the file to enable and comment the Clojure pack in the community.lua file
If all is good, then I'll update the Clojure pack to include these packages.
I also tried to created an autocommand to set clojure as the mode for ClojureDart, this does seem to set the file type to Clojure and enable some Clojure LSP warning. Unfortunately this doesnt seem to enable syntax highlighting (I suspect because there isnt a ClojureDart language parser for TreeSitter). Auto complete and other features not enabled either.
Also added lua/plugins/neo-tree.lua for example overrides, including setting hidden files to show in an alternate text style.
Yes, the nvim-treesitter-nvim provides a series of https://github.com/PaterJason/nvim-treesitter-sexp?tab=readme-ov-file#configuration.
I'll add some key mapping examples that use <leader>k to the practicalli config this evening, to help with discoverability.
@luciolucio Changes to the nvim-treesitter-sexp config in Practicalli Astronvim User Config have been pushed. I would be interested to know if the default key mappings from the plugin or the <leader>k mappings are the most useful.
Thanks, just updated and gave them a try. Let me play a little with both options for a few days and see what happens.
Love the examples, thanks for that! I migrated over to the new style config, and I tried to use the example nvim-treesitter-sexp config but I don't get a <localleader> k menu which is what I'd expect from the config.
Is that working for you? I made these changes in lua/plugins/clojure.lua but still no cigar.
• Removed out the first line
• Removed all other structural editing configs
• Set enabled to true
• Uncommented the keymaps key
I also disabled the community pack's parinfer through plugins/user.lua
I do see some paredit-like structural editing, but not sure where those are coming from
,@ Splice element
,O Promote element
,o Promote form
<( Slurp left
<) Barf right
>( Barf left
>) Slurp rightI think the above key mapping were the default from nvim-treesitter-sexp
I'll check the lua/plugins/clojure.lua config, sounds like the alternate mapping config is not in the right place
I'm having a hell of a time understanding how to use lisp editing with this config and keep from destroying what I'm writing.
Have
(defn module [f] (let [data {:parent (.getParent f)}] data))
Execute
Return with cursor between the [f] and the (let
Expect
(defn module [f]
(let [data {:parent (.getParent f)}] data)
Get
(defn module [f])
(let [data {:parent (.getParent f)}] data)
and then given that I think, well this is an opportunity to fix it with lisp editing so,
Move cursor to inside first form at ^
(defn mod^ule [f])
(let [data {:parent (.getParent f)}] data)
Think about what barf and slurp and left and right mean.
"Um slurp... right?"
Type
>)
Get no edit, the cursor moves only
(defn module [f])
(let [data {:parent (.getParent f)}] data)^
and because paredit is aggressively "fixing" my keystrokes I can't just switch into editing characters and fix it into something that will run 😭
The way I'm reading the characters it would be
>) move the end parenthesis forward to enclose
<) move the end parenthesis backward to disgorge
<( move the start parenthesis backward to enclose the form behind
>( move the start parenthesis forward to disgorge the earliest form
I've also tried pasting things into the inside of parentheses and I just keep making things worse
Let me add btw that sometimes I'm also just typing something, fretting I'll have an editing disaster, and the plugin guesses exactly what I mean. So I can tell it's good, I'm just holding it so wrong that I can barely type
Sounds like you should comment the parinfer plugin, or set it to parents mode.
Parinfer by default expects the user to manage the indentation and it doesn't sound like this is being done.
Suggest only using the nvim-treesitter-sexp plugin from the clojure.lua config file.
I am away for a few days so won't have much time to pick through the specific comments
Understood. I have partly started understanding how to work with it. It might be as simple as unlearning older styles of managing the cursor, because I started speeding up once I started just hitting return and typing and letting the algorithm catch up. Thanks for the configuration work you put in 🙏
FWIW, I personally have parinfer switched off
So far I've been enjoying the default mappings, and they don't seem to limit or conflict with anything I regularly use.
I did add the <leader>k for a while and it just seemed clunky to me, like for slurping right
Thanks for the feedback, very useful. The <leader>k was a homage to the Lisp state in Emacs (Spacemacs), although I only use a few of those in Spacemacs now (usually just raise) I'll add nvim-treesitter-sexp package to the Astronvim Clojure pack, along with info on how to configure/disable plugins from the pack (disable a specific plugin should be a one additional line after importing the Clojure pack in the user config. Hopefully people enjoy using both plugins or only notice the one they use :)