Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LuaSnip + texlab not working properly #218

Closed
tiagovla opened this issue Nov 11, 2021 · 7 comments
Closed

LuaSnip + texlab not working properly #218

tiagovla opened this issue Nov 11, 2021 · 7 comments

Comments

@tiagovla
Copy link
Contributor

I opened this issue latex-lsp/texlab#503, but I'm not sure if it's texlab that's causing the problem. I noticed that it only happens if I don't jump to all fields and escape. Could this be related to luasnip or nvim-cmp?

@L3MON4D3
Copy link
Owner

Yes, that could very well be related to luasnip+formatting.
Could you do :lua Luasnip_current_nodes[vim.api.nvim_get_current_buf()].parent:dump() (prints the nodes' positions) after the text was duplicated? I'd assume the extmarks get messed up by the formatting (if a block of text is replaced, the marks that were inside it get pushed to either end).

@tiagovla
Copy link
Contributor Author

:lua Luasnip_current_nodes[vim.api.nvim_get_current_buf()].parent:dump():

E5108: Error executing lua [string ":lua"]:1: attempt to index global 'Luasnip_curren
t_nodes' (a nil value)
stack traceback:
        [string ":lua"]:1: in main chunk

:lua require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()].parent:dump()

1
false false
0 0
0 0
2
false true
0 0
17 0
3
true false
17 0
0 0
4
false false
0 0
8 0
5
false false
8 0
8 0
6
false false
8 0
8 0
7
false false
8 0
8 0
8
false false
8 0
8 0
9
false false
8 0
8 0
10
false false
8 0
8 0

@tiagovla
Copy link
Contributor Author

\documentclass{article}

\begin{document}
\section{ok} % (fold)
\label{sec:ok}

% section section name (end)

\documentclass{article}

\begin{document}
\section{ok} % (fold)
\label{sec:ok}

% section section name (end)

\end{document}

@L3MON4D3
Copy link
Owner

Yes that's the correct one :D 🤦
Normally these indices should be consecutive, here the marks are getting moved around.
Sadly there's little we can do about that (except manually tracking changes and not relying on extmarks, but that's very much work) :/

@tiagovla
Copy link
Contributor Author

This is using efm to format instead of texlab:

1
false false
3 0
3 9
2
false true
3 9
3 11
3
true false
3 11
4 11
4
false false
4 11
4 13
5
false false
4 13
5 0
6
false false
5 0
5 0
7
false false
5 0
5 0
8
false false
5 0
6 10
9
false false
6 10
6 22
10
false false
6 22
6 28

Is this the normal behavior? Efm does not duplicate it, only texlab does that.

@L3MON4D3
Copy link
Owner

That looks correct, you can see that all nodes are adjacent ((3,0)->(3,9), (3,9)->(3,11),...), which is the correct behaviour.
I guess efm does something nicer, eg. not formatting at all or only inserting/removing parts that need to be changed as opposed to texlabs' complete replacement of the buffer.

@L3MON4D3
Copy link
Owner

L3MON4D3 commented Oct 4, 2023

Should no longer happen after 6e951d8, I think

@L3MON4D3 L3MON4D3 closed this as completed Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants