Code Monkey home page Code Monkey logo

Comments (18)

hrsh7th avatar hrsh7th commented on August 29, 2024 3

Currently, vsnip does not support it.

My random thought is it would be good to provide g:vsnip_filetypes variable.

let g:vsnip_filetypes = {}
let g:vsnip_filetypes.typescriptreact = ['typescript', 'javascript']
let g:vsnip_filetypes.jinja = ['html']

from vim-vsnip.

hrsh7th avatar hrsh7th commented on August 29, 2024 2

I think vsnip's global.json is the same feature for ultisnips's all.snippets.

If these does not the same, please explain what you want.

from vim-vsnip.

hrsh7th avatar hrsh7th commented on August 29, 2024 2

Implemented in #89

from vim-vsnip.

jandamm avatar jandamm commented on August 29, 2024 1

Unfortunately this breaks the Vim way to handle sub filetypes.
In vim you would typically solve this by setting the filetype to jinja.html.

This is also the way how UltiSnips handles this.
Using filetypes with a . to separate them is supported by many other plugins as well.

Vim does this for ftplugins the same way.
Assuming you have ftplugin/jinja.vim and ftplugin/html.vim in your &rtp, vim would first source ftplugin/html.vim and then ftplugin/jinja.vim.

from vim-vsnip.

jandamm avatar jandamm commented on August 29, 2024 1

This would let the user decide if the default behavior is wanted (by not doing anything) or overwrite it with their own logic.

Somewhere here:

function! vsnip#source#filetypes(bufnr) abort
let l:filetype = getbufvar(a:bufnr, '&filetype', '')
return [l:filetype] + get(g:vsnip_filetypes, l:filetype, []) + ['global']
endfunction

from vim-vsnip.

hrsh7th avatar hrsh7th commented on August 29, 2024

(I am not a native English speaker so every naming is hard and worry to decision...)

from vim-vsnip.

ahmedelgabri avatar ahmedelgabri commented on August 29, 2024

I think this is a good idea 👍

from vim-vsnip.

ahmedelgabri avatar ahmedelgabri commented on August 29, 2024

Another question, is there is something similar to all.snippets in UltiSnips in vsnip? can this be fixed by the above solution?

For example

let g:vsnip_filetypes = {}
let g:vsnip_filetypes['*']= ['all']

from vim-vsnip.

ahmedelgabri avatar ahmedelgabri commented on August 29, 2024

Working great, thanks @hrsh7th!

from vim-vsnip.

hrsh7th avatar hrsh7th commented on August 29, 2024

I intentionally deleted it, but I think it's OK to restore it.

For example, javascript.tsx case, how we should handle it?

  1. filetypes=javascript.tsx, javascript, tsx and g:vsnip_filetypes['javascript.tsx']
  2. filetypes=javascript, tsx and g:vsnip_filetypes['javascript.tsx']
  3. filetypes=javascript, tsx and g:vsnip_filetypes['javascript'] + g:vsnip_filetypes['tsx']

from vim-vsnip.

jandamm avatar jandamm commented on August 29, 2024

Using the "Vim-logic" it would check in javascript.json and tsx.json.
When the prefix is available in both, the javascript one is used, as it is the first filetype.

from vim-vsnip.

hrsh7th avatar hrsh7th commented on August 29, 2024

Due to my previous decision, probably we can not able to ignorejavascript.tsx.json... sorry.

But thank you! your opinion seems correct to me.

I restore it as javascript.tsx, javascript, tsx and g:vsnip_filetypes['javascript.tsx'].

from vim-vsnip.

hrsh7th avatar hrsh7th commented on August 29, 2024

Hm... How to change this behavior with keeping backward compatibility.

from vim-vsnip.

jandamm avatar jandamm commented on August 29, 2024

What if this would prefill g:vsnip_filetypes['javascript.tsx'] = ['javascript', 'tsx']?
Of course only if the key does not exist.

from vim-vsnip.

hrsh7th avatar hrsh7th commented on August 29, 2024

Ah. sorry.
I was misunderstanding the previous behavior.

I was checked VsnipOpen command after set filetype=javascript.jsx in old vsnip.
Then, vsnip display javascript or jsx or global.

So we has no problem maybe.

from vim-vsnip.

hrsh7th avatar hrsh7th commented on August 29, 2024

I think https://github.com/hrsh7th/vim-vsnip/pull/96/files solves this problem.

from vim-vsnip.

jandamm avatar jandamm commented on August 29, 2024

Looks good 👍

from vim-vsnip.

hrsh7th avatar hrsh7th commented on August 29, 2024

Thank you!

from vim-vsnip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.