From f19448c2fb5971fd532092daf9e8baaf5a391e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Deuchnord?= Date: Thu, 25 Apr 2019 13:40:07 +0200 Subject: [PATCH] Add COC --- Makefile | 3 +++ README.md | 10 +++++----- scripts/activate-coc | 46 ++++++++++++++++++++++++++++++++++++++++++++ vimrc | 3 +++ 4 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 scripts/activate-coc diff --git a/Makefile b/Makefile index 02ba31c..8ee9b91 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,5 @@ install: bash scripts/install + +coc: + bash scripts/activate-coc diff --git a/README.md b/README.md index 920892c..c627477 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ Note: if a configuration already exists, it will be backed up. ## Installed plugins -The following plugins are installed with [Vundle](https://github.com/VundleVim/Vundle.vim): - -| Plugin | Description | -| ------ | ----------- | -| [w0rp/ale](https://github.com/w0rp/ale) | Asynchronous linting/fixing for Vim and Language Server Protocol (LSP) integration +The following plugins are installed with [Vundle](https://github.com/VundleVim/Vundle.vim). +| Plugin | Description | Activation +| ------ | ----------- | ---------- +| [w0rp/ale](https://github.com/w0rp/ale) | Asynchronous linting/fixing for Vim and Language Server Protocol (LSP) integration | _Immediate_ +| [neoclide/coc.vim](https://github.com/neoclide/coc.nvim) | Intellisense engine for Vim 8 & neovim | `make coc` diff --git a/scripts/activate-coc b/scripts/activate-coc new file mode 100644 index 0000000..c40597f --- /dev/null +++ b/scripts/activate-coc @@ -0,0 +1,46 @@ +#!/bin/bash + +missingCommands="" + +nodeVersion=$(node --version 2>&1 | cut -d. -f1 | sed 's/v//') + +if [ $? != 0 ]; then + missingCommands="- node >= 8.0" +fi + +vimVersion=$(vim --version | head -n 1 | sed -E 's/VIM - Vi IMproved ([^ ]+).+/\1/') +vimMajorVersion=$(echo $vimVersion | cut -d. -f1) +vimMinorVersion=$(echo $vimVersion | cut -d. -f2) + +if [ "$missingCommands" != "" ]; then + echo -e "You have to install the following commands before installing this extension:\n$missingCommands" + exit 1 +fi + +stop=0 + +if [ "$nodeVersion" -lt "8" ]; then + echo "This plugin requires NodeJS >= 8.0 (detected version $nodeVersion)." + stop=1 +fi + +if [ "$vimMajorVersion" -lt "8" -o "$vimMajorVersion" -ge "8" -a "$vimMinorVersion" -lt "1" ]; then + echo "This plugin requires VIM >= 8.1 (detected version $vimVersion)." + stop=1 +fi + +if [ "$stop" -eq "1" ]; then + exit 1; +fi + +echo "Activating COC..." +cat ~/.vimrc | sed "s/\" Plugin 'neoclide\/coc.nvim'/Plugin 'neoclide\/coc.nvim'/" > ~/.vimrc.tmp +rm ~/.vimrc +mv ~/.vimrc.tmp ~/.vimrc +vim +PluginInstall +qall +vim "+call coc#util#install()" +qall + +echo "COC is now ready for use!" +echo "If you like this plugin, don't forget to send your ♥ to its author: https://github.com/neoclide/coc.nvim" +echo "You can add support for your favourite languages by adding them: https://github.com/neoclide/coc.nvim/wiki/Language-servers#example-configuration-for-custom-language-servers" + diff --git a/vimrc b/vimrc index 13a74d0..8ac5bb1 100644 --- a/vimrc +++ b/vimrc @@ -25,5 +25,8 @@ Plugin 'VundleVim/Vundle.vim' " integration - https://github.com/w0rp/ale Plugin 'w0rp/ale' +" IntelliSense for Vim +" Plugin 'neoclide/coc.nvim' + call vundle#end()