ee3f3d0

Branches > main > ee3f3d0 > files / nvim / pack / plugins / opt / conjure / dev / clojure / src

Parinfer updates

Grahp, 2026-06-20

Commit: ee3f3d09de94cf235ebc5554c28a1f6a4b6ac711
Parent: 773aabf

1 changed file:

nvim/lua/parinfer/plugin.lua modified (view file)

@@ -1,15 +1,10 @@ --- Modified version of https://github.com/gpanders/nvim-parinfer --- See ./LICENSE -vim.g.parinfer_mode = vim.g.parinfer_mode or "smart"-vim.g.parinfer_enabled = vim.g.parinfer_enabled ~= false-vim.g.parinfer_force_balance = vim.g.parinfer_force_balance or false-vim.g.parinfer_comment_chars = vim.g.parinfer_comment_chars or { ";" }--vim.g.parinfer_filetypes = vim.g.parinfer_filetypes or {-  "clojure", "scheme", "lisp", "racket", "hy",-  "fennel", "janet", "carp", "wast", "yuck", "dune"-}+vim.g.parinfer_mode = "smart"+vim.g.parinfer_enabled = true+vim.g.parinfer_force_balance = false+vim.g.parinfer_comment_chars = {";"}  local api = vim.api local diff = (vim.text.diff or vim.diff)@@ -37,50 +32,6 @@   return val ~= 0 end -local function log(tag, data)-  if vim.g.parinfer_logfile then-    local f = io.open(vim.g.parinfer_logfile, "a")-    local function close_handlers_12_(ok_13_, ...)-      f:close()-      if ok_13_ then-        return ...-      else-        return error(..., 0)-      end-    end-    local function _6_()-      return f:write(("%s: %s\n"):format(tag, vim.fn.json_encode(data)))-    end-    local _8_-    do-      local t_7_ = _G-      if (nil ~= t_7_) then-        t_7_ = t_7_.package-      else-      end-      if (nil ~= t_7_) then-        t_7_ = t_7_.loaded-      else-      end-      if (nil ~= t_7_) then-        t_7_ = t_7_.fennel-      else-      end-      _8_ = t_7_-    end-    local or_12_ = _8_ or _G.debug-    if not or_12_ then-      local function _13_()-        return ""-      end-      or_12_ = {traceback = _13_}-    end-    return close_handlers_12_(_G.xpcall(_6_, or_12_.traceback))-  else-    return nil-  end-end- local function get_option(opt)   local b = vim.b[opt] or vim.g[opt]   if b == nil then@@ -97,7 +48,6 @@   local changes = state[bufnr].changes   local request = {commentChars = get_option("parinfer_comment_chars"), prevCursorLine = prev_lnum, prevCursorX = prev_col, cursorLine = lnum, cursorX = (col + 1), changes = changes, forceBalance = normalize_bool(get_option("parinfer_force_balance"))}   local response = modes[get_option("parinfer_mode")](text, request)-  log("request", request)   state[bufnr]["changes"] = {}   return response end@@ -180,19 +130,14 @@     state[bufnr]["tabstops"] = response.tabStops     state[bufnr]["prev-cursor"] = {new_lnum, new_col}     if (response.text ~= text) then-      log("change-response", response)-      local function _40_()+      vim.schedule(function ()         update_buffer(bufnr, text, response.text)         return api.nvim_win_set_cursor(winnr, {new_lnum, (new_col - 1)})       end-      vim.schedule(_40_)+    )     else     end     highlight_error(bufnr, response.error)-    if response.error then-      log("error-response", response)-    else-    end     return table.insert(elapsed_times[bufnr], (vim.loop.hrtime() - start))   else     return nil@@ -202,21 +147,24 @@ local function slice(lines, start_row, start_col, row_offset, col_offset)   local start_row0 = (start_row + 1)   local start_col0 = (start_col + 1)-  local first_line-  local function _44_()-    if (0 == row_offset) then-      return ((start_col0 + col_offset) - 1)++  local function get_offset_or_something()+    if row_offset == 0 then+      return start_col0 + col_offset - 1     else       return -1     end   end-  first_line = string.sub(lines[start_row0], start_col0, _44_())++  local first_line = string.sub(lines[start_row0], start_col0, get_offset_or_something())   local out = {first_line}+   for i = (start_row0 + 1), ((start_row0 + row_offset) - 1) do     local line = lines[i]     table.insert(out, line)   end-  if (0 ~= row_offset) then++  if (row_offset ~= 0) then     local function _45_()       if ((0 < col_offset) and lines[(start_row0 + row_offset)]) then         return string.sub(lines[(start_row0 + row_offset)], 1, col_offset)@@ -225,7 +173,6 @@       end     end     table.insert(out, _45_())-  else   end   return out end@@ -251,9 +198,6 @@     else     end     state[bufnr]["prev-contents"] = contents-    return nil-  else-    return nil   end end @@ -267,48 +211,17 @@   vim.g.parinfer_mode = "paren"   process_buffer(bufnr)   vim.g.parinfer_mode = mode-  return nil end  local function cursor_moved(bufnr)-  local function _52_()-    local _let_53_ = vim.api.nvim_win_get_cursor(0)-    local lnum = _let_53_[1]-    local col = _let_53_[2]-    state[bufnr]["prev-cursor"] = {lnum, (col + 1)}-    return nil-  end-  return vim.schedule(_52_)-end--local function stats()-  local bufnr = api.nvim_get_current_buf()-  local times = elapsed_times[bufnr]-  local n = #times-  if (n > 0) then-    local min = math.huge-    local max = 0-    local sum = 0-    local sumsq = 0-    for _, v in ipairs(times) do-      if (v < min) then-        min = v-      else-      end-      if (v > max) then-        max = v-      else-      end-      sum = (sum + v)-      sumsq = (sumsq + (v * v))+  return vim.schedule(+    function()+      local cursor = vim.api.nvim_win_get_cursor(0)+      local lnum = cursor[1]+      local col = cursor[2]+      state[bufnr]["prev-cursor"] = {lnum, (col + 1)}     end-    local avg = (sum / n)-    local sqsum = (sum * sum)-    local std = math.sqrt(((sumsq - (sqsum / n)) / (n - 1)))-    return print(("N: %d    Min: %0.6fms    Max: %0.6fms    Avg: %0.6fms    Std: %0.6fms"):format(n, (min / 1000000), (max / 1000000), (avg / 1000000), (std / 1000000)))-  else-    return nil-  end+  ) end  --- Setup@@ -323,10 +236,6 @@    local bufnr = vim.api.nvim_get_current_buf() -  vim.api.nvim_buf_create_user_command(bufnr, "ParinferStats", function()-    stats()-  end, {})-   vim.b.parinfer_enabled = vim.g.parinfer_enabled ~= false    enter_buffer()