8
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MSYS2のvimでも:terminalを使えるようにする

Posted at

やることは単純である

必要なツールのインストール

$ pacman -S base-devel msys2-devel
$ pacman -S python3 ruby
$ pacman -S ncurses-devel libcrypt-devel gettext-devel

luaのビルドとインストール

$ curl -R -O http://www.lua.org/ftp/lua-5.3.4.tar.gz
$ tar zxf lua-5.3.4.tar.gz
$ cd lua-5.3.4
$ make mingw
$ cp /src/lua54.dll /usr/local/bin/lua54.dll

MSYS2の開発者用リポジトリをクローン & vimをビルド

$ git clone https://github.com/Alexpux/MSYS2-packages.git
$ cd MSYS2-packages/vim
$ vim PKGBUILD

# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=vim
_topver=8.0
-_patchlevel=0606
+_patchlevel=0858
_versiondir="${pkgname}${_topver//./}"
pkgver=${_topver}.${_patchlevel}
pkgrel=1
arch=('i686' 'x86_64')
license=('custom:vim')
url="http://www.vim.org"
depends=('ncurses')
groups=('editors')
makedepends=('gawk' 'perl' 'python2' 'python3' 'ruby' 'libiconv' 'ncurses-devel' 'libcrypt-devel')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/vim/vim/archive/v${pkgver}.tar.gz
        'dot.vimrc'
        '7.3-cygwin-mouse.patch'
        '7.3-virc.patch'
        '7.3-cygwin-python-dyn.patch'
        'pretend-cygwin-msys.patch'
        'accept-crlf.patch'
        'vim-completion')
-sha256sums=('fe8dc50c735f625073cbe06b6dda863e623117ce41b66f40ce5f7efd77a1109e'
+sha256sums=('0a585eaa477ecb9f4723ce2709c9e2457a37672ba65f7c174c4deb26b1c5c5fc'
            'edd18e0756406ee7b659e4552e444c50c3a0c1e9fb4fce2ddd770c933ea6c7f5'
            'bca6e030d50c0d2468ab5c78aa0b359eb18a88a197de8406c593458ffedde922'
            '44d7738a8f801195898eeef766ff77506c717dd5d19145ade3c1c2349d4bc4fd'
            '0698234a2436f2d37f43775c9db5a2fc67d182f8baa46a8a0e2b7dd37da6fcbd'
            '5fcec194d2fcb2a624358d8ce074e8d97b873b5c2fff2118491b57a4880737d9'
            'bfa0b1f29e83eadd161c570f28a1247e3dca6aa3d89d23abcb7e57dab7649a6d'
            'bdca6069ef0fa995718f4b59fea85e58629259bb5a385d53e52d162d1463d4ff')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}

  iconv -f ISO-8859-1 -t UTF-8 runtime/doc/eval.txt \
    > runtime/doc/eval.tmp && mv -f runtime/doc/eval.{tmp,txt}

  patch -p2 -i ${srcdir}/7.3-cygwin-mouse.patch
  patch -p2 -i ${srcdir}/7.3-virc.patch
  patch -p2 -i ${srcdir}/7.3-cygwin-python-dyn.patch
  patch -p1 -i ${srcdir}/pretend-cygwin-msys.patch
  patch -p1 -i ${srcdir}/accept-crlf.patch

  # define the place for the global (g)vimrc file (set to /etc/vimrc)
  #sed -i 's|^.*\(#define SYS_.*VIMRC_FILE.*"\) .*$|\1|' \
  #  vim-build/src/feature.h
  #sed -i 's|^.*\(#define VIMRC_FILE.*"\) .*$|\1|' \
  #  vim-build/src/feature.h

  cd src
  autoconf
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}

  # ./configure \
    # --prefix=/usr \
    # --build=${CHOST} \
    # --with-features=small \
    # --with-tlib=ncursesw \
    # --enable-multibyte \
    # --disable-luainterp \
    # --disable-perlinterp \
    # --disable-pythoninterp \
    # --disable-python3interp \
    # --disable-rubyinterp \
    # --disable-tclinterp \
    # --disable-gpm --disable-sysmouse \
    # --disable-gui --without-x \
    # --with-compiledby="<alexpux@gmail.com>"
  # make auto/osdef.h
  # make VIMRCLOC=/etc VIMRUNTIMEDIR=/usr/share/vim/vim${slot/\.} || die "make 2 fail"
  # mv vim.exe vi.exe
  # make distclean

  ./configure \
+   --with-features=huge \
+   --enable-terminal \
    --prefix=/usr \
    --build=${CHOST} \
    --with-features=huge \
    --with-tlib=ncursesw \
    --enable-cscope \
    --enable-multibyte \
-   --enable-luainterp=dynamic \
+   --enable-luainterp \
+   --with-lua-prefix=/usr/local \
+   --enable-fail-if-missing \
    --enable-perlinterp=dynamic \
    --enable-pythoninterp=dynamic \
    --enable-python3interp=dynamic \
    --enable-rubyinterp=dynamic \
    --disable-tclinterp \
    --disable-gpm --disable-sysmouse \
    --disable-gui --without-x \
    CPPFLAGS="${CPPFLAGS} -I/usr/include/ncursesw" \
    --with-compiledby="<alexpux@gmail.com>"

  #make auto/osdef.h
  make -j1 VIMRCLOC=/etc VIMRUNTIMEDIR=/usr/share/vim/vim${_topver/\.}
}

check() {
  # disable tests because they seem to freeze

  cd "${srcdir}"/${pkgname}-${pkgver}

  #make test
}

package() {
  cd "${srcdir}"/${pkgname}-${pkgver}
  make -j1 VIMRCLOC=/etc DESTDIR="${pkgdir}" install

  make install -j1 \
    VIMRCLOC=/etc VIMRUNTIMEDIR=/usr/share/vim/vim${_topver/\.} \
    STRIP=: INSTALL_DATA="cp -L" INSTALL_DATA_R="cp -Lr" \
    DESTDIR="${pkgdir}"

  #for x in ex rvi vi.exe
  #do
  #  cp -f vi.exe ${pkgdir}/usr/bin/${x}
  #done

  for y in vimdiff view rview rvim
  do
    cp -f ${pkgdir}/usr/bin/vim.exe ${pkgdir}/usr/bin/${y}
  done

  mkdir -p ${pkgdir}/usr/share/bash-completion/completions
  cp -f ${srcdir}/vim-completion ${pkgdir}/usr/share/bash-completion/completions/vim

  # delete some manpages
  find "${pkgdir}"/usr/share/man -type d -name 'man1' 2>/dev/null | \
    while read _mandir; do
    cd ${_mandir}
    rm -f ex.1 # provided by (n)vi
    rm -f evim.1    # this does not make sense if we have no GUI
  done

  # fix FS#17216
  sed -i 's|messages,/var|messages,/var/log/messages.log,/var|' \
    "${pkgdir}"/usr/share/vim/${_versiondir}/filetype.vim

  # patch filetype.vim for better handling of pacman related files
  sed -i "s/rpmsave/pacsave/;s/rpmnew/pacnew/;s/,\*\.ebuild/\0,PKGBUILD*,*.install/" \
    "${pkgdir}"/usr/share/vim/${_versiondir}/filetype.vim
  sed -i "/find the end/,+3{s/changelog_date_entry_search/changelog_date_end_entry_search/}" \
    "${pkgdir}"/usr/share/vim/${_versiondir}/ftplugin/changelog.vim

  # rc files
  install -Dm644 "${srcdir}"/dot.vimrc "${pkgdir}"/etc/skel/.vimrc

  # rgb.txt file
  install -Dm644 "${srcdir}"/vim-${pkgver}/runtime/rgb.txt \
    "${pkgdir}"/usr/share/vim/${_versiondir}/rgb.txt

  # license
  install -Dm644 "${srcdir}"/vim-${pkgver}/runtime/doc/uganda.txt \
    "${pkgdir}"/usr/share/licenses/${pkgname}/license.txt
}

pacman用のパッケージを作成

$ makepkg
$ pacman -U vim-8.0.0858-1-x86_64.pkg.tar.xz

できたー

ScreenShot.png

留意点

ConEmuとの相性がすこぶる悪くて打った文字が見えません:sleepy:
ただ、バージョンが進むときっと解決されるでしょう(他力本願

謝辞

8
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?