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

python: merge base.json into python.json and change snippets #454

Merged
merged 3 commits into from
Jun 3, 2024

Conversation

REmerald
Copy link
Contributor

It seems that there's no purpose for base.json, there is even duplicate snippets in these 2 files.

So I merged them into python.json.
Also, deleted obsolete (e.g. python2 future and encoding) and useless (e.g. async variants because you can just type async and then use normal def) snippets, added some useful ones, made prefixes more user friendly and shortened descriptions.

It seems that there's no purpose for `base.json`, there is even duplicate snippets in these 2 files, so I merged them into `python.json`.
Also, deleted obsolete (e.g. python2 future and encoding) and useless (e.g. async variants because you can just type `async` and then use normal `def`) snippets, added some useful ones, made prefixes more user friendly and shortened descriptions
Copy link
Collaborator

@OkelleyDevelopment OkelleyDevelopment left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I greatly appreciate this PR (a similar refactor should happen with the LaTeX snippets, but that's a later problem).

Overall I think I'm content with these changes, have you tested these locally too @REmerald ?

@REmerald
Copy link
Contributor Author

@OkelleyDevelopment, for the most part they do, but there are 2 problems with some neovim setups.

For some reason vim.snippet rejects nested placeholder and placeholder-transform inside a placeholder:

vim.snippet  WARN Failed to parse snippet,
but was able to fix it automatically.
```python
try:
	${1:pass}
except ${2:Exception} as ${3:e}:
	${4:raise $3}
else:
	${5:pass}
```

and inserted text is

try:
    pass
except Exception as e:
    raise 
else:
    pass

Similar situation the nested placeholder like "\t${4:raise ${5:SystemExit}}".

And secondly, for some reason after typing # character(s) the completion menu doesn't show up, only after typing additional letter such as #e the menu appears. This applies to other special characters such as #, / or @.
This means, I can't insert # and ## snippets (/, // and /** as well in C files).
But this can be LazyVim, garymjr/nvim-snippets or nvim-cmp issue, I don't have LuaSnip setup to test.

These 2 issues seem to be related to snippets in almost all languages, not just python, so I think, we can merge this pr and later figure out if it's our issue or not.

@OkelleyDevelopment
Copy link
Collaborator

OkelleyDevelopment commented Jun 3, 2024

Yeah that seems to be a problem out of scope for this PR, so I'll merge these. FWIW in my local setup (a little different from my last config update), was able to handle this snippet:

"test": {
    "prefix": "nested",
    "body": ["${1:entry ${2:entrytwo}}"]
  }

@OkelleyDevelopment OkelleyDevelopment merged commit e11b09b into rafamadriz:main Jun 3, 2024
@OkelleyDevelopment
Copy link
Collaborator

Feel free to raise an issue with whatever you've researched (even if it's just a copy-paste from the above text) @REmerald.

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