Skip to content

Dynamic node with user input #963

Answered by uyha
uyha asked this question in Q&A
Jul 23, 2023 · 1 comments · 10 replies
Discussion options

You must be logged in to vote

awesome, so the minial snippet to have expand dynamic node with user input is

vim.keymap.set(
  { "i", "s" },
  "<C-e>",
  function()
      local current_node = ls.session.current_nodes[vim.api.nvim_get_current_buf()]
      local dyn_node = current_node
      while not dyn_node.dynamicNode do
        dyn_node = dyn_node.parent
      end
      dyn_node = dyn_node.dynamicNode

      local fn = dyn_node.user_args[1]
      fn(dyn_node.parent.user_state)
      dyn_node.last_args = nil
      dyn_node:update()
      ls.session.current_nodes[vim.api.nvim_get_current_buf()] = dyn_node.snip:jump_into(1)
  end
)

ls.add_snippets("text", {
  s(
    "recurse",
    fmt(
      [[
      command({})
      ]]

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@uyha
Comment options

@L3MON4D3
Comment options

@uyha
Comment options

Answer selected by uyha
@L3MON4D3
Comment options

@uyha
Comment options

@L3MON4D3
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants