From fd86eb885c5d7948aac85fe98e143cdf21897b3a Mon Sep 17 00:00:00 2001 From: Nexoniarz Date: Fri, 9 Oct 2026 00:36:44 +0200 Subject: [PATCH] CMake: enable C (Homebrew LLVM's config needs it); Kate: highlighting, language server setup, install script Co-Authored-By: Claude Opus 5.5 --- CMakeLists.txt | 2 +- editors/kate/README.md | 41 +++++++++ editors/kate/finch.xml | 165 ++++++++++++++++++++++++++++++++++++ editors/kate/install.sh | 27 ++++++ editors/kate/lspclient.json | 9 ++ examples/OpenGL.fn | 29 +++++++ 6 files changed, 272 insertions(+), 1 deletion(-) create mode 100644 editors/kate/README.md create mode 100644 editors/kate/finch.xml create mode 100755 editors/kate/install.sh create mode 100644 editors/kate/lspclient.json create mode 100644 examples/OpenGL.fn diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fab202..8ac9328 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.20) -project(finch VERSION 2.3.0 LANGUAGES CXX) +project(finch VERSION 2.3.0 LANGUAGES C CXX) # C: LLVM's CMake config checks C headers on some systems set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/editors/kate/README.md b/editors/kate/README.md new file mode 100644 index 0000000..f1a3fae --- /dev/null +++ b/editors/kate/README.md @@ -0,0 +1,41 @@ +# Finch in Kate + +Syntax highlighting and the Finch language server for **Kate** (and KWrite / KDevelop, which share +Kate's highlighting engine). + +## Install + +```sh +editors/kate/install.sh +``` + +It copies `finch.xml` to `~/.local/share/org.kde.syntax-highlighting/syntax/` and adds a `finch` entry +to `~/.config/kate/lspclient/settings.json` (your other servers are kept). Then: + +1. Restart Kate. +2. **Settings → Configure Kate → Plugins**: enable **LSP Client** (and **Build & Run** for the next part). +3. Make sure `finch` is on your PATH (`finch version` in a terminal). + +Open a `.fch` file: errors appear as you type, hovering shows types and docs, `Ctrl+Space` completes +(fields and methods after `.`), **Go to Definition** and the **Symbols** outline work, and parameter hints +pop up inside `(…)`. + +## Running and building + +**Build & Run** plugin → **Add target set**, then add targets with these commands (the working folder +can be `%d`, the folder of the current file): + +| Target | Command | +|---|---| +| Run | `finch run %f` | +| Build | `finch build %f` | + +Give one of them a shortcut in **Settings → Configure Keyboard Shortcuts** (search for "Build"). Finch's +errors have the `file:line:column: error:` form, so Kate lists them and jumps to the line on click. + +## By hand + +- Highlighting: copy `finch.xml` into `~/.local/share/org.kde.syntax-highlighting/syntax/` + (Windows: `%LOCALAPPDATA%\org.kde.syntax-highlighting\syntax\`). +- Language server: **Settings → Configure Kate → LSP Client → User Server Settings**, and add the + `finch` entry from `lspclient.json` inside `"servers"`. diff --git a/editors/kate/finch.xml b/editors/kate/finch.xml new file mode 100644 index 0000000..b13b876 --- /dev/null +++ b/editors/kate/finch.xml @@ -0,0 +1,165 @@ + + + + + + + fn + struct + + + if + else + while + for + in + break + continue + return + defer + + + import + link + + + true + false + null + + + int + float + bool + char + str + ptr + i8 + i16 + i32 + i64 + u8 + u16 + u32 + u64 + f32 + f64 + + + print + input + read_file + write_file + file_exists + delete_file + shell + exit + addr + new + free + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/editors/kate/install.sh b/editors/kate/install.sh new file mode 100755 index 0000000..4d0fd9c --- /dev/null +++ b/editors/kate/install.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Installs Finch support for Kate (also KWrite and KDevelop): +# - syntax highlighting: ~/.local/share/org.kde.syntax-highlighting/syntax/finch.xml +# - the language server: adds "finch" to ~/.config/kate/lspclient/settings.json +# Then restart Kate and enable Settings → Configure Kate → Plugins → "LSP Client". +set -eu +here="$(cd "$(dirname "$0")" && pwd)" +data="${XDG_DATA_HOME:-$HOME/.local/share}/org.kde.syntax-highlighting/syntax" +conf="${XDG_CONFIG_HOME:-$HOME/.config}/kate/lspclient" +mkdir -p "$data" "$conf" +cp "$here/finch.xml" "$data/finch.xml" +echo "highlighting: $data/finch.xml" + +# merge into the user's LSP settings instead of replacing them +python3 - "$conf/settings.json" "$here/lspclient.json" <<'PY' +import json, os, sys +path, ours = sys.argv[1], json.load(open(sys.argv[2])) +cur = {} +if os.path.exists(path) and os.path.getsize(path) > 0: + cur = json.load(open(path)) +cur.setdefault("servers", {}).update(ours["servers"]) +with open(path, "w") as f: + json.dump(cur, f, indent=4) + f.write("\n") +print("language server: " + path) +PY +command -v finch > /dev/null || echo "note: 'finch' isn't on your PATH yet; Kate starts the language server with 'finch lsp'" diff --git a/editors/kate/lspclient.json b/editors/kate/lspclient.json new file mode 100644 index 0000000..a05ec44 --- /dev/null +++ b/editors/kate/lspclient.json @@ -0,0 +1,9 @@ +{ + "servers": { + "finch": { + "command": ["finch", "lsp"], + "url": "https://github.com/Nexoniarz/Finch", + "highlightingModeRegex": "^Finch$" + } + } +} diff --git a/examples/OpenGL.fn b/examples/OpenGL.fn new file mode 100644 index 0000000..a9afb95 --- /dev/null +++ b/examples/OpenGL.fn @@ -0,0 +1,29 @@ +import "GLFW/glfw3.h" + +fn main() { + if glfwInit() == 0 { + print("Błąd: Nie udało się zainicjalizować GLFW!") + return + } + + win := glfwCreateWindow(800, 600, "lukas", null, null) + + if win == null { + print("Błąd: Nie udało się stworzyć okna!") + glfwTerminate() + return + } + + glfwMakeContextCurrent(win) + + while glfwWindowShouldClose(win) == 0 { + // 1. Obsługa klawiatury/myszki + glfwPollEvents() + + // 2. Podmiana bufora (wyświetlenie narysowanej klatki) + glfwSwapBuffers(win) + } + + glfwDestroyWindow(win) + glfwTerminate() +}