diff --git a/README.md b/README.md index e38fb984a..5969bc79a 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,26 @@ # Bash Language Server -Bash language server implementation based on [Tree Sitter][tree-sitter] and its [grammar for Bash][tree-sitter-bash] and supports [explainshell][explainshell] and [shellcheck][shellcheck]. +Bash language server that brings an IDE-like experience for bash scripts to most editors. This is based on the [Tree Sitter parser][tree-sitter-bash] and supports [explainshell][explainshell] and [shellcheck][shellcheck]. We strongly recommend that you install [shellcheck][shellcheck] to enable linting: https://github.com/koalaman/shellcheck#installing +Documentation around configuration can be found in the [config.ts](https://github.com/bash-lsp/bash-language-server/blob/main/server/src/config.ts) file. + ## Features -- [x] Jump to declaration -- [x] Find references -- [x] Code Outline & Show Symbols -- [x] Highlight occurrences -- [x] Code completion -- [x] Simple diagnostics reporting -- [x] Documentation for flags on hover -- [x] Workspace symbols -- [ ] Rename symbol +- Jump to declaration +- Find references +- Code Outline & Show Symbols +- Highlight occurrences +- Code completion +- Simple diagnostics reporting +- Documentation for symbols on hover +- Workspace symbols + +To be implemented: + +- Rename symbol +- Better jump to declaration and find references based on scope ## Installation @@ -28,7 +34,7 @@ On Fedora based distros: dnf install -y nodejs-bash-language-server ``` -If you encounter installation errors, ensure you have node version 12 or newer (`node --version`). +If you encounter installation errors, ensure you have node version 14 or newer (`node --version`). ### Clients diff --git a/server/README.md b/server/README.md index 3bb1544bb..c6f6da214 100644 --- a/server/README.md +++ b/server/README.md @@ -1,12 +1,3 @@ # Bash Language Server -Bash language server implementation based on [Tree Sitter][tree-sitter] and its [grammar for Bash][tree-sitter-bash]. Integrates with [explainshell][explainshell] and [shellcheck][shellcheck]. - -Documentation for environment variables can be found in the [config.ts][https://github.com/bash-lsp/bash-language-server/blob/main/server/src/config.ts] file. - -For more information see the GitHub repository: [bash-ide/bash-language-server][https://github.com/bash-lsp/bash-language-server] - -[tree-sitter]: https://github.com/tree-sitter/tree-sitter -[tree-sitter-bash]: https://github.com/tree-sitter/tree-sitter-bash -[explainshell]: https://explainshell.com/ -[shellcheck]: https://www.shellcheck.net/ +This folder holds the node server written in Typescript that implements the Language Server Protocol (LSP). diff --git a/server/package.json b/server/package.json index fb2b4b5e8..26582e062 100644 --- a/server/package.json +++ b/server/package.json @@ -29,7 +29,7 @@ "zod": "3.20.2" }, "scripts": { - "prepublishOnly": "cd ../ && yarn run compile" + "prepublishOnly": "cd ../ && yarn run compile && cp README.md server/" }, "devDependencies": { "@types/fuzzy-search": "2.1.2", diff --git a/server/src/__tests__/analyzer.test.ts b/server/src/__tests__/analyzer.test.ts index 230f41a0d..90461a7c0 100644 --- a/server/src/__tests__/analyzer.test.ts +++ b/server/src/__tests__/analyzer.test.ts @@ -1,3 +1,5 @@ +import { pathToFileURL } from 'node:url' + import { FIXTURE_DOCUMENT, FIXTURE_FOLDER, @@ -201,7 +203,7 @@ describe('findAllSourcedUris', () => { const newAnalyzer = new Analyzer({ console: connection.console, parser, - workspaceFolder: REPO_ROOT_FOLDER, + workspaceFolder: pathToFileURL(REPO_ROOT_FOLDER).href, }) await newAnalyzer.initiateBackgroundAnalysis({ backgroundAnalysisMaxFiles: defaultConfig.backgroundAnalysisMaxFiles, diff --git a/server/src/__tests__/server.test.ts b/server/src/__tests__/server.test.ts index d55a98b8d..301936351 100644 --- a/server/src/__tests__/server.test.ts +++ b/server/src/__tests__/server.test.ts @@ -1,5 +1,7 @@ -import * as Process from 'child_process' -import * as Path from 'path' +import * as Process from 'node:child_process' +import * as Path from 'node:path' +import { pathToFileURL } from 'node:url' + import * as LSP from 'vscode-languageserver/node' import { CodeAction } from 'vscode-languageserver/node' @@ -14,7 +16,7 @@ import LspServer from '../server' import { CompletionItemDataType } from '../types' async function initializeServer( - { rootPath }: { rootPath?: string } = { rootPath: FIXTURE_FOLDER }, + { rootPath }: { rootPath?: string } = { rootPath: pathToFileURL(FIXTURE_FOLDER).href }, ) { const diagnostics: Array = [] diff --git a/server/src/util/fs.ts b/server/src/util/fs.ts index ffac68f29..fe3278ee0 100644 --- a/server/src/util/fs.ts +++ b/server/src/util/fs.ts @@ -1,5 +1,7 @@ +import * as os from 'node:os' +import { fileURLToPath } from 'node:url' + import * as fastGlob from 'fast-glob' -import * as os from 'os' // from https://github.com/sindresorhus/untildify/blob/f85a087418aeaa2beb56fe2684fe3b64fc8c588d/index.js#L11 export function untildify(pathWithTilde: string): string { @@ -18,6 +20,10 @@ export async function getFilePaths({ rootPath: string maxItems: number }): Promise { + if (rootPath.startsWith('file://')) { + rootPath = fileURLToPath(rootPath) + } + const stream = fastGlob.stream([globPattern], { absolute: true, onlyFiles: true,