Ubuntu Server 20.04 LTS 环境下搭建vim 编辑器Python IDE的详细步骤

目录
  • 安装配置vim-plug
    • 安装vim-plug
    • 配置vim-plug
  • 安装coc.nvim插件
    • 更新vim
    • 安装node
    • 添加coc.nvim到.vimrc文件
    • 配置服务器
    • 设置TAB 代码补全
    • 设置F5一键执行代码

安装配置vim-plug

安装vim-plug

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

配置vim-plug

在家目录下创建.vimrc配置文件

在.vimrc下填写配置

vim ~/.vimrc
call plug#begin()
Plug 'neoclide/coc.nvim'
Plug 'asins/vimcdoc'
Plug 'preservim/nerdtree'
Plug 'mhinz/vim-startify'
Plug 'luochen1990/rainbow'

call plug#end()

安装coc.nvim插件

更新vim

sudo add-apt-repository ppa:jonathonf/vim

sudo apt-get update

sudo apt-get install vim

安装node

sudo apt update
sudo apt install nodejs npm
sudo curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt install nodejs

添加coc.nvim到.vimrc文件

call plug#bing()
 Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()

:PlugInstall 安装自动补全插件
:CocInfo 检查插件安装情况
:CocInstall coc-json coc-tsserver支持JSON和Typescript相关子插件

配置服务器

:CocConfig添加Python配置数据
:CocInstall coc-pyright

// be careful not to condense the hierarchy as it breaks pyls
"languageserver": {
  "python": {
    "command": "python",
    "args": [
      "-mpyls",
      "-vv",
      "--log-file",
      "/tmp/lsp_python.log"
    ],
    "trace.server": "verbose",
    "filetypes": [
      "python"
    ],
    "settings": {
      "pyls": {
        "enable": true,
        "trace": {
          "server": "verbose"
        },
        "commandPath": "",
        "configurationSources": [
          "pycodestyle"
        ],
        "plugins": {
          "jedi_completion": {
            "enabled": true
          },
          "jedi_hover": {
            "enabled": true
          },
          "jedi_references": {
            "enabled": true
          },
          "jedi_signature_help": {
            "enabled": true
          },
          "jedi_symbols": {
            "enabled": true,
            "all_scopes": true
          },
          "mccabe": {
            "enabled": true,
            "threshold": 15
          },
          "preload": {
            "enabled": true
          },
          "pycodestyle": {
            "enabled": true
          },
          "pydocstyle": {
            "enabled": false,
            "match": "(?!test_).*\\.py",
            "matchDir": "[^\\.].*"
          },
          "pyflakes": {
            "enabled": true
          },
          "rope_completion": {
            "enabled": true
          },
          "yapf": {
            "enabled": true
          }
        }
      }
    }
  }
}

设置TAB 代码补全

在.vimrc文件中添加以下代码

set nobackup
set nowritebackup
set updatetime=300
set signcolumn=yes
inoremap <silent><expr> <TAB>
      \ coc#pum#visible() ? coc#pum#next(1):
      \ CheckBackspace() ? "\<Tab>" :
      \ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"

inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
                              \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"

function! CheckBackspace() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'
endfunction

" Use <c-space> to trigger completion.
if has('nvim')
  inoremap <silent><expr> <c-space> coc#refresh()
else
  inoremap <silent><expr> <c-@> coc#refresh()
endif

" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)

" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

" Use K to show documentation in preview window.
nnoremap <silent> K :call ShowDocumentation()<CR>

function! ShowDocumentation()
  if CocAction('hasProvider', 'hover')
    call CocActionAsync('doHover')
  else
    call feedkeys('K', 'in')
  endif
endfunction

" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')

" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)

" Formatting selected code.
xmap <leader>f  <Plug>(coc-format-selected)
nmap <leader>f  <Plug>(coc-format-selected)

augroup mygroup
  autocmd!
  " Setup formatexpr specified filetype(s).
  autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  " Update signature help on jump placeholder.
  autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end

" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a  <Plug>(coc-codeaction-selected)
nmap <leader>a  <Plug>(coc-codeaction-selected)

" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac  <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf  <Plug>(coc-fix-current)

" Run the Code Lens action on the current line.
nmap <leader>cl  <Plug>(coc-codelens-action)

" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)

" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
  nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
  inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
  inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
  vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif

" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)

" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocActionAsync('format')

" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call     CocAction('fold', <f-args>)

" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR   :call     CocActionAsync('runCommand', 'editor.action.organizeImport')

" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}

