Add autopairs with cr-only behavior, switch to treesitter-endwise

Thu, 10 Aug 2023 02:32:37 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Thu, 10 Aug 2023 02:32:37 -0500
changeset 1126
fe77c5eed375
parent 1125
58490a30d6fb
child 1127
a120f1d3d932

Add autopairs with cr-only behavior, switch to treesitter-endwise

.config/nvim/after/indent/ruby.vim file | annotate | diff | comparison | revisions
.config/nvim/lua/plugins/editing.lua file | annotate | diff | comparison | revisions
--- a/.config/nvim/after/indent/ruby.vim
+++ b/.config/nvim/after/indent/ruby.vim
@@ -1,1 +1,2 @@
-setl indentkeys-=.
+" Fix annoying outdent behaviors
+setl indentkeys-=0{ indk-=.
--- a/.config/nvim/lua/plugins/editing.lua
+++ b/.config/nvim/lua/plugins/editing.lua
@@ -42,7 +42,38 @@ return {
 
   "tpope/vim-unimpaired",
   "tomtom/tcomment_vim",
-  "tpope/vim-endwise",
+
+  {
+    "windwp/nvim-autopairs",
+    event = { "InsertEnter" },
+    config = function (_, _)
+      local npairs = require("nvim-autopairs")
+      npairs.setup({})
+      local Rule = require("nvim-autopairs.rule")
+
+      -- Only run autopairs for opening a multiline block
+      npairs.clear_rules()
+      for _,bracket in pairs { { '(', ')' }, { '[', ']' }, { '{', '}' } } do
+        npairs.add_rules {
+          Rule(bracket[1], bracket[2])
+            :end_wise(function() return true end)
+        }
+      end
+    end,
+  },
+
+  -- "tpope/vim-endwise",
+  -- treesitter-endwise only applies if the parser is installed. do i want to
+  -- worry about a fallback?
+  {
+    "RRethy/nvim-treesitter-endwise",
+    config = function (_,_)
+      require("nvim-treesitter.configs").setup({
+        endwise = { enable = true },
+      })
+    end,
+  },
+
   "godlygeek/tabular",
   { "mbbill/undotree", cmd = "UndotreeToggle" },
 

mercurial