Linux下配置vim配置python轻量级IDE

前言

个人建议 不是每个帖子都适合你,如果没有你想要的赶紧跳过一个前辈的帖子其实还是有坑,由于时间的原因软件不断更新之类的远缘故所以坑就自然而然的出现了也不是每个人的环境都一样,Enjoy bro

https://www.jianshu.com/p/f0513d18742a

这个是vim插件官网
https://vimawesome.com/plugin/coc-nvim

编译安装最新版vim

Tips:centos
yum remove vim vi -y
git clone https://github.com/vim/vim.git
cd vim
./configure --with-features=huge --enable-python3interp --enable-pythoninterp --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu/ --enable-rubyinterp --enable-luainterp --with-python3-config-dir=config-3.6m-x86_64-linux-gnu --enable-multibyte --enable-cscope && make && make install

安装插件

Tips:

  1. 谨慎安装YouCompleteMe 太多坑了
  2. 其他的python辅助插件
  3. python-mode:
    优点:能够自动补全,自带python语法检测和代码折叠等功能,很强大。
    缺点:自动补全时顺带显示函数的帮助信息,页面显示不够简洁、美观;语法检测功能一般。
    强大的代码自动完成和代码检查
    检查(simultaneously)
    :PymodeLint
    自动修复(Autofix PEP8 errors)
    :PymodeLintAuto
  4. jedi-vim:
    优点:加载速度挺快,页面简洁。
    缺点:没有语法检测,能没YCM强大。

配置个vim主题

安装下载插件的助手如似pip
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

  1. 在~/.vimrc 配置这两个参数

    syntax enable
    colorscheme monokai

  2. 并把主题get clone下来
    mkdir ~/.vim/colors
    wget -O ~/.vim/colors/monokai.vim https://raw.githubusercontent.com/sickill/vim-monokai/master/colors/monokai.vim

.vimrc配置文件

"去掉vi的一致性"
set nocompatible
"显示行号"
set number
" 隐藏滚动条"    
set guioptions-=r 
set guioptions-=L
set guioptions-=b
"隐藏顶部标签栏"
set showtabline=0
"设置字体"
set guifont=Monaco:h13         
syntax on   "开启语法高亮"
let g:solarized_termcolors=256  "solarized主题设置在终端下的设置"
set background=dark     "设置背景色"
colorscheme monokai
set nowrap  "设置不折行"
set fileformat=unix "设置以unix的格式保存文件"
set cindent     "设置C样式的缩进格式"
set tabstop=4   "设置table长度"
set shiftwidth=4        "同上"
set showmatch   "显示匹配的括号"
set scrolloff=5     "距离顶部和底部5行"
set laststatus=2    "命令行为两行"
set fenc=utf-8      "文件编码"
set backspace=2
set mouse=a     "启用鼠标"
set selection=exclusive
set selectmode=mouse,key
set matchtime=5
set ignorecase      "忽略大小写"
set incsearch
set hlsearch        "高亮搜索项"
set noexpandtab     "不允许扩展table"
set whichwrap+=<,>,h,l
set autoread
set cursorline      "突出显示当前行"
set cursorcolumn        "突出显示当前列"

"按F5运行python"
map <F5> :Autopep8<CR> :w<CR> :call RunPython()<CR>
function RunPython()
    let mp = &makeprg
    let ef = &errorformat
    let exeFile = expand("%:t")
    setlocal makeprg=python\ -u
    set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
    silent make %
    copen
    let &makeprg = mp
    let &errorformat = ef
endfunction

"F2开启和关闭树"
map <F2> :NERDTreeToggle<CR>
let NERDTreeChDirMode=1
"显示书签"
let NERDTreeShowBookmarks=1
"设置忽略文件类型"
let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
"窗口大小"
let NERDTreeWinSize=25

"缩进指示线"
let g:indentLine_char='┆'
let g:indentLine_enabled = 1

"autopep8设置"
let g:autopep8_disable_show_diff=1

filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'neoclide/coc.nvim'
Plugin 'VundleVim/Vundle.vim'
Plugin 'Lokaltog/vim-powerline'
Plugin 'scrooloose/nerdtree'
Plugin 'Yggdroot/indentLine'
Plugin 'jiangmiao/auto-pairs'
Plugin 'tell-k/vim-autopep8'
Plugin 'scrooloose/nerdcommenter'

call vundle#end()
filetype plugin indent on  

YCM(YouCompleteMe)插件编译安装

Tips: 经过两天的奋战试过了各种办法各种帖子最终以单独编译的形式告终安装完毕!!!以下是方法:

  1. 下载YouComplateMe源码 等待编译
    git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe
  2. 下载YouComplateMe可能需要的安装环境
    cd ~/.vim/bundle/YouCompleteMe
    git submodule update --init --recursive
  3. 编译YCM(YouComplateMe)
    ./install.py --clang-completer

期间如果出现编译问题可以看看这个链接(其实我也没看过,我没出错)
https://www.cnblogs.com/dakewei/p/10491373.html

coc.nvim插件(亲测没毛病!!!)

安装coc.nvim时 报[coc.nvim] javascript file not found 错误的解决方案
错误提示:
[coc.nvim] javascript file not found, please compile the code or use release >branch.
Press ENTER or type command to continue

解决方案:
Tips: 解决问题可以根据自己的插件管理器进行设置,文章开头已写明官方地址,不会可留言帮你看看。

  1. 进入coc.nvim目录
    cd ~/.vim/plugged/coc.nvim/
  2. 执行install.sh
    ./install.sh
  3. 进入vim执行命令
    :PlugInstall

发现没有python补全怎么办:

  1. pip install pylint jedi #这是python2的
  2. pip3 install pylint jedi #这是python3的
  3. 最后!!!
    :CocInstall coc-python
发布了39 篇原创文章 · 获赞 13 · 访问量 3350

猜你喜欢

转载自blog.csdn.net/qq_30036471/article/details/102833622