" Mappings for CoCList
" Show all diagnostics.
nnoremap <silent><nowait> <space>a  :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent><nowait> <space>e  :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent><nowait> <space>c  :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent><nowait> <space>o  :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent><nowait> <space>s  :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent><nowait> <space>j  :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent><nowait> <space>k  :<C-u>CocPrev<CR>
" Resume latest coc list.
nnoremap <silent><nowait> <space>p  :<C-u>CocListResume<CR>

设置F5一键执行代码

"一键运行代码

map <F5> :call CompileRunGcc()<CR>
    func! CompileRunGcc()
        exec "w"
if &filetype == 'c'
            exec "!g++ % -o %<"
            exec "!time ./%<"
elseif &filetype == 'cpp'
            exec "!g++ % -o %<"
            exec "!time ./%<"
elseif &filetype == 'java'
            exec "!javac %"
            exec "!time java %<"
elseif &filetype == 'sh'
            :!time bash %
elseif &filetype == 'python'
            exec "!time python3 %"
elseif &filetype == 'html'
            exec "!firefox % &"
elseif &filetype == 'go'
    "        exec "!go build %<"
            exec "!time go run %"
elseif &filetype == 'mkd'
            exec "!~/.vim/markdown.pl % > %.html &"
            exec "!firefox %.html &"
endif
    endfunc

