nvim.lua 654 B

123456789101112131415161718192021
  1. vim.api.nvim_create_user_command('Inspect', function(cmd)
  2. if cmd.bang then
  3. vim.print(vim.inspect_pos())
  4. else
  5. vim.show_pos()
  6. end
  7. end, { desc = 'Inspect highlights and extmarks at the cursor', bang = true })
  8. vim.api.nvim_create_user_command('InspectTree', function(cmd)
  9. if cmd.mods ~= '' or cmd.count ~= 0 then
  10. local count = cmd.count ~= 0 and cmd.count or ''
  11. local new = cmd.mods ~= '' and 'new' or 'vnew'
  12. vim.treesitter.inspect_tree({
  13. command = ('%s %s%s'):format(cmd.mods, count, new),
  14. })
  15. else
  16. vim.treesitter.inspect_tree()
  17. end
  18. end, { desc = 'Inspect treesitter language tree for buffer', count = true })