vimプラグインのquickrunでnodejsが実行できなくて困っています。
node.jsの実行したいファイル名は「server.js」です。
quickrunはファイルの拡張しから実行するべき処理系を自動で識別するそうですが、.js拡張子のファイルは標準ではjavascriptが実行される様になっているそうです。
なのでNodeの実行ファイルであるnodeコマンドを代わりに使用するために
.vimrcファイルの設定には以下のように書いてあります。
(コマンドラインでnodeコマンドを打てば実行できるのでPATHは通っているとと思います)
linux
1 let g:quickrun_config = { 2 \ "javascript": { 3 \ "command": "node", 4 \ "tempfile": "{tempname()}.js" 5 \ } 6 \ }
この設定でバッファを開いて「\r」で実行するのですが、全く反応がありません。
ちなみに、phpファイルや純粋なjavascriptファイルのquickrun実行はできます。
quickrunをnode.jsで実行する方法を教えて下さい。
追加でquickrunで実行するserver.jsと.vimrcのすべてのソースを追記します。
linux
1//server.js 2var http = require('http'); 3 4var server = http.createServer(); 5server.on('request', doRequest); 6server.listen(process.env.PORT, process.env.IP); 7console.log('Server running!'); 8 9// リクエストの処理 10function doRequest(req, res) { 11res.writeHead(200, {'Content-Type': 'text/plain'}); 12res.write('Hello World\n'); 13res.end(); 14}
linux
1" .vimrc 2" 表示設定 3set number "行番号を表示する 4set title "編集中のファイル名を表示 5set showmatch "括弧入力時の対応する括弧を表示 6syntax on "コードの色分け 7set tabstop=4 "インデントをスペース4つ分に設定 8set smartindent "オートインデント 9 10" 行番号の色を設定 11hi LineNr ctermbg=none ctermfg=8 12hi CursorLineNr ctermbg=10 ctermfg=255 13set cursorline 14hi clear CursorLine 15 16" 検索設定 17set ignorecase "大文字/小文字の区別なく検索する 18set smartcase "検索文字列に大文字が含まれている場合は区別して検索する 19set wrapscan "検索時に最後まで行ったら最初に戻る 20" 21" 22"--------------------------- 23" Start Neobundle Settings. 24"--------------------------- 25" bundleで管理するディレクトリを指定 26set runtimepath+=~/.vim/bundle/neobundle.vim/ 27" 28" Required: 29call neobundle#begin(expand('~/.vim/bundle/')) 30" 31NeoBundleFetch 'Shougo/neobundle.vim' 32" quickrumを設定 33NeoBundle 'thinca/vim-quickrun' 34 let g:quickrun_config = { 35 \ "node": { 36 \ "command": "node", 37 \ "tempfile": "{tempname()}.js" 38 \ } 39 \ } 40" 41" autocloseを設定 42NeoBundle 'Townk/vim-autoclose' 43" 44call neobundle#end() 45" 46" Required: 47filetype plugin indent on 48" 49NeoBundleCheck 50" ------------------------- 51" End Neobundle Settings. 52" ------------------------- "
linux
1# .bash_profile 2 3# Get the aliases and functions 4if [ -f ~/.bashrc ]; then 5 . ~/.bashrc 6fi 7# User specific environment and startup programs 8PATH=$PATH:$HOME/bin 9export PATH
linux
1# .bashrc 2 3# Source global definitions 4if [ -f /etc/bashrc ]; then 5 . /etc/bashrc 6fi 7# User specific aliases and functions 8export PATH=$HOME/.nodebrew/current/bin:$PATH
nodejsとphpをQuickRunした時の画面結果を2枚ずつ載せます
ご覧の通りnodeでは動きませんが、phpだと動くのがわかると思います。
回答3件
あなたの回答
tips
プレビュー