PaterJason / nvim-treesitter-sexp

MIT License
30 stars 5 forks source link

[FR] Wrap element/form #4

Open kflak opened 9 months ago

kflak commented 9 months ago

Hi, and thanks for a beautiful plugin! Learning Clojure these days, and this is a huge help in my editing experience...

I was wondering if it would be possible to implement a wrapping function, similar to the one used in vim-sexp?

thecontinium commented 5 months ago

I use the following setup using this plugin and mini.surround for

'sexp_round_head_wrap_list':      '<LocalLeader>i',
'sexp_round_tail_wrap_list':      '<LocalLeader>I',
'sexp_round_head_wrap_element':   '<LocalLeader>w',
'sexp_round_tail_wrap_element':   '<LocalLeader>W',

with <LocalLeader> set to , and using lazy.vim

{
  "PaterJason/nvim-treesitter-sexp",
  ft = "clojure",
  dependencies = 'echasnovski/mini.surround',
  init = function()
    vim.api.nvim_create_autocmd('FileType', {
      group = vim.api.nvim_create_augroup('group_treesitter-sexp', {}),
      pattern = 'clojure',
      callback = function()
        vim.keymap.set('n', ',w', 'saie)<I', { buffer = true, remap = true })
        vim.keymap.set('n', ',W', 'saie)>I ', { buffer = true, remap = true })
        vim.keymap.set('n', ',i', 'saif)((<I', { buffer = true, remap = true })
        vim.keymap.set('n', ',I', 'saif)))>I ', { buffer = true, remap = true })
      end,
    })
  end,
},
kflak commented 5 months ago

Cool, thanks!