19 Apr 2024 |
gokberkgunes | There is a problem using that function. jump_destination function is defined after jump function. | 09:27:01 |
L3MON4D3 | Jump has to modify the snippet-tree, and jump_destination does not, we have to stick with safe_jump_current for this | 09:31:20 |
L3MON4D3 | What's the problem? | 09:31:29 |
L3MON4D3 | * What's the problem with safe_jump_current? | 09:31:48 |
gokberkgunes | Nothing, I'm trying to understand how safe_jump_current works. Does this snippet-tree modification appear due to { active = {} } ? | 09:33:52 |
gokberkgunes | So, return safe_jump_current(dir, true, {}) should work? | 09:35:19 |
L3MON4D3 | Ah alright :D
The tree is modified because we don't pass no_move and that other key to jump_from | 09:35:40 |
gokberkgunes | I am not sure about if we should pass active or not such that return safe_jump_current(dir, true, { active }) | 09:36:46 |
L3MON4D3 | I think I don't know what you're figuring out just now 😅
I would've put the return-value from util.no_region_check_wrap(safe_jump...) into a temporary variable node, check whether it's the $0 of a root, if it is, set nil for current_node else set node as current_node | 09:38:11 |
L3MON4D3 | Ah! If I write current_node, I meant session.current_nodes[vim.api...], srry for that | 09:38:44 |
gokberkgunes | Sorry, I'm pretty foreign how luasnip works. Since you suggested that we should use safe_jump_current to figure of return value of jump function. I wanted to see which parameters should I pass to safe_jump_current . | 09:48:06 |
L3MON4D3 | Oh, you can leave the safe_jump_current-call as-is | 09:56:10 |
L3MON4D3 | Right now, we'd do the jump and always store the jumped-to node in session.current_nodes.
I'd propose to instead do the jump and only conditionally store the node in current_nodes, ie. don't store if it is the $0 of a root-snippet | 09:58:28 |
gokberkgunes | diff --git a/lua/luasnip/init.lua b/lua/luasnip/init.lua
index 5ec2a93..4183df9 100644
--- a/lua/luasnip/init.lua
+++ b/lua/luasnip/init.lua
@@ -158,6 +158,12 @@ local function safe_jump_current(dir, no_move, dry_run)
end
local function jump(dir)
local current = session.current_nodes[vim.api.nvim_get_current_buf()]
+
+ if (current.pos == 0 and current.parent.parent_node == nil) then
+ session.current_nodes[vim.api.nvim_get_current_buf()] = nil
+ return true
+ end
+
if current then
session.current_nodes[vim.api.nvim_get_current_buf()] =
util.no_region_check_wrap(safe_jump_current, dir)
This should work then, nope?
I got confused because you mentioned we should decide the return value by usign safe_jump_current
| 10:02:46 |
gokberkgunes | Forgive me if this is getting too vexing, I am not sure what is needed to be done. | 10:04:29 |
L3MON4D3 | Almost, only do that check on the value returned by `util.no_region_check_wrap(safe_jump_current, dir)`, that's the node we would jump from next | 10:06:56 |
L3MON4D3 | In reply to @gokberkgunes:matrix.org Forgive me if this is getting too vexing, I am not sure what is needed to be done. I could also implement this, only I'm not at home right now, so it'll be a bit | 10:07:53 |
gokberkgunes | diff --git a/lua/luasnip/init.lua b/lua/luasnip/init.lua
index 5ec2a93..1a9a2cb 100644
--- a/lua/luasnip/init.lua
+++ b/lua/luasnip/init.lua
@@ -158,6 +158,13 @@ local function safe_jump_current(dir, no_move, dry_run)
end
local function jump(dir)
local current = session.current_nodes[vim.api.nvim_get_current_buf()]
+
+ local next_node = util.no_region_check_wrap(safe_jump_current, dir)
+ 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
+
if current then
session.current_nodes[vim.api.nvim_get_current_buf()] =
util.no_region_check_wrap(safe_jump_current, dir)
I don't know if this is what you meant, but this does not work properly.
| 10:19:17 |
gokberkgunes | * diff --git a/lua/luasnip/init.lua b/lua/luasnip/init.lua
index 5ec2a93..1a9a2cb 100644
--- a/lua/luasnip/init.lua
+++ b/lua/luasnip/init.lua
@@ -158,6 +158,13 @@ local function safe_jump_current(dir, no_move, dry_run)
end
local function jump(dir)
local current = session.current_nodes[vim.api.nvim_get_current_buf()]
+
+ local next_node = util.no_region_check_wrap(safe_jump_current, dir)
+ 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
+
if current then
session.current_nodes[vim.api.nvim_get_current_buf()] =
util.no_region_check_wrap(safe_jump_current, dir)
I don't know if this is what you meant, but this does not work properly.
| 10:19:27 |
gokberkgunes | Should I give up? lol | 10:19:39 |
gokberkgunes | Download lst.mp4 | 10:20:50 |
gokberkgunes | * diff --git a/lua/luasnip/init.lua b/lua/luasnip/init.lua
index 5ec2a93..1a9a2cb 100644
--- a/lua/luasnip/init.lua
+++ b/lua/luasnip/init.lua
@@ -158,6 +158,13 @@ local function safe_jump_current(dir, no_move, dry_run)
end
local function jump(dir)
local current = session.current_nodes[vim.api.nvim_get_current_buf()]
+
+ local next_node = util.no_region_check_wrap(safe_jump_current, dir)
+ 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
+
if current then
session.current_nodes[vim.api.nvim_get_current_buf()] =
util.no_region_check_wrap(safe_jump_current, dir)
I don't know if this is what you meant, but this does not work properly. The previous one appeared as working correctly.
| 10:24:20 |
gokberkgunes | In reply to @l3mon4d3:matrix.org I could also implement this, only I'm not at home right now, so it'll be a bit I would like to contribute and learn how luasnip works. It's just I am worried that I am spending your time with my newbie attempts. | 10:25:23 |
L3MON4D3 | In reply to @gokberkgunes:matrix.org
diff --git a/lua/luasnip/init.lua b/lua/luasnip/init.lua
index 5ec2a93..1a9a2cb 100644
--- a/lua/luasnip/init.lua
+++ b/lua/luasnip/init.lua
@@ -158,6 +158,13 @@ local function safe_jump_current(dir, no_move, dry_run)
end
local function jump(dir)
local current = session.current_nodes[vim.api.nvim_get_current_buf()]
+
+ local next_node = util.no_region_check_wrap(safe_jump_current, dir)
+ 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
+
if current then
session.current_nodes[vim.api.nvim_get_current_buf()] =
util.no_region_check_wrap(safe_jump_current, dir)
I don't know if this is what you meant, but this does not work properly. The previous one appeared as working correctly.
Oh almost correct: in the not-$0 branch, assign next_node to session.current_nodes, don't "jump again" | 10:32:34 |
L3MON4D3 | In reply to @gokberkgunes:matrix.org I would like to contribute and learn how luasnip works. It's just I am worried that I am spending your time with my newbie attempts. Nah, so far you haven't spent that much of my time, don't worry :) | 10:33:41 |
gokberkgunes | alright then xD | 10:34:09 |
gokberkgunes | In reply to @l3mon4d3:matrix.org Oh almost correct: in the not-$0 branch, assign next_node to session.current_nodes, don't "jump again" okay, this makes perfect sense now. all good. | 10:36:29 |
gokberkgunes | diff --git a/lua/luasnip/init.lua b/lua/luasnip/init.lua
index 5ec2a93..4d4d4ae 100644
--- a/lua/luasnip/init.lua
+++ b/lua/luasnip/init.lua
@@ -158,9 +158,15 @@ local function safe_jump_current(dir, no_move, dry_run)
end
local function jump(dir)
local current = session.current_nodes[vim.api.nvim_get_current_buf()]
+
+ local next_node = util.no_region_check_wrap(safe_jump_current, dir)
+ if (next_node.pos == 0 and next_node.parent.parent_node == nil) then
+ session.current_nodes[vim.api.nvim_get_current_buf()] = nil
+ return false
+ end
+
if current then
- session.current_nodes[vim.api.nvim_get_current_buf()] =
- util.no_region_check_wrap(safe_jump_current, dir)
+ session.current_nodes[vim.api.nvim_get_current_buf()] = next_node
return true
else
return false
I am pushing this as the previous pull request, all good?
| 10:37:44 |
gokberkgunes | * diff --git a/lua/luasnip/init.lua b/lua/luasnip/init.lua
index 5ec2a93..4d4d4ae 100644
--- a/lua/luasnip/init.lua
+++ b/lua/luasnip/init.lua
@@ -158,9 +158,15 @@ local function safe_jump_current(dir, no_move, dry_run)
end
local function jump(dir)
local current = session.current_nodes[vim.api.nvim_get_current_buf()]
+
+ local next_node = util.no_region_check_wrap(safe_jump_current, dir)
+ 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
+
if current then
- session.current_nodes[vim.api.nvim_get_current_buf()] =
- util.no_region_check_wrap(safe_jump_current, dir)
+ session.current_nodes[vim.api.nvim_get_current_buf()] = next_node
return true
else
return false
I am pushing this as the previous pull request, all good?
| 10:38:20 |
gokberkgunes | * diff --git a/lua/luasnip/init.lua b/lua/luasnip/init.lua
index 5ec2a93..4d4d4ae 100644
--- a/lua/luasnip/init.lua
+++ b/lua/luasnip/init.lua
@@ -158,9 +158,15 @@ local function safe_jump_current(dir, no_move, dry_run)
end
local function jump(dir)
local current = session.current_nodes[vim.api.nvim_get_current_buf()]
+
+ local next_node = util.no_region_check_wrap(safe_jump_current, dir)
+ 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
+
if current then
- session.current_nodes[vim.api.nvim_get_current_buf()] =
- util.no_region_check_wrap(safe_jump_current, dir)
+ session.current_nodes[vim.api.nvim_get_current_buf()] = next_node
return true
else
return false
returning true is correct, right?
If so, I am pushing this as the previous pull request, is all good?
| 10:38:58 |