基于命令行的python开发IDE搭建

安装脚本

在命令行中运行脚本,不需要加sudo,脚本中需要管理员权限的命令都自带sudo了。

#!/bin/bash
set -ex

# install the tools
if [ !	$(which sudo) ]; then
	apt-get update
	apt-get install -y sudo
else
	sudo apt-get update
fi
sudo apt-get install -y vim vim-scripts vim-doc # vim
sudo apt-get install -y git wget # tools
sudo apt-get install -y python3 python3-pip python3-dev python3-setuptools # python

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 150
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 150
sudo pip install --upgrade pip

# create vim plugin directory
mkdir -p ~/.vim/bundle && cd ~/.vim/bundle

# use vim plugin manager - vundle
if [ ! -d Vundle.vim ]; then git clone https://github.com/VundleVim/Vundle.vim.git; fi

# get code completion plugin - YouCompleteMe
sudo apt-get install -y gcc make build-essential cmake
if [ ! -d YouCompleteMe ]; then git clone https://github.com/Valloric/YouCompleteMe.git; fi
cd YouCompleteMe
git submodule update --init --recursive 
./install.py --clang-completer
cd ..

# get and install ctags
wget http://prdownloads.sourceforge.net/ctags/ctags-5.8.tar.gz
tar -xf ctags-5.8.tar.gz
cd ctags-5.8 
./configure
sudo make install
cd .. && rm -fr ctags*

# get file system explorer plugin - nerdtree
if [ ! -d nerdtree ]; then git clone https://github.com/scrooloose/nerdtree.git; fi

# get Eclipse like task list plugin - tasklist or tagbar
if [ ! -d TaskList.vim ]; then git clone https://github.com/vim-scripts/TaskList.vim.git; fi
if [ ! -d tagbar ]; then git clone https://github.com/majutsushi/tagbar.git; fi


# get  syntax checking plugin - syntastic
if [ ! -d syntastic ]; then git clone https://github.com/vim-syntastic/syntastic.git; fi

# get Elegant buffer explorer plugin - minibufexpl
if [ ! -d minibufexpl.vim ]; then git clone https://github.com/vim-scripts/minibufexpl.vim.git; fi

# get code formatting manager plugin - vim-autoformat
if [ ! -d vim-autoformat ]; then git clone https://github.com/Chiel92/vim-autoformat.git; fi
sudo pip install yapf # python
sudo apt-get install -y tidy # html,xhtml,xml

# get full path fuzzy finder plugin - grep.vim and LeaderF
if [ ! -d grep ]; then git clone https://github.com/yegappan/grep.git; fi # find string in files
if [ ! -d LeaderF ]; then git clone https://github.com/Yggdroot/LeaderF.git; fi # find file in directory
cd LeaderF
./install.sh
cd ..

# get statusline plugin - vim-airline
if [ ! -d vim-airline ]; then git clone https://github.com/vim-airline/vim-airline.git; fi

# get windows manager plugin - winmanager
if [ ! -d winmanager--Fox ]; then git clone https://github.com/vim-scripts/winmanager--Fox.git; fi

# get interactive terminal plugin - vim-terminal
if [ ! -d vim-terminal ]; then git clone https://github.com/tc50cal/vim-terminal.git; fi

# install pudb debugger
sudo pip install pudb

配置文件 .vimrc

F2:打开文件目录窗口
F3:打开函数变量窗口
;+t:打开tasklist窗口
;+f:打开文件搜索窗口(只搜文件)
:Grep “xxxx”:打开字符串搜索窗口
文件保存的时候,会自动格式化,并检查语法错误(只有python)
输入的时候,会自动补全

"==========================================
" General Settings
"==========================================
" 设置前缀键
let mapleader=';'

" 开启语法高亮  
syntax enable  

" 开启语法高亮
syntax on  

" 针对不同的文件,采用不同的缩进方式  
filetype indent on  

" 允许插件  
filetype plugin on  

" 启动自动补全
filetype plugin indent on

" 文件修改之后自动读入
set autoread

" 设置取消备份,禁止临时文件生成  
"set nobackup  
"set noswapfile  

" 设置在Vim中可以使用鼠标,防止终端无法拷贝  
set mouse=a  

" for regular expression turn magic on
set magic

" 当你 :set nohidden 时,Vim 会在切换 Buffer 的时候检测当前 Buffer 是否保存,
" 如果还未保存,则会以打开一个新 Window 的形式打开另一个 Buffer。
set hidden

