Skip to content

Commit

Permalink
Merge pull request #897 from Durbatuluk1701/activity-bar-display-fix
Browse files Browse the repository at this point in the history
fix: make VsCoq activity bar logo appear only when Coq files present
  • Loading branch information
rtetley authored Sep 13, 2024
2 parents 3a1d581 + 24fb030 commit 6ad8b29
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
5 changes: 5 additions & 0 deletions client/coq-project.configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"comments": {
"lineComment": "#"
}
}
26 changes: 24 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"bugs": "https://github.com/coq-community/vscoq/issues",
"homepage": "https://github.com/coq-community/vscoq/blob/master/README.md",
"activationEvents": [
"onLanguage:coq"
"workspaceContains:**/_CoqProject",
"workspaceContains:**/*.v"
],
"main": "./dist/extension.js",
"contributes": {
Expand All @@ -50,13 +51,33 @@
"light": "./assets/logo.png",
"dark": "./assets/logo.png"
}
},
{
"id": "coq-project",
"aliases": [
"Coq Project",
"coq-project"
],
"extensions": [
"_CoqProject"
],
"configuration": "./coq-project.configuration.json",
"icon": {
"light": "./assets/logo.png",
"dark": "./assets/logo.png"
}
}
],
"grammars": [
{
"language": "coq",
"scopeName": "source.coq",
"path": "./syntax/coq.tmLanguage.json"
},
{
"language": "coq-project",
"scopeName": "source.coq-project",
"path": "./syntax/coq-project.tmLanguage.json"
}
],
"viewsContainers": {
Expand All @@ -73,7 +94,8 @@
{
"type": "webview",
"id": "vscoq.search",
"name": "Query"
"name": "Query",
"when": "inCoqProject"
}
]
},
Expand Down
15 changes: 14 additions & 1 deletion client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ import { QUICKFIX_COMMAND, CoqWarningQuickFix } from './QuickFixProvider';
let client: Client;

export function activate(context: ExtensionContext) {
commands.executeCommand('setContext', 'inCoqProject', true);

function checkInCoqProject() {
workspace.findFiles('**/{*.v,_CoqProject}').then(files => {
commands.executeCommand('setContext', 'inCoqProject', files.length > 0);
});
}

// Watch for files being added or removed
workspace.onDidCreateFiles(checkInCoqProject);
workspace.onDidDeleteFiles(checkInCoqProject);

const coqTM = new VsCoqToolchainManager();
coqTM.intialize().then(
Expand Down Expand Up @@ -382,4 +393,6 @@ Path: \`${coqTM.getVsCoqTopPath()}\`
}

// This method is called when your extension is deactivated
export function deactivate() {}
export function deactivate() {
commands.executeCommand('setContext', 'inCoqProject', undefined);
}
32 changes: 32 additions & 0 deletions client/syntax/coq-project.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"fileTypes": [
"_CoqProject"
],
"name": "Coq Project",
"scopeName": "source.coq-project",
"patterns": [
{
"name": "comment.line.coq-project",
"match": "#.*$"
},
{
"name": "string.quoted.double.coq-project",
"begin": "\"",
"end": "\""
},
{
"name": "keyword.other.coq-project",
"match": "(-arg|-generate-meta-for-package|-docroot|-Q|-R|-I|-native-compiler)"
},
{
"name": "entity.name.file.coq-project",
"match": "(.*(\\|/))?(\\S+\\.v)"
},
{
"name": "entity.name.folder.coq-project",
"match": "(.*(\\|/))?(\\S+)"
}
],
"repository": {},
"uuid": "94440acd-57c4-46ad-b59b-d05ab6902361"
}

0 comments on commit 6ad8b29

Please sign in to comment.