I want to use the plugin neocomplete only for a few filetypes. For example for Go programming language. So I have the following entries in my ~/.vimrc/ftplugin/go.vim:
...
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#sources#syntax#min_keyword_length = 3
...
(My plugins are managed through VimPlug which works flawless.)
Now I have one problem and one question.
Question: Is it bad practice to set global variables in an ftplugin? And why? They seem to work with the exception of the neocomplete#enable_at_startup variable.
Here it comes to the problem: neocomplete doesn't do auto-completion until I enable it manually:
:NeoCompleteEnable
I have to add the following line in my go.vim to enable it automatically at startup:
autocmd VimEnter * NeoCompleteEnable
My question and my problem seem to affect each other. Is there a better way to enable neocomplete plugin only for specific filetypes and to set also different values to the variables for each type?
Greetings
Philipp
autocmd CursorHold,InsertEnter
but only for the current buffer (as ftplugins are executed once per related buffer). Note that you may want aaugroup
name built for the current buffer, or to maintain a list of buffers for which the completions is enabled. But this later solution should be implement in the plugin, IMO.