!NRhNKUEoESUdXFNGzc:matrix.org

LuaSnip

72 Members
A Neovim snippet engine in Lua | https://github.com/L3MON4D3/LuaSnip11 Servers

Load older messages


SenderMessageTime
19 Apr 2024
@l3mon4d3:matrix.orgL3MON4D3Bets put that whole block into "if current", as before, but apart from that this looks sound👍 I think true is correct, could you check how jump is specified in DOC.md? It should be somewhere near the end :D Now all that's missing is the conditional on a new config-variable (exit_roots?) and that this variable defaults to `history`. For an example of that, I think the big commit that broke the behaviour has some changes to config.lua that should be similar to what you have to do :)10:45:36
@gokberkgunes:matrix.orggokberkgunesjump(direction): returns true if the jump was successful. Alright, this is correct. Working on new variable, and documentation.11:02:32
@gokberkgunes:matrix.orggokberkgunes *

jump(direction): returns true if the jump was successful. Alright, this is correct.

Working on new variable, and documentation.

11:02:43
@gokberkgunes:matrix.orggokberkgunes *

jump(direction): returns true if the jump was successful. Alright, this is correct.

Working on the new variable and the documentation.

11:02:54
@gokberkgunes:matrix.orggokberkgunes L3MON4D3: should we not always exit when reaching $0? I am confused right now. Was not the old behavior like this? 11:08:17
@gokberkgunes:matrix.orggokberkgunesOr was this only the case when history was set to false?11:08:49
@l3mon4d3:matrix.orgL3MON4D3Yeah exactly, only if history is false, which was the default11:10:26
@l3mon4d3:matrix.orgL3MON4D3With history=true the snippet remained active11:10:46
@gokberkgunes:matrix.orggokberkgunes👍️11:10:52
@gokberkgunes:matrix.orggokberkgunes

Does setting exit_roots to reverse of history value appear good to you?

When history = true, exit_roots = false which means snippets will not exit at $0.
Similarly, when history = false, exit_roots = true which means snippets exit at $0.

This simulates old behavior, correctly, does it not?

11:29:41
@gokberkgunes:matrix.orggokberkgunes

Secondly, do you think it is good idea to leave the outer if statement as it is?

		if session.config.exit_roots then
			if (next_node.pos == 0 and next_node.parent.parent_node == nil) then
				session.current_nodes[vim.api.nvim_get_current_buf()] = nil
				return true
			end
		end

Naturally, can take it into the inner if statement, but it appears harder to read.

11:31:22
@l3mon4d3:matrix.orgL3MON4D3
In reply to @gokberkgunes:matrix.org

Does setting exit_roots to reverse of history value appear good to you?

When history = true, exit_roots = false which means snippets will not exit at $0.
Similarly, when history = false, exit_roots = true which means snippets exit at $0.

This simulates old behavior, correctly, does it not?

Ahh right, yes👍👍
18:44:31
@l3mon4d3:matrix.orgL3MON4D3
In reply to @gokberkgunes:matrix.org

Secondly, do you think it is good idea to leave the outer if statement as it is?

		if session.config.exit_roots then
			if (next_node.pos == 0 and next_node.parent.parent_node == nil) then
				session.current_nodes[vim.api.nvim_get_current_buf()] = nil
				return true
			end
		end

Naturally, can take it into the inner if statement, but it appears harder to read.

I'd agree that leaving the config-setting in its own if is more readable👍 Leave it like that :D
18:46:30
@gokberkgunes:matrix.orggokberkgunesI have pushed the new commit though there is a single test failing right now.19:57:09
20 Apr 2024
@l3mon4d3:matrix.orgL3MON4D3Mhmm, I'm pretty sure that's unrelated to your change, and I thought one very recent commit to master fixed this. Are your commits based on current master?08:44:36
@gokberkgunes:matrix.orggokberkgunesimage.png
Download image.png
09:30:03
@gokberkgunes:matrix.orggokberkgunesYes, they are based on current master09:30:18
21 Apr 2024
@gokberkgunes:matrix.orggokberkgunes L3MON4D3: Are you available to check the test I have generated? It appears to be working good so far. 10:12:31
@gokberkgunes:matrix.orggokberkgunes

Here is the file

