Something went wrong. Try again.
neovim configuration using rocks.nvim plugin manager
Something went wrong. Try again.
1.2 kB · 39 lines
Lua
at main
12345678910111213141516171819202122232425262728293031323334353637383940local treesj = require("treesj")local lang_utils = require("treesj.langs.utils")
---@param parent_kind string---@param node_kind stringlocal function splitjoin_attribute_value(parent_kind, node_kind) return { both = { enable = function(tsn) return tsn:parent():type() == parent_kind end, }, split = { format_tree = function(tsj) local str = tsj:child(node_kind) local words = vim.split(str:text(), " ") tsj:remove_child(node_kind) for i, word in ipairs(words) do tsj:create_child({ text = word }, i + 1) end end, }, }end
treesj.setup({ use_default_keymaps = false, max_join_length = 240, langs = { html = lang_utils.merge_preset(require("treesj.langs.html"), { ["quoted_attribute_value"] = splitjoin_attribute_value("attribute", "attribute_value"), }), javascript = lang_utils.merge_preset(require("treesj.langs.javascript"), { ["string"] = splitjoin_attribute_value("jsx_attribute", "string_fragment"), }), },})
vim.keymap.set("n", "<leader>j", treesj.toggle)