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

Another command for linking #205

Open
zorgick opened this issue Jul 21, 2021 · 0 comments
Open

Another command for linking #205

zorgick opened this issue Jul 21, 2021 · 0 comments

Comments

@zorgick
Copy link

zorgick commented Jul 21, 2021

command! -bang VsnipOpen call s:open_command(<bang>0, 'vsplit')

First of all, thank you very much for your amazing plugin, it works like a charm with vim-lsp.

I think, it might be useful to add one more command for creating a symlink to a dedicated snippet file that exists in other directory, than g:vsnip_snippet_dir.
Also, It would be great to have a variable with an absolute path to a symlinked external directory. I'll explain later, what I mean.

First of all, I am aware of a very useful feature of your plugin that merges snippets from another plugins with snippets from g:vsnip_snippet_dir.

However, in my case (and I hope somebody will face with it also) I want to have several comfy features:

  1. Develop my favourite plugin with snippets, e.g. my snippets installed locally on my machine in ~/Documents/my-snippets. Let's call it my-snippets directory.
  2. Have g:vsnip_snippet_dir variable set to ~/.config/nvim/snippets. Let's call it root-snippets.
  3. Have my-snippets plugin installed via Plug in my init.vim, e.g. Plug 'zorgick/my-snippets'
  4. I don't want to change root-snippets variable in my init.vim config each time my-snippets directory changes. Furthermore, my-snippets directory might not even exist on my other virtual machine.
  5. Experiment with snippets in root-snippets and have precedence of root-snippets over my my-snippets plugin.
  6. Update my-snippets with changes that I favor in root-snippets, commit them and push to my repository, so that I could use them later as Plug 'zorgick/my-snippets'

What I am doing currently as a workaround to achieve a similar result

  1. I have g:vsnip_snippet_dir variable set to ~/.config/nvim/snippets
  2. I have my-snippets installed locally on my machine in ~/Documents/my-snippets
  3. If I want to add a typescript snippet to my-snippets, I symlink this file to root-snippets
ln -s /home/zorgik/Documents/my-snippets/javascript/typescript.json /home/zorgik/.config/nvim/snippets
  1. I check if the snippet works correctly, commit changes in my-snippets directory and push them to my repository.

Alas, It requires a lot of typing in the terminal each time I want to add another snippet for another language.

How I see the improvements of your plugin to make the above work out of the box:

  1. You may find it useful to add another variable, e.g., g:vsnip_external_dir, that will be a prefix for external snippet files. It will give a user an ability to type in only filename of the lynked snippet, instead of the full path.
let g:vsnip_external_dir = expand('~/Documents/my-snippets/')
  1. I kindly suggest you to add one more command, e.g., VsnipLink, that will behave similar to VsnipOpen, but with extra step. On this additional step VsnipLink will prompt the user to type in either full path to an external snippet file, e.g., /home/zorgik/Documents/my-snippets/javascript/typescript.json, or just a filename if the previous item in this list is implemented, so that this filename will be appended to the g:vsnip_external_dir path.

Hope, you will find this idea usefull for your plugin.

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

1 participant