From e0d4ac9768d5ae54567a0329ff50699ff023c64d Mon Sep 17 00:00:00 2001 From: yaegassy Date: Wed, 10 Aug 2022 10:47:01 +0900 Subject: [PATCH] feat(commands): add "ansible.server.resyncAnsibleInventory" command --- README.md | 1 + package.json | 4 ++++ src/commands/serverResyncAnsibleInventory.ts | 17 +++++++++++++++++ src/index.ts | 2 ++ 4 files changed, 24 insertions(+) create mode 100644 src/commands/serverResyncAnsibleInventory.ts diff --git a/README.md b/README.md index 28a4680..f4644b5 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ You can also run the installation command manually. - **[Note]** `ansible` is a very large tool and will take some time to install - `ansible.server.restart`: Restart ansible language server - `ansible.server.showMetaData`: Show ansible-metadata for ansible language server +- `ansible.server.resyncAnsibleInventory`: Resync Ansible Inventory - `ansible.ansbileDoc.showInfo`: Run the `ansible-doc` command in a terminal window with various options to display information about the plugins | [DEMO](https://github.com/yaegassy/coc-ansible/pull/22#issuecomment-1178586815) - `ansible.ansbileDoc.showSnippets`: Run the `ansible-doc` command in a terminal window with various options to display a snippets of the plugins | [DEMO](https://github.com/yaegassy/coc-ansible/pull/22#issuecomment-1178587359) diff --git a/package.json b/package.json index 0670f8f..42adf2e 100644 --- a/package.json +++ b/package.json @@ -351,6 +351,10 @@ "command": "ansible.server.showMetaData", "title": "Show ansible-metadata for ansible language server" }, + { + "command": "ansible.server.resyncAnsibleInventory", + "title": "Resync Ansible Inventory" + }, { "command": "ansible.ansbileDoc.showInfo", "title": "Run the `ansible-doc` command in a terminal window with various options to display information about the plugins" diff --git a/src/commands/serverResyncAnsibleInventory.ts b/src/commands/serverResyncAnsibleInventory.ts new file mode 100644 index 0000000..edb6f06 --- /dev/null +++ b/src/commands/serverResyncAnsibleInventory.ts @@ -0,0 +1,17 @@ +import { commands, ExtensionContext, LanguageClient, NotificationType, workspace } from 'coc.nvim'; + +export async function activate(context: ExtensionContext, client: LanguageClient) { + await client.onReady(); + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + client.onNotification(new NotificationType(`resync/ansible-inventory`), (event) => {}); + + context.subscriptions.push( + commands.registerCommand('ansible.server.resyncAnsibleInventory', async () => { + const { document } = await workspace.getCurrentState(); + if (document.languageId !== 'ansible') return; + + client.sendNotification(new NotificationType(`resync/ansible-inventory`)); + }) + ); +} diff --git a/src/index.ts b/src/index.ts index c2630ab..e160482 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,6 +27,7 @@ import * as ansibleDocShowInfoCommandFeature from './commands/ansibleDocShowInfo import * as ansibleDocShowSnippetsCommandFeature from './commands/ansibleDocShowSnippets'; import * as builtinInstallRequirementsToolsCommandFeature from './commands/builtinInstallRequirementsTools'; import * as serverRestartCommandFeature from './commands/serverRestart'; +import * as serverResyncAnsibleInventoryCommandFeature from './commands/serverResyncAnsibleInventory'; import * as serverShowMetaDataCommandFeature from './commands/serverShowMetaData'; let client: LanguageClient; @@ -182,6 +183,7 @@ export async function activate(context: ExtensionContext): Promise { // commands serverRestartCommandFeature.activate(context, client); serverShowMetaDataCommandFeature.activate(context, client); + serverResyncAnsibleInventoryCommandFeature.activate(context, client); if (pythonCommandPaths) { builtinInstallRequirementsToolsCommandFeature.activate(context, pythonCommandPaths, client); }