Add language server executable
This commit is contained in:
@@ -10,8 +10,85 @@ The [package](https://www.npmjs.com/package/@actions/languageserver) contains Ty
|
|||||||
npm install @actions/languageserver
|
npm install @actions/languageserver
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To install the language server as a standalone CLI:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g @actions/languageserver
|
||||||
|
```
|
||||||
|
|
||||||
|
This makes the `actions-languageserver` command available globally.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
### Standalone CLI
|
||||||
|
|
||||||
|
After installing globally, you can run the language server directly:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
actions-languageserver --stdio
|
||||||
|
```
|
||||||
|
|
||||||
|
This starts the language server using stdio transport, which is the standard way for editors to communicate with language servers.
|
||||||
|
|
||||||
|
### In Neovim
|
||||||
|
|
||||||
|
Neovim 0.5+ has built-in LSP support. To use the Actions language server:
|
||||||
|
|
||||||
|
#### 1. Install the language server
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g @actions/languageserver
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. Set up filetype detection
|
||||||
|
|
||||||
|
Add this to your `init.lua` to detect GitHub Actions workflow files:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
vim.filetype.add({
|
||||||
|
pattern = {
|
||||||
|
[".*/%.github/workflows/.*%.ya?ml"] = "yaml.ghactions",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
This sets the filetype to `yaml.ghactions` for YAML files in `.github/workflows/`, allowing you to keep separate YAML LSP configurations if needed.
|
||||||
|
|
||||||
|
#### 3. Create the LSP configuration
|
||||||
|
|
||||||
|
Create `~/.config/nvim/lsp/actionsls.lua`:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
return {
|
||||||
|
cmd = { "actions-languageserver", "--stdio" },
|
||||||
|
filetypes = { "yaml.ghactions" },
|
||||||
|
root_markers = { ".git" },
|
||||||
|
init_options = {
|
||||||
|
-- Optional: provide a GitHub token for enhanced functionality
|
||||||
|
-- (e.g., repository-specific completions)
|
||||||
|
sessionToken = vim.fn.system("gh auth token"):gsub("%s+", ""),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 4. Enable the LSP
|
||||||
|
|
||||||
|
Add to your `init.lua`:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
vim.lsp.enable('actionsls')
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 5. Verify it's working
|
||||||
|
|
||||||
|
Open any `.github/workflows/*.yml` file and run:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
:checkhealth vim.lsp
|
||||||
|
```
|
||||||
|
|
||||||
|
You should see `actionsls` in the list of attached clients.
|
||||||
|
|
||||||
### Basic usage using `vscode-languageserver-node`
|
### Basic usage using `vscode-languageserver-node`
|
||||||
|
|
||||||
For the server, import the module. It detects whether it's running in a Node.js environment or a web worker and initializes the appropriate connection.
|
For the server, import the module. It detects whether it's running in a Node.js environment or a web worker and initializes the appropriate connection.
|
||||||
@@ -110,6 +187,27 @@ or to watch for changes
|
|||||||
npm run watch
|
npm run watch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Running the language server locally
|
||||||
|
|
||||||
|
After running
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build:cli
|
||||||
|
npm link
|
||||||
|
```
|
||||||
|
|
||||||
|
`actions-languageserver` will be available globally. You can start it with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
actions-languageserver --stdio
|
||||||
|
```
|
||||||
|
|
||||||
|
Once linked you can also watch for changes and rebuild automatically:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run watch:cli
|
||||||
|
```
|
||||||
|
|
||||||
### Test
|
### Test
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
Executable
+2
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
import "../dist/cli.bundle.cjs";
|
||||||
@@ -31,7 +31,8 @@
|
|||||||
"url": "https://github.com/actions/languageservices"
|
"url": "https://github.com/actions/languageservices"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc --build tsconfig.build.json",
|
"build": "tsc --build tsconfig.build.json && npm run build:cli",
|
||||||
|
"build:cli": "esbuild src/index.ts --bundle --platform=node --format=cjs --outfile=dist/cli.bundle.cjs",
|
||||||
"clean": "rimraf dist",
|
"clean": "rimraf dist",
|
||||||
"format": "prettier --write '**/*.ts'",
|
"format": "prettier --write '**/*.ts'",
|
||||||
"format-check": "prettier --check '**/*.ts'",
|
"format-check": "prettier --check '**/*.ts'",
|
||||||
@@ -40,7 +41,11 @@
|
|||||||
"prepublishOnly": "npm run build && npm run test",
|
"prepublishOnly": "npm run build && npm run test",
|
||||||
"test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest",
|
"test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest",
|
||||||
"test-watch": "NODE_OPTIONS=\"--experimental-vm-modules\" jest --watch",
|
"test-watch": "NODE_OPTIONS=\"--experimental-vm-modules\" jest --watch",
|
||||||
"watch": "tsc --build tsconfig.build.json --watch"
|
"watch": "tsc --build tsconfig.build.json --watch",
|
||||||
|
"watch:cli": "esbuild src/index.ts --bundle --platform=node --format=cjs --outfile=dist/cli.bundle.cjs --watch"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"actions-languageserver": "./bin/actions-languageserver"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/languageservice": "^0.3.25",
|
"@actions/languageservice": "^0.3.25",
|
||||||
@@ -55,12 +60,14 @@
|
|||||||
"node": ">= 18"
|
"node": ">= 18"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/**/*"
|
"dist/**/*",
|
||||||
|
"bin/**/*"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.0.3",
|
"@types/jest": "^29.0.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
||||||
"@typescript-eslint/parser": "^5.56.0",
|
"@typescript-eslint/parser": "^5.56.0",
|
||||||
|
"esbuild": "^0.27.1",
|
||||||
"eslint": "^8.36.0",
|
"eslint": "^8.36.0",
|
||||||
"eslint-config-prettier": "^8.8.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"eslint-plugin-prettier": "^4.2.1",
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
|
|||||||
Generated
+203
-1589
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user