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

feat: server document formatting #429

Merged
merged 4 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 2 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 0 additions & 2 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -25,7 +24,6 @@ export async function activate(context: ExtensionContext) {

await indexHardhatProjects(extensionState);

setupFormatterHook(extensionState);
setupLanguageServerHooks(extensionState);
setupTaskProvider(extensionState);
await setupCommands(extensionState);
Expand Down
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
Expand Up @@ -59,6 +59,7 @@ const startLanguageServer = (extensionState: ExtensionState): void => {
env: extensionState.env,
telemetryEnabled: extensionState.telemetryEnabled,
machineId: extensionState.machineId,
extensionConfig: workspace.getConfiguration("solidity"),
},
};

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

const hardhatTelemetryChangeDisposable = workspace.onDidChangeConfiguration(
notifyTelemetryChanged
);
const configChangedDisposable = workspace.onDidChangeConfiguration(() => {
kanej marked this conversation as resolved.
Show resolved Hide resolved
notifyTelemetryChanged();
client.sendNotification(
"custom/didChangeExtensionConfig",
workspace.getConfiguration("solidity")
);
});

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

client.start();

Expand Down
11 changes: 11 additions & 0 deletions coc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions coc/README.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions coc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
env: "production",
telemetryEnabled,
machineId: await machineId(),
extensionConfig: getExtensionConfig(),
},
}
);
Expand Down
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