2015/11/22

先日、Visual Studio Code がオープンソースになりました。

Microsoft/vscode - GitHub
https://github.com/Microsoft/vscode

OSS になる少し前から拡張を作る為の仕組み等が github 上で展開されていたので、もしかするととは思っていましたが予想通りです。

Atom の時にも OpenVim を作ったので

Big Sky :: 21 世紀のエディタである Atom を最強にする

Atom 最高ですね!! でも、Atom は 21 世紀のエディタです。まだ 21 世紀になって 14 年しか経っていないので、 20 世紀最強のエディタ に比べてまだまだ足りない機能があるのはしょう...

http://mattn.kaoriya.net/software/atom/20140922210610.htm

これはやるしかないと決めて作ってみました。(Twitter で告知したので知っている人もいるかと思いますが)

OpenVim

Visual Studio Marketplace - OpenVim

Open a current file in Vim

https://marketplace.visualstudio.com/items/mattn.OpenVim
Open Vim というコマンドで、現在 Visual Studio Code で開いているファイルを Vim (gvim) で開けます。gvim じゃない人は openvim.executablePath という設定で起動コマンドを変更できます。 {
    "openvim.executablePath": "/usr/bin/emacs"
}

リポジトリは以下です。pull-request よろしくお願いします。

mattn/vscode-openvim - GitHub
https://github.com/mattn/vscode-openvim

もう一つ作りました。

Runner

Visual Studio Code はプロジェクトでファイルを実行するには launch.json という設定に書くしかなく、実質一つしか実行出来ない為、非常に面倒だった。そこで、ファイルタイプや拡張子に従って実行出来る物を書きました。

Visual Studio Marketplace - Runner

Run various scripts.

https://marketplace.visualstudio.com/items/mattn.Runner
Runner

CTRL+SHIFT+R をタイプすると主要なスクリプト言語は実行できます。登録されていない物や、ファイルタイプが決まらない物については、以下の様に自分のコマンドに置き換えたり拡張子で設定したりも出来ます。

{
    "runner.extensionMap": {
        "ujm": "ujm",
        "ank": "c:/dev/godev/bin/anko",
        "lisp": "sbcl"
    },
    "runner.languageMap": {
        "c": "crun.bat",
        "csharp": "cscrun.bat",
        "java": "javarun.bat"   
    }
}

個人的には Runner の方は便利だなーと思っています。

mattn/vscode-runner - GitHub
https://github.com/mattn/vscode-runner

こちらも pull-request お待ちしております。

ちなみに crun.bat は以下の様にしています。

@echo off

if "%1" equ "" goto :eof

setlocal
set tempfile=%date:~4%%time::=%
set tempfile=%tempfile:/=%
set tempfile=%tempfile:.=%
gcc -o %tempfile%.exe "%1"
%tempfile%.exe
del %tempfile%.exe

cscrun.bat も同様。

@echo off

if "%1" equ "" goto :eof

setlocal
set tempfile=%date:~4%%time::=%
set tempfile=%tempfile:/=%
set tempfile=%tempfile:.=%
c:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /out:%tempfile%.exe "%1"
%tempfile%.exe
del %tempfile%.exe

javarun.bat は以下の通り。

@echo off
setlocal enabledelayedexpansion
set CP=.;
for %%i in (lib\*) do set CP=!CP!%%i;
if exist "%JAVA_HOME%\bin\javac.exe" goto run
for /F %%i in ('dir /b "%JAVA_HOME%\..\jdk*"') do (
  set PATH=!JAVA_HOME!\..\%%i\bin;!PATH!
  break
)
:run
javac -encoding utf-8 -cp "%CP%" %1
if %ERRORLEVEL% neq 0 goto :eof
java -cp "%CP%";%~dp1%~n1 %2 %3 %4 %5 %6 %7 %8 %9
:eof
endlocal
exit /b %ERRORLEVEL%
Posted at 11:37 | WriteBacks () | Edit
Edit this entry...

wikieditish message: Ready to edit this entry.






















A quick preview will be rendered here when you click "Preview" button.