Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release:2023-04-18 #454

Merged
merged 4 commits into from
Apr 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: server document formatting provider
Support for coc formatting by moving formatting from client-side to
server-side.
antico5 authored and kanej committed Apr 18, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 24086c7b3d6b16f5a458fefbf460b4b9b7d5f64a
5 changes: 2 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -58,13 +58,12 @@
"@types/prettier": "2.6.0",
"@types/vscode": "^1.70",
"eslint": "^7.23.0",
"rimraf": "3.0.2"
"rimraf": "3.0.2",
"prettier": "2.5.1"
},
"dependencies": {
"@nomicfoundation/solidity-language-server": "0.6.15",
"@sentry/node": "6.19.1",
"prettier": "2.5.1",
"prettier-plugin-solidity": "1.1.2",
"vscode-languageclient": "^7.0.0"
},
"contributes": {
2 changes: 0 additions & 2 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ import { warnOnOtherSolidityExtensions } from "./popups/warnOnOtherSolidityExten
import { indexHardhatProjects } from "./setup/indexHardhatProjects";
import { setupCommands } from "./setup/setupCommands";
import { setupExtensionState } from "./setup/setupExtensionState";
import { setupFormatterHook } from "./setup/setupFormatterHook";
import { setupLanguageServerHooks } from "./setup/setupLanguageServerHooks";
import { setupTaskProvider } from "./setup/setupTaskProvider";
import { setupWorkspaceHooks } from "./setup/setupWorkspaceHooks";
@@ -25,7 +24,6 @@ export async function activate(context: ExtensionContext) {

await indexHardhatProjects(extensionState);

setupFormatterHook(extensionState);
setupLanguageServerHooks(extensionState);
setupTaskProvider(extensionState);
await setupCommands(extensionState);
88 changes: 0 additions & 88 deletions client/src/formatter/forgeFormatter.ts

This file was deleted.

25 changes: 0 additions & 25 deletions client/src/formatter/index.ts

This file was deleted.

94 changes: 0 additions & 94 deletions client/src/formatter/prettierFormatter.ts

This file was deleted.

26 changes: 0 additions & 26 deletions client/src/setup/setupFormatterHook.ts

This file was deleted.

13 changes: 9 additions & 4 deletions client/src/setup/setupLanguageServerHooks.ts
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ const startLanguageServer = (extensionState: ExtensionState): void => {
env: extensionState.env,
telemetryEnabled: extensionState.telemetryEnabled,
machineId: extensionState.machineId,
extensionConfig: workspace.getConfiguration("solidity"),
},
};

@@ -92,12 +93,16 @@ const startLanguageServer = (extensionState: ExtensionState): void => {
notifyTelemetryChanged
);

const hardhatTelemetryChangeDisposable = workspace.onDidChangeConfiguration(
notifyTelemetryChanged
);
const configChangedDisposable = workspace.onDidChangeConfiguration(() => {
notifyTelemetryChanged();
client.sendNotification(
"custom/didChangeExtensionConfig",
workspace.getConfiguration("solidity")
);
});

extensionState.listenerDisposables.push(globalTelemetryChangeDisposable);
extensionState.listenerDisposables.push(hardhatTelemetryChangeDisposable);
extensionState.listenerDisposables.push(configChangedDisposable);

client.start();

11 changes: 11 additions & 0 deletions coc/README.md
Original file line number Diff line number Diff line change
@@ -14,6 +14,13 @@ In your vim/neovim, run this command:
:CocInstall @nomicfoundation/coc-solidity
```

## Configure

In your coc-settings.json, the following settings are supported:

- `"@nomicfoundation/coc-solidity.telemetry": true|false`
- `"@nomicfoundation/coc-solidity.formatter": "prettier"|"forge"|"none"`

## Features

### Code Completions
@@ -173,6 +180,10 @@ The **Hardhat config file** that is used when validating a Solidity file is show
![Open Config](https://raw.githubusercontent.com/NomicFoundation/hardhat-vscode/main/docs/gifs/open-config.gif "Open Config")


## Format document

Running `:call CocActionAsync('format')` will trigger document formatting.

## Language server logs

If you encounter an issue with the plugin, you can inspect the server logs by running `:CocCommand workspace.showOutput`. This can help troubleshooting the problem.
11 changes: 11 additions & 0 deletions coc/README.template.md
Original file line number Diff line number Diff line change
@@ -14,8 +14,19 @@ In your vim/neovim, run this command:
:CocInstall @nomicfoundation/coc-solidity
```

## Configure

In your coc-settings.json, the following settings are supported:

- `"@nomicfoundation/coc-solidity.telemetry": true|false`
- `"@nomicfoundation/coc-solidity.formatter": "prettier"|"forge"|"none"`

[include '../docs/features.md']

## Format document

Running `:call CocActionAsync('format')` will trigger document formatting.

## Language server logs

If you encounter an issue with the plugin, you can inspect the server logs by running `:CocCommand workspace.showOutput`. This can help troubleshooting the problem.
1 change: 1 addition & 0 deletions coc/src/index.ts
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
env: "production",
telemetryEnabled,
machineId: await machineId(),
extensionConfig: getExtensionConfig(),
},
}
);
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading