Skip to content

How to select different choices in nested choice nodes #1367

@Bekaboo

Description

@Bekaboo

I have the following snippet for Python logs:

local fmtad = ls.extend_decorator.apply(fmta, {
  repeat_duplicates = true,
})

ls.snippet(
  {
    trig = 'lconf',
    desc = 'Config logging',
  },
  fmtad('logging.basicConfig(<out>, level=<level>)', {
    out = c(1, {
      fmtad('stream=<fd>', {
	fd = c(1, {
	  i(nil, 'sys.stdout'),
	  i(nil, 'sys.stderr'),
	}),
      }),
      fmtad('filename=<fname>, filemode=<fmode>', {
	fname = i(1, 'fname'),
	fmode = i(2, 'a'),
      }),
    }),
    level = c(2, {
      i(nil, 'logging.DEBUG'),
      i(nil, 'logging.INFO'),
      i(nil, 'logging.WARNING'),
      i(nil, 'logging.ERROR'),
      i(nil, 'logging.CRITICAL'),
      i(nil, 'logging.NOTSET'),
    }),
  })
),

I want to first set the <out> placeholder, where I can choose whether to write log to the console or a log file; inside the "writing to console" choice, there's a second layer of choice between "stderr" and "stdout".

However, after I expand the snippet, I am only able to select between "sys.stdout" and "sys.stderr" (the inner choice) but not the outer choice between writing to a file or console (stream).

I think the correct behavior should be as follows:

  1. After expanding the snippet, luasnip should select the range of the out choice, aka out node, enabling users to select between "stream=..." and "filename=..., filemode=..."
  2. Then, after pressing tab, the cursor should jump to the inner node (fd or fname), if it's fd, then the user should be able to select the inner choice node.
  3. Continue with other node...

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions