knightrider
knightrider

Reputation: 2143

adding new file type to ultisnips

I am trying to add for the cuda (.cu) files. The basic objective is to first make all c,cpp snippets available for the cu files and then add additional support. The first thing I did to test is to set the filetype inside vim

set ft:cpp.c

and this works. Then I tried to go to the vim-snippets/snippets and vim-snippets/UltiSnips and tried to copy the cpp.snippets file to cu.snippets. But this is not working (not working as in --the snippets are not detected--) . I have also added

au BufNewFile,BufRead *.cu set ft=cuda
au BufNewFile,BufRead *.cuh set ft=cuda

in my .vimrc. Even after this it is not working.

I also checked the UltiSnipsSnippetDirectories. It is pointing to Ultisnips.

I also tried creating a cu.snippets which just tries to extend cpp (nothing else). This is also not working.

As a side question: As far I understand https://github.com/honza/vim-snippets has two folders with snippets. snippets/* for the snipmate based ones and UltiSnips/* for the ultisnips based ones. However the inc snippet is only provided on the c.snippets in snippets directory (not in ultisnips). But strangely inc works on c files for me. I am positive that I am not using snipmate. How could this happen? Am I missing something. or is it that ultisnips can understand both formats?

Upvotes: 1

Views: 1888

Answers (2)

EvgeniyRRU
EvgeniyRRU

Reputation: 531

I think, some plugin in your plugins list conflicts with your custom filetype detection config. Just faced with the same issue (tried to declare custom filetype for Jest typescript tests for react). My filetype settings overrides by peitalin/vim-jsx-typescript plugin.

So you should to switch off some of yor installed cpp plugins for detect culprit.

Upvotes: 0

thedanotto
thedanotto

Reputation: 7307

Ultisnips uses Vim's filetype detection system. So to see what filetype Vim thinks you have use the :set filetype? command.

If that's incorrect, you can try

autocmd BufRead,BufNewFile *.cu setfiletype cuda

Also, I used Vundle, and I used call vundle#rc(), but I needed to change that to call vundle#begin() and call vundle#end()

Upvotes: 1

Related Questions