|
1 |
| -const inquirer = require('inquirer') |
2 |
| -const { emojify } = require('node-emoji') |
3 |
| -const { getConfigPlugins } = require('./files') |
4 |
| -const { getPlugNameFromConfig } = require('./helpers') |
| 1 | +const inquirer = require("inquirer"); |
| 2 | +const { emojify } = require("node-emoji"); |
| 3 | +const { getConfigPlugins } = require("./files"); |
| 4 | +const { getPlugNameFromConfig } = require("./helpers"); |
5 | 5 |
|
6 | 6 | const askForVimInfo = () => {
|
7 | 7 | const questions = [
|
8 | 8 | {
|
9 |
| - name: 'vimpath', |
10 |
| - type: 'input', |
| 9 | + name: "vimpath", |
| 10 | + type: "input", |
11 | 11 | message:
|
12 |
| - 'Path to your vim config file using vim-plug relative to user directory. Example: .config/nvim/init.vim)?', |
| 12 | + "Path to your vim config file using vim-plug relative to user directory. Example: .config/nvim/init.vim)?\nIf your vim-plug block including your plugins is in a separate file, please use the path to that file instead.", |
13 | 13 | validate: (val) => {
|
14 | 14 | if (val.length) {
|
15 |
| - return true |
| 15 | + return true; |
16 | 16 | } else {
|
17 |
| - return 'Please enter a path to your vim config file' |
| 17 | + return "Please enter a path to your vim config file or the file that holds your vim-plug Plug declarations."; |
18 | 18 | }
|
19 |
| - } |
| 19 | + }, |
20 | 20 | },
|
21 | 21 | {
|
22 |
| - name: 'vimtype', |
23 |
| - type: 'list', |
24 |
| - message: 'Are you using neovim (nvim) or vim?', |
25 |
| - choices: ['nvim', 'vim'], |
26 |
| - default: 'vim' |
27 |
| - } |
28 |
| - ] |
| 22 | + name: "vimtype", |
| 23 | + type: "list", |
| 24 | + message: "Are you using neovim (nvim) or vim?", |
| 25 | + choices: ["nvim", "vim"], |
| 26 | + default: "vim", |
| 27 | + }, |
| 28 | + ]; |
29 | 29 |
|
30 |
| - return inquirer.prompt(questions) |
31 |
| -} |
| 30 | + return inquirer.prompt(questions); |
| 31 | +}; |
32 | 32 |
|
33 | 33 | const askForQuery = () =>
|
34 | 34 | inquirer.prompt([
|
35 | 35 | {
|
36 |
| - name: 'query', |
37 |
| - type: 'input', |
38 |
| - message: 'query', |
| 36 | + name: "query", |
| 37 | + type: "input", |
| 38 | + message: "query", |
39 | 39 | validate: (val) => {
|
40 | 40 | if (val.length === 0) {
|
41 |
| - return 'Must supply a name' |
| 41 | + return "Must supply a name"; |
42 | 42 | } else {
|
43 |
| - return true |
| 43 | + return true; |
44 | 44 | }
|
45 |
| - } |
46 |
| - } |
47 |
| - ]) |
| 45 | + }, |
| 46 | + }, |
| 47 | + ]); |
48 | 48 |
|
49 | 49 | const askPluginSelection = (plugins) =>
|
50 | 50 | inquirer.prompt([
|
51 | 51 | {
|
52 |
| - name: 'selection', |
53 |
| - type: 'list', |
| 52 | + name: "selection", |
| 53 | + type: "list", |
54 | 54 | choices: plugins.map((p) => ({
|
55 | 55 | name: `${p.name} - ${emojify(p.short_desc)}`,
|
56 | 56 | value: p,
|
57 |
| - short: `${p.name} - ${emojify(p.short_desc)}` |
58 |
| - })) |
| 57 | + short: `${p.name} - ${emojify(p.short_desc)}`, |
| 58 | + })), |
59 | 59 | },
|
60 | 60 | {
|
61 |
| - name: 'action', |
62 |
| - type: 'list', |
63 |
| - choices: ['info', 'install', 'back', 'exit'], |
64 |
| - default: 'info' |
65 |
| - } |
66 |
| - ]) |
| 61 | + name: "action", |
| 62 | + type: "list", |
| 63 | + choices: ["info", "install", "back", "exit"], |
| 64 | + default: "info", |
| 65 | + }, |
| 66 | + ]); |
67 | 67 |
|
68 | 68 | const installedPluginsList = async () => {
|
69 |
| - const installed = await getConfigPlugins() |
| 69 | + const installed = await getConfigPlugins(); |
70 | 70 |
|
71 | 71 | return inquirer.prompt([
|
72 | 72 | {
|
73 |
| - name: 'plugin', |
74 |
| - type: 'list', |
| 73 | + name: "plugin", |
| 74 | + type: "list", |
75 | 75 | choices: installed.map((p) => {
|
76 | 76 | return {
|
77 | 77 | name: getPlugNameFromConfig(p),
|
78 |
| - value: p |
79 |
| - } |
80 |
| - }) |
| 78 | + value: p, |
| 79 | + }; |
| 80 | + }), |
81 | 81 | },
|
82 | 82 | {
|
83 |
| - name: 'action', |
84 |
| - type: 'list', |
85 |
| - choices: ['info', 'uninstall', 'back', 'exit'] |
86 |
| - } |
87 |
| - ]) |
88 |
| -} |
| 83 | + name: "action", |
| 84 | + type: "list", |
| 85 | + choices: ["info", "uninstall", "back", "exit"], |
| 86 | + }, |
| 87 | + ]); |
| 88 | +}; |
89 | 89 |
|
90 | 90 | const menuSelection = () =>
|
91 | 91 | inquirer.prompt([
|
92 | 92 | {
|
93 |
| - name: 'command', |
94 |
| - type: 'list', |
95 |
| - choices: ['query', 'list', 'update', 'exit'], |
96 |
| - default: 'query' |
97 |
| - } |
98 |
| - ]) |
| 93 | + name: "command", |
| 94 | + type: "list", |
| 95 | + choices: ["query", "list", "update", "exit"], |
| 96 | + default: "query", |
| 97 | + }, |
| 98 | + ]); |
99 | 99 |
|
100 | 100 | module.exports = {
|
101 | 101 | askForVimInfo,
|
102 | 102 | askForQuery,
|
103 | 103 | askPluginSelection,
|
104 | 104 | installedPluginsList,
|
105 |
| - menuSelection |
106 |
| -} |
| 105 | + menuSelection, |
| 106 | +}; |
0 commit comments