1

I am using vim-plug to load many plugins into MacVim running through Rosetta on MacBook Air M1. One of the plugins is UltiSnips by SirVer.

The problem is that UltiSnips does load (checked via :PlugStatus) but doesn't work by default whenever I run vim/MacVim through terminal or .app application whereas all other plugins do.

For example : Let's say I open a document named test.tex in MacVim through terminal or the application. I have predefined snippet called notes in UltiSnips which doesn't work if I immediately use it. Now, if I run in command mode :UltiSnipsEdit then it is not recognized which leads me to believe that UltiSnips is not loaded/working (so I use :PlugStatus which tells me it is loaded but not working whereas others are loaded and working e.g. vimtex plugin runs perfectly) but strangely enough if I run :PlugInstall (whereupon UltiSnips and other snippets are shown to be Already installed) and then come back to my document then the snippets from UltiSnips do work and I can also use :UltiSnipsEdit.

I have already tried restarting my system and running Terminal under Rosetta to no avail.

Can someone please help me figure out how to make UltiSnips work by default without doing the :PlugInstall thing?

My ~/.gvimrc :- (also tried putting full path to plugins in the call but didn't make any difference)

call plug#begin()

Plug 'SirVer/ultisnips'
let g:UltiSnipsExpandTrigger='<tab>'
let g:UltiSnipsJumpForwardTrigger='<tab>'
let g:UltiSnipsJumpBackwardTrigger='<s-tab>'
let g:UltiSnipsEditSplit='tabdo'
let g:UltiSnipsSnippetDirectories=['/home-path-directory/.vim/plugged/mysnippets/']

Plug 'honza/vim-snippets'

Plug 'arcticicestudio/nord-vim'

Plug 'KeitaNakamura/tex-conceal.vim', {'for': 'tex'}

Plug 'lervag/vimtex'
let g:tex_flavor='latex'
let g:vimtex_view_method='skim'
let g:vimtex_quickfix_mode=0
set conceallevel=1
let g:tex_conceal='abdmg'
let g:vimtex_compiler_latexmk = { 
        \ 'build_dir' : 'build',
    \ 'executable' : 'latexmk',
        \ 'options' : [ 
        \   '-xelatex',
        \   '-file-line-error',
        \   '-synctex=1',
        \   '-interaction=nonstopmode',
        \ ],
        \}

call plug#end()

colorscheme nord

setlocal spell 
set spelllang=en_us
inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u
3
  • 1
    It's hard to tell what's happening, can you describe exactly where your snippet files are located, give an example of a simple snippet you're trying to use, how you're triggering it? Are you sure the file type is set correctly for the current buffer? (Check :set ft? to confirm.) Also note that you should use ~/.vimrc and not ~/.gvimrc for all these settings! The gvimrc file is mainly for settings that only affect the GUI, such as which font to use, etc. They're loaded at different times, so this might matter.
    – filbranden
    Dec 19, 2020 at 16:53
  • Also not sure that the g:UltiSnipsSnippetDirectories setting is correct... Why do you feel you need to override that? Try dropping it to see if it helps.
    – filbranden
    Dec 19, 2020 at 16:54
  • 1
    @filbranden Actually the problem was me using ~/.gvimrc instead of ~/.vimrc. I didn't know that gvimrc is mainly for GUI and thought that it will affect MacVim in a similar manner as vimrc does. Rest everything is fine, no problem with file type or the directories. Can you please put this as an answer so that I can accept it? Thanks.
    – Nitin
    Dec 19, 2020 at 17:18

1 Answer 1

2

You need to use the vimrc file (~/.vimrc or ~/.vim/vimrc on MacOS, Linux/Unix) to configure most of initialization, in particular plug-ins.

The gvimrc file is mostly reserved for additional settings that are only to be used to configure GUI-specific settings, such as which font to use in GUI versions of Vim such as MacVim.

See :help initialization, which lists the sequence in which steps are executed. In particular:

  1. Execute Ex commands, from environment variables and/or files.

A file that contains initialization commands is called a vimrc file.

  1. Load the plugin scripts.

...

  1. Perform GUI initialization.

Only when starting gvim, the GUI initializations will be done. See gui-init.

As you can see, GUI initialization happens too late for plug-in configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.