到此这篇关于Ubuntu Server 20.04 LTS 环境下搭建vim 编辑器Python IDE的文章就介绍到这了,更多相关vim 编辑器Python IDE内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • 探析Windows下将gvim8配置为Python IDE的方法

    Windows下将gvim8配置为Python IDE大概分为以下四步,每步介绍的都非常详细,一起看看吧. 1.准备工作 将下面的安装包或者文件下载好 1) Python 2.7  http://www.python.org/ftp/python/2.7.2/python-2.7.2.msi 2) gvim8.0   http://www.vim.org/download.php 3) Exuberant Ctags http://ctags.sourceforge.net/ 4) Taglis

  • 两个命令把 Vim 打造成 Python IDE的方法

    运行下面两个命令,即可把 Vim(含插件)配置成 Python IDE.目前支持 MAC 和 Ubuntu. curl -O https://raw.githubusercontent.com/vince67/v7_config/master/vim.sh bash vim.sh 截图示例 做了什么 写了个方便的bash脚本,用来配置VIM 使用的配置来自 fisa-vim-config 效果爆炸 附脚本: •注意一: 每次运行本脚本,会把旧的 ~/.vimrc 文件备份到 /tmp/vimrc

  • Ubuntu下VIM配置成C++开发编辑器

    1.复制配置文件到本用户环境下,再新建一个.vim文件夹,并创建bundle子文件夹 sudo cp /etc/vim/vimrc /home/wangy/.vimrc sudo mkdir /home/wangy/.vim sudo mkdir /home/wangy/.vim/bundle sudo mkdir /home/wangy/.vim/bundle/vundle bundle的配置文件如下: "新增的配置放在这里 set nocompatible " be iMprove

  • Linux (Ubuntu 18.04) 下安装vim编辑器的方法

    大家可以去Ubuntu官网下载桌面系统: https://ubuntu.com/download/desktop ,虽然最新版是19.04,但是建议大家下载稳定版18.04.安装过程非常简洁,我使用的是VMware Workstation Pro虚拟机,大家也可以用其他的,这个没什么影响. Ubuntu 18.04 用起来还是要比老版本要舒服很多的,毕竟做了这么久的Windows开发,突然接触linux,还是有点不习惯,但是新版的Ubuntu的一些操作习惯已经很接近Windows了,毕竟科技的发

  • Ubuntu Server 20.04 LTS 环境下搭建vim 编辑器Python IDE的详细步骤

    目录 安装配置vim-plug 安装vim-plug 配置vim-plug 安装coc.nvim插件 更新vim 安装node 添加coc.nvim到.vimrc文件 配置服务器 设置TAB 代码补全 设置F5一键执行代码 安装配置vim-plug 安装vim-plug curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug

  • 关于Ubuntu Server 18.04 LTS 安装Tomcat并配置systemctl管理Tomcat服务的问题

    目录 1.下载安装 2.配置JDK环境变量 软件环境 系统版本:Ubuntu Server 18.04.1 LTS JDK版本:Java SE Development Kit 8u231 Tomcat版本:Tomcat 9.0.27 Released 1.下载安装 由于JDK下载需要登录,用wget下载不方便,建议先在别的机子先下载好再拷贝到Ubuntu上. 将下载好的JDK压缩包解压到指定目录 tar -zxvf jdk-8u231-linux-x64.tar.gz -C ~/server 解

  • Ubuntu Server 16.04 LTS 上安装 LAMP图解教程

    LAMP 方案是一系列自由和开源软件的集合,包含了 Linux.Web 服务器 (Apache). 数据库服务器 (MySQL / MariaDB) 和 PHP (脚本语言).LAMP 是那些需要安装和构建动态网页应用的基础平台,比如WordPress.Joomla.OpenCart 和 Drupal. 在这篇文章中,我将描述如何在 Ubuntu Server 16.04 LTS 上安装 LAMP,众所周知 Ubuntu 是一个基于 Linux 的操作系统,因此它构成了 LAMP 的第一个部分,

  • Ubuntu16.04环境下搭建FTP服务器的教程

    Ubuntu16.04搭建FTP服务器 安装ftp 安装ftp: sudo apt-get update sudo apt-get install vsftpd 检查ftp是否安装: vsftpd --version 更改配置文件 注意使用sudo命令获得root权限 打开配置文件: sudo vim /etc/vsftpd.conf 做如下更改: # Example config file /etc/vsftpd.conf # # The default compiled in setting

  • 详解ubuntu 20.04 LTS安装记录

    本篇记录U盘启动盘制作及系统安装,系统配置另开文章. 所需材料: 4GB或以上U盘 Ubuntu 20.04 ISO文件(从ubuntu官网下载) 一.U盘启动盘制作 使用旧版ubuntu制作ubuntu 20.04启动盘 以下参考ubuntu官方教程 需要ubuntu 14.04或以上版本,我用的是ubuntu 16.04 在启动栏输入Startup Disk Creator,打开系统自带的启动盘制作工具 会自动检测Downloads文件夹内的iso文件和插入电脑的U盘 将U盘内文件备份好,点

  • win10+Ubuntu 20.04 LTS双系统安装(UEFI + GPT)(图文,多图预警)

    win10 安装(已安装的略过) win10安装请看:win10 u盘重装系统 全新安装 ubuntu安装准备官网下载镜像:https://ubuntu.com/download/desktop 下载rufus(官网推荐)https://rufus.ie/ 如果下载速度慢,可以用我下好的(含镜像.rufus):链接: https://pan.baidu.com/s/1qwgUFa-ME-EXLrAZ7rQJvw 提取码: v6af 制作启动u盘 插入U盘, 运行 rufus-3.10.exe,按

  • Ubuntu Server 16.04下mysql8.0安装配置图文教程

    Ubuntu Server 16.04下mysql8.0安装配置图文教程 1.从Mysql官网上下载安装文件.有两种方式可供选择: 使用APT安装方式安装 使用完整的安装包进行安装 sudo dpkg -i mysql-apt-config_0.8.6-1_all.deb 2.更新系统安装源 sudo apt-get update 3.安装Mysql服务 sudo apt-get install mysql-server 4.修改Mysql Server的字符集 要修改字符集,首先得找到Mysq

  • Ubuntu Server 18.04.5 LTS服务器版安装配置图解教程

    一.Ubuntu Server 18.04.5 LTS系统安装 Ubuntu分为桌面版(desktop)和服务器版(Server),下面为大家介绍服务器版本Ubuntu Server 18.04.5 LTS的详细安装过程. Ubuntu Server 18.04.5 LTS离线安装镜像下载地址: ubuntu 18.04 LTS Server 点击下载 ps:此链接下载的是iso镜像 http://cdimage.ubuntu.com/ubuntu/releases/18.04.5/releas

  • Ubuntu Server 14.04升级Ubuntu Server 16.04

    Ubuntu Server 14.04升级Ubuntu Server 16.04 1.终端下执行命令 $ sudo apt-get update && sudo apt-get dist-upgrade 2.重启系统以完成更新的安装 $ sudo init 6 3.用命令安装更新管理器核心update-manager-core,如果服务器已安装则可以跳过 $ sudo apt-get install update-manager-core 4.编辑/etc/update-manager/r

  • Ubuntu14.04服务器环境下配置PHP7.0+Apache2+Mysql5.7的方法

    本文实例讲述了Ubuntu14.04服务器环境下配置PHP7.0+Apache2+Mysql5.7的方法.分享给大家供大家参考,具体如下: 这里为Ubuntu14.04系统下配置PHP7.0+Apache2+Mysql5.7,主要目的是为了试玩WordPress. 更新系统资源 sudo apt-get update sudo apt-get uograde Apache2 安装apache sudo apt-get apache2 编辑apache主配置文件/etc/apache2/apach

随机推荐