Skip to content

Commit

Permalink
feat!: Support coc.nvim latest(0.0.82) and drop prior versions
Browse files Browse the repository at this point in the history
- Support 0.0.82
- Drop support for old coc.nvim versions. (prior to 0.0.82)
- Drop Node.js v10 because coc.nvim also drops.
- Fix for errors on switching to node but you should use patched
  version. Refer to fannheyward/coc-deno#184
  • Loading branch information
LumaKernel committed Oct 10, 2022
1 parent 9390eed commit 8a4ec01
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -28,6 +28,10 @@ Checking following in order.
b. Shebang is present and including `deno` -> **deno**
4. Otherwise, nothing is detected.

## Optional: To suppress errors on switching to node

To suppress errors what you'll see when switching to node, you should use [my patched coc-deno](https://github.com/LumaKernel/coc-deno-pruned) (not published to npm, so you should install as vim script and build) instead of official until [the issue](https://github.com/fannheyward/coc-deno/issues/184) is fixed.

## When does this try to detect?

This tries to detect when following events occurred.
Expand Down
11 changes: 4 additions & 7 deletions src/commands.ts
@@ -1,13 +1,11 @@
import { commands, window, workspace } from 'coc.nvim';
import { ConfigurationTarget } from './coc_internal';
import { setConfigWorkspace } from './set_config';
import type { Settings, TsRuntime } from './settings';
import { getSettings } from './settings';

const configure = async (runtime: TsRuntime, settings: Settings): Promise<void> => {
await setConfigWorkspace('tsserver', 'enable', runtime === 'node');
await setConfigWorkspace('deno', 'enable', runtime === 'deno');
await commands.executeCommand('editor.action.restart');
const override = runtime === 'node' ? settings.nodeOverride : settings.denoOverride;

/* eslint-disable no-restricted-syntax,no-await-in-loop,no-continue */
Expand All @@ -21,6 +19,7 @@ const configure = async (runtime: TsRuntime, settings: Settings): Promise<void>
await setConfigWorkspace(ns.join('.'), nsKey, override[key]);
}
/* eslint-enable no-restricted-syntax,no-await-in-loop,no-continue */
await commands.executeCommand('editor.action.restart');
};

export const manualInitializeWorkspace = async (runtime: TsRuntime): Promise<void> => {
Expand All @@ -29,15 +28,13 @@ export const manualInitializeWorkspace = async (runtime: TsRuntime): Promise<voi

await configure(runtime, settings);

await commands.executeCommand('editor.action.restart');

await window.showInformationMessage(`${runtime === 'node' ? 'Node' : 'Deno'} workspace settings configured!`);
};

export const autoInitializeWorkspace = async (runtime: TsRuntime): Promise<void> => {
const workspaceConfigFile = workspace.getConfigFile(ConfigurationTarget.Workspace);
const configuration = workspace.getConfiguration();
const settings = getSettings();
const exists = typeof workspaceConfigFile === 'string';
const exists = configuration.has('');

if (settings.doNothingIfConfigExists && exists) return;
if (settings.doNotCreateOnNode && runtime === 'node' && !exists) return;
Expand All @@ -49,6 +46,6 @@ export const autoInitializeWorkspace = async (runtime: TsRuntime): Promise<void>
if (exists && denoConfig.get('enable') && runtime === 'deno') return;

await configure(runtime, settings);
await commands.executeCommand('editor.action.restart');

await workspace.nvim.command(`doautocmd User tsdetect#coc#auto#switch#${runtime}#after`);
};
7 changes: 0 additions & 7 deletions src/globals.d.ts

This file was deleted.

0 comments on commit 8a4ec01

Please sign in to comment.