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

add option to skip indent nodes #1072

Merged
merged 7 commits into from
Dec 2, 2023

Conversation

TwIStOy
Copy link
Contributor

@TwIStOy TwIStOy commented Dec 2, 2023

No description provided.

@L3MON4D3
Copy link
Owner

L3MON4D3 commented Dec 2, 2023

Interesting!
What's the usecase?

@TwIStOy
Copy link
Contributor Author

TwIStOy commented Dec 2, 2023

Some LSP servers already take indens into consideration. In such cases, LuaSnip will add additional indents.

Before the option:

CleanShot.2023-12-02.at.21.38.15.mp4

After the option:

CleanShot.2023-12-02.at.21.39.15.mp4

Config in nvim-cmp can be:

snippet = {
  expand = function(args)
    local skip_indent_nodes = false
    if vim.api.nvim_get_option_value("filetype", { buf = 0 }) == "dart" then
      skip_indent_nodes = true
    end
    require("luasnip").lsp_expand(args.body, {
      skip_indent_nodes = skip_indent_nodes,
    })
  end,
},

@L3MON4D3
Copy link
Owner

L3MON4D3 commented Dec 2, 2023

Ahh okay, pretty cool 👍

lua/luasnip/init.lua Outdated Show resolved Hide resolved
@L3MON4D3
Copy link
Owner

L3MON4D3 commented Dec 2, 2023

Could you also add this to the other documented options in snip_expand (waaayyyy at
the bottom of DOC.md IIRC)? I think especially including the motivation with lsp would be pretty cool, could you do that?

@TwIStOy
Copy link
Contributor Author

TwIStOy commented Dec 2, 2023

All fixed!

DOC.md Show resolved Hide resolved
@L3MON4D3
Copy link
Owner

L3MON4D3 commented Dec 2, 2023

Beautiful, could you squash the commits?

@L3MON4D3
Copy link
Owner

L3MON4D3 commented Dec 2, 2023

Ah wait I can squash :D

@L3MON4D3 L3MON4D3 merged commit 07f217f into L3MON4D3:master Dec 2, 2023
@L3MON4D3
Copy link
Owner

L3MON4D3 commented Dec 2, 2023

Cool, that seems to have worked.
Thank you!! Really cool addition (again) :D

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

Successfully merging this pull request may close these issues.

2 participants