Vim UltiSnips for python not working - vim

Maybe it's a stupid question, but I can't figure it out. I have installed the UltiSnips plugin [UltiSnips plugin][1]. I followed all the instructions on setting it up. I added this into my .vimrc file but it's not working:
" Track the engine.
Plugin 'SirVer/ultisnips'
" Snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
I checked that is not used anywhere in the rest of my .vimrc file. When I pritn 'cl' and press tab nothing happens. However, I am expeting it to offer me insert snippet for the python class.
This is the list of plugin I am using:
ctrlp
jedi-vim
SumpylFold
ultisnips
vim-airline
vim-airline-themes
vim-fugitive
Vundle
indentpython
nerdtree
vim-nerdtree-tabs
syntastic
vim-flake8
What am I missing here?

I got answer here answer to my question. This is some clarification:
I added this line from the documentation of UltiSnips let g:UltiSnipsSnippetDirectories=["UltiSnips"] to the .vimrc file and it's working fine now. It wasn't obvious in my case, though.

Related

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?
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()
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.

Using the VIM JavaScript syntax file

I tried including the following syntax file into my vim.
I installed this plugin using Pathogen as per instruction:
git clone https://github.com/jelera/vim-javascript-syntax.git ~/.vim/bundle/vim-javascript-syntax
Then included the following in my .virc file
au FileType javascript call JavaScriptFold()
After restarting vim and opening a JavaScript file I am not able to fold using the standard zo, zc commands .. any clue ?
Check whether the fold settings have been activated:
:verbose set foldmethod?
:syntax list foldBraces
The first should yield syntax, and the syntax group should be defined.
Note that only { ... } blocks spanning multiple lines are folded by this.
For anyone else who may come across this scenario; I had the exact same problem. The fix, for me, was to edit my .vimrc by moving
syntax enable
above
au FileType javascript call JavaScriptFold()

Unable to use NERDCommenter with vundle

I am using vim The-NERD-Commenter plugin along with vundle. But I am not able to get the plugin to work.
I have my leader ley mapped to ,. When I run the :scriptnames command I see that ~\vimfiles\bundle\The-NERD-Commenter\plugin\NERD_commenter.vim is listed in the output. I am also able to bring up help for NERDCommenter using :help NERDCommenter command which tells me that the plugin is installed correctly. But when I try to toggle a comment using <leader>c<space> which translates in my case to ,c it invokes the change command instead.
I have my .vimrc file here https://gist.github.com/bAmrish/be1aac3aeb087925a3e5
Update:
It looks like if I remove the leader key mapping from my .vimrc file then the plugin starts working with the default leader key \.
Please let me know what am I doing wrong.
Thanks,
Amrish
You are installing the plugin twice (lines 15, 29):
Plugin 'The-NERD-Commenter'
Plugin 'https://github.com/scrooloose/nerdcommenter.git'
From scanning the README, the scrooloose version doesn't seem to support the c shortcut, so it may be doing some blocking. Reread the documentations and choose one of the two. Post back if your problem isn't solved by one of those two actions.
UPDATE:
Okay, digging deeper. The plugin's .vim code runs the following line:
let leader = exists('g:mapleader') ? g:mapleader : '\'
In your vim try running
:echo exists('g:mapleader')
:echo 'g:mapleader'
If the mapleader exists and spits back , as expected, then we need to look for unexpected/buggy code in the plugin. If it doesn't exist or isn't , as you expect, then we know what needs to be fixed.

Vim Vundle - load ftplugin for different filetype

How, using Vundle, can I load a ftplugin for a filtype it wasn't written for?
In my old .vimrc (before I started using Vundle), I would do something like this:
au FileType xquery ru fplugin/xhtml.vim
But that doesn't seem to be doing the trick.
...any thoughts?
Thanks!
(Not a Vundle user, and I think it should not affect your command.)
Instead of the :autocmd, create a file ftplugin/xquery.vim (either under ~/.vim/ or as a bundle), with the following contents:
runtime! ftplugin/xhtml.vim
runtime! ftplugin/xhtml_*.vim ftplugin/xhtml/*.vim
(This assumes you have :filetype plugin on.)
OK, so I'm just coming back to this, and it turns out that what I had up there actually does work. Except that the line that I'm actually using in Vim uses a lower case "t" in "Filetype". Not sure if that was the issue, but it works perfectly now:
au Filetype xquery ru ftplugin/xhtml.vim

Disabling pathogen for loading specific plugin for javascript files

I do not want to use the plugin "surround" (listed as /bundle/vim-surround) when I am using pathogen with vim for javascript files.
I currently have the following:
let g:pathogen_disabled = []
au FileType javascript call add(g:pathogen_disabled, 'vim-surround')
"Pathogen must be called before everything
call pathogen#infect()
Somehow I am still seeing the effects of surround. What's going on?
It doesn't seem to work here either. I've also tried with surround instead of vim-surround and with other random plugins without any success.
I suggest you raise an issue at Tim Pope's GitHub page.

Resources