Skip to content

Commit

Permalink
feat: introduce setting to disable Code Lens feature (#64)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom French <[email protected]>
  • Loading branch information
kobyhallx and TomAFrench authored Mar 4, 2024
1 parent 0be02a5 commit 2ef2925
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@
"default": true,
"description": "Enable the language server"
},
"noir.enableCodeLens": {
"scope": "resource",
"type": "boolean",
"default": true,
"description": "Enable the Code Lens feature of language server. (Compile, Execute, Info, Profile, Run Test links above entry functions and tests)"
},
"noir.trace.server": {
"scope": "resource",
"type": "string",
Expand Down
7 changes: 7 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,17 @@ export default class Client extends LanguageClient {
});
}

const config = workspace.getConfiguration('noir', uri);

const enableCodeLens = config.get<boolean>('enableCodeLens');

const clientOptions: LanguageClientOptions = {
documentSelector,
workspaceFolder,
outputChannel,
initializationOptions: {
enableCodeLens,
},
};

const serverOptions: ServerOptions = {
Expand Down
5 changes: 5 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ async function didOpenTextDocument(document: TextDocument): Promise<Disposable>
await removeWorkspaceClient(folder);
await addWorkspaceClient(folder);
}

if (e.affectsConfiguration('noir.enableCodeLens', folder.uri)) {
await removeWorkspaceClient(folder);
await addWorkspaceClient(folder);
}
});
} else {
// We only want to handle `file:` and `untitled:` schemes because
Expand Down

0 comments on commit 2ef2925

Please sign in to comment.