1

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

4
  • As you've guessed, setting global variables from a ftplugin is a bad practice. According the documentation I've just read, this plugin doesn't seems to be written to work only in specified buffers. It may be best to directly contact the author if you want to activate the plugin only with specific filetypes or in specific projects. Jan 24, 2017 at 10:35
  • You could may try to duplicate in your ftplugin the lines from the plugin that register autocmd CursorHold,InsertEnter but only for the current buffer (as ftplugins are executed once per related buffer). Note that you may want a augroup 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. Jan 24, 2017 at 10:40
  • Do you know if there is an other plugin for completion which plays well with buffers?
    – phips
    Jan 24, 2017 at 16:15
  • Sorry. I don't use this type of plugin. Jan 24, 2017 at 16:34

0

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.

Browse other questions tagged or ask your own question.