local ls_helpers = require("helpers")
local exec_lua, feed, exec =
    ls_helpers.exec_lua, ls_helpers.feed, ls_helpers.exec
local Screen = require("test.functional.ui.screen")

describe("snippets_basic", function()
	local screen

	before_each(function()
		ls_helpers.clear()
		ls_helpers.session_setup_luasnip()

		screen = Screen.new(50, 3)
		screen:attach()
		screen:set_default_attr_ids({
			[0] = { bold = true, foreground = Screen.colors.Blue },
			[1] = { bold = true, foreground = Screen.colors.Brown },
			[2] = { bold = true },
			[3] = { background = Screen.colors.LightGray },
		})
	end)

	after_each(function()
		screen:detach()
	end)


	it("exit_roots exits when the last node of snippet-root is reached.", function()
		exec_lua([[
			ls.setup({
				exit_roots = true
			})

			ls.add_snippets("all", {
			s("aa", { t{"( "}, i(1, "1"), t{" )"}, i(0, "0") })
			})
		]])

		feed("iaa")
		exec_lua("ls.expand()")
		screen:expect({
			grid = [[
			( ^1 )0                                            |
			{0:~                                                 }|
			{2:-- SELECT --}                                      |]]
		})
		feed("aa")
		exec_lua("ls.expand()")
		screen:expect({
			grid = [[
			( ( ^1 )0 )0                                       |
			{0:~                                                 }|
			{2:-- SELECT --}                                      |]]
		})
		-- verify we do not exit when reaching to a child root
		exec_lua("ls.jump(1) ls.jump(-1)")
		screen:expect({
			grid = [[
			( ( ^1 )0 )0                                       |
			{0:~                                                 }|
			{2:-- SELECT --}                                      |]]
		})
		-- be sure that reaching root $0 exits.
		exec_lua("ls.jump(1) ls.jump(1) ls.jump(-1)")
		screen:expect({
			grid = [[
			( ( 1 )0 )^0                                       |
			{0:~                                                 }|
			{2:-- SELECT --}                                      |]]
		})
	end)
end)
10:13:41
@l3mon4d3:matrix.orgL3MON4D3I'll check this evening :)11:10:18
@gokberkgunes:matrix.orggokberkgunesAlright. I thought if there should be more actions in the test but current actions appears to be enough. Let me know if you have any feedback.11:11:25
@gokberkgunes:matrix.orggokberkgunes * Alright. I thought if there should be more actions in the test but current actions appears to be enough. Let me know if you have any feedback. Maybe a test case where exit_roots set to false could also be useful. What do you say?11:26:42
@l3mon4d3:matrix.orgL3MON4D3I think the test looks good👍 +1 for another test with exit_roots false :D17:12:09
@gokberkgunes:matrix.orggokberkgunesI'm on it18:04:25
23 Apr 2024
@gokberkgunes:matrix.orggokberkgunesRedacted or Malformed Event11:51:00
@gokberkgunes:matrix.orggokberkgunes L3MON4D3: While adding exit_roots = false to tests, options set by ls_helpers.session_setup_luasnip({ hl_choiceNode = true }) appears to get overwritten. Is there any tips that I can just set exit_roots to false without affecting other settings? Currently, I'm trying to alter failing tests in luasnip/tests/integration/session_spec.lua 12:18:42
@gokberkgunes:matrix.orggokberkgunesUsing I guess it's possible using session. I got it I guess.12:27:00
@l3mon4d3:matrix.orgL3MON4D3Uh, there's an option to that function that controls the values in ls.setup, check tests/helpers.lua12:27:16
@gokberkgunes:matrix.orggokberkgunes

Any preferences to use in a test function below? Additionally, is there any difference in changing setup as given in 2nd case? I am worried if first approach will alter behavior of other tests.

ls_helpers.session_setup_luasnip({ setup_extend = { exit_roots = false}, hl_choiceNode = true})
exec_lua("ls.setup(vim.tbl_extend('force', ls.session.config, { exit_roots = true }))")
13:21:16
@l3mon4d3:matrix.orgL3MON4D3I'd prefer the first; tests that require a clean slate should reset the entire state anyway (mostly done in `before_each`)13:34:49

There are no newer messages yet.


Back to Room ListRoom Version: 6