[Docker]我想在像IDE这样的容器中使用neovim进行开发[外观IDE]


目标人

想要在Docker容器中使用vim开发像IDE的人

摘要

  • 将centos 6.9与Docker一起使用
  • 将Neovim放在centos 6.9中
  • 插入neovim插件NERD树
  • 由于Dockerfile位于末尾,因此,如果您了解以上三个故事并想要创建一个快速的环境,请跳至Dockerfile一章。

IDE就像在容器中开发时一样!
我将在下一篇和后续文章中介绍除外观之外的功能方面。

自己的环境

<表格>

项目

目录


<身体>

操作系统

macOS Sierra

操作系统版本

10.12.4

码头工人

Docker版本17.03.1-ce,构建c6d412e

docker pull OS

CentOS:6.9


首先,为centOS拉

1
$ docker pull centos:6.9

您现在拥有centOS 6.9的映像。
然后

1
$ docker run -it --name test centos:6.9

将启动一个名为test的容器,

1
[root@7ed0424bd284 /]#

我认为它看起来像

让我们尝试在这里用vi创建一个php文件!

1
2
3
[root@7ed0424bd284 /]# cd
[root@7ed0424bd284 ~]# mkdir qiita_php
[root@7ed0424bd284 ~]# vi test.php

test.php

1
2
3
4
5
6
7
8
9
10
11
<?php

// greetingという名前をつけた関数
function greeting($name) {
    $message = 'Hello, '. $name. '!'; // 処理

    return $message; // 結果を返す
}

$message = greeting('Tom');
echo $message; // 'Hello, Tom!'

[PHP]我从qiita文章Function中复制并粘贴了php程序。

与IDE

的外观差异

IDE(PhpStorm)

在本地Mac上使用PhpStorm创建test.php并将其打开。
スクリーンショット 2017-06-26 23.18.28.png

感觉好像左侧是文件浏览器,而下方是终端一样。
代码也是彩色的,很容易看!

vi

スクリーンショット 2017-06-26 23.24.56.png

......
不出所料,vi太忙了

neovim

将neovim放在centOS6中有点困难

1
2
3
4
5
6
7
[root@7ed0424bd284 ~]# cd /
[root@7ed0424bd284 /]# yum -y install libtool autoconf automake cmake gcc gcc-c++ make pkgconfig unzip
[root@7ed0424bd284 /]# yum -y install git
[root@7ed0424bd284 /]# git clone https://github.com/neovim/neovim
[root@7ed0424bd284 /]# cd neovim/
[root@7ed0424bd284 /]# make
[root@7ed0424bd284 /]# make install

制造时间很长。

让我们打开neovim所在的test.php!

1
[root@7ed0424bd284 /]# nvim ~/qiita_test/test.php

スクリーンショット 2017-06-26 23.49.28.png

颜色改善了很多! (很明显)

Neovim

的环境维护

首先,编辑文件init.vim,该文件与vim中的.vimrc相对应。

1
2
3
[root@7ed0424bd284 /]# mkdir -p ~/.config/nvim

[root@7ed0424bd284 /]# nvim ~/.config/nvim/init.vim

?/ .config / nvim / init.vim

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
" プラグインが実際にインストールされるディレクトリ
let s:dein_dir = expand('~/.cache/dein')
" dein.vim 本体
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'

" dein.vim がなければ github から落としてくる
if &runtimepath !~# '/dein.vim'
  if !isdirectory(s:dein_repo_dir)
    execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_dir
  endif
  execute 'set runtimepath^=' . fnamemodify(s:dein_repo_dir, ':p')
endif

" 設定開始
if dein#load_state(s:dein_dir)
  call dein#begin(s:dein_dir)

  " プラグインリストを収めた TOML ファイル
  " 予め TOML ファイル(後述)を用意しておく
  let g:rc_dir    = expand("~/.config/nvim")
  let s:toml      = g:rc_dir . '/dein.toml'
  let s:lazy_toml = g:rc_dir . '/dein_lazy.toml'
  " TOML を読み込み、キャッシュしておく
  call dein#load_toml(s:toml,      {'lazy': 0})
  call dein#load_toml(s:lazy_toml, {'lazy': 1})
  " 設定終了
  call dein#end()
  call dein#save_state()
endif

" もし、未インストールものものがあったらインストール
if dein#check_install()
  call dein#install()
endif

接下来,创建一个用于管理插件的文件dein.toml

1
[root@7ed0424bd284 /]# nvim ~/.config/nvim/dein.toml

顺便说一句,dein.vim的安装应该在此阶段开始。安装完成后,将出现文件编辑屏幕。

?/ .config / nvim / dein.toml

1
2
3
4
5
6
7
[[plugins]]
repo = 'scrooloose/nerdtree'
hook_add = '''
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
map <C-n> :NERDTreeToggle<CR>
'''

介绍一个名为NERDTree的插件。
安装此插件后,文件浏览器将出现在neovim屏幕的左侧!

hood_add之后的语句描述了这样的设置:如果在不指定文件名的情况下启动neovim,则文件浏览器将打开,而在以指定的文件名启动neovim时,文件浏览器将不会打开。
它还指出,即使未打开文件资源管理器,按Ctl n也会打开文件资源管理器。

外观游戏第2轮

进入

qiita_php文件夹并启动neovim!

1
2
[root@7ed0424bd284 /]# cd ~/qiita_php
[root@7ed0424bd284 qiita_php]# nvim

スクリーンショット 2017-06-27 0.16.46.png

文件浏览器已出现在左侧! !!
从那里,使用十字键将光标移至test.php并输入!!

スクリーンショット 2017-06-27 0.18.06.png

非常接近
剩下的就是IDE中下面的终端。

  • 当光标在test.php中时
    类型:拆分
  • 屏幕被分割,并且test.php也显示在下面的屏幕中
  • 使用Ctl-w j移至以下屏幕
  • 输入:terminal(只能使用neovim来完成)(如果您说vim Shell,也可以使用vim)
  • スクリーンショット 2017-06-27 0.21.31.png

    外观已经完全赶上了! !!

    另外,我将总结移动分割屏幕的命令。

    <表格>

    命令

    目标


    <身体>

    Ctl-w k

    上屏幕

    Ctl-w j

    下屏

    Ctl-w l

    右屏幕

    Ctl-w h

    左屏幕


    当资源管理器出现问题时,它会随Ctl n一起消失,并且在您需要时按Ctl n它将出现,因此请尝试一下。

    执行更多neovim首选项

    在我安装neovim并尝试使用dein.toml管理插件的文章中,有dein.toml带有一个名为deoplete的补充插件,因此请不要犹豫。

    Dockerfile

    从头开始写! !! !! !! 请不要说。
    我们已经在github上发布了仓库。

    1
    2
    3
    $ git clone https://github.com/ryo2851/neovim_ide.git
    $ docker build -t test neovim_ide/.
    $ docker run -it --name sample test

    制作

    neovim会花费很多时间,但是可以在由此生成的样本容器中使用nvim,并且还会安装NERDTree。

    下次,我将写一篇文章,就功能方面赶上IDE。

    参考

    我安装了neovim并尝试使用dein.toml

    进行插件管理

    [Python环境维护] De-NeoBundle。准备带有dein的超级方便的互补插件jedi-vim的环境并将其设置为舒适

    Vim注意:尝试安装Neovim