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

update README.md and fix bug in fallback config lookup #52

Merged
merged 2 commits into from
Mar 13, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This project adhere's to [Semantic Versioning](https://semver.org/spec/v2.0.0.ht

## [unreleased]

- Update README.md for version 3.
- Fix bug that prevented using fallback config.
- Add timestamps to output.

## [3.0.1]

- Fix bug in setting config `grepPath`.
Expand Down
107 changes: 82 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,83 @@ Most of the properties are optional, so you can make use of only the features th
{
"languageId": "cabal",
"formatCommand": "cabal-fmt --stdout",
"apiSearchUrl": "https://hoogle.haskell.org/?hoogle=${query}"
"apiSearchUrl": "https://hackage.haskell.org/packages/search?terms=${query}"
},
{
"languageId": "haskell",
"serverCommand": "static-ls",
"formatCommand": "fourmolu --mode stdout --stdin-input-file ${file}",
"apiSearchUrl": "https://hoogle.haskell.org/?hoogle=${query}",
"tags": {
"file": ".tags",
"initTagsCommand": "ghc-tags -c",
"refreshTagsCommand": "ghc-tags -c",
"completionsProvider": true,
"definitionsProvider": true,
"importsProvider": {
"importLinePattern": "import ${module} (${symbol})",
"matchFromFilepath": "([A-Z][A-Za-z0-9_']*)(\\/([A-Z][A-Za-z0-9_']*))*\\.hs",
"renderModuleName": [
{
"tag": "replace",
"from": "\\.hs",
"to": ""
},
{
"tag": "replace",
"from": "\\/",
"to": "."
}
]
"tags": [
{
"file": ".tags",
"initTagsCommand": "ghc-tags -c",
"refreshTagsCommand": "ghc-tags -c",
"completionsProvider": true,
"definitionsProvider": true,
"importsProvider": {
"importLinePattern": "import ${module} (${symbol})",
"matchFromFilepath": "([A-Z][A-Za-z0-9_']*)(\\/([A-Z][A-Za-z0-9_']*))*\\.hs",
"renderModuleName": [
{
"tag": "replace",
"from": "\\.hs",
"to": ""
},
{
"tag": "replace",
"from": "\\/",
"to": "."
}
]
}
},
{
"file": "package-deps-index.tsv",
"completionsProvider": true,
"importsProvider": {
"importLinePattern": "import ${module}",
"matchFromFilepath": "(.*)",
"renderModuleName": [
{
"tag": "replace",
"from": "(Data\\.ByteString.*)",
"to": "$1 qualified as BS"
},
{
"tag": "replace",
"from": "(Data\\.Text.*)",
"to": "$1 qualified as T"
},
{
"tag": "replace",
"from": "(Data\\.ByteString.*Lazy.*) qualified as BS",
"to": "$1 qualified as BSL"
},
{
"tag": "replace",
"from": "(Data\\.Text.*Lazy.*) qualified as T",
"to": "$1 qualified as TL"
},
{
"tag": "replace",
"from": "(Data\\.Map.*)",
"to": "$1 qualified as M"
},
{
"tag": "replace",
"from": "(Data\\.Set.*)",
"to": "$1 qualified as S"
},
{
"tag": "replace",
"from": "(Data\\.Vector.*)",
"to": "$1 qualified as V"
}
]
}
}
},
],
"annotations": [
{
"file": "ghc-out.json",
Expand Down Expand Up @@ -125,6 +172,16 @@ export type TConfig = {
* If `true`, Alloglot will log more output.
*/
verboseOutput?: boolean

/**
* If `true`, Alloglot will merge `.vscode/alloglot.json` into its config.
*/
mergeConfigs?: boolean

/**
* Path to GNU Grep. Parsing tags files depends on GNU Grep. (BSD Grep is not supported.)
*/
grepPath?: string
}

/**
Expand Down Expand Up @@ -156,9 +213,9 @@ export type LanguageConfig = {
apiSearchUrl?: string

/**
* Configuration for using a tags file to suggest completions, definitions, or imports.
* A list of tags files to use to find definitions, suggest completions, or suggest imports.
*/
tags?: TagsConfig
tags?: Array<TagsConfig>

/**
* A list of files to watch for compiler-generated JSON output.
Expand Down
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,33 @@
"properties": {
"alloglot.activateCommand": {
"type": "string",
"description": "A shell command to run on activation. The command will run asynchronously. It will be killed (if it's still running) on deactivation."
"description": "A shell command to run on activation. The command will run asynchronously. It will be killed (if it's still running) on deactivation.",
"default": null
},
"alloglot.deactivateCommand": {
"type": "string",
"description": "A shell command to run on deactivation."
"description": "A shell command to run on deactivation.",
"default": null
},
"alloglot.verboseOutput": {
"type": "boolean",
"description": "If `true`, Alloglot will log more output."
"description": "If `true`, Alloglot will log more output.",
"default": null
Comment on lines -62 to +65
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue preventing the fallback from being used is that VS Code defaults boolean config options to false if the package.json doesn't specify a different default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My config-loading logic saw that user-level config "existed" (incorrectly) and so ignored the fallback.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:argh:

},
"alloglot.mergeConfigs": {
"type": "boolean",
"description": "If `true`, Alloglot will merge `.vscode/alloglot.json` into its config."
"description": "If `true`, Alloglot will merge `.vscode/alloglot.json` into its config.",
"default": null
},
"alloglot.grepPath": {
"type": "string",
"description": "Path to GNU Grep. Parsing tags files depends on GNU Grep. (BSD Grep is not supported.)"
"description": "Path to GNU Grep. Parsing tags files depends on GNU Grep. (BSD Grep is not supported.)",
"default": null
},
"alloglot.languages": {
"type": "array",
"description": "An array of language configurations. See README.md for schema.",
"default": null,
"items": {
"type": "object",
"required": [
Expand Down
24 changes: 23 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,31 @@ export namespace HierarchicalOutputChannel {
* Spawned channels will have the same name as the parent channel, so messages appear in the same output window.
*/
export function make(name: string): IHierarchicalOutputChannel {
return addTimestamps(makeNoTimestamps(name))
}

function makeNoTimestamps(name: string): IHierarchicalOutputChannel {
return promote([], vscode.window.createOutputChannel(name))
}

function addTimestamps(output: IHierarchicalOutputChannel): IHierarchicalOutputChannel {
return {
...output,

append(value: string) {
output.append(`[${timestamp()}] ${value}`)
},

appendLine(value: string) {
output.appendLine(`[${timestamp()}] ${value}`)
}
}
}

function timestamp(): string {
return new Date().toJSON().split('T')[1].replace(/\.\d*Z/, ' UTC')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dates in vanilla JS, oh what fun.

}

function addPrefix(output: vscode.OutputChannel, prefix: string): vscode.OutputChannel {
return {
...output,
Expand Down Expand Up @@ -135,7 +157,7 @@ export namespace HierarchicalOutputChannel {
split() {
const name = [output.name, ...prefixPath].join('-')
output.appendLine(alloglot.ui.splittingOutputChannel(name))
return make(name)
return makeNoTimestamps(name)
}
}
}
Expand Down
Loading