Skip to content

Commit

Permalink
Improve config completion and CLI logging
Browse files Browse the repository at this point in the history
  • Loading branch information
DervexDev committed Jun 18, 2024
1 parent 1f9d6fc commit 566e7f2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

## [Unreleased]

### Fixed

- Global configuration completion no longer suggests settings that already exist
- Argon no longer displays `npm` verbose information in notifications

## [2.0.6] - 2024-06-16

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/argon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function log(data: string, silent?: boolean) {
let output = undefined

for (const line of data.trim().split("\n")) {
const isVerbose = line.endsWith("]")
const isVerbose = line.endsWith("]") || !/^.{0,5}:/.test(line)

if (line.startsWith("ERROR")) {
logger.error(line, isVerbose)
Expand Down
24 changes: 21 additions & 3 deletions src/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ const SETTINGS = [
},
]

function hasSetting(document: vscode.TextDocument, setting: string) {
const text = document.getText()

if (text.includes(setting)) {
for (const line of text.split("\n")) {
if (line.includes(setting)) {
return !line.includes("#")
}
}
}

return false
}

export function start() {
const selector: vscode.DocumentSelector = {
language: "toml",
Expand All @@ -112,8 +126,12 @@ export function start() {
}

vscode.languages.registerCompletionItemProvider(selector, {
provideCompletionItems() {
return SETTINGS.map((setting) => {
provideCompletionItems(document) {
return SETTINGS.flatMap((setting) => {
if (hasSetting(document, setting.field)) {
return []
}

const item = new vscode.CompletionItem(
setting.field,
vscode.CompletionItemKind.Field,
Expand All @@ -122,7 +140,7 @@ export function start() {
item.insertText = new vscode.SnippetString(setting.value)
item.documentation = new vscode.MarkdownString(setting.doc)

return item
return [item]
})
},
})
Expand Down

0 comments on commit 566e7f2

Please sign in to comment.