bash-language-server
Advanced tools
Comparing version 1.11.0 to 1.11.1
# Bash Language Server | ||
## 1.11.1 | ||
* Workspace symbols are resolved using fuzzy search (not just starting with it) | ||
## 1.11.0 | ||
* Support for workspace symbols (https://github.com/mads-hartmann/bash-language-server/pull/195) | ||
* Support for workspace symbols (https://github.com/bash-lsp/bash-language-server/pull/195) | ||
## 1.10.0 | ||
* Improved completion handler and support auto-completion and documentation for [bash reserved words](https://www.gnu.org/software/bash/manual/html_node/Reserved-Word-Index.html) (https://github.com/mads-hartmann/bash-language-server/pull/192) | ||
* Improved completion handler and support auto-completion and documentation for [bash reserved words](https://www.gnu.org/software/bash/manual/html_node/Reserved-Word-Index.html) (https://github.com/bash-lsp/bash-language-server/pull/192) | ||
* Upgrade tree-sitter | ||
@@ -33,8 +37,8 @@ | ||
* Switch to tree-sitter-wasm instead of tree-sitter (native bindings) to support node 12 and to ease installation (https://github.com/mads-hartmann/bash-language-server/pull/147) | ||
* Switch to tree-sitter-wasm instead of tree-sitter (native bindings) to support node 12 and to ease installation (https://github.com/bash-lsp/bash-language-server/pull/147) | ||
## 1.5.6 | ||
* Fix crash when parsing directories with `.sh` suffix (https://github.com/mads-hartmann/bash-language-server/pull/111) | ||
* Fix invalid LSP response (https://github.com/mads-hartmann/bash-language-server/pull/110) | ||
* Fix crash when parsing directories with `.sh` suffix (https://github.com/bash-lsp/bash-language-server/pull/111) | ||
* Fix invalid LSP response (https://github.com/bash-lsp/bash-language-server/pull/110) | ||
@@ -48,3 +52,3 @@ ## 1.5.5 | ||
* Fix explain shell configuration issue (https://github.com/mads-hartmann/bash-language-server/issues/80) | ||
* Fix explain shell configuration issue (https://github.com/bash-lsp/bash-language-server/issues/80) | ||
@@ -105,10 +109,10 @@ ## 1.5.3 | ||
[17]: https://github.com/mads-hartmann/bash-language-server/pull/17 | ||
[28]: https://github.com/mads-hartmann/bash-language-server/pull/28 | ||
[31]: https://github.com/mads-hartmann/bash-language-server/pull/31 | ||
[33]: https://github.com/mads-hartmann/bash-language-server/pull/33 | ||
[40]: https://github.com/mads-hartmann/bash-language-server/pull/40 | ||
[45]: https://github.com/mads-hartmann/bash-language-server/pull/45 | ||
[58]: https://github.com/mads-hartmann/bash-language-server/pull/58 | ||
[17]: https://github.com/bash-lsp/bash-language-server/pull/17 | ||
[28]: https://github.com/bash-lsp/bash-language-server/pull/28 | ||
[31]: https://github.com/bash-lsp/bash-language-server/pull/31 | ||
[33]: https://github.com/bash-lsp/bash-language-server/pull/33 | ||
[40]: https://github.com/bash-lsp/bash-language-server/pull/40 | ||
[45]: https://github.com/bash-lsp/bash-language-server/pull/45 | ||
[58]: https://github.com/bash-lsp/bash-language-server/pull/58 | ||
[chrismwendt]: https://github.com/chrismwendt | ||
[maximbaz]: https://github.com/maximbaz |
@@ -33,3 +33,3 @@ import * as LSP from 'vscode-languageserver'; | ||
/** | ||
* Find all the symbols matching the query. | ||
* Find all the symbols matching the query using fuzzy search. | ||
*/ | ||
@@ -70,3 +70,4 @@ search(query: string): LSP.SymbolInformation[]; | ||
wordAtPoint(uri: string, line: number, column: number): string | null; | ||
private getAllSymbols; | ||
private symbolKindToCompletionKind; | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -12,2 +13,3 @@ }); | ||
const fs = require("fs"); | ||
const FuzzySearch = require("fuzzy-search"); | ||
const request = require("request-promise-native"); | ||
@@ -89,15 +91,9 @@ const URI = require("urijs"); | ||
/** | ||
* Find all the symbols matching the query. | ||
* Find all the symbols matching the query using fuzzy search. | ||
*/ | ||
search(query) { | ||
const symbols = []; | ||
Object.keys(this.uriToDeclarations).forEach(uri => { | ||
Object.keys(this.uriToDeclarations[uri]).forEach(name => { | ||
if (name.startsWith(query)) { | ||
const declarationNames = this.uriToDeclarations[uri][name] || []; | ||
declarationNames.forEach(d => symbols.push(d)); | ||
} | ||
}); | ||
const searcher = new FuzzySearch(this.getAllSymbols(), ['name'], { | ||
caseSensitive: true, | ||
}); | ||
return symbols; | ||
return searcher.search(query); | ||
} | ||
@@ -127,3 +123,3 @@ getExplainshellDocumentation({ params, endpoint, }) { | ||
// VS Code output). | ||
const response = Object.assign({}, explainshellResponse, { cmd, cmdType: interestingNode.type }); | ||
const response = Object.assign(Object.assign({}, explainshellResponse), { cmd, cmdType: interestingNode.type }); | ||
if (explainshellResponse.status === 'error') { | ||
@@ -133,3 +129,3 @@ return response; | ||
else if (!explainshellResponse.matches) { | ||
return Object.assign({}, response, { status: 'error' }); | ||
return Object.assign(Object.assign({}, response), { status: 'error' }); | ||
} | ||
@@ -143,5 +139,5 @@ else { | ||
if (!helpHTML) { | ||
return Object.assign({}, response, { status: 'error' }); | ||
return Object.assign(Object.assign({}, response), { status: 'error' }); | ||
} | ||
return Object.assign({}, response, { helpHTML }); | ||
return Object.assign(Object.assign({}, response), { helpHTML }); | ||
} | ||
@@ -273,2 +269,13 @@ }); | ||
} | ||
getAllSymbols() { | ||
// NOTE: this could be cached, it takes < 1 ms to generate for a project with 250 bash files... | ||
const symbols = []; | ||
Object.keys(this.uriToDeclarations).forEach(uri => { | ||
Object.keys(this.uriToDeclarations[uri]).forEach(name => { | ||
const declarationNames = this.uriToDeclarations[uri][name] || []; | ||
declarationNames.forEach(d => symbols.push(d)); | ||
}); | ||
}); | ||
return symbols; | ||
} | ||
symbolKindToCompletionKind(s) { | ||
@@ -275,0 +282,0 @@ switch (s) { |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -8,0 +9,0 @@ }); |
@@ -12,2 +12,5 @@ "use strict"; | ||
class Executables { | ||
constructor(executables) { | ||
this.executables = new Set(executables); | ||
} | ||
/** | ||
@@ -24,5 +27,2 @@ * @param path is expected to to be a ':' separated list of paths. | ||
} | ||
constructor(executables) { | ||
this.executables = new Set(executables); | ||
} | ||
/** | ||
@@ -29,0 +29,0 @@ * Find all programs in your PATH |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -8,0 +9,0 @@ }); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -8,0 +9,0 @@ }); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -226,3 +227,3 @@ }); | ||
this.connection.console.log(`onCompletionResolve name=${name} type=${type}`); | ||
const getMarkdownCompletionItem = (doc) => (Object.assign({}, item, { | ||
const getMarkdownCompletionItem = (doc) => (Object.assign(Object.assign({}, item), { | ||
// LSP.MarkupContent | ||
@@ -229,0 +230,0 @@ documentation: { |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -8,0 +9,0 @@ }); |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "1.11.0", | ||
"version": "1.11.1", | ||
"publisher": "mads-hartmann", | ||
@@ -16,3 +16,3 @@ "main": "./out/server.js", | ||
"type": "git", | ||
"url": "https://github.com/mads-hartmann/bash-language-server" | ||
"url": "https://github.com/bash-lsp/bash-language-server" | ||
}, | ||
@@ -23,2 +23,3 @@ "engines": { | ||
"dependencies": { | ||
"fuzzy-search": "^3.2.1", | ||
"glob": "^7.1.6", | ||
@@ -38,2 +39,3 @@ "request": "^2.83.0", | ||
"devDependencies": { | ||
"@types/fuzzy-search": "^2.1.0", | ||
"@types/glob": "^7.1.1", | ||
@@ -40,0 +42,0 @@ "@types/request-promise-native": "^1.0.17", |
@@ -10,2 +10,2 @@ # Bash Language Server | ||
[tree-sitter-bash]: https://github.com/tree-sitter/tree-sitter-bash | ||
[repo]: https://github.com/mads-hartmann/bash-language-server | ||
[repo]: https://github.com/bash-lsp/bash-language-server |
@@ -141,28 +141,39 @@ import * as lsp from 'vscode-languageserver' | ||
const result = await onWorkspaceSymbol( | ||
{ | ||
query: 'npm_config_log', | ||
}, | ||
{} as any, | ||
) | ||
async function lookupAndExpectNpmConfigLoglevelResult(query: string) { | ||
const result = await onWorkspaceSymbol( | ||
{ | ||
query, | ||
}, | ||
{} as any, | ||
) | ||
expect(result).toBeDefined() | ||
expect(result).toEqual([ | ||
{ | ||
kind: expect.any(Number), | ||
location: { | ||
range: { end: { character: 27, line: 40 }, start: { character: 0, line: 40 } }, | ||
uri: expect.stringContaining('/testing/fixtures/install.sh'), | ||
expect(result).toEqual([ | ||
{ | ||
kind: expect.any(Number), | ||
location: { | ||
range: { | ||
end: { character: 27, line: 40 }, | ||
start: { character: 0, line: 40 }, | ||
}, | ||
uri: expect.stringContaining('/testing/fixtures/install.sh'), | ||
}, | ||
name: 'npm_config_loglevel', | ||
}, | ||
name: 'npm_config_loglevel', | ||
}, | ||
{ | ||
kind: expect.any(Number), | ||
location: { | ||
range: { end: { character: 31, line: 48 }, start: { character: 2, line: 48 } }, | ||
uri: expect.stringContaining('/testing/fixtures/install.sh'), | ||
{ | ||
kind: expect.any(Number), | ||
location: { | ||
range: { | ||
end: { character: 31, line: 48 }, | ||
start: { character: 2, line: 48 }, | ||
}, | ||
uri: expect.stringContaining('/testing/fixtures/install.sh'), | ||
}, | ||
name: 'npm_config_loglevel', | ||
}, | ||
name: 'npm_config_loglevel', | ||
}, | ||
]) | ||
]) | ||
} | ||
await lookupAndExpectNpmConfigLoglevelResult('npm_config_loglevel') // exact | ||
await lookupAndExpectNpmConfigLoglevelResult('config_log') // in the middle | ||
await lookupAndExpectNpmConfigLoglevelResult('npmloglevel') // fuzzy | ||
}) | ||
@@ -169,0 +180,0 @@ |
import * as fs from 'fs' | ||
import * as FuzzySearch from 'fuzzy-search' | ||
import * as request from 'request-promise-native' | ||
@@ -122,15 +123,9 @@ import * as URI from 'urijs' | ||
/** | ||
* Find all the symbols matching the query. | ||
* Find all the symbols matching the query using fuzzy search. | ||
*/ | ||
public search(query: string): LSP.SymbolInformation[] { | ||
const symbols: LSP.SymbolInformation[] = [] | ||
Object.keys(this.uriToDeclarations).forEach(uri => { | ||
Object.keys(this.uriToDeclarations[uri]).forEach(name => { | ||
if (name.startsWith(query)) { | ||
const declarationNames = this.uriToDeclarations[uri][name] || [] | ||
declarationNames.forEach(d => symbols.push(d)) | ||
} | ||
}) | ||
const searcher = new FuzzySearch(this.getAllSymbols(), ['name'], { | ||
caseSensitive: true, | ||
}) | ||
return symbols | ||
return searcher.search(query) | ||
} | ||
@@ -375,2 +370,16 @@ | ||
private getAllSymbols(): LSP.SymbolInformation[] { | ||
// NOTE: this could be cached, it takes < 1 ms to generate for a project with 250 bash files... | ||
const symbols: LSP.SymbolInformation[] = [] | ||
Object.keys(this.uriToDeclarations).forEach(uri => { | ||
Object.keys(this.uriToDeclarations[uri]).forEach(name => { | ||
const declarationNames = this.uriToDeclarations[uri][name] || [] | ||
declarationNames.forEach(d => symbols.push(d)) | ||
}) | ||
}) | ||
return symbols | ||
} | ||
private symbolKindToCompletionKind(s: LSP.SymbolKind): LSP.CompletionItemKind { | ||
@@ -377,0 +386,0 @@ switch (s) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
543753
3011
8
5
+ Addedfuzzy-search@^3.2.1
+ Addedfuzzy-search@3.2.1(transitive)