forked from oxalica/nil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
26 lines (22 loc) · 905 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { ExtensionContext, services, LanguageClient, workspace, commands } from 'coc.nvim';
import * as lsp_ext from './lsp_ext';
const ROOT_SECTION = 'nil';
export async function activate(context: ExtensionContext): Promise<void> {
const cfg = workspace.getConfiguration(ROOT_SECTION);
if (!cfg.get('enable', true)) {
return;
}
const serverOptions = {
command: cfg.get<string>('server.path', 'nil'),
};
const clientOptions = {
documentSelector: [{ language: 'nix' }],
initializationOptions: cfg,
};
const client = new LanguageClient('nil', 'nil Language Server', serverOptions, clientOptions);
context.subscriptions.push(services.registLanguageClient(client));
context.subscriptions.push(commands.registerCommand('nil.reloadFlake', () => onReloadFlake(client)));
}
function onReloadFlake(client: LanguageClient) {
client.sendNotification(lsp_ext.reloadFlake);
}