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

UltiSnips string interpolation does not work. #323

Open
nonetallt opened this issue Jan 12, 2023 · 1 comment
Open

UltiSnips string interpolation does not work. #323

nonetallt opened this issue Jan 12, 2023 · 1 comment
Labels
question Further information is requested

Comments

@nonetallt
Copy link

nonetallt commented Jan 12, 2023

Platform information:

  • OS: Ubuntu 20.04
  • Vim: Neovim 0.8.2

Relevant plugins used:

  • coc.nvim
  • coc-snippets
  • UltiSnips

I'm trying to use string interpolation for dynamic snippet content, as described in section 4.4 of the UltiSnips documentation. Given that there's a checkmark next to Execute vim, python and shell code in snippet in the readme of this repository while another bulletpoint makes a reference to Execute shell code with custom shabang (will not support), it is implied that string interpolation should indeed be supported by this extension.

However, as far as I can tell, none of the various interpolation modes work. I've tested this with shell, python and vimscript and I'm getting a variation of this error for each of them:

[coc.nvim]: UnhandledRejection: Vim:E121: Undefined variable: v 
Error: request error on "nvim_eval" - Vim:E121: Undefined variable: v 
    at pX (/home/nonetallt/.config/nvim/plugged/coc.nvim/build/index.js:194:10656)
    at Do.resolve (/home/nonetallt/.config/nvim/plugged/coc.nvim/build/index.js:203:2810)
    at /home/nonetallt/.config/nvim/plugged/coc.nvim/build/index.js:206:1476        
    at Array.map (<anonymous>)                                                                          
    at Ac.evalCodeBlocks (/home/nonetallt/.config/nvim/plugged/coc.nvim/build/index.js:206:1445)     
    at gm.resolve (/home/nonetallt/.config/nvim/plugged/coc.nvim/build/index.js:249:728)    
    at runMicrotasks (<anonymous>)   
    at processTicksAndRejections (node:internal/process/task_queues:96:5) 

The only change between interpolation modes is that the "Undefined variable" is whatever word follows after the backticks or exclamation mark. Here's an example snippet that causes the error above:

snippet test-vim "This is a test vim snippet"
`!v system('echo test')`
endsnippet

Another variation, this one for shell interpolation:

snippet test-shell "This is a test shell snippet"
`echo foo`
endsnippet

The shell variation results in Undefined variable: echo. I've tried these snippets with the basic UltiSnips expand command and they work correctly, just not when invoked through this plugin. I don't see this issue as being addressed very clearly despite looking through the previous issues in this repostory. I did manage to find the coc-ultisnips plugin, which might suit my purposes better. However it's still unclear to me whether this plugin is supposed to support string interpolation in snippets or not? If not, then it should addressed clearly in the readme.

Edit:
There seems to be something weird going on with the loading of the snippets. Sometimes after I've had neovim open for a longer period (and probably tinkered with the snippets file by editing and saving it), a second entry gets added to the snippet autocompletion menu. See the following picture for reference:

bug

Here I'm working with a "namespace" snippet that uses string interpolation with vimscript. Notice how two different snippets are sourced:

  • ns|namespace~
  • "ns|namespace"~

The one without quotes works but the one with quotes errors with the expected undefined variable. For some reason, only the snippet with quotes is added whenever I open the editor.

@chemzqm
Copy link
Member

chemzqm commented Jan 22, 2023

Can't reproduce, the snippets with string interpolation work as expected for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants