Last active
March 30, 2019 02:47
-
-
Save OwenChia/ddb39b60fa2709881ff79913a9f05508 to your computer and use it in GitHub Desktop.
Install neovim fro Tencent Cloud Studio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# vim: set nu rnu fdm=indent ts=2 sts=2 shiftwidth=2 sr nowrap : | |
TODAY=$(date +%Y%m%d) | |
echo "Running on $(sed -nE '/PRETTY_NAME/{s/PRETTY_NAME="([^"]+)"/\1/p}' /etc/os-release)..." | |
cat <<EOF | |
Written for Cloud Studio: <https://studio.dev.tencent.com> | |
This script $(tput bold)ONLY$(tput sgr0) tested for Ubuntu 16.04. | |
>>> Waiting 5 seconds before starting... | |
>>> (Control-C to abort)... | |
EOF | |
_count_done=5 | |
echo -n ">>> Starting in: " | |
while test $_count_done -gt 0; do | |
echo -n "$_count_done"... | |
sleep 1 | |
_count_done=$((_count_done - 1)) | |
done | |
echo | |
echo "\n[+] Install Python3.7..." | |
if test ! -x /usr/bin/python3.7; then | |
sudo add-apt-repository ppa:deadsnakes/ppa | |
sudo apt-get update | |
sudo apt install python3.7 python3.7-venv | |
fi | |
if ! python3.7 -m pip > /dev/null 2>&1; then | |
python3.7 -m ensurepip --user | |
python3.7 -m pip install --user --upgrade pip | |
fi | |
echo "\n[+] Install ag ctags global unar..." | |
sudo apt install silversearcher-ag exuberant-ctags global unar | |
echo "\n[+] Install neovim..." | |
NEOVIM_PKG=nvim-linux64_${TODAY}.tar.gz | |
NEOVIM_DLOAD="https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz" | |
if test ! -x /usr/local/bin/nvim; then | |
if test ! -e ${NEOVIM_PKG}; then | |
if test ! -x /usr/bin/wget; then | |
sudo apt install wget | |
fi | |
wget ${NEOVIM_DLOAD} -O ${NEOVIM_PKG} | |
fi | |
sudo tar -axvf ${NEOVIM_PKG} --strip-components 1 -C /usr/local/ | |
fi | |
python3.7 -m pip install --user --upgrade pynvim | |
echo "\n[+] Install neovim plugins..." | |
PLUGIN_DIR=~/.cache/dein | |
INSTALL_DIR="${PLUGIN_DIR}/repos/github.com/Shougo/dein.vim" | |
if test ! -d ${INSTALL_DIR}; then | |
mkdir -p ${PLUGIN_DIR} | |
git clone https://github.com/Shougo/dein.vim ${INSTALL_DIR} | |
fi | |
if test ! -d ${HOME}/.config/nvim/; then | |
mkdir -p ${HOME}/.config/nvim/ | |
fi | |
cat > ${HOME}/.config/nvim/init.vim <<\EOF | |
" -*- coding: utf8 -*- | |
" | |
" Owen Chia <aptx945@gmail.com> | |
" Sat Jul 7 15:07:41 CST 2018 | |
" | |
" $ PLUGIN_DIR=~/.cache/dein | |
" $ INSTALL_DIR="${PLUGIN_DIR}/repos/github.com/Shougo/dein.vim" | |
" $ mkdir -p ${PLUGIN_DIR} | |
" $ git clone https://github.com/Shougo/dein.vim ${INSTALL_DIR} | |
if has('nvim') | |
" Add the default vim runtime path | |
set runtimepath+=/usr/share/vim/vimfiles/ | |
endif | |
" Dein {{{ | |
" Add the dein installation directory into runtimepath | |
" Required: | |
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/dein.vim | |
" Required: | |
if dein#load_state('~/.cache/dein') | |
call dein#begin('~/.cache/dein') | |
" Let dein manage dein | |
" Required: | |
call dein#add('~/.cache/dein') | |
" Plugins {{{ | |
call dein#add('Shougo/deoplete.nvim') | |
if !has('nvim') | |
call dein#add('roxma/nvim-yarp') | |
call dein#add('roxma/vim-hug-neovim-rpc') | |
endif | |
call dein#add('Shougo/deol.nvim') | |
call dein#add('Shougo/denite.nvim') | |
call dein#add('Shougo/neosnippet.vim') | |
call dein#add('Shougo/neosnippet-snippets') | |
call dein#add('Shougo/context_filetype.vim') | |
call dein#add('Shougo/echodoc.vim') | |
call dein#add('w0rp/ale') | |
call dein#add('sheerun/vim-polyglot') | |
call dein#add('Shougo/neco-syntax') | |
call dein#add('Shougo/neco-vim') | |
call dein#add('zchee/deoplete-zsh') | |
call dein#add('Shougo/deoplete-clangx') | |
call dein#add('Shougo/neoinclude.vim') | |
call dein#add('jsfaint/gen_tags.vim') | |
call dein#add('davidhalter/jedi-vim', | |
\{'on_ft': 'python'}) | |
call dein#add('zchee/deoplete-jedi', | |
\{'on_ft': 'python'}) | |
call dein#add('clojure-vim/async-clj-omni') | |
call dein#add('tpope/vim-salve') | |
call dein#add('tpope/vim-fireplace') | |
call dein#add('rust-lang/rust.vim') | |
call dein#add('fatih/vim-go') | |
call dein#add('wlangstroth/vim-racket') | |
call dein#add('pangloss/vim-javascript') | |
call dein#add('mxw/vim-jsx') | |
call dein#add('HerringtonDarkholme/yats.vim') | |
call dein#add('bling/vim-airline') | |
call dein#add('ap/vim-css-color') | |
call dein#add('luochen1990/rainbow') | |
call dein#add('gregsexton/MatchTag') | |
call dein#add('Yggdroot/indentLine') | |
call dein#add('airblade/vim-gitgutter') | |
call dein#add('tpope/vim-fugitive') | |
call dein#add('jiangmiao/auto-pairs') | |
call dein#add('majutsushi/tagbar') | |
call dein#add('Shougo/defx.nvim') | |
call dein#add('godlygeek/tabular') | |
call dein#add('kovisoft/slimv') | |
call dein#add('scrooloose/nerdcommenter') | |
call dein#add('tpope/vim-surround') | |
call dein#add('vim-scripts/DrawIt') | |
" }}} | |
" Required: | |
call dein#end() | |
call dein#save_state() | |
endif | |
" Required: | |
filetype plugin indent on | |
syntax enable | |
" install not installed plugins on startup | |
if dein#check_install() | |
call dein#install() | |
endif | |
" }}} | |
" Workaround {{{ | |
" for python_single_target_python3_7 | |
let g:python3_host_prog = '/usr/bin/python3.7' | |
" tex_conceal is annoying | |
let g:tex_conceal = "" | |
" can not use ctrl-w in browser | |
nnoremap <leader>w <c-w> | |
set mouse=a | |
" }}} | |
" Common Setting {{{ | |
set termguicolors " Using 24-bit color, Requires a ISO-8613-3 compatible terminal. | |
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids | |
set number | |
set relativenumber | |
set cursorline " Highlight current line | |
set showmode " display mode INSERT/REPLACE/... | |
set linespace=0 " No extra spaces between rows | |
set showmatch " Show matching brackets/parenthesis | |
set winminheight=0 " Windows can be 0 line high | |
set ignorecase " Case insensitive search | |
set smartcase " Case sensitive when uc present | |
set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all | |
set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too | |
set scrolljump=5 " Lines to scroll when cursor leaves screen | |
set foldmethod=marker | |
set list | |
set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace | |
" Status Line {{{ | |
set statusline=%<%f\ " Filename | |
set statusline+=%w%h%m%r " Options | |
set statusline+=%{fugitive#statusline()} " Git Hotness | |
set statusline+=\ [%{&ff}/%Y] " Filetype | |
set statusline+=\ [%{getcwd()}] " Current directory | |
set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info | |
" }}} | |
" Necessary to show Unicode glyphs {{{ | |
set encoding=utf-8 | |
set fileencoding=utf-8 | |
set fileencodings=ucs-bom,utf-8,cp936 | |
" }}} | |
set shiftwidth=2 " Use indents of 2 spaces | |
set tabstop=2 " An indentation every two columns | |
set softtabstop=2 " Let backspace delete indent | |
set shiftround " Round indent to nearest shiftwidth multiple | |
set expandtab " Tabs are spaces, not tabs | |
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J) | |
set smartindent | |
" Persistent undo {{{ | |
set undofile | |
set undolevels=1000 | |
set undoreload=10000 | |
" }}} | |
highlight clear SignColumn " SignColumn should match background | |
highlight clear LineNr " Current line number row will have same background color in relative mode | |
set background=light | |
" When editing a file, always jump to the last cursor position | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line ("'\"") <= line("$") | | |
\ exe "normal g'\"" | | |
\ endif | | |
" }}} | |
" Plugins Setting {{{ | |
" Deoplete {{{ | |
" Use deoplete | |
let g:deoplete#enable_at_startup = 1 | |
" Use smartcase. | |
call deoplete#custom#option('smart_case', v:true) | |
" <TAB>: completion. | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ deoplete#manual_complete() | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~ '\s' | |
endfunction | |
" <S-TAB>: completion back. | |
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
inoremap <expr><C-g> deoplete#refresh() | |
inoremap <expr><C-e> deoplete#cancel_popup() | |
inoremap <silent><expr><C-l> deoplete#complete_common_string() | |
" <CR>: close popup and save indent. | |
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR> | |
function! s:my_cr_function() abort | |
return pumvisible() ? deoplete#close_popup() : "\<CR>" | |
endfunction | |
" }}} | |
" neosnippet {{{ | |
let g:neosnippet#enable_completed_snippet = 1 | |
" Plugin key-mappings. | |
" Note: It must be "imap" and "smap". It uses <Plug> mappings. | |
imap <C-k> <Plug>(neosnippet_expand_or_jump) | |
smap <C-k> <Plug>(neosnippet_expand_or_jump) | |
xmap <C-k> <Plug>(neosnippet_expand_target) | |
" SuperTab like snippets behavior. | |
" Note: It must be "imap" and "smap". It uses <Plug> mappings. | |
imap <expr><TAB> | |
\ pumvisible() ? "\<C-n>" : | |
\ neosnippet#expandable_or_jumpable() ? | |
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>" | |
smap <expr><TAB> neosnippet#expandable_or_jumpable() ? | |
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>" | |
" For conceal markers. | |
if has('conceal') | |
set conceallevel=2 concealcursor=niv | |
endif | |
" Tell Neosnippet about the other snippets | |
let g:neosnippet#snippets_directory='~/.config/nvim/snippets' | |
" }}} | |
" jedi-vim {{{ | |
let g:jedi#use_tabs_not_buffers = 1 | |
" }}} | |
" Deoplete Jedi {{{ | |
let g:deoplete#sources#jedi#show_docstring = 1 | |
" }}} | |
" async-clj-omni {{{ | |
let g:deoplete#keyword_patterns = {} | |
let g:deoplete#keyword_patterns.clojure = '[\w!$%&*+/:<=>?@\^_~\-\.#]*' | |
" }}} | |
" rainbow {{{ | |
let g:rainbow_active = 1 | |
let g:rainbow_conf = { | |
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'], | |
\ 'ctermfgs': ['blue', 'yellow', 'cyan', 'magenta'], | |
\ 'operators': '_,_', | |
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'], | |
\ 'separately': { | |
\ '*': {}, | |
\ 'tex': { | |
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'], | |
\ }, | |
\ 'lisp': { | |
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'], | |
\ }, | |
\ 'vim': { | |
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'], | |
\ }, | |
\ 'html': { | |
\ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'], | |
\ }, | |
\ 'css': 0, | |
\ } | |
\ } | |
" }}} | |
" ale {{{ | |
let g:ale_completion_enabled = 1 | |
" }}} | |
" airline {{{ | |
if !exists('g:airline_symbols') | |
let g:airline_symbols = {} | |
endif | |
" unicode symbols | |
let g:airline_left_sep = '»' | |
let g:airline_right_sep = '«' | |
let g:airline_symbols.crypt = '🔒' | |
let g:airline_symbols.linenr = '☰' | |
let g:airline_symbols.linenr = '␊' | |
let g:airline_symbols.maxlinenr = '㏑' | |
let g:airline_symbols.branch = '⎇' | |
let g:airline_symbols.paste = 'ρ' | |
let g:airline_symbols.spell = 'Ꞩ' | |
let g:airline_symbols.notexists = 'Ɇ' | |
let g:airline_symbols.whitespace = 'Ξ' | |
"let g:airline_theme = 'murmur' | |
let g:airline#extensions#ale#enabled = 1 | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline#extensions#tabline#buffer_min_count = 2 | |
let g:airline#extensions#tabline#buffer_nr_show = 1 | |
nmap <leader>1 <Plug>AirlineSelectTab1 | |
nmap <leader>2 <Plug>AirlineSelectTab2 | |
nmap <leader>3 <Plug>AirlineSelectTab3 | |
nmap <leader>4 <Plug>AirlineSelectTab4 | |
nmap <leader>5 <Plug>AirlineSelectTab5 | |
nmap <leader>6 <Plug>AirlineSelectTab6 | |
nmap <leader>7 <Plug>AirlineSelectTab7 | |
nmap <leader>8 <Plug>AirlineSelectTab8 | |
nmap <leader>9 <Plug>AirlineSelectTab9 | |
" for key -/+ without Shift | |
nmap <leader>- <Plug>AirlineSelectPrevTab | |
nmap <leader>= <Plug>AirlineSelectNextTab | |
" }}} | |
" tagbar {{{ | |
nnoremap <silent> <leader>tt :TagbarToggle<CR> | |
let g:tagbar_type_make = { | |
\ 'kinds': [ | |
\ 'm:macros', | |
\ 't:targets' | |
\ ] | |
\} | |
let g:tagbar_type_haskell = { | |
\ 'ctagsbin' : 'hasktags', | |
\ 'ctagsargs' : '-x -c -o-', | |
\ 'kinds' : [ | |
\ 'm:modules:0:1', | |
\ 'd:data: 0:1', | |
\ 'd_gadt: data gadt:0:1', | |
\ 't:type names:0:1', | |
\ 'nt:new types:0:1', | |
\ 'c:classes:0:1', | |
\ 'cons:constructors:1:1', | |
\ 'c_gadt:constructor gadt:1:1', | |
\ 'c_a:constructor accessors:1:1', | |
\ 'ft:function types:1:1', | |
\ 'fi:function implementations:0:1', | |
\ 'o:others:0:1' | |
\ ], | |
\ 'sro' : '.', | |
\ 'kind2scope' : { | |
\ 'm' : 'module', | |
\ 'c' : 'class', | |
\ 'd' : 'data', | |
\ 't' : 'type' | |
\ }, | |
\ 'scope2kind' : { | |
\ 'module' : 'm', | |
\ 'class' : 'c', | |
\ 'data' : 'd', | |
\ 'type' : 't' | |
\ } | |
\ } | |
let g:tagbar_type_rust = { | |
\ 'ctagstype' : 'rust', | |
\ 'kinds' : [ | |
\'T:types,type definitions', | |
\'f:functions,function definitions', | |
\'g:enum,enumeration names', | |
\'s:structure names', | |
\'m:modules,module names', | |
\'c:consts,static constants', | |
\'t:traits', | |
\'i:impls,trait implementations', | |
\] | |
\} | |
" }}} | |
" echodoc {{{ | |
set noshowmode | |
let g:echodoc#enable_at_startup = 1 | |
" }}} | |
" }}} | |
" FileType-specific Setting {{{ | |
" Python {{{ | |
augroup language_python | |
autocmd! | |
autocmd BufNewFile *.py exec ":call NewPythonFile()" | |
function! NewPythonFile() | |
call setline(1, "# -*- coding: utf-8 -*-") | |
call setline(2, "") | |
call cursor(2, 1) | |
endfunc | |
augroup END | |
" }}} | |
" Perl {{{ | |
augroup language_perl | |
autocmd! | |
autocmd BufNewFile *.pl exec ":call NewPerlFile()" | |
function! NewPerlFile() | |
call setline(1, "#!/usr/bin/env perl") | |
call setline(2, "") | |
call setline(3, "use strict;") | |
call setline(4, "use warnings;") | |
call setline(5, "use autodie;") | |
call setline(6, "") | |
call setline(7, "") | |
call cursor(7, 1) | |
endfunc | |
augroup END | |
" }}} | |
" C {{{ | |
augroup language_c | |
autocmd! | |
autocmd BufNewFile *.c exec ":call NewCSourceFile()" | |
function! NewCSourceFile() | |
call setline(1, "#include <stdbool.h>") | |
call setline(2, "#include <stddef.h>") | |
call setline(3, "#include <stdint.h>") | |
call setline(4, "#include <stdio.h>") | |
call setline(5, "#include <stdlib.h>") | |
call setline(6, "") | |
call setline(7, "") | |
call setline(8, "int main(int argc, char const* argv[])") | |
call setline(9, "{") | |
call setline(10, "\t") | |
call setline(11, "\treturn EXIT_SUCCESS;") | |
call setline(12, "}") | |
call cursor(10, 2) | |
endfunc | |
augroup END | |
" }}} | |
" }}} | |
" vim: set number relativenumber foldmethod=marker noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 shiftround nowrap : | |
EOF | |
nvim +UpdateRemotePlugins +qa | |
cat <<EOF | |
[+] Done | |
$(tput bold)Use default Light Theme with Stylus$(tput sgr0) | |
$(tput bold)Stylus CSS$(tput sgr0) | |
=========== | |
https://studio.qcloud.coding.net/ws | |
#PANEL_BOTTOM div.xterm-screen > div.xterm-rows { | |
font-family: "PT Mono" !important; | |
background-color: #FDF6E3; | |
} | |
$(tput bold)Workaround for ag$(tput sgr0) | |
================= | |
/usr/local/bin/ag | |
#!/bin/sh | |
/usr/bin/ag --noaffinity "\$@" | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment