My dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 4.1 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var tslib_1 = require("tslib");
  4. var coc_nvim_1 = require("coc.nvim");
  5. function activate(context) {
  6. return tslib_1.__awaiter(this, void 0, void 0, function () {
  7. var config, isEnable, serverModule, serverOptions, isEnableDebug, nvim, vimruntime, runtimepath, iskeyword, isEnableDiagnostic, fromVimruntime, fromRuntimepath, indexesRuntimepath, indexesCount, indexesGap, clientOptions, client;
  8. return tslib_1.__generator(this, function (_a) {
  9. switch (_a.label) {
  10. case 0:
  11. config = coc_nvim_1.workspace.getConfiguration('vimlsp');
  12. isEnable = config.get('enable', true);
  13. // extension is disable
  14. if (!isEnable) {
  15. return [2 /*return*/];
  16. }
  17. serverModule = require.resolve('vim-language-server');
  18. serverOptions = {
  19. run: {
  20. module: serverModule,
  21. transport: coc_nvim_1.TransportKind.ipc
  22. },
  23. debug: {
  24. module: serverModule,
  25. transport: coc_nvim_1.TransportKind.ipc
  26. }
  27. };
  28. isEnableDebug = config.get('debug', false);
  29. // The debug options for the server
  30. if (isEnableDebug) {
  31. serverOptions.debug.options = {
  32. execArgv: [
  33. "--nolazy",
  34. "--debug=6009"
  35. ]
  36. };
  37. }
  38. nvim = coc_nvim_1.workspace.nvim;
  39. return [4 /*yield*/, nvim.commandOutput('echo $VIMRUNTIME')];
  40. case 1:
  41. vimruntime = _a.sent();
  42. return [4 /*yield*/, nvim.getOption('runtimepath')];
  43. case 2:
  44. runtimepath = _a.sent();
  45. return [4 /*yield*/, nvim.getOption('iskeyword')];
  46. case 3:
  47. iskeyword = _a.sent();
  48. isEnableDiagnostic = config.get('diagnostic.enable', true);
  49. fromVimruntime = config.get('suggest.fromVimruntime', true);
  50. fromRuntimepath = config.get('suggest.fromRuntimepath', false);
  51. indexesRuntimepath = config.get('indexes.runtimepath', true);
  52. indexesCount = config.get('indexes.count', 1);
  53. indexesGap = config.get('indexes.gap', 100);
  54. clientOptions = {
  55. documentSelector: ['vim'],
  56. initializationOptions: {
  57. iskeyword: iskeyword,
  58. vimruntime: vimruntime,
  59. runtimepath: runtimepath,
  60. diagnostic: {
  61. enable: isEnableDiagnostic
  62. },
  63. indexes: {
  64. runtimepath: indexesRuntimepath,
  65. count: indexesCount,
  66. gap: indexesGap
  67. },
  68. suggest: {
  69. fromVimruntime: fromVimruntime,
  70. fromRuntimepath: fromRuntimepath
  71. }
  72. }
  73. };
  74. client = new coc_nvim_1.LanguageClient('vimlsp', 'vim language server', serverOptions, clientOptions);
  75. // Push the disposable to the context's subscriptions so that the
  76. // client can be deactivated on extension deactivation
  77. context.subscriptions.push(coc_nvim_1.services.registLanguageClient(client));
  78. return [2 /*return*/];
  79. }
  80. });
  81. });
  82. }
  83. exports.activate = activate;
  84. //# sourceMappingURL=index.js.map