Skip to content

Commit

Permalink
🚀 Prepare for first release
Browse files Browse the repository at this point in the history
  • Loading branch information
ewen-lbh committed Apr 27, 2024
1 parent df41626 commit 37b80bf
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ go.work
hyprlang-lsp
parser/data/generate/generator
logs
*.vsix
hyprls
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"label": "go:compile",
"type": "shell",
"command": "just",
"args": ["install"]
"args": ["build-debug"]
}
]
}
45 changes: 45 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Contributing

Thanks for your interest in contributing to HyprLS :3!

## Setup your environment development

You just need to install:

- [Go](https://golang.org/doc/install)
- [Just](https://just.systems)

Then:

```sh
git clone --recurse-submodules https://github.com/your/fork
cd fork
just build
```

Then, you can build a binary locally with `just build`.
To create a "debug build" that logs all the requests, responses and server logs to files (useful for debugging), you can run `just build-debug`.

The debug binary is named `hyprls-debug` and the regular binary is named `hyprls`.

### VSCode

To develop the vscode extension, you'll also need:

- [VSCode](https://code.visualstudio.com/), really useful for debugging the extension, you just have to launch from the "start/debug" menu in the sidebar
- [Bun](https://bun.sh)

Then:

```sh
cd vscode
bun i
```

> **Note:** "Reloading" does not re-build the Go server, you'll need to kill the "Develoment Host Extension" window and kill the terminal that ran the `go:compile` task before launching again.
The VSCode dev environment is set up to use the debug binary in development. The path is absolute and hardcoded, so you may need to change it to where your debug binary is (check `vscode/src/extension.ts`).

## Commit names

We use the [gitmoji](https://gitmoji.dev/) convention for commit names.
19 changes: 17 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
serverLogsFilepath := `realpath ./logs/server.log`
latestTag := `git describe --tags --abbrev=0 || echo commit:$(git rev-parse --short HEAD)`

release tag:
jq '.version = "{{ tag }}"' < vscode/package.json | sponge vscode/package.json
git add vscode/package.json
git commit -m "Release {{ tag }}"
git tag -- {{ tag }}
cd vscode; bun vsce package; bun vsce publish
git push

run:
just build
Expand All @@ -8,11 +17,17 @@ build:
mkdir -p parser/data/sources
cp hyprland-wiki/pages/Configuring/*.md parser/data/sources/
go mod tidy
go build -ldflags "-X main.OutputServerLogs={{ serverLogsFilepath }}" -o hyprlang-lsp cmd/main.go
go build -ldflags "-X main.Version={{ latestTag }}" -o hyprls cmd/hyprls/main.go

build-debug:
mkdir -p parser/data/sources
cp hyprland-wiki/pages/Configuring/*.md parser/data/sources/
go mod tidy
go build -ldflags "-X main.OutputServerLogs={{ serverLogsFilepath }}" -o hyprlang-lsp cmd/hyprls/main.go

install:
just build
cp hyprlang-lsp ~/.local/bin/hyprls
cp hyprls ~/.local/bin/hyprls

parser-data:
#!/bin/bash
Expand Down
37 changes: 31 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# HyprLS (huge WIP rn)
# HyprLS

<table>
<tr>
Expand All @@ -14,24 +14,47 @@

A LSP server for Hyprland configuration files.

## Features

Not checked means planned / work in progress.

- [x] Auto-complete
- [x] Hover
- [ ] TODO: Documentation on hover of categories?
- [x] Go to definition
- [x] Color pickers
- [x] Document symbols
- [ ] Diagnostics
- [ ] Formatting
- [ ] Semantic highlighting

## Installation

### With `go install`

Right now you _have_ to build from source:
```sh
go install github.com/ewen-lbh/hyprls/cmd/hyprls@latest
```

### From source

- Required: [Just](https://just.systems) (`paru -S just` on Arch Linux (btw))

```sh
git clone --recurse-submodules git@github.com:ewen-lbh/hyprlang-lsp.git
cd hyprlang-lsp
git clone --recurse-submodules https://github.com/ewen-lbh/hyprls
cd hyprls
# installs the binary to ~/.local/bin.
# Make sure that directory exists and is in your PATH
just install
```

## Usage

Neovim example: add this to your `init.lua`:
### With Neovim

_Combine with [The tree-sitter grammar for Hyprlang](https://github.com/tree-sitter-grammars/tree-sitter-hyprlang) for syntax highlighting._

Add this to your `init.lua`:

```lua
-- Hyprlang LSP
Expand All @@ -50,4 +73,6 @@ vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, {

### VSCode

Go to Extensions > Install from VSIX... and select `vscode/vscode-hyprlang-0.0.1.vsix` from this repo.
_Combine with [FireBlast's Hyprlang extension](https://marketplace.visualstudio.com/items?itemName=fireblast.hyprlang-vscode) for syntax highlighting._

<!-- Go to Extensions > Install from VSIX... and select `vscode/vscode-hyprlang-X.X.X.vsix` from this repo. -->
File renamed without changes.
4 changes: 2 additions & 2 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ func (h Handler) Initialize(ctx context.Context, params *protocol.InitializePara
},
},
ServerInfo: &protocol.ServerInfo{
Name: "hyprlsp",
Version: "0.0.0",
Name: "hyprls",
Version: Version,
},
}, nil
}
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"go.uber.org/zap"
)

var Version string

func StartServer(logger *zap.Logger, logClientIn string) {
logger.Debug("starting server")
conn := jsonrpc2.NewConn(jsonrpc2.NewStream(&readWriteCloser{
Expand Down
7 changes: 4 additions & 3 deletions parser/data/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,12 @@ func htmlBetweenHeadingAndNextHeading(heading soup.Root, element soup.Root) stri
return ""
}

defer func() string {
defer func() {
if crash := recover(); crash != nil {
fmt.Fprintf(os.Stderr, "Panic while rendering %s\n", next.HTML())
if os.Getenv("DEBUG") != "" {
fmt.Fprintf(os.Stderr, "Panic while rendering %s\n", next.HTML())
}
}
return ""
}()

rendered := next.HTML()
Expand Down
4 changes: 2 additions & 2 deletions vscode/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# VSCode Extension for Ortfo
# VSCode Extension for Hyprland configuraiton files

## Installation

Requires [installing `ortfodb`](https://ortfo.org/db/getting-started#installation) and having in on your PATH.
Requires [installing `hyprls`](https://github.com/ewen-lbh/hyprls) and having in on your PATH.
19 changes: 15 additions & 4 deletions vscode/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "vscode-hyprlang",
"name": "vscode-hyprls",
"description": "VSCode extension for HyprLS",
"author": "Ewen Le Bihan <[email protected]>",
"license": "MIT",
Expand All @@ -14,9 +14,20 @@
"engines": {
"vscode": "^1.75.0"
},
"activationEvents": [
"onLanguage:plaintext"
],
"contributes": {
"languages": [{
"id": "hyprlang",
"aliases": ["HyprLang"],
"extensions": [".hl"],
"filenamePatterns": ["hypr*.conf"]
}],
"commands": [{
"category": "HyprLS",
"title": "Restart language server",
"command": "vscode-hyprls.restart-lsp"
}]
},
"activationEvents": [ "onLanguage:hyprlang" ],
"main": "./out/extension",
"scripts": {
"vscode:prepublish": "npm run compile",
Expand Down
12 changes: 9 additions & 3 deletions vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import { ExtensionContext, workspace } from "vscode"
import { commands, ExtensionContext, workspace } from "vscode"

import {
LanguageClient,
Expand Down Expand Up @@ -33,13 +33,19 @@ export function activate(context: ExtensionContext) {
// Options to control the language client
const clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: [{ scheme: "file", language: "plaintext" }],
outputChannelName: "hyprls",
documentSelector: [{ scheme: "file", language: "hyprlang" }],
outputChannelName: "HyprLS",
synchronize: {
fileEvents: workspace.createFileSystemWatcher("*.hl"),
},
}

context.subscriptions.push(
commands.registerCommand("vscode-hyprls.restart-lsp", () => {
client.restart()
})
)

// Create the language client and start the client.
client = new LanguageClient("hyprlang", "Hypr", serverOptions, clientOptions)

Expand Down

0 comments on commit 37b80bf

Please sign in to comment.