├── AUTHORS.md ├── LICENCE.md ├── README.md └── plugin └── vimppm.js /AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Thanks 2 | 3 | * anekos: [vimperator-plugins/function-template.js at master ・ vimpr/vimperator-plugins](https://github.com/vimpr/vimperator-plugins/blob/master/function-template.js) 4 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) 2013 CD01 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vimppm - Vimperator Plugin Manager (Experimental) 2 | 3 | [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE) 4 | 5 | ## Require 6 | 7 | * Git 8 | * if you use Windows, you require Windows 7+ or to install PowerShell. 9 | 10 | 11 | # Install 12 | 13 | ``` sh 14 | cd ~/.vimperator 15 | mkdir vimppm && cd vimppm 16 | git clone git://github.com/cd01/vimppm 17 | ``` 18 | 19 | # Usage 20 | 21 | Sample `.vimperatorrc` 22 | 23 | ``` vim 24 | source ~/.vimperator/vimppm/plugin/vimppm/vimppm.js 25 | 26 | " Github 27 | vimppm 'cd01/evernote-clearly-vimp' 28 | vimppm 'hoge/hogehoge-vimp' 29 | vimppm 'homu/homuhomu-vimp' 30 | 31 | " Vimpr 32 | vimppm '_smooziee.js' 33 | vimppm 'copy.js' 34 | vimppm 'caret-hint.js' 35 | ``` 36 | 37 | run `:vimppm install` 38 | -------------------------------------------------------------------------------- /plugin/vimppm.js: -------------------------------------------------------------------------------- 1 | // vimppm 2 | // Copyright (c) 2015 CD01 3 | // This software is released under the MIT License. 4 | // http://opensource.org/licenses/mit-license.php 5 | 6 | 7 | var INFO = xml` 8 | 13 | CD01 14 | MIT 15 | 16 |

17 | Vimppm 18 |

19 | 20 | 21 | :vimppm 22 | :vimppm 23 | 24 |

25 | manage plugin by vimppm 26 |

27 |
28 |
29 | 30 | 31 | :vimppm install 32 | :vimppm install 33 | 34 |

35 | install all bundled plugins 36 |

37 |
38 |
39 | 40 | 41 | :vimppm update 42 | :vimppm update 43 | 44 |

45 | update all bundled plugins 46 |

47 |
48 |
49 |
`; 50 | 51 | 52 | var gitProtocol = (liberator.globalVariables.vimppm_default_git_protocol == undefined) 53 | ? 'https' 54 | : liberator.globalVariables.vimppm_default_git_protocol; 55 | var vimppmDirPath = getVimppmDir(); 56 | var powershellCommand = "!powershell -WindowStyle Minimized -NoProfile -ExecutionPolicy unrestricted -Command "; 57 | 58 | function getVimppmDir() { 59 | var vimperatorDir = io.File(io.File.expandPath("~/.vimperator")); 60 | 61 | if (vimperatorDir.exists()) return "~/.vimperator/vimppm"; 62 | 63 | vimperatorDir = io.File(io.File.expandPath("~/vimperator")); 64 | 65 | if (vimperatorDir.exists()) return "~/vimperator/vimppm"; 66 | 67 | vimperatorDir = io.File(io.File.expandPath("~/_vimperator")); 68 | 69 | if (vimperatorDir.exists()) 70 | return "~/_vimperator/vimppm"; 71 | else 72 | return false; 73 | } 74 | 75 | function isGithubRepository(repositoryName) { 76 | return (repositoryName.indexOf('/') !== -1) ? true : false; 77 | } 78 | 79 | function isDirectory(path) { 80 | var pluginDir = io.File(io.File.expandPath(path)); 81 | return (pluginDir.exists() && pluginDir.isDirectory()) ? true : false; 82 | } 83 | 84 | function installFromGithub(vimppmRepositoryName) { 85 | var pluginDirPath = vimppmDirPath + '/' + vimppmRepositoryName.split('/')[1]; 86 | if (!isDirectory(pluginDirPath)) { 87 | if (liberator.has('Windows')) 88 | liberator.execute(powershellCommand + 'cd "' + vimppmDirPath + '"; git clone ' + gitProtocol + '://github.com/' + vimppmRepositoryName + '.git'); 89 | else 90 | liberator.execute('!cd ' + vimppmDirPath + ' && git clone ' + gitProtocol + '://github.com/' + vimppmRepositoryName + '.git'); 91 | 92 | return true; 93 | } else { 94 | liberator.echoerr(vimppmRepositoryName + ' already exists!'); 95 | return false; 96 | } 97 | } 98 | 99 | function gitPull(vimppmRepositoryName) { 100 | var pluginDirPath = vimppmDirPath + '/' + vimppmRepositoryName.split('/')[1]; 101 | if (isDirectory(pluginDirPath)) { 102 | if (liberator.has('Windows')) 103 | liberator.execute(powershellCommand + 'cd "' + pluginDirPath + '"; git pull'); 104 | else 105 | liberator.execute('!cd ' + pluginDirPath + ' && git pull'); 106 | 107 | return true; 108 | } else { 109 | liberator.echoerr(vimppmRepositoryName + " isn't installed"); 110 | return false; 111 | } 112 | } 113 | 114 | function installTwittperatorFromVimpr(pluginName) { 115 | // TODO: 116 | // %TMP% に git clone 117 | // mv Twittperator 118 | // rmdir %TMP%Twittperator 119 | } 120 | 121 | function installFromVimpr(pluginName) { 122 | var pluginDirPath = vimppmDirPath + '/' + pluginName; 123 | if (!isDirectory(pluginDirPath)) { 124 | if (liberator.has('Windows')) { 125 | var downloadUrl = 'https://raw.github.com/vimpr/vimperator-plugins/master/' + pluginName; 126 | var destPath = io.File.expandPath(pluginDirPath + '/plugin/' + pluginName) 127 | liberator.execute(powershellCommand + 'New-Item -type directory "' + io.File.expandPath(pluginDirPath) + '/plugin"'); 128 | liberator.execute(powershellCommand + '$(new-object System.Net.WebClient).DownloadFile("' + downloadUrl + '", "' + destPath + '")'); 129 | } else { 130 | liberator.execute('!mkdir -p ' + io.File.expandPath(pluginDirPath) + '/plugin'); 131 | liberator.execute('!wget https://raw.github.com/vimpr/vimperator-plugins/master/' + pluginName + ' -P ' + io.File.expandPath(pluginDirPath) + '/plugin/'); 132 | } 133 | return true; 134 | } else { 135 | liberator.echoerr(pluginName + ' already exists!'); 136 | return false; 137 | } 138 | } 139 | 140 | function updateFromVimpr(pluginName) { 141 | var pluginDirPath = vimppmDirPath + '/' + pluginName; 142 | if (isDirectory(pluginDirPath)) { 143 | if (liberator.has('Windows')) { 144 | var downloadUrl = 'https://raw.github.com/vimpr/vimperator-plugins/master/' + pluginName; 145 | var destPath = io.File.expandPath(pluginDirPath + '/plugin/' + pluginName) 146 | liberator.execute(powershellCommand + '$(new-object System.Net.WebClient).DownloadFile("' + downloadUrl + '", "' + destPath + '")'); 147 | } else { 148 | liberator.execute('!wget https://raw.github.com/vimpr/vimperator-plugins/master/' + pluginName + ' -O ' + io.File.expandPath(pluginDirPath) + '/plugin/' + pluginName); 149 | } 150 | return true; 151 | } else { 152 | liberator.echoerr(pluginName + " isn't installed"); 153 | return false; 154 | } 155 | } 156 | 157 | 158 | (function () { 159 | var vimppmRepository = []; 160 | 161 | commands.addUserCommand( 162 | ['vimppm'], 'VIMPeratorPluginManage command', 163 | function (args) { 164 | // vimppm "cd01/plugin-vimp" "{'hoge': 'hogehoge'}" 165 | // JSON.parse(args[1]).hoge; 166 | 167 | var repositoryName = args[0]; 168 | if (isGithubRepository(repositoryName)) repositoryName = repositoryName.split('/')[1]; 169 | var pluginDirPath = vimppmDirPath + '/' + repositoryName; 170 | 171 | if (isDirectory(pluginDirPath)) 172 | liberator.execute('set rtp+=' + pluginDirPath); 173 | 174 | vimppmRepository.push(args[0]); 175 | }, { 176 | subCommands: [ 177 | new Command( 178 | ['install'], 'install plugin', 179 | function (args) { 180 | if (args == "") { 181 | for (var i = 0; i < vimppmRepository.length; i++) { 182 | if (isGithubRepository(vimppmRepository[i])) 183 | installFromGithub(vimppmRepository[i]); 184 | else 185 | installFromVimpr(vimppmRepository[i]); 186 | } 187 | } else { 188 | if (isGithubRepository(args)) 189 | installFromGithub(args); 190 | else 191 | installFromVimpr(args); 192 | } 193 | 194 | liberator.echo("Vimperator plugins are installed!! Please, restart vimperator."); 195 | } 196 | ), 197 | new Command( 198 | ['update'], 'update plugin', 199 | function (args) { 200 | if (args == "") { 201 | for (var i = 0; i < vimppmRepository.length; i++) { 202 | if (isGithubRepository(vimppmRepository[i])) 203 | gitPull(vimppmRepository[i]); 204 | else 205 | updateFromVimpr(vimppmRepository[i]); 206 | } 207 | } else { 208 | if (isGithubRepository(args[0])) 209 | gitPull(args[0]); 210 | else 211 | updateFromVimpr(args[0]); 212 | } 213 | 214 | liberator.echo("Vimperator plugins are updated. Please, restart vimperator."); 215 | } 216 | ) 217 | ] 218 | } 219 | ); 220 | })(); 221 | 222 | // vim:sw=4 ts=4 et : 223 | --------------------------------------------------------------------------------