"==========================================
" Display Settings
"==========================================
"
" 显示当前行号和列号
set ruler

" 在状态栏显示正在输入的命令
set showcmd

" 左下角显示当前Vim模式
set showmode

" 显示行号  
set number  

" 指定不折行
set nowrap  

" 设置代码匹配,包括括号匹配情况  
set showmatch  

" 开启及时搜索(is)  
set incsearch  

" 设置搜索高亮(hlsearch)  
set hls  

" 设置搜索时忽略大小写  
set ignorecase  

" 当搜索的时候尝试smart  
set smartcase  

" 设置C/C++方式自动对齐  
set autoindent  
set cindent  
set smartindent  

" 设置tab宽度  
set tabstop=4  

" 设置自动对齐空格数  
set shiftwidth=4  

" 按退格键时可以一次删除4个空格
"set softtabstop=4

 " 编辑的时候将所有的tab设置为空格(expandtab)  
 set et  

 " 使用Backspace直接删除tab  
 set smarttab  

 "==========================================
 " FileEncode Settings
 "==========================================

 " 设置编码方式  
 set encoding=utf-8  

 " 设置打开文件的编码格式  
 set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1  

 set helplang=cn 

 " 只对终端影响(默认)
 set termencoding=utf-8

 " use UNIX as the standard file type
 set ffs=unix,dos,mac

" 如遇Unicode值大于255的文本,不必等到空格再折行。
set formatoptions+=m

" 合并两行中文时,不在中间加空格:
set formatoptions+=B

"==========================================
" Vundle设置
"==========================================
set nocompatible              " 去除VI一致性,必须要添加
filetype off                  " 必须要添加

" 设置包括vundle和初始化相关的runtime path
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" 让vundle管理插件版本,必须
Plugin 'VundleVim/Vundle.vim'

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plugin 'https://github.com/Valloric/YouCompleteMe.git'
autocmd InsertLeave * if pumvisible() == 0|pclose|endif "离开插入模式后自动关闭预览窗口"
let g:ycm_collect_identifiers_from_tags_files = 1           " 开启 YCM基于标签引擎
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释与字符串中的内容也用于补全
let g:syntastic_ignore_files=[".*\.py$"]
let g:ycm_seed_identifiers_with_syntax = 1                  " 语法关键字补全
let g:ycm_complete_in_comments = 1			    " 在注释输入中也能补全
let g:ycm_complete_in_strings = 1                           " 在字符串输入中也能补全
let g:ycm_key_list_select_completion = ['<c-n>', '<Down>']  " 映射按键,没有这个会拦截掉tab, 导致其他插件的tab不能用
let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>']
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"             " 回车即选中当前项
nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR>     " 跳转到定义处

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plugin 'https://github.com/vim-airline/vim-airline.git'

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plugin 'https://github.com/majutsushi/tagbar.git'
map <F3> :TagbarToggle<CR>
let g:tagbar_sort = 0

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plugin 'https://github.com/scrooloose/nerdtree.git'
map <F2> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"autocmd vimenter * NERDTree

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plugin 'https://github.com/vim-scripts/TaskList.vim.git'
let g:tlWindowPosition = 1

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plugin 'https://github.com/vim-scripts/minibufexpl.vim.git'

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plugin 'https://github.com/Chiel92/vim-autoformat.git'
au BufWrite * :Autoformat " code be formatted upon saving file

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plugin 'https://github.com/vim-syntastic/syntastic.git'
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plugin 'https://github.com/Yggdroot/LeaderF.git'
let g:Lf_Ctags = '/usr/local/bin/ctags'
let g:Lf_ShowHidden = 1

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plugin 'https://github.com/yegappan/grep.git'
nnoremap <silent> <F4> :Grep<CR>

" pydiction setting
"Plugin 'https://github.com/rkulla/pydiction.git'
"let g:pydiction_location = '~/.vim/bundle/pydiction/complete-dict'

"Plugin 'davidhalter/jedi-vim'
"let g:jedi#popup_on_dot = 1
"let g:jedi#popup_select_first = 0


" 你的所有插件需要在下面这行之前
call vundle#end()            " 必须
filetype plugin indent on    " 必须 加载vim自带和插件相应的语法和文件类型相关脚本


发布了25 篇原创文章 · 获赞 1 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/fleaxin/article/details/89476923