-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(commands): add "ansible.server.showMetaData" (#24)
- Loading branch information
Showing
4 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { commands, ExtensionContext, LanguageClient, NotificationType, workspace } from 'coc.nvim'; | ||
|
||
export async function activate(context: ExtensionContext, client: LanguageClient) { | ||
await client.onReady(); | ||
|
||
client.onNotification(new NotificationType(`update/ansible-metadata`), async (ansibleMetaDataList: any) => { | ||
const outputText = JSON.stringify(ansibleMetaDataList, null, 2); | ||
|
||
await workspace.nvim | ||
.command( | ||
'belowright vnew ansible-server-metadata | setlocal buftype=nofile bufhidden=hide noswapfile filetype=json' | ||
) | ||
.then(async () => { | ||
const buf = await workspace.nvim.buffer; | ||
buf.setLines(outputText.split('\n'), { start: 0, end: -1 }); | ||
}); | ||
}); | ||
|
||
context.subscriptions.push( | ||
commands.registerCommand('ansible.server.showMetaData', async () => { | ||
const { document } = await workspace.getCurrentState(); | ||
if (document.languageId !== 'ansible') return; | ||
|
||
client.sendNotification(new NotificationType(`update/ansible-metadata`), [document.uri.toString()]); | ||
}) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters