Compare commits
31 Commits
b5c49f4277
...
experiment
| Author | SHA1 | Date | |
|---|---|---|---|
|
c683754d49
|
|||
|
e9d164d769
|
|||
|
5b66f503e4
|
|||
|
d79ea4e75a
|
|||
|
dd474cc38d
|
|||
|
a62d4a18a8
|
|||
|
e3fc5323df
|
|||
|
15cef855d6
|
|||
|
59fe554259
|
|||
|
8b93b955e8
|
|||
|
f77caf604f
|
|||
|
8b49ab6085
|
|||
|
154e557339
|
|||
|
04cce4224e
|
|||
|
410222b82a
|
|||
|
f93afc0d14
|
|||
|
86d5b7a021
|
|||
|
78949bc770
|
|||
|
17a04bdddc
|
|||
|
eafed64bea
|
|||
|
9757a8db31
|
|||
|
cef357ffdc
|
|||
|
515d5559a7
|
|||
|
1312c09501
|
|||
|
b018877c03
|
|||
|
e6f51d69b6
|
|||
|
6abdefa808
|
|||
|
cca0177929
|
|||
|
6dc0813b49
|
|||
|
81da75dc15
|
|||
|
fd894e4e9f
|
10
.clangd
10
.clangd
@@ -1,7 +1,9 @@
|
||||
CompileFlags:
|
||||
Add: [-I/home/syed/main/crib/include, -I/home/syed/main/crib/libs, c++20]
|
||||
Add: [
|
||||
-I/home/syed/main/crib/include,
|
||||
-I/home/syed/main/crib/libs,
|
||||
-I/home/syed/main/crib/libs/mruby/include,
|
||||
-std=c++23
|
||||
]
|
||||
Remove: []
|
||||
Compiler: clang++
|
||||
|
||||
HeaderInsertion:
|
||||
Policy: Never
|
||||
|
||||
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -1,2 +1 @@
|
||||
/libs/unicode_width/** linguist-vendored
|
||||
*.scm linguist-language=Tree-sitter-Query
|
||||
/libs/** linguist-vendored
|
||||
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -3,6 +3,7 @@
|
||||
*.a
|
||||
*.o
|
||||
*.so
|
||||
!libs/libruby/libruby.so
|
||||
*.yml
|
||||
|
||||
.vscode
|
||||
@@ -12,8 +13,10 @@ samples/tmp*
|
||||
build
|
||||
bin
|
||||
|
||||
grammar/.*.scm
|
||||
|
||||
.thinlto-cache/
|
||||
Gemfile*
|
||||
.ruby-lsp/
|
||||
|
||||
include/scripting/ruby_compiled.h
|
||||
|
||||
__old__
|
||||
|
||||
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -2,3 +2,7 @@
|
||||
path = libs/libgrapheme
|
||||
url = git://git.suckless.org/libgrapheme
|
||||
ignore = dirty
|
||||
[submodule "libs/mruby"]
|
||||
path = libs/mruby
|
||||
url = https://github.com/mruby/mruby.git
|
||||
ignore = dirty
|
||||
|
||||
47
Makefile
47
Makefile
@@ -9,25 +9,31 @@ TARGET_RELEASE := $(BIN_DIR)/crib
|
||||
PCH_DEBUG := $(OBJ_DIR)/debug/pch.h.gch
|
||||
PCH_RELEASE := $(OBJ_DIR)/release/pch.h.gch
|
||||
|
||||
GENERATED_HEADER := $(INCLUDE_DIR)/scripting/ruby_compiled.h
|
||||
|
||||
CCACHE := ccache
|
||||
CXX := $(CCACHE) clang++
|
||||
CC := $(CCACHE) musl-clang
|
||||
|
||||
CFLAGS_DEBUG :=\
|
||||
-std=c++20 -Wall -Wextra \
|
||||
-O0 -fno-inline -gsplit-dwarf\
|
||||
-g -fsanitize=address -fno-omit-frame-pointer\
|
||||
-O0 -fno-inline -gsplit-dwarf \
|
||||
-g -fno-omit-frame-pointer \
|
||||
-Wno-unused-command-line-argument \
|
||||
-I./include -I./libs
|
||||
-I./include -I./libs -I/home/syed/main/crib/libs/mruby/include
|
||||
|
||||
# C_SANITIZER := -fsanitize=address
|
||||
|
||||
CFLAGS_RELEASE :=\
|
||||
-std=c++20 -O3 -march=native \
|
||||
-fno-exceptions -fno-rtti -fstrict-aliasing \
|
||||
-static --target=x86_64-linux-musl \
|
||||
-std=c++20 -O3 -march=x86-64 -mtune=generic \
|
||||
-fno-rtti \
|
||||
-ffast-math -flto=thin \
|
||||
-fvisibility=hidden -fuse-ld=lld \
|
||||
-fvisibility=hidden \
|
||||
-fomit-frame-pointer -DNDEBUG -s \
|
||||
-mllvm -vectorize-loops \
|
||||
-fno-unwind-tables -fno-asynchronous-unwind-tables\
|
||||
-Wno-unused-command-line-argument \
|
||||
-I./include -I./libs
|
||||
-I./include -I./libs -I/home/syed/main/crib/libs/mruby/include
|
||||
|
||||
PCH_CFLAGS_DEBUG := $(CFLAGS_DEBUG) -x c++-header
|
||||
PCH_CFLAGS_RELEASE := $(CFLAGS_RELEASE) -x c++-header
|
||||
@@ -37,9 +43,13 @@ UNICODE_SRC := $(wildcard libs/unicode_width/*.c)
|
||||
UNICODE_OBJ_DEBUG := $(patsubst libs/unicode_width/%.c,$(OBJ_DIR)/debug/unicode_width/%.o,$(UNICODE_SRC))
|
||||
UNICODE_OBJ_RELEASE := $(patsubst libs/unicode_width/%.c,$(OBJ_DIR)/release/unicode_width/%.o,$(UNICODE_SRC))
|
||||
|
||||
LIBS := \
|
||||
libs/libgrapheme/libgrapheme.a \
|
||||
-lpcre2-8 -lmagic
|
||||
LIBS_RELEASE := \
|
||||
libs/libgrapheme/libgrapheme.a ./libs/mruby/build/host/lib/libmruby.a \
|
||||
-Wl,-Bstatic,--gc-sections -lpcre2-8
|
||||
|
||||
LIBS_DEBUG := \
|
||||
libs/libgrapheme/libgrapheme.a ./libs/mruby/build/host/lib/libmruby.a \
|
||||
-Wl,-Bdynamic -lpcre2-8
|
||||
|
||||
SRC := $(wildcard $(SRC_DIR)/**/*.cc) $(wildcard $(SRC_DIR)/*.cc)
|
||||
OBJ_DEBUG := $(patsubst $(SRC_DIR)/%.cc,$(OBJ_DIR)/debug/%.o,$(SRC))
|
||||
@@ -56,6 +66,9 @@ test: $(TARGET_DEBUG)
|
||||
|
||||
release: $(TARGET_RELEASE)
|
||||
|
||||
$(GENERATED_HEADER): $(INCLUDE_DIR)/syntax/tokens.def $(INCLUDE_DIR)/ruby/libcrib.rb src/ruby_compile.sh
|
||||
src/ruby_compile.sh
|
||||
|
||||
$(PCH_DEBUG): $(INCLUDE_DIR)/pch.h
|
||||
mkdir -p $(dir $@)
|
||||
$(CXX) $(PCH_CFLAGS_DEBUG) -o $@ $<
|
||||
@@ -66,27 +79,27 @@ $(PCH_RELEASE): $(INCLUDE_DIR)/pch.h
|
||||
|
||||
$(TARGET_DEBUG): $(PCH_DEBUG) $(OBJ_DEBUG) $(UNICODE_OBJ_DEBUG)
|
||||
mkdir -p $(BIN_DIR)
|
||||
$(CXX) $(CFLAGS_DEBUG) -o $@ $(OBJ_DEBUG) $(UNICODE_OBJ_DEBUG) $(LIBS)
|
||||
$(CXX) $(CFLAGS_DEBUG) $(C_SANITIZER) -o $@ $(OBJ_DEBUG) $(UNICODE_OBJ_DEBUG) $(LIBS_DEBUG)
|
||||
|
||||
$(TARGET_RELEASE): $(PCH_RELEASE) $(OBJ_RELEASE) $(UNICODE_OBJ_RELEASE)
|
||||
mkdir -p $(BIN_DIR)
|
||||
$(CXX) $(CFLAGS_RELEASE) -o $@ $(OBJ_RELEASE) $(UNICODE_OBJ_RELEASE) $(LIBS)
|
||||
$(CXX) $(CFLAGS_RELEASE) -o $@ $(OBJ_RELEASE) $(UNICODE_OBJ_RELEASE) $(LIBS_RELEASE)
|
||||
|
||||
$(OBJ_DIR)/debug/%.o: $(SRC_DIR)/%.cc $(PCH_DEBUG)
|
||||
$(OBJ_DIR)/debug/%.o: $(SRC_DIR)/%.cc $(PCH_DEBUG) $(GENERATED_HEADER)
|
||||
mkdir -p $(dir $@)
|
||||
$(CXX) $(CFLAGS_DEBUG) -include $(INCLUDE_DIR)/pch.h -MMD -MP -c $< -o $@
|
||||
|
||||
$(OBJ_DIR)/release/%.o: $(SRC_DIR)/%.cc $(PCH_RELEASE)
|
||||
$(OBJ_DIR)/release/%.o: $(SRC_DIR)/%.cc $(PCH_RELEASE) $(GENERATED_HEADER)
|
||||
mkdir -p $(dir $@)
|
||||
$(CXX) $(CFLAGS_RELEASE) -include $(INCLUDE_DIR)/pch.h -MMD -MP -c $< -o $@
|
||||
|
||||
$(OBJ_DIR)/debug/unicode_width/%.o: libs/unicode_width/%.c
|
||||
mkdir -p $(dir $@)
|
||||
$(CXX) $(CFLAGS_DEBUG) -MMD -MP -c $< -o $@
|
||||
$(CC) -MMD -MP -c $< -o $@
|
||||
|
||||
$(OBJ_DIR)/release/unicode_width/%.o: libs/unicode_width/%.c
|
||||
mkdir -p $(dir $@)
|
||||
$(CXX) $(CFLAGS_RELEASE) -MMD -MP -c $< -o $@
|
||||
$(CC) -MMD -MP -c $< -o $@
|
||||
|
||||
DEP_DEBUG += $(UNICODE_OBJ_DEBUG:.o=.d)
|
||||
DEP_RELEASE += $(UNICODE_OBJ_RELEASE:.o=.d)
|
||||
|
||||
191
README.md
191
README.md
@@ -12,6 +12,17 @@ It aims to be complete general purpose IDE.<br>
|
||||
(It is still very much a work in progress so a lot of things may seem incomplete)<br>
|
||||
For now it is just a single file editor. I plan to add a multi-file support with file pickers and tabs soon.<br>
|
||||
|
||||
## Installation
|
||||
|
||||
Binary can be installed with the following command:
|
||||
|
||||
```bash
|
||||
curl https://syedm.dev/crib | sh
|
||||
```
|
||||
|
||||
Currently only for Linux.<br>
|
||||
*Tested with arch linux and ubuntu and void*<br>
|
||||
|
||||
## Building
|
||||
|
||||
### Get started
|
||||
@@ -40,27 +51,45 @@ Make sure you have the following dependencies installed (apart from the standard
|
||||
#include <pcre2.h>
|
||||
```
|
||||
|
||||
* **libmagic**
|
||||
Install it so that you can include it in your code (most *nix systems have it installed):
|
||||
```cpp
|
||||
#include <magic.h>
|
||||
```
|
||||
|
||||
It also uses `xclip` at runtime for copying/pasting *(TODO: make it os portable)*.
|
||||
And any modern terminal should work fine - preferably `kitty` or `wezterm`.<br>
|
||||
|
||||
#### `./libs` folder
|
||||
|
||||
Some other dependancies like `libgrapheme` and `unicode_width` are added as submodules or copied.<br>
|
||||
`unicode_width` is compiled by the makefile so nothing to do there.<br>
|
||||
`libgrapheme` needs to be compiled using `make` in it's folder.<br>
|
||||
Some other dependancies are added as submodules or copied.<br>
|
||||
- `unicode_width` is compiled by the makefile so nothing to do there.<br>
|
||||
- `libgrapheme` needs to be compiled using `make` in it's folder.<br>
|
||||
- `mruby` needs to be compiled using `rake` in it's folder (needs ruby).<br>
|
||||
- Need to add the following lines to the `build_config/default.rb` file (in the `MRuby::Build.new` block)
|
||||
```ruby
|
||||
conf.gem :mgem => 'pure-regexp'
|
||||
conf.gem :mgem => 'env'
|
||||
conf.gem :mgem => 'process'
|
||||
conf.gem :mgem => 'marshal-c'
|
||||
```
|
||||
|
||||
#### config file
|
||||
|
||||
The config file is a ruby file placed in one of these places (in order, first one found will be used):
|
||||
- `$CRIB_CONFIG`
|
||||
- `$CRIB_CONFIG_DIR/crib.rb`
|
||||
- `$CRIB_CONFIG_DIR/main.rb`
|
||||
- `./crib.rb`
|
||||
- `$XDG_CONFIG_HOME/crib/crib.rb`
|
||||
- `$XDG_CONFIG_HOME/crib/main.rb`
|
||||
- `$XDG_CONFIG_HOME/crib.rb`
|
||||
- `$HOME/.config/crib/crib.rb`
|
||||
- `$HOME/.config/crib/main.rb`
|
||||
- `$HOME/.config/crib.rb`
|
||||
|
||||
#### LSPs
|
||||
|
||||
The following lsp's are supported and can be installed anywhere in your `$PATH`<br>
|
||||
Lsp's are defined in the `libcrib.rb` file and you can use your config file to add more.<br>
|
||||
|
||||
The following lsp's are added by default and can be installed anywhere in your `$PATH`<br>
|
||||
|
||||
* [clangd](https://clangd.llvm.org/)
|
||||
* [solargraph](https://solargraph.org/)
|
||||
* [ruby-lsp](https://shopify.github.io/ruby-lsp/)
|
||||
* [bash-language-server](https://github.com/bash-lsp/bash-language-server)
|
||||
* [vscode-css-language-server](https://github.com/hrsh7th/vscode-langservers-extracted)
|
||||
* [vscode-json-language-server](https://github.com/hrsh7th/vscode-langservers-extracted)
|
||||
@@ -81,14 +110,11 @@ The following lsp's are supported and can be installed anywhere in your `$PATH`<
|
||||
* [make-language-server](https://github.com/Freed-Wu/autotools-language-server)
|
||||
|
||||
> As it is still in development, some of these may not work as expected or that well.<br>
|
||||
> But for c/ruby/lua/python it should work fine (I test more with these).<br>
|
||||
> It should work even if the lsp is not installed but lsp features will not work.<br>
|
||||
> See `include/config.h` & `include/ts/decl.h` if you want to add your own lsp and/or tree-sitter grammar.<br>
|
||||
|
||||
#### Compiler
|
||||
|
||||
`g++` and `clang++` should both work fine but `c++20+` is required.
|
||||
The makefile uses `clang++` by default.<br>
|
||||
`g++` or `clang++` should work fine but `c++20+` is required.<br>
|
||||
Can remove `ccache` if you want from the makefile.<br>
|
||||
|
||||
#### Compliling
|
||||
@@ -100,9 +126,6 @@ make release
|
||||
### Running
|
||||
|
||||
Preferably add the `bin` folder to PATH or move `bin/crib` to somewhere in PATH.<br>
|
||||
But make sure that `scripts/` are at `../` relative to the binary or it will crash.<br>
|
||||
`scripts/init.sh` and `scripts/exit.sh` can be used to add hooks to the editor on startup and exit
|
||||
(Make sure to remove my `kitty` hooks from them if you want).<br>
|
||||
For some LSP's to work properly `crib` needs to be run from the root folder of the project. *To be fixed*<br>
|
||||
then do -<br>
|
||||
|
||||
@@ -110,127 +133,13 @@ then do -<br>
|
||||
crib ./filename.ext
|
||||
```
|
||||
|
||||
*If `filename.ext` does not exist, it will fail to load the editor - use `touch filename.ext` to create it - to be fixed*<br>
|
||||
*Try out with files in `samples/`*<br>
|
||||
*If `filename.ext` does not exist, it will be created*<br>
|
||||
*memory usage is average case 10MB + 2x size of file*<br>
|
||||
|
||||
## Keybindings
|
||||
|
||||
### Mouse Interactions
|
||||
|
||||
These interactions work globally or generally across the editor canvas.
|
||||
|
||||
| Action | Function |
|
||||
| --- | --- |
|
||||
| **Scroll Up/Down** | Scrolls the view. |
|
||||
| **Scroll Left/Right** | Moves the cursor left or right. |
|
||||
| **Left Click (Press)** | Moves cursor to position; resets selection. |
|
||||
| **Left Click (Double)** | Selects the **word** under the cursor (enters SELECT mode). |
|
||||
| **Left Click (Triple)** | Selects the **line** under the cursor (enters SELECT mode). |
|
||||
| **Left Click (Drag)** | Selects text (Character, Word, or Line based on initial click type). |
|
||||
| **Left Click (Release)** | If cursor and selection start are the same, returns to NORMAL mode. |
|
||||
|
||||
### Navigation (Global / Special Keys)
|
||||
|
||||
These keys work primarily in Normal mode but handle movement logic.
|
||||
|
||||
| Key | Modifier | Function |
|
||||
| --- | --- | --- |
|
||||
| **Arrows** (Up/Down/Left/Right) | None | Move cursor 1 step in that direction. |
|
||||
| **Arrows** (Up/Down) | `CTRL` | Move cursor **5 steps** in that direction. |
|
||||
| **Arrows** (Left/Right) | `CTRL` | Jump to the previous/next **word boundary**. |
|
||||
| **Arrows** (Up/Down) | `ALT` | **Move the current line** Up or Down. |
|
||||
| **Arrows** (Left/Right) | `ALT` | Move cursor **8 steps** in that direction. |
|
||||
|
||||
### NORMAL Mode
|
||||
|
||||
This is the default navigation and command mode.
|
||||
|
||||
| Key | Function |
|
||||
| --- | --- |
|
||||
| **i** | Enter **INSERT** mode (at current position). |
|
||||
| **a** | Enter **INSERT** mode (append: moves cursor right by 1 first). |
|
||||
| **s** or **v** | Enter **SELECT** mode (start character selection). |
|
||||
| **:** or **;** | Enter **RUNNER** mode (Command Bar). |
|
||||
| **u** | Select the **last line** of the file (Jumps to bottom). |
|
||||
| **h** | Trigger **LSP Hover** information for the symbol under cursor. |
|
||||
| **Ctrl + h** | Scroll the hover window **Up**. |
|
||||
| **Ctrl + l** | Scroll the hover window **Down**. |
|
||||
| **Ctrl + s** | **Save** the file. |
|
||||
| **Ctrl + d** | Scroll Page **Down** (1 unit). |
|
||||
| **Ctrl + u** | Scroll Page **Up** (1 unit). |
|
||||
| **p** | **Paste** from clipboard at cursor position (moves cursor to end of paste). |
|
||||
| **>** or **.** | **Indent** the current line. |
|
||||
| **<** or **,** | **Dedent** (un-indent) the current line. |
|
||||
| **Space** | Move cursor Right. |
|
||||
| **Backspace** (`0x7F`) | Move cursor Left. |
|
||||
| **Enter** (`\n`, `\r`) | Move cursor Down. |
|
||||
| **\| or \\** | Move cursor Up. |
|
||||
| **n** | Enter **JUMPER** mode (Set Bookmark). |
|
||||
| **m** | Enter **JUMPER** mode (Jump to Bookmark). |
|
||||
| **N** | Clear specific Jumper hook (logic attempts to clear hook at current line). |
|
||||
|
||||
### INSERT Mode
|
||||
|
||||
Used for typing text.
|
||||
|
||||
| Key | Function |
|
||||
| --- | --- |
|
||||
| **Esc** (`0x1B`) | Return to **NORMAL** mode. |
|
||||
| **Tab** (`\t`) | Inserts 2 spaces. |
|
||||
| **Enter** | Inserts newline + **Auto-indents** based on previous line/context. |
|
||||
| **Backspace** | Deletes previous character or auto-collapses empty pairs (e.g., `{` -> `}`). |
|
||||
| **Ctrl + w** | **Delete Previous Word**. |
|
||||
| **Del** | Delete character under cursor. |
|
||||
| **Ctrl + Del** | Delete **Next Word**. |
|
||||
| **Typing** | Inserts characters. |
|
||||
| **Ctrl + Shift + v or as configured in your terminal** | System pasting. |
|
||||
| **{ ( [ " '** | Auto-inserts closing pair (e.g., typing `{` inserts `{}`). |
|
||||
| **} ) ] " '** | If the next char matches the typed char, skip insertion (overwrite), otherwise insert. |
|
||||
|
||||
#### Autocompletion (Inside Insert Mode)
|
||||
|
||||
These function only if LSP and completion are active.
|
||||
|
||||
| Key | Function |
|
||||
| --- | --- |
|
||||
| **Ctrl + p** | Select **Next** completion item. |
|
||||
| **Ctrl + o** | Select **Previous** completion item. |
|
||||
| **Ctrl + \\** | **Accept** selected completion OR trigger new completion request. |
|
||||
| **Trigger Chars** | (e.g., `.`, `>`) Automatically triggers completion popup. |
|
||||
|
||||
### SELECT Mode
|
||||
|
||||
Used for highlighting text.
|
||||
|
||||
| Key | Function |
|
||||
| --- | --- |
|
||||
| **Esc**, **s**, **v** | Cancel selection and return to **NORMAL** mode. |
|
||||
| **y** | **Yank (Copy)** selection to clipboard → Return to Normal. |
|
||||
| **x** | **Cut** selection to clipboard → Return to Normal. |
|
||||
| **p** | **Paste** over selection (Replace text) → Return to Normal. |
|
||||
| **f** | **Fold** the selected range (collapses code) → Return to Normal. |
|
||||
|
||||
### JUMPER Mode
|
||||
|
||||
This mode uses a bookmarking system mapped to keyboard characters.
|
||||
|
||||
* **Entered via `n` (Set Mode):**
|
||||
* Pressing any key `!` through `~` assigns the current line number to that key.
|
||||
|
||||
* **Entered via `m` (Jump Mode):**
|
||||
* Pressing any key `!` through `~` jumps the cursor to the line previously assigned to that key.
|
||||
|
||||
### RUNNER Mode (Command Bar)
|
||||
|
||||
Activated by `:` or `;`.
|
||||
|
||||
| Key | Function |
|
||||
| --- | --- |
|
||||
| **Esc** | Cancel and return to **NORMAL** mode. |
|
||||
| **Enter** | Execute the typed command. |
|
||||
| **Left / Right** | Move cursor within the command bar. |
|
||||
| **Up / Down** | Intended for command history. (Not implemented) |
|
||||
| **Typing** | Insert characters into the command bar. (Not implemented) |
|
||||
TODO: add keybind information on how to set in config file
|
||||
and default / unchangeable keybinds
|
||||
|
||||
## Features Implemented
|
||||
|
||||
@@ -250,9 +159,9 @@ Activated by `:` or `;`.
|
||||
- hooks jumping (bookmarking)
|
||||
- color hex code highlighting
|
||||
- current line highlighting
|
||||
<!-- - TODO: current word under cursor highlighting -->
|
||||
- all instances of current word under cursor highlighting
|
||||
|
||||
#### syntax highlighting and filetype detection (using extention or libmagic) for:
|
||||
#### syntax highlighting and filetype detection for:
|
||||
- ruby
|
||||
<!-- TODO: -->
|
||||
<!-- - bash -->
|
||||
@@ -286,11 +195,13 @@ Activated by `:` or `;`.
|
||||
#### LSP-powered features:
|
||||
- diagnostics
|
||||
- autocompletion
|
||||
- hover docs (with markdown support)
|
||||
- hover docs
|
||||
- formatting support
|
||||
- Full file formatting on save
|
||||
- Ontype formatting when inserting special characters defined by the language server
|
||||
- *(few lsp's actually support this - try to configure a few more which can but need configuration and for others need to add support for external formatters)*
|
||||
- A list of all supported lsp's can be found [here](#lsps).
|
||||
- A list of some lsp's can be found [here](#lsps).
|
||||
- Any lsp can be added to the `config/main.rb` file.
|
||||
- Though not all might work well. Open an issue if you find a lsp that doesn't work well.
|
||||
|
||||
**A lot lot more to come**
|
||||
|
||||
170
TODO.md
170
TODO.md
@@ -2,41 +2,109 @@ Copyright 2025 Syed Daanish
|
||||
|
||||
# TODO
|
||||
|
||||
### Critical Fixes
|
||||
## Next few super long boring things to do::
|
||||
* redo lsp threads such that no mutex needed for any rope stuff (done)
|
||||
- Also make the classes own the methods in lsp (done)
|
||||
- This will mean that parsers/renderers and keystrokes will not need to be individually locked (done)
|
||||
- And so it will be much faster (done)
|
||||
- At which point the main thread can also be blocked on user input or lsp responses and still be faster
|
||||
* Add a superclass for editor called Window (which can be popup or tiled) (done)
|
||||
* Add a recursive tiling class for windows (done)
|
||||
* Handled by a single renderer that calls and renders each window (done)
|
||||
* Make editor's functions into its own methods (classify it) (done)
|
||||
- While at it
|
||||
- Seperate system functions into a class that branches to support local / ssh / server modes.
|
||||
- Even lsp shouldnt be directly controlled because it can branch on local and server modes
|
||||
- check wolfSSH stuff for remote editing
|
||||
- Thick and thin mode
|
||||
- thin mode only shares screen diffing over the network - uses server settings / themes
|
||||
- thick only shared fileio and lsp data with local used for all else - uses local settings / themes
|
||||
- Redo hooks as a engine of its own.
|
||||
- And factorize renderer into its own class (and make it just return an array of the render without knowing teh x,y)
|
||||
- which is just managed by the renderer
|
||||
- which is reused by scrollers/ensurers too
|
||||
- this will then allow inlay hints to be possible
|
||||
- and also make VAI easier to implement
|
||||
* Allow keybinds to be set in ruby
|
||||
|
||||
##### Check each lsp with each of the features implemented
|
||||
* then the fun part:
|
||||
* Then allow ruby code to create and handle windows as extentions
|
||||
* Then 3 inbuilt extentions being file manager, theme picker, tab selector
|
||||
|
||||
* Extentions can also be used as file openers (for like databases . diffing . images . audio etc)
|
||||
* Local cache for state management (like undo history, cursor positions etc) (location can be set in config)
|
||||
* make sure to write inbuilt extentions in cpp and not ruby
|
||||
* also move default bar and clipboard back into cpp
|
||||
* all lsp popups are no longer their own classes but instead windows (extention like) in popup mode
|
||||
|
||||
* also **fix click handling to send mouse unclick to the same focus window as the click And also for drag to be same as the starter**
|
||||
* skip opening binary files
|
||||
* apply themeing in bg log bar lsp popus etc. to keep visual consistency
|
||||
* searching/replace/Multi-Cursor (for just one lsp command for all) with pcre2 with regex (started by a slash) (disabled for large files)
|
||||
* add links support in xterm (kitty like clickable links)
|
||||
* And preprocess markdown in popups to be more like styled than just highlighted
|
||||
* In the ruby libcrib populate toplevel binding and file and dir and rubybuild stuff and other similar constants
|
||||
* in require_relative allow requiring without appending .rb if possible.
|
||||
* Possibly in the future limit memory usage by parser for larger files
|
||||
* Add a file picker suggestion while typing a path (including stuff like ~ and .. and $HOME etc)
|
||||
* allow opening directory after filemanger is sorted out.
|
||||
* commands to:
|
||||
change pwd
|
||||
load a rb file
|
||||
run a ruby command
|
||||
close a window etc.
|
||||
* [ ] Add mgems for most common things and a ruby library to allow combining true ruby with mruby
|
||||
* add command to set and use a file type at runtime
|
||||
* [ ] color alpha in ini files
|
||||
* [ ] Make warning before ctrl+q for saving
|
||||
* [ ] **LSP Bug:** Check why `fish-lsp` is behaving so off with completions filtering.
|
||||
* [ ] **File IO:** Normalize/validate unicode on file open (enforce UTF-8, handle other types gracefully).
|
||||
* [ ] **Critical Crash:** Fix bug where closing immediately while LSP is still loading hangs and then segfaults (especially on slow ones like fish-lsp where quick edits and exit can hang).
|
||||
* [ ] **Line move:** fix the move line functions to work without the calculations from folds as folds are removed.
|
||||
* [ ] **Modularize handle_events and renderer functions:** The function is over 700 lines with a lot of repeating blocks. Split into smaller functions.
|
||||
* [ ] **Editor Indentation Fix:** - Main : merger indentation with the parser for more accurate results.
|
||||
* [ ] Keep cache of language maps in engine to reduce lookup time.
|
||||
* [ ] In indents add function to support tab which indents if before any content and inserts a pure \t otherwise.
|
||||
* [ ] And backspace which undents if before any content.
|
||||
* [ ] Add block indentation support.
|
||||
* [ ] Ignore comments/strings from parser when auto-indenting.
|
||||
* [ ] These will dedent when the block immediately after them is dedented
|
||||
* [ ] Dont dedent if ending is valid starting is invalid but also empty
|
||||
* [ ] Just leave asis if starting is empty
|
||||
* [ ] **Readme:** Update readme to show indetation mechanics.
|
||||
* [ ] **LSP Bug:** Try to find out why emojis are breaking lsp edits. (check the ruby sample)
|
||||
* [ ] Support for stuff like bash \ and math operators in other languages and comma and line starting with a dot (like in ruby)
|
||||
etc.
|
||||
* [ ] **Readme:** Update readme to show ruby based config in detail.
|
||||
* [ ] **UI Refinement:**
|
||||
* [ ] Allow completion list to be scrolled; show only `x` max items.
|
||||
* [ ] Finish autocomplete box style functions.
|
||||
* [ ] **Documentation UI:** Capture `Ctrl+h` / `Ctrl+l` for scrolling documentation windows.
|
||||
* [ ] **Redo hooks and folding as proper engines**: With functions to checkstate/cursor like function and edits application.
|
||||
* [ ] Do trextmate like regex grammar parsing with lsp symbols for semantic highlighting.
|
||||
* Probably remove tre--sitter or just keep it for context tree.
|
||||
* Making bracket matching andignoring strings/comments easier.
|
||||
* remove tree-sitter mention from everywhere especially submodules
|
||||
* make it faster for line inserts/deletes too (treeify the vector)
|
||||
* Try to make all functions better now that folds have been purged
|
||||
* Cleanup syntax and renderer files
|
||||
* Fix ruby regexp not living across lines when edits are made
|
||||
* Cap line_tree data limit for large files and just store about a thousand previous lines maybe? (lazily loaded)
|
||||
|
||||
* for ruby regex use hueristic where is a space is seen after the / it is not a regexp
|
||||
* add `:j<n>` command to jump to line \<n> in the current file
|
||||
* and give warning for invalid commands
|
||||
* and upon escape clear the current command
|
||||
* allow multiline logging which captures the input entirely and y will copy the log and anything else will exit
|
||||
* it will then collapse to being the first line from the log only
|
||||
|
||||
* allow flushing functions in ruby to tell c++ to refresh keybinds/themes etc.
|
||||
|
||||
* [ ] **LSP:**
|
||||
support snippets in completion properly
|
||||
check::
|
||||
pull diagnostics for ruby-lsp
|
||||
lsp selection range - use to highlight start / end of range maybe?
|
||||
goto definiton
|
||||
signature help
|
||||
document symbol for the top bar maybe? (or workspace symbol)
|
||||
also setup workspaces
|
||||
Semantic highlighting
|
||||
Quick fixes
|
||||
Rename symbols
|
||||
|
||||
* Allow ruby to config lsp capabilities
|
||||
|
||||
* also try to fix why solargraph is the only one breaking on edits near emojis
|
||||
* ruby-lsp also supports erb so thats a plus
|
||||
|
||||
* the ruby should have an api to be able to draw windows and add mappings to them
|
||||
|
||||
* **Syntax highlighting**
|
||||
* ruby done!!
|
||||
* finish bash then do all the directive-like ones like jsonc (first to help with theme files) / toml / yaml / ini / nginx
|
||||
* then [ch](++)? then gdscript and python then erb then php
|
||||
* then markdown / html
|
||||
* then gitignore / gitattributes
|
||||
* then fish then sql then css and [jt]sx? then lua (make with type annotations for lsp results)
|
||||
* then haskell then gomod then go then rust
|
||||
|
||||
* [ ] **Undo/Redo:** Add support for undo/redo history.
|
||||
|
||||
@@ -44,29 +112,13 @@ Copyright 2025 Syed Daanish
|
||||
|
||||
* [ ] **Tree-sitter Indent:** Attempt to allow Tree-sitter to handle indentation if possible.
|
||||
|
||||
* [ ] **Scrolling:** Add logic where selecting at the end of the screen scrolls down (and vice versa).
|
||||
* *Implementation:* Update `main.cc` to send drag events to the selected editor.
|
||||
|
||||
|
||||
### UX
|
||||
|
||||
* [ ] **Editor word highlighter:** Do not recompute word under cursor if not changed.
|
||||
|
||||
* [ ] **Completion Filtering:**
|
||||
* [ ] Stop filtering case-sensitive.
|
||||
* [ ] Normalize completion edits if local filtering is used.
|
||||
|
||||
* [ ] **LSP Features:**
|
||||
* [ ] Add LSP jumping support (Go to Definition, Hover).
|
||||
* [ ] Add LSP rename support.
|
||||
* [ ] Handle snippets properly in autocomplete: use only the last word in signature when replacing and set cursor to the first one.
|
||||
|
||||
* [ ] **Basic Autocomplete:** Keep a list of words in the current buffer for non-LSP fallback.
|
||||
* [ ] **Language Support:**
|
||||
* [ ] Add ECMA to JS and make TSX support.
|
||||
* [ ] Add formatting for files where LSP doesn't provide it.
|
||||
* [ ] Redo grammar files properly (especially cpp).
|
||||
|
||||
|
||||
### Major Features
|
||||
|
||||
@@ -81,50 +133,24 @@ Copyright 2025 Syed Daanish
|
||||
* [ ] Allow search and place cursor at all matches.
|
||||
|
||||
* [ ] **Block Selection:**
|
||||
* [ ] Double-clicking a bracket selects the whole block (first time only) and sets mode to `WORD`.
|
||||
|
||||
* [ ] **Tree-sitter Context:**
|
||||
* [ ] Get code context from Tree-sitter.
|
||||
* [ ] Get node path of current cursor and add indicator bar (breadcrumbs).
|
||||
* [ ] Highlight block edges when cursor is on/in a bracket.
|
||||
|
||||
* [ ] Double-clicking a bracket selects the whole block and sets mode to `WORD`.
|
||||
|
||||
### Visuals, UI & Extensions?
|
||||
|
||||
*Focus: Aesthetics and external integrations.*
|
||||
|
||||
* [ ] **Status Bar:** Complete status bar and command runner.
|
||||
|
||||
* [ ] **Visual Aids:**
|
||||
* [ ] Expand color regex to match CSS colors in CSS files.
|
||||
* [ ] Add color picker/palette.
|
||||
* [ ] Add color picker/palette (as a floating extention).
|
||||
|
||||
* [ ] **Git:** Add Git integration (status, diffs).
|
||||
* [ ] **AI/Snippets:**
|
||||
* [ ] Add snippets support (LuaSnip/VSnip style).
|
||||
* [ ] Add Codeium/Copilot support (using VAI virtual text) as a test phase.
|
||||
|
||||
* [ ] **SQL:** Add SQL support (Viewer and Basic Editor).
|
||||
* [ ] **SQL:** Add SQL support (Viewer and Basic Editor) (as ruby extension).
|
||||
* [ ] **Prolly?:** Add Splash Screen / Minigame.
|
||||
|
||||
|
||||
### Optimizations & Fluff
|
||||
|
||||
* [ ] **Event Loop:**
|
||||
* [ ] Make the whole engine event-driven rather than clock-driven.
|
||||
* [ ] Mybe keep background thread with dirty flag.
|
||||
* [ ] But merge input and render into a single loop that only renders when input affects render or background thread needs refresh and try to couple multiple renders.
|
||||
* [ ] LSP and inputs should be blocking (lsp on its fd) and inputs in io/input.cc
|
||||
### Unimportant optimizations
|
||||
|
||||
* [ ] **Performance:**
|
||||
* [ ] Switch JSON parser to `RapidJSON` (or similar high-performance lib).
|
||||
* [ ] Decrease usage of `std::string` in UI, LSP, and warnings.
|
||||
* [ ] Decrease usage of `std::string` in UI, LSP, warnings etc.
|
||||
* [ ] Also for vectors into managed memory especially for completions/lsp-stuff.
|
||||
|
||||
* [ ] **Folding:** Redo folding system and its relation to `move_line_*` functions.
|
||||
|
||||
* [ ] **Grammars:**
|
||||
* [ ] Manually add redo SCM files (especially cpp/c/h).
|
||||
* [ ] Create `lua-typed` and `man pages` Tree-sitter grammars.
|
||||
|
||||
* [ ] **Repo Maintenance:** Once renderer is proven check commit `43f443e`.
|
||||
|
||||
98
config/main.rb
Normal file
98
config/main.rb
Normal file
@@ -0,0 +1,98 @@
|
||||
# Files can be insluded using Kernel#require_relative
|
||||
# but it can be called with binding as the second argument
|
||||
# skipping it will call it with global binding which is usually fine
|
||||
# Kernel#load can also be used
|
||||
|
||||
require_relative "theme"
|
||||
|
||||
# basic configuration
|
||||
# This can also be used to do speacail configs for different projects.
|
||||
# its ruby guys script whatever you want.
|
||||
|
||||
# puts "Loading main config..."
|
||||
|
||||
C.startup do
|
||||
puts "Starting crib..."
|
||||
end
|
||||
|
||||
C.shutdown do
|
||||
puts "Exiting crib..."
|
||||
end
|
||||
|
||||
# TODO: to be done once a proper api for binding and window drawing is made
|
||||
# The binds will be connected to either `editor` or windows where editor can
|
||||
# only use a preset set of stuff to bind while teh windows are purely custom
|
||||
# # this part uses dsl bindings to define the bind function
|
||||
# # Hopefully extend to give more context/power to bindings
|
||||
# # but try to keep simple for performance
|
||||
# # for default keybindings
|
||||
# C.bind [:normal, :select], :a => "insert_mode"
|
||||
# # for custom keybindings
|
||||
# C.bind :select, [:x, :c] do
|
||||
# puts "cut"
|
||||
# end
|
||||
# C.bind :jumper do
|
||||
# set [:x, :c] do
|
||||
# puts "jump to first bookmark"
|
||||
# end
|
||||
# end
|
||||
# # they can also be defined conditionally
|
||||
# # This code is just an example and doesnt actually work
|
||||
# if using_tmux?
|
||||
# bind :C-p do
|
||||
# system("tmux select-pane -U")
|
||||
# end
|
||||
# end
|
||||
|
||||
# This can, for example, be modified by user bindings during runtime
|
||||
# TODO: dynamic registration to actually be implemented once keybinds and extentions are implemented
|
||||
# A predefined list already exists and can be found in libcrib.rb
|
||||
# C.lsp_config["solargraph"] = ["stdio"]
|
||||
#
|
||||
# C.languages[:ruby] = {
|
||||
# color: 0xff8087,
|
||||
# symbol: " ",
|
||||
# extensions: ["rb"],
|
||||
# filenames: ["Gemfile"],
|
||||
# lsp: "solargraph"
|
||||
# }
|
||||
|
||||
C.line_endings = :auto_unix # or :unix or :windows or :auto_windows
|
||||
|
||||
C.extra_highlights do |_line, _idx|
|
||||
# the return can be an array of
|
||||
# [fg, bg. flags, start, end]
|
||||
# where fg and bg are integers (using 24 bit color)
|
||||
# and flags is a bitmask of bold/underline/italic etc
|
||||
# and start and end are integers strictly inside the line
|
||||
return []
|
||||
end
|
||||
|
||||
# The highlighter will be aplied to the language as long as the langauge is defined in C.languages
|
||||
C.highlighters[:string] = {
|
||||
parser: ->(line, state, line_idx) {
|
||||
# the return value is a hash
|
||||
# it contains the state and the highlights
|
||||
# state can be of any type but will be consistent between calls
|
||||
# initially nil is sent for uninitialized state the returned must be anything but nil
|
||||
# the same state can be used for multiple lines
|
||||
# the highlights can be an array of
|
||||
# [K_type, start, end]
|
||||
# K_type is a constant from the constants defined in libcrib.rb
|
||||
# for ex: for strings it would be Tokens::K_STRING or for numbers Tokens::K_NUMBER etc.
|
||||
# and start and end are integers strictly inside the line
|
||||
return {
|
||||
state: "",
|
||||
tokens: [
|
||||
# This will highlight the entire line as a string
|
||||
# Any wrong format will not be handled and lead to crashes
|
||||
{ type: Tokens::K_STRING, start: 0, end: line.length }
|
||||
]
|
||||
}
|
||||
},
|
||||
matcher: ->(state1, state2) {
|
||||
# returns true if the states are equal
|
||||
# And so would not need recomputation for further lines
|
||||
return state1 == state2
|
||||
}
|
||||
}
|
||||
36
config/theme.rb
Normal file
36
config/theme.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
# this can be modified by the user during runtime through keybindings
|
||||
# But i need to know how to ever read this value only when needed.
|
||||
# maybe i can write a function that notifies if theme maybe changed then reload
|
||||
# It can also be scripted to load different theme formats into a hash usable by crib
|
||||
C.theme = {
|
||||
:default => { fg: 0xEEEEEE },
|
||||
:shebang => { fg: 0x7DCFFF },
|
||||
:error => { fg: 0xEF5168 },
|
||||
:comment => { fg: 0xAAAAAA, italic: true },
|
||||
:string => { fg: 0xAAD94C },
|
||||
:escape => { fg: 0x7DCFFF },
|
||||
:interpolation => { fg: 0x7DCFFF },
|
||||
:regexp => { fg: 0xD2A6FF },
|
||||
:number => { fg: 0xE6C08A },
|
||||
# rubocop:disable Lint/BooleanSymbol
|
||||
:true => { fg: 0x7AE93C },
|
||||
:false => { fg: 0xEF5168 },
|
||||
# rubocop:enable Lint/BooleanSymbol
|
||||
:char => { fg: 0xFFAF70 },
|
||||
:keyword => { fg: 0xFF8F40 },
|
||||
:keywordoperator => { fg: 0xF07178 },
|
||||
:operator => { fg: 0xFFFFFF, italic: true },
|
||||
:function => { fg: 0xFFAF70 },
|
||||
:type => { fg: 0xF07178 },
|
||||
:constant => { fg: 0x7DCFFF },
|
||||
:variableinstance => { fg: 0x95E6CB },
|
||||
:variableglobal => { fg: 0xF07178 },
|
||||
:annotation => { fg: 0x7DCFFF },
|
||||
:directive => { fg: 0xFF8F40 },
|
||||
:label => { fg: 0xD2A6FF },
|
||||
:brace1 => { fg: 0xD2A6FF },
|
||||
:brace2 => { fg: 0xFFAFAF },
|
||||
:brace3 => { fg: 0xFFFF00 },
|
||||
:brace4 => { fg: 0x0FFF0F },
|
||||
:brace5 => { fg: 0xFF0F0F }
|
||||
}
|
||||
435
grammar/bash.scm
435
grammar/bash.scm
@@ -1,435 +0,0 @@
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"{"
|
||||
"}"
|
||||
"["
|
||||
"]"
|
||||
"[["
|
||||
"]]"
|
||||
"(("
|
||||
"))"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[
|
||||
";"
|
||||
";;"
|
||||
";&"
|
||||
";;&"
|
||||
"&"
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
[
|
||||
">"
|
||||
">>"
|
||||
"<"
|
||||
"<<"
|
||||
"&&"
|
||||
"|"
|
||||
"|&"
|
||||
"||"
|
||||
"="
|
||||
"+="
|
||||
"=~"
|
||||
"=="
|
||||
"!="
|
||||
"&>"
|
||||
"&>>"
|
||||
"<&"
|
||||
">&"
|
||||
">|"
|
||||
"<&-"
|
||||
">&-"
|
||||
"<<-"
|
||||
"<<<"
|
||||
".."
|
||||
"!"
|
||||
] @operator
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
[
|
||||
(string)
|
||||
(raw_string)
|
||||
(ansi_c_string)
|
||||
(heredoc_body)
|
||||
] @string
|
||||
|
||||
;; #E6C08A #000000 0 0 0 0 1
|
||||
[
|
||||
(heredoc_start)
|
||||
(heredoc_end)
|
||||
] @label
|
||||
|
||||
(variable_assignment
|
||||
(word) @variable)
|
||||
|
||||
(command
|
||||
argument: "$" @string) ; bare dollar
|
||||
|
||||
(concatenation
|
||||
(word) @string)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"if"
|
||||
"then"
|
||||
"else"
|
||||
"elif"
|
||||
"fi"
|
||||
"case"
|
||||
"in"
|
||||
"esac"
|
||||
] @keyword.conditional
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"for"
|
||||
"do"
|
||||
"done"
|
||||
"select"
|
||||
"until"
|
||||
"while"
|
||||
] @keyword.repeat
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"declare"
|
||||
"typeset"
|
||||
"readonly"
|
||||
"local"
|
||||
"unset"
|
||||
"unsetenv"
|
||||
] @keyword
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
"export" @keyword.import
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
"function" @keyword.function
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(special_variable_name) @constant
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
((word) @constant.builtin
|
||||
(#match? @constant.builtin "^(SIGHUP|SIGINT|SIGQUIT|SIGILL|SIGTRAP|SIGABRT|SIGBUS|SIGFPE|SIGKILL|SIGUSR1|SIGSEGV|SIGUSR2|SIGPIPE|SIGALRM|SIGTERM|SIGSTKFLT|SIGCHLD|SIGCONT|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU|SIGURG|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGIO|SIGPWR|SIGSYS|SIGRTMIN|SIGRTMIN\+1|SIGRTMIN\+2|SIGRTMIN\+3|SIGRTMIN\+4|SIGRTMIN\+5|SIGRTMIN\+6|SIGRTMIN\+7|SIGRTMIN\+8|SIGRTMIN\+9|SIGRTMIN\+10|SIGRTMIN\+11|SIGRTMIN\+12|SIGRTMIN\+13|SIGRTMIN\+14|SIGRTMIN\+15|SIGRTMAX\-14|SIGRTMAX\-13|SIGRTMAX\-12|SIGRTMAX\-11|SIGRTMAX\-10|SIGRTMAX\-9|SIGRTMAX\-8|SIGRTMAX\-7|SIGRTMAX\-6|SIGRTMAX\-5|SIGRTMAX\-4|SIGRTMAX\-3|SIGRTMAX\-2|SIGRTMAX\-1|SIGRTMAX)$"))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
((word) @boolean.true
|
||||
(#match? @boolean.true "^true$"))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
((word) @boolean.false
|
||||
(#match? @boolean.false "^false$"))
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment @spell
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(test_operator) @operator
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(command_substitution
|
||||
"$(" @punctuation.special
|
||||
")" @punctuation.special)
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(process_substitution
|
||||
[
|
||||
"<("
|
||||
">("
|
||||
] @punctuation.special
|
||||
")" @punctuation.special)
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(arithmetic_expansion
|
||||
[
|
||||
"$(("
|
||||
"(("
|
||||
] @punctuation.special
|
||||
"))" @punctuation.special)
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
(arithmetic_expansion
|
||||
"," @punctuation.delimiter)
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(ternary_expression
|
||||
[
|
||||
"?"
|
||||
":"
|
||||
] @keyword.conditional.ternary)
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(binary_expression
|
||||
operator: _ @operator)
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(unary_expression
|
||||
operator: _ @operator)
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(postfix_expression
|
||||
operator: _ @operator)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(function_definition
|
||||
name: (word) @function)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(command_name
|
||||
(word) @function.call)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(command_name
|
||||
(word) @function.builtin
|
||||
(#match? @function.builtin "^(\.|\:|alias|bg|bind|break|builtin|caller|cd|command|compgen|complete|compopt|continue|coproc|dirs|disown|echo|enable|eval|exec|exit|false|fc|fg|getopts|hash|help|history|jobs|kill|let|logout|mapfile|popd|printf|pushd|pwd|read|readarray|return|set|shift|shopt|source|suspend|test|time|times|trap|true|type|typeset|ulimit|umask|unalias|wait)$"))
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(command
|
||||
argument: [
|
||||
(word) @variable.parameter
|
||||
(concatenation
|
||||
(word) @variable.parameter)
|
||||
])
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(declaration_command
|
||||
(word) @variable.parameter)
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(unset_command
|
||||
(word) @variable.parameter)
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(number) @number
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
((word) @number
|
||||
(#match? @number "^[0-9]+$"))
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
(file_redirect
|
||||
(word) @string.special.path)
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
(herestring_redirect
|
||||
(word) @string)
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(file_descriptor) @operator
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(simple_expansion
|
||||
"$" @punctuation.special) @none
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(expansion
|
||||
"${" @punctuation.special
|
||||
"}" @punctuation.special) @none
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(expansion
|
||||
operator: _ @punctuation.special)
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(expansion
|
||||
"@"
|
||||
.
|
||||
operator: _ @character.special)
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
((expansion
|
||||
(subscript
|
||||
index: (word) @character.special))
|
||||
(#any-of? @character.special "@" "*"))
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
"``" @punctuation.special
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(variable_name) @variable
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
((variable_name) @constant
|
||||
(#match? @constant "^[A-Z][A-Z_0-9]*$"))
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
((variable_name) @variable.builtin
|
||||
(#match? @variable.builtin "^(CDPATH|HOME|IFS|MAIL|MAILPATH|OPTARG|OPTIND|PATH|PS1|PS2|_|BASH|BASHOPTS|BASHPID|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_ARGV0|BASH_CMDS|BASH_COMMAND|BASH_COMPAT|BASH_ENV|BASH_EXECUTION_STRING|BASH_LINENO|BASH_LOADABLES_PATH|BASH_REMATCH|BASH_SOURCE|BASH_SUBSHELL|BASH_VERSINFO|BASH_VERSION|BASH_XTRACEFD|CHILD_MAX|COLUMNS|COMP_CWORD|COMP_LINE|COMP_POINT|COMP_TYPE|COMP_KEY|COMP_WORDBREAKS|COMP_WORDS|COMPREPLY|COPROC|DIRSTACK|EMACS|ENV|EPOCHREALTIME|EPOCHSECONDS|EUID|EXECIGNORE|FCEDIT|FIGNORE|FUNCNAME|FUNCNEST|GLOBIGNORE|GROUPS|histchars|HISTCMD|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTIGNORE|HISTSIZE|HISTTIMEFORMAT|HOSTFILE|HOSTNAME|HOSTTYPE|IGNOREEOF|INPUTRC|INSIDE_EMACS|LANG|LC_ALL|LC_COLLATE|LC_CTYPE|LC_MESSAGES|LC_NUMERIC|LC_TIME|LINENO|LINES|MACHTYPE|MAILCHECK|MAPFILE|OLDPWD|OPTERR|OSTYPE|PIPESTATUS|POSIXLY_CORRECT|PPID|PROMPT_COMMAND|PROMPT_DIRTRIM|PS0|PS3|PS4|PWD|RANDOM|READLINE_ARGUMENT|READLINE_LINE|READLINE_MARK|READLINE_POINT|REPLY|SECONDS|SHELL|SHELLOPTS|SHLVL|SRANDOM|TIMEFORMAT|TMOUT|TMPDIR|UID)$"))
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(case_item
|
||||
value: (word) @variable.parameter)
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 3
|
||||
((program
|
||||
.
|
||||
(comment) @keyword.directive @nospell)
|
||||
(#match? @keyword.directive "^#!/"))
|
||||
|
||||
; Injections
|
||||
|
||||
;; !regex
|
||||
[
|
||||
(regex)
|
||||
(extglob_pattern)
|
||||
] @string.regexp
|
||||
|
||||
;; !bash
|
||||
((heredoc_body) @bash_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "BASH")))
|
||||
|
||||
;; !c
|
||||
((heredoc_body) @c_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "C$")))
|
||||
|
||||
;; !cpp
|
||||
((heredoc_body) @cpp_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "CPP")))
|
||||
|
||||
;; !css
|
||||
((heredoc_body) @css_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "CSS")))
|
||||
|
||||
;; !fish
|
||||
((heredoc_body) @fish_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "FISH")))
|
||||
|
||||
;; !go
|
||||
((heredoc_body) @go_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "GO")))
|
||||
|
||||
;; !haskell
|
||||
((heredoc_body) @haskell_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "HASKELL")))
|
||||
|
||||
;; !html
|
||||
((heredoc_body) @html_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "HTML")))
|
||||
|
||||
;; !javascript
|
||||
((heredoc_body) @javascript_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "JAVASCRIPT")))
|
||||
|
||||
;; !json
|
||||
((heredoc_body) @json_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "JSON")))
|
||||
|
||||
;; !lua
|
||||
((heredoc_body) @lua_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "LUA")))
|
||||
|
||||
;; !make
|
||||
((heredoc_body) @make_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "MAKE")))
|
||||
|
||||
;; !python
|
||||
((heredoc_body) @python_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "PYTHON")))
|
||||
|
||||
;; !ruby
|
||||
((heredoc_body) @ruby_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "RUBY")))
|
||||
|
||||
;; !rust
|
||||
((heredoc_body) @rust_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "RUST")))
|
||||
|
||||
;; !diff
|
||||
((heredoc_body) @diff_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "DIFF")))
|
||||
|
||||
;; !embedded_template
|
||||
((heredoc_body) @embedded_template_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "ERB")))
|
||||
|
||||
;; !gdscript
|
||||
((heredoc_body) @gdscript_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "GDSCRIPT")))
|
||||
|
||||
;; !gitattributes
|
||||
((heredoc_body) @gitattributes_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "GITATTRIBUTES")))
|
||||
|
||||
;; !gitignore
|
||||
((heredoc_body) @gitignore_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "GITIGNORE")))
|
||||
|
||||
;; !gomod
|
||||
((heredoc_body) @gomod_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "GOMOD")))
|
||||
|
||||
;; !ini
|
||||
((heredoc_body) @ini_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "INI")))
|
||||
|
||||
;; !markdown
|
||||
((heredoc_body) @markdown_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "MARKDOWN")))
|
||||
|
||||
;; !nginx
|
||||
((heredoc_body) @nginx_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "NGINX")))
|
||||
|
||||
;; !php
|
||||
((heredoc_body) @php_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "PHP")))
|
||||
|
||||
;; !query
|
||||
((heredoc_body) @query_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "QUERY")))
|
||||
|
||||
;; !regex
|
||||
((heredoc_body) @regex_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "REGEX")))
|
||||
|
||||
;; !sql
|
||||
((heredoc_body) @sql_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "SQL")))
|
||||
|
||||
;; !toml
|
||||
((heredoc_body) @toml_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "TOML")))
|
||||
|
||||
;; !yaml
|
||||
((heredoc_body) @yaml_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "YAML")))
|
||||
|
||||
;; !cabal
|
||||
((heredoc_body) @cabal_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "CABAL")))
|
||||
564
grammar/c.scm
564
grammar/c.scm
@@ -1,564 +0,0 @@
|
||||
; ============================================================
|
||||
; Identifiers
|
||||
; ============================================================
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
((identifier) @variable)
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 9
|
||||
(function_declarator
|
||||
declarator: (identifier) @function)
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z0-9_]+$"))
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
(preproc_def
|
||||
(preproc_arg) @constant
|
||||
(#match? @constant "^[A-Z][A-Z0-9_]+$"))
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
((identifier) @constant.builtin
|
||||
(#match? @constant.builtin "^(stderr|stdin|stdout|__FILE__|__LINE__|__DATE__|__TIME__|__STDC__|__STDC_VERSION__|__STDC_HOSTED__|__cplusplus|__OBJC__|__ASSEMBLER__|__BASE_FILE__|__FILE_NAME__|__INCLUDE_LEVEL__|__TIMESTAMP__|__clang__|__clang_major__|__clang_minor__|__clang_patchlevel__|__clang_version__|__clang_literal_encoding__|__clang_wide_literal_encoding__|__FUNCTION__|__func__|__PRETTY_FUNCTION__|__VA_ARGS__|__VA_OPT__)$"))
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_def
|
||||
(preproc_arg) @constant.builtin
|
||||
(#match? @constant.builtin "^(stderr|stdin|stdout|__FILE__|__LINE__|__DATE__|__TIME__|__STDC__|__STDC_VERSION__|__STDC_HOSTED__|__cplusplus|__OBJC__|__ASSEMBLER__|__BASE_FILE__|__FILE_NAME__|__INCLUDE_LEVEL__|__TIMESTAMP__|__clang__|__clang_major__|__clang_minor__|__clang_patchlevel__|__clang_version__|__clang_literal_encoding__|__clang_wide_literal_encoding__|__FUNCTION__|__func__|__PRETTY_FUNCTION__|__VA_ARGS__|__VA_OPT__)$"))
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
(preproc_def
|
||||
(preproc_arg) @variable)
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
(statement_identifier) @label
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
(declaration
|
||||
type: (type_identifier) @_type
|
||||
declarator: (identifier) @label
|
||||
(#match? @_type "^__label__$"))
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
((identifier) @variable.member
|
||||
(#match? @variable.member "^m_.*$"))
|
||||
|
||||
; ============================================================
|
||||
; Keywords
|
||||
; ============================================================
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"default"
|
||||
"goto"
|
||||
"asm"
|
||||
"__asm__"
|
||||
] @keyword
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"enum"
|
||||
"struct"
|
||||
"union"
|
||||
"typedef"
|
||||
] @keyword.type
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
[
|
||||
"sizeof"
|
||||
"offsetof"
|
||||
] @keyword.operator
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(alignof_expression
|
||||
.
|
||||
_ @keyword.operator)
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 2
|
||||
"return" @keyword.return
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"while"
|
||||
"for"
|
||||
"do"
|
||||
"continue"
|
||||
"break"
|
||||
] @keyword.repeat
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 2
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"case"
|
||||
"switch"
|
||||
] @keyword.conditional
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(conditional_expression
|
||||
[
|
||||
"?"
|
||||
":"
|
||||
] @keyword.conditional.ternary)
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
[
|
||||
"#if"
|
||||
"#ifdef"
|
||||
"#ifndef"
|
||||
"#else"
|
||||
"#elif"
|
||||
"#endif"
|
||||
"#elifdef"
|
||||
"#elifndef"
|
||||
(preproc_directive)
|
||||
] @keyword.directive
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
"#define" @keyword.directive.define
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
"#include" @keyword.import
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"try"
|
||||
"catch"
|
||||
"noexcept"
|
||||
"throw"
|
||||
] @keyword.exception
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"decltype"
|
||||
"explicit"
|
||||
"friend"
|
||||
"override"
|
||||
"using"
|
||||
"requires"
|
||||
"constexpr"
|
||||
] @keyword
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"class"
|
||||
"namespace"
|
||||
"template"
|
||||
"typename"
|
||||
"concept"
|
||||
] @keyword.type
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"co_await"
|
||||
"co_yield"
|
||||
"co_return"
|
||||
] @keyword.coroutine
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
[
|
||||
"public"
|
||||
"private"
|
||||
"protected"
|
||||
"final"
|
||||
"virtual"
|
||||
] @keyword.modifier
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(storage_class_specifier) @keyword.modifier
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
[
|
||||
(type_qualifier)
|
||||
(gnu_asm_qualifier)
|
||||
"__extension__"
|
||||
] @keyword.modifier
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(linkage_specification
|
||||
"extern" @keyword.modifier)
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 2
|
||||
[
|
||||
"new"
|
||||
"delete"
|
||||
"xor"
|
||||
"bitand"
|
||||
"bitor"
|
||||
"compl"
|
||||
"not"
|
||||
"xor_eq"
|
||||
"and_eq"
|
||||
"or_eq"
|
||||
"not_eq"
|
||||
"and"
|
||||
"or"
|
||||
] @keyword.operator
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 2
|
||||
"<=>" @operator
|
||||
|
||||
; ============================================================
|
||||
; Types & modules
|
||||
; ============================================================
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
[
|
||||
(type_identifier)
|
||||
(type_descriptor)
|
||||
] @type
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
(type_definition
|
||||
declarator: (type_identifier) @type.definition)
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
(primitive_type) @type.builtin
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
(sized_type_specifier
|
||||
_ @type.builtin
|
||||
type: _?)
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(namespace_identifier) @module
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
((namespace_identifier) @type
|
||||
(#match? @type "^[A-Z]"))
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(using_declaration
|
||||
.
|
||||
"using"
|
||||
.
|
||||
"namespace"
|
||||
.
|
||||
[
|
||||
(qualified_identifier)
|
||||
(identifier)
|
||||
] @module)
|
||||
|
||||
; ============================================================
|
||||
; Functions & calls
|
||||
; ============================================================
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 1
|
||||
(operator_name) @function
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 3
|
||||
"operator" @function
|
||||
|
||||
;; #78C2FF #000000 0 0 0 0 2
|
||||
(call_expression
|
||||
function: (identifier) @function.call)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (identifier) @function.builtin)
|
||||
(#match? @function.builtin "^__builtin_"))
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (identifier) @function.builtin))
|
||||
|
||||
; ============================================================
|
||||
; Constructors & methods
|
||||
; ============================================================
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (identifier) @constructor)
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (qualified_identifier
|
||||
name: (identifier) @constructor))
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (field_expression
|
||||
field: (field_identifier) @constructor))
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 2
|
||||
((field_initializer
|
||||
(field_identifier) @constructor
|
||||
(argument_list))
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 4
|
||||
(destructor_name
|
||||
(identifier) @function.method)
|
||||
|
||||
; ============================================================
|
||||
; Properties & members
|
||||
; ============================================================
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
((field_expression
|
||||
(field_identifier) @property) @_parent)
|
||||
|
||||
(field_designator) @property
|
||||
|
||||
((field_identifier) @property)
|
||||
|
||||
(field_initializer
|
||||
(field_identifier) @property)
|
||||
|
||||
;; #F29CC3 #000000 0 0 1 0 2
|
||||
(field_declaration
|
||||
(field_identifier) @variable.member)
|
||||
|
||||
; ============================================================
|
||||
; Parameters
|
||||
; ============================================================
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(parameter_declaration
|
||||
declarator: (identifier) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(parameter_declaration
|
||||
declarator: (array_declarator) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(parameter_declaration
|
||||
declarator: (pointer_declarator) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(preproc_params
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(parameter_declaration
|
||||
declarator: (reference_declarator) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(variadic_parameter_declaration
|
||||
declarator: (variadic_declarator
|
||||
(_) @variable.parameter))
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(optional_parameter_declaration
|
||||
declarator: (_) @variable.parameter)
|
||||
|
||||
; ============================================================
|
||||
; Attributes & specifiers
|
||||
; ============================================================
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
[
|
||||
"__attribute__"
|
||||
"__declspec"
|
||||
"__based"
|
||||
"__cdecl"
|
||||
"__clrcall"
|
||||
"__stdcall"
|
||||
"__fastcall"
|
||||
"__thiscall"
|
||||
"__vectorcall"
|
||||
(ms_pointer_modifier)
|
||||
(attribute_declaration)
|
||||
] @attribute
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(identifier) @variable.builtin))
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(call_expression
|
||||
function: (identifier) @variable.builtin)))
|
||||
|
||||
; ============================================================
|
||||
; Operators & punctuation
|
||||
; ============================================================
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
[
|
||||
"="
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"+"
|
||||
"%"
|
||||
"~"
|
||||
"|"
|
||||
"&"
|
||||
"^"
|
||||
"<<"
|
||||
">>"
|
||||
"->"
|
||||
"<"
|
||||
"<="
|
||||
">="
|
||||
">"
|
||||
"=="
|
||||
"!="
|
||||
"!"
|
||||
"&&"
|
||||
"||"
|
||||
"-="
|
||||
"+="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"|="
|
||||
"&="
|
||||
"^="
|
||||
">>="
|
||||
"<<="
|
||||
"--"
|
||||
"++"
|
||||
] @operator
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
(comma_expression
|
||||
"," @operator)
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
[
|
||||
";"
|
||||
":"
|
||||
","
|
||||
"."
|
||||
"::"
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
"::" @punctuation.delimiter
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
"..." @punctuation.special
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
(template_argument_list
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
(template_parameter_list
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
||||
; ============================================================
|
||||
; Literals
|
||||
; ============================================================
|
||||
|
||||
;; #C2E8FF #000000 0 0 0 0 2
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
;; #C2E8FF #000000 0 0 0 0 2
|
||||
(true) @boolean_true
|
||||
|
||||
;; #C2E8FF #000000 0 0 0 0 2
|
||||
(false) @boolean_false
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 2
|
||||
(string_literal) @string
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 2
|
||||
(system_lib_string) @string
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 2
|
||||
(raw_string_literal) @string
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 2
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
;; #B8E986 #000000 0 0 0 0 2
|
||||
(number_literal) @number
|
||||
|
||||
;; #B8E986 #000000 0 0 0 0 2
|
||||
(char_literal) @character
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(null) @constant.builtin
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(null
|
||||
"nullptr" @constant.builtin)
|
||||
|
||||
; ============================================================
|
||||
; Macros & directives
|
||||
; ============================================================
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_def
|
||||
name: (_) @constant.macro)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_call
|
||||
directive: (preproc_directive) @_u
|
||||
argument: (_) @constant.macro
|
||||
(#match? @_u "^#undef$"))
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_ifdef
|
||||
name: (identifier) @constant.macro)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_elifdef
|
||||
name: (identifier) @constant.macro)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_defined
|
||||
(identifier) @constant.macro)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_defined) @function.macro
|
||||
|
||||
; ============================================================
|
||||
; Builtins & special identifiers
|
||||
; ============================================================
|
||||
|
||||
;; #F28FAD #000000 0 0 0 0 2
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(identifier) @variable.builtin))
|
||||
|
||||
;; #F28FAD #000000 0 0 0 0 2
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(call_expression
|
||||
function: (identifier) @variable.builtin)))
|
||||
|
||||
;; #F28FAD #000000 0 0 0 0 2
|
||||
(this) @variable.builtin
|
||||
|
||||
; ============================================================
|
||||
; Exceptions & control helpers
|
||||
; ============================================================
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 2
|
||||
"static_assert" @function.builtin
|
||||
|
||||
; ============================================================
|
||||
; Comments
|
||||
; ============================================================
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment @spell
|
||||
564
grammar/cpp.scm
564
grammar/cpp.scm
@@ -1,564 +0,0 @@
|
||||
; ============================================================
|
||||
; Identifiers
|
||||
; ============================================================
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
((identifier) @variable)
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 9
|
||||
(function_declarator
|
||||
declarator: (identifier) @function)
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z0-9_]+$"))
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
(preproc_def
|
||||
(preproc_arg) @constant
|
||||
(#match? @constant "^[A-Z][A-Z0-9_]+$"))
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
((identifier) @constant.builtin
|
||||
(#match? @constant.builtin "^(stderr|stdin|stdout|__FILE__|__LINE__|__DATE__|__TIME__|__STDC__|__STDC_VERSION__|__STDC_HOSTED__|__cplusplus|__OBJC__|__ASSEMBLER__|__BASE_FILE__|__FILE_NAME__|__INCLUDE_LEVEL__|__TIMESTAMP__|__clang__|__clang_major__|__clang_minor__|__clang_patchlevel__|__clang_version__|__clang_literal_encoding__|__clang_wide_literal_encoding__|__FUNCTION__|__func__|__PRETTY_FUNCTION__|__VA_ARGS__|__VA_OPT__)$"))
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_def
|
||||
(preproc_arg) @constant.builtin
|
||||
(#match? @constant.builtin "^(stderr|stdin|stdout|__FILE__|__LINE__|__DATE__|__TIME__|__STDC__|__STDC_VERSION__|__STDC_HOSTED__|__cplusplus|__OBJC__|__ASSEMBLER__|__BASE_FILE__|__FILE_NAME__|__INCLUDE_LEVEL__|__TIMESTAMP__|__clang__|__clang_major__|__clang_minor__|__clang_patchlevel__|__clang_version__|__clang_literal_encoding__|__clang_wide_literal_encoding__|__FUNCTION__|__func__|__PRETTY_FUNCTION__|__VA_ARGS__|__VA_OPT__)$"))
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
(preproc_def
|
||||
(preproc_arg) @variable)
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
(statement_identifier) @label
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
(declaration
|
||||
type: (type_identifier) @_type
|
||||
declarator: (identifier) @label
|
||||
(#match? @_type "^__label__$"))
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
((identifier) @variable.member
|
||||
(#match? @variable.member "^m_.*$"))
|
||||
|
||||
; ============================================================
|
||||
; Keywords
|
||||
; ============================================================
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"default"
|
||||
"goto"
|
||||
"asm"
|
||||
"__asm__"
|
||||
] @keyword
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"enum"
|
||||
"struct"
|
||||
"union"
|
||||
"typedef"
|
||||
] @keyword.type
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
[
|
||||
"sizeof"
|
||||
"offsetof"
|
||||
] @keyword.operator
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(alignof_expression
|
||||
.
|
||||
_ @keyword.operator)
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 2
|
||||
"return" @keyword.return
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"while"
|
||||
"for"
|
||||
"do"
|
||||
"continue"
|
||||
"break"
|
||||
] @keyword.repeat
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 2
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"case"
|
||||
"switch"
|
||||
] @keyword.conditional
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(conditional_expression
|
||||
[
|
||||
"?"
|
||||
":"
|
||||
] @keyword.conditional.ternary)
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
[
|
||||
"#if"
|
||||
"#ifdef"
|
||||
"#ifndef"
|
||||
"#else"
|
||||
"#elif"
|
||||
"#endif"
|
||||
"#elifdef"
|
||||
"#elifndef"
|
||||
(preproc_directive)
|
||||
] @keyword.directive
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
"#define" @keyword.directive.define
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
"#include" @keyword.import
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"try"
|
||||
"catch"
|
||||
"noexcept"
|
||||
"throw"
|
||||
] @keyword.exception
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"decltype"
|
||||
"explicit"
|
||||
"friend"
|
||||
"override"
|
||||
"using"
|
||||
"requires"
|
||||
"constexpr"
|
||||
] @keyword
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"class"
|
||||
"namespace"
|
||||
"template"
|
||||
"typename"
|
||||
"concept"
|
||||
] @keyword.type
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"co_await"
|
||||
"co_yield"
|
||||
"co_return"
|
||||
] @keyword.coroutine
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
[
|
||||
"public"
|
||||
"private"
|
||||
"protected"
|
||||
"final"
|
||||
"virtual"
|
||||
] @keyword.modifier
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(storage_class_specifier) @keyword.modifier
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
[
|
||||
(type_qualifier)
|
||||
(gnu_asm_qualifier)
|
||||
"__extension__"
|
||||
] @keyword.modifier
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(linkage_specification
|
||||
"extern" @keyword.modifier)
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 2
|
||||
[
|
||||
"new"
|
||||
"delete"
|
||||
"xor"
|
||||
"bitand"
|
||||
"bitor"
|
||||
"compl"
|
||||
"not"
|
||||
"xor_eq"
|
||||
"and_eq"
|
||||
"or_eq"
|
||||
"not_eq"
|
||||
"and"
|
||||
"or"
|
||||
] @keyword.operator
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 2
|
||||
"<=>" @operator
|
||||
|
||||
; ============================================================
|
||||
; Types & modules
|
||||
; ============================================================
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
[
|
||||
(type_identifier)
|
||||
(type_descriptor)
|
||||
] @type
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
(type_definition
|
||||
declarator: (type_identifier) @type.definition)
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
(primitive_type) @type.builtin
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
(sized_type_specifier
|
||||
_ @type.builtin
|
||||
type: _?)
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(namespace_identifier) @module
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
((namespace_identifier) @type
|
||||
(#match? @type "^[A-Z]"))
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(using_declaration
|
||||
.
|
||||
"using"
|
||||
.
|
||||
"namespace"
|
||||
.
|
||||
[
|
||||
(qualified_identifier)
|
||||
(identifier)
|
||||
] @module)
|
||||
|
||||
; ============================================================
|
||||
; Functions & calls
|
||||
; ============================================================
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 1
|
||||
(operator_name) @function
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 3
|
||||
"operator" @function
|
||||
|
||||
;; #78C2FF #000000 0 0 0 0 2
|
||||
(call_expression
|
||||
function: (identifier) @function.call)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (identifier) @function.builtin)
|
||||
(#match? @function.builtin "^__builtin_"))
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (identifier) @function.builtin))
|
||||
|
||||
; ============================================================
|
||||
; Constructors & methods
|
||||
; ============================================================
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (identifier) @constructor)
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (qualified_identifier
|
||||
name: (identifier) @constructor))
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (field_expression
|
||||
field: (field_identifier) @constructor))
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 2
|
||||
((field_initializer
|
||||
(field_identifier) @constructor
|
||||
(argument_list))
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 4
|
||||
(destructor_name
|
||||
(identifier) @function.method)
|
||||
|
||||
; ============================================================
|
||||
; Properties & members
|
||||
; ============================================================
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
((field_expression
|
||||
(field_identifier) @property) @_parent)
|
||||
|
||||
(field_designator) @property
|
||||
|
||||
((field_identifier) @property)
|
||||
|
||||
(field_initializer
|
||||
(field_identifier) @property)
|
||||
|
||||
;; #F29CC3 #000000 0 0 1 0 2
|
||||
(field_declaration
|
||||
(field_identifier) @variable.member)
|
||||
|
||||
; ============================================================
|
||||
; Parameters
|
||||
; ============================================================
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(parameter_declaration
|
||||
declarator: (identifier) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(parameter_declaration
|
||||
declarator: (array_declarator) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(parameter_declaration
|
||||
declarator: (pointer_declarator) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(preproc_params
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(parameter_declaration
|
||||
declarator: (reference_declarator) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(variadic_parameter_declaration
|
||||
declarator: (variadic_declarator
|
||||
(_) @variable.parameter))
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(optional_parameter_declaration
|
||||
declarator: (_) @variable.parameter)
|
||||
|
||||
; ============================================================
|
||||
; Attributes & specifiers
|
||||
; ============================================================
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
[
|
||||
"__attribute__"
|
||||
"__declspec"
|
||||
"__based"
|
||||
"__cdecl"
|
||||
"__clrcall"
|
||||
"__stdcall"
|
||||
"__fastcall"
|
||||
"__thiscall"
|
||||
"__vectorcall"
|
||||
(ms_pointer_modifier)
|
||||
(attribute_declaration)
|
||||
] @attribute
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(identifier) @variable.builtin))
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(call_expression
|
||||
function: (identifier) @variable.builtin)))
|
||||
|
||||
; ============================================================
|
||||
; Operators & punctuation
|
||||
; ============================================================
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
[
|
||||
"="
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"+"
|
||||
"%"
|
||||
"~"
|
||||
"|"
|
||||
"&"
|
||||
"^"
|
||||
"<<"
|
||||
">>"
|
||||
"->"
|
||||
"<"
|
||||
"<="
|
||||
">="
|
||||
">"
|
||||
"=="
|
||||
"!="
|
||||
"!"
|
||||
"&&"
|
||||
"||"
|
||||
"-="
|
||||
"+="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"|="
|
||||
"&="
|
||||
"^="
|
||||
">>="
|
||||
"<<="
|
||||
"--"
|
||||
"++"
|
||||
] @operator
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
(comma_expression
|
||||
"," @operator)
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
[
|
||||
";"
|
||||
":"
|
||||
","
|
||||
"."
|
||||
"::"
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
"::" @punctuation.delimiter
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
"..." @punctuation.special
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
(template_argument_list
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
(template_parameter_list
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
||||
; ============================================================
|
||||
; Literals
|
||||
; ============================================================
|
||||
|
||||
;; #C2E8FF #000000 0 0 0 0 2
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
;; #C2E8FF #000000 0 0 0 0 2
|
||||
(true) @boolean_true
|
||||
|
||||
;; #C2E8FF #000000 0 0 0 0 2
|
||||
(false) @boolean_false
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 2
|
||||
(string_literal) @string
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 2
|
||||
(system_lib_string) @string
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 2
|
||||
(raw_string_literal) @string
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 2
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
;; #B8E986 #000000 0 0 0 0 2
|
||||
(number_literal) @number
|
||||
|
||||
;; #B8E986 #000000 0 0 0 0 2
|
||||
(char_literal) @character
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(null) @constant.builtin
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(null
|
||||
"nullptr" @constant.builtin)
|
||||
|
||||
; ============================================================
|
||||
; Macros & directives
|
||||
; ============================================================
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_def
|
||||
name: (_) @constant.macro)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_call
|
||||
directive: (preproc_directive) @_u
|
||||
argument: (_) @constant.macro
|
||||
(#match? @_u "^#undef$"))
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_ifdef
|
||||
name: (identifier) @constant.macro)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_elifdef
|
||||
name: (identifier) @constant.macro)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_defined
|
||||
(identifier) @constant.macro)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_defined) @function.macro
|
||||
|
||||
; ============================================================
|
||||
; Builtins & special identifiers
|
||||
; ============================================================
|
||||
|
||||
;; #F28FAD #000000 0 0 0 0 2
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(identifier) @variable.builtin))
|
||||
|
||||
;; #F28FAD #000000 0 0 0 0 2
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(call_expression
|
||||
function: (identifier) @variable.builtin)))
|
||||
|
||||
;; #F28FAD #000000 0 0 0 0 2
|
||||
(this) @variable.builtin
|
||||
|
||||
; ============================================================
|
||||
; Exceptions & control helpers
|
||||
; ============================================================
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 2
|
||||
"static_assert" @function.builtin
|
||||
|
||||
; ============================================================
|
||||
; Comments
|
||||
; ============================================================
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment @spell
|
||||
@@ -1,95 +0,0 @@
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(tag_name) @tag
|
||||
(nesting_selector) @tag
|
||||
(universal_selector) @tag
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
"~" @operator
|
||||
">" @operator
|
||||
"+" @operator
|
||||
"-" @operator
|
||||
"*" @operator
|
||||
"/" @operator
|
||||
"=" @operator
|
||||
"^=" @operator
|
||||
"|=" @operator
|
||||
"~=" @operator
|
||||
"$=" @operator
|
||||
"*=" @operator
|
||||
"and" @operator
|
||||
"or" @operator
|
||||
"not" @operator
|
||||
"only" @operator
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 2
|
||||
(attribute_selector (plain_value) @string)
|
||||
(string_value) @string
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
((property_name) @variable
|
||||
(#match? @variable "^--"))
|
||||
((plain_value) @variable
|
||||
(#match? @variable "^--"))
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(class_name) @property
|
||||
(id_name) @property
|
||||
(namespace_name) @property
|
||||
(property_name) @property
|
||||
(feature_name) @property
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
(pseudo_element_selector (tag_name) @attribute)
|
||||
(pseudo_class_selector (class_name) @attribute)
|
||||
(attribute_name) @attribute
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
(function_name) @function
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(color_value) @string.special
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(integer_value) @number
|
||||
(float_value) @number
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(unit) @type
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 3
|
||||
[
|
||||
"#"
|
||||
","
|
||||
"."
|
||||
":"
|
||||
"::"
|
||||
";"
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 3
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
")"
|
||||
"("
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(at_keyword) @keyword
|
||||
(to) @keyword
|
||||
(from) @keyword
|
||||
(important) @keyword
|
||||
|
||||
; This is put at the end as the regex parser will wrongly think @media is a capture name becouse of its @
|
||||
; TODO: This should be fixed by not selecting if it is in a string
|
||||
"@media" @keyword
|
||||
"@import" @keyword
|
||||
"@charset" @keyword
|
||||
"@namespace" @keyword
|
||||
"@supports" @keyword
|
||||
"@keyframes" @keyword
|
||||
@@ -1,57 +0,0 @@
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment @spell
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 2
|
||||
(addition) @diff.plus
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 2
|
||||
(deletion) @diff.minus
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 0
|
||||
[
|
||||
(new_file)
|
||||
(old_file)
|
||||
] @file
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(commit) @constant
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(location) @attribute
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(command
|
||||
"diff" @function
|
||||
(argument) @variable.parameter)
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 6
|
||||
(mode) @number
|
||||
|
||||
;; #888888 #000000 0 0 0 0 3
|
||||
[
|
||||
".."
|
||||
"+"
|
||||
"++"
|
||||
"+++"
|
||||
"++++"
|
||||
"-"
|
||||
"--"
|
||||
"---"
|
||||
"----"
|
||||
] @punctuation.special
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
[
|
||||
(binary_change)
|
||||
(similarity)
|
||||
(file_change)
|
||||
] @label
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(index
|
||||
"index" @keyword)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(similarity
|
||||
(score) @number
|
||||
"%" @number)
|
||||
@@ -1,20 +0,0 @@
|
||||
;; #99ADBF #000000 0 1 0 0 4
|
||||
(comment_directive) @comment
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 6
|
||||
[
|
||||
"<%#"
|
||||
"<%"
|
||||
"<%="
|
||||
"<%_"
|
||||
"<%-"
|
||||
"%>"
|
||||
"-%>"
|
||||
"_%>"
|
||||
] @keyword
|
||||
|
||||
;; !html
|
||||
(content) @injection.html
|
||||
|
||||
;; !ruby
|
||||
(code) @injection.ruby
|
||||
191
grammar/fish.scm
191
grammar/fish.scm
@@ -1,191 +0,0 @@
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
[
|
||||
"&&"
|
||||
"||"
|
||||
"|"
|
||||
"&|"
|
||||
"2>|"
|
||||
"&"
|
||||
".."
|
||||
"!"
|
||||
(direction)
|
||||
(stream_redirect)
|
||||
] @operator
|
||||
|
||||
(command
|
||||
name: (word) @function.builtin
|
||||
(#match? @function.builtin "^test$")
|
||||
;; #FFFFFF #000000 0 0 0 0 3
|
||||
argument: (word) @word
|
||||
(#match? @word "^(!?=|-[a-zA-Z]+)$"))
|
||||
|
||||
(command
|
||||
name: (word) @punctuation.bracket
|
||||
(#match? @punctuation.bracket "^\\[$")
|
||||
argument: (word) @word
|
||||
(#match? @word "^(!?=|-[a-zA-Z]+)$"))
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
[
|
||||
"not"
|
||||
"and"
|
||||
"or"
|
||||
] @keyword.operator
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(if_statement
|
||||
[
|
||||
"if"
|
||||
"end"
|
||||
] @keyword.conditional)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(switch_statement
|
||||
[
|
||||
"switch"
|
||||
"end"
|
||||
] @keyword.conditional)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(case_clause
|
||||
"case" @keyword.conditional)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(else_clause
|
||||
"else" @keyword.conditional)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(else_if_clause
|
||||
[
|
||||
"else"
|
||||
"if"
|
||||
] @keyword.conditional)
|
||||
|
||||
; Loops/Blocks
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(while_statement
|
||||
[
|
||||
"while"
|
||||
"end"
|
||||
] @keyword.repeat)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(for_statement
|
||||
[
|
||||
"for"
|
||||
"end"
|
||||
] @keyword.repeat)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(begin_statement
|
||||
[
|
||||
"begin"
|
||||
"end"
|
||||
] @keyword.repeat)
|
||||
|
||||
; Keywords
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"in"
|
||||
(break)
|
||||
(continue)
|
||||
] @keyword
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
"return" @keyword.return
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"("
|
||||
")"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
"," @punctuation.delimiter
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(command_substitution
|
||||
"$" @punctuation.special)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(command
|
||||
name: (word) @function.call)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(command
|
||||
name: (word) @function.builtin
|
||||
(#match? @function.builtin
|
||||
"^(\\.|:|_|abbr|alias|argparse|bg|bind|block|breakpoint|builtin|cd|command|commandline|complete|contains|count|disown|echo|emit|eval|exec|exit|fg|functions|history|isatty|jobs|math|path|printf|pwd|random|read|realpath|set|set_color|source|status|string|test|time|type|ulimit|wait)$"))
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(function_definition
|
||||
[
|
||||
"function"
|
||||
"end"
|
||||
] @keyword.function)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(function_definition
|
||||
name: [
|
||||
(word)
|
||||
(concatenation)
|
||||
] @function)
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(function_definition
|
||||
option: [
|
||||
(word)
|
||||
(concatenation
|
||||
(word))
|
||||
] @variable.parameter
|
||||
(#match? @variable.parameter "^[-]"))
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
[
|
||||
(double_quote_string)
|
||||
(single_quote_string)
|
||||
] @string
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(variable_name) @variable
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(variable_expansion) @constant
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(variable_expansion
|
||||
"$" @punctuation.special) @none
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
((variable_name) @variable.builtin
|
||||
(#match? @variable.builtin
|
||||
"^(PATH|CDPATH|LANG|LC_ALL|LC_COLLATE|LC_CTYPE|LC_MESSAGES|LC_MONETARY|LC_NUMERIC|LC_TIME|fish_color_normal|fish_color_command|fish_color_keyword|fish_color_redirection|fish_color_end|fish_color_error|fish_color_param|fish_color_valid_path|fish_color_option|fish_color_comment|fish_color_selection|fish_color_operator|fish_color_escape|fish_color_autosuggestion|fish_color_cwd|fish_color_cwd_root|fish_color_user|fish_color_host|fish_color_host_remote|fish_color_status|fish_color_cancel|fish_color_search_match|fish_color_history_current|fish_pager_color_progress|fish_pager_color_background|fish_pager_color_prefix|fish_pager_color_completion|fish_pager_color_description|fish_pager_color_selected_background|fish_pager_color_selected_prefix|fish_pager_color_selected_completion|fish_pager_color_selected_description|fish_pager_color_secondary_background|fish_pager_color_secondary_prefix|fish_pager_color_secondary_completion|fish_pager_color_secondary_description|fish_term24bit|fish_term256|fish_ambiguous_width|fish_emoji_width|fish_autosuggestion_enabled|fish_handle_reflow|fish_key_bindings|fish_escape_delay_ms|fish_sequence_key_delay_ms|fish_complete_path|fish_cursor_selection_mode|fish_cursor_default|fish_cursor_insert|fish_cursor_replace|fish_cursor_replace_one|fish_cursor_visual|fish_cursor_external|fish_function_path|fish_greeting|fish_history|fish_trace|FISH_DEBUG|FISH_DEBUG_OUTPUT|fish_user_paths|umask|BROWSER|_|argv|CMD_DURATION|COLUMNS|LINES|fish_kill_signal|fish_killring|fish_read_limit|fish_pid|history|HOME|hostname|IFS|last_pid|PWD|pipestatus|SHLVL|status|status_generation|TERM|USER|EUID|version|FISH_VERSION)$"))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
[
|
||||
(integer)
|
||||
(float)
|
||||
] @number
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @spell
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
((word) @boolean
|
||||
(#match? @boolean "^(true|false)$"))
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 3
|
||||
((program
|
||||
.
|
||||
(comment) @keyword.directive @nospell)
|
||||
(#match? @keyword.directive "^#!"))
|
||||
File diff suppressed because one or more lines are too long
@@ -1,70 +0,0 @@
|
||||
;; #AAD94C #000000 0 0 0 0 3
|
||||
(dir_sep) @punctuation.delimiter
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 3
|
||||
(quoted_pattern
|
||||
"\"" @punctuation.special)
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 3
|
||||
(range_notation) @string.special
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 3
|
||||
(range_notation
|
||||
[ "[" "]" ] @punctuation.bracket)
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(wildcard) @string.regexp
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(range_negation) @operator
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(character_class) @constant
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(class_range "-" @operator)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
(ansi_c_escape)
|
||||
(escaped_char)
|
||||
] @escape
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 3
|
||||
(attribute
|
||||
(attr_name) @variable.parameter)
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
(attribute
|
||||
(builtin_attr) @variable.builtin)
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
[
|
||||
(attr_reset)
|
||||
(attr_unset)
|
||||
(attr_set)
|
||||
] @operator
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(boolean_value) @boolean
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 2
|
||||
(string_value) @string
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(macro_tag) @keyword
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(macro_def
|
||||
macro_name: (_) @property)
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
[
|
||||
(pattern_negation)
|
||||
(redundant_escape)
|
||||
(trailing_slash)
|
||||
(ignored_value)
|
||||
] @error
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment
|
||||
@@ -1,46 +0,0 @@
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment @spell
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(pattern_char) @string.special.path
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 3
|
||||
[
|
||||
(directory_separator)
|
||||
(directory_separator_escaped)
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
[
|
||||
(wildcard_char_single)
|
||||
(wildcard_chars)
|
||||
(wildcard_chars_allow_slash)
|
||||
] @character.special
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
(pattern_char_escaped)
|
||||
(bracket_char_escaped)
|
||||
] @string.escape
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 3
|
||||
(negation) @punctuation.special
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
(bracket_negation) @operator
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 3
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(bracket_char) @constant
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(bracket_range
|
||||
"-" @operator)
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
(bracket_char_class) @constant.builtin
|
||||
286
grammar/go.scm
286
grammar/go.scm
@@ -1,286 +0,0 @@
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(type_identifier) @type
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(type_spec
|
||||
name: (type_identifier) @type.definition)
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(field_identifier) @property
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(identifier) @variable
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(package_identifier) @module
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(parameter_declaration
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(variadic_parameter_declaration
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
(label_name) @label
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(const_spec
|
||||
name: (identifier) @constant)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(call_expression
|
||||
function: (identifier) @function.call)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(call_expression
|
||||
function: (selector_expression
|
||||
field: (field_identifier) @function.method.call))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(function_declaration
|
||||
name: (identifier) @function)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(method_declaration
|
||||
name: (field_identifier) @function.method)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(method_elem
|
||||
name: (field_identifier) @function.method)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
((call_expression
|
||||
(identifier) @constructor)
|
||||
(#match? @constructor "^[nN]ew.+$"))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
((call_expression
|
||||
(identifier) @constructor)
|
||||
(#match? @constructor "^[mM]ake.+$"))
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
[
|
||||
"--"
|
||||
"-"
|
||||
"-="
|
||||
":="
|
||||
"!"
|
||||
"!="
|
||||
"..."
|
||||
"*"
|
||||
"*="
|
||||
"/"
|
||||
"/="
|
||||
"&"
|
||||
"&&"
|
||||
"&="
|
||||
"&^"
|
||||
"&^="
|
||||
"%"
|
||||
"%="
|
||||
"^"
|
||||
"^="
|
||||
"+"
|
||||
"++"
|
||||
"+="
|
||||
"<-"
|
||||
"<"
|
||||
"<<"
|
||||
"<<="
|
||||
"<="
|
||||
"="
|
||||
"=="
|
||||
">"
|
||||
">="
|
||||
">>"
|
||||
">>="
|
||||
"|"
|
||||
"|="
|
||||
"||"
|
||||
"~"
|
||||
] @operator
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"break"
|
||||
"const"
|
||||
"continue"
|
||||
"default"
|
||||
"defer"
|
||||
"goto"
|
||||
"range"
|
||||
"select"
|
||||
"var"
|
||||
"fallthrough"
|
||||
] @keyword
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"type"
|
||||
"struct"
|
||||
"interface"
|
||||
] @keyword.type
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
"func" @keyword.function
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
"return" @keyword.return
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
"go" @keyword.coroutine
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
"for" @keyword.repeat
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"import"
|
||||
"package"
|
||||
] @keyword.import
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"else"
|
||||
"case"
|
||||
"switch"
|
||||
"if"
|
||||
] @keyword.conditional
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
[
|
||||
"chan"
|
||||
"map"
|
||||
] @type.builtin
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
((type_identifier) @type.builtin
|
||||
(#match? @type.builtin
|
||||
"^(any|bool|byte|comparable|complex128|complex64|error|float32|float64|int|int16|int32|int64|int8|rune|string|uint|uint16|uint32|uint64|uint8|uintptr)$"))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
((identifier) @function.builtin
|
||||
(#match? @function.builtin
|
||||
"^(append|cap|clear|close|complex|copy|delete|imag|len|make|max|min|new|panic|print|println|real|recover)$"))
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
"." @punctuation.delimiter
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
"," @punctuation.delimiter
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
":" @punctuation.delimiter
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
";" @punctuation.delimiter
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
"(" @punctuation.bracket
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
")" @punctuation.bracket
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
"{" @punctuation.bracket
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
"}" @punctuation.bracket
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
"[" @punctuation.bracket
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
"]" @punctuation.bracket
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
(interpreted_string_literal) @string
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
(raw_string_literal) @string
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
(rune_literal) @string
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(int_literal) @number
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(float_literal) @number.float
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(imaginary_literal) @number
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
[
|
||||
(nil)
|
||||
(iota)
|
||||
] @constant.builtin
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(keyed_element
|
||||
.
|
||||
(literal_element
|
||||
(identifier) @variable.member))
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(field_declaration
|
||||
name: (field_identifier) @variable.member)
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment @spell
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(source_file
|
||||
.
|
||||
(comment)+ @comment.documentation)
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(source_file
|
||||
(comment)+ @comment.documentation
|
||||
.
|
||||
(const_declaration))
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(source_file
|
||||
(comment)+ @comment.documentation
|
||||
.
|
||||
(function_declaration))
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(source_file
|
||||
(comment)+ @comment.documentation
|
||||
.
|
||||
(type_declaration))
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(source_file
|
||||
(comment)+ @comment.documentation
|
||||
.
|
||||
(var_declaration))
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
(call_expression
|
||||
(selector_expression) @_function
|
||||
(#match? @_function
|
||||
"^(regexp\.Match|regexp\.MatchReader|regexp\.MatchString|regexp\.Compile|regexp\.CompilePOSIX|regexp\.MustCompile|regexp\.MustCompilePOSIX)$")
|
||||
(argument_list
|
||||
.
|
||||
[
|
||||
;; !regex
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @string.regexp)
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @string.regexp)
|
||||
]))
|
||||
@@ -1,46 +0,0 @@
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
[
|
||||
"require"
|
||||
"replace"
|
||||
"toolchain"
|
||||
"exclude"
|
||||
"retract"
|
||||
] @keyword
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
[
|
||||
"go"
|
||||
"module"
|
||||
] @keyword.directive
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
"=>" @operator
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment @spell
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 1
|
||||
(module_path) @string.special.url
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(tool_directive) @keyword.directive
|
||||
|
||||
(tool) @string.special.url
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 2
|
||||
[
|
||||
(version)
|
||||
(go_version)
|
||||
(toolchain_name)
|
||||
] @string.special
|
||||
|
||||
;; #888888 #000000 0 0 0 0 3
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #888888 #000000 0 1 0 0 3
|
||||
"," @punctuation.delimiter
|
||||
564
grammar/h.scm
564
grammar/h.scm
@@ -1,564 +0,0 @@
|
||||
; ============================================================
|
||||
; Identifiers
|
||||
; ============================================================
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
((identifier) @variable)
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 9
|
||||
(function_declarator
|
||||
declarator: (identifier) @function)
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z0-9_]+$"))
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
(preproc_def
|
||||
(preproc_arg) @constant
|
||||
(#match? @constant "^[A-Z][A-Z0-9_]+$"))
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
((identifier) @constant.builtin
|
||||
(#match? @constant.builtin "^(stderr|stdin|stdout|__FILE__|__LINE__|__DATE__|__TIME__|__STDC__|__STDC_VERSION__|__STDC_HOSTED__|__cplusplus|__OBJC__|__ASSEMBLER__|__BASE_FILE__|__FILE_NAME__|__INCLUDE_LEVEL__|__TIMESTAMP__|__clang__|__clang_major__|__clang_minor__|__clang_patchlevel__|__clang_version__|__clang_literal_encoding__|__clang_wide_literal_encoding__|__FUNCTION__|__func__|__PRETTY_FUNCTION__|__VA_ARGS__|__VA_OPT__)$"))
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(preproc_def
|
||||
(preproc_arg) @constant.builtin
|
||||
(#match? @constant.builtin "^(stderr|stdin|stdout|__FILE__|__LINE__|__DATE__|__TIME__|__STDC__|__STDC_VERSION__|__STDC_HOSTED__|__cplusplus|__OBJC__|__ASSEMBLER__|__BASE_FILE__|__FILE_NAME__|__INCLUDE_LEVEL__|__TIMESTAMP__|__clang__|__clang_major__|__clang_minor__|__clang_patchlevel__|__clang_version__|__clang_literal_encoding__|__clang_wide_literal_encoding__|__FUNCTION__|__func__|__PRETTY_FUNCTION__|__VA_ARGS__|__VA_OPT__)$"))
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
(preproc_def
|
||||
(preproc_arg) @variable)
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
(statement_identifier) @label
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
(declaration
|
||||
type: (type_identifier) @_type
|
||||
declarator: (identifier) @label
|
||||
(#match? @_type "^__label__$"))
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
((identifier) @variable.member
|
||||
(#match? @variable.member "^m_.*$"))
|
||||
|
||||
; ============================================================
|
||||
; Keywords
|
||||
; ============================================================
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"default"
|
||||
"goto"
|
||||
"asm"
|
||||
"__asm__"
|
||||
] @keyword
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"enum"
|
||||
"struct"
|
||||
"union"
|
||||
"typedef"
|
||||
] @keyword.type
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
[
|
||||
"sizeof"
|
||||
"offsetof"
|
||||
] @keyword.operator
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(alignof_expression
|
||||
.
|
||||
_ @keyword.operator)
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 2
|
||||
"return" @keyword.return
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"while"
|
||||
"for"
|
||||
"do"
|
||||
"continue"
|
||||
"break"
|
||||
] @keyword.repeat
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 2
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"case"
|
||||
"switch"
|
||||
] @keyword.conditional
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(conditional_expression
|
||||
[
|
||||
"?"
|
||||
":"
|
||||
] @keyword.conditional.ternary)
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
[
|
||||
"#if"
|
||||
"#ifdef"
|
||||
"#ifndef"
|
||||
"#else"
|
||||
"#elif"
|
||||
"#endif"
|
||||
"#elifdef"
|
||||
"#elifndef"
|
||||
(preproc_directive)
|
||||
] @keyword.directive
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
"#define" @keyword.directive.define
|
||||
|
||||
;; #8AD5FF #000000 0 0 0 0 2
|
||||
"#include" @keyword.import
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"try"
|
||||
"catch"
|
||||
"noexcept"
|
||||
"throw"
|
||||
] @keyword.exception
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"decltype"
|
||||
"explicit"
|
||||
"friend"
|
||||
"override"
|
||||
"using"
|
||||
"requires"
|
||||
"constexpr"
|
||||
] @keyword
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"class"
|
||||
"namespace"
|
||||
"template"
|
||||
"typename"
|
||||
"concept"
|
||||
] @keyword.type
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
[
|
||||
"co_await"
|
||||
"co_yield"
|
||||
"co_return"
|
||||
] @keyword.coroutine
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
[
|
||||
"public"
|
||||
"private"
|
||||
"protected"
|
||||
"final"
|
||||
"virtual"
|
||||
] @keyword.modifier
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(storage_class_specifier) @keyword.modifier
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
[
|
||||
(type_qualifier)
|
||||
(gnu_asm_qualifier)
|
||||
"__extension__"
|
||||
] @keyword.modifier
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(linkage_specification
|
||||
"extern" @keyword.modifier)
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 2
|
||||
[
|
||||
"new"
|
||||
"delete"
|
||||
"xor"
|
||||
"bitand"
|
||||
"bitor"
|
||||
"compl"
|
||||
"not"
|
||||
"xor_eq"
|
||||
"and_eq"
|
||||
"or_eq"
|
||||
"not_eq"
|
||||
"and"
|
||||
"or"
|
||||
] @keyword.operator
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 2
|
||||
"<=>" @operator
|
||||
|
||||
; ============================================================
|
||||
; Types & modules
|
||||
; ============================================================
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
[
|
||||
(type_identifier)
|
||||
(type_descriptor)
|
||||
] @type
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
(type_definition
|
||||
declarator: (type_identifier) @type.definition)
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
(primitive_type) @type.builtin
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
(sized_type_specifier
|
||||
_ @type.builtin
|
||||
type: _?)
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(namespace_identifier) @module
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
((namespace_identifier) @type
|
||||
(#match? @type "^[A-Z]"))
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(using_declaration
|
||||
.
|
||||
"using"
|
||||
.
|
||||
"namespace"
|
||||
.
|
||||
[
|
||||
(qualified_identifier)
|
||||
(identifier)
|
||||
] @module)
|
||||
|
||||
; ============================================================
|
||||
; Functions & calls
|
||||
; ============================================================
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 1
|
||||
(operator_name) @function
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 3
|
||||
"operator" @function
|
||||
|
||||
;; #78C2FF #000000 0 0 0 0 2
|
||||
(call_expression
|
||||
function: (identifier) @function.call)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (identifier) @function.builtin)
|
||||
(#match? @function.builtin "^__builtin_"))
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (identifier) @function.builtin))
|
||||
|
||||
; ============================================================
|
||||
; Constructors & methods
|
||||
; ============================================================
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (identifier) @constructor)
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (qualified_identifier
|
||||
name: (identifier) @constructor))
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 2
|
||||
((call_expression
|
||||
function: (field_expression
|
||||
field: (field_identifier) @constructor))
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 2
|
||||
((field_initializer
|
||||
(field_identifier) @constructor
|
||||
(argument_list))
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 4
|
||||
(destructor_name
|
||||
(identifier) @function.method)
|
||||
|
||||
; ============================================================
|
||||
; Properties & members
|
||||
; ============================================================
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
((field_expression
|
||||
(field_identifier) @property) @_parent)
|
||||
|
||||
(field_designator) @property
|
||||
|
||||
((field_identifier) @property)
|
||||
|
||||
(field_initializer
|
||||
(field_identifier) @property)
|
||||
|
||||
;; #F29CC3 #000000 0 0 1 0 2
|
||||
(field_declaration
|
||||
(field_identifier) @variable.member)
|
||||
|
||||
; ============================================================
|
||||
; Parameters
|
||||
; ============================================================
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(parameter_declaration
|
||||
declarator: (identifier) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(parameter_declaration
|
||||
declarator: (array_declarator) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(parameter_declaration
|
||||
declarator: (pointer_declarator) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(preproc_params
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(parameter_declaration
|
||||
declarator: (reference_declarator) @variable.parameter)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(variadic_parameter_declaration
|
||||
declarator: (variadic_declarator
|
||||
(_) @variable.parameter))
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(optional_parameter_declaration
|
||||
declarator: (_) @variable.parameter)
|
||||
|
||||
; ============================================================
|
||||
; Attributes & specifiers
|
||||
; ============================================================
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
[
|
||||
"__attribute__"
|
||||
"__declspec"
|
||||
"__based"
|
||||
"__cdecl"
|
||||
"__clrcall"
|
||||
"__stdcall"
|
||||
"__fastcall"
|
||||
"__thiscall"
|
||||
"__vectorcall"
|
||||
(ms_pointer_modifier)
|
||||
(attribute_declaration)
|
||||
] @attribute
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(identifier) @variable.builtin))
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(call_expression
|
||||
function: (identifier) @variable.builtin)))
|
||||
|
||||
; ============================================================
|
||||
; Operators & punctuation
|
||||
; ============================================================
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
[
|
||||
"="
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"+"
|
||||
"%"
|
||||
"~"
|
||||
"|"
|
||||
"&"
|
||||
"^"
|
||||
"<<"
|
||||
">>"
|
||||
"->"
|
||||
"<"
|
||||
"<="
|
||||
">="
|
||||
">"
|
||||
"=="
|
||||
"!="
|
||||
"!"
|
||||
"&&"
|
||||
"||"
|
||||
"-="
|
||||
"+="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"|="
|
||||
"&="
|
||||
"^="
|
||||
">>="
|
||||
"<<="
|
||||
"--"
|
||||
"++"
|
||||
] @operator
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
(comma_expression
|
||||
"," @operator)
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
[
|
||||
";"
|
||||
":"
|
||||
","
|
||||
"."
|
||||
"::"
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
"::" @punctuation.delimiter
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
"..." @punctuation.special
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
(template_argument_list
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
(template_parameter_list
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
||||
; ============================================================
|
||||
; Literals
|
||||
; ============================================================
|
||||
|
||||
;; #C2E8FF #000000 0 0 0 0 2
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
;; #C2E8FF #000000 0 0 0 0 2
|
||||
(true) @boolean_true
|
||||
|
||||
;; #C2E8FF #000000 0 0 0 0 2
|
||||
(false) @boolean_false
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 2
|
||||
(string_literal) @string
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 2
|
||||
(system_lib_string) @string
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 2
|
||||
(raw_string_literal) @string
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 2
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
;; #B8E986 #000000 0 0 0 0 2
|
||||
(number_literal) @number
|
||||
|
||||
;; #B8E986 #000000 0 0 0 0 2
|
||||
(char_literal) @character
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(null) @constant.builtin
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(null
|
||||
"nullptr" @constant.builtin)
|
||||
|
||||
; ============================================================
|
||||
; Macros & directives
|
||||
; ============================================================
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 3
|
||||
(preproc_def
|
||||
name: (_) @constant.macro)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 3
|
||||
(preproc_call
|
||||
directive: (preproc_directive) @_u
|
||||
argument: (_) @constant.macro
|
||||
(#match? @_u "^#undef$"))
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 3
|
||||
(preproc_ifdef
|
||||
name: (identifier) @constant.macro)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 3
|
||||
(preproc_elifdef
|
||||
name: (identifier) @constant.macro)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 3
|
||||
(preproc_defined
|
||||
(identifier) @constant.macro)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 3
|
||||
(preproc_defined) @function.macro
|
||||
|
||||
; ============================================================
|
||||
; Builtins & special identifiers
|
||||
; ============================================================
|
||||
|
||||
;; #F28FAD #000000 0 0 0 0 2
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(identifier) @variable.builtin))
|
||||
|
||||
;; #F28FAD #000000 0 0 0 0 2
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(call_expression
|
||||
function: (identifier) @variable.builtin)))
|
||||
|
||||
;; #F28FAD #000000 0 0 0 0 2
|
||||
(this) @variable.builtin
|
||||
|
||||
; ============================================================
|
||||
; Exceptions & control helpers
|
||||
; ============================================================
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 2
|
||||
"static_assert" @function.builtin
|
||||
|
||||
; ============================================================
|
||||
; Comments
|
||||
; ============================================================
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment @spell
|
||||
@@ -1,207 +0,0 @@
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(variable) @variable
|
||||
|
||||
;; Lambdas / patterns keep params white
|
||||
;; #FFFFFF #000000 0 1 0 0 5
|
||||
(expression/lambda
|
||||
(_)+ @variable.parameter
|
||||
"->")
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(decl/function
|
||||
patterns: (patterns
|
||||
(_) @variable.parameter))
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(decl/function
|
||||
(infix
|
||||
(pattern) @variable.parameter))
|
||||
|
||||
;; Types / builtins
|
||||
;; #F07178 #000000 0 0 0 0 6
|
||||
((name) @type.builtin
|
||||
(#match? @type.builtin "^(Int|Integer|Bool|Char|String|Float|Double|Word)$"))
|
||||
|
||||
;; Strings / chars
|
||||
;; #9ADE7A #000000 0 0 0 0 1
|
||||
(char) @literal.char
|
||||
;; #9ADE7A #000000 0 0 0 0 1
|
||||
(string) @literal.string
|
||||
|
||||
;; Comments
|
||||
;; #99ADBF #000000 0 1 0 0 5
|
||||
(comment) @comment.general
|
||||
;; #99ADBF #000000 0 1 0 0 5
|
||||
(haddock) @comment.documentation
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @spell
|
||||
|
||||
;; Punctuation
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[
|
||||
"(" ")" "{" "}" "[" "]"
|
||||
] @punctuation.bracket
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[ "," ";" ] @punctuation.delimiter
|
||||
|
||||
;; Keywords (orange)
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[ "forall" ] @keyword.quantifier
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(pragma) @keyword.directive
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"if" "then" "else" "case" "of"
|
||||
] @keyword.conditional
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[ "import" "qualified" "module" ] @keyword.import
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"where" "let" "in" "class" "instance" "pattern" "data"
|
||||
"newtype" "family" "type" "as" "hiding" "deriving" "via"
|
||||
"stock" "anyclass" "do" "mdo" "rec" "infix" "infixl" "infixr"
|
||||
] @keyword.definition
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[ "forall" ] @keyword.repeat
|
||||
|
||||
;; Operators (italic white, high priority)
|
||||
;; #FFFFFF #000000 0 1 0 0 6
|
||||
[
|
||||
(operator)
|
||||
(constructor_operator)
|
||||
(all_names)
|
||||
"." ".." "=" "|" "::" "=>" "->" "<-" "\\" "`" "@"
|
||||
] @operator.general
|
||||
;; #FFFFFF #000000 0 1 0 0 6
|
||||
(infix_id
|
||||
[
|
||||
(variable) @operator.infix
|
||||
(qualified (variable) @operator.infix)
|
||||
])
|
||||
;; #FFFFFF #000000 0 1 0 0 6
|
||||
[
|
||||
(operator)
|
||||
(constructor_operator)
|
||||
(all_names)
|
||||
(wildcard)
|
||||
"." ".." "=" "|" "::" "=>" "->" "<-" "\\" "`" "@"
|
||||
] @operator
|
||||
|
||||
;; Modules
|
||||
;; #7dcfff #000000 0 0 0 0 1
|
||||
(module
|
||||
(module_id) @module.name)
|
||||
;; #7dcfff #000000 0 0 0 0 1
|
||||
(module
|
||||
(module_id) @module)
|
||||
|
||||
;; Functions / calls (leave blue for function identifiers, but vars stay white due to higher priority var rules)
|
||||
;; #82AAFF #000000 0 0 0 0 3
|
||||
(decl/signature
|
||||
[
|
||||
name: (variable) @function.name
|
||||
names: (binding_list (variable) @function.name)
|
||||
])
|
||||
;; #82AAFF #000000 0 0 0 0 3
|
||||
(decl/function
|
||||
[
|
||||
name: (variable) @function.name
|
||||
names: (binding_list (variable) @function.name)
|
||||
])
|
||||
;; #82AAFF #000000 0 0 0 0 3
|
||||
(decl/bind
|
||||
[
|
||||
name: (variable) @function.name
|
||||
names: (binding_list (variable) @function.name)
|
||||
])
|
||||
;; #82AAFF #000000 0 0 0 0 2
|
||||
(decl
|
||||
[
|
||||
name: (variable) @function
|
||||
names: (binding_list (variable) @function)
|
||||
])
|
||||
;; #82AAFF #000000 0 0 0 0 3
|
||||
(decl/signature
|
||||
name: (variable) @function.io
|
||||
type: (type/apply
|
||||
constructor: (name) @_io)
|
||||
(#match? @_io "^IO$"))
|
||||
|
||||
;; Function calls kept white via var priority; ensure explicit call rule stays neutral/white
|
||||
;; #FFFFFF #000000 0 0 0 0 3
|
||||
(apply
|
||||
[
|
||||
(expression/variable) @function.call
|
||||
(expression/qualified (variable) @function.call)
|
||||
])
|
||||
|
||||
;; Types / constructors
|
||||
;; #82AAFF #000000 0 0 0 0 3
|
||||
(name) @type
|
||||
;; #82AAFF #000000 0 0 0 0 3
|
||||
(type/star) @type
|
||||
;; #C6B5FF #000000 0 0 0 0 1
|
||||
(constructor) @constructor.general
|
||||
;; #9ADE7A #000000 0 0 0 0 2
|
||||
((constructor) @boolean
|
||||
(#match? @boolean "^(True|False)$"))
|
||||
;; #9ADE7A #000000 0 0 0 0 1
|
||||
((variable) @boolean
|
||||
(#match? @boolean "^otherwise$"))
|
||||
|
||||
;; Quoters / quasiquotes
|
||||
;; #82AAFF #000000 0 0 0 0 3
|
||||
(quoter) @function.call
|
||||
;; #9ADE7A #000000 0 0 0 0 1
|
||||
(quasiquote
|
||||
[
|
||||
(quoter) @_name
|
||||
(_
|
||||
(variable) @_name)
|
||||
]
|
||||
(#match? @_name "^qq$")
|
||||
(quasiquote_body) @string)
|
||||
;; #9ADE7A #000000 0 0 0 0 1
|
||||
(quasiquote
|
||||
(_
|
||||
(variable) @_name)
|
||||
(#match? @_name "^qq$")
|
||||
(quasiquote_body) @string)
|
||||
;; #82AAFF #000000 0 0 0 0 3
|
||||
(quasiquote
|
||||
(_
|
||||
(module) @module
|
||||
.
|
||||
(variable) @function.call))
|
||||
|
||||
;; Exceptions / Debug
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
((variable) @keyword.exception
|
||||
(#match? @keyword.exception "^(error|undefined|try|tryJust|tryAny|catch|catches|catchJust|handle|handleJust|throw|throwIO|throwTo|throwError|ioError|mask|mask_|uninterruptibleMask|uninterruptibleMask_|bracket|bracket_|bracketOnErrorSource|finally|fail|onException|expectationFailure)$"))
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
((variable) @keyword.debug
|
||||
(#match? @keyword.debug "^(trace|traceId|traceShow|traceShowId|traceWith|traceShowWith|traceStack|traceIO|traceM|traceShowM|traceEvent|traceEventWith|traceEventIO|flushEventLog|traceMarker|traceMarkerIO)$"))
|
||||
|
||||
;; Misc remaining structural
|
||||
;; #C6B5FF #000000 0 0 0 0 1
|
||||
(wildcard) @literal.special
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[ "," ";" ] @punctuation.delimiter
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[
|
||||
"(" ")" "{" "}" "[" "]"
|
||||
] @punctuation.bracket
|
||||
;; #7dcfff #000000 0 0 0 0 1
|
||||
(type/unit) @type.unit
|
||||
(type/list) @type.list
|
||||
(type/star) @type.star
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(field_name (variable) @variable.member)
|
||||
(import_name (name) . (children (variable) @variable.member))
|
||||
|
||||
;; Numbers (bright yellow-green)
|
||||
;; #DFFFA0 #000000 0 0 0 0 2
|
||||
(integer) @number.integer
|
||||
;; #DFFFA0 #000000 0 0 0 0 2
|
||||
(negation) @number.integer
|
||||
;; #DFFFA0 #000000 0 0 0 0 2
|
||||
(expression/literal
|
||||
(float) @number.float)
|
||||
@@ -1,334 +0,0 @@
|
||||
;; #82AAFF #000000 1 0 1 0 4
|
||||
(setext_heading
|
||||
(paragraph) @markup.heading.1
|
||||
(setext_h1_underline) @markup.heading.1)
|
||||
|
||||
;; #82AAFF #000000 1 0 1 0 4
|
||||
(setext_heading
|
||||
(paragraph) @markup.heading.2
|
||||
(setext_h2_underline) @markup.heading.2)
|
||||
|
||||
(atx_heading
|
||||
(atx_h1_marker)) @markup.heading.1
|
||||
|
||||
(atx_heading
|
||||
(atx_h2_marker)) @markup.heading.2
|
||||
|
||||
;; #82AAFF #000000 1 0 0 0 4
|
||||
(atx_heading
|
||||
(atx_h3_marker)) @markup.heading.3
|
||||
|
||||
;; #82AAFF #000000 1 0 0 0 4
|
||||
(atx_heading
|
||||
(atx_h4_marker)) @markup.heading.4
|
||||
|
||||
;; #82AAFF #000000 1 0 0 0 4
|
||||
(atx_heading
|
||||
(atx_h5_marker)) @markup.heading.5
|
||||
|
||||
;; #82AAFF #000000 1 0 0 0 4
|
||||
(atx_heading
|
||||
(atx_h6_marker)) @markup.heading.6
|
||||
|
||||
;; #82AAFF #000000 0 0 0 0 4
|
||||
(info_string) @label
|
||||
|
||||
;; #FF6347 #000000 0 0 0 0 4
|
||||
(pipe_table_header
|
||||
(pipe_table_cell) @markup.heading)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 4
|
||||
(pipe_table_header
|
||||
"|" @punctuation.special)
|
||||
|
||||
(pipe_table_row
|
||||
"|" @punctuation.special)
|
||||
|
||||
(pipe_table_delimiter_row
|
||||
"|" @punctuation.special)
|
||||
|
||||
(pipe_table_delimiter_cell) @punctuation.special
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 2
|
||||
(indented_code_block) @markup.raw.block
|
||||
|
||||
(fenced_code_block) @markup.raw.block
|
||||
|
||||
(fenced_code_block
|
||||
(fenced_code_block_delimiter) @markup.raw.block)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @label))
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 6
|
||||
(link_destination) @markup.link.url
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 6
|
||||
[
|
||||
(link_title)
|
||||
(link_label)
|
||||
] @markup.link.label
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 4
|
||||
((link_label)
|
||||
.
|
||||
":" @punctuation.delimiter)
|
||||
|
||||
;; #9ADE7A #000000 0 0 0 0 4
|
||||
[
|
||||
(list_marker_plus)
|
||||
(list_marker_minus)
|
||||
(list_marker_star)
|
||||
(list_marker_dot)
|
||||
(list_marker_parenthesis)
|
||||
] @markup.list
|
||||
|
||||
(thematic_break) @punctuation.special
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 4
|
||||
(task_list_marker_unchecked) @markup.list.unchecked
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 4
|
||||
(task_list_marker_checked) @markup.list.checked
|
||||
|
||||
[
|
||||
(plus_metadata)
|
||||
(minus_metadata)
|
||||
] @keyword.directive
|
||||
|
||||
[
|
||||
(block_continuation)
|
||||
(block_quote_marker)
|
||||
] @punctuation.special
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 6
|
||||
(backslash_escape) @string.escape
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^ruby$"))
|
||||
;; !ruby
|
||||
(code_fence_content) @injection.ruby)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^bash$"))
|
||||
;; !bash
|
||||
(code_fence_content) @injection.bash)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^cpp$"))
|
||||
;; !cpp
|
||||
(code_fence_content) @injection.cpp)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^objective-cpp$"))
|
||||
;; !cpp
|
||||
(code_fence_content) @injection.cpp)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^h$"))
|
||||
;; !h
|
||||
(code_fence_content) @injection.h)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^c$"))
|
||||
;; !c
|
||||
(code_fence_content) @injection.h)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^css$"))
|
||||
;; !css
|
||||
(code_fence_content) @injection.css)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^fish$"))
|
||||
;; !fish
|
||||
(code_fence_content) @injection.fish)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^go$"))
|
||||
;; !go
|
||||
(code_fence_content) @injection.go)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^haskell$"))
|
||||
;; !haskell
|
||||
(code_fence_content) @injection.haskell)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^html$"))
|
||||
;; !html
|
||||
(code_fence_content) @injection.html)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^javascript$"))
|
||||
;; !javascript
|
||||
(code_fence_content) @injection.javascript)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^json$"))
|
||||
;; !json
|
||||
(code_fence_content) @injection.json)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^lua$"))
|
||||
; - lua format in hover boxes is typed making it unparsable as normal lua
|
||||
; - TODO: add a lua grammar with typing or remove this injection
|
||||
(code_fence_content) @injection.lua)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^regex$"))
|
||||
;; !regex
|
||||
(code_fence_content) @injection.regex)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^query$"))
|
||||
;; !query
|
||||
(code_fence_content) @injection.query)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^markdown$"))
|
||||
;; !markdown
|
||||
(code_fence_content) @injection.markdown)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^markdown_inline$"))
|
||||
;; !markdown_inline
|
||||
(code_fence_content) @injection.markdown_inline)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^erb$"))
|
||||
;; !embedded_template
|
||||
(code_fence_content) @injection.embedded_template)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^python$"))
|
||||
;; !python
|
||||
(code_fence_content) @injection.python)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^php$"))
|
||||
;; !php
|
||||
(code_fence_content) @injection.php)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^rust$"))
|
||||
;; !rust
|
||||
(code_fence_content) @injection.rust)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^sql$"))
|
||||
;; !sql
|
||||
(code_fence_content) @injection.sql)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^gitattributes$"))
|
||||
;; !gitattributes
|
||||
(code_fence_content) @injection.gitattributes)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^gitignore$"))
|
||||
;; !gitignore
|
||||
(code_fence_content) @injection.gitignore)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^gdscript$"))
|
||||
;; !gdscript
|
||||
(code_fence_content) @injection.gdscript)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^make$"))
|
||||
;; !make
|
||||
(code_fence_content) @injection.make)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^diff$"))
|
||||
;; !diff
|
||||
(code_fence_content) @injection.diff)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^ini$"))
|
||||
;; !ini
|
||||
(code_fence_content) @injection.ini)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^nginx$"))
|
||||
;; !nginx
|
||||
(code_fence_content) @injection.nginx)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^toml$"))
|
||||
;; !toml
|
||||
(code_fence_content) @injection.toml)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^yaml$"))
|
||||
;; !yaml
|
||||
(code_fence_content) @injection.yaml)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^gomod$"))
|
||||
;; !gomod
|
||||
(code_fence_content) @injection.gomod)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^man$"))
|
||||
;; !man
|
||||
(code_fence_content) @injection.man)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^cabal$"))
|
||||
;; !cabal
|
||||
(code_fence_content) @injection.cabal)
|
||||
|
||||
;; !html
|
||||
(html_block) @injection.html
|
||||
|
||||
;; !yaml
|
||||
(minus_metadata) @injection.yaml
|
||||
|
||||
;; !toml
|
||||
(plus_metadata) @injection.toml
|
||||
|
||||
;; !markdown_inline
|
||||
(paragraph) @inline
|
||||
|
||||
(pipe_table_row
|
||||
(pipe_table_cell) @inline)
|
||||
|
||||
(block_quote ((paragraph) @inline))
|
||||
146
grammar/html.scm
146
grammar/html.scm
@@ -1,146 +0,0 @@
|
||||
;; #99ADBF #000000 0 1 0 0 5
|
||||
(comment) @comment @spell
|
||||
|
||||
;; #9ADE7A #000000 0 0 0 0 1
|
||||
(attribute_name) @tag.attribute
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 0
|
||||
((attribute
|
||||
(quoted_attribute_value) @string))
|
||||
|
||||
(attribute_value) @string
|
||||
|
||||
[
|
||||
"'"
|
||||
"\""
|
||||
] @string
|
||||
|
||||
;; #82AAFF #000000 1 0 0 0 3
|
||||
((element
|
||||
(start_tag
|
||||
(tag_name) @_tag)
|
||||
(text) @markup.heading)
|
||||
(#match? @_tag "^title$"))
|
||||
|
||||
;; #82AAFF #000000 1 0 1 0 3
|
||||
((element
|
||||
(start_tag
|
||||
(tag_name) @_tag)
|
||||
(text) @markup.heading.1)
|
||||
(#match? @_tag "^h[1-6]$"))
|
||||
|
||||
;; #FFD700 #000000 1 0 0 0 2
|
||||
((element
|
||||
(start_tag
|
||||
(tag_name) @_tag)
|
||||
(text) @markup.strong)
|
||||
(#match? @_tag "^(strong|b)$"))
|
||||
|
||||
;; #FF8F40 #000000 0 1 0 0 2
|
||||
((element
|
||||
(start_tag
|
||||
(tag_name) @_tag)
|
||||
(text) @markup.italic)
|
||||
(#match? @_tag "^(em|i)$"))
|
||||
|
||||
;; #FF6347 #000000 0 0 0 1 2
|
||||
((element
|
||||
(start_tag
|
||||
(tag_name) @_tag)
|
||||
(text) @markup.strikethrough)
|
||||
(#match? @_tag "^(s|del)$"))
|
||||
|
||||
;; #82AAFF #000000 0 0 1 0 2
|
||||
((element
|
||||
(start_tag
|
||||
(tag_name) @_tag)
|
||||
(text) @markup.underline)
|
||||
(#match? @_tag "^u$"))
|
||||
|
||||
;; #9ADE7A #000000 0 0 0 0 2
|
||||
((element
|
||||
(start_tag
|
||||
(tag_name) @_tag)
|
||||
(text) @markup.raw)
|
||||
(#match? @_tag "^(code|kbd)$"))
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 2
|
||||
((element
|
||||
(start_tag
|
||||
(tag_name) @_tag)
|
||||
(text) @markup.link.label)
|
||||
(#match? @_tag "^a$"))
|
||||
|
||||
((attribute
|
||||
(attribute_name) @_attr
|
||||
(quoted_attribute_value
|
||||
;; #7dcfff #000000 0 0 1 0 5
|
||||
(attribute_value) @string.special.url))
|
||||
(#match? @_attr "^(href|src)$"))
|
||||
|
||||
;; Punctuation
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
"</"
|
||||
"/>"
|
||||
] @tag.delimiter
|
||||
|
||||
;; #FFFFFF #000000 0 1 0 0 1
|
||||
"=" @operator
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 1
|
||||
(tag_name) @tag
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(erroneous_end_tag_name) @tag.error
|
||||
|
||||
;; #FFD700 #000000 0 0 0 0 1
|
||||
(doctype) @constant
|
||||
|
||||
;; #9ADE7A #000000 0 0 0 0 1
|
||||
(attribute_name) @attribute
|
||||
|
||||
; Injections
|
||||
|
||||
((style_element
|
||||
(start_tag) @_start_tag
|
||||
;; !css
|
||||
(raw_text) @injection.css))
|
||||
|
||||
((attribute
|
||||
(attribute_name) @_attr
|
||||
(quoted_attribute_value
|
||||
(attribute_value) @injection.css))
|
||||
(#match? @_attr "^style$"))
|
||||
|
||||
((script_element
|
||||
(start_tag) @_start
|
||||
;; !javascript
|
||||
(raw_text) @injection.javascript)
|
||||
(#match? @_start "^<script\\b(?![^>]*\\btype\\s*=\\s*\\\"(?!module|text/javascript)[^\\\"]*\\\")[^>]*>$"))
|
||||
|
||||
((attribute
|
||||
(attribute_name) @_name
|
||||
(quoted_attribute_value
|
||||
(attribute_value) @injection.javascript))
|
||||
(#match? @_name "^on[a-z]+$"))
|
||||
|
||||
((attribute
|
||||
(quoted_attribute_value
|
||||
(attribute_value) @injection.javascript))
|
||||
(#match? @injection.javascript "\\$\\{"))
|
||||
|
||||
((script_element
|
||||
(start_tag) @_start
|
||||
;; !json
|
||||
(raw_text) @injection.json)
|
||||
(#match? @_start "^<script\\b(?![^>]*\\btype\\s*=\\s*\\\"(?!importmap)[^\\\"]*\\\")[^>]*>$"))
|
||||
|
||||
((attribute
|
||||
(attribute_name) @_name
|
||||
(quoted_attribute_value
|
||||
;; !regex
|
||||
(attribute_value) @injection.regex))
|
||||
(#match? @_name "^pattern$"))
|
||||
@@ -1,34 +0,0 @@
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(section_name
|
||||
(text) @type)
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment @spell
|
||||
|
||||
;; #888888 #000000 0 0 0 0 3
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
"=" @operator
|
||||
|
||||
;; #F0F8FF #000000 0 0 0 0 2
|
||||
(setting
|
||||
(setting_name) @property)
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 2
|
||||
((setting_value) @boolean
|
||||
(#match? @boolean "^\\s*(true|false|True|False|yes|no|Yes|No|on|off|On|Off|)\\s*$"))
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
((setting_value) @number
|
||||
(#match? @number "^\\s*[-+0-9]+\\s*$"))
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 2
|
||||
((setting_value) @float
|
||||
(#match? @float "^\\s*[-+0-9\\.]+\\s*$"))
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
(setting_value) @string
|
||||
@@ -1,316 +0,0 @@
|
||||
; ============================================================
|
||||
; Identifiers
|
||||
; ============================================================
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(identifier) @variable
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z_][A-Z0-9_]*$"))
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 3
|
||||
((identifier) @variable.builtin
|
||||
(#match? @variable.builtin
|
||||
"^(arguments|console|window|document|globalThis|process|module|exports)$"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 1
|
||||
((identifier) @constructor
|
||||
(#match? @constructor "^[A-Z][a-zA-Z0-9]*$"))
|
||||
|
||||
; ============================================================
|
||||
; Properties
|
||||
; ============================================================
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
(property_identifier) @property
|
||||
|
||||
; ============================================================
|
||||
; Functions
|
||||
; ============================================================
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(function_declaration
|
||||
name: (identifier) @function)
|
||||
|
||||
(function_expression
|
||||
name: (identifier) @function)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(method_definition
|
||||
name: (property_identifier) @function.method)
|
||||
|
||||
(variable_declarator
|
||||
name: (identifier) @function
|
||||
value: [(function_expression) (arrow_function)])
|
||||
|
||||
(assignment_expression
|
||||
left: (identifier) @function
|
||||
right: [(function_expression) (arrow_function)])
|
||||
|
||||
(pair
|
||||
key: (property_identifier) @function.method
|
||||
value: [(function_expression) (arrow_function)])
|
||||
|
||||
; ------------------------------------------------------------
|
||||
; Function calls
|
||||
; ------------------------------------------------------------
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(call_expression
|
||||
function: (identifier) @function.call)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(call_expression
|
||||
function: (member_expression
|
||||
property: (property_identifier) @function.method))
|
||||
|
||||
; ============================================================
|
||||
; Highlighted definitions & references
|
||||
; ============================================================
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(assignment_expression
|
||||
left: [
|
||||
(identifier) @name
|
||||
(member_expression
|
||||
property: (property_identifier) @name)
|
||||
]
|
||||
right: [(arrow_function) (function_expression)]
|
||||
) @definition.function
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(pair
|
||||
key: (property_identifier) @name
|
||||
value: [(arrow_function) (function_expression)]) @definition.function
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 0
|
||||
((call_expression
|
||||
function: (identifier) @name) @reference.call
|
||||
(#not-match? @name "^(require)$"))
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(new_expression
|
||||
constructor: (_) @name) @reference.class
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(export_statement value: (assignment_expression left: (identifier) @name right: ([
|
||||
(number)
|
||||
(string)
|
||||
(identifier)
|
||||
(undefined)
|
||||
(null)
|
||||
(new_expression)
|
||||
(binary_expression)
|
||||
(call_expression)
|
||||
]))) @definition.constant
|
||||
|
||||
; ============================================================
|
||||
; Parameters
|
||||
; ============================================================
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(formal_parameters
|
||||
[
|
||||
(identifier) @variable.parameter
|
||||
(array_pattern
|
||||
(identifier) @variable.parameter)
|
||||
(object_pattern
|
||||
[
|
||||
(pair_pattern value: (identifier) @variable.parameter)
|
||||
(shorthand_property_identifier_pattern) @variable.parameter
|
||||
])
|
||||
])
|
||||
|
||||
; ============================================================
|
||||
; Keywords (split into semantic groups)
|
||||
; ============================================================
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
; Declarations
|
||||
[
|
||||
"var"
|
||||
"let"
|
||||
"const"
|
||||
"function"
|
||||
"class"
|
||||
] @keyword.declaration
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
; Control flow
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"switch"
|
||||
"case"
|
||||
"default"
|
||||
"for"
|
||||
"while"
|
||||
"do"
|
||||
"break"
|
||||
"continue"
|
||||
"return"
|
||||
"throw"
|
||||
"try"
|
||||
"catch"
|
||||
"finally"
|
||||
"extends"
|
||||
] @keyword.control
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
; Imports / exports
|
||||
[
|
||||
"import"
|
||||
"export"
|
||||
"from"
|
||||
"as"
|
||||
] @keyword.import
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
; Operators-as-keywords
|
||||
[
|
||||
"in"
|
||||
"instanceof"
|
||||
"new"
|
||||
"delete"
|
||||
"typeof"
|
||||
"void"
|
||||
"await"
|
||||
"yield"
|
||||
] @keyword.operator
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
; Modifiers
|
||||
[
|
||||
"async"
|
||||
"static"
|
||||
"get"
|
||||
"set"
|
||||
] @keyword.modifier
|
||||
|
||||
; ============================================================
|
||||
; Literals
|
||||
; ============================================================
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
(this) @variable.builtin
|
||||
(super) @variable.builtin
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 4
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
(null)
|
||||
(undefined)
|
||||
] @constant.builtin
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(number) @number
|
||||
|
||||
;; #D2A6FF #000000 0 1 0 0 2
|
||||
((string) @use_strict
|
||||
(#match? @use_strict "^['\"]use strict['\"]$"))
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 0
|
||||
(string) @string
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 0
|
||||
(template_string) @string.special
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment
|
||||
|
||||
; ============================================================
|
||||
; Operators & punctuation
|
||||
; ============================================================
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
[
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"**"
|
||||
"++"
|
||||
"--"
|
||||
"=="
|
||||
"!="
|
||||
"==="
|
||||
"!=="
|
||||
"<"
|
||||
"<="
|
||||
">"
|
||||
">="
|
||||
"&&"
|
||||
"||"
|
||||
"??"
|
||||
"!"
|
||||
"~"
|
||||
"&"
|
||||
"|"
|
||||
"^"
|
||||
"<<"
|
||||
">>"
|
||||
">>>"
|
||||
"="
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"<<="
|
||||
">>="
|
||||
">>>="
|
||||
"&="
|
||||
"|="
|
||||
"^="
|
||||
"&&="
|
||||
"||="
|
||||
"??="
|
||||
"=>"
|
||||
] @operator
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[
|
||||
"."
|
||||
","
|
||||
";"
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(template_substitution
|
||||
"${" @punctuation.special
|
||||
"}" @punctuation.special)
|
||||
|
||||
; ============================================================
|
||||
; JSX
|
||||
; ============================================================
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 4
|
||||
(jsx_opening_element (identifier) @tag2)
|
||||
(jsx_closing_element (identifier) @tag2)
|
||||
(jsx_self_closing_element (identifier) @tag2)
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 3
|
||||
(jsx_attribute (property_identifier) @attribute2)
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 3
|
||||
(jsx_opening_element (["<" ">"]) @punctuation.bracket2)
|
||||
(jsx_closing_element (["</" ">"]) @punctuation.bracket2)
|
||||
(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket2)
|
||||
|
||||
; Injections
|
||||
|
||||
;; !regex
|
||||
(regex) @string.regex
|
||||
@@ -1,22 +0,0 @@
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(pair
|
||||
key: (_) @string.special.key)
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
(string) @string
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(number) @number
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
[
|
||||
(null)
|
||||
(true)
|
||||
(false)
|
||||
] @constant.builtin
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(escape_sequence) @escape
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment
|
||||
@@ -1,22 +0,0 @@
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(pair
|
||||
key: (_) @string.special.key)
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
(string) @string
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(number) @number
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
[
|
||||
(null)
|
||||
(true)
|
||||
(false)
|
||||
] @constant.builtin
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(escape_sequence) @escape
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment
|
||||
312
grammar/lua.scm
312
grammar/lua.scm
@@ -1,312 +0,0 @@
|
||||
; ============================================================
|
||||
; Identifiers
|
||||
; ============================================================
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(identifier) @variable
|
||||
|
||||
;; #C9B4FF #000000 0 0 0 0 2
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z_0-9]*$"))
|
||||
|
||||
;; #F28FAD #000000 0 0 0 0 3
|
||||
((identifier) @variable.builtin
|
||||
(#match? @variable.builtin "^self$"))
|
||||
|
||||
; Attributes (generic parameters)
|
||||
;; #7CD5CF #000000 0 0 0 0 2
|
||||
(variable_list
|
||||
(attribute
|
||||
"<" @punctuation.bracket
|
||||
(identifier) @attribute
|
||||
">" @punctuation.bracket))
|
||||
|
||||
; ============================================================
|
||||
; Control flow & keywords
|
||||
; ============================================================
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
"return" @keyword.return
|
||||
|
||||
;; #FF9E64 #000000 0 0 0 0 2
|
||||
[
|
||||
"goto"
|
||||
"in"
|
||||
"local"
|
||||
] @keyword
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(label_statement) @label
|
||||
|
||||
;; #FF9E64 #000000 0 0 0 0 2
|
||||
(break_statement) @keyword
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(do_statement
|
||||
[
|
||||
"do"
|
||||
"end"
|
||||
] @keyword)
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(while_statement
|
||||
[
|
||||
"while"
|
||||
"do"
|
||||
"end"
|
||||
] @repeat)
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(repeat_statement
|
||||
[
|
||||
"repeat"
|
||||
"until"
|
||||
] @repeat)
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 2
|
||||
(if_statement
|
||||
[
|
||||
"if"
|
||||
"elseif"
|
||||
"else"
|
||||
"then"
|
||||
"end"
|
||||
] @conditional)
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(elseif_statement
|
||||
[
|
||||
"elseif"
|
||||
"then"
|
||||
"end"
|
||||
] @conditional)
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(else_statement
|
||||
[
|
||||
"else"
|
||||
"end"
|
||||
] @conditional)
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(for_statement
|
||||
[
|
||||
"for"
|
||||
"do"
|
||||
"end"
|
||||
] @repeat)
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 2
|
||||
(function_declaration
|
||||
[
|
||||
"function"
|
||||
"end"
|
||||
] @keyword.function)
|
||||
|
||||
;; #FFB870 #000000 0 0 0 0 2
|
||||
(function_definition
|
||||
[
|
||||
"function"
|
||||
"end"
|
||||
] @keyword.function)
|
||||
|
||||
; ============================================================
|
||||
; Operators
|
||||
; ============================================================
|
||||
|
||||
;; #6BD9DF #000000 0 1 0 0 1
|
||||
(binary_expression operator: _ @operator)
|
||||
|
||||
;; #6BD9DF #000000 0 1 0 0 1
|
||||
(unary_expression operator: _ @operator)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 1
|
||||
[
|
||||
"and"
|
||||
"not"
|
||||
"or"
|
||||
] @keyword.operator
|
||||
|
||||
; ============================================================
|
||||
; Punctuation
|
||||
; ============================================================
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
[
|
||||
";"
|
||||
":"
|
||||
","
|
||||
"."
|
||||
] @punctuation.delimiter
|
||||
|
||||
; Brackets
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
; ============================================================
|
||||
; Tables & fields
|
||||
; ============================================================
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 1
|
||||
(field name: (identifier) @field)
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 1
|
||||
(dot_index_expression field: (identifier) @field)
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 1
|
||||
(table_constructor
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
] @constructor)
|
||||
|
||||
; ============================================================
|
||||
; Functions
|
||||
; ============================================================
|
||||
|
||||
;; #FFC877 #000000 0 0 0 0 3
|
||||
(parameters (identifier) @parameter)
|
||||
|
||||
;; #FFC877 #000000 0 0 0 0 3
|
||||
(function_declaration
|
||||
name: [
|
||||
(identifier) @function
|
||||
(dot_index_expression
|
||||
field: (identifier) @function)
|
||||
])
|
||||
|
||||
;; #FFC877 #000000 0 0 0 0 3
|
||||
(function_declaration
|
||||
name: (method_index_expression
|
||||
method: (identifier) @method))
|
||||
|
||||
;; #FFC877 #000000 0 0 0 0 3
|
||||
(assignment_statement
|
||||
(variable_list .
|
||||
name: [
|
||||
(identifier) @function
|
||||
(dot_index_expression
|
||||
field: (identifier) @function)
|
||||
])
|
||||
(expression_list .
|
||||
value: (function_definition)))
|
||||
|
||||
;; #FFC877 #000000 0 0 0 0 3
|
||||
(table_constructor
|
||||
(field
|
||||
name: (identifier) @function
|
||||
value: (function_definition)))
|
||||
|
||||
; Function calls
|
||||
;; #78C2FF #000000 0 0 0 0 2
|
||||
(function_call
|
||||
name: [
|
||||
(identifier) @function.call
|
||||
(dot_index_expression
|
||||
field: (identifier) @function.call)
|
||||
(method_index_expression
|
||||
method: (identifier) @method.call)
|
||||
])
|
||||
|
||||
; Highlighted definitions & references
|
||||
;; #FFC877 #000000 0 0 0 0 3
|
||||
(function_declaration
|
||||
name: [
|
||||
(identifier) @name
|
||||
(dot_index_expression
|
||||
field: (identifier) @name)
|
||||
]) @definition.function
|
||||
|
||||
;; #FFC877 #000000 0 0 0 0 3
|
||||
(function_declaration
|
||||
name: (method_index_expression
|
||||
method: (identifier) @name)) @definition.method
|
||||
|
||||
;; #FFC877 #000000 0 0 0 0 3
|
||||
(assignment_statement
|
||||
(variable_list .
|
||||
name: [
|
||||
(identifier) @name
|
||||
(dot_index_expression
|
||||
field: (identifier) @name)
|
||||
])
|
||||
(expression_list .
|
||||
value: (function_definition))) @definition.function
|
||||
|
||||
;; #FFC877 #000000 0 0 0 0 3
|
||||
(table_constructor
|
||||
(field
|
||||
name: (identifier) @name
|
||||
value: (function_definition))) @definition.function
|
||||
|
||||
;; #78C2FF #000000 0 0 0 0 2
|
||||
(function_call
|
||||
name: [
|
||||
(identifier) @name
|
||||
(dot_index_expression
|
||||
field: (identifier) @name)
|
||||
(method_index_expression
|
||||
method: (identifier) @name)
|
||||
]) @reference.call
|
||||
|
||||
; Builtins
|
||||
;; #F28FAD #000000 0 0 0 0 2
|
||||
(function_call
|
||||
(identifier) @function.builtin
|
||||
(#match? @function.builtin "^(assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|loadstring|module|next|pairs|pcall|print|rawequal|rawget|rawset|required|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)$"))
|
||||
|
||||
; ============================================================
|
||||
; Literals & constants
|
||||
; ============================================================
|
||||
|
||||
;; #B8E986 #000000 0 0 0 0 5
|
||||
(number) @number
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 5
|
||||
(string) @string
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 6
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
;; #C9B4FF #000000 0 0 0 0 2
|
||||
(vararg_expression) @constant
|
||||
|
||||
;; #C9B4FF #000000 0 0 0 0 2
|
||||
(nil) @constant.builtin
|
||||
|
||||
;; #C2E8FF #000000 0 0 0 0 2
|
||||
[
|
||||
(false)
|
||||
(true)
|
||||
] @boolean
|
||||
|
||||
; ============================================================
|
||||
; Comments & directives
|
||||
; ============================================================
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment
|
||||
|
||||
;; #7CD5CF #000000 0 0 0 0 1
|
||||
(hash_bang_line) @preproc
|
||||
|
||||
; ============================================================
|
||||
; Injections
|
||||
; ============================================================
|
||||
|
||||
;; #7CD5CF #000000 0 1 0 0 2
|
||||
((function_call
|
||||
name: [
|
||||
(identifier) @_cdef_identifier
|
||||
(_ _ (identifier) @_cdef_identifier)
|
||||
]
|
||||
;; !c
|
||||
arguments: (arguments (string content: _ @injection.c)))
|
||||
(#match? @_cdef_identifier "^cdef$"))
|
||||
191
grammar/make.scm
191
grammar/make.scm
@@ -1,191 +0,0 @@
|
||||
;; #9CDCFE #000000 0 0 0 0 3
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #C2E8FF #000000 0 1 0 0 2
|
||||
[
|
||||
":"
|
||||
"&:"
|
||||
"::"
|
||||
"|"
|
||||
";"
|
||||
"\""
|
||||
"'"
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #FFD700 #000000 0 0 0 0 2
|
||||
[
|
||||
"$"
|
||||
"$$"
|
||||
] @punctuation.special
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
(automatic_variable
|
||||
[ "@" "%" "<" "?" "^" "+" "/" "*" "D" "F"] @punctuation.special)
|
||||
|
||||
;; #FF6347 #000000 0 0 0 0 2
|
||||
(automatic_variable
|
||||
"/" @error . ["D" "F"])
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 2
|
||||
[
|
||||
"="
|
||||
":="
|
||||
"::="
|
||||
"?="
|
||||
"+="
|
||||
"!="
|
||||
"@"
|
||||
"-"
|
||||
"+"
|
||||
] @operator
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
[
|
||||
(text)
|
||||
(string)
|
||||
(raw_text)
|
||||
] @string
|
||||
|
||||
;; #9AD4FF #000000 0 0 0 0 2
|
||||
(variable_assignment (word) @string)
|
||||
|
||||
;; #7AA2F7 #000000 0 0 0 0 1
|
||||
[
|
||||
"ifeq"
|
||||
"ifneq"
|
||||
"ifdef"
|
||||
"ifndef"
|
||||
"else"
|
||||
"endif"
|
||||
"if"
|
||||
"or" ; boolean functions are conditional in make grammar
|
||||
"and"
|
||||
] @conditional
|
||||
|
||||
;; #9ADE7A #000000 0 0 0 0 2
|
||||
"foreach" @repeat
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
[
|
||||
"define"
|
||||
"endef"
|
||||
"vpath"
|
||||
"undefine"
|
||||
"export"
|
||||
"unexport"
|
||||
"override"
|
||||
"private"
|
||||
; "load"
|
||||
] @keyword
|
||||
|
||||
;; #C6B5FF #000000 0 0 0 0 2
|
||||
[
|
||||
"include"
|
||||
"sinclude"
|
||||
"-include"
|
||||
] @include
|
||||
|
||||
;; #82AAFF #000000 0 0 0 0 2
|
||||
[
|
||||
"subst"
|
||||
"patsubst"
|
||||
"strip"
|
||||
"findstring"
|
||||
"filter"
|
||||
"filter-out"
|
||||
"sort"
|
||||
"word"
|
||||
"words"
|
||||
"wordlist"
|
||||
"firstword"
|
||||
"lastword"
|
||||
"dir"
|
||||
"notdir"
|
||||
"suffix"
|
||||
"basename"
|
||||
"addsuffix"
|
||||
"addprefix"
|
||||
"join"
|
||||
"wildcard"
|
||||
"realpath"
|
||||
"abspath"
|
||||
"call"
|
||||
"eval"
|
||||
"file"
|
||||
"value"
|
||||
"shell"
|
||||
] @keyword.function
|
||||
|
||||
;; #FF9D5C #000000 0 0 0 0 2
|
||||
[
|
||||
"error"
|
||||
"warning"
|
||||
"info"
|
||||
] @exception
|
||||
|
||||
;; #B8E986 #000000 0 0 0 0 2
|
||||
(variable_assignment
|
||||
name: (word) @constant)
|
||||
|
||||
;; #B8E986 #000000 0 0 0 0 2
|
||||
(variable_reference
|
||||
(word) @constant)
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment
|
||||
|
||||
;; #F28FAD #000000 0 0 0 0 2
|
||||
((word) @clean @string.regex
|
||||
(#match? @clean "[%\*\?]"))
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 2
|
||||
(function_call
|
||||
function: "error"
|
||||
(arguments (text) @text.danger))
|
||||
|
||||
;; #FFC877 #000000 0 0 0 0 2
|
||||
(function_call
|
||||
function: "warning"
|
||||
(arguments (text) @text.warning))
|
||||
|
||||
;; #61AFEF #000000 0 0 0 0 2
|
||||
(function_call
|
||||
function: "info"
|
||||
(arguments (text) @text.note))
|
||||
|
||||
;; #95E6CB #000000 0 0 0 0 2
|
||||
[
|
||||
"VPATH"
|
||||
".RECIPEPREFIX"
|
||||
] @constant.builtin
|
||||
|
||||
;; #95E6CB #000000 0 0 0 0 2
|
||||
(variable_assignment
|
||||
name: (word) @clean @constant.builtin
|
||||
(#match? @clean "^(AR|AS|CC|CXX|CPP|FC|M2C|PC|CO|GET|LEX|YACC|LINT|MAKEINFO|TEX|TEXI2DVI|WEAVE|CWEAVE|TANGLE|CTANGLE|RM|ARFLAGS|ASFLAGS|CFLAGS|CXXFLAGS|COFLAGS|CPPFLAGS|FFLAGS|GFLAGS|LDFLAGS|LDLIBS|LFLAGS|YFLAGS|PFLAGS|RFLAGS|LINTFLAGS|PRE_INSTALL|POST_INSTALL|NORMAL_INSTALL|PRE_UNINSTALL|POST_UNINSTALL|NORMAL_UNINSTALL|MAKEFILE_LIST|MAKE_RESTARTS|MAKE_TERMOUT|MAKE_TERMERR|\\.DEFAULT_GOAL|\\.RECIPEPREFIX|\\.EXTRA_PREREQS)$"))
|
||||
|
||||
;; #95E6CB #000000 0 0 0 0 2
|
||||
(variable_reference
|
||||
(word) @clean @constant.builtin
|
||||
(#match? @clean "^(AR|AS|CC|CXX|CPP|FC|M2C|PC|CO|GET|LEX|YACC|LINT|MAKEINFO|TEX|TEXI2DVI|WEAVE|CWEAVE|TANGLE|CTANGLE|RM|ARFLAGS|ASFLAGS|CFLAGS|CXXFLAGS|COFLAGS|CPPFLAGS|FFLAGS|GFLAGS|LDFLAGS|LDLIBS|LFLAGS|YFLAGS|PFLAGS|RFLAGS|LINTFLAGS|PRE_INSTALL|POST_INSTALL|NORMAL_INSTALL|PRE_UNINSTALL|POST_UNINSTALL|NORMAL_UNINSTALL|MAKEFILE_LIST|MAKE_RESTARTS|MAKE_TERMOUT|MAKE_TERMERR|\\.DEFAULT_GOAL|\\.RECIPEPREFIX|\\.EXTRA_PREREQS\\.VARIABLES|\\.FEATURES|\\.INCLUDE_DIRS|\\.LOADED)$"))
|
||||
|
||||
;; #C792EA #000000 0 0 0 0 2
|
||||
(targets
|
||||
(word) @constant.macro
|
||||
(#match? @constant.macro "^(all|install|install-html|install-dvi|install-pdf|install-ps|uninstall|install-strip|clean|distclean|mostlyclean|maintainer-clean|TAGS|info|dvi|html|pdf|ps|dist|check|installcheck|installdirs)$"))
|
||||
|
||||
;; #C792EA #000000 0 0 0 0 2
|
||||
(targets
|
||||
(word) @constant.macro
|
||||
(#match? @constant.macro "^(all|install|install-html|install-dvi|install-pdf|install-ps|uninstall|install-strip|clean|distclean|mostlyclean|maintainer-clean|TAGS|info|dvi|html|pdf|ps|dist|check|installcheck|installdirs)$"))
|
||||
|
||||
;; #C792EA #000000 0 0 0 0 2
|
||||
(targets
|
||||
(word) @constant.macro
|
||||
(#match? @constant.macro "^\\.(PHONY|SUFFIXES|DEFAULT|PRECIOUS|INTERMEDIATE|SECONDARY|SECONDEXPANSION|DELETE_ON_ERROR|IGNORE|LOW_RESOLUTION_TIME|SILENT|EXPORT_ALL_VARIABLES|NOTPARALLEL|ONESHELL|POSIX)$"))
|
||||
@@ -1,23 +0,0 @@
|
||||
;; #82AAFF #000000 1 0 1 0 2
|
||||
(title) @markup.heading.1
|
||||
|
||||
;; #ccefc9 #000000 0 0 0 0 0
|
||||
(section_title) @markup.heading.2
|
||||
|
||||
;; #FF8F40 #000000 1 0 0 0 2
|
||||
(subsection_title) @markup.heading.3
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 3
|
||||
(option) @variable.parameter
|
||||
|
||||
;; #FFD700 #000000 1 0 0 0 3
|
||||
(reference) @markup.link.label
|
||||
|
||||
;; #C792EA #000000 0 0 0 0 3
|
||||
(footer) @markup.heading
|
||||
|
||||
(section_heading
|
||||
(section_title) @_title
|
||||
;; #FFD700 #000000 1 0 0 0 1
|
||||
(block) @injection.content
|
||||
(#match? @_title "SYNOPSIS"))
|
||||
@@ -1,327 +0,0 @@
|
||||
;; #82AAFF #000000 1 0 1 0 4
|
||||
(setext_heading
|
||||
(paragraph) @markup.heading.1
|
||||
(setext_h1_underline) @markup.heading.1)
|
||||
|
||||
;; #82AAFF #000000 1 0 1 0 4
|
||||
(setext_heading
|
||||
(paragraph) @markup.heading.2
|
||||
(setext_h2_underline) @markup.heading.2)
|
||||
|
||||
(atx_heading
|
||||
(atx_h1_marker)) @markup.heading.1
|
||||
|
||||
(atx_heading
|
||||
(atx_h2_marker)) @markup.heading.2
|
||||
|
||||
;; #82AAFF #000000 1 0 0 0 4
|
||||
(atx_heading
|
||||
(atx_h3_marker)) @markup.heading.3
|
||||
|
||||
;; #82AAFF #000000 1 0 0 0 4
|
||||
(atx_heading
|
||||
(atx_h4_marker)) @markup.heading.4
|
||||
|
||||
;; #82AAFF #000000 1 0 0 0 4
|
||||
(atx_heading
|
||||
(atx_h5_marker)) @markup.heading.5
|
||||
|
||||
;; #82AAFF #000000 1 0 0 0 4
|
||||
(atx_heading
|
||||
(atx_h6_marker)) @markup.heading.6
|
||||
|
||||
;; #82AAFF #000000 0 0 0 0 4
|
||||
(info_string) @label
|
||||
|
||||
;; #FF6347 #000000 0 0 0 0 4
|
||||
(pipe_table_header
|
||||
(pipe_table_cell) @markup.heading)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 4
|
||||
(pipe_table_header
|
||||
"|" @punctuation.special)
|
||||
|
||||
(pipe_table_row
|
||||
"|" @punctuation.special)
|
||||
|
||||
(pipe_table_delimiter_row
|
||||
"|" @punctuation.special)
|
||||
|
||||
(pipe_table_delimiter_cell) @punctuation.special
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 2
|
||||
(indented_code_block) @markup.raw.block
|
||||
|
||||
(fenced_code_block) @markup.raw.block
|
||||
|
||||
(fenced_code_block
|
||||
(fenced_code_block_delimiter) @markup.raw.block)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @label))
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 6
|
||||
(link_destination) @markup.link.url
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 6
|
||||
[
|
||||
(link_title)
|
||||
(link_label)
|
||||
] @markup.link.label
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 4
|
||||
((link_label)
|
||||
.
|
||||
":" @punctuation.delimiter)
|
||||
|
||||
;; #9ADE7A #000000 0 0 0 0 4
|
||||
[
|
||||
(list_marker_plus)
|
||||
(list_marker_minus)
|
||||
(list_marker_star)
|
||||
(list_marker_dot)
|
||||
(list_marker_parenthesis)
|
||||
] @markup.list
|
||||
|
||||
(thematic_break) @punctuation.special
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 4
|
||||
(task_list_marker_unchecked) @markup.list.unchecked
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 4
|
||||
(task_list_marker_checked) @markup.list.checked
|
||||
|
||||
[
|
||||
(plus_metadata)
|
||||
(minus_metadata)
|
||||
] @keyword.directive
|
||||
|
||||
[
|
||||
(block_continuation)
|
||||
(block_quote_marker)
|
||||
] @punctuation.special
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 6
|
||||
(backslash_escape) @string.escape
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^ruby$"))
|
||||
;; !ruby
|
||||
(code_fence_content) @injection.ruby)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^bash$"))
|
||||
;; !bash
|
||||
(code_fence_content) @injection.bash)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^cpp$"))
|
||||
;; !cpp
|
||||
(code_fence_content) @injection.cpp)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^h$"))
|
||||
;; !h
|
||||
(code_fence_content) @injection.h)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^c$"))
|
||||
;; !c
|
||||
(code_fence_content) @injection.h)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^css$"))
|
||||
;; !css
|
||||
(code_fence_content) @injection.css)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^fish$"))
|
||||
;; !fish
|
||||
(code_fence_content) @injection.fish)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^go$"))
|
||||
;; !go
|
||||
(code_fence_content) @injection.go)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^haskell$"))
|
||||
;; !haskell
|
||||
(code_fence_content) @injection.haskell)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^html$"))
|
||||
;; !html
|
||||
(code_fence_content) @injection.html)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^javascript$"))
|
||||
;; !javascript
|
||||
(code_fence_content) @injection.javascript)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^json$"))
|
||||
;; !json
|
||||
(code_fence_content) @injection.json)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^lua$"))
|
||||
;; !lua
|
||||
(code_fence_content) @injection.lua)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^regex$"))
|
||||
;; !regex
|
||||
(code_fence_content) @injection.regex)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^query$"))
|
||||
;; !query
|
||||
(code_fence_content) @injection.query)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^markdown$"))
|
||||
;; !markdown
|
||||
(code_fence_content) @injection.markdown)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^markdown_inline$"))
|
||||
;; !markdown_inline
|
||||
(code_fence_content) @injection.markdown_inline)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^erb$"))
|
||||
;; !embedded_template
|
||||
(code_fence_content) @injection.embedded_template)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^python$"))
|
||||
;; !python
|
||||
(code_fence_content) @injection.python)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^php$"))
|
||||
;; !php
|
||||
(code_fence_content) @injection.php)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^rust$"))
|
||||
;; !rust
|
||||
(code_fence_content) @injection.rust)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^sql$"))
|
||||
;; !sql
|
||||
(code_fence_content) @injection.sql)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^gitattributes$"))
|
||||
;; !gitattributes
|
||||
(code_fence_content) @injection.gitattributes)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^gitignore$"))
|
||||
;; !gitignore
|
||||
(code_fence_content) @injection.gitignore)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^gdscript$"))
|
||||
;; !gdscript
|
||||
(code_fence_content) @injection.gdscript)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^make$"))
|
||||
;; !make
|
||||
(code_fence_content) @injection.make)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^diff$"))
|
||||
;; !diff
|
||||
(code_fence_content) @injection.diff)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^ini$"))
|
||||
;; !ini
|
||||
(code_fence_content) @injection.ini)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^nginx$"))
|
||||
;; !nginx
|
||||
(code_fence_content) @injection.nginx)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^toml$"))
|
||||
;; !toml
|
||||
(code_fence_content) @injection.toml)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^yaml$"))
|
||||
;; !yaml
|
||||
(code_fence_content) @injection.yaml)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^gomod$"))
|
||||
;; !gomod
|
||||
(code_fence_content) @injection.gomod)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^man$"))
|
||||
;; !man
|
||||
(code_fence_content) @injection.man)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^cabal$"))
|
||||
;; !cabal
|
||||
(code_fence_content) @injection.cabal)
|
||||
|
||||
;; !html
|
||||
(html_block) @injection.html
|
||||
|
||||
;; !yaml
|
||||
(minus_metadata) @injection.yaml
|
||||
|
||||
;; !toml
|
||||
(plus_metadata) @injection.toml
|
||||
|
||||
;; !markdown_inline
|
||||
(paragraph) @inline
|
||||
|
||||
(pipe_table_row
|
||||
(pipe_table_cell) @inline)
|
||||
|
||||
(block_quote ((paragraph) @inline))
|
||||
@@ -1,92 +0,0 @@
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
(code_span) @markup.raw
|
||||
|
||||
;; #FF8F40 #000000 0 1 0 0 1
|
||||
(emphasis) @markup.italic
|
||||
|
||||
;; #FFD700 #000000 1 0 0 0 1
|
||||
(strong_emphasis) @markup.strong
|
||||
|
||||
;; #FF6347 #000000 0 0 0 1 1
|
||||
(strikethrough) @markup.strikethrough
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 1
|
||||
[
|
||||
(backslash_escape)
|
||||
(hard_line_break)
|
||||
] @string.escape
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 1
|
||||
(inline_link
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
"("
|
||||
(link_destination)
|
||||
")"
|
||||
] @markup.link)
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 1
|
||||
[
|
||||
(link_label)
|
||||
(link_text)
|
||||
(link_title)
|
||||
(image_description)
|
||||
] @markup.link.label
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 1
|
||||
((inline_link
|
||||
(link_destination) @_url) @_label)
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 1
|
||||
((image
|
||||
(link_destination) @_url) @_label)
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 1
|
||||
(image
|
||||
[
|
||||
"!"
|
||||
"["
|
||||
"]"
|
||||
"("
|
||||
(link_destination)
|
||||
")"
|
||||
] @markup.link)
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 1
|
||||
(full_reference_link
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
(link_label)
|
||||
] @markup.link)
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 1
|
||||
(collapsed_reference_link
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
] @markup.link)
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 1
|
||||
(shortcut_link
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
] @markup.link)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 0
|
||||
">" @markup.quote
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 1
|
||||
[
|
||||
(link_destination)
|
||||
(uri_autolink)
|
||||
(email_autolink)
|
||||
] @markup.link.url @nospell
|
||||
|
||||
;; #7dcfff #000000 0 0 1 0 1
|
||||
(uri_autolink) @_url
|
||||
|
||||
;; !html
|
||||
(html_tag) @injection.html
|
||||
@@ -1,54 +0,0 @@
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(number) @number
|
||||
(metric) @number
|
||||
|
||||
;; !regex
|
||||
(regex) @regex
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(variable) @variable
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(modifier) @operator
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(simple_directive
|
||||
name: (directive) @function)
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(block_directive
|
||||
name: (directive) @function)
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(lua_block_directive
|
||||
"access_by_lua_block" @function)
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
((generic) @constant.builtin
|
||||
(#match? @constant.builtin "^(off|on)$"))
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 2
|
||||
(generic) @string
|
||||
(string) @string
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(scheme) @string
|
||||
(ipv4) @number
|
||||
|
||||
;; #888888 #000000 0 1 0 0 3
|
||||
[
|
||||
";"
|
||||
] @delimiter
|
||||
|
||||
;; #888888 #000000 0 0 0 0 3
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
453
grammar/php.scm
453
grammar/php.scm
@@ -1,453 +0,0 @@
|
||||
;; =========================================================
|
||||
;; PHP SYNTAX HIGHLIGHTING
|
||||
;; Cool–warm balanced palette (blue / teal / purple / orange)
|
||||
;; =========================================================
|
||||
|
||||
;; #FF9D5C #000000 0 0 0 0 1
|
||||
;; Keywords (logic / flow)
|
||||
[
|
||||
"and"
|
||||
"as"
|
||||
"instanceof"
|
||||
"or"
|
||||
"xor"
|
||||
] @keyword.operator
|
||||
|
||||
;; #FF9D5C #000000 0 0 0 0 1
|
||||
[
|
||||
"fn"
|
||||
"function"
|
||||
] @keyword.function
|
||||
|
||||
;; #FF9D5C #000000 0 0 0 0 1
|
||||
[
|
||||
"clone"
|
||||
"declare"
|
||||
"default"
|
||||
"echo"
|
||||
"enddeclare"
|
||||
"extends"
|
||||
"global"
|
||||
"goto"
|
||||
"implements"
|
||||
"insteadof"
|
||||
"print"
|
||||
"new"
|
||||
"unset"
|
||||
] @keyword
|
||||
|
||||
;; #6FB3FF #000000 0 0 0 0 1
|
||||
[
|
||||
"enum"
|
||||
"class"
|
||||
"interface"
|
||||
"namespace"
|
||||
"trait"
|
||||
] @keyword.type
|
||||
|
||||
;; #FF9D5C #000000 0 0 0 0 1
|
||||
[
|
||||
"abstract"
|
||||
"const"
|
||||
"final"
|
||||
"private"
|
||||
"protected"
|
||||
"public"
|
||||
"readonly"
|
||||
"static"
|
||||
] @keyword.modifier
|
||||
|
||||
;; #FF9D5C #000000 0 0 0 0 1
|
||||
[
|
||||
"return"
|
||||
"exit"
|
||||
"yield"
|
||||
"yield from"
|
||||
] @keyword.return
|
||||
|
||||
;; #FF9D5C #000000 0 0 0 0 1
|
||||
[
|
||||
"case"
|
||||
"else"
|
||||
"elseif"
|
||||
"endif"
|
||||
"endswitch"
|
||||
"if"
|
||||
"switch"
|
||||
"match"
|
||||
"??"
|
||||
] @keyword.conditional
|
||||
|
||||
;; #FF9D5C #000000 0 0 0 0 1
|
||||
[
|
||||
"break"
|
||||
"continue"
|
||||
"do"
|
||||
"endfor"
|
||||
"endforeach"
|
||||
"endwhile"
|
||||
"for"
|
||||
"foreach"
|
||||
"while"
|
||||
] @keyword.repeat
|
||||
|
||||
;; #FF9D5C #000000 0 0 0 0 1
|
||||
[
|
||||
"catch"
|
||||
"finally"
|
||||
"throw"
|
||||
"try"
|
||||
] @keyword.exception
|
||||
|
||||
;; #8BD5CA #000000 0 0 0 0 1
|
||||
[
|
||||
"include_once"
|
||||
"include"
|
||||
"require_once"
|
||||
"require"
|
||||
"use"
|
||||
] @keyword.import
|
||||
|
||||
;; #B0BEC5 #000000 0 0 0 0 1
|
||||
[
|
||||
","
|
||||
";"
|
||||
":"
|
||||
"\\"
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #B0BEC5 #000000 0 0 0 0 1
|
||||
[
|
||||
(php_tag)
|
||||
(php_end_tag)
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"#["
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
[
|
||||
"="
|
||||
"."
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"+"
|
||||
"%"
|
||||
"**"
|
||||
"~"
|
||||
"|"
|
||||
"^"
|
||||
"&"
|
||||
"<<"
|
||||
">>"
|
||||
"<<<"
|
||||
"->"
|
||||
"?->"
|
||||
"=>"
|
||||
"<"
|
||||
"<="
|
||||
">="
|
||||
">"
|
||||
"<>"
|
||||
"<=>"
|
||||
"=="
|
||||
"!="
|
||||
"==="
|
||||
"!=="
|
||||
"!"
|
||||
"&&"
|
||||
"||"
|
||||
".="
|
||||
"-="
|
||||
"+="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"**="
|
||||
"&="
|
||||
"|="
|
||||
"^="
|
||||
"<<="
|
||||
">>="
|
||||
"??="
|
||||
"--"
|
||||
"++"
|
||||
"@"
|
||||
"::"
|
||||
] @operator
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 1
|
||||
(variable_name) @variable
|
||||
|
||||
;; #C792EA #000000 0 0 0 0 1
|
||||
((name) @constant
|
||||
(#lua-match? @constant "^_?[A-Z][A-Z%d_]*$"))
|
||||
|
||||
;; #C792EA #000000 0 0 0 0 1
|
||||
((name) @constant.builtin
|
||||
(#lua-match? @constant.builtin "^__[A-Z][A-Z%d_]+__$"))
|
||||
|
||||
;; #6FB3FF #000000 0 0 0 0 1
|
||||
(const_declaration
|
||||
(const_element
|
||||
(name) @constant))
|
||||
|
||||
;; #82AAFF #000000 0 0 0 0 1
|
||||
[
|
||||
(primitive_type)
|
||||
(cast_type)
|
||||
(bottom_type)
|
||||
] @type.builtin
|
||||
|
||||
;; #82AAFF #000000 0 0 0 0 1
|
||||
(named_type
|
||||
[
|
||||
(name) @type
|
||||
(qualified_name (name) @type)
|
||||
(relative_name (name) @type)
|
||||
])
|
||||
|
||||
;; #82AAFF #000000 0 0 0 0 1
|
||||
(named_type
|
||||
(name) @type.builtin
|
||||
(#any-of? @type.builtin "static" "self"))
|
||||
|
||||
;; #82AAFF #000000 0 0 0 0 1
|
||||
(class_declaration
|
||||
name: (name) @type)
|
||||
|
||||
;; #82AAFF #000000 0 0 0 0 1
|
||||
(enum_declaration
|
||||
name: (name) @type)
|
||||
|
||||
;; #82AAFF #000000 0 0 0 0 1
|
||||
(interface_declaration
|
||||
name: (name) @type)
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 1
|
||||
(namespace_use_clause
|
||||
[
|
||||
(name) @type
|
||||
(qualified_name (name) @type)
|
||||
alias: (name) @type.definition
|
||||
])
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 1
|
||||
(namespace_use_clause
|
||||
type: "function"
|
||||
[
|
||||
(name) @function
|
||||
(qualified_name (name) @function)
|
||||
alias: (name) @function
|
||||
])
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 1
|
||||
(namespace_use_clause
|
||||
type: "const"
|
||||
[
|
||||
(name) @constant
|
||||
(qualified_name (name) @constant)
|
||||
alias: (name) @constant
|
||||
])
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 1
|
||||
(scoped_call_expression
|
||||
scope: [
|
||||
(name) @type
|
||||
(qualified_name (name) @type)
|
||||
(relative_name (name) @type)
|
||||
])
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 1
|
||||
(class_constant_access_expression
|
||||
.
|
||||
[
|
||||
(name) @type
|
||||
(qualified_name (name) @type)
|
||||
(relative_name (name) @type)
|
||||
]
|
||||
(name) @constant)
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 1
|
||||
(scoped_property_access_expression
|
||||
name: (variable_name) @variable.member)
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 1
|
||||
(trait_declaration
|
||||
name: (name) @type)
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 1
|
||||
(use_declaration
|
||||
(name) @type)
|
||||
|
||||
;; #FF9D5C #000000 0 0 0 0 1
|
||||
(binary_expression
|
||||
operator: "instanceof"
|
||||
right: [
|
||||
(name) @type
|
||||
(qualified_name (name) @type)
|
||||
(relative_name (name) @type)
|
||||
])
|
||||
|
||||
;; #FFD580 #000000 0 0 0 0 1
|
||||
(array_creation_expression
|
||||
"array" @function.builtin)
|
||||
|
||||
;; #FFD580 #000000 0 0 0 0 1
|
||||
(list_literal
|
||||
"list" @function.builtin)
|
||||
|
||||
;; #FFD580 #000000 0 0 0 0 1
|
||||
(exit_statement
|
||||
"exit" @function.builtin
|
||||
"(")
|
||||
|
||||
;; #89DDFF #000000 0 0 0 0 1
|
||||
(method_declaration
|
||||
name: (name) @function.method)
|
||||
|
||||
;; #89DDFF #000000 0 0 0 0 1
|
||||
(function_call_expression
|
||||
function: [
|
||||
(name) @function.call
|
||||
(qualified_name (name) @function.call)
|
||||
(relative_name (name) @function.call)
|
||||
])
|
||||
|
||||
;; #89DDFF #000000 0 0 0 0 1
|
||||
(scoped_call_expression
|
||||
name: (name) @function.call)
|
||||
|
||||
;; #89DDFF #000000 0 0 0 0 1
|
||||
(member_call_expression
|
||||
name: (name) @function.method)
|
||||
|
||||
;; #89DDFF #000000 0 0 0 0 1
|
||||
(nullsafe_member_call_expression
|
||||
name: (name) @function.method)
|
||||
|
||||
;; #FFD580 #000000 0 0 0 0 1
|
||||
(method_declaration
|
||||
name: (name) @constructor
|
||||
(#eq? @constructor "__construct"))
|
||||
|
||||
;; #FFD580 #000000 0 0 0 0 1
|
||||
(object_creation_expression
|
||||
[
|
||||
(name) @constructor
|
||||
(qualified_name (name) @constructor)
|
||||
(relative_name (name) @constructor)
|
||||
])
|
||||
|
||||
;; #9CDCFE #000000 0 0 0 0 1
|
||||
(variadic_parameter
|
||||
"..." @operator
|
||||
name: (variable_name) @variable.parameter)
|
||||
|
||||
;; #9CDCFE #000000 0 0 0 0 1
|
||||
(simple_parameter
|
||||
name: (variable_name) @variable.parameter)
|
||||
|
||||
;; #9CDCFE #000000 0 0 0 0 1
|
||||
(argument
|
||||
(name) @variable.parameter)
|
||||
|
||||
;; #9CDCFE #000000 0 0 0 0 1
|
||||
(property_element
|
||||
(variable_name) @property)
|
||||
|
||||
;; #9CDCFE #000000 0 0 0 0 1
|
||||
(member_access_expression
|
||||
name: (variable_name (name)) @variable.member)
|
||||
|
||||
;; #9CDCFE #000000 0 0 0 0 1
|
||||
(relative_scope) @variable.builtin
|
||||
|
||||
;; #7AA2F7 #000000 0 0 0 0 1
|
||||
((variable_name) @variable.builtin
|
||||
(#eq? @variable.builtin "$this"))
|
||||
|
||||
;; #C792EA #000000 0 0 0 0 1
|
||||
(namespace_definition
|
||||
name: (namespace_name (name) @module))
|
||||
|
||||
;; #C792EA #000000 0 0 0 0 1
|
||||
(namespace_name
|
||||
(name) @module)
|
||||
|
||||
;; #7AA2F7 #000000 0 0 0 0 1
|
||||
(relative_name
|
||||
"namespace" @module.builtin)
|
||||
|
||||
;; #89DDFF #000000 0 0 0 0 1
|
||||
(attribute_list) @attribute
|
||||
|
||||
;; #FF9D5C #000000 0 0 0 0 1
|
||||
(conditional_expression
|
||||
"?" @keyword.conditional.ternary
|
||||
":" @keyword.conditional.ternary)
|
||||
|
||||
;; #9CDCFE #000000 0 0 0 0 1
|
||||
(declare_directive
|
||||
[
|
||||
"strict_types"
|
||||
"ticks"
|
||||
"encoding"
|
||||
] @variable.parameter)
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 1
|
||||
[
|
||||
(string)
|
||||
(encapsed_string)
|
||||
(heredoc_body)
|
||||
(nowdoc_body)
|
||||
(shell_command_expression)
|
||||
] @string
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 1
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 1
|
||||
[
|
||||
(heredoc_start)
|
||||
(heredoc_end)
|
||||
] @label
|
||||
|
||||
;; #DDB6F2 #000000 0 0 0 0 1
|
||||
(nowdoc
|
||||
"'" @label)
|
||||
|
||||
;; #F38BA8 #000000 0 0 0 0 1
|
||||
(boolean) @boolean
|
||||
|
||||
;; #F38BA8 #000000 0 0 0 0 1
|
||||
(null) @constant.builtin
|
||||
|
||||
;; #F38BA8 #000000 0 0 0 0 1
|
||||
(integer) @number
|
||||
|
||||
;; #F38BA8 #000000 0 0 0 0 1
|
||||
(float) @number.float
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment @spell
|
||||
|
||||
;; #A6E3A1 #000000 0 0 0 0 1
|
||||
(named_label_statement) @label
|
||||
|
||||
;; #7AA2F7 #000000 0 0 0 0 1
|
||||
(property_hook
|
||||
(name) @label)
|
||||
|
||||
;; #7AA2F7 #000000 0 0 0 0 1
|
||||
(visibility_modifier
|
||||
(operation) @label)
|
||||
|
||||
;; #89DDFF #000000 0 0 0 0 1
|
||||
;; !html
|
||||
(text) @injection.html
|
||||
@@ -1,412 +0,0 @@
|
||||
; ============================================================
|
||||
; Identifiers
|
||||
; ============================================================
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(identifier) @variable
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
((identifier) @type
|
||||
(#match? @type "^[A-Z].*[a-z]"))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z_0-9]*$"))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
((identifier) @constant.builtin
|
||||
(#match? @constant.builtin "^__[a-zA-Z0-9_]*__$"))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
((identifier) @constant.builtin
|
||||
(#match? @constant.builtin "^(NotImplemented|Ellipsis|quit|exit|copyright|credits|license)$"))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
((assignment
|
||||
left: (identifier) @type.definition
|
||||
(type
|
||||
(identifier) @_annotation))
|
||||
(#match? @_annotation "^TypeAlias$"))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
((assignment
|
||||
left: (identifier) @type.definition
|
||||
right: (call
|
||||
function: (identifier) @_func))
|
||||
(#match? @_func "^(TypeVar|NewType)$"))
|
||||
|
||||
; ============================================================
|
||||
; Function definitions
|
||||
; ============================================================
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(function_definition
|
||||
name: (identifier) @function)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(type
|
||||
(identifier) @type)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(type
|
||||
(subscript
|
||||
(identifier) @type))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
((call
|
||||
function: (identifier) @_isinstance
|
||||
arguments: (argument_list
|
||||
(_)
|
||||
(identifier) @type))
|
||||
(#match? @_isinstance "^isinstance$"))
|
||||
|
||||
; ============================================================
|
||||
; Literals
|
||||
; ============================================================
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(none) @constant.builtin
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(integer) @number
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(float) @number.float
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment @spell
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
((module
|
||||
.
|
||||
(comment) @keyword.directive @nospell)
|
||||
(#match? @keyword.directive "^#!/"))
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 0
|
||||
(string) @string
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 0
|
||||
[
|
||||
(escape_sequence)
|
||||
(escape_interpolation)
|
||||
] @string.escape
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 0
|
||||
(expression_statement
|
||||
(string
|
||||
(string_content) @spell) @string.documentation)
|
||||
|
||||
; ============================================================
|
||||
; Operators
|
||||
; ============================================================
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[ "if" "elif" "else" "for" "while" "break" "continue" ] @keyword.control_flow_loops
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[ "def" "return" "lambda" "yield" "async" "await" ] @keyword.functions_coroutines
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
[ "class" ] @keyword.class
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
[ "try" "except" "finally" "raise" ] @keyword.exceptions
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
[ "with" ] @keyword.context_management
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
[ "import" "from" "exec" ] @keyword.imports_execution
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
[ "match" "case" ] @keyword.pattern_matching
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
[ "global" "nonlocal" ] @keyword.scope_bindings
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[ "del" ] @keyword.deletion
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[ "pass" "assert" "as" "print" ] @keyword.utility
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
[
|
||||
"-"
|
||||
"-="
|
||||
"!="
|
||||
"*"
|
||||
"**"
|
||||
"**="
|
||||
"*="
|
||||
"/"
|
||||
"//"
|
||||
"//="
|
||||
"/="
|
||||
"&"
|
||||
"&="
|
||||
"%"
|
||||
"%="
|
||||
"^"
|
||||
"^="
|
||||
"+"
|
||||
"->"
|
||||
"+="
|
||||
"<"
|
||||
"<<"
|
||||
"<<="
|
||||
"<="
|
||||
"<>"
|
||||
"="
|
||||
":="
|
||||
"=="
|
||||
">"
|
||||
">="
|
||||
">>"
|
||||
">>="
|
||||
"|"
|
||||
"|="
|
||||
"~"
|
||||
"@="
|
||||
"and"
|
||||
"in"
|
||||
"is"
|
||||
"not"
|
||||
"or"
|
||||
"is not"
|
||||
"not in"
|
||||
] @operatoroperator
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[
|
||||
","
|
||||
"."
|
||||
":"
|
||||
";"
|
||||
(ellipsis)
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(interpolation
|
||||
"{" @punctuation.special
|
||||
"}" @punctuation.special)
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(format_expression
|
||||
"{" @punctuation.special
|
||||
"}" @punctuation.special)
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(line_continuation) @punctuation.special
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(type_conversion) @function.macro
|
||||
|
||||
; ============================================================
|
||||
; Builtins / Exception types
|
||||
; ============================================================
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
((identifier) @type.builtin
|
||||
(#match? @type.builtin
|
||||
"^(BaseException|Exception|ArithmeticError|BufferError|LookupError|AssertionError|AttributeError|EOFError|FloatingPointError|GeneratorExit|ImportError|ModuleNotFoundError|IndexError|KeyError|KeyboardInterrupt|MemoryError|NameError|NotImplementedError|OSError|OverflowError|RecursionError|ReferenceError|RuntimeError|StopIteration|StopAsyncIteration|SyntaxError|IndentationError|TabError|SystemError|SystemExit|TypeError|UnboundLocalError|UnicodeError|UnicodeEncodeError|UnicodeDecodeError|UnicodeTranslateError|ValueError|ZeroDivisionError|EnvironmentError|IOError|WindowsError|BlockingIOError|ChildProcessError|ConnectionError|BrokenPipeError|ConnectionAbortedError|ConnectionRefusedError|ConnectionResetError|FileExistsError|FileNotFoundError|InterruptedError|IsADirectoryError|NotADirectoryError|PermissionError|ProcessLookupError|TimeoutError|Warning|UserWarning|DeprecationWarning|PendingDeprecationWarning|SyntaxWarning|RuntimeWarning|FutureWarning|ImportWarning|UnicodeWarning|BytesWarning|ResourceWarning)$"))
|
||||
|
||||
; ============================================================
|
||||
; Function / Lambda parameters
|
||||
; ============================================================
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(parameters
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(lambda_parameters
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(lambda_parameters
|
||||
(tuple_pattern
|
||||
(identifier) @variable.parameter))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(keyword_argument
|
||||
name: (identifier) @variable.parameter)
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(default_parameter
|
||||
name: (identifier) @variable.parameter)
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(typed_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(typed_default_parameter
|
||||
name: (identifier) @variable.parameter)
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(parameters
|
||||
(list_splat_pattern
|
||||
(identifier) @variable.parameter))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(parameters
|
||||
(dictionary_splat_pattern
|
||||
(identifier) @variable.parameter))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(lambda_parameters
|
||||
(list_splat_pattern
|
||||
(identifier) @variable.parameter))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(lambda_parameters
|
||||
(dictionary_splat_pattern
|
||||
(identifier) @variable.parameter))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
((identifier) @variable.builtin
|
||||
(#match? @variable.builtin "^(self|cls)$"))
|
||||
|
||||
; ============================================================
|
||||
; Attributes / Class members
|
||||
; ============================================================
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
((attribute
|
||||
attribute: (identifier) @variable.member)
|
||||
(#match? @variable.member "^[%l_].*$"))
|
||||
|
||||
; ============================================================
|
||||
; Class definitions
|
||||
; ============================================================
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 2
|
||||
(class_definition
|
||||
name: (identifier) @type)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(class_definition
|
||||
body: (block
|
||||
(function_definition
|
||||
name: (identifier) @function.method)))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(class_definition
|
||||
superclasses: (argument_list
|
||||
(identifier) @type))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
((class_definition
|
||||
body: (block
|
||||
(expression_statement
|
||||
(assignment
|
||||
left: (identifier) @variable.member))))
|
||||
(#match? @variable.member "^[%l_].*$"))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
((class_definition
|
||||
body: (block
|
||||
(expression_statement
|
||||
(assignment
|
||||
left: (_
|
||||
(identifier) @variable.member)))))
|
||||
(#match? @variable.member "^[%l_].*$"))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
((class_definition
|
||||
(block
|
||||
(function_definition
|
||||
name: (identifier) @constructor)))
|
||||
(#match? @constructor "^(__new__|__init__)$"))
|
||||
|
||||
; ============================================================
|
||||
; Function calls
|
||||
; ============================================================
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(call
|
||||
function: (identifier) @function.call)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(call
|
||||
function: (attribute
|
||||
attribute: (identifier) @function.method.call))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 3
|
||||
((call
|
||||
function: (identifier) @constructor)
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 3
|
||||
((call
|
||||
function: (attribute
|
||||
attribute: (identifier) @constructor))
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
((call
|
||||
function: (identifier) @function.builtin)
|
||||
(#match? @function.builtin
|
||||
"^(abs|all|any|ascii|bin|bool|breakpoint|bytearray|bytes|callable|chr|classmethod|compile|complex|delattr|dict|dir|divmod|enumerate|eval|exec|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|vars|zip|__import__)$"))
|
||||
|
||||
; ============================================================
|
||||
; Regex call
|
||||
; ============================================================
|
||||
|
||||
(call
|
||||
function: (identifier) @_re
|
||||
arguments: (argument_list
|
||||
;; !regex
|
||||
(string) @string.regexp
|
||||
)
|
||||
(#match? @_re "re"))
|
||||
|
||||
; ============================================================
|
||||
; Decorators
|
||||
; ============================================================
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(decorator
|
||||
"@" @attribute)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(decorator
|
||||
(identifier) @attribute)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(decorator
|
||||
(attribute
|
||||
attribute: (identifier) @attribute))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(decorator
|
||||
(call
|
||||
(identifier) @attribute))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(decorator
|
||||
(call
|
||||
(attribute
|
||||
attribute: (identifier) @attribute)))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 3
|
||||
((decorator
|
||||
(identifier) @attribute.builtin)
|
||||
(#match? @attribute.builtin "^(classmethod|property|staticmethod)$"))
|
||||
@@ -1,122 +0,0 @@
|
||||
;; ============================================================
|
||||
;; Strings & escapes
|
||||
;; ============================================================
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 2
|
||||
(string) @string
|
||||
|
||||
;; #95E6CB #000000 0 0 0 0 2
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
;; ============================================================
|
||||
;; Identifiers
|
||||
;; ============================================================
|
||||
|
||||
;; #C4B5FF #000000 0 0 0 0 2
|
||||
(capture
|
||||
(identifier) @type)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(predicate
|
||||
name: (identifier) @function.call)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(named_node
|
||||
name: (identifier) @variable)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(missing_node
|
||||
name: (identifier) @variable)
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 2
|
||||
(field_definition
|
||||
name: (identifier) @variable.member)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(negated_field
|
||||
"!" @operator
|
||||
(identifier) @property)
|
||||
|
||||
;; ============================================================
|
||||
;; Comments
|
||||
;; ============================================================
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 2
|
||||
(comment) @comment @spell
|
||||
|
||||
;; ============================================================
|
||||
;; Operators & punctuation
|
||||
;; ============================================================
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 2
|
||||
(quantifier) @operator
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 2
|
||||
(predicate_type) @punctuation.special
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 2
|
||||
"." @operator
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 2
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
"("
|
||||
")"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 2
|
||||
[
|
||||
":"
|
||||
"/"
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 2
|
||||
[
|
||||
"@"
|
||||
"#"
|
||||
] @punctuation.special
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 2
|
||||
(predicate
|
||||
"." @punctuation.special)
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
"_" @character.special
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
"MISSING" @keyword
|
||||
|
||||
;; ============================================================
|
||||
;; Numbers
|
||||
;; ============================================================
|
||||
|
||||
;; #B8E986 #000000 0 0 0 0 2
|
||||
((parameters
|
||||
(identifier) @number)
|
||||
(#match? @number "^[-+]?[0-9]+(.[0-9]+)?$"))
|
||||
|
||||
;; ============================================================
|
||||
;; Predicate parameters
|
||||
;; ============================================================
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
((predicate
|
||||
name: (identifier) @_name
|
||||
parameters: (parameters
|
||||
.
|
||||
(capture)?
|
||||
.
|
||||
(identifier) @property))
|
||||
(#match? @_name "^set$"))
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 2
|
||||
((predicate
|
||||
name: (identifier) @_name
|
||||
parameters: (parameters
|
||||
(string
|
||||
"\"" @string
|
||||
"\"" @string)
|
||||
;; !regex
|
||||
@string.regexp))
|
||||
(#match? @_name "^(match|not-match)$"))
|
||||
@@ -1,77 +0,0 @@
|
||||
;; ============================================================
|
||||
;; Punctuation / brackets
|
||||
;; ============================================================
|
||||
|
||||
;; #B6BEC8 #000000 0 0 0 0 1
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"(?"
|
||||
"(?:"
|
||||
"(?<"
|
||||
"(?P<"
|
||||
"(?P="
|
||||
">"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"[:"
|
||||
":]"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(group_name) @property
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
[
|
||||
"*"
|
||||
"+"
|
||||
"?"
|
||||
"|"
|
||||
"="
|
||||
"!"
|
||||
] @operator
|
||||
|
||||
;; #B8E986 #000000 0 0 0 0 2
|
||||
(count_quantifier
|
||||
[
|
||||
(decimal_digits) @number
|
||||
"," @punctuation.delimiter
|
||||
])
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 2
|
||||
(inline_flags_group
|
||||
"-"? @operator
|
||||
":"? @punctuation.delimiter)
|
||||
|
||||
;; #F29CC3 #000000 0 0 0 0 2
|
||||
(flags) @character.special
|
||||
|
||||
;; #C2E8FF #000000 0 0 0 0 2
|
||||
(character_class
|
||||
[
|
||||
"^" @operator
|
||||
(class_range "-" @operator)
|
||||
])
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
[
|
||||
(class_character)
|
||||
(posix_class_name)
|
||||
] @constant.character
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(pattern_character) @string
|
||||
|
||||
;; #95E6CB #000000 0 0 0 0 2
|
||||
[
|
||||
(identity_escape)
|
||||
(control_letter_escape)
|
||||
(character_class_escape)
|
||||
(control_escape)
|
||||
(start_assertion)
|
||||
(end_assertion)
|
||||
(boundary_assertion)
|
||||
(non_boundary_assertion)
|
||||
] @escape
|
||||
515
grammar/ruby.scm
515
grammar/ruby.scm
@@ -1,515 +0,0 @@
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
[
|
||||
(identifier)
|
||||
(global_variable)
|
||||
] @variable
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"alias"
|
||||
"begin"
|
||||
"do"
|
||||
"end"
|
||||
"ensure"
|
||||
"module"
|
||||
"rescue"
|
||||
"then"
|
||||
] @keyword
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
"class" @keyword.type
|
||||
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"return"
|
||||
"yield"
|
||||
] @keyword.return
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
[
|
||||
"and"
|
||||
"or"
|
||||
"in"
|
||||
"not"
|
||||
] @keyword.operator
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"def"
|
||||
"undef"
|
||||
] @keyword.function
|
||||
|
||||
(method
|
||||
"end" @keyword.function)
|
||||
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"case"
|
||||
"else"
|
||||
"elsif"
|
||||
"if"
|
||||
"unless"
|
||||
"when"
|
||||
"then"
|
||||
] @keyword.conditional
|
||||
|
||||
(if
|
||||
"end" @keyword.conditional)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"for"
|
||||
"until"
|
||||
"while"
|
||||
"break"
|
||||
"redo"
|
||||
"retry"
|
||||
"next"
|
||||
] @keyword.repeat
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(constant) @constant
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"rescue"
|
||||
"ensure"
|
||||
] @keyword.exception
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
"defined?" @function
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(call
|
||||
receiver: (constant)? @type
|
||||
method: [
|
||||
(identifier)
|
||||
(constant)
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
] @function.call)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(alias
|
||||
(identifier) @function)
|
||||
|
||||
(setter
|
||||
(identifier) @function)
|
||||
|
||||
(method
|
||||
name: [
|
||||
(identifier) @function
|
||||
(constant) @type
|
||||
])
|
||||
|
||||
(singleton_method
|
||||
name: [
|
||||
(identifier) @function
|
||||
(constant) @type
|
||||
])
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 2
|
||||
(class
|
||||
name: (constant) @type)
|
||||
|
||||
(module
|
||||
name: (constant) @type)
|
||||
|
||||
(superclass
|
||||
(constant) @type)
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 2
|
||||
[
|
||||
(class_variable)
|
||||
(instance_variable)
|
||||
] @variable.member
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
((identifier) @keyword.modifier
|
||||
(#match? @keyword.modifier "^(private|protected|public)$" ))
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 3
|
||||
(program
|
||||
(call
|
||||
(identifier) @keyword.import)
|
||||
(#match? @keyword.import "^(require|require_relative|load)$"))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 4
|
||||
((identifier) @constant.builtin
|
||||
(#match? @constant.builtin "^(__callee__|__dir__|__id__|__method__|__send__|__ENCODING__|__FILE__|__LINE__)$" ))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
((identifier) @function.builtin
|
||||
(#match? @function.builtin "^(attr_reader|attr_writer|attr_accessor|module_function)$" ))
|
||||
|
||||
((call
|
||||
!receiver
|
||||
method: (identifier) @function.builtin)
|
||||
(#match? @function.builtin "^(include|extend|prepend|refine|using)$"))
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 3
|
||||
((identifier) @keyword.exception
|
||||
(#match? @keyword.exception "^(raise|fail|catch|throw)$" ))
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
[
|
||||
(self)
|
||||
(super)
|
||||
] @variable.builtin
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(method_parameters
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(lambda_parameters
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(block_parameters
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(splat_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(hash_splat_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(optional_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(destructured_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(block_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(keyword_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
[
|
||||
(string_content)
|
||||
(heredoc_content)
|
||||
"\""
|
||||
"`"
|
||||
] @string
|
||||
|
||||
;; #E6C08A #000000 0 0 0 0 1
|
||||
[
|
||||
(heredoc_beginning)
|
||||
(heredoc_end)
|
||||
] @label
|
||||
|
||||
;; #39BAE6 #000000 0 0 0 0 2
|
||||
[
|
||||
(bare_symbol)
|
||||
(simple_symbol)
|
||||
(delimited_symbol)
|
||||
(hash_key_symbol)
|
||||
] @string.special.symbol
|
||||
|
||||
;; #95E6CB #000000 0 0 0 0 2
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(integer) @number
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(float) @number.float
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(true) @boolean.true
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(false) @boolean.false
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(nil) @constant.nil
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 3
|
||||
((program
|
||||
.
|
||||
(comment) @shebang @nospell)
|
||||
(#match? @shebang "^#!/"))
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
[
|
||||
"!"
|
||||
"="
|
||||
">>"
|
||||
"<<"
|
||||
">"
|
||||
"<"
|
||||
"**"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"+"
|
||||
"-"
|
||||
"&"
|
||||
"|"
|
||||
"^"
|
||||
"%="
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"=~"
|
||||
"!~"
|
||||
"?"
|
||||
":"
|
||||
] @operator
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
[
|
||||
"=="
|
||||
"==="
|
||||
"<=>"
|
||||
"=>"
|
||||
"->"
|
||||
">="
|
||||
"<="
|
||||
"||"
|
||||
"||="
|
||||
"&&="
|
||||
"&&"
|
||||
"!="
|
||||
".."
|
||||
"..."
|
||||
] @operator.ligature
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[
|
||||
","
|
||||
";"
|
||||
"."
|
||||
"&."
|
||||
"::"
|
||||
] @punctuation.delimiter
|
||||
|
||||
(pair
|
||||
":" @punctuation.delimiter)
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 3
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"%w("
|
||||
"%i("
|
||||
] @punctuation.bracket
|
||||
|
||||
(regex
|
||||
"/" @punctuation.bracket)
|
||||
|
||||
(block_parameters
|
||||
"|" @punctuation.bracket)
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(interpolation
|
||||
"#{" @punctuation.special
|
||||
"}" @punctuation.special)
|
||||
|
||||
; Injections
|
||||
|
||||
;; !regex
|
||||
(regex
|
||||
(string_content) @string.regexp)
|
||||
|
||||
(heredoc_body
|
||||
;; !bash
|
||||
(heredoc_content) @bash_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "BASH")))
|
||||
|
||||
(heredoc_body
|
||||
;; !c
|
||||
(heredoc_content) @c_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "C$")))
|
||||
|
||||
(heredoc_body
|
||||
;; !cpp
|
||||
(heredoc_content) @cpp_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "CPP")))
|
||||
|
||||
(heredoc_body
|
||||
;; !css
|
||||
(heredoc_content) @css_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "CSS")))
|
||||
|
||||
(heredoc_body
|
||||
;; !fish
|
||||
(heredoc_content) @fish_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "FISH")))
|
||||
|
||||
(heredoc_body
|
||||
;; !go
|
||||
(heredoc_content) @go_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "GO")))
|
||||
|
||||
(heredoc_body
|
||||
;; !haskell
|
||||
(heredoc_content) @haskell_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "HASKELL")))
|
||||
|
||||
(heredoc_body
|
||||
;; !html
|
||||
(heredoc_content) @html_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "HTML")))
|
||||
|
||||
(heredoc_body
|
||||
;; !javascript
|
||||
(heredoc_content) @javascript_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "JAVASCRIPT")))
|
||||
|
||||
(heredoc_body
|
||||
;; !json
|
||||
(heredoc_content) @json_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "JSON")))
|
||||
|
||||
(heredoc_body
|
||||
;; !lua
|
||||
(heredoc_content) @lua_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "LUA")))
|
||||
|
||||
(heredoc_body
|
||||
;; !make
|
||||
(heredoc_content) @make_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "MAKE")))
|
||||
|
||||
(heredoc_body
|
||||
;; !python
|
||||
(heredoc_content) @python_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "PYTHON")))
|
||||
|
||||
(heredoc_body
|
||||
;; !ruby
|
||||
(heredoc_content) @ruby_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "RUBY")))
|
||||
|
||||
(heredoc_body
|
||||
;; !rust
|
||||
(heredoc_content) @rust_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "RUST")))
|
||||
|
||||
(heredoc_body
|
||||
;; !diff
|
||||
(heredoc_content) @diff_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "DIFF")))
|
||||
|
||||
(heredoc_body
|
||||
;; !embedded_template
|
||||
(heredoc_content) @embedded_template_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "ERB")))
|
||||
|
||||
(heredoc_body
|
||||
;; !gdscript
|
||||
(heredoc_content) @gdscript_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "GDSCRIPT")))
|
||||
|
||||
(heredoc_body
|
||||
;; !gitattributes
|
||||
(heredoc_content) @gitattributes_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "GITATTRIBUTES")))
|
||||
|
||||
(heredoc_body
|
||||
;; !gitignore
|
||||
(heredoc_content) @gitignore_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "GITIGNORE")))
|
||||
|
||||
(heredoc_body
|
||||
;; !gomod
|
||||
(heredoc_content) @gomod_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "GOMOD")))
|
||||
|
||||
(heredoc_body
|
||||
;; !ini
|
||||
(heredoc_content) @ini_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "INI")))
|
||||
|
||||
(heredoc_body
|
||||
;; !markdown
|
||||
(heredoc_content) @markdown_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "MARKDOWN")))
|
||||
|
||||
(heredoc_body
|
||||
;; !nginx
|
||||
(heredoc_content) @nginx_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "NGINX")))
|
||||
|
||||
(heredoc_body
|
||||
;; !php
|
||||
(heredoc_content) @php_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "PHP")))
|
||||
|
||||
(heredoc_body
|
||||
;; !query
|
||||
(heredoc_content) @query_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "QUERY")))
|
||||
|
||||
(heredoc_body
|
||||
;; !regex
|
||||
(heredoc_content) @regex_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "REGEX")))
|
||||
|
||||
(heredoc_body
|
||||
;; !sql
|
||||
(heredoc_content) @sql_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "SQL")))
|
||||
|
||||
(heredoc_body
|
||||
;; !toml
|
||||
(heredoc_content) @toml_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "TOML")))
|
||||
|
||||
(heredoc_body
|
||||
;; !yaml
|
||||
(heredoc_content) @yaml_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "YAML")))
|
||||
|
||||
(heredoc_body
|
||||
;; !cabal
|
||||
(heredoc_content) @cabal_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "CABAL")))
|
||||
|
||||
(heredoc_body
|
||||
;; !man
|
||||
(heredoc_content) @man_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "MAN")))
|
||||
663
grammar/rust.scm
663
grammar/rust.scm
@@ -1,663 +0,0 @@
|
||||
; ============================================================
|
||||
; Identifiers & Modules
|
||||
; ============================================================
|
||||
|
||||
;; #82AAFF #000000 0 0 0 0 1
|
||||
(shebang) @keyword.directive1
|
||||
|
||||
;; #E5C07B #000000 0 0 0 0 1
|
||||
(identifier) @variable1
|
||||
|
||||
;; #A6E22E #000000 0 0 0 0 2
|
||||
((identifier) @type1
|
||||
(#match? @type1 "^[A-Z]"))
|
||||
|
||||
;; #FFD700 #000000 0 0 0 0 2
|
||||
(const_item
|
||||
name: (identifier) @constant1)
|
||||
|
||||
;; #FF9E64 #000000 0 0 0 0 3
|
||||
((identifier) @constant2
|
||||
(#match? @constant2 "^[A-Z][A-Z%d_]*$"))
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 4
|
||||
(type_identifier) @type2
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 2
|
||||
(primitive_type) @type.builtin1
|
||||
|
||||
;; #C678DD #000000 0 0 0 0 2
|
||||
(field_identifier) @variable.member1
|
||||
|
||||
;; #C678DD #000000 0 0 0 0 2
|
||||
(shorthand_field_identifier) @variable.member2
|
||||
|
||||
;; #C678DD #000000 0 0 0 0 2
|
||||
(shorthand_field_initializer
|
||||
(identifier) @variable.member3)
|
||||
|
||||
;; #61AFEF #000000 0 0 0 0 2
|
||||
(mod_item
|
||||
name: (identifier) @module1)
|
||||
|
||||
;; #D19A66 #000000 0 0 0 0 2
|
||||
(self) @variable.builtin1
|
||||
|
||||
;; #5C6370 #000000 0 0 0 0 1
|
||||
"_" @character.special1
|
||||
|
||||
;; #61AFEF #000000 0 0 1 0 2
|
||||
(label
|
||||
[
|
||||
"'"
|
||||
(identifier)
|
||||
] @label1)
|
||||
|
||||
; ============================================================
|
||||
; Functions & Parameters
|
||||
; ============================================================
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(function_item
|
||||
(identifier) @function1)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(function_signature_item
|
||||
(identifier) @function2)
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(parameter
|
||||
[
|
||||
(identifier)
|
||||
"_"
|
||||
] @variable.parameter1)
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(parameter
|
||||
(ref_pattern
|
||||
[
|
||||
(mut_pattern
|
||||
(identifier) @variable.parameter2)
|
||||
(identifier) @variable.parameter3
|
||||
]))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(closure_parameters
|
||||
(_) @variable.parameter4)
|
||||
|
||||
; ============================================================
|
||||
; Function Calls & Constructors
|
||||
; ============================================================
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(call_expression
|
||||
function: (identifier) @function.call1)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
(identifier) @function.call2 .))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(call_expression
|
||||
function: (field_expression
|
||||
field: (field_identifier) @function.call3))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(generic_function
|
||||
function: (identifier) @function.call4)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(generic_function
|
||||
function: (scoped_identifier
|
||||
name: (identifier) @function.call5))
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(generic_function
|
||||
function: (field_expression
|
||||
field: (field_identifier) @function.call6))
|
||||
|
||||
;; #9ADE7A #000000 0 0 0 0 32
|
||||
((field_identifier) @constant3
|
||||
(#match? @constant3 "^[A-Z]"))
|
||||
|
||||
;; #9ADE7A #000000 0 0 0 0 32
|
||||
(enum_variant
|
||||
name: (identifier) @constant4)
|
||||
|
||||
; ============================================================
|
||||
; Scoped Identifiers & Paths
|
||||
; ============================================================
|
||||
|
||||
;; #82AAFF #000000 0 0 0 0 9
|
||||
(scoped_identifier
|
||||
path: (identifier) @module2)
|
||||
|
||||
;; #82AAFF #000000 0 0 0 0 9
|
||||
(scoped_identifier
|
||||
(scoped_identifier
|
||||
name: (identifier) @module3))
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 9
|
||||
(scoped_type_identifier
|
||||
path: (identifier) @module4)
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 9
|
||||
(scoped_type_identifier
|
||||
path: (identifier) @type3
|
||||
(#match? @type3 "^[A-Z]"))
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 9
|
||||
(scoped_type_identifier
|
||||
(scoped_identifier
|
||||
name: (identifier) @module5))
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 9
|
||||
((scoped_identifier
|
||||
path: (identifier) @type4)
|
||||
(#match? @type4 "^[A-Z]"))
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 9
|
||||
((scoped_identifier
|
||||
name: (identifier) @type5)
|
||||
(#match? @type5 "^[A-Z]"))
|
||||
|
||||
;; #FFD700 #000000 0 0 0 0 7
|
||||
((scoped_identifier
|
||||
name: (identifier) @constant5)
|
||||
(#match? @constant5 "^[A-Z][A-Z%d_]*$"))
|
||||
|
||||
;; #FFD700 #000000 0 0 0 0 7
|
||||
((scoped_identifier
|
||||
path: (identifier) @type6
|
||||
name: (identifier) @constant6)
|
||||
(#match? @type6 "^[A-Z]")
|
||||
(#match? @constant6 "^[A-Z]"))
|
||||
|
||||
;; #FFD700 #000000 0 0 0 0 7
|
||||
((scoped_type_identifier
|
||||
path: (identifier) @type7
|
||||
name: (type_identifier) @constant7)
|
||||
(#match? @type7 "^[A-Z]")
|
||||
(#match? @constant7 "^[A-Z]"))
|
||||
|
||||
;; #61AFEF #000000 0 0 0 0 0
|
||||
[
|
||||
(crate)
|
||||
(super)
|
||||
] @module6
|
||||
|
||||
;; #61AFEF #000000 0 0 0 0 0
|
||||
(scoped_use_list
|
||||
path: (identifier) @module7)
|
||||
|
||||
;; #61AFEF #000000 0 0 0 0 0
|
||||
(scoped_use_list
|
||||
path: (scoped_identifier
|
||||
(identifier) @module8))
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 0
|
||||
(use_list
|
||||
(scoped_identifier
|
||||
(identifier) @module9
|
||||
.
|
||||
(_)))
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 0
|
||||
(use_list
|
||||
(identifier) @type8
|
||||
(#match? @type8 "^[A-Z]"))
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 0
|
||||
(use_as_clause
|
||||
alias: (identifier) @type9
|
||||
(#match? @type9 "^[A-Z]"))
|
||||
|
||||
; ============================================================
|
||||
; Enum Constructors & Match Arms
|
||||
; ============================================================
|
||||
|
||||
;; #9ADE7A #000000 0 0 0 0 9
|
||||
; Correct enum constructors
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
"::"
|
||||
name: (identifier) @constant8)
|
||||
(#match? @constant8 "^[A-Z]"))
|
||||
|
||||
;; #FFD700 #000000 0 0 0 0 2
|
||||
; Assume uppercase names in a match arm are constants.
|
||||
((match_arm
|
||||
pattern: (match_pattern
|
||||
(identifier) @constant9))
|
||||
(#match? @constant9 "^[A-Z]"))
|
||||
|
||||
;; #FFD700 #000000 0 0 0 0 2
|
||||
((match_arm
|
||||
pattern: (match_pattern
|
||||
(scoped_identifier
|
||||
name: (identifier) @constant10)))
|
||||
(#match? @constant10 "^[A-Z]"))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 3
|
||||
((identifier) @constant.builtin1
|
||||
(#match? @constant.builtin1 "^(Some|None|Ok|Err)$"))
|
||||
|
||||
; ============================================================
|
||||
; Macros
|
||||
; ============================================================
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
"$" @function.macro1
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
(metavariable) @function.macro2
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
(macro_definition
|
||||
"macro_rules!" @function.macro3)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
(attribute_item
|
||||
(attribute
|
||||
(identifier) @function.macro4))
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
(inner_attribute_item
|
||||
(attribute
|
||||
(identifier) @function.macro5))
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
(attribute
|
||||
(scoped_identifier
|
||||
(identifier) @function.macro6 .))
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
(macro_invocation
|
||||
macro: (identifier) @function.macro7)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
(macro_invocation
|
||||
macro: (scoped_identifier
|
||||
(identifier) @function.macro8 .))
|
||||
|
||||
; ============================================================
|
||||
; Literals
|
||||
; ============================================================
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(boolean_literal) @boolean1
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(integer_literal) @number1
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(float_literal) @number.float1
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 0
|
||||
[
|
||||
(raw_string_literal)
|
||||
(string_literal)
|
||||
] @string1
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 0
|
||||
(escape_sequence) @string.escape1
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
(char_literal) @character1
|
||||
|
||||
; ============================================================
|
||||
; Keywords
|
||||
; ============================================================
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"use"
|
||||
"mod"
|
||||
] @keyword.import1
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(use_as_clause
|
||||
"as" @keyword.import2)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"default"
|
||||
"impl"
|
||||
"let"
|
||||
"move"
|
||||
"unsafe"
|
||||
"where"
|
||||
] @keyword1
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"enum"
|
||||
"struct"
|
||||
"union"
|
||||
"trait"
|
||||
"type"
|
||||
] @keyword.type1
|
||||
|
||||
;; #82AAFF #000000 0 0 0 0 1
|
||||
[
|
||||
"async"
|
||||
"await"
|
||||
"gen"
|
||||
] @keyword.coroutine1
|
||||
|
||||
;; #FF6347 #000000 0 0 0 0 1
|
||||
"try" @keyword.exception1
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"ref"
|
||||
"pub"
|
||||
"raw"
|
||||
(mutable_specifier)
|
||||
"const"
|
||||
"static"
|
||||
"dyn"
|
||||
"extern"
|
||||
] @keyword.modifier1
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(lifetime
|
||||
"'" @keyword.modifier2)
|
||||
|
||||
;; #9ADE7A #000000 0 0 0 0 5
|
||||
(lifetime
|
||||
(identifier) @attribute1)
|
||||
|
||||
;; #9ADE7A #000000 0 0 0 0 5
|
||||
(lifetime
|
||||
(identifier) @attribute.builtin1
|
||||
(#match? @attribute.builtin1 "^(static|_)$"))
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
"fn" @keyword.function1
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"return"
|
||||
"yield"
|
||||
] @keyword.return1
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(type_cast_expression
|
||||
"as" @keyword.operator1)
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(qualified_type
|
||||
"as" @keyword.operator2)
|
||||
|
||||
;; #61AFEF #000000 0 0 0 0 9
|
||||
(use_list
|
||||
(self) @module10)
|
||||
|
||||
;; #61AFEF #000000 0 0 0 0 9
|
||||
(scoped_use_list
|
||||
(self) @module11)
|
||||
|
||||
;; #61AFEF #000000 0 0 0 0 9
|
||||
(scoped_identifier
|
||||
[
|
||||
(crate)
|
||||
(super)
|
||||
(self)
|
||||
] @module12)
|
||||
|
||||
;; #61AFEF #000000 0 0 0 0 9
|
||||
(visibility_modifier
|
||||
[
|
||||
(crate)
|
||||
(super)
|
||||
(self)
|
||||
] @module13)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"match"
|
||||
] @keyword.conditional1
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
[
|
||||
"break"
|
||||
"continue"
|
||||
"in"
|
||||
"loop"
|
||||
"while"
|
||||
] @keyword.repeat1
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
"for" @keyword2
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
(for_expression
|
||||
"for" @keyword.repeat2)
|
||||
|
||||
; ============================================================
|
||||
; Operators
|
||||
; ============================================================
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
[
|
||||
"!"
|
||||
"!="
|
||||
"%"
|
||||
"%="
|
||||
"&"
|
||||
"&&"
|
||||
"&="
|
||||
"*"
|
||||
"*="
|
||||
"+"
|
||||
"+="
|
||||
"-"
|
||||
"-="
|
||||
".."
|
||||
"..="
|
||||
"..."
|
||||
"/"
|
||||
"/="
|
||||
"<"
|
||||
"<<"
|
||||
"<<="
|
||||
"<="
|
||||
"="
|
||||
"=="
|
||||
">"
|
||||
">="
|
||||
">>"
|
||||
">>="
|
||||
"?"
|
||||
"@"
|
||||
"^"
|
||||
"^="
|
||||
"|"
|
||||
"|="
|
||||
"||"
|
||||
] @operator1
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
(use_wildcard
|
||||
"*" @character.special2)
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
(remaining_field_pattern
|
||||
".." @character.special3)
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
(range_pattern
|
||||
[
|
||||
".."
|
||||
"..="
|
||||
"..."
|
||||
] @character.special4)
|
||||
|
||||
; ============================================================
|
||||
; Punctuation
|
||||
; ============================================================
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket1
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
(closure_parameters
|
||||
"|" @punctuation.bracket2)
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
(type_arguments
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket3)
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
(type_parameters
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket4)
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
(bracketed_type
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket5)
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
(for_lifetimes
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket6)
|
||||
|
||||
;; #BFBDB6 #000000 0 1 0 0 1
|
||||
[
|
||||
","
|
||||
"."
|
||||
":"
|
||||
"::"
|
||||
";"
|
||||
"->"
|
||||
"=>"
|
||||
] @punctuation.delimiter1
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
(attribute_item
|
||||
"#" @punctuation.special1)
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
(inner_attribute_item
|
||||
[
|
||||
"!"
|
||||
"#"
|
||||
] @punctuation.special2)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
(macro_invocation
|
||||
"!" @function.macro9)
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 1
|
||||
(never_type
|
||||
"!" @type.builtin2)
|
||||
|
||||
; ============================================================
|
||||
; Panic / Assert / Debug Macros
|
||||
; ============================================================
|
||||
|
||||
;; #FF6347 #000000 0 0 0 0 2
|
||||
(macro_invocation
|
||||
macro: (identifier) @_identifier1 @keyword.exception2
|
||||
"!" @keyword.exception2
|
||||
(#match? @_identifier1 "^panic$"))
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
(macro_invocation
|
||||
macro: (identifier) @_identifier2 @keyword.exception3
|
||||
"!" @keyword.exception3
|
||||
(#match? @_identifier2 "assert"))
|
||||
|
||||
;; #7DCFFF #000000 0 0 0 0 2
|
||||
(macro_invocation
|
||||
macro: (identifier) @_identifier3 @keyword.debug1
|
||||
"!" @keyword.debug1
|
||||
(#match? @_identifier3 "^dbg$"))
|
||||
|
||||
; ============================================================
|
||||
; Comments
|
||||
; ============================================================
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
[
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
(outer_doc_comment_marker)
|
||||
(inner_doc_comment_marker)
|
||||
] @comment1
|
||||
|
||||
(line_comment
|
||||
(doc_comment)) @comment2
|
||||
|
||||
(block_comment
|
||||
(doc_comment)) @comment3
|
||||
|
||||
; ============================================================
|
||||
; Regex Strings (highlighted)
|
||||
; ============================================================
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
path: (identifier) @_regex1
|
||||
(#match? @_regex1 "Regex")
|
||||
name: (identifier) @_new1
|
||||
(#match? @_new1 "^new$"))
|
||||
arguments: (arguments
|
||||
(raw_string_literal
|
||||
;; !regex
|
||||
(string_content) @string.regexp)))
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
path: (scoped_identifier
|
||||
(identifier) @_regex2
|
||||
(#match? @_regex2 "Regex") .)
|
||||
name: (identifier) @_new2
|
||||
(#match? @_new2 "^new$"))
|
||||
arguments: (arguments
|
||||
(raw_string_literal
|
||||
(string_content) @string.regexp)))
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
path: (identifier) @_regex3
|
||||
(#match? @_regex3 "Regex")
|
||||
name: (identifier) @_new3
|
||||
(#match? @_new3 "^new$"))
|
||||
arguments: (arguments
|
||||
(array_expression
|
||||
(raw_string_literal
|
||||
(string_content) @string.regexp))))
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
path: (scoped_identifier
|
||||
(identifier) @_regex4
|
||||
(#match? @_regex4 "Regex") .)
|
||||
name: (identifier) @_new4
|
||||
(#match? @_new4 "^new$"))
|
||||
arguments: (arguments
|
||||
(array_expression
|
||||
(raw_string_literal
|
||||
(string_content) @string.regexp))))
|
||||
469
grammar/sql.scm
469
grammar/sql.scm
@@ -1,469 +0,0 @@
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(object_reference
|
||||
name: (identifier) @type)
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(invocation
|
||||
(object_reference
|
||||
name: (identifier) @function.call))
|
||||
|
||||
((term
|
||||
value: (cast
|
||||
name: (keyword_cast) @function.call
|
||||
parameter: [(literal)]?)))
|
||||
|
||||
[
|
||||
(keyword_gist)
|
||||
(keyword_btree)
|
||||
(keyword_hash)
|
||||
(keyword_spgist)
|
||||
(keyword_gin)
|
||||
(keyword_brin)
|
||||
(keyword_array)
|
||||
(keyword_object_id)
|
||||
] @function.call
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(relation
|
||||
alias: (identifier) @variable)
|
||||
|
||||
(term
|
||||
alias: (identifier) @variable)
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(field
|
||||
name: (identifier) @field)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 2
|
||||
((literal) @number
|
||||
(#match? @number "^[-+0-9]+$"))
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 2
|
||||
((literal) @float
|
||||
(#match? @float "^[-+0-9]+\\.[0-9]+$"))
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 0
|
||||
(literal) @string
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment @spell
|
||||
(marginalia) @comment
|
||||
|
||||
(parameter) @parameter
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
[
|
||||
(keyword_true)
|
||||
(keyword_false)
|
||||
] @boolean
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
[
|
||||
(keyword_asc)
|
||||
(keyword_desc)
|
||||
(keyword_terminated)
|
||||
(keyword_escaped)
|
||||
(keyword_unsigned)
|
||||
(keyword_nulls)
|
||||
(keyword_last)
|
||||
(keyword_delimited)
|
||||
(keyword_replication)
|
||||
(keyword_auto_increment)
|
||||
(keyword_default)
|
||||
(keyword_collate)
|
||||
(keyword_concurrently)
|
||||
(keyword_engine)
|
||||
(keyword_always)
|
||||
(keyword_generated)
|
||||
(keyword_preceding)
|
||||
(keyword_following)
|
||||
(keyword_first)
|
||||
(keyword_current_timestamp)
|
||||
(keyword_immutable)
|
||||
(keyword_atomic)
|
||||
(keyword_parallel)
|
||||
(keyword_leakproof)
|
||||
(keyword_safe)
|
||||
(keyword_cost)
|
||||
(keyword_strict)
|
||||
] @attribute
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
[
|
||||
(keyword_materialized)
|
||||
(keyword_recursive)
|
||||
(keyword_temp)
|
||||
(keyword_temporary)
|
||||
(keyword_unlogged)
|
||||
(keyword_external)
|
||||
(keyword_parquet)
|
||||
(keyword_csv)
|
||||
(keyword_rcfile)
|
||||
(keyword_textfile)
|
||||
(keyword_orc)
|
||||
(keyword_avro)
|
||||
(keyword_jsonfile)
|
||||
(keyword_sequencefile)
|
||||
(keyword_volatile)
|
||||
] @storageclass
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
[
|
||||
(keyword_case)
|
||||
(keyword_when)
|
||||
(keyword_then)
|
||||
(keyword_else)
|
||||
] @conditional
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
[
|
||||
(keyword_select)
|
||||
(keyword_from)
|
||||
(keyword_where)
|
||||
(keyword_index)
|
||||
(keyword_join)
|
||||
(keyword_primary)
|
||||
(keyword_delete)
|
||||
(keyword_create)
|
||||
(keyword_show)
|
||||
(keyword_unload)
|
||||
(keyword_insert)
|
||||
(keyword_merge)
|
||||
(keyword_distinct)
|
||||
(keyword_replace)
|
||||
(keyword_update)
|
||||
(keyword_into)
|
||||
(keyword_overwrite)
|
||||
(keyword_matched)
|
||||
(keyword_values)
|
||||
(keyword_value)
|
||||
(keyword_attribute)
|
||||
(keyword_set)
|
||||
(keyword_left)
|
||||
(keyword_right)
|
||||
(keyword_outer)
|
||||
(keyword_inner)
|
||||
(keyword_full)
|
||||
(keyword_order)
|
||||
(keyword_partition)
|
||||
(keyword_group)
|
||||
(keyword_with)
|
||||
(keyword_without)
|
||||
(keyword_as)
|
||||
(keyword_having)
|
||||
(keyword_limit)
|
||||
(keyword_offset)
|
||||
(keyword_table)
|
||||
(keyword_tables)
|
||||
(keyword_key)
|
||||
(keyword_references)
|
||||
(keyword_foreign)
|
||||
(keyword_constraint)
|
||||
(keyword_force)
|
||||
(keyword_use)
|
||||
(keyword_include)
|
||||
(keyword_for)
|
||||
(keyword_if)
|
||||
(keyword_exists)
|
||||
(keyword_column)
|
||||
(keyword_columns)
|
||||
(keyword_cross)
|
||||
(keyword_lateral)
|
||||
(keyword_natural)
|
||||
(keyword_alter)
|
||||
(keyword_drop)
|
||||
(keyword_add)
|
||||
(keyword_view)
|
||||
(keyword_end)
|
||||
(keyword_is)
|
||||
(keyword_using)
|
||||
(keyword_between)
|
||||
(keyword_window)
|
||||
(keyword_no)
|
||||
(keyword_data)
|
||||
(keyword_type)
|
||||
(keyword_rename)
|
||||
(keyword_to)
|
||||
(keyword_schema)
|
||||
(keyword_owner)
|
||||
(keyword_authorization)
|
||||
(keyword_all)
|
||||
(keyword_any)
|
||||
(keyword_some)
|
||||
(keyword_returning)
|
||||
(keyword_begin)
|
||||
(keyword_commit)
|
||||
(keyword_rollback)
|
||||
(keyword_transaction)
|
||||
(keyword_only)
|
||||
(keyword_like)
|
||||
(keyword_similar)
|
||||
(keyword_over)
|
||||
(keyword_change)
|
||||
(keyword_modify)
|
||||
(keyword_after)
|
||||
(keyword_before)
|
||||
(keyword_range)
|
||||
(keyword_rows)
|
||||
(keyword_groups)
|
||||
(keyword_exclude)
|
||||
(keyword_current)
|
||||
(keyword_ties)
|
||||
(keyword_others)
|
||||
(keyword_zerofill)
|
||||
(keyword_format)
|
||||
(keyword_fields)
|
||||
(keyword_row)
|
||||
(keyword_sort)
|
||||
(keyword_compute)
|
||||
(keyword_comment)
|
||||
(keyword_location)
|
||||
(keyword_cached)
|
||||
(keyword_uncached)
|
||||
(keyword_lines)
|
||||
(keyword_stored)
|
||||
(keyword_virtual)
|
||||
(keyword_partitioned)
|
||||
(keyword_analyze)
|
||||
(keyword_explain)
|
||||
(keyword_verbose)
|
||||
(keyword_truncate)
|
||||
(keyword_rewrite)
|
||||
(keyword_optimize)
|
||||
(keyword_vacuum)
|
||||
(keyword_cache)
|
||||
(keyword_language)
|
||||
(keyword_called)
|
||||
(keyword_conflict)
|
||||
(keyword_declare)
|
||||
(keyword_filter)
|
||||
(keyword_function)
|
||||
(keyword_input)
|
||||
(keyword_name)
|
||||
(keyword_oid)
|
||||
(keyword_oids)
|
||||
(keyword_precision)
|
||||
(keyword_regclass)
|
||||
(keyword_regnamespace)
|
||||
(keyword_regproc)
|
||||
(keyword_regtype)
|
||||
(keyword_restricted)
|
||||
(keyword_return)
|
||||
(keyword_returns)
|
||||
(keyword_separator)
|
||||
(keyword_setof)
|
||||
(keyword_stable)
|
||||
(keyword_support)
|
||||
(keyword_tblproperties)
|
||||
(keyword_trigger)
|
||||
(keyword_unsafe)
|
||||
(keyword_admin)
|
||||
(keyword_connection)
|
||||
(keyword_cycle)
|
||||
(keyword_database)
|
||||
(keyword_encrypted)
|
||||
(keyword_increment)
|
||||
(keyword_logged)
|
||||
(keyword_none)
|
||||
(keyword_owned)
|
||||
(keyword_password)
|
||||
(keyword_reset)
|
||||
(keyword_role)
|
||||
(keyword_sequence)
|
||||
(keyword_start)
|
||||
(keyword_restart)
|
||||
(keyword_tablespace)
|
||||
(keyword_split)
|
||||
(keyword_tablets)
|
||||
(keyword_until)
|
||||
(keyword_user)
|
||||
(keyword_valid)
|
||||
(keyword_action)
|
||||
(keyword_definer)
|
||||
(keyword_invoker)
|
||||
(keyword_security)
|
||||
(keyword_extension)
|
||||
(keyword_version)
|
||||
(keyword_out)
|
||||
(keyword_inout)
|
||||
(keyword_variadic)
|
||||
(keyword_ordinality)
|
||||
(keyword_session)
|
||||
(keyword_isolation)
|
||||
(keyword_level)
|
||||
(keyword_serializable)
|
||||
(keyword_repeatable)
|
||||
(keyword_read)
|
||||
(keyword_write)
|
||||
(keyword_committed)
|
||||
(keyword_uncommitted)
|
||||
(keyword_deferrable)
|
||||
(keyword_names)
|
||||
(keyword_zone)
|
||||
(keyword_immediate)
|
||||
(keyword_deferred)
|
||||
(keyword_constraints)
|
||||
(keyword_snapshot)
|
||||
(keyword_characteristics)
|
||||
(keyword_off)
|
||||
(keyword_follows)
|
||||
(keyword_precedes)
|
||||
(keyword_each)
|
||||
(keyword_instead)
|
||||
(keyword_of)
|
||||
(keyword_initially)
|
||||
(keyword_old)
|
||||
(keyword_new)
|
||||
(keyword_referencing)
|
||||
(keyword_statement)
|
||||
(keyword_execute)
|
||||
(keyword_procedure)
|
||||
(keyword_copy)
|
||||
(keyword_delimiter)
|
||||
(keyword_encoding)
|
||||
(keyword_escape)
|
||||
(keyword_force_not_null)
|
||||
(keyword_force_null)
|
||||
(keyword_force_quote)
|
||||
(keyword_freeze)
|
||||
(keyword_header)
|
||||
(keyword_match)
|
||||
(keyword_program)
|
||||
(keyword_quote)
|
||||
(keyword_stdin)
|
||||
(keyword_extended)
|
||||
(keyword_main)
|
||||
(keyword_plain)
|
||||
(keyword_storage)
|
||||
(keyword_compression)
|
||||
(keyword_duplicate)
|
||||
(keyword_while)
|
||||
] @keyword
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
[
|
||||
(keyword_restrict)
|
||||
(keyword_unbounded)
|
||||
(keyword_unique)
|
||||
(keyword_cascade)
|
||||
(keyword_delayed)
|
||||
(keyword_high_priority)
|
||||
(keyword_low_priority)
|
||||
(keyword_ignore)
|
||||
(keyword_nothing)
|
||||
(keyword_check)
|
||||
(keyword_option)
|
||||
(keyword_local)
|
||||
(keyword_cascaded)
|
||||
(keyword_wait)
|
||||
(keyword_nowait)
|
||||
(keyword_metadata)
|
||||
(keyword_incremental)
|
||||
(keyword_bin_pack)
|
||||
(keyword_noscan)
|
||||
(keyword_stats)
|
||||
(keyword_statistics)
|
||||
(keyword_maxvalue)
|
||||
(keyword_minvalue)
|
||||
] @type.qualifier
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
[
|
||||
(keyword_int)
|
||||
(keyword_null)
|
||||
(keyword_boolean)
|
||||
(keyword_binary)
|
||||
(keyword_varbinary)
|
||||
(keyword_image)
|
||||
(keyword_bit)
|
||||
(keyword_inet)
|
||||
(keyword_character)
|
||||
(keyword_smallserial)
|
||||
(keyword_serial)
|
||||
(keyword_bigserial)
|
||||
(keyword_smallint)
|
||||
(keyword_mediumint)
|
||||
(keyword_bigint)
|
||||
(keyword_tinyint)
|
||||
(keyword_decimal)
|
||||
(keyword_float)
|
||||
(keyword_double)
|
||||
(keyword_numeric)
|
||||
(keyword_real)
|
||||
(double)
|
||||
(keyword_money)
|
||||
(keyword_smallmoney)
|
||||
(keyword_char)
|
||||
(keyword_nchar)
|
||||
(keyword_varchar)
|
||||
(keyword_nvarchar)
|
||||
(keyword_varying)
|
||||
(keyword_text)
|
||||
(keyword_string)
|
||||
(keyword_uuid)
|
||||
(keyword_json)
|
||||
(keyword_jsonb)
|
||||
(keyword_xml)
|
||||
(keyword_bytea)
|
||||
(keyword_enum)
|
||||
(keyword_date)
|
||||
(keyword_datetime)
|
||||
(keyword_time)
|
||||
(keyword_datetime2)
|
||||
(keyword_datetimeoffset)
|
||||
(keyword_smalldatetime)
|
||||
(keyword_timestamp)
|
||||
(keyword_timestamptz)
|
||||
(keyword_geometry)
|
||||
(keyword_geography)
|
||||
(keyword_box2d)
|
||||
(keyword_box3d)
|
||||
(keyword_interval)
|
||||
] @type.builtin
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
[
|
||||
(keyword_in)
|
||||
(keyword_and)
|
||||
(keyword_or)
|
||||
(keyword_not)
|
||||
(keyword_by)
|
||||
(keyword_on)
|
||||
(keyword_do)
|
||||
(keyword_union)
|
||||
(keyword_except)
|
||||
(keyword_intersect)
|
||||
] @keyword.operator
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
[
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"^"
|
||||
":="
|
||||
"="
|
||||
"<"
|
||||
"<="
|
||||
"!="
|
||||
">="
|
||||
">"
|
||||
"<>"
|
||||
(op_other)
|
||||
(op_unary_other)
|
||||
] @operator
|
||||
|
||||
;; #888888 #000000 0 0 0 0 1
|
||||
[
|
||||
"("
|
||||
")"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #888888 #000000 0 1 0 0 1
|
||||
[
|
||||
";"
|
||||
","
|
||||
"."
|
||||
] @punctuation.delimiter
|
||||
@@ -1,56 +0,0 @@
|
||||
;; #F0F8FF #000000 0 0 0 0 2
|
||||
(bare_key) @type
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(quoted_key) @string.quoted
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 0
|
||||
(pair
|
||||
(bare_key)) @property
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 0
|
||||
(pair
|
||||
(dotted_key
|
||||
(bare_key) @property))
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(boolean) @boolean
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 1
|
||||
(string) @string
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
[
|
||||
(integer)
|
||||
(float)
|
||||
] @number
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
[
|
||||
(offset_date_time)
|
||||
(local_date_time)
|
||||
(local_date)
|
||||
(local_time)
|
||||
] @string.special
|
||||
|
||||
;; #888888 #000000 0 1 0 0 3
|
||||
[
|
||||
"."
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
"=" @operator
|
||||
|
||||
;; #888888 #000000 0 0 0 0 3
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
"[["
|
||||
"]]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
@@ -1,316 +0,0 @@
|
||||
; ============================================================
|
||||
; Identifiers
|
||||
; ============================================================
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 1
|
||||
(identifier) @variable
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z_][A-Z0-9_]*$"))
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 3
|
||||
((identifier) @variable.builtin
|
||||
(#match? @variable.builtin
|
||||
"^(arguments|console|window|document|globalThis|process|module|exports)$"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 1
|
||||
((identifier) @constructor
|
||||
(#match? @constructor "^[A-Z][a-zA-Z0-9]*$"))
|
||||
|
||||
; ============================================================
|
||||
; Properties
|
||||
; ============================================================
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
(property_identifier) @property
|
||||
|
||||
; ============================================================
|
||||
; Functions
|
||||
; ============================================================
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(function_declaration
|
||||
name: (identifier) @function)
|
||||
|
||||
(function_expression
|
||||
name: (identifier) @function)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(method_definition
|
||||
name: (property_identifier) @function.method)
|
||||
|
||||
(variable_declarator
|
||||
name: (identifier) @function
|
||||
value: [(function_expression) (arrow_function)])
|
||||
|
||||
(assignment_expression
|
||||
left: (identifier) @function
|
||||
right: [(function_expression) (arrow_function)])
|
||||
|
||||
(pair
|
||||
key: (property_identifier) @function.method
|
||||
value: [(function_expression) (arrow_function)])
|
||||
|
||||
; ------------------------------------------------------------
|
||||
; Function calls
|
||||
; ------------------------------------------------------------
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(call_expression
|
||||
function: (identifier) @function.call)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 2
|
||||
(call_expression
|
||||
function: (member_expression
|
||||
property: (property_identifier) @function.method))
|
||||
|
||||
; ============================================================
|
||||
; Highlighted definitions & references
|
||||
; ============================================================
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(assignment_expression
|
||||
left: [
|
||||
(identifier) @name
|
||||
(member_expression
|
||||
property: (property_identifier) @name)
|
||||
]
|
||||
right: [(arrow_function) (function_expression)]
|
||||
) @definition.function
|
||||
|
||||
;; #FFB454 #000000 0 0 0 0 3
|
||||
(pair
|
||||
key: (property_identifier) @name
|
||||
value: [(arrow_function) (function_expression)]) @definition.function
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 0
|
||||
((call_expression
|
||||
function: (identifier) @name) @reference.call
|
||||
(#not-match? @name "^(require)$"))
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(new_expression
|
||||
constructor: (_) @name) @reference.class
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(export_statement value: (assignment_expression left: (identifier) @name right: ([
|
||||
(number)
|
||||
(string)
|
||||
(identifier)
|
||||
(undefined)
|
||||
(null)
|
||||
(new_expression)
|
||||
(binary_expression)
|
||||
(call_expression)
|
||||
]))) @definition.constant
|
||||
|
||||
; ============================================================
|
||||
; Parameters
|
||||
; ============================================================
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(formal_parameters
|
||||
[
|
||||
(identifier) @variable.parameter
|
||||
(array_pattern
|
||||
(identifier) @variable.parameter)
|
||||
(object_pattern
|
||||
[
|
||||
(pair_pattern value: (identifier) @variable.parameter)
|
||||
(shorthand_property_identifier_pattern) @variable.parameter
|
||||
])
|
||||
])
|
||||
|
||||
; ============================================================
|
||||
; Keywords (split into semantic groups)
|
||||
; ============================================================
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
; Declarations
|
||||
[
|
||||
"var"
|
||||
"let"
|
||||
"const"
|
||||
"function"
|
||||
"class"
|
||||
] @keyword.declaration
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
; Control flow
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"switch"
|
||||
"case"
|
||||
"default"
|
||||
"for"
|
||||
"while"
|
||||
"do"
|
||||
"break"
|
||||
"continue"
|
||||
"return"
|
||||
"throw"
|
||||
"try"
|
||||
"catch"
|
||||
"finally"
|
||||
"extends"
|
||||
] @keyword.control
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
; Imports / exports
|
||||
[
|
||||
"import"
|
||||
"export"
|
||||
"from"
|
||||
"as"
|
||||
] @keyword.import
|
||||
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
; Operators-as-keywords
|
||||
[
|
||||
"in"
|
||||
"instanceof"
|
||||
"new"
|
||||
"delete"
|
||||
"typeof"
|
||||
"void"
|
||||
"await"
|
||||
"yield"
|
||||
] @keyword.operator
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 0 1
|
||||
; Modifiers
|
||||
[
|
||||
"async"
|
||||
"static"
|
||||
"get"
|
||||
"set"
|
||||
] @keyword.modifier
|
||||
|
||||
; ============================================================
|
||||
; Literals
|
||||
; ============================================================
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
(this) @variable.builtin
|
||||
(super) @variable.builtin
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 4
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
(null)
|
||||
(undefined)
|
||||
] @constant.builtin
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 2
|
||||
(number) @number
|
||||
|
||||
;; #D2A6FF #000000 0 1 0 0 2
|
||||
((string) @use_strict
|
||||
(#match? @use_strict "^['\"]use strict['\"]$"))
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 0
|
||||
(string) @string
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 0
|
||||
(template_string) @string.special
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment
|
||||
|
||||
; ============================================================
|
||||
; Operators & punctuation
|
||||
; ============================================================
|
||||
|
||||
;; #F29668 #000000 0 1 0 0 1
|
||||
[
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"**"
|
||||
"++"
|
||||
"--"
|
||||
"=="
|
||||
"!="
|
||||
"==="
|
||||
"!=="
|
||||
"<"
|
||||
"<="
|
||||
">"
|
||||
">="
|
||||
"&&"
|
||||
"||"
|
||||
"??"
|
||||
"!"
|
||||
"~"
|
||||
"&"
|
||||
"|"
|
||||
"^"
|
||||
"<<"
|
||||
">>"
|
||||
">>>"
|
||||
"="
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"<<="
|
||||
">>="
|
||||
">>>="
|
||||
"&="
|
||||
"|="
|
||||
"^="
|
||||
"&&="
|
||||
"||="
|
||||
"??="
|
||||
"=>"
|
||||
] @operator
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[
|
||||
"."
|
||||
","
|
||||
";"
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 1
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(template_substitution
|
||||
"${" @punctuation.special
|
||||
"}" @punctuation.special)
|
||||
|
||||
; ============================================================
|
||||
; JSX
|
||||
; ============================================================
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0 4
|
||||
(jsx_opening_element (identifier) @tag2)
|
||||
(jsx_closing_element (identifier) @tag2)
|
||||
(jsx_self_closing_element (identifier) @tag2)
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 3
|
||||
(jsx_attribute (property_identifier) @attribute2)
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 0 3
|
||||
(jsx_opening_element (["<" ">"]) @punctuation.bracket2)
|
||||
(jsx_closing_element (["</" ">"]) @punctuation.bracket2)
|
||||
(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket2)
|
||||
|
||||
; Injections
|
||||
|
||||
;; !regex
|
||||
(regex) @string.regex
|
||||
@@ -1,98 +0,0 @@
|
||||
;; #F29668 #000000 0 0 0 0 1
|
||||
(boolean_scalar) @boolean
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
(null_scalar) @constant.builtin
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0 0
|
||||
[
|
||||
(double_quote_scalar)
|
||||
(single_quote_scalar)
|
||||
] @string
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 0 0
|
||||
[
|
||||
(block_scalar)
|
||||
(string_scalar)
|
||||
] @string.abs
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
[
|
||||
(integer_scalar)
|
||||
(float_scalar)
|
||||
] @number
|
||||
|
||||
;; #99ADBF #000000 0 1 0 0 1
|
||||
(comment) @comment
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
[
|
||||
(anchor_name)
|
||||
(alias_name)
|
||||
] @label
|
||||
|
||||
;; #7dcfff #000000 0 0 0 0 2
|
||||
(tag) @type
|
||||
|
||||
;; #F07178 #000000 0 0 0 0 1
|
||||
[
|
||||
(yaml_directive)
|
||||
(tag_directive)
|
||||
(reserved_directive)
|
||||
] @attribute
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(block_mapping_pair
|
||||
key: (flow_node
|
||||
[
|
||||
(double_quote_scalar)
|
||||
(single_quote_scalar)
|
||||
] @property))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(block_mapping_pair
|
||||
key: (flow_node
|
||||
(plain_scalar
|
||||
(string_scalar) @property)))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(flow_mapping
|
||||
(_
|
||||
key: (flow_node
|
||||
[
|
||||
(double_quote_scalar)
|
||||
(single_quote_scalar)
|
||||
] @property)))
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 0 1
|
||||
(flow_mapping
|
||||
(_
|
||||
key: (flow_node
|
||||
(plain_scalar
|
||||
(string_scalar) @property))))
|
||||
|
||||
;; #F38BA8 #000000 0 1 0 0 3
|
||||
[
|
||||
","
|
||||
"-"
|
||||
":"
|
||||
">"
|
||||
"?"
|
||||
"|"
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #888888 #000000 0 0 0 0 3
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #AAD94C #000000 0 1 0 0 3
|
||||
[
|
||||
"*"
|
||||
"&"
|
||||
"---"
|
||||
"..."
|
||||
] @punctuation.special
|
||||
291
include/config.h
291
include/config.h
@@ -1,291 +0,0 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#include "lsp/lsp.h"
|
||||
#include "pch.h"
|
||||
|
||||
static const std::unordered_map<uint8_t, LSP> kLsps = {
|
||||
{1,
|
||||
{"clangd",
|
||||
{
|
||||
"clangd",
|
||||
"--background-index",
|
||||
"--clang-tidy",
|
||||
"--completion-style=detailed",
|
||||
"--header-insertion=never",
|
||||
"--pch-storage=memory",
|
||||
"--limit-results=50",
|
||||
"--log=error",
|
||||
nullptr,
|
||||
}}},
|
||||
{2,
|
||||
{"ruby-lsp",
|
||||
{
|
||||
"ruby-lsp",
|
||||
nullptr,
|
||||
}}},
|
||||
{3,
|
||||
{"solargraph",
|
||||
{
|
||||
"solargraph",
|
||||
"stdio",
|
||||
nullptr,
|
||||
}}},
|
||||
{4,
|
||||
{"bash-language-server",
|
||||
{
|
||||
"bash-language-server",
|
||||
"start",
|
||||
nullptr,
|
||||
}}},
|
||||
{5,
|
||||
{"vscode-css-language-server",
|
||||
{
|
||||
"vscode-css-language-server",
|
||||
"--stdio",
|
||||
nullptr,
|
||||
}}},
|
||||
{6,
|
||||
{"vscode-json-language-server",
|
||||
{
|
||||
"vscode-json-language-server",
|
||||
"--stdio",
|
||||
nullptr,
|
||||
}}},
|
||||
{7,
|
||||
{"fish-lsp",
|
||||
{
|
||||
"fish-lsp",
|
||||
"start",
|
||||
nullptr,
|
||||
}}},
|
||||
{8,
|
||||
{"gopls",
|
||||
{
|
||||
"gopls",
|
||||
"serve",
|
||||
nullptr,
|
||||
}}},
|
||||
{9,
|
||||
{"haskell-language-server",
|
||||
{
|
||||
"haskell-language-server",
|
||||
"lsp",
|
||||
nullptr,
|
||||
}}},
|
||||
{10,
|
||||
{"emmet-language-server",
|
||||
{
|
||||
"emmet-language-server",
|
||||
"--stdio",
|
||||
nullptr,
|
||||
}}},
|
||||
{11,
|
||||
{"typescript-language-server",
|
||||
{
|
||||
"typescript-language-server",
|
||||
"--stdio",
|
||||
nullptr,
|
||||
}}},
|
||||
#define LUA_LS 12
|
||||
{12,
|
||||
{"lua-language-server",
|
||||
{
|
||||
"lua-language-server",
|
||||
nullptr,
|
||||
}}},
|
||||
{13,
|
||||
{"pyright-langserver",
|
||||
{
|
||||
"pyright-langserver",
|
||||
"--stdio",
|
||||
nullptr,
|
||||
}}},
|
||||
{14,
|
||||
{"rust-analyzer",
|
||||
{
|
||||
"rust-analyzer",
|
||||
nullptr,
|
||||
}}},
|
||||
{15,
|
||||
{"intelephense",
|
||||
{
|
||||
"intelephense",
|
||||
"--stdio",
|
||||
nullptr,
|
||||
}}},
|
||||
{16,
|
||||
{"marksman",
|
||||
{
|
||||
"marksman",
|
||||
"server",
|
||||
nullptr,
|
||||
}}},
|
||||
{17,
|
||||
{"nginx-language-server",
|
||||
{
|
||||
"nginx-language-server",
|
||||
nullptr,
|
||||
}}},
|
||||
{18,
|
||||
{"taplo",
|
||||
{
|
||||
"taplo",
|
||||
"lsp",
|
||||
"stdio",
|
||||
nullptr,
|
||||
}}},
|
||||
{19,
|
||||
{"yaml-language-server",
|
||||
{
|
||||
"yaml-language-server",
|
||||
"--stdio",
|
||||
nullptr,
|
||||
}}},
|
||||
{20,
|
||||
{"sqls",
|
||||
{
|
||||
"sqls",
|
||||
"serve",
|
||||
nullptr,
|
||||
}}},
|
||||
{21,
|
||||
{"make-language-server",
|
||||
{
|
||||
"make-language-server",
|
||||
nullptr,
|
||||
}}},
|
||||
{22,
|
||||
{"sql-language-server",
|
||||
{
|
||||
"sql-language-server",
|
||||
"up",
|
||||
"--method",
|
||||
"stdio",
|
||||
nullptr,
|
||||
}}},
|
||||
};
|
||||
|
||||
static const std::unordered_map<std::string, Language> kLanguages = {
|
||||
{"bash", {"bash", 4, 0x4d5a5e, " "}},
|
||||
{"c", {"c", 1, 0x555555, " "}},
|
||||
{"cpp", {"cpp", 1, 0x00599C, " "}},
|
||||
{"h", {"h", 1, 0xA8B9CC, " "}},
|
||||
{"css", {"css", 5, 0x36a3d9, " "}},
|
||||
{"fish", {"fish", 7, 0x4d5a5e, " "}},
|
||||
{"go", {"go", 8, 0x00add8, " "}},
|
||||
{"gomod", {"gomod", 8, 0x00add8, " "}},
|
||||
{"haskell", {"haskell", 9, 0xa074c4, " "}},
|
||||
{"html", {"html", 10, 0xef8a91, " "}},
|
||||
{"javascript", {"javascript", 11, 0xf0df8a, " "}},
|
||||
{"typescript", {"typescript", 11, 0x36a3d9, " "}},
|
||||
{"json", {"json", 6, 0xcbcb41, "{}"}},
|
||||
{"jsonc", {"jsonc", 6, 0xcbcb41, "{}"}},
|
||||
{"erb", {"erb", 10, 0x6e1516, " "}},
|
||||
{"ruby", {"ruby", 3, 0xff8087, " "}},
|
||||
{"lua", {"lua", 12, 0x36a3d9, " "}},
|
||||
{"python", {"python", 13, 0x95e6cb, " "}},
|
||||
{"rust", {"rust", 14, 0xdea584, " "}},
|
||||
{"php", {"php", 15, 0xa074c4, " "}},
|
||||
{"markdown", {"markdown", 16, 0x36a3d9, " "}},
|
||||
{"markdown_inline", {"markdown_inline", 16, 0x36a3d9, " "}},
|
||||
{"nginx", {"nginx", 17, 0x6d8086, " "}},
|
||||
{"toml", {"toml", 18, 0x36a3d9, " "}},
|
||||
{"yaml", {"yaml", 19, 0x6d8086, " "}},
|
||||
{"sql", {"sql", 20, 0xdad8d8, " "}},
|
||||
{"make", {"make", 21, 0x4e5c61, " "}},
|
||||
{"gdscript", {"gdscript", 0, 0x6d8086, " "}},
|
||||
{"man", {"man", 0, 0xdad8d8, " "}},
|
||||
{"diff", {"diff", 0, 0xDD4C35, " "}},
|
||||
{"gitattributes", {"gitattributes", 0, 0xF05032, " "}},
|
||||
{"gitignore", {"gitignore", 0, 0xF05032, " "}},
|
||||
{"query", {"query", 0, 0x7E57C2, " "}},
|
||||
{"regex", {"regex", 0, 0x9E9E9E, ".*"}},
|
||||
{"ini", {"ini", 0, 0x6d8086, " "}},
|
||||
};
|
||||
|
||||
static const std::unordered_map<std::string, std::string> kExtToLang = {
|
||||
{"sh", "bash"},
|
||||
{"bash", "bash"},
|
||||
{"c", "c"},
|
||||
{"cpp", "cpp"},
|
||||
{"cxx", "cpp"},
|
||||
{"cc", "cpp"},
|
||||
{"hpp", "h"},
|
||||
{"hh", "h"},
|
||||
{"hxx", "h"},
|
||||
{"h", "h"},
|
||||
{"css", "css"},
|
||||
{"fish", "fish"},
|
||||
{"go", "go"},
|
||||
{"hs", "haskell"},
|
||||
{"html", "html"},
|
||||
{"htm", "html"},
|
||||
{"js", "javascript"},
|
||||
{"jsx", "javascript"},
|
||||
{"ts", "typescript"},
|
||||
{"tsx", "typescript"},
|
||||
{"json", "json"},
|
||||
{"jsonc", "jsonc"},
|
||||
{"lua", "lua"},
|
||||
{"make", "make"},
|
||||
{"mk", "make"},
|
||||
{"makefile", "make"},
|
||||
{"man", "man"},
|
||||
{"py", "python"},
|
||||
{"rb", "ruby"},
|
||||
{"rs", "rust"},
|
||||
{"diff", "diff"},
|
||||
{"patch", "diff"},
|
||||
{"erb", "erb"},
|
||||
{"gd", "gdscript"},
|
||||
{"gitattributes", "gitattributes"},
|
||||
{"gitignore", "gitignore"},
|
||||
{"mod", "gomod"},
|
||||
{"ini", "ini"},
|
||||
{"gitmodules", "ini"},
|
||||
{"md", "markdown"},
|
||||
{"markdown", "markdown"},
|
||||
{"conf", "nginx"},
|
||||
{"php", "php"},
|
||||
{"scm", "query"},
|
||||
{"regex", "regex"},
|
||||
{"sql", "sql"},
|
||||
{"toml", "toml"},
|
||||
{"yaml", "yaml"},
|
||||
{"yml", "yaml"},
|
||||
{"clangd", "yaml"},
|
||||
};
|
||||
|
||||
static const std::unordered_map<std::string, std::string> kMimeToLang = {
|
||||
{"text/x-c", "c"},
|
||||
{"text/x-c++", "cpp"},
|
||||
{"text/x-shellscript", "bash"},
|
||||
{"application/json", "json"},
|
||||
{"text/javascript", "javascript"},
|
||||
{"text/html", "html"},
|
||||
{"text/css", "css"},
|
||||
{"text/x-python", "python"},
|
||||
{"text/x-ruby", "ruby"},
|
||||
{"text/x-go", "go"},
|
||||
{"text/x-haskell", "haskell"},
|
||||
{"text/x-rust", "rust"},
|
||||
{"text/x-lua", "lua"},
|
||||
{"text/x-diff", "diff"},
|
||||
{"text/x-gdscript", "gdscript"},
|
||||
{"text/x-gitattributes", "gitattributes"},
|
||||
{"text/x-gitignore", "gitignore"},
|
||||
{"text/x-gomod", "gomod"},
|
||||
{"text/x-ini", "ini"},
|
||||
{"text/markdown", "markdown"},
|
||||
{"text/x-nginx-conf", "nginx"},
|
||||
{"application/x-php", "php"},
|
||||
{"text/x-tree-sitter-query", "query"},
|
||||
{"text/x-regex", "regex"},
|
||||
{"text/x-sql", "sql"},
|
||||
{"text/x-toml", "toml"},
|
||||
{"text/x-yaml", "yaml"},
|
||||
{"text/x-man", "man"},
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -23,13 +23,15 @@ struct CompletionItem {
|
||||
};
|
||||
|
||||
struct CompletionSession {
|
||||
struct Editor *editor;
|
||||
std::shared_mutex mtx;
|
||||
bool active = false;
|
||||
Coord hook;
|
||||
std::optional<std::string> prefix;
|
||||
uint8_t select = 0;
|
||||
uint32_t select = 0;
|
||||
uint32_t scroll = 0;
|
||||
std::vector<CompletionItem> items;
|
||||
std::vector<uint8_t> visible;
|
||||
std::vector<uint32_t> visible;
|
||||
bool complete = true;
|
||||
std::optional<char> trigger_char;
|
||||
uint8_t trigger = 0;
|
||||
@@ -39,7 +41,14 @@ struct CompletionSession {
|
||||
std::atomic<bool> hover_dirty = false;
|
||||
int version;
|
||||
|
||||
CompletionSession() : box(this) {}
|
||||
CompletionSession(Editor *editor) : editor(editor), box(this) {}
|
||||
|
||||
void resolve_doc();
|
||||
void accept();
|
||||
void next();
|
||||
void prev();
|
||||
void choose(uint8_t index);
|
||||
void handle(KeyEvent event);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,158 +1,176 @@
|
||||
#ifndef EDITOR_H
|
||||
#define EDITOR_H
|
||||
|
||||
#include "editor/completions.h"
|
||||
#include "editor/indents.h"
|
||||
#include "extentions/diagnostics.h"
|
||||
#include "extentions/hover.h"
|
||||
#include "io/knot.h"
|
||||
#include "io/sysio.h"
|
||||
#include "syntax/extras.h"
|
||||
#include "syntax/parser.h"
|
||||
#include "ui/completionbox.h"
|
||||
#include "ui/diagnostics.h"
|
||||
#include "ui/hover.h"
|
||||
#include "utils/utils.h"
|
||||
#include "windows/decl.h"
|
||||
|
||||
#define CHAR 0
|
||||
#define WORD 1
|
||||
#define LINE 2
|
||||
|
||||
#define EXTRA_META 4
|
||||
#define EXTRA_META 2
|
||||
#define INDENT_WIDTH 2
|
||||
|
||||
// autocomplete lua// Bracket closing / tab on enter
|
||||
|
||||
struct Editor {
|
||||
std::string filename;
|
||||
std::string uri;
|
||||
Knot *root;
|
||||
std::shared_mutex knot_mtx;
|
||||
Coord cursor;
|
||||
uint32_t cursor_preffered;
|
||||
Coord selection;
|
||||
bool selection_active;
|
||||
int selection_type;
|
||||
Coord position;
|
||||
Coord size;
|
||||
Coord scroll;
|
||||
Language lang;
|
||||
uint32_t hooks[94];
|
||||
bool jumper_set;
|
||||
std::shared_mutex v_mtx;
|
||||
std::vector<VWarn> warnings;
|
||||
bool warnings_dirty;
|
||||
VAI ai;
|
||||
struct Editor : Window {
|
||||
std::string filename = "";
|
||||
std::string uri = "";
|
||||
Knot *root = nullptr;
|
||||
Coord cursor = {0, 0};
|
||||
uint32_t cursor_preffered = 0;
|
||||
Coord selection = {0, 0};
|
||||
bool selection_active = false;
|
||||
bool unix_eol = true;
|
||||
int selection_type = 0;
|
||||
Coord size = {0, 0};
|
||||
Coord scroll = {0, 0};
|
||||
Language lang = {};
|
||||
uint32_t hooks[94] = {0};
|
||||
bool jumper_set = false;
|
||||
std::vector<VWarn> warnings = {};
|
||||
bool warnings_dirty = false;
|
||||
VAI ai = {};
|
||||
std::shared_mutex lsp_mtx;
|
||||
std::shared_ptr<struct LSPInstance> lsp;
|
||||
bool hover_active;
|
||||
HoverBox hover;
|
||||
bool diagnostics_active;
|
||||
DiagnosticBox diagnostics;
|
||||
std::atomic<struct LSPInstance *> lsp = nullptr;
|
||||
HoverBox *hover_popup = init_hover();
|
||||
DiagnosticBox *diagnostic_popup = init_diagnostic();
|
||||
std::atomic<int> lsp_version = 1;
|
||||
CompletionSession completion;
|
||||
IndentationEngine indents;
|
||||
Parser *parser;
|
||||
};
|
||||
IndentationEngine indents = {};
|
||||
Parser *parser = nullptr;
|
||||
ExtraHighlighter extra_hl = {};
|
||||
bool is_css_color = false;
|
||||
|
||||
Editor *new_editor(const char *filename_arg, Coord position, Coord size);
|
||||
void save_file(Editor *editor);
|
||||
void free_editor(Editor *editor);
|
||||
void render_editor(Editor *editor);
|
||||
void cursor_up(Editor *editor, uint32_t number);
|
||||
void cursor_down(Editor *editor, uint32_t number);
|
||||
Coord move_left(Editor *editor, Coord cursor, uint32_t number);
|
||||
Coord move_right(Editor *editor, Coord cursor, uint32_t number);
|
||||
void cursor_left(Editor *editor, uint32_t number);
|
||||
void cursor_right(Editor *editor, uint32_t number);
|
||||
void scroll_up(Editor *editor, int32_t number);
|
||||
void scroll_down(Editor *editor, uint32_t number);
|
||||
void ensure_cursor(Editor *editor);
|
||||
void ensure_scroll(Editor *editor);
|
||||
void handle_editor_event(Editor *editor, KeyEvent event);
|
||||
void edit_erase(Editor *editor, Coord pos, int64_t len);
|
||||
void edit_insert(Editor *editor, Coord pos, char *data, uint32_t len);
|
||||
void edit_replace(Editor *editor, Coord start, Coord end, const char *text,
|
||||
uint32_t len);
|
||||
Coord editor_hit_test(Editor *editor, uint32_t x, uint32_t y);
|
||||
char *get_selection(Editor *editor, uint32_t *out_len, Coord *out_start);
|
||||
void editor_worker(Editor *editor);
|
||||
void move_line_down(Editor *editor);
|
||||
void move_line_up(Editor *editor);
|
||||
void word_boundaries(Editor *editor, Coord coord, uint32_t *prev_col,
|
||||
uint32_t *next_col, uint32_t *prev_clusters,
|
||||
uint32_t *next_clusters);
|
||||
void word_boundaries_exclusive(Editor *editor, Coord coord, uint32_t *prev_col,
|
||||
uint32_t *next_col);
|
||||
void editor_lsp_handle(Editor *editor, json msg);
|
||||
void apply_lsp_edits(Editor *editor, std::vector<TextEdit> edits, bool move);
|
||||
void completion_resolve_doc(Editor *editor);
|
||||
void complete_accept(Editor *editor);
|
||||
void complete_next(Editor *editor);
|
||||
void complete_prev(Editor *editor);
|
||||
void complete_select(Editor *editor, uint8_t index);
|
||||
void handle_completion(Editor *editor, KeyEvent event);
|
||||
Editor(const char *filename_arg, uint8_t eol);
|
||||
~Editor();
|
||||
|
||||
inline void apply_hook_insertion(Editor *editor, uint32_t line, uint32_t rows) {
|
||||
for (auto &hook : editor->hooks)
|
||||
if (hook > line)
|
||||
hook += rows;
|
||||
}
|
||||
void render(std::vector<ScreenCell> &buffer, Coord size, Coord pos) override;
|
||||
void handle_event(KeyEvent event) override;
|
||||
void handle_click(KeyEvent event, Coord size) override;
|
||||
void handle_command(std::string &command) override;
|
||||
void work() override;
|
||||
std::array<std::string, 5> bar_info() override { return {}; };
|
||||
|
||||
inline void apply_hook_deletion(Editor *editor, uint32_t removal_start,
|
||||
uint32_t removal_end) {
|
||||
for (auto &hook : editor->hooks)
|
||||
if (hook > removal_start)
|
||||
hook -= removal_end - removal_start + 1;
|
||||
}
|
||||
void save();
|
||||
void cursor_up(uint32_t number);
|
||||
void cursor_down(uint32_t number);
|
||||
void cursor_left(uint32_t number);
|
||||
void cursor_right(uint32_t number);
|
||||
void move_line_down();
|
||||
void move_line_up();
|
||||
|
||||
inline static void utf8_normalize_edit(Editor *editor, TextEdit *edit) {
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
if (edit->start.row > editor->root->line_count) {
|
||||
edit->start.row = editor->root->line_count;
|
||||
edit->start.col = UINT32_MAX;
|
||||
}
|
||||
if (edit->end.row > editor->root->line_count) {
|
||||
edit->end.row = editor->root->line_count;
|
||||
edit->end.col = UINT32_MAX;
|
||||
}
|
||||
LineIterator *it = begin_l_iter(editor->root, edit->start.row);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t len;
|
||||
char *line = next_line(it, &len);
|
||||
if (!line) {
|
||||
void scroll_up(uint32_t number);
|
||||
void scroll_down(uint32_t number);
|
||||
void ensure_cursor();
|
||||
void ensure_scroll();
|
||||
|
||||
void edit_erase(Coord pos, int64_t len);
|
||||
void edit_insert(Coord pos, char *data, uint32_t len);
|
||||
void edit_replace(Coord start, Coord end, const char *text, uint32_t len);
|
||||
|
||||
Coord click_coord(uint32_t x, uint32_t y);
|
||||
|
||||
char *get_selection(uint32_t *out_len, Coord *out_start);
|
||||
void selection_bounds(Coord *out_start, Coord *out_end);
|
||||
|
||||
void insert_str(char *c, uint32_t len);
|
||||
void insert_char(char c);
|
||||
void normal_mode();
|
||||
void backspace_edit();
|
||||
void delete_prev_word();
|
||||
void delete_next_word();
|
||||
void clear_hooks_at_line(uint32_t line);
|
||||
void cursor_prev_word();
|
||||
void cursor_next_word();
|
||||
void select_all();
|
||||
void fetch_lsp_hover();
|
||||
void indent_current_line();
|
||||
void dedent_current_line();
|
||||
void indent_selection();
|
||||
void dedent_selection();
|
||||
void paste();
|
||||
void copy();
|
||||
void cut();
|
||||
|
||||
void lsp_handle(json msg);
|
||||
void apply_lsp_edits(std::vector<TextEdit> edits, bool move);
|
||||
|
||||
Coord move_left(Coord cursor, uint32_t number);
|
||||
Coord move_right(Coord cursor, uint32_t number);
|
||||
|
||||
void word_boundaries(Coord coord, uint32_t *prev_col, uint32_t *next_col,
|
||||
uint32_t *prev_clusters, uint32_t *next_clusters);
|
||||
void word_boundaries_exclusive(Coord coord, uint32_t *prev_col,
|
||||
uint32_t *next_col);
|
||||
|
||||
void utf8_normalize_edit(TextEdit *edit) {
|
||||
if (edit->start.row > this->root->line_count) {
|
||||
edit->start.row = this->root->line_count;
|
||||
edit->start.col = UINT32_MAX;
|
||||
}
|
||||
if (edit->end.row > this->root->line_count) {
|
||||
edit->end.row = this->root->line_count;
|
||||
edit->end.col = UINT32_MAX;
|
||||
}
|
||||
LineIterator *it = begin_l_iter(this->root, edit->start.row);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t len;
|
||||
char *line = next_line(it, &len);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
if (edit->start.col < len)
|
||||
edit->start.col = utf16_offset_to_utf8(line, len, edit->start.col);
|
||||
else
|
||||
edit->start.col = len;
|
||||
if (edit->end.row == edit->start.row) {
|
||||
if (edit->end.col < len)
|
||||
edit->end.col = utf16_offset_to_utf8(line, len, edit->end.col);
|
||||
else
|
||||
edit->end.col = len;
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
if (edit->start.col < len)
|
||||
edit->start.col = utf16_offset_to_utf8(line, edit->start.col);
|
||||
else
|
||||
edit->start.col = len;
|
||||
if (edit->end.row == edit->start.row) {
|
||||
it = begin_l_iter(this->root, edit->end.row);
|
||||
if (!it)
|
||||
return;
|
||||
line = next_line(it, &len);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
if (edit->end.col < len)
|
||||
edit->end.col = utf16_offset_to_utf8(line, edit->end.col);
|
||||
edit->end.col = utf16_offset_to_utf8(line, len, edit->end.col);
|
||||
else
|
||||
edit->end.col = len;
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
it = begin_l_iter(editor->root, edit->end.row);
|
||||
if (!it)
|
||||
return;
|
||||
line = next_line(it, &len);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
|
||||
inline void apply_hook_insertion(uint32_t line, uint32_t rows) {
|
||||
for (auto &hook : this->hooks)
|
||||
if (hook > line)
|
||||
hook += rows;
|
||||
}
|
||||
if (edit->end.col < len)
|
||||
edit->end.col = utf16_offset_to_utf8(line, edit->end.col);
|
||||
else
|
||||
edit->end.col = len;
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
}
|
||||
|
||||
inline void apply_hook_deletion(uint32_t removal_start,
|
||||
uint32_t removal_end) {
|
||||
for (auto &hook : this->hooks)
|
||||
if (hook > removal_start)
|
||||
hook -= removal_end - removal_start + 1;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
6
include/editor/helpers.h
Normal file
6
include/editor/helpers.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef EDITOR_HELPERS_H
|
||||
#define EDITOR_HELPERS_H
|
||||
|
||||
#include "editor/editor.h"
|
||||
|
||||
#endif
|
||||
@@ -112,12 +112,18 @@ struct IndentationEngine {
|
||||
uint32_t set_indent(uint32_t row, int64_t indent_level);
|
||||
uint32_t indent_line(uint32_t row);
|
||||
uint32_t dedent_line(uint32_t row);
|
||||
void indent_block(uint32_t start_row, uint32_t end_row, int delta);
|
||||
void indent_block(uint32_t start, uint32_t end);
|
||||
void dedent_block(uint32_t start, uint32_t end);
|
||||
// fixes a autocomplete block's indentation
|
||||
char *block_to_asis(Coord cursor, std::string source, uint32_t *out_len);
|
||||
|
||||
private:
|
||||
const std::vector<std::string> *start_end = nullptr;
|
||||
const std::vector<std::string> *start_start = nullptr;
|
||||
const std::vector<std::string> *end_full = nullptr;
|
||||
const std::vector<std::string> *end_start = nullptr;
|
||||
|
||||
// TODO: Ignore comments/strings too
|
||||
// returns the indent level of the line itself or of the previous non-empty
|
||||
uint32_t indent_expected(uint32_t row);
|
||||
|
||||
22
include/extentions/diagnostics.h
Normal file
22
include/extentions/diagnostics.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef EXTENTION_DIAGNOSTICS_H
|
||||
#define EXTENTION_DIAGNOSTICS_H
|
||||
|
||||
#include "editor/decl.h"
|
||||
#include "io/sysio.h"
|
||||
#include "pch.h"
|
||||
#include "utils/utils.h"
|
||||
#include "windows/decl.h"
|
||||
|
||||
struct DiagnosticBox : Popup {
|
||||
std::vector<VWarn> warnings;
|
||||
|
||||
DiagnosticBox() { this->hidden = true; }
|
||||
void clear() { this->warnings.clear(); }
|
||||
void render(std::vector<ScreenCell> &buffer, Coord size, Coord pos) override;
|
||||
void handle_click(KeyEvent, Coord) override { this->hidden = true; };
|
||||
~DiagnosticBox() {};
|
||||
};
|
||||
|
||||
DiagnosticBox *init_diagnostic();
|
||||
|
||||
#endif
|
||||
37
include/extentions/hover.h
Normal file
37
include/extentions/hover.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef EXTENTION_HOVER_H
|
||||
#define EXTENTION_HOVER_H
|
||||
|
||||
#include "io/sysio.h"
|
||||
#include "pch.h"
|
||||
#include "utils/utils.h"
|
||||
#include "windows/decl.h"
|
||||
|
||||
struct HoverBox : Popup {
|
||||
std::string text;
|
||||
std::atomic<bool> is_markup;
|
||||
uint32_t scroll_;
|
||||
bool scroll_dirty;
|
||||
|
||||
HoverBox() : scroll_(0) { this->hidden = true; }
|
||||
void clear() {
|
||||
this->text = "";
|
||||
this->hidden = true;
|
||||
this->is_markup = false;
|
||||
this->scroll_ = 0;
|
||||
this->scroll_dirty = true;
|
||||
}
|
||||
void scroll(int32_t number);
|
||||
void render(std::vector<ScreenCell> &buffer, Coord size, Coord pos) override;
|
||||
void handle_click(KeyEvent ev, Coord) override {
|
||||
if (ev.mouse_button == SCROLL_BTN && ev.mouse_state == SCROLL) {
|
||||
this->scroll(ev.mouse_direction == SCROLL_UP ? -1 : 1);
|
||||
return;
|
||||
}
|
||||
this->hidden = true;
|
||||
};
|
||||
~HoverBox() {};
|
||||
};
|
||||
|
||||
HoverBox *init_hover();
|
||||
|
||||
#endif
|
||||
@@ -115,8 +115,8 @@ LineIterator *begin_l_iter(Knot *root, uint32_t start_line);
|
||||
// Each subsequent call returns the next line as a null terminated string
|
||||
// `it` is the iterator returned from begin_l_iter
|
||||
// After getting the necessary lines free the iterator (no need to go upto
|
||||
// the end) returns null if there are no more lines All return strings
|
||||
// `must` be freed by the caller
|
||||
// the end) returns null if there are no more lines
|
||||
// The string must not be freed
|
||||
char *next_line(LineIterator *it, uint32_t *out_len);
|
||||
|
||||
// Returns the previous line as a null terminated string
|
||||
|
||||
@@ -96,20 +96,19 @@ inline bool is_empty_cell(const ScreenCell &c) {
|
||||
return c.utf8.empty() || c.utf8 == " " || c.utf8 == "\x1b";
|
||||
}
|
||||
|
||||
namespace io {
|
||||
extern std::vector<ScreenCell> new_screen;
|
||||
extern uint32_t rows, cols;
|
||||
extern bool show_cursor;
|
||||
extern std::vector<ScreenCell> old_screen;
|
||||
extern termios orig_termios;
|
||||
} // namespace io
|
||||
|
||||
Coord start_screen();
|
||||
void end_screen();
|
||||
void update(uint32_t row, uint32_t col, std::string utf8, uint32_t fg,
|
||||
uint32_t bg, uint8_t flags);
|
||||
void update(uint32_t row, uint32_t col, const char *utf8, uint32_t fg,
|
||||
uint32_t bg, uint8_t flags);
|
||||
void update(uint32_t row, uint32_t col, std::string utf8, uint32_t fg,
|
||||
uint32_t bg, uint8_t flags, uint32_t ul_color);
|
||||
void update(uint32_t row, uint32_t col, const char *utf8, uint32_t fg,
|
||||
uint32_t bg, uint8_t flags, uint32_t ul_color);
|
||||
void set_cursor(uint8_t row, uint8_t col, uint32_t type,
|
||||
bool show_cursor_param);
|
||||
void render();
|
||||
Coord get_size();
|
||||
void io_render();
|
||||
|
||||
KeyEvent read_key();
|
||||
|
||||
|
||||
@@ -2,57 +2,20 @@
|
||||
#define LSP_H
|
||||
|
||||
#include "editor/editor.h"
|
||||
#include "main.h"
|
||||
#include "pch.h"
|
||||
#include "utils/utils.h"
|
||||
#include <cstdint>
|
||||
#include <sys/types.h>
|
||||
|
||||
struct LSP {
|
||||
const char *command;
|
||||
std::vector<const char *> args;
|
||||
};
|
||||
#define LSP_TIMEOUT_START 3000
|
||||
#define LSP_TIMEOUT_QUIT_NORMAL 300
|
||||
#define LSP_TIMEOUT_QUIT_FORCE 80
|
||||
|
||||
struct LSPPending {
|
||||
std::string method;
|
||||
Editor *editor = nullptr;
|
||||
void lsp_worker();
|
||||
|
||||
std::function<void(Editor *, std::string, json)> callback;
|
||||
};
|
||||
|
||||
struct LSPOpenRequest {
|
||||
Language language;
|
||||
Editor *editor;
|
||||
};
|
||||
|
||||
struct LSPInstance {
|
||||
std::shared_mutex mtx;
|
||||
const LSP *lsp;
|
||||
std::string root_dir;
|
||||
int pid{-1};
|
||||
int stdin_fd{-1};
|
||||
int stdout_fd{-1};
|
||||
std::atomic<bool> initialized = false;
|
||||
std::atomic<bool> exited = false;
|
||||
bool incremental_sync = false;
|
||||
bool allow_hover = false;
|
||||
bool allow_completion = false;
|
||||
bool allow_resolve = false;
|
||||
bool allow_formatting = false;
|
||||
bool allow_formatting_on_type = false;
|
||||
std::vector<char> format_chars;
|
||||
std::vector<char> trigger_chars;
|
||||
std::vector<char> end_chars;
|
||||
uint32_t last_id = 0;
|
||||
Queue<json> inbox;
|
||||
Queue<json> outbox;
|
||||
Queue<std::pair<Language, Editor *>> open_queue;
|
||||
std::unordered_map<uint32_t, LSPPending *> pending;
|
||||
std::vector<Editor *> editors;
|
||||
};
|
||||
|
||||
extern std::shared_mutex active_lsps_mtx;
|
||||
extern std::unordered_map<uint8_t, std::shared_ptr<LSPInstance>> active_lsps;
|
||||
extern Queue<LSPOpenRequest> lsp_open_queue;
|
||||
|
||||
static json client_capabilities = {
|
||||
static const json client_capabilities = {
|
||||
{"general", {{"positionEncodings", {"utf-16"}}}},
|
||||
{"textDocument",
|
||||
{{"publishDiagnostics", {{"relatedInformation", true}}},
|
||||
{"hover", {{"contentFormat", {"markdown", "plaintext"}}}},
|
||||
@@ -75,19 +38,415 @@ static json client_capabilities = {
|
||||
{"contextSupport", true},
|
||||
{"insertTextMode", 1}}}}}};
|
||||
|
||||
void lsp_send(std::shared_ptr<LSPInstance> lsp, json message,
|
||||
LSPPending *pending);
|
||||
void lsp_worker();
|
||||
struct LSPMessage {
|
||||
Editor *editor = nullptr;
|
||||
json message;
|
||||
std::function<void(const LSPMessage &)> callback;
|
||||
};
|
||||
|
||||
std::shared_ptr<LSPInstance> get_or_init_lsp(uint8_t lsp_id);
|
||||
void clean_lsp(std::shared_ptr<LSPInstance> lsp, uint8_t lsp_id);
|
||||
void close_lsp(uint8_t lsp_id);
|
||||
namespace lsp {
|
||||
extern std::mutex lsp_mutex;
|
||||
extern std::unordered_map<std::string, std::unique_ptr<LSPInstance>>
|
||||
active_lsps;
|
||||
extern Queue<std::string> need_opening;
|
||||
extern std::unordered_set<std::string> opened;
|
||||
extern std::vector<Editor *> new_editors;
|
||||
extern Queue<std::unique_ptr<LSPMessage>> response_queue;
|
||||
} // namespace lsp
|
||||
|
||||
void open_editor(std::shared_ptr<LSPInstance> lsp,
|
||||
std::pair<Language, Editor *> entry);
|
||||
void request_add_to_lsp(Language language, Editor *editor);
|
||||
void add_to_lsp(Language language, Editor *editor);
|
||||
void remove_from_lsp(Editor *editor);
|
||||
void lsp_handle(std::shared_ptr<LSPInstance> lsp, json message);
|
||||
struct LSPInstance {
|
||||
const LSP *lsp_info;
|
||||
std::string root_dir;
|
||||
int pid{-1};
|
||||
int stdin_fd{-1};
|
||||
int stdout_fd{-1};
|
||||
std::atomic<bool> initialized = false;
|
||||
std::atomic<bool> exited = false;
|
||||
bool incremental_sync = false;
|
||||
bool allow_hover = false;
|
||||
bool allow_completion = false;
|
||||
bool allow_resolve = false;
|
||||
bool allow_formatting = false;
|
||||
bool allow_formatting_on_type = false;
|
||||
bool is_utf8 = false;
|
||||
std::vector<char> format_chars;
|
||||
std::vector<char> trigger_chars;
|
||||
std::vector<char> end_chars;
|
||||
uint32_t last_id = 0;
|
||||
Queue<json> inbox;
|
||||
Queue<json> outbox;
|
||||
std::unordered_map<uint32_t, std::unique_ptr<LSPMessage>> pending;
|
||||
std::vector<Editor *> editors;
|
||||
|
||||
LSPInstance(std::string lsp_id) {
|
||||
lsp_info = &lsps[lsp_id];
|
||||
if (!init_process()) {
|
||||
exited = true;
|
||||
return;
|
||||
}
|
||||
json initialize_message = {
|
||||
{"jsonrpc", "2.0"},
|
||||
{"id", ++last_id},
|
||||
{"method", "initialize"},
|
||||
{"params",
|
||||
{{"processId", getpid()},
|
||||
{"rootUri", "file://" + percent_encode(path_abs("."))},
|
||||
{"capabilities", client_capabilities}}}};
|
||||
send_raw(initialize_message);
|
||||
pollfd pfd{stdout_fd, POLLIN, 0};
|
||||
uint32_t waited = 0;
|
||||
while (waited < LSP_TIMEOUT_START) {
|
||||
poll(&pfd, 1, 50);
|
||||
if (pfd.revents & POLLIN)
|
||||
break;
|
||||
if (!running)
|
||||
return;
|
||||
waited += 50;
|
||||
}
|
||||
if (!(pfd.revents & POLLIN)) {
|
||||
exited = true;
|
||||
return;
|
||||
}
|
||||
json response = *read_lsp_message();
|
||||
if (response.contains("result") &&
|
||||
response["result"].contains("capabilities")) {
|
||||
auto &caps = response["result"]["capabilities"];
|
||||
// if (caps.contains("positionEncoding")) {
|
||||
// std::string s = caps["positionEncoding"].get<std::string>();
|
||||
// if (s == "utf-8")
|
||||
// is_utf8 = true;
|
||||
// log("Lsp name: %s, supports: %s", lsp->command.c_str(),
|
||||
// s.c_str());
|
||||
// }
|
||||
if (caps.contains("textDocumentSync")) {
|
||||
auto &sync = caps["textDocumentSync"];
|
||||
if (sync.is_number()) {
|
||||
int change_type = sync.get<int>();
|
||||
incremental_sync = (change_type == 2);
|
||||
} else if (sync.is_object() && sync.contains("change")) {
|
||||
int change_type = sync["change"].get<int>();
|
||||
incremental_sync = (change_type == 2);
|
||||
}
|
||||
}
|
||||
allow_formatting = caps.value("documentFormattingProvider", false);
|
||||
if (caps.contains("documentOnTypeFormattingProvider")) {
|
||||
auto &fmt = caps["documentOnTypeFormattingProvider"];
|
||||
if (fmt.is_object()) {
|
||||
if (fmt.contains("firstTriggerCharacter")) {
|
||||
std::string s = fmt["firstTriggerCharacter"].get<std::string>();
|
||||
if (s.size() == 1)
|
||||
format_chars.push_back(s[0]);
|
||||
}
|
||||
if (fmt.contains("moreTriggerCharacter")) {
|
||||
for (auto &c : fmt["moreTriggerCharacter"]) {
|
||||
std::string s = c.get<std::string>();
|
||||
if (s.size() == 1)
|
||||
format_chars.push_back(s[0]);
|
||||
}
|
||||
}
|
||||
allow_formatting_on_type = true;
|
||||
} else if (fmt.is_boolean()) {
|
||||
allow_formatting_on_type = fmt.get<bool>();
|
||||
}
|
||||
}
|
||||
if (caps.contains("hoverProvider")) {
|
||||
auto &hover = caps["hoverProvider"];
|
||||
allow_hover =
|
||||
hover.is_boolean() ? hover.get<bool>() : hover.is_object();
|
||||
} else {
|
||||
allow_hover = false;
|
||||
}
|
||||
if (caps.contains("completionProvider")) {
|
||||
allow_completion = true;
|
||||
if (caps["completionProvider"].contains("resolveProvider"))
|
||||
allow_resolve =
|
||||
caps["completionProvider"]["resolveProvider"].get<bool>();
|
||||
if (caps["completionProvider"].contains("triggerCharacters")) {
|
||||
auto &chars = caps["completionProvider"]["triggerCharacters"];
|
||||
if (chars.is_array()) {
|
||||
for (auto &c : chars) {
|
||||
std::string str = c.get<std::string>();
|
||||
if (str.size() != 1)
|
||||
continue;
|
||||
trigger_chars.push_back(str[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (caps["completionProvider"].contains("allCommitCharacters")) {
|
||||
auto &chars = caps["completionProvider"]["allCommitCharacters"];
|
||||
if (chars.is_array()) {
|
||||
for (auto &c : chars) {
|
||||
std::string str = c.get<std::string>();
|
||||
if (str.size() != 1)
|
||||
continue;
|
||||
end_chars.push_back(str[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
initialized = true;
|
||||
json initialized_message = {{"jsonrpc", "2.0"},
|
||||
{"method", "initialized"},
|
||||
{"params", json::object()}};
|
||||
send_raw(initialized_message);
|
||||
}
|
||||
~LSPInstance() {
|
||||
uint32_t timeout =
|
||||
running ? LSP_TIMEOUT_QUIT_NORMAL : LSP_TIMEOUT_QUIT_FORCE;
|
||||
for (auto &ed : editors)
|
||||
ed->lsp.store(nullptr);
|
||||
initialized = false;
|
||||
exited = true;
|
||||
if (pid == -1)
|
||||
return;
|
||||
json shutdown = {
|
||||
{"jsonrpc", "2.0"}, {"id", ++last_id}, {"method", "shutdown"}};
|
||||
send_raw(shutdown);
|
||||
pollfd pfd{stdout_fd, POLLIN, 0};
|
||||
poll(&pfd, 1, timeout);
|
||||
if (pfd.revents & POLLIN) {
|
||||
json exit_msg = {{"jsonrpc", "2.0"}, {"method", "exit"}};
|
||||
send_raw(exit_msg);
|
||||
int waited = 0;
|
||||
while (waited < timeout) {
|
||||
int status;
|
||||
pid_t res = waitpid(pid, &status, WNOHANG);
|
||||
if (res == pid)
|
||||
break;
|
||||
std::this_thread::sleep_for(10ms);
|
||||
waited += 10;
|
||||
}
|
||||
}
|
||||
close(stdin_fd);
|
||||
close(stdout_fd);
|
||||
if (kill(pid, 0) == 0) {
|
||||
kill(pid, SIGKILL);
|
||||
waitpid(pid, nullptr, 0);
|
||||
}
|
||||
pid = -1;
|
||||
}
|
||||
bool init_process() {
|
||||
int in_pipe[2];
|
||||
int out_pipe[2];
|
||||
if (pipe(in_pipe) == -1 || pipe(out_pipe) == -1) {
|
||||
perror("pipe");
|
||||
return false;
|
||||
}
|
||||
pid_t pid_tmp = fork();
|
||||
if (pid_tmp == -1) {
|
||||
perror("fork");
|
||||
return false;
|
||||
}
|
||||
if (pid_tmp == 0) {
|
||||
dup2(in_pipe[0], STDIN_FILENO);
|
||||
dup2(out_pipe[1], STDOUT_FILENO);
|
||||
int devnull = open("/dev/null", O_WRONLY);
|
||||
if (devnull >= 0) {
|
||||
dup2(devnull, STDERR_FILENO);
|
||||
close(devnull);
|
||||
}
|
||||
close(in_pipe[0]);
|
||||
close(in_pipe[1]);
|
||||
close(out_pipe[0]);
|
||||
close(out_pipe[1]);
|
||||
std::vector<char *> argv;
|
||||
argv.push_back(const_cast<char *>(lsp_info->command.c_str()));
|
||||
for (auto &arg : lsp_info->args)
|
||||
argv.push_back(const_cast<char *>(arg.c_str()));
|
||||
argv.push_back(nullptr);
|
||||
execvp(lsp_info->command.c_str(), argv.data());
|
||||
perror("execvp");
|
||||
_exit(127);
|
||||
}
|
||||
pid = pid_tmp;
|
||||
stdin_fd = in_pipe[1];
|
||||
stdout_fd = out_pipe[0];
|
||||
close(in_pipe[0]);
|
||||
close(out_pipe[1]);
|
||||
return true;
|
||||
}
|
||||
void add(Editor *ed) {
|
||||
editors.push_back(ed);
|
||||
ed->lsp.store(this);
|
||||
char *buf = read(ed->root, 0, ed->root->char_count);
|
||||
std::string text(buf);
|
||||
free(buf);
|
||||
json message = {{"jsonrpc", "2.0"},
|
||||
{"method", "textDocument/didOpen"},
|
||||
{"params",
|
||||
{{"textDocument",
|
||||
{{"uri", ed->uri},
|
||||
{"languageId", ed->lang.name},
|
||||
{"version", 1},
|
||||
{"text", text}}}}}};
|
||||
send_raw(message);
|
||||
}
|
||||
void remove(Editor *ed) {
|
||||
std::unique_lock lock(lsp::lsp_mutex);
|
||||
editors.erase(std::remove(editors.begin(), editors.end(), ed),
|
||||
editors.end());
|
||||
lock.unlock();
|
||||
auto message = std::make_unique<LSPMessage>();
|
||||
message->message = {{"method", "textDocument/didClose"},
|
||||
{"params", {{"textDocument", {{"uri", ed->uri}}}}}};
|
||||
send(std::move(message));
|
||||
}
|
||||
void work() {
|
||||
if (exited)
|
||||
return;
|
||||
int status;
|
||||
pid_t res = waitpid(pid, &status, WNOHANG);
|
||||
if (res == pid) {
|
||||
exited = true;
|
||||
pid = -1;
|
||||
return;
|
||||
}
|
||||
while (!outbox.empty()) {
|
||||
json message = outbox.front();
|
||||
std::string m = message.value("method", "");
|
||||
outbox.pop();
|
||||
send_raw(message);
|
||||
}
|
||||
pollfd pfd{stdout_fd, POLLIN | POLLHUP | POLLERR, 0};
|
||||
int r = poll(&pfd, 1, 0);
|
||||
if (r > 0 && pfd.revents & (POLLHUP | POLLERR)) {
|
||||
exited = true;
|
||||
pid = -1;
|
||||
return;
|
||||
}
|
||||
while ((r = poll(&pfd, 1, 0)) > 0) {
|
||||
if (pfd.revents & (POLLHUP | POLLERR)) {
|
||||
exited = true;
|
||||
pid = -1;
|
||||
return;
|
||||
}
|
||||
auto msg = read_lsp_message();
|
||||
if (!msg)
|
||||
break;
|
||||
if (msg->contains("id")) {
|
||||
uint32_t id = msg->at("id").get<uint32_t>();
|
||||
auto it = pending.find(id);
|
||||
if (it != pending.end()) {
|
||||
if (it->second->editor) {
|
||||
it->second->message = *msg;
|
||||
lsp::response_queue.push(std::move(it->second));
|
||||
} else {
|
||||
auto message = *std::move(it->second);
|
||||
message.message = *msg;
|
||||
message.callback(message);
|
||||
}
|
||||
pending.erase(it);
|
||||
}
|
||||
} else if (msg->contains("method")) {
|
||||
std::string uri;
|
||||
if (msg->contains("params")) {
|
||||
auto &p = (*msg)["params"];
|
||||
if (p.contains("textDocument") && p["textDocument"].contains("uri"))
|
||||
uri = p["textDocument"]["uri"].get<std::string>();
|
||||
else if (p.contains("uri"))
|
||||
uri = p["uri"].get<std::string>();
|
||||
}
|
||||
Editor *ed = resolve_uri(uri);
|
||||
auto response = std::make_unique<LSPMessage>();
|
||||
response->editor = ed;
|
||||
response->message = *msg;
|
||||
response->callback = editor_handle_wrapper;
|
||||
if (ed)
|
||||
lsp::response_queue.push(std::move(response));
|
||||
else
|
||||
lsp_handle(*msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
inline static void editor_handle_wrapper(const LSPMessage &message) {
|
||||
message.editor->lsp_handle(message.message);
|
||||
}
|
||||
inline void send_raw(const json &msg) {
|
||||
std::string payload = msg.dump();
|
||||
std::string header =
|
||||
"Content-Length: " + std::to_string(payload.size()) + "\r\n\r\n";
|
||||
std::string out = header + payload;
|
||||
const char *ptr = out.data();
|
||||
size_t remaining = out.size();
|
||||
while (remaining > 0) {
|
||||
ssize_t n = write(stdin_fd, ptr, remaining);
|
||||
if (n <= 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
ptr += n;
|
||||
remaining -= n;
|
||||
}
|
||||
};
|
||||
inline std::optional<json> read_lsp_message() {
|
||||
std::string header;
|
||||
char c;
|
||||
while (true) {
|
||||
ssize_t n = read(stdout_fd, &c, 1);
|
||||
if (n <= 0)
|
||||
return std::nullopt;
|
||||
header.push_back(c);
|
||||
if (header.size() >= 4 && header.substr(header.size() - 4) == "\r\n\r\n")
|
||||
break;
|
||||
}
|
||||
size_t pos = header.find("Content-Length:");
|
||||
if (pos == std::string::npos)
|
||||
return std::nullopt;
|
||||
pos += strlen("Content-Length:");
|
||||
while (pos < header.size() && std::isspace(header[pos]))
|
||||
pos++;
|
||||
size_t end = pos;
|
||||
while (end < header.size() && std::isdigit(header[end]))
|
||||
end++;
|
||||
size_t len = std::stoul(header.substr(pos, end - pos));
|
||||
std::string body(len, '\0');
|
||||
size_t got = 0;
|
||||
while (got < len) {
|
||||
ssize_t n = read(stdout_fd, &body[got], len - got);
|
||||
if (n <= 0)
|
||||
return std::nullopt;
|
||||
got += n;
|
||||
}
|
||||
return json::parse(body);
|
||||
}
|
||||
inline Editor *resolve_uri(std::string uri) {
|
||||
if (uri.empty())
|
||||
return nullptr;
|
||||
for (auto &editor : editors)
|
||||
if (editor->uri == uri)
|
||||
return editor;
|
||||
return nullptr;
|
||||
}
|
||||
inline void lsp_handle(json &message) {
|
||||
std::string method = message.value("method", "");
|
||||
if (method == "window/showMessage") {
|
||||
if (message.contains("params")) {
|
||||
auto &p = message["params"];
|
||||
if (p.contains("message"))
|
||||
log("%s\n", p["message"].get<std::string>().c_str());
|
||||
}
|
||||
} else if (method == "window/logMessage") {
|
||||
if (message.contains("params")) {
|
||||
auto &p = message["params"];
|
||||
if (p.contains("message"))
|
||||
log("%s\n", p["message"].get<std::string>().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
void send(std::unique_ptr<LSPMessage> message) {
|
||||
if (pid == -1)
|
||||
return;
|
||||
message->message["jsonrpc"] = "2.0";
|
||||
if (message->callback)
|
||||
message->message["id"] = ++last_id;
|
||||
outbox.push(message->message);
|
||||
if (!message->callback)
|
||||
return;
|
||||
std::lock_guard lock(lsp::lsp_mutex);
|
||||
pending[last_id] = std::move(message);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define MAIN_H
|
||||
|
||||
#include "pch.h"
|
||||
#include "ui/bar.h"
|
||||
|
||||
#define NORMAL 0
|
||||
#define INSERT 1
|
||||
@@ -11,7 +12,10 @@
|
||||
|
||||
extern std::atomic<bool> running;
|
||||
extern std::atomic<uint8_t> mode;
|
||||
extern std::vector<struct Editor *> editors;
|
||||
extern uint8_t current_editor;
|
||||
extern fs::path pwd;
|
||||
|
||||
namespace ui {
|
||||
extern Bar bar;
|
||||
} // namespace ui
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,12 @@
|
||||
#define PCRE2_CODE_UNIT_WIDTH 8
|
||||
#define PCRE_WORKSPACE_SIZE 512
|
||||
|
||||
#include <magic.h>
|
||||
#include "mruby.h"
|
||||
#include "mruby/array.h"
|
||||
#include "mruby/compile.h"
|
||||
#include "mruby/hash.h"
|
||||
#include "mruby/irep.h"
|
||||
#include "mruby/string.h"
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <pcre2.h>
|
||||
extern "C" {
|
||||
@@ -45,6 +50,7 @@ extern "C" {
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
52
include/ruby/decl.h
Normal file
52
include/ruby/decl.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef SCRIPTING_DECL_H
|
||||
#define SCRIPTING_DECL_H
|
||||
|
||||
#include "syntax/decl.h"
|
||||
#include "utils/utils.h"
|
||||
#include "windows/decl.h"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
extern std::unordered_map<std::string, std::pair<mrb_value, mrb_value>>
|
||||
custom_highlighters;
|
||||
extern mrb_state *mrb;
|
||||
extern fs::path ruby_config_path;
|
||||
|
||||
struct BarLight {
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
Highlight highlight;
|
||||
};
|
||||
|
||||
struct BarLine {
|
||||
std::string line;
|
||||
std::vector<BarLight> highlights;
|
||||
|
||||
Highlight get_highlight(uint32_t x) {
|
||||
for (auto &hl : highlights) {
|
||||
if (hl.start <= x && x <= hl.end)
|
||||
return hl.highlight;
|
||||
}
|
||||
return {0xFFFFFF, 0, 0};
|
||||
}
|
||||
};
|
||||
|
||||
void setup_ruby_bindings(mrb_state *mrb, RClass *C_module);
|
||||
void ruby_start();
|
||||
void ruby_shutdown();
|
||||
void ruby_copy(const char *text, size_t len);
|
||||
std::string ruby_paste();
|
||||
std::string ruby_file_detect(std::string filename);
|
||||
void load_theme();
|
||||
void load_languages_info();
|
||||
uint8_t read_line_endings();
|
||||
void load_custom_highlighters();
|
||||
bool custom_compare(mrb_value match_block, std::string state1,
|
||||
std::string state2);
|
||||
std::string parse_custom(std::vector<Token> *tokens, mrb_value parser_block,
|
||||
const char *line, uint32_t len, std::string state,
|
||||
uint32_t c_line);
|
||||
BarLine bar_contents(uint8_t mode, uint32_t width, std::string foldername,
|
||||
Window *window);
|
||||
|
||||
#endif
|
||||
500
include/ruby/libcrib.rb
Normal file
500
include/ruby/libcrib.rb
Normal file
@@ -0,0 +1,500 @@
|
||||
def command_exists?(cmd)
|
||||
system("command -v #{cmd} > /dev/null 2>&1")
|
||||
end
|
||||
|
||||
module Clipboard
|
||||
@clip = ""
|
||||
@os = :os_name_placed_here
|
||||
|
||||
class << self
|
||||
def copy(text)
|
||||
if @os == :windows
|
||||
IO.popen("clip", "w") { |f| f.write(text) }
|
||||
elsif @os == :mac
|
||||
IO.popen("pbcopy", "w") { |f| f.write(text) }
|
||||
elsif @os == :linux
|
||||
if ENV["XDG_SESSION_TYPE"]&.downcase == "wayland" || ENV["WAYLAND_DISPLAY"]
|
||||
if command_exists?("wl-copy")
|
||||
IO.popen("wl-copy", "w") { |f| f.write(text) }
|
||||
else
|
||||
osc52_copy(text)
|
||||
end
|
||||
elsif ENV["XDG_SESSION_TYPE"]&.downcase == "x11" || ENV["DISPLAY"]
|
||||
if command_exists?("xsel")
|
||||
IO.popen("xsel --clipboard --input", "w") { |f| f.write(text) }
|
||||
elsif command_exists?("xclip")
|
||||
IO.popen("xclip -selection clipboard", "w") { |f| f.write(text) }
|
||||
else
|
||||
osc52_copy(text)
|
||||
end
|
||||
end
|
||||
end
|
||||
@clip = text
|
||||
end
|
||||
def paste
|
||||
if @os == :windows
|
||||
return `powershell -NoProfile -Command Get-Clipboard`
|
||||
elsif @os == :mac
|
||||
return `pbpaste`
|
||||
elsif @os == :linux
|
||||
if ENV["XDG_SESSION_TYPE"]&.downcase == "wayland" || ENV["WAYLAND_DISPLAY"]
|
||||
if command_exists?("wl-copy")
|
||||
return `wl-paste`
|
||||
end
|
||||
elsif ENV["XDG_SESSION_TYPE"]&.downcase == "x11" || ENV["DISPLAY"]
|
||||
if command_exists?("xsel")
|
||||
return `xsel --clipboard --output`
|
||||
elsif command_exists?("xclip")
|
||||
return `xclip -selection clipboard -o`
|
||||
else
|
||||
return @clip
|
||||
end
|
||||
end
|
||||
end
|
||||
return ""
|
||||
end
|
||||
def osc52_copy(text)
|
||||
encoded = [text].pack("m0")
|
||||
print "\e]52;c;#{encoded}\a"
|
||||
text
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module C
|
||||
@lsp_config = {
|
||||
"clangd" => [
|
||||
"--background-index",
|
||||
"--clang-tidy",
|
||||
"--completion-style=detailed",
|
||||
"--header-insertion=never",
|
||||
"--pch-storage=memory",
|
||||
"--limit-results=50",
|
||||
"--log=error"
|
||||
],
|
||||
"ruby-lsp" => [],
|
||||
"solargraph" => ["stdio"],
|
||||
"bash-language-server" => ["start"],
|
||||
"vscode-css-language-server" => ["--stdio"],
|
||||
"vscode-json-language-server" => ["--stdio"],
|
||||
"fish-lsp" => ["start"],
|
||||
"gopls" => ["serve"],
|
||||
"haskell-language-server" => ["lsp"],
|
||||
"emmet-language-server" => ["--stdio"],
|
||||
"typescript-language-server" => ["--stdio"],
|
||||
"lua-language-server" => [],
|
||||
"pyright-langserver" => ["--stdio"],
|
||||
"rust-analyzer" => [],
|
||||
"intelephense" => ["--stdio"],
|
||||
"marksman" => ["server"],
|
||||
"nginx-language-server" => [],
|
||||
"taplo" => ["lsp", "stdio"],
|
||||
"yaml-language-server" => ["--stdio"],
|
||||
"sqls" => ["serve"],
|
||||
"make-language-server" => [],
|
||||
"sql-language-server" => ["up", "--method", "stdio"]
|
||||
}
|
||||
@languages = {
|
||||
c: {
|
||||
color: 0x555555,
|
||||
symbol: " ",
|
||||
extensions: ["c"],
|
||||
lsp: "clangd"
|
||||
},
|
||||
cpp: {
|
||||
color: 0x00599C,
|
||||
symbol: " ",
|
||||
extensions: ["cpp", "cc", "cxx"],
|
||||
lsp: "clangd"
|
||||
},
|
||||
h: {
|
||||
color: 0xA8B9CC,
|
||||
symbol: " ",
|
||||
extensions: ["h", "hpp"],
|
||||
lsp: "clangd"
|
||||
},
|
||||
css: {
|
||||
color: 0x36a3d9,
|
||||
symbol: " ",
|
||||
extensions: ["css"],
|
||||
lsp: "vscode-css-language-server"
|
||||
},
|
||||
fish: {
|
||||
color: 0x4d5a5e,
|
||||
symbol: " ",
|
||||
extensions: ["fish"],
|
||||
lsp: "fish-lsp"
|
||||
},
|
||||
go: {
|
||||
color: 0x00add8,
|
||||
symbol: " ",
|
||||
extensions: ["go"],
|
||||
lsp: "gopls"
|
||||
},
|
||||
gomod: {
|
||||
color: 0x00add8,
|
||||
symbol: " ",
|
||||
extensions: ["mod"],
|
||||
lsp: "gopls"
|
||||
},
|
||||
haskell: {
|
||||
color: 0xa074c4,
|
||||
symbol: " ",
|
||||
extensions: ["hs", "lhs"],
|
||||
lsp: "haskell-language-server"
|
||||
},
|
||||
html: {
|
||||
color: 0xef8a91,
|
||||
symbol: " ",
|
||||
extensions: ["html", "htm"],
|
||||
lsp: "emmet-language-server"
|
||||
},
|
||||
javascript: {
|
||||
color: 0xf0df8a,
|
||||
symbol: " ",
|
||||
extensions: ["js"],
|
||||
lsp: "typescript-language-server"
|
||||
},
|
||||
typescript: {
|
||||
color: 0x36a3d9,
|
||||
symbol: " ",
|
||||
extensions: ["ts"],
|
||||
lsp: "typescript-language-server"
|
||||
},
|
||||
json: {
|
||||
color: 0xcbcb41,
|
||||
symbol: "{}",
|
||||
extensions: ["json"],
|
||||
lsp: "vscode-json-language-server"
|
||||
},
|
||||
jsonc: {
|
||||
color: 0xcbcb41,
|
||||
symbol: "{}",
|
||||
extensions: ["jsonc"],
|
||||
lsp: "vscode-json-language-server"
|
||||
},
|
||||
erb: {
|
||||
color: 0x6e1516,
|
||||
symbol: " ",
|
||||
extensions: ["erb"],
|
||||
lsp: "emmet-language-server"
|
||||
},
|
||||
lua: {
|
||||
color: 0x36a3d9,
|
||||
symbol: " ",
|
||||
extensions: ["lua"],
|
||||
lsp: "lua-language-server"
|
||||
},
|
||||
python: {
|
||||
color: 0x95e6cb,
|
||||
symbol: " ",
|
||||
extensions: ["py"],
|
||||
lsp: "pyright"
|
||||
},
|
||||
rust: {
|
||||
color: 0xdea584,
|
||||
symbol: " ",
|
||||
extensions: ["rs"],
|
||||
lsp: "rust-analyzer"
|
||||
},
|
||||
php: {
|
||||
color: 0xa074c4,
|
||||
symbol: " ",
|
||||
extensions: ["php"],
|
||||
lsp: "intelephense"
|
||||
},
|
||||
markdown: {
|
||||
color: 0x36a3d9,
|
||||
symbol: " ",
|
||||
extensions: ["md", "markdown"],
|
||||
lsp: "marksman"
|
||||
},
|
||||
nginx: {
|
||||
color: 0x6d8086,
|
||||
symbol: " ",
|
||||
extensions: ["conf"],
|
||||
lsp: "nginx-language-server"
|
||||
},
|
||||
toml: {
|
||||
color: 0x36a3d9,
|
||||
symbol: " ",
|
||||
extensions: ["toml"],
|
||||
lsp: "taplo"
|
||||
},
|
||||
yaml: {
|
||||
color: 0x6d8086,
|
||||
symbol: " ",
|
||||
extensions: ["yml", "yaml"],
|
||||
lsp: "yaml-language-server"
|
||||
},
|
||||
sql: {
|
||||
color: 0xdad8d8,
|
||||
symbol: " ",
|
||||
extensions: ["sql"],
|
||||
lsp: "sqls"
|
||||
},
|
||||
make: {
|
||||
color: 0x4e5c61,
|
||||
symbol: " ",
|
||||
extensions: ["Makefile", "makefile"],
|
||||
lsp: "make-language-server"
|
||||
},
|
||||
gdscript: {
|
||||
color: 0x6d8086,
|
||||
symbol: " ",
|
||||
extensions: ["gd"]
|
||||
},
|
||||
man: {
|
||||
color: 0xdad8d8,
|
||||
symbol: " ",
|
||||
extensions: ["man"]
|
||||
},
|
||||
diff: {
|
||||
color: 0xDD4C35,
|
||||
symbol: " ",
|
||||
extensions: ["diff", "patch"]
|
||||
},
|
||||
gitattributes: {
|
||||
color: 0xF05032,
|
||||
symbol: " ",
|
||||
extensions: ["gitattributes"]
|
||||
},
|
||||
gitignore: {
|
||||
color: 0xF05032,
|
||||
symbol: " ",
|
||||
extensions: ["gitignore"]
|
||||
},
|
||||
regex: {
|
||||
color: 0x9E9E9E,
|
||||
symbol: ".*",
|
||||
extensions: ["regex"]
|
||||
},
|
||||
ini: {
|
||||
color: 0x6d8086,
|
||||
symbol: " ",
|
||||
extensions: ["ini"]
|
||||
},
|
||||
ruby: {
|
||||
color: 0xff8087,
|
||||
symbol: " ",
|
||||
extensions: ["rb"],
|
||||
filenames: ["Gemfile"],
|
||||
lsp: "solargraph"
|
||||
},
|
||||
bash: {
|
||||
color: 0x4d5a5e,
|
||||
symbol: " ",
|
||||
extensions: ["sh"],
|
||||
filenames: ["bash_profile", "bashrc"],
|
||||
lsp: "bash-language-server"
|
||||
},
|
||||
default: {
|
||||
color: 0x6d8086,
|
||||
symbol: " ",
|
||||
extensions: []
|
||||
}
|
||||
}
|
||||
@theme = {
|
||||
:default => { fg: 0xEEEEEE },
|
||||
:shebang => { fg: 0x7DCFFF },
|
||||
:error => { fg: 0xEF5168 },
|
||||
:comment => { fg: 0xAAAAAA, italic: true },
|
||||
:string => { fg: 0xAAD94C },
|
||||
:escape => { fg: 0x7DCFFF },
|
||||
:interpolation => { fg: 0x7DCFFF },
|
||||
:regexp => { fg: 0xD2A6FF },
|
||||
:number => { fg: 0xE6C08A },
|
||||
:true => { fg: 0x7AE93C },
|
||||
:false => { fg: 0xEF5168 },
|
||||
:char => { fg: 0xFFAF70 },
|
||||
:keyword => { fg: 0xFF8F40 },
|
||||
:keywordoperator => { fg: 0xF07178 },
|
||||
:operator => { fg: 0xFFFFFF, italic: true },
|
||||
:function => { fg: 0xFFAF70 },
|
||||
:type => { fg: 0xF07178 },
|
||||
:constant => { fg: 0x7DCFFF },
|
||||
:variableinstance => { fg: 0x95E6CB },
|
||||
:variableglobal => { fg: 0xF07178 },
|
||||
:annotation => { fg: 0x7DCFFF },
|
||||
:directive => { fg: 0xFF8F40 },
|
||||
:label => { fg: 0xD2A6FF },
|
||||
:brace1 => { fg: 0xD2A6FF },
|
||||
:brace2 => { fg: 0xFFAFAF },
|
||||
:brace3 => { fg: 0xFFFF00 },
|
||||
:brace4 => { fg: 0x0FFF0F },
|
||||
:brace5 => { fg: 0xFF0F0F }
|
||||
}
|
||||
@line_endings = :auto_unix
|
||||
@key_handlers = {}
|
||||
@key_binds = {}
|
||||
@highlighters = {}
|
||||
@b_startup = nil
|
||||
@b_shutdown = nil
|
||||
@b_bar = proc do |info|
|
||||
# mode, width, data[5] : strings (any data about the focused window)
|
||||
# puts info.inspect
|
||||
mode_color = 0x82AAFF
|
||||
mode_symbol = " "
|
||||
case info[:mode]
|
||||
when :normal
|
||||
mode_color = 0x82AAFF
|
||||
mode_symbol = " "
|
||||
when :insert
|
||||
mode_color = 0xFF8F40
|
||||
mode_symbol = " "
|
||||
when :select
|
||||
mode_color = 0x9ADE7A
|
||||
mode_symbol = " "
|
||||
when :runner
|
||||
mode_color = 0xFFD700
|
||||
mode_symbol = " "
|
||||
when :jumper
|
||||
mode_color = 0xF29CC3
|
||||
mode_symbol = " "
|
||||
end
|
||||
lang_info = C.languages[:default]
|
||||
filename = ""
|
||||
if info[:data][0] == "editor"
|
||||
lang_info = C.languages[info[:data][2]] if info[:data][2] != ""
|
||||
if lang_info.nil?
|
||||
lang_info = C.languages[:default]
|
||||
end
|
||||
filename = File.basename(info[:data][1]) if info[:data][1] != ""
|
||||
end
|
||||
starting = " #{mode_symbol} #{info[:mode].to_s.upcase} #{lang_info[:symbol]} #{filename}"
|
||||
highlights = []
|
||||
highlights << { fg: 0x0b0e14, bg: mode_color, flags: 1 << 1, start: 0, length: 10 }
|
||||
highlights << { fg: mode_color, bg: 0x33363c, start: 10, length: 1 }
|
||||
highlights << { fg: 0x33363c, bg: 0x24272d, start: 11, length: 1 }
|
||||
highlights << { fg: lang_info[:color], bg: 0x24272d, start: 13, length: 2 }
|
||||
highlights << { fg: 0xced4df, bg: 0x24272d, start: 15, length: filename.length + 1 }
|
||||
highlights << { fg: 0x24272d, bg: 0x000000, start: 15 + filename.length + 1, length: 1 }
|
||||
next {
|
||||
text: starting,
|
||||
highlights: highlights
|
||||
}
|
||||
end
|
||||
@b_copy = proc do |text|
|
||||
Clipboard.copy(text)
|
||||
end
|
||||
@b_paste = proc do
|
||||
next Clipboard.paste
|
||||
end
|
||||
@b_file_detect = proc do |filename|
|
||||
type = :default
|
||||
next type unless File.exist?(filename)
|
||||
first_line = File.open(filename, &:readline).chomp
|
||||
if first_line.start_with?("#!")
|
||||
shebang = first_line[2..].downcase
|
||||
type = case shebang
|
||||
when /bash/, /sh/ then :bash
|
||||
when /fish/ then :fish
|
||||
when /python/ then :python
|
||||
when /ruby/ then :ruby
|
||||
when /lua/ then :lua
|
||||
else :default
|
||||
end
|
||||
next type
|
||||
end
|
||||
next type if :os_name_placed_here != :linux || :os_name_placed_here != :mac
|
||||
next type if !command_exists?("file")
|
||||
mimetype = `file --mime-type -b #{filename}`.chomp
|
||||
type = case mimetype
|
||||
when /shellscript/ then :bash
|
||||
when /ruby/ then :ruby
|
||||
when /diff/ then :diff
|
||||
when /html/ then :html
|
||||
when /python/ then :python
|
||||
when /javascript/ then :javascript
|
||||
when /makefile/ then :makefile
|
||||
when /-c$/ then :c
|
||||
else :default
|
||||
end
|
||||
next type
|
||||
end
|
||||
|
||||
class << self
|
||||
attr_accessor :theme, :lsp_config, :languages,
|
||||
:line_endings, :highlighters
|
||||
attr_reader :b_startup, :b_shutdown, :b_extra_highlights,
|
||||
:b_bar, :b_copy, :b_paste, :b_file_detect
|
||||
|
||||
def bar=(&block)
|
||||
@b_bar = block
|
||||
end
|
||||
|
||||
def startup(&block)
|
||||
@b_startup = block
|
||||
end
|
||||
|
||||
def shutdown(&block)
|
||||
@b_shutdown = block
|
||||
end
|
||||
|
||||
def copy(&block)
|
||||
@b_copy = block
|
||||
end
|
||||
|
||||
def paste(&block)
|
||||
@b_paste = block
|
||||
end
|
||||
|
||||
def file_detect(&block)
|
||||
@b_file_detect = block
|
||||
end
|
||||
|
||||
def extra_highlights(&block)
|
||||
@b_extra_highlights = block
|
||||
end
|
||||
|
||||
def bind(modes, keys = nil, action = nil, &block)
|
||||
modes = [modes] unless modes.is_a?(Array)
|
||||
if keys.nil?
|
||||
app = self
|
||||
dsl = Object.new
|
||||
dsl.define_singleton_method(:set) do |k, act = nil, &blk|
|
||||
app.bind(modes, k, act, &blk)
|
||||
end
|
||||
dsl.instance_exec(&block) if block_given?
|
||||
elsif block_given?
|
||||
keys = [keys] unless keys.is_a?(Array)
|
||||
modes.each do |mode|
|
||||
keys.each do |key|
|
||||
@key_handlers[mode] ||= {}
|
||||
@key_handlers[mode][key] ||= []
|
||||
@key_handlers[mode][key] << block
|
||||
end
|
||||
end
|
||||
elsif action.is_a?(String)
|
||||
keys = [keys] unless keys.is_a?(Array)
|
||||
modes.each do |mode|
|
||||
keys.each do |key|
|
||||
@key_binds[mode] ||= {}
|
||||
@key_binds[mode][key] ||= []
|
||||
@key_binds[mode][key] << action
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
$LOADED ||= []
|
||||
$BIND_TOP = binding
|
||||
|
||||
module Kernel
|
||||
def require_relative(path, bind = nil)
|
||||
path += ".rb" unless path.end_with?(".rb")
|
||||
path = File.expand_path(path, File.dirname(C.config_file))
|
||||
return if $LOADED.include?(path)
|
||||
$LOADED << path
|
||||
code = File.read(path)
|
||||
eval(code, bind || $BIND_TOP, path)
|
||||
end
|
||||
def load(path, bind = nil)
|
||||
path += ".rb" unless path.end_with?(".rb")
|
||||
path = File.expand_path(path, File.dirname(C.config_file))
|
||||
$LOADED.delete(path)
|
||||
require_relative(path, bind)
|
||||
end
|
||||
end
|
||||
946
include/ruby/ruby_compiled.h
Normal file
946
include/ruby/ruby_compiled.h
Normal file
@@ -0,0 +1,946 @@
|
||||
#pragma once
|
||||
constexpr unsigned char _tmp___crib_precompiled_mrb[] = {
|
||||
0x52, 0x49, 0x54, 0x45, 0x30, 0x34, 0x30, 0x30, 0x00, 0x00, 0x2c, 0x1d,
|
||||
0x4d, 0x41, 0x54, 0x5a, 0x30, 0x30, 0x30, 0x30, 0x49, 0x52, 0x45, 0x50,
|
||||
0x00, 0x00, 0x2a, 0x89, 0x30, 0x34, 0x30, 0x30, 0x00, 0x00, 0x00, 0xa2,
|
||||
0x00, 0x01, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a,
|
||||
0x11, 0x01, 0x68, 0x01, 0x00, 0x69, 0x01, 0x00, 0x6b, 0x01, 0x01, 0x01,
|
||||
0x11, 0x01, 0x68, 0x01, 0x02, 0x69, 0x01, 0x02, 0x11, 0x01, 0x68, 0x01,
|
||||
0x03, 0x69, 0x01, 0x03, 0x15, 0x01, 0x04, 0x27, 0x01, 0x00, 0x06, 0x52,
|
||||
0x01, 0x00, 0x16, 0x01, 0x04, 0x30, 0x01, 0x05, 0x16, 0x01, 0x06, 0x11,
|
||||
0x01, 0x68, 0x01, 0x07, 0x69, 0x01, 0x04, 0x3d, 0x01, 0x76, 0x00, 0x00,
|
||||
0x00, 0x08, 0x00, 0x06, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x00, 0x00,
|
||||
0x0f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x5f, 0x65, 0x78, 0x69,
|
||||
0x73, 0x74, 0x73, 0x3f, 0x00, 0x00, 0x09, 0x43, 0x6c, 0x69, 0x70, 0x62,
|
||||
0x6f, 0x61, 0x72, 0x64, 0x00, 0x00, 0x01, 0x43, 0x00, 0x00, 0x07, 0x24,
|
||||
0x4c, 0x4f, 0x41, 0x44, 0x45, 0x44, 0x00, 0x00, 0x07, 0x62, 0x69, 0x6e,
|
||||
0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x09, 0x24, 0x42, 0x49, 0x4e, 0x44,
|
||||
0x5f, 0x54, 0x4f, 0x50, 0x00, 0x00, 0x06, 0x4b, 0x65, 0x72, 0x6e, 0x65,
|
||||
0x6c, 0x00, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x3b, 0x06, 0x01, 0x1e, 0x01, 0x00, 0x07,
|
||||
0x01, 0x1e, 0x01, 0x01, 0x08, 0x01, 0x1e, 0x01, 0x02, 0x09, 0x01, 0x1e,
|
||||
0x01, 0x03, 0x0a, 0x01, 0x1e, 0x01, 0x04, 0x0b, 0x01, 0x1e, 0x01, 0x05,
|
||||
0x0c, 0x01, 0x1e, 0x01, 0x06, 0x0d, 0x01, 0x1e, 0x01, 0x07, 0x03, 0x01,
|
||||
0x08, 0x1e, 0x01, 0x08, 0x03, 0x01, 0x09, 0x1e, 0x01, 0x09, 0x03, 0x01,
|
||||
0x0a, 0x1e, 0x01, 0x0a, 0x03, 0x01, 0x0b, 0x1e, 0x01, 0x0b, 0x03, 0x01,
|
||||
0x0c, 0x1e, 0x01, 0x0c, 0x03, 0x01, 0x0d, 0x1e, 0x01, 0x0d, 0x03, 0x01,
|
||||
0x0e, 0x1e, 0x01, 0x0e, 0x03, 0x01, 0x0f, 0x1e, 0x01, 0x0f, 0x03, 0x01,
|
||||
0x10, 0x1e, 0x01, 0x10, 0x03, 0x01, 0x11, 0x1e, 0x01, 0x11, 0x03, 0x01,
|
||||
0x12, 0x1e, 0x01, 0x12, 0x03, 0x01, 0x13, 0x1e, 0x01, 0x13, 0x03, 0x01,
|
||||
0x14, 0x1e, 0x01, 0x14, 0x03, 0x01, 0x15, 0x1e, 0x01, 0x15, 0x03, 0x01,
|
||||
0x16, 0x1e, 0x01, 0x16, 0x03, 0x01, 0x17, 0x1e, 0x01, 0x17, 0x03, 0x01,
|
||||
0x18, 0x1e, 0x01, 0x18, 0x03, 0x01, 0x19, 0x1e, 0x01, 0x19, 0x03, 0x01,
|
||||
0x1a, 0x1e, 0x01, 0x1a, 0x03, 0x01, 0x1b, 0x1e, 0x01, 0x1b, 0x03, 0x01,
|
||||
0x1c, 0x1e, 0x01, 0x1c, 0x03, 0x01, 0x1d, 0x1e, 0x01, 0x1d, 0x03, 0x01,
|
||||
0x1e, 0x1e, 0x01, 0x1e, 0x03, 0x01, 0x1f, 0x1e, 0x01, 0x1f, 0x03, 0x01,
|
||||
0x20, 0x1e, 0x01, 0x20, 0x03, 0x01, 0x21, 0x1e, 0x01, 0x21, 0x03, 0x01,
|
||||
0x22, 0x1e, 0x01, 0x22, 0x03, 0x01, 0x23, 0x1e, 0x01, 0x23, 0x03, 0x01,
|
||||
0x24, 0x1e, 0x01, 0x24, 0x03, 0x01, 0x25, 0x1e, 0x01, 0x25, 0x03, 0x01,
|
||||
0x26, 0x1e, 0x01, 0x26, 0x03, 0x01, 0x27, 0x1e, 0x01, 0x27, 0x03, 0x01,
|
||||
0x28, 0x1e, 0x01, 0x28, 0x03, 0x01, 0x29, 0x1e, 0x01, 0x29, 0x03, 0x01,
|
||||
0x2a, 0x1e, 0x01, 0x2a, 0x03, 0x01, 0x2b, 0x1e, 0x01, 0x2b, 0x03, 0x01,
|
||||
0x2c, 0x1e, 0x01, 0x2c, 0x03, 0x01, 0x2d, 0x1e, 0x01, 0x2d, 0x03, 0x01,
|
||||
0x2e, 0x1e, 0x01, 0x2e, 0x03, 0x01, 0x2f, 0x1e, 0x01, 0x2f, 0x03, 0x01,
|
||||
0x30, 0x1e, 0x01, 0x30, 0x03, 0x01, 0x31, 0x1e, 0x01, 0x31, 0x03, 0x01,
|
||||
0x32, 0x1e, 0x01, 0x32, 0x03, 0x01, 0x33, 0x1e, 0x01, 0x33, 0x03, 0x01,
|
||||
0x34, 0x1e, 0x01, 0x34, 0x30, 0x01, 0x35, 0x3d, 0x00, 0x00, 0x00, 0x00,
|
||||
0x36, 0x00, 0x06, 0x4b, 0x5f, 0x44, 0x41, 0x54, 0x41, 0x00, 0x00, 0x09,
|
||||
0x4b, 0x5f, 0x53, 0x48, 0x45, 0x42, 0x41, 0x4e, 0x47, 0x00, 0x00, 0x09,
|
||||
0x4b, 0x5f, 0x43, 0x4f, 0x4d, 0x4d, 0x45, 0x4e, 0x54, 0x00, 0x00, 0x07,
|
||||
0x4b, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x00, 0x00, 0x08, 0x4b, 0x5f,
|
||||
0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x00, 0x00, 0x08, 0x4b, 0x5f, 0x45,
|
||||
0x53, 0x43, 0x41, 0x50, 0x45, 0x00, 0x00, 0x0f, 0x4b, 0x5f, 0x49, 0x4e,
|
||||
0x54, 0x45, 0x52, 0x50, 0x4f, 0x4c, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x00,
|
||||
0x00, 0x08, 0x4b, 0x5f, 0x52, 0x45, 0x47, 0x45, 0x58, 0x50, 0x00, 0x00,
|
||||
0x08, 0x4b, 0x5f, 0x4e, 0x55, 0x4d, 0x42, 0x45, 0x52, 0x00, 0x00, 0x06,
|
||||
0x4b, 0x5f, 0x54, 0x52, 0x55, 0x45, 0x00, 0x00, 0x07, 0x4b, 0x5f, 0x46,
|
||||
0x41, 0x4c, 0x53, 0x45, 0x00, 0x00, 0x06, 0x4b, 0x5f, 0x43, 0x48, 0x41,
|
||||
0x52, 0x00, 0x00, 0x09, 0x4b, 0x5f, 0x4b, 0x45, 0x59, 0x57, 0x4f, 0x52,
|
||||
0x44, 0x00, 0x00, 0x11, 0x4b, 0x5f, 0x4b, 0x45, 0x59, 0x57, 0x4f, 0x52,
|
||||
0x44, 0x4f, 0x50, 0x45, 0x52, 0x41, 0x54, 0x4f, 0x52, 0x00, 0x00, 0x0a,
|
||||
0x4b, 0x5f, 0x4f, 0x50, 0x45, 0x52, 0x41, 0x54, 0x4f, 0x52, 0x00, 0x00,
|
||||
0x0a, 0x4b, 0x5f, 0x46, 0x55, 0x4e, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x00,
|
||||
0x00, 0x06, 0x4b, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x00, 0x00, 0x0a, 0x4b,
|
||||
0x5f, 0x43, 0x4f, 0x4e, 0x53, 0x54, 0x41, 0x4e, 0x54, 0x00, 0x00, 0x12,
|
||||
0x4b, 0x5f, 0x56, 0x41, 0x52, 0x49, 0x41, 0x42, 0x4c, 0x45, 0x49, 0x4e,
|
||||
0x53, 0x54, 0x41, 0x4e, 0x43, 0x45, 0x00, 0x00, 0x10, 0x4b, 0x5f, 0x56,
|
||||
0x41, 0x52, 0x49, 0x41, 0x42, 0x4c, 0x45, 0x47, 0x4c, 0x4f, 0x42, 0x41,
|
||||
0x4c, 0x00, 0x00, 0x0c, 0x4b, 0x5f, 0x41, 0x4e, 0x4e, 0x4f, 0x54, 0x41,
|
||||
0x54, 0x49, 0x4f, 0x4e, 0x00, 0x00, 0x0b, 0x4b, 0x5f, 0x44, 0x49, 0x52,
|
||||
0x45, 0x43, 0x54, 0x49, 0x56, 0x45, 0x00, 0x00, 0x07, 0x4b, 0x5f, 0x4c,
|
||||
0x41, 0x42, 0x45, 0x4c, 0x00, 0x00, 0x08, 0x4b, 0x5f, 0x42, 0x52, 0x41,
|
||||
0x43, 0x45, 0x31, 0x00, 0x00, 0x08, 0x4b, 0x5f, 0x42, 0x52, 0x41, 0x43,
|
||||
0x45, 0x32, 0x00, 0x00, 0x08, 0x4b, 0x5f, 0x42, 0x52, 0x41, 0x43, 0x45,
|
||||
0x33, 0x00, 0x00, 0x08, 0x4b, 0x5f, 0x42, 0x52, 0x41, 0x43, 0x45, 0x34,
|
||||
0x00, 0x00, 0x08, 0x4b, 0x5f, 0x42, 0x52, 0x41, 0x43, 0x45, 0x35, 0x00,
|
||||
0x00, 0x0a, 0x4b, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x49, 0x4e, 0x47, 0x31,
|
||||
0x00, 0x00, 0x0a, 0x4b, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x49, 0x4e, 0x47,
|
||||
0x32, 0x00, 0x00, 0x0a, 0x4b, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x49, 0x4e,
|
||||
0x47, 0x33, 0x00, 0x00, 0x0a, 0x4b, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x49,
|
||||
0x4e, 0x47, 0x34, 0x00, 0x00, 0x0a, 0x4b, 0x5f, 0x48, 0x45, 0x41, 0x44,
|
||||
0x49, 0x4e, 0x47, 0x35, 0x00, 0x00, 0x0a, 0x4b, 0x5f, 0x48, 0x45, 0x41,
|
||||
0x44, 0x49, 0x4e, 0x47, 0x36, 0x00, 0x00, 0x0c, 0x4b, 0x5f, 0x42, 0x4c,
|
||||
0x4f, 0x43, 0x4b, 0x51, 0x55, 0x4f, 0x54, 0x45, 0x00, 0x00, 0x06, 0x4b,
|
||||
0x5f, 0x4c, 0x49, 0x53, 0x54, 0x00, 0x00, 0x0a, 0x4b, 0x5f, 0x4c, 0x49,
|
||||
0x53, 0x54, 0x49, 0x54, 0x45, 0x4d, 0x00, 0x00, 0x06, 0x4b, 0x5f, 0x43,
|
||||
0x4f, 0x44, 0x45, 0x00, 0x00, 0x0e, 0x4b, 0x5f, 0x4c, 0x41, 0x4e, 0x47,
|
||||
0x55, 0x41, 0x47, 0x45, 0x4e, 0x41, 0x4d, 0x45, 0x00, 0x00, 0x0b, 0x4b,
|
||||
0x5f, 0x4c, 0x49, 0x4e, 0x4b, 0x4c, 0x41, 0x42, 0x45, 0x4c, 0x00, 0x00,
|
||||
0x0c, 0x4b, 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x4c, 0x41, 0x42, 0x45,
|
||||
0x4c, 0x00, 0x00, 0x06, 0x4b, 0x5f, 0x4c, 0x49, 0x4e, 0x4b, 0x00, 0x00,
|
||||
0x07, 0x4b, 0x5f, 0x54, 0x41, 0x42, 0x4c, 0x45, 0x00, 0x00, 0x0d, 0x4b,
|
||||
0x5f, 0x54, 0x41, 0x42, 0x4c, 0x45, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52,
|
||||
0x00, 0x00, 0x08, 0x4b, 0x5f, 0x49, 0x54, 0x41, 0x4c, 0x49, 0x43, 0x00,
|
||||
0x00, 0x06, 0x4b, 0x5f, 0x42, 0x4f, 0x4c, 0x44, 0x00, 0x00, 0x0b, 0x4b,
|
||||
0x5f, 0x55, 0x4e, 0x44, 0x45, 0x52, 0x4c, 0x49, 0x4e, 0x45, 0x00, 0x00,
|
||||
0x0f, 0x4b, 0x5f, 0x53, 0x54, 0x52, 0x49, 0x4b, 0x45, 0x54, 0x48, 0x52,
|
||||
0x4f, 0x55, 0x47, 0x48, 0x00, 0x00, 0x10, 0x4b, 0x5f, 0x48, 0x4f, 0x52,
|
||||
0x49, 0x58, 0x4f, 0x4e, 0x54, 0x41, 0x4c, 0x52, 0x55, 0x4c, 0x45, 0x00,
|
||||
0x00, 0x05, 0x4b, 0x5f, 0x54, 0x41, 0x47, 0x00, 0x00, 0x0b, 0x4b, 0x5f,
|
||||
0x41, 0x54, 0x54, 0x52, 0x49, 0x42, 0x55, 0x54, 0x45, 0x00, 0x00, 0x0b,
|
||||
0x4b, 0x5f, 0x43, 0x48, 0x45, 0x43, 0x4b, 0x44, 0x4f, 0x4e, 0x45, 0x00,
|
||||
0x00, 0x0e, 0x4b, 0x5f, 0x43, 0x48, 0x45, 0x43, 0x4b, 0x4e, 0x4f, 0x54,
|
||||
0x44, 0x4f, 0x4e, 0x45, 0x00, 0x00, 0x06, 0x66, 0x72, 0x65, 0x65, 0x7a,
|
||||
0x65, 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x39, 0x04, 0x00, 0x00, 0x5c, 0x04,
|
||||
0x00, 0x01, 0x05, 0x01, 0x5d, 0x04, 0x5c, 0x05, 0x01, 0x5d, 0x04, 0x2f,
|
||||
0x03, 0x00, 0x01, 0x3d, 0x03, 0x00, 0x02, 0x00, 0x00, 0x0b, 0x63, 0x6f,
|
||||
0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x2d, 0x76, 0x20, 0x00, 0x00, 0x00,
|
||||
0x11, 0x20, 0x3e, 0x20, 0x2f, 0x64, 0x65, 0x76, 0x2f, 0x6e, 0x75, 0x6c,
|
||||
0x6c, 0x20, 0x32, 0x3e, 0x26, 0x31, 0x00, 0x00, 0x01, 0x00, 0x06, 0x73,
|
||||
0x79, 0x73, 0x74, 0x65, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x43, 0x00, 0x01,
|
||||
0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x5c, 0x01,
|
||||
0x00, 0x1a, 0x01, 0x00, 0x10, 0x01, 0x01, 0x1a, 0x01, 0x02, 0x12, 0x01,
|
||||
0x6f, 0x01, 0x69, 0x01, 0x00, 0x3d, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x05, 0x40, 0x63, 0x6c, 0x69, 0x70, 0x00, 0x00,
|
||||
0x05, 0x6c, 0x69, 0x6e, 0x75, 0x78, 0x00, 0x00, 0x03, 0x40, 0x6f, 0x73,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x01, 0x00, 0x01, 0x00, 0x03, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x0e, 0x6b, 0x01, 0x00, 0x00, 0x6b, 0x01, 0x01,
|
||||
0x01, 0x6b, 0x01, 0x02, 0x02, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
|
||||
0x04, 0x63, 0x6f, 0x70, 0x79, 0x00, 0x00, 0x05, 0x70, 0x61, 0x73, 0x74,
|
||||
0x65, 0x00, 0x00, 0x0a, 0x6f, 0x73, 0x63, 0x35, 0x32, 0x5f, 0x63, 0x6f,
|
||||
0x70, 0x79, 0x00, 0x00, 0x00, 0x02, 0x37, 0x00, 0x03, 0x00, 0x07, 0x00,
|
||||
0x05, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0f, 0x39, 0x04, 0x00, 0x00, 0x19,
|
||||
0x03, 0x00, 0x10, 0x04, 0x01, 0x4d, 0x03, 0x28, 0x03, 0x00, 0x13, 0x1d,
|
||||
0x03, 0x02, 0x5c, 0x04, 0x00, 0x5c, 0x05, 0x01, 0x62, 0x06, 0x00, 0x34,
|
||||
0x03, 0x03, 0x02, 0x26, 0x00, 0xe4, 0x19, 0x03, 0x00, 0x10, 0x04, 0x04,
|
||||
0x4d, 0x03, 0x28, 0x03, 0x00, 0x13, 0x1d, 0x03, 0x02, 0x5c, 0x04, 0x02,
|
||||
0x5c, 0x05, 0x01, 0x62, 0x06, 0x01, 0x34, 0x03, 0x03, 0x02, 0x26, 0x00,
|
||||
0xc5, 0x19, 0x03, 0x00, 0x10, 0x04, 0x05, 0x4d, 0x03, 0x28, 0x03, 0x00,
|
||||
0xb9, 0x1d, 0x03, 0x06, 0x5c, 0x04, 0x03, 0x23, 0x03, 0x01, 0x04, 0x03,
|
||||
0x29, 0x04, 0x00, 0x03, 0x33, 0x03, 0x07, 0x5c, 0x04, 0x04, 0x4d, 0x03,
|
||||
0x27, 0x03, 0x00, 0x08, 0x1d, 0x03, 0x06, 0x5c, 0x04, 0x05, 0x23, 0x03,
|
||||
0x28, 0x03, 0x00, 0x28, 0x5c, 0x04, 0x06, 0x2f, 0x03, 0x08, 0x01, 0x28,
|
||||
0x03, 0x00, 0x13, 0x1d, 0x03, 0x02, 0x5c, 0x04, 0x06, 0x5c, 0x05, 0x01,
|
||||
0x62, 0x06, 0x02, 0x34, 0x03, 0x03, 0x02, 0x26, 0x00, 0x07, 0x01, 0x04,
|
||||
0x01, 0x2f, 0x03, 0x09, 0x01, 0x26, 0x00, 0x6a, 0x1d, 0x03, 0x06, 0x5c,
|
||||
0x04, 0x03, 0x23, 0x03, 0x01, 0x04, 0x03, 0x29, 0x04, 0x00, 0x03, 0x33,
|
||||
0x03, 0x07, 0x5c, 0x04, 0x07, 0x4d, 0x03, 0x27, 0x03, 0x00, 0x08, 0x1d,
|
||||
0x03, 0x06, 0x5c, 0x04, 0x08, 0x23, 0x03, 0x28, 0x03, 0x00, 0x43, 0x5c,
|
||||
0x04, 0x09, 0x2f, 0x03, 0x08, 0x01, 0x28, 0x03, 0x00, 0x13, 0x1d, 0x03,
|
||||
0x02, 0x5c, 0x04, 0x0a, 0x5c, 0x05, 0x01, 0x62, 0x06, 0x03, 0x34, 0x03,
|
||||
0x03, 0x02, 0x26, 0x00, 0x25, 0x5c, 0x04, 0x0b, 0x2f, 0x03, 0x08, 0x01,
|
||||
0x28, 0x03, 0x00, 0x13, 0x1d, 0x03, 0x02, 0x5c, 0x04, 0x0c, 0x5c, 0x05,
|
||||
0x01, 0x62, 0x06, 0x04, 0x34, 0x03, 0x03, 0x02, 0x26, 0x00, 0x07, 0x01,
|
||||
0x04, 0x01, 0x2f, 0x03, 0x09, 0x01, 0x01, 0x03, 0x01, 0x1a, 0x03, 0x0a,
|
||||
0x3d, 0x03, 0x00, 0x0d, 0x00, 0x00, 0x04, 0x63, 0x6c, 0x69, 0x70, 0x00,
|
||||
0x00, 0x00, 0x01, 0x77, 0x00, 0x00, 0x00, 0x06, 0x70, 0x62, 0x63, 0x6f,
|
||||
0x70, 0x79, 0x00, 0x00, 0x00, 0x10, 0x58, 0x44, 0x47, 0x5f, 0x53, 0x45,
|
||||
0x53, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x00, 0x00,
|
||||
0x00, 0x07, 0x77, 0x61, 0x79, 0x6c, 0x61, 0x6e, 0x64, 0x00, 0x00, 0x00,
|
||||
0x0f, 0x57, 0x41, 0x59, 0x4c, 0x41, 0x4e, 0x44, 0x5f, 0x44, 0x49, 0x53,
|
||||
0x50, 0x4c, 0x41, 0x59, 0x00, 0x00, 0x00, 0x07, 0x77, 0x6c, 0x2d, 0x63,
|
||||
0x6f, 0x70, 0x79, 0x00, 0x00, 0x00, 0x03, 0x78, 0x31, 0x31, 0x00, 0x00,
|
||||
0x00, 0x07, 0x44, 0x49, 0x53, 0x50, 0x4c, 0x41, 0x59, 0x00, 0x00, 0x00,
|
||||
0x04, 0x78, 0x73, 0x65, 0x6c, 0x00, 0x00, 0x00, 0x18, 0x78, 0x73, 0x65,
|
||||
0x6c, 0x20, 0x2d, 0x2d, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72,
|
||||
0x64, 0x20, 0x2d, 0x2d, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00,
|
||||
0x05, 0x78, 0x63, 0x6c, 0x69, 0x70, 0x00, 0x00, 0x00, 0x1a, 0x78, 0x63,
|
||||
0x6c, 0x69, 0x70, 0x20, 0x2d, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x20, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64,
|
||||
0x00, 0x00, 0x0b, 0x00, 0x03, 0x40, 0x6f, 0x73, 0x00, 0x00, 0x07, 0x77,
|
||||
0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x00, 0x00, 0x02, 0x49, 0x4f, 0x00,
|
||||
0x00, 0x05, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x00, 0x00, 0x03, 0x6d, 0x61,
|
||||
0x63, 0x00, 0x00, 0x05, 0x6c, 0x69, 0x6e, 0x75, 0x78, 0x00, 0x00, 0x03,
|
||||
0x45, 0x4e, 0x56, 0x00, 0x00, 0x08, 0x64, 0x6f, 0x77, 0x6e, 0x63, 0x61,
|
||||
0x73, 0x65, 0x00, 0x00, 0x0f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64,
|
||||
0x5f, 0x65, 0x78, 0x69, 0x73, 0x74, 0x73, 0x3f, 0x00, 0x00, 0x0a, 0x6f,
|
||||
0x73, 0x63, 0x35, 0x32, 0x5f, 0x63, 0x6f, 0x70, 0x79, 0x00, 0x00, 0x05,
|
||||
0x40, 0x63, 0x6c, 0x69, 0x70, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x03,
|
||||
0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x39, 0x04,
|
||||
0x00, 0x00, 0x01, 0x03, 0x01, 0x21, 0x04, 0x01, 0x00, 0x32, 0x03, 0x00,
|
||||
0x01, 0x3d, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x77, 0x72, 0x69,
|
||||
0x74, 0x65, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x03, 0x00, 0x06, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x39, 0x04, 0x00, 0x00, 0x01,
|
||||
0x03, 0x01, 0x21, 0x04, 0x01, 0x00, 0x32, 0x03, 0x00, 0x01, 0x3d, 0x03,
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x77, 0x72, 0x69, 0x74, 0x65, 0x00,
|
||||
0x00, 0x00, 0x00, 0x2d, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x11, 0x39, 0x04, 0x00, 0x00, 0x01, 0x03, 0x01, 0x21,
|
||||
0x04, 0x01, 0x00, 0x32, 0x03, 0x00, 0x01, 0x3d, 0x03, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x05, 0x77, 0x72, 0x69, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00,
|
||||
0x2d, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x11, 0x39, 0x04, 0x00, 0x00, 0x01, 0x03, 0x01, 0x21, 0x04, 0x01, 0x00,
|
||||
0x32, 0x03, 0x00, 0x01, 0x3d, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x05,
|
||||
0x77, 0x72, 0x69, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x03,
|
||||
0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x39, 0x04,
|
||||
0x00, 0x00, 0x01, 0x03, 0x01, 0x21, 0x04, 0x01, 0x00, 0x32, 0x03, 0x00,
|
||||
0x01, 0x3d, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x77, 0x72, 0x69,
|
||||
0x74, 0x65, 0x00, 0x00, 0x00, 0x02, 0x27, 0x00, 0x02, 0x00, 0x05, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdd, 0x39, 0x00, 0x00, 0x00, 0x19,
|
||||
0x02, 0x00, 0x10, 0x03, 0x01, 0x4d, 0x02, 0x28, 0x02, 0x00, 0x0c, 0x5c,
|
||||
0x03, 0x00, 0x2f, 0x02, 0x02, 0x01, 0x3d, 0x02, 0x26, 0x00, 0xbc, 0x19,
|
||||
0x02, 0x00, 0x10, 0x03, 0x03, 0x4d, 0x02, 0x28, 0x02, 0x00, 0x0c, 0x5c,
|
||||
0x03, 0x01, 0x2f, 0x02, 0x02, 0x01, 0x3d, 0x02, 0x26, 0x00, 0xa4, 0x19,
|
||||
0x02, 0x00, 0x10, 0x03, 0x04, 0x4d, 0x02, 0x28, 0x02, 0x00, 0x98, 0x1d,
|
||||
0x02, 0x05, 0x5c, 0x03, 0x02, 0x23, 0x02, 0x01, 0x03, 0x02, 0x29, 0x03,
|
||||
0x00, 0x03, 0x33, 0x02, 0x06, 0x5c, 0x03, 0x03, 0x4d, 0x02, 0x27, 0x02,
|
||||
0x00, 0x08, 0x1d, 0x02, 0x05, 0x5c, 0x03, 0x04, 0x23, 0x02, 0x28, 0x02,
|
||||
0x00, 0x17, 0x5c, 0x03, 0x05, 0x2f, 0x02, 0x07, 0x01, 0x28, 0x02, 0x00,
|
||||
0x09, 0x5c, 0x03, 0x06, 0x2f, 0x02, 0x02, 0x01, 0x3d, 0x02, 0x26, 0x00,
|
||||
0x5a, 0x1d, 0x02, 0x05, 0x5c, 0x03, 0x02, 0x23, 0x02, 0x01, 0x03, 0x02,
|
||||
0x29, 0x03, 0x00, 0x03, 0x33, 0x02, 0x06, 0x5c, 0x03, 0x07, 0x4d, 0x02,
|
||||
0x27, 0x02, 0x00, 0x08, 0x1d, 0x02, 0x05, 0x5c, 0x03, 0x08, 0x23, 0x02,
|
||||
0x28, 0x02, 0x00, 0x33, 0x5c, 0x03, 0x09, 0x2f, 0x02, 0x07, 0x01, 0x28,
|
||||
0x02, 0x00, 0x0c, 0x5c, 0x03, 0x0a, 0x2f, 0x02, 0x02, 0x01, 0x3d, 0x02,
|
||||
0x26, 0x00, 0x1c, 0x5c, 0x03, 0x0b, 0x2f, 0x02, 0x07, 0x01, 0x28, 0x02,
|
||||
0x00, 0x0c, 0x5c, 0x03, 0x0c, 0x2f, 0x02, 0x02, 0x01, 0x3d, 0x02, 0x26,
|
||||
0x00, 0x05, 0x19, 0x02, 0x08, 0x3d, 0x02, 0x5c, 0x02, 0x0d, 0x3d, 0x02,
|
||||
0x00, 0x0e, 0x00, 0x00, 0x2c, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x73, 0x68,
|
||||
0x65, 0x6c, 0x6c, 0x20, 0x2d, 0x4e, 0x6f, 0x50, 0x72, 0x6f, 0x66, 0x69,
|
||||
0x6c, 0x65, 0x20, 0x2d, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20,
|
||||
0x47, 0x65, 0x74, 0x2d, 0x43, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72,
|
||||
0x64, 0x00, 0x00, 0x00, 0x07, 0x70, 0x62, 0x70, 0x61, 0x73, 0x74, 0x65,
|
||||
0x00, 0x00, 0x00, 0x10, 0x58, 0x44, 0x47, 0x5f, 0x53, 0x45, 0x53, 0x53,
|
||||
0x49, 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x00, 0x00, 0x00, 0x07,
|
||||
0x77, 0x61, 0x79, 0x6c, 0x61, 0x6e, 0x64, 0x00, 0x00, 0x00, 0x0f, 0x57,
|
||||
0x41, 0x59, 0x4c, 0x41, 0x4e, 0x44, 0x5f, 0x44, 0x49, 0x53, 0x50, 0x4c,
|
||||
0x41, 0x59, 0x00, 0x00, 0x00, 0x07, 0x77, 0x6c, 0x2d, 0x63, 0x6f, 0x70,
|
||||
0x79, 0x00, 0x00, 0x00, 0x08, 0x77, 0x6c, 0x2d, 0x70, 0x61, 0x73, 0x74,
|
||||
0x65, 0x00, 0x00, 0x00, 0x03, 0x78, 0x31, 0x31, 0x00, 0x00, 0x00, 0x07,
|
||||
0x44, 0x49, 0x53, 0x50, 0x4c, 0x41, 0x59, 0x00, 0x00, 0x00, 0x04, 0x78,
|
||||
0x73, 0x65, 0x6c, 0x00, 0x00, 0x00, 0x19, 0x78, 0x73, 0x65, 0x6c, 0x20,
|
||||
0x2d, 0x2d, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x20,
|
||||
0x2d, 0x2d, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00, 0x05,
|
||||
0x78, 0x63, 0x6c, 0x69, 0x70, 0x00, 0x00, 0x00, 0x1d, 0x78, 0x63, 0x6c,
|
||||
0x69, 0x70, 0x20, 0x2d, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x20, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x20,
|
||||
0x2d, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x03, 0x40,
|
||||
0x6f, 0x73, 0x00, 0x00, 0x07, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73,
|
||||
0x00, 0x00, 0x01, 0x60, 0x00, 0x00, 0x03, 0x6d, 0x61, 0x63, 0x00, 0x00,
|
||||
0x05, 0x6c, 0x69, 0x6e, 0x75, 0x78, 0x00, 0x00, 0x03, 0x45, 0x4e, 0x56,
|
||||
0x00, 0x00, 0x08, 0x64, 0x6f, 0x77, 0x6e, 0x63, 0x61, 0x73, 0x65, 0x00,
|
||||
0x00, 0x0f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x5f, 0x65, 0x78,
|
||||
0x69, 0x73, 0x74, 0x73, 0x3f, 0x00, 0x00, 0x05, 0x40, 0x63, 0x6c, 0x69,
|
||||
0x70, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x39, 0x04, 0x00, 0x00, 0x01, 0x04,
|
||||
0x01, 0x52, 0x04, 0x01, 0x5c, 0x05, 0x00, 0x32, 0x04, 0x00, 0x01, 0x01,
|
||||
0x03, 0x04, 0x5c, 0x05, 0x01, 0x01, 0x06, 0x03, 0x5d, 0x05, 0x5c, 0x06,
|
||||
0x02, 0x5d, 0x05, 0x2f, 0x04, 0x01, 0x01, 0x3d, 0x01, 0x00, 0x03, 0x00,
|
||||
0x00, 0x02, 0x6d, 0x30, 0x00, 0x00, 0x00, 0x07, 0x1b, 0x5d, 0x35, 0x32,
|
||||
0x3b, 0x63, 0x3b, 0x00, 0x00, 0x00, 0x01, 0x07, 0x00, 0x00, 0x02, 0x00,
|
||||
0x04, 0x70, 0x61, 0x63, 0x6b, 0x00, 0x00, 0x05, 0x70, 0x72, 0x69, 0x6e,
|
||||
0x74, 0x00, 0x00, 0x00, 0x0f, 0xc7, 0x00, 0x01, 0x00, 0x4c, 0x00, 0x05,
|
||||
0x00, 0x00, 0x00, 0x00, 0x07, 0xa8, 0x5c, 0x01, 0x00, 0x5c, 0x02, 0x01,
|
||||
0x5c, 0x03, 0x02, 0x5c, 0x04, 0x03, 0x5c, 0x05, 0x04, 0x5c, 0x06, 0x05,
|
||||
0x5c, 0x07, 0x06, 0x5c, 0x08, 0x07, 0x52, 0x02, 0x07, 0x5c, 0x03, 0x08,
|
||||
0x52, 0x04, 0x00, 0x5c, 0x05, 0x09, 0x5c, 0x06, 0x0a, 0x52, 0x06, 0x01,
|
||||
0x5c, 0x07, 0x0b, 0x5c, 0x08, 0x0c, 0x52, 0x08, 0x01, 0x5c, 0x09, 0x0d,
|
||||
0x5c, 0x0a, 0x0e, 0x52, 0x0a, 0x01, 0x5c, 0x0b, 0x0f, 0x5c, 0x0c, 0x0e,
|
||||
0x52, 0x0c, 0x01, 0x5c, 0x0d, 0x10, 0x5c, 0x0e, 0x0c, 0x52, 0x0e, 0x01,
|
||||
0x5c, 0x0f, 0x11, 0x5c, 0x10, 0x12, 0x52, 0x10, 0x01, 0x5c, 0x11, 0x13,
|
||||
0x5c, 0x12, 0x14, 0x52, 0x12, 0x01, 0x5c, 0x13, 0x15, 0x5c, 0x14, 0x0e,
|
||||
0x52, 0x14, 0x01, 0x5c, 0x15, 0x16, 0x5c, 0x16, 0x0e, 0x52, 0x16, 0x01,
|
||||
0x5c, 0x17, 0x17, 0x52, 0x18, 0x00, 0x5c, 0x19, 0x18, 0x5c, 0x1a, 0x0e,
|
||||
0x52, 0x1a, 0x01, 0x5c, 0x1b, 0x19, 0x52, 0x1c, 0x00, 0x5c, 0x1d, 0x1a,
|
||||
0x5c, 0x1e, 0x0e, 0x52, 0x1e, 0x01, 0x5c, 0x1f, 0x1b, 0x5c, 0x20, 0x1c,
|
||||
0x52, 0x20, 0x01, 0x5c, 0x21, 0x1d, 0x52, 0x22, 0x00, 0x5c, 0x23, 0x1e,
|
||||
0x5c, 0x24, 0x14, 0x5c, 0x25, 0x0a, 0x52, 0x24, 0x02, 0x5c, 0x25, 0x1f,
|
||||
0x5c, 0x26, 0x0e, 0x52, 0x26, 0x01, 0x5c, 0x27, 0x20, 0x5c, 0x28, 0x12,
|
||||
0x52, 0x28, 0x01, 0x5c, 0x29, 0x21, 0x52, 0x2a, 0x00, 0x5c, 0x2b, 0x22,
|
||||
0x5c, 0x2c, 0x23, 0x5c, 0x2d, 0x24, 0x5c, 0x2e, 0x0a, 0x52, 0x2c, 0x03,
|
||||
0x5e, 0x01, 0x16, 0x1a, 0x01, 0x00, 0x10, 0x01, 0x01, 0x10, 0x02, 0x02,
|
||||
0x0f, 0x03, 0x00, 0x55, 0x55, 0x55, 0x10, 0x04, 0x03, 0x5c, 0x05, 0x25,
|
||||
0x10, 0x06, 0x04, 0x5c, 0x07, 0x26, 0x52, 0x07, 0x01, 0x10, 0x08, 0x05,
|
||||
0x5c, 0x09, 0x00, 0x5e, 0x02, 0x04, 0x10, 0x03, 0x06, 0x10, 0x04, 0x02,
|
||||
0x0e, 0x05, 0x59, 0x9c, 0x10, 0x06, 0x03, 0x5c, 0x07, 0x27, 0x10, 0x08,
|
||||
0x04, 0x5c, 0x09, 0x28, 0x5c, 0x0a, 0x29, 0x5c, 0x0b, 0x2a, 0x52, 0x09,
|
||||
0x03, 0x10, 0x0a, 0x05, 0x5c, 0x0b, 0x00, 0x5e, 0x04, 0x04, 0x10, 0x05,
|
||||
0x07, 0x10, 0x06, 0x02, 0x0f, 0x07, 0x00, 0xa8, 0xb9, 0xcc, 0x10, 0x08,
|
||||
0x03, 0x5c, 0x09, 0x2b, 0x10, 0x0a, 0x04, 0x5c, 0x0b, 0x2c, 0x5c, 0x0c,
|
||||
0x2d, 0x52, 0x0b, 0x02, 0x10, 0x0c, 0x05, 0x5c, 0x0d, 0x00, 0x5e, 0x06,
|
||||
0x04, 0x10, 0x07, 0x08, 0x10, 0x08, 0x02, 0x0f, 0x09, 0x00, 0x36, 0xa3,
|
||||
0xd9, 0x10, 0x0a, 0x03, 0x5c, 0x0b, 0x2e, 0x10, 0x0c, 0x04, 0x5c, 0x0d,
|
||||
0x2f, 0x52, 0x0d, 0x01, 0x10, 0x0e, 0x05, 0x5c, 0x0f, 0x0d, 0x5e, 0x08,
|
||||
0x04, 0x10, 0x09, 0x09, 0x10, 0x0a, 0x02, 0x0f, 0x0b, 0x00, 0x4d, 0x5a,
|
||||
0x5e, 0x10, 0x0c, 0x03, 0x5c, 0x0d, 0x30, 0x10, 0x0e, 0x04, 0x5c, 0x0f,
|
||||
0x31, 0x52, 0x0f, 0x01, 0x10, 0x10, 0x05, 0x5c, 0x11, 0x10, 0x5e, 0x0a,
|
||||
0x04, 0x10, 0x0b, 0x0a, 0x10, 0x0c, 0x02, 0x0f, 0x0d, 0x00, 0x00, 0xad,
|
||||
0xd8, 0x10, 0x0e, 0x03, 0x5c, 0x0f, 0x32, 0x10, 0x10, 0x04, 0x5c, 0x11,
|
||||
0x33, 0x52, 0x11, 0x01, 0x10, 0x12, 0x05, 0x5c, 0x13, 0x11, 0x5e, 0x0c,
|
||||
0x04, 0x10, 0x0d, 0x0b, 0x10, 0x0e, 0x02, 0x0f, 0x0f, 0x00, 0x00, 0xad,
|
||||
0xd8, 0x10, 0x10, 0x03, 0x5c, 0x11, 0x32, 0x10, 0x12, 0x04, 0x5c, 0x13,
|
||||
0x34, 0x52, 0x13, 0x01, 0x10, 0x14, 0x05, 0x5c, 0x15, 0x11, 0x5e, 0x0e,
|
||||
0x04, 0x10, 0x0f, 0x0c, 0x10, 0x10, 0x02, 0x0f, 0x11, 0x00, 0xa0, 0x74,
|
||||
0xc4, 0x10, 0x12, 0x03, 0x5c, 0x13, 0x35, 0x10, 0x14, 0x04, 0x5c, 0x15,
|
||||
0x36, 0x5c, 0x16, 0x37, 0x52, 0x15, 0x02, 0x10, 0x16, 0x05, 0x5c, 0x17,
|
||||
0x13, 0x5e, 0x10, 0x04, 0x10, 0x11, 0x0d, 0x10, 0x12, 0x02, 0x0f, 0x13,
|
||||
0x00, 0xef, 0x8a, 0x91, 0x10, 0x14, 0x03, 0x5c, 0x15, 0x38, 0x10, 0x16,
|
||||
0x04, 0x5c, 0x17, 0x39, 0x5c, 0x18, 0x3a, 0x52, 0x17, 0x02, 0x10, 0x18,
|
||||
0x05, 0x5c, 0x19, 0x15, 0x5e, 0x12, 0x04, 0x10, 0x13, 0x0e, 0x10, 0x14,
|
||||
0x02, 0x0f, 0x15, 0x00, 0xf0, 0xdf, 0x8a, 0x10, 0x16, 0x03, 0x5c, 0x17,
|
||||
0x3b, 0x10, 0x18, 0x04, 0x5c, 0x19, 0x3c, 0x52, 0x19, 0x01, 0x10, 0x1a,
|
||||
0x05, 0x5c, 0x1b, 0x16, 0x5e, 0x14, 0x04, 0x10, 0x15, 0x0f, 0x10, 0x16,
|
||||
0x02, 0x0f, 0x17, 0x00, 0x36, 0xa3, 0xd9, 0x10, 0x18, 0x03, 0x5c, 0x19,
|
||||
0x3d, 0x10, 0x1a, 0x04, 0x5c, 0x1b, 0x3e, 0x52, 0x1b, 0x01, 0x10, 0x1c,
|
||||
0x05, 0x5c, 0x1d, 0x16, 0x5e, 0x16, 0x04, 0x10, 0x17, 0x10, 0x10, 0x18,
|
||||
0x02, 0x0f, 0x19, 0x00, 0xcb, 0xcb, 0x41, 0x10, 0x1a, 0x03, 0x5c, 0x1b,
|
||||
0x3f, 0x10, 0x1c, 0x04, 0x5c, 0x1d, 0x40, 0x52, 0x1d, 0x01, 0x10, 0x1e,
|
||||
0x05, 0x5c, 0x1f, 0x0f, 0x5e, 0x18, 0x04, 0x10, 0x19, 0x11, 0x10, 0x1a,
|
||||
0x02, 0x0f, 0x1b, 0x00, 0xcb, 0xcb, 0x41, 0x10, 0x1c, 0x03, 0x5c, 0x1d,
|
||||
0x3f, 0x10, 0x1e, 0x04, 0x5c, 0x1f, 0x41, 0x52, 0x1f, 0x01, 0x10, 0x20,
|
||||
0x05, 0x5c, 0x21, 0x0f, 0x5e, 0x1a, 0x04, 0x10, 0x1b, 0x12, 0x10, 0x1c,
|
||||
0x02, 0x0f, 0x1d, 0x00, 0x6e, 0x15, 0x16, 0x10, 0x1e, 0x03, 0x5c, 0x1f,
|
||||
0x38, 0x10, 0x20, 0x04, 0x5c, 0x21, 0x42, 0x52, 0x21, 0x01, 0x10, 0x22,
|
||||
0x05, 0x5c, 0x23, 0x15, 0x5e, 0x1c, 0x04, 0x10, 0x1d, 0x13, 0x10, 0x1e,
|
||||
0x02, 0x0f, 0x1f, 0x00, 0x36, 0xa3, 0xd9, 0x10, 0x20, 0x03, 0x5c, 0x21,
|
||||
0x43, 0x10, 0x22, 0x04, 0x5c, 0x23, 0x44, 0x52, 0x23, 0x01, 0x10, 0x24,
|
||||
0x05, 0x5c, 0x25, 0x17, 0x5e, 0x1e, 0x04, 0x10, 0x1f, 0x14, 0x10, 0x20,
|
||||
0x02, 0x0f, 0x21, 0x00, 0x95, 0xe6, 0xcb, 0x10, 0x22, 0x03, 0x5c, 0x23,
|
||||
0x45, 0x10, 0x24, 0x04, 0x5c, 0x25, 0x46, 0x52, 0x25, 0x01, 0x10, 0x26,
|
||||
0x05, 0x5c, 0x27, 0x47, 0x5e, 0x20, 0x04, 0x10, 0x21, 0x15, 0x10, 0x22,
|
||||
0x02, 0x0f, 0x23, 0x00, 0xde, 0xa5, 0x84, 0x10, 0x24, 0x03, 0x5c, 0x25,
|
||||
0x48, 0x10, 0x26, 0x04, 0x5c, 0x27, 0x49, 0x52, 0x27, 0x01, 0x10, 0x28,
|
||||
0x05, 0x5c, 0x29, 0x19, 0x5e, 0x22, 0x04, 0x10, 0x23, 0x16, 0x10, 0x24,
|
||||
0x02, 0x0f, 0x25, 0x00, 0xa0, 0x74, 0xc4, 0x10, 0x26, 0x03, 0x5c, 0x27,
|
||||
0x4a, 0x10, 0x28, 0x04, 0x5c, 0x29, 0x4b, 0x52, 0x29, 0x01, 0x10, 0x2a,
|
||||
0x05, 0x5c, 0x2b, 0x1a, 0x5e, 0x24, 0x04, 0x10, 0x25, 0x17, 0x10, 0x26,
|
||||
0x02, 0x0f, 0x27, 0x00, 0x36, 0xa3, 0xd9, 0x10, 0x28, 0x03, 0x5c, 0x29,
|
||||
0x4c, 0x10, 0x2a, 0x04, 0x5c, 0x2b, 0x4d, 0x5c, 0x2c, 0x4e, 0x52, 0x2b,
|
||||
0x02, 0x10, 0x2c, 0x05, 0x5c, 0x2d, 0x1b, 0x5e, 0x26, 0x04, 0x10, 0x27,
|
||||
0x18, 0x10, 0x28, 0x02, 0x0f, 0x29, 0x00, 0x6d, 0x80, 0x86, 0x10, 0x2a,
|
||||
0x03, 0x5c, 0x2b, 0x4f, 0x10, 0x2c, 0x04, 0x5c, 0x2d, 0x50, 0x52, 0x2d,
|
||||
0x01, 0x10, 0x2e, 0x05, 0x5c, 0x2f, 0x1d, 0x5e, 0x28, 0x04, 0x10, 0x29,
|
||||
0x19, 0x10, 0x2a, 0x02, 0x0f, 0x2b, 0x00, 0x36, 0xa3, 0xd9, 0x10, 0x2c,
|
||||
0x03, 0x5c, 0x2d, 0x51, 0x10, 0x2e, 0x04, 0x5c, 0x2f, 0x52, 0x52, 0x2f,
|
||||
0x01, 0x10, 0x30, 0x05, 0x5c, 0x31, 0x1e, 0x5e, 0x2a, 0x04, 0x10, 0x2b,
|
||||
0x1a, 0x10, 0x2c, 0x02, 0x0f, 0x2d, 0x00, 0x6d, 0x80, 0x86, 0x10, 0x2e,
|
||||
0x03, 0x5c, 0x2f, 0x4f, 0x10, 0x30, 0x04, 0x5c, 0x31, 0x53, 0x5c, 0x32,
|
||||
0x54, 0x52, 0x31, 0x02, 0x10, 0x32, 0x05, 0x5c, 0x33, 0x1f, 0x5e, 0x2c,
|
||||
0x04, 0x10, 0x2d, 0x1b, 0x10, 0x2e, 0x02, 0x0f, 0x2f, 0x00, 0xda, 0xd8,
|
||||
0xd8, 0x10, 0x30, 0x03, 0x5c, 0x31, 0x55, 0x10, 0x32, 0x04, 0x5c, 0x33,
|
||||
0x56, 0x52, 0x33, 0x01, 0x10, 0x34, 0x05, 0x5c, 0x35, 0x20, 0x5e, 0x2e,
|
||||
0x04, 0x10, 0x2f, 0x1c, 0x10, 0x30, 0x02, 0x0f, 0x31, 0x00, 0x4e, 0x5c,
|
||||
0x61, 0x10, 0x32, 0x03, 0x5c, 0x33, 0x57, 0x10, 0x34, 0x04, 0x5c, 0x35,
|
||||
0x58, 0x5c, 0x36, 0x59, 0x52, 0x35, 0x02, 0x10, 0x36, 0x05, 0x5c, 0x37,
|
||||
0x21, 0x5e, 0x30, 0x04, 0x10, 0x31, 0x1d, 0x10, 0x32, 0x02, 0x0f, 0x33,
|
||||
0x00, 0x6d, 0x80, 0x86, 0x10, 0x34, 0x03, 0x5c, 0x35, 0x5a, 0x10, 0x36,
|
||||
0x04, 0x5c, 0x37, 0x5b, 0x52, 0x37, 0x01, 0x5e, 0x32, 0x03, 0x10, 0x33,
|
||||
0x1e, 0x10, 0x34, 0x02, 0x0f, 0x35, 0x00, 0xda, 0xd8, 0xd8, 0x10, 0x36,
|
||||
0x03, 0x5c, 0x37, 0x5c, 0x10, 0x38, 0x04, 0x5c, 0x39, 0x5d, 0x52, 0x39,
|
||||
0x01, 0x5e, 0x34, 0x03, 0x10, 0x35, 0x1f, 0x10, 0x36, 0x02, 0x0f, 0x37,
|
||||
0x00, 0xdd, 0x4c, 0x35, 0x10, 0x38, 0x03, 0x5c, 0x39, 0x5e, 0x10, 0x3a,
|
||||
0x04, 0x5c, 0x3b, 0x5f, 0x5c, 0x3c, 0x60, 0x52, 0x3b, 0x02, 0x5e, 0x36,
|
||||
0x03, 0x10, 0x37, 0x20, 0x10, 0x38, 0x02, 0x0f, 0x39, 0x00, 0xf0, 0x50,
|
||||
0x32, 0x10, 0x3a, 0x03, 0x5c, 0x3b, 0x61, 0x10, 0x3c, 0x04, 0x5c, 0x3d,
|
||||
0x62, 0x52, 0x3d, 0x01, 0x5e, 0x38, 0x03, 0x10, 0x39, 0x21, 0x10, 0x3a,
|
||||
0x02, 0x0f, 0x3b, 0x00, 0xf0, 0x50, 0x32, 0x10, 0x3c, 0x03, 0x5c, 0x3d,
|
||||
0x61, 0x10, 0x3e, 0x04, 0x5c, 0x3f, 0x63, 0x52, 0x3f, 0x01, 0x5e, 0x3a,
|
||||
0x03, 0x10, 0x3b, 0x22, 0x10, 0x3c, 0x02, 0x0f, 0x3d, 0x00, 0x9e, 0x9e,
|
||||
0x9e, 0x10, 0x3e, 0x03, 0x5c, 0x3f, 0x64, 0x10, 0x40, 0x04, 0x5c, 0x41,
|
||||
0x65, 0x52, 0x41, 0x01, 0x5e, 0x3c, 0x03, 0x10, 0x3d, 0x23, 0x10, 0x3e,
|
||||
0x02, 0x0f, 0x3f, 0x00, 0x6d, 0x80, 0x86, 0x10, 0x40, 0x03, 0x5c, 0x41,
|
||||
0x4f, 0x10, 0x42, 0x04, 0x5c, 0x43, 0x66, 0x52, 0x43, 0x01, 0x5e, 0x3e,
|
||||
0x03, 0x10, 0x3f, 0x24, 0x10, 0x40, 0x02, 0x0f, 0x41, 0x00, 0xff, 0x80,
|
||||
0x87, 0x10, 0x42, 0x03, 0x5c, 0x43, 0x67, 0x10, 0x44, 0x04, 0x5c, 0x45,
|
||||
0x68, 0x52, 0x45, 0x01, 0x10, 0x46, 0x25, 0x5c, 0x47, 0x69, 0x52, 0x47,
|
||||
0x01, 0x10, 0x48, 0x05, 0x5c, 0x49, 0x09, 0x5e, 0x40, 0x05, 0x10, 0x41,
|
||||
0x26, 0x10, 0x42, 0x02, 0x0f, 0x43, 0x00, 0x4d, 0x5a, 0x5e, 0x10, 0x44,
|
||||
0x03, 0x5c, 0x45, 0x6a, 0x10, 0x46, 0x04, 0x5c, 0x47, 0x6b, 0x52, 0x47,
|
||||
0x01, 0x10, 0x48, 0x25, 0x5c, 0x49, 0x6c, 0x5c, 0x4a, 0x6d, 0x52, 0x49,
|
||||
0x02, 0x10, 0x4a, 0x05, 0x5c, 0x4b, 0x0b, 0x5e, 0x42, 0x05, 0x10, 0x43,
|
||||
0x27, 0x10, 0x44, 0x02, 0x0f, 0x45, 0x00, 0x6d, 0x80, 0x86, 0x10, 0x46,
|
||||
0x03, 0x5c, 0x47, 0x6e, 0x10, 0x48, 0x04, 0x52, 0x49, 0x00, 0x5e, 0x44,
|
||||
0x03, 0x5e, 0x01, 0x22, 0x1a, 0x01, 0x28, 0x10, 0x01, 0x27, 0x10, 0x02,
|
||||
0x29, 0x0f, 0x03, 0x00, 0xee, 0xee, 0xee, 0x5e, 0x02, 0x01, 0x10, 0x03,
|
||||
0x2a, 0x10, 0x04, 0x29, 0x0f, 0x05, 0x00, 0x7d, 0xcf, 0xff, 0x5e, 0x04,
|
||||
0x01, 0x10, 0x05, 0x2b, 0x10, 0x06, 0x29, 0x0f, 0x07, 0x00, 0xef, 0x51,
|
||||
0x68, 0x5e, 0x06, 0x01, 0x10, 0x07, 0x2c, 0x10, 0x08, 0x29, 0x0f, 0x09,
|
||||
0x00, 0xaa, 0xaa, 0xaa, 0x10, 0x0a, 0x2d, 0x13, 0x0b, 0x5e, 0x08, 0x02,
|
||||
0x10, 0x09, 0x2e, 0x10, 0x0a, 0x29, 0x0f, 0x0b, 0x00, 0xaa, 0xd9, 0x4c,
|
||||
0x5e, 0x0a, 0x01, 0x10, 0x0b, 0x2f, 0x10, 0x0c, 0x29, 0x0f, 0x0d, 0x00,
|
||||
0x7d, 0xcf, 0xff, 0x5e, 0x0c, 0x01, 0x10, 0x0d, 0x30, 0x10, 0x0e, 0x29,
|
||||
0x0f, 0x0f, 0x00, 0x7d, 0xcf, 0xff, 0x5e, 0x0e, 0x01, 0x10, 0x0f, 0x31,
|
||||
0x10, 0x10, 0x29, 0x0f, 0x11, 0x00, 0xd2, 0xa6, 0xff, 0x5e, 0x10, 0x01,
|
||||
0x10, 0x11, 0x32, 0x10, 0x12, 0x29, 0x0f, 0x13, 0x00, 0xe6, 0xc0, 0x8a,
|
||||
0x5e, 0x12, 0x01, 0x10, 0x13, 0x33, 0x10, 0x14, 0x29, 0x0f, 0x15, 0x00,
|
||||
0x7a, 0xe9, 0x3c, 0x5e, 0x14, 0x01, 0x10, 0x15, 0x34, 0x10, 0x16, 0x29,
|
||||
0x0f, 0x17, 0x00, 0xef, 0x51, 0x68, 0x5e, 0x16, 0x01, 0x10, 0x17, 0x35,
|
||||
0x10, 0x18, 0x29, 0x0f, 0x19, 0x00, 0xff, 0xaf, 0x70, 0x5e, 0x18, 0x01,
|
||||
0x10, 0x19, 0x36, 0x10, 0x1a, 0x29, 0x0f, 0x1b, 0x00, 0xff, 0x8f, 0x40,
|
||||
0x5e, 0x1a, 0x01, 0x10, 0x1b, 0x37, 0x10, 0x1c, 0x29, 0x0f, 0x1d, 0x00,
|
||||
0xf0, 0x71, 0x78, 0x5e, 0x1c, 0x01, 0x10, 0x1d, 0x38, 0x10, 0x1e, 0x29,
|
||||
0x0f, 0x1f, 0x00, 0xff, 0xff, 0xff, 0x10, 0x20, 0x2d, 0x13, 0x21, 0x5e,
|
||||
0x1e, 0x02, 0x10, 0x1f, 0x39, 0x10, 0x20, 0x29, 0x0f, 0x21, 0x00, 0xff,
|
||||
0xaf, 0x70, 0x5e, 0x20, 0x01, 0x10, 0x21, 0x3a, 0x10, 0x22, 0x29, 0x0f,
|
||||
0x23, 0x00, 0xf0, 0x71, 0x78, 0x5e, 0x22, 0x01, 0x10, 0x23, 0x3b, 0x10,
|
||||
0x24, 0x29, 0x0f, 0x25, 0x00, 0x7d, 0xcf, 0xff, 0x5e, 0x24, 0x01, 0x10,
|
||||
0x25, 0x3c, 0x10, 0x26, 0x29, 0x0f, 0x27, 0x00, 0x95, 0xe6, 0xcb, 0x5e,
|
||||
0x26, 0x01, 0x10, 0x27, 0x3d, 0x10, 0x28, 0x29, 0x0f, 0x29, 0x00, 0xf0,
|
||||
0x71, 0x78, 0x5e, 0x28, 0x01, 0x10, 0x29, 0x3e, 0x10, 0x2a, 0x29, 0x0f,
|
||||
0x2b, 0x00, 0x7d, 0xcf, 0xff, 0x5e, 0x2a, 0x01, 0x10, 0x2b, 0x3f, 0x10,
|
||||
0x2c, 0x29, 0x0f, 0x2d, 0x00, 0xff, 0x8f, 0x40, 0x5e, 0x2c, 0x01, 0x10,
|
||||
0x2d, 0x40, 0x10, 0x2e, 0x29, 0x0f, 0x2f, 0x00, 0xd2, 0xa6, 0xff, 0x5e,
|
||||
0x2e, 0x01, 0x10, 0x2f, 0x41, 0x10, 0x30, 0x29, 0x0f, 0x31, 0x00, 0xd2,
|
||||
0xa6, 0xff, 0x5e, 0x30, 0x01, 0x10, 0x31, 0x42, 0x10, 0x32, 0x29, 0x0f,
|
||||
0x33, 0x00, 0xff, 0xaf, 0xaf, 0x5e, 0x32, 0x01, 0x10, 0x33, 0x43, 0x10,
|
||||
0x34, 0x29, 0x0f, 0x35, 0x00, 0xff, 0xff, 0x00, 0x5e, 0x34, 0x01, 0x10,
|
||||
0x35, 0x44, 0x10, 0x36, 0x29, 0x0f, 0x37, 0x00, 0x0f, 0xff, 0x0f, 0x5e,
|
||||
0x36, 0x01, 0x10, 0x37, 0x45, 0x10, 0x38, 0x29, 0x0f, 0x39, 0x00, 0xff,
|
||||
0x0f, 0x0f, 0x5e, 0x38, 0x01, 0x5e, 0x01, 0x1c, 0x1a, 0x01, 0x46, 0x10,
|
||||
0x01, 0x47, 0x1a, 0x01, 0x48, 0x5e, 0x01, 0x00, 0x1a, 0x01, 0x49, 0x5e,
|
||||
0x01, 0x00, 0x1a, 0x01, 0x4a, 0x5e, 0x01, 0x00, 0x1a, 0x01, 0x4b, 0x11,
|
||||
0x01, 0x1a, 0x01, 0x4c, 0x11, 0x01, 0x1a, 0x01, 0x4d, 0x62, 0x02, 0x00,
|
||||
0x31, 0x01, 0x4e, 0x00, 0x1a, 0x01, 0x4f, 0x62, 0x02, 0x01, 0x31, 0x01,
|
||||
0x4e, 0x00, 0x1a, 0x01, 0x50, 0x62, 0x02, 0x02, 0x31, 0x01, 0x4e, 0x00,
|
||||
0x1a, 0x01, 0x51, 0x62, 0x02, 0x03, 0x31, 0x01, 0x4e, 0x00, 0x1a, 0x01,
|
||||
0x52, 0x12, 0x01, 0x6f, 0x01, 0x69, 0x01, 0x04, 0x3d, 0x00, 0x00, 0x6f,
|
||||
0x00, 0x00, 0x06, 0x63, 0x6c, 0x61, 0x6e, 0x67, 0x64, 0x00, 0x00, 0x00,
|
||||
0x12, 0x2d, 0x2d, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e,
|
||||
0x64, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x00, 0x00, 0x00, 0x0c, 0x2d,
|
||||
0x2d, 0x63, 0x6c, 0x61, 0x6e, 0x67, 0x2d, 0x74, 0x69, 0x64, 0x79, 0x00,
|
||||
0x00, 0x00, 0x1b, 0x2d, 0x2d, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x2d, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x3d, 0x64, 0x65,
|
||||
0x74, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x00, 0x00, 0x00, 0x18, 0x2d, 0x2d,
|
||||
0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2d, 0x69, 0x6e, 0x73, 0x65, 0x72,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x6e, 0x65, 0x76, 0x65, 0x72, 0x00, 0x00,
|
||||
0x00, 0x14, 0x2d, 0x2d, 0x70, 0x63, 0x68, 0x2d, 0x73, 0x74, 0x6f, 0x72,
|
||||
0x61, 0x67, 0x65, 0x3d, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x00, 0x00,
|
||||
0x00, 0x12, 0x2d, 0x2d, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x2d, 0x72, 0x65,
|
||||
0x73, 0x75, 0x6c, 0x74, 0x73, 0x3d, 0x35, 0x30, 0x00, 0x00, 0x00, 0x0b,
|
||||
0x2d, 0x2d, 0x6c, 0x6f, 0x67, 0x3d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x00,
|
||||
0x00, 0x00, 0x08, 0x72, 0x75, 0x62, 0x79, 0x2d, 0x6c, 0x73, 0x70, 0x00,
|
||||
0x00, 0x00, 0x0a, 0x73, 0x6f, 0x6c, 0x61, 0x72, 0x67, 0x72, 0x61, 0x70,
|
||||
0x68, 0x00, 0x00, 0x00, 0x05, 0x73, 0x74, 0x64, 0x69, 0x6f, 0x00, 0x00,
|
||||
0x00, 0x14, 0x62, 0x61, 0x73, 0x68, 0x2d, 0x6c, 0x61, 0x6e, 0x67, 0x75,
|
||||
0x61, 0x67, 0x65, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x00, 0x00,
|
||||
0x00, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x00, 0x00, 0x00, 0x1a, 0x76,
|
||||
0x73, 0x63, 0x6f, 0x64, 0x65, 0x2d, 0x63, 0x73, 0x73, 0x2d, 0x6c, 0x61,
|
||||
0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65,
|
||||
0x72, 0x00, 0x00, 0x00, 0x07, 0x2d, 0x2d, 0x73, 0x74, 0x64, 0x69, 0x6f,
|
||||
0x00, 0x00, 0x00, 0x1b, 0x76, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x2d, 0x6a,
|
||||
0x73, 0x6f, 0x6e, 0x2d, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65,
|
||||
0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x00, 0x00, 0x00, 0x08, 0x66,
|
||||
0x69, 0x73, 0x68, 0x2d, 0x6c, 0x73, 0x70, 0x00, 0x00, 0x00, 0x05, 0x67,
|
||||
0x6f, 0x70, 0x6c, 0x73, 0x00, 0x00, 0x00, 0x05, 0x73, 0x65, 0x72, 0x76,
|
||||
0x65, 0x00, 0x00, 0x00, 0x17, 0x68, 0x61, 0x73, 0x6b, 0x65, 0x6c, 0x6c,
|
||||
0x2d, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x2d, 0x73, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x00, 0x00, 0x00, 0x03, 0x6c, 0x73, 0x70, 0x00,
|
||||
0x00, 0x00, 0x15, 0x65, 0x6d, 0x6d, 0x65, 0x74, 0x2d, 0x6c, 0x61, 0x6e,
|
||||
0x67, 0x75, 0x61, 0x67, 0x65, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
|
||||
0x00, 0x00, 0x00, 0x1a, 0x74, 0x79, 0x70, 0x65, 0x73, 0x63, 0x72, 0x69,
|
||||
0x70, 0x74, 0x2d, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x2d,
|
||||
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x00, 0x00, 0x00, 0x13, 0x6c, 0x75,
|
||||
0x61, 0x2d, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x2d, 0x73,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x00, 0x00, 0x00, 0x12, 0x70, 0x79, 0x72,
|
||||
0x69, 0x67, 0x68, 0x74, 0x2d, 0x6c, 0x61, 0x6e, 0x67, 0x73, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x00, 0x00, 0x00, 0x0d, 0x72, 0x75, 0x73, 0x74, 0x2d,
|
||||
0x61, 0x6e, 0x61, 0x6c, 0x79, 0x7a, 0x65, 0x72, 0x00, 0x00, 0x00, 0x0c,
|
||||
0x69, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x68, 0x65, 0x6e, 0x73, 0x65,
|
||||
0x00, 0x00, 0x00, 0x08, 0x6d, 0x61, 0x72, 0x6b, 0x73, 0x6d, 0x61, 0x6e,
|
||||
0x00, 0x00, 0x00, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x00, 0x00,
|
||||
0x00, 0x15, 0x6e, 0x67, 0x69, 0x6e, 0x78, 0x2d, 0x6c, 0x61, 0x6e, 0x67,
|
||||
0x75, 0x61, 0x67, 0x65, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x00,
|
||||
0x00, 0x00, 0x05, 0x74, 0x61, 0x70, 0x6c, 0x6f, 0x00, 0x00, 0x00, 0x14,
|
||||
0x79, 0x61, 0x6d, 0x6c, 0x2d, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67,
|
||||
0x65, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x00, 0x00, 0x00, 0x04,
|
||||
0x73, 0x71, 0x6c, 0x73, 0x00, 0x00, 0x00, 0x14, 0x6d, 0x61, 0x6b, 0x65,
|
||||
0x2d, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x2d, 0x73, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x00, 0x00, 0x00, 0x13, 0x73, 0x71, 0x6c, 0x2d,
|
||||
0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x2d, 0x73, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x00, 0x00, 0x00, 0x02, 0x75, 0x70, 0x00, 0x00, 0x00,
|
||||
0x08, 0x2d, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x00, 0x00, 0x00,
|
||||
0x04, 0xee, 0x98, 0x9e, 0x20, 0x00, 0x00, 0x00, 0x01, 0x63, 0x00, 0x00,
|
||||
0x00, 0x04, 0xee, 0x98, 0x9d, 0x20, 0x00, 0x00, 0x00, 0x03, 0x63, 0x70,
|
||||
0x70, 0x00, 0x00, 0x00, 0x02, 0x63, 0x63, 0x00, 0x00, 0x00, 0x03, 0x63,
|
||||
0x78, 0x78, 0x00, 0x00, 0x00, 0x04, 0xef, 0x83, 0xbd, 0x20, 0x00, 0x00,
|
||||
0x00, 0x01, 0x68, 0x00, 0x00, 0x00, 0x03, 0x68, 0x70, 0x70, 0x00, 0x00,
|
||||
0x00, 0x04, 0xee, 0x9a, 0xb8, 0x20, 0x00, 0x00, 0x00, 0x03, 0x63, 0x73,
|
||||
0x73, 0x00, 0x00, 0x00, 0x04, 0xee, 0xb9, 0x81, 0x20, 0x00, 0x00, 0x00,
|
||||
0x04, 0x66, 0x69, 0x73, 0x68, 0x00, 0x00, 0x00, 0x04, 0xee, 0x98, 0xa7,
|
||||
0x20, 0x00, 0x00, 0x00, 0x02, 0x67, 0x6f, 0x00, 0x00, 0x00, 0x03, 0x6d,
|
||||
0x6f, 0x64, 0x00, 0x00, 0x00, 0x04, 0xee, 0x9d, 0xb7, 0x20, 0x00, 0x00,
|
||||
0x00, 0x02, 0x68, 0x73, 0x00, 0x00, 0x00, 0x03, 0x6c, 0x68, 0x73, 0x00,
|
||||
0x00, 0x00, 0x04, 0xef, 0x84, 0xa1, 0x20, 0x00, 0x00, 0x00, 0x04, 0x68,
|
||||
0x74, 0x6d, 0x6c, 0x00, 0x00, 0x00, 0x03, 0x68, 0x74, 0x6d, 0x00, 0x00,
|
||||
0x00, 0x04, 0xef, 0x8b, 0xaf, 0x20, 0x00, 0x00, 0x00, 0x02, 0x6a, 0x73,
|
||||
0x00, 0x00, 0x00, 0x04, 0xee, 0x9a, 0x9d, 0x20, 0x00, 0x00, 0x00, 0x02,
|
||||
0x74, 0x73, 0x00, 0x00, 0x00, 0x02, 0x7b, 0x7d, 0x00, 0x00, 0x00, 0x04,
|
||||
0x6a, 0x73, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x05, 0x6a, 0x73, 0x6f, 0x6e,
|
||||
0x63, 0x00, 0x00, 0x00, 0x03, 0x65, 0x72, 0x62, 0x00, 0x00, 0x00, 0x05,
|
||||
0xf3, 0xb0, 0xa2, 0xb1, 0x20, 0x00, 0x00, 0x00, 0x03, 0x6c, 0x75, 0x61,
|
||||
0x00, 0x00, 0x00, 0x05, 0xf3, 0xb0, 0x8c, 0xa0, 0x20, 0x00, 0x00, 0x00,
|
||||
0x02, 0x70, 0x79, 0x00, 0x00, 0x00, 0x07, 0x70, 0x79, 0x72, 0x69, 0x67,
|
||||
0x68, 0x74, 0x00, 0x00, 0x00, 0x05, 0xf3, 0xb1, 0x98, 0x97, 0x20, 0x00,
|
||||
0x00, 0x00, 0x02, 0x72, 0x73, 0x00, 0x00, 0x00, 0x05, 0xf3, 0xb0, 0x8c,
|
||||
0x9f, 0x20, 0x00, 0x00, 0x00, 0x03, 0x70, 0x68, 0x70, 0x00, 0x00, 0x00,
|
||||
0x04, 0xee, 0xba, 0xab, 0x20, 0x00, 0x00, 0x00, 0x02, 0x6d, 0x64, 0x00,
|
||||
0x00, 0x00, 0x08, 0x6d, 0x61, 0x72, 0x6b, 0x64, 0x6f, 0x77, 0x6e, 0x00,
|
||||
0x00, 0x00, 0x04, 0xee, 0x98, 0x95, 0x20, 0x00, 0x00, 0x00, 0x04, 0x63,
|
||||
0x6f, 0x6e, 0x66, 0x00, 0x00, 0x00, 0x04, 0xee, 0x9a, 0xb2, 0x20, 0x00,
|
||||
0x00, 0x00, 0x04, 0x74, 0x6f, 0x6d, 0x6c, 0x00, 0x00, 0x00, 0x03, 0x79,
|
||||
0x6d, 0x6c, 0x00, 0x00, 0x00, 0x04, 0x79, 0x61, 0x6d, 0x6c, 0x00, 0x00,
|
||||
0x00, 0x04, 0xee, 0x99, 0x8d, 0x20, 0x00, 0x00, 0x00, 0x03, 0x73, 0x71,
|
||||
0x6c, 0x00, 0x00, 0x00, 0x04, 0xee, 0x99, 0xb3, 0x20, 0x00, 0x00, 0x00,
|
||||
0x08, 0x4d, 0x61, 0x6b, 0x65, 0x66, 0x69, 0x6c, 0x65, 0x00, 0x00, 0x00,
|
||||
0x08, 0x6d, 0x61, 0x6b, 0x65, 0x66, 0x69, 0x6c, 0x65, 0x00, 0x00, 0x00,
|
||||
0x04, 0xee, 0x99, 0x9f, 0x20, 0x00, 0x00, 0x00, 0x02, 0x67, 0x64, 0x00,
|
||||
0x00, 0x00, 0x04, 0xef, 0x80, 0xad, 0x20, 0x00, 0x00, 0x00, 0x03, 0x6d,
|
||||
0x61, 0x6e, 0x00, 0x00, 0x00, 0x04, 0xee, 0x9c, 0xa8, 0x20, 0x00, 0x00,
|
||||
0x00, 0x04, 0x64, 0x69, 0x66, 0x66, 0x00, 0x00, 0x00, 0x05, 0x70, 0x61,
|
||||
0x74, 0x63, 0x68, 0x00, 0x00, 0x00, 0x04, 0xee, 0x99, 0x9d, 0x20, 0x00,
|
||||
0x00, 0x00, 0x0d, 0x67, 0x69, 0x74, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62,
|
||||
0x75, 0x74, 0x65, 0x73, 0x00, 0x00, 0x00, 0x09, 0x67, 0x69, 0x74, 0x69,
|
||||
0x67, 0x6e, 0x6f, 0x72, 0x65, 0x00, 0x00, 0x00, 0x02, 0x2e, 0x2a, 0x00,
|
||||
0x00, 0x00, 0x05, 0x72, 0x65, 0x67, 0x65, 0x78, 0x00, 0x00, 0x00, 0x03,
|
||||
0x69, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x05, 0xf3, 0xb0, 0xb4, 0xad, 0x20,
|
||||
0x00, 0x00, 0x00, 0x02, 0x72, 0x62, 0x00, 0x00, 0x00, 0x07, 0x47, 0x65,
|
||||
0x6d, 0x66, 0x69, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x04, 0xee, 0xaf, 0x8a,
|
||||
0x20, 0x00, 0x00, 0x00, 0x02, 0x73, 0x68, 0x00, 0x00, 0x00, 0x0c, 0x62,
|
||||
0x61, 0x73, 0x68, 0x5f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x00,
|
||||
0x00, 0x00, 0x06, 0x62, 0x61, 0x73, 0x68, 0x72, 0x63, 0x00, 0x00, 0x00,
|
||||
0x05, 0xf3, 0xb0, 0x88, 0x9a, 0x20, 0x00, 0x00, 0x53, 0x00, 0x0b, 0x40,
|
||||
0x6c, 0x73, 0x70, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x00, 0x00,
|
||||
0x01, 0x63, 0x00, 0x00, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00,
|
||||
0x06, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x00, 0x00, 0x0a, 0x65, 0x78,
|
||||
0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x00, 0x00, 0x03, 0x6c,
|
||||
0x73, 0x70, 0x00, 0x00, 0x03, 0x63, 0x70, 0x70, 0x00, 0x00, 0x01, 0x68,
|
||||
0x00, 0x00, 0x03, 0x63, 0x73, 0x73, 0x00, 0x00, 0x04, 0x66, 0x69, 0x73,
|
||||
0x68, 0x00, 0x00, 0x02, 0x67, 0x6f, 0x00, 0x00, 0x05, 0x67, 0x6f, 0x6d,
|
||||
0x6f, 0x64, 0x00, 0x00, 0x07, 0x68, 0x61, 0x73, 0x6b, 0x65, 0x6c, 0x6c,
|
||||
0x00, 0x00, 0x04, 0x68, 0x74, 0x6d, 0x6c, 0x00, 0x00, 0x0a, 0x6a, 0x61,
|
||||
0x76, 0x61, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x00, 0x00, 0x0a, 0x74,
|
||||
0x79, 0x70, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x00, 0x00, 0x04,
|
||||
0x6a, 0x73, 0x6f, 0x6e, 0x00, 0x00, 0x05, 0x6a, 0x73, 0x6f, 0x6e, 0x63,
|
||||
0x00, 0x00, 0x03, 0x65, 0x72, 0x62, 0x00, 0x00, 0x03, 0x6c, 0x75, 0x61,
|
||||
0x00, 0x00, 0x06, 0x70, 0x79, 0x74, 0x68, 0x6f, 0x6e, 0x00, 0x00, 0x04,
|
||||
0x72, 0x75, 0x73, 0x74, 0x00, 0x00, 0x03, 0x70, 0x68, 0x70, 0x00, 0x00,
|
||||
0x08, 0x6d, 0x61, 0x72, 0x6b, 0x64, 0x6f, 0x77, 0x6e, 0x00, 0x00, 0x05,
|
||||
0x6e, 0x67, 0x69, 0x6e, 0x78, 0x00, 0x00, 0x04, 0x74, 0x6f, 0x6d, 0x6c,
|
||||
0x00, 0x00, 0x04, 0x79, 0x61, 0x6d, 0x6c, 0x00, 0x00, 0x03, 0x73, 0x71,
|
||||
0x6c, 0x00, 0x00, 0x04, 0x6d, 0x61, 0x6b, 0x65, 0x00, 0x00, 0x08, 0x67,
|
||||
0x64, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x00, 0x00, 0x03, 0x6d, 0x61,
|
||||
0x6e, 0x00, 0x00, 0x04, 0x64, 0x69, 0x66, 0x66, 0x00, 0x00, 0x0d, 0x67,
|
||||
0x69, 0x74, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73,
|
||||
0x00, 0x00, 0x09, 0x67, 0x69, 0x74, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65,
|
||||
0x00, 0x00, 0x05, 0x72, 0x65, 0x67, 0x65, 0x78, 0x00, 0x00, 0x03, 0x69,
|
||||
0x6e, 0x69, 0x00, 0x00, 0x04, 0x72, 0x75, 0x62, 0x79, 0x00, 0x00, 0x09,
|
||||
0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x00, 0x00, 0x04,
|
||||
0x62, 0x61, 0x73, 0x68, 0x00, 0x00, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75,
|
||||
0x6c, 0x74, 0x00, 0x00, 0x0a, 0x40, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61,
|
||||
0x67, 0x65, 0x73, 0x00, 0x00, 0x02, 0x66, 0x67, 0x00, 0x00, 0x07, 0x73,
|
||||
0x68, 0x65, 0x62, 0x61, 0x6e, 0x67, 0x00, 0x00, 0x05, 0x65, 0x72, 0x72,
|
||||
0x6f, 0x72, 0x00, 0x00, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74,
|
||||
0x00, 0x00, 0x06, 0x69, 0x74, 0x61, 0x6c, 0x69, 0x63, 0x00, 0x00, 0x06,
|
||||
0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x06, 0x65, 0x73, 0x63,
|
||||
0x61, 0x70, 0x65, 0x00, 0x00, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70,
|
||||
0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x06, 0x72, 0x65,
|
||||
0x67, 0x65, 0x78, 0x70, 0x00, 0x00, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65,
|
||||
0x72, 0x00, 0x00, 0x04, 0x74, 0x72, 0x75, 0x65, 0x00, 0x00, 0x05, 0x66,
|
||||
0x61, 0x6c, 0x73, 0x65, 0x00, 0x00, 0x04, 0x63, 0x68, 0x61, 0x72, 0x00,
|
||||
0x00, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x00, 0x00, 0x0f,
|
||||
0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x6f, 0x70, 0x65, 0x72, 0x61,
|
||||
0x74, 0x6f, 0x72, 0x00, 0x00, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74,
|
||||
0x6f, 0x72, 0x00, 0x00, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x00, 0x00, 0x04, 0x74, 0x79, 0x70, 0x65, 0x00, 0x00, 0x08, 0x63,
|
||||
0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x00, 0x00, 0x10, 0x76, 0x61,
|
||||
0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e,
|
||||
0x63, 0x65, 0x00, 0x00, 0x0e, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c,
|
||||
0x65, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x00, 0x0a, 0x61, 0x6e,
|
||||
0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x09, 0x64,
|
||||
0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x00, 0x00, 0x05, 0x6c,
|
||||
0x61, 0x62, 0x65, 0x6c, 0x00, 0x00, 0x06, 0x62, 0x72, 0x61, 0x63, 0x65,
|
||||
0x31, 0x00, 0x00, 0x06, 0x62, 0x72, 0x61, 0x63, 0x65, 0x32, 0x00, 0x00,
|
||||
0x06, 0x62, 0x72, 0x61, 0x63, 0x65, 0x33, 0x00, 0x00, 0x06, 0x62, 0x72,
|
||||
0x61, 0x63, 0x65, 0x34, 0x00, 0x00, 0x06, 0x62, 0x72, 0x61, 0x63, 0x65,
|
||||
0x35, 0x00, 0x00, 0x06, 0x40, 0x74, 0x68, 0x65, 0x6d, 0x65, 0x00, 0x00,
|
||||
0x09, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x75, 0x6e, 0x69, 0x78, 0x00, 0x00,
|
||||
0x0d, 0x40, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x65, 0x6e, 0x64, 0x69, 0x6e,
|
||||
0x67, 0x73, 0x00, 0x00, 0x0d, 0x40, 0x6b, 0x65, 0x79, 0x5f, 0x68, 0x61,
|
||||
0x6e, 0x64, 0x6c, 0x65, 0x72, 0x73, 0x00, 0x00, 0x0a, 0x40, 0x6b, 0x65,
|
||||
0x79, 0x5f, 0x62, 0x69, 0x6e, 0x64, 0x73, 0x00, 0x00, 0x0d, 0x40, 0x68,
|
||||
0x69, 0x67, 0x68, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x65, 0x72, 0x73, 0x00,
|
||||
0x00, 0x0a, 0x40, 0x62, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x75, 0x70,
|
||||
0x00, 0x00, 0x0b, 0x40, 0x62, 0x5f, 0x73, 0x68, 0x75, 0x74, 0x64, 0x6f,
|
||||
0x77, 0x6e, 0x00, 0x00, 0x04, 0x70, 0x72, 0x6f, 0x63, 0x00, 0x00, 0x06,
|
||||
0x40, 0x62, 0x5f, 0x62, 0x61, 0x72, 0x00, 0x00, 0x07, 0x40, 0x62, 0x5f,
|
||||
0x63, 0x6f, 0x70, 0x79, 0x00, 0x00, 0x08, 0x40, 0x62, 0x5f, 0x70, 0x61,
|
||||
0x73, 0x74, 0x65, 0x00, 0x00, 0x0e, 0x40, 0x62, 0x5f, 0x66, 0x69, 0x6c,
|
||||
0x65, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x00, 0x00, 0x00, 0x03,
|
||||
0xb4, 0x00, 0x09, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
|
||||
0x7b, 0x39, 0x04, 0x00, 0x00, 0x0f, 0x03, 0x00, 0x82, 0xaa, 0xff, 0x5c,
|
||||
0x04, 0x00, 0x01, 0x09, 0x01, 0x10, 0x0a, 0x00, 0x23, 0x09, 0x10, 0x0a,
|
||||
0x01, 0x01, 0x0b, 0x09, 0x32, 0x0a, 0x02, 0x01, 0x28, 0x0a, 0x00, 0x0c,
|
||||
0x0f, 0x03, 0x00, 0x82, 0xaa, 0xff, 0x5c, 0x04, 0x01, 0x26, 0x00, 0x68,
|
||||
0x10, 0x0a, 0x03, 0x01, 0x0b, 0x09, 0x32, 0x0a, 0x02, 0x01, 0x28, 0x0a,
|
||||
0x00, 0x0c, 0x0f, 0x03, 0x00, 0xff, 0x8f, 0x40, 0x5c, 0x04, 0x02, 0x26,
|
||||
0x00, 0x4e, 0x10, 0x0a, 0x04, 0x01, 0x0b, 0x09, 0x32, 0x0a, 0x02, 0x01,
|
||||
0x28, 0x0a, 0x00, 0x0c, 0x0f, 0x03, 0x00, 0x9a, 0xde, 0x7a, 0x5c, 0x04,
|
||||
0x03, 0x26, 0x00, 0x34, 0x10, 0x0a, 0x05, 0x01, 0x0b, 0x09, 0x32, 0x0a,
|
||||
0x02, 0x01, 0x28, 0x0a, 0x00, 0x0c, 0x0f, 0x03, 0x00, 0xff, 0xd7, 0x00,
|
||||
0x5c, 0x04, 0x04, 0x26, 0x00, 0x1a, 0x10, 0x0a, 0x06, 0x01, 0x0b, 0x09,
|
||||
0x32, 0x0a, 0x02, 0x01, 0x28, 0x0a, 0x00, 0x0c, 0x0f, 0x03, 0x00, 0xf2,
|
||||
0x9c, 0xc3, 0x5c, 0x04, 0x05, 0x26, 0x00, 0x00, 0x1d, 0x09, 0x07, 0x33,
|
||||
0x09, 0x08, 0x10, 0x0a, 0x09, 0x23, 0x09, 0x01, 0x05, 0x09, 0x5c, 0x06,
|
||||
0x06, 0x01, 0x09, 0x01, 0x10, 0x0a, 0x0a, 0x23, 0x09, 0x06, 0x0a, 0x23,
|
||||
0x09, 0x5c, 0x0a, 0x07, 0x4d, 0x09, 0x28, 0x09, 0x00, 0x73, 0x01, 0x09,
|
||||
0x01, 0x10, 0x0a, 0x0a, 0x23, 0x09, 0x08, 0x0a, 0x23, 0x09, 0x5c, 0x0a,
|
||||
0x06, 0x32, 0x09, 0x0b, 0x01, 0x28, 0x09, 0x00, 0x17, 0x1d, 0x09, 0x07,
|
||||
0x33, 0x09, 0x08, 0x01, 0x0a, 0x01, 0x10, 0x0b, 0x0a, 0x23, 0x0a, 0x08,
|
||||
0x0b, 0x23, 0x0a, 0x23, 0x09, 0x01, 0x05, 0x09, 0x01, 0x09, 0x05, 0x29,
|
||||
0x09, 0x00, 0x03, 0x26, 0x00, 0x0e, 0x1d, 0x09, 0x07, 0x33, 0x09, 0x08,
|
||||
0x10, 0x0a, 0x09, 0x23, 0x09, 0x01, 0x05, 0x09, 0x01, 0x09, 0x01, 0x10,
|
||||
0x0a, 0x0a, 0x23, 0x09, 0x07, 0x0a, 0x23, 0x09, 0x5c, 0x0a, 0x06, 0x32,
|
||||
0x09, 0x0b, 0x01, 0x28, 0x09, 0x00, 0x16, 0x1d, 0x09, 0x0c, 0x01, 0x0a,
|
||||
0x01, 0x10, 0x0b, 0x0a, 0x23, 0x0a, 0x07, 0x0b, 0x23, 0x0a, 0x32, 0x09,
|
||||
0x0d, 0x01, 0x01, 0x06, 0x09, 0x5c, 0x09, 0x08, 0x01, 0x0a, 0x04, 0x5d,
|
||||
0x09, 0x5c, 0x0a, 0x08, 0x5d, 0x09, 0x01, 0x0a, 0x01, 0x10, 0x0b, 0x00,
|
||||
0x23, 0x0a, 0x33, 0x0a, 0x0e, 0x33, 0x0a, 0x0f, 0x5d, 0x09, 0x5c, 0x0a,
|
||||
0x09, 0x5d, 0x09, 0x01, 0x0a, 0x05, 0x10, 0x0b, 0x10, 0x23, 0x0a, 0x5d,
|
||||
0x09, 0x5c, 0x0a, 0x08, 0x5d, 0x09, 0x01, 0x0a, 0x06, 0x5d, 0x09, 0x5c,
|
||||
0x0a, 0x0a, 0x5d, 0x09, 0x01, 0x07, 0x09, 0x52, 0x08, 0x00, 0x01, 0x09,
|
||||
0x08, 0x10, 0x0a, 0x11, 0x0f, 0x0b, 0x00, 0x0b, 0x0e, 0x14, 0x10, 0x0c,
|
||||
0x12, 0x01, 0x0d, 0x03, 0x10, 0x0e, 0x13, 0x08, 0x0f, 0x10, 0x10, 0x14,
|
||||
0x06, 0x11, 0x10, 0x12, 0x15, 0x03, 0x13, 0x0a, 0x5e, 0x0a, 0x05, 0x32,
|
||||
0x09, 0x16, 0x01, 0x01, 0x09, 0x08, 0x10, 0x0a, 0x11, 0x01, 0x0b, 0x03,
|
||||
0x10, 0x0c, 0x12, 0x0f, 0x0d, 0x00, 0x33, 0x36, 0x3c, 0x10, 0x0e, 0x14,
|
||||
0x03, 0x0f, 0x0a, 0x10, 0x10, 0x15, 0x07, 0x11, 0x5e, 0x0a, 0x04, 0x32,
|
||||
0x09, 0x16, 0x01, 0x01, 0x09, 0x08, 0x10, 0x0a, 0x11, 0x0f, 0x0b, 0x00,
|
||||
0x33, 0x36, 0x3c, 0x10, 0x0c, 0x12, 0x0f, 0x0d, 0x00, 0x24, 0x27, 0x2d,
|
||||
0x10, 0x0e, 0x14, 0x03, 0x0f, 0x0b, 0x10, 0x10, 0x15, 0x07, 0x11, 0x5e,
|
||||
0x0a, 0x04, 0x32, 0x09, 0x16, 0x01, 0x01, 0x09, 0x08, 0x10, 0x0a, 0x11,
|
||||
0x01, 0x0b, 0x05, 0x10, 0x0c, 0x17, 0x23, 0x0b, 0x10, 0x0c, 0x12, 0x0f,
|
||||
0x0d, 0x00, 0x24, 0x27, 0x2d, 0x10, 0x0e, 0x14, 0x03, 0x0f, 0x0d, 0x10,
|
||||
0x10, 0x15, 0x08, 0x11, 0x5e, 0x0a, 0x04, 0x32, 0x09, 0x16, 0x01, 0x01,
|
||||
0x09, 0x08, 0x10, 0x0a, 0x11, 0x0f, 0x0b, 0x00, 0xce, 0xd4, 0xdf, 0x10,
|
||||
0x0c, 0x12, 0x0f, 0x0d, 0x00, 0x24, 0x27, 0x2d, 0x10, 0x0e, 0x14, 0x03,
|
||||
0x0f, 0x0f, 0x10, 0x10, 0x15, 0x01, 0x11, 0x06, 0x33, 0x11, 0x15, 0x46,
|
||||
0x11, 0x01, 0x5e, 0x0a, 0x04, 0x32, 0x09, 0x16, 0x01, 0x01, 0x09, 0x08,
|
||||
0x10, 0x0a, 0x11, 0x0f, 0x0b, 0x00, 0x24, 0x27, 0x2d, 0x10, 0x0c, 0x12,
|
||||
0x06, 0x0d, 0x10, 0x0e, 0x14, 0x03, 0x0f, 0x0f, 0x01, 0x10, 0x06, 0x33,
|
||||
0x10, 0x15, 0x45, 0x0f, 0x46, 0x0f, 0x01, 0x10, 0x10, 0x15, 0x07, 0x11,
|
||||
0x5e, 0x0a, 0x04, 0x32, 0x09, 0x16, 0x01, 0x10, 0x09, 0x18, 0x01, 0x0a,
|
||||
0x07, 0x10, 0x0b, 0x19, 0x01, 0x0c, 0x08, 0x5e, 0x09, 0x02, 0x3d, 0x09,
|
||||
0x00, 0x0b, 0x00, 0x00, 0x02, 0x20, 0x20, 0x00, 0x00, 0x00, 0x04, 0xee,
|
||||
0x99, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x05, 0xf3, 0xb1, 0x93, 0xa7, 0x20,
|
||||
0x00, 0x00, 0x00, 0x05, 0xf3, 0xb1, 0xa9, 0xa7, 0x20, 0x00, 0x00, 0x00,
|
||||
0x04, 0xef, 0x84, 0xa0, 0x20, 0x00, 0x00, 0x00, 0x04, 0xee, 0xba, 0xa2,
|
||||
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x65, 0x64, 0x69,
|
||||
0x74, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x01, 0x20, 0x00, 0x00, 0x00, 0x08,
|
||||
0x20, 0xee, 0x82, 0xb4, 0xee, 0x82, 0xb4, 0x20, 0x00, 0x00, 0x00, 0x03,
|
||||
0xee, 0x82, 0xb4, 0x00, 0x00, 0x1a, 0x00, 0x04, 0x6d, 0x6f, 0x64, 0x65,
|
||||
0x00, 0x00, 0x06, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x00, 0x00, 0x03,
|
||||
0x3d, 0x3d, 0x3d, 0x00, 0x00, 0x06, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74,
|
||||
0x00, 0x00, 0x06, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x00, 0x00, 0x06,
|
||||
0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x00, 0x00, 0x06, 0x6a, 0x75, 0x6d,
|
||||
0x70, 0x65, 0x72, 0x00, 0x00, 0x01, 0x43, 0x00, 0x00, 0x09, 0x6c, 0x61,
|
||||
0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x73, 0x00, 0x00, 0x07, 0x64, 0x65,
|
||||
0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, 0x00, 0x04, 0x64, 0x61, 0x74, 0x61,
|
||||
0x00, 0x00, 0x02, 0x21, 0x3d, 0x00, 0x00, 0x04, 0x46, 0x69, 0x6c, 0x65,
|
||||
0x00, 0x00, 0x08, 0x62, 0x61, 0x73, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x00,
|
||||
0x00, 0x04, 0x74, 0x6f, 0x5f, 0x73, 0x00, 0x00, 0x06, 0x75, 0x70, 0x63,
|
||||
0x61, 0x73, 0x65, 0x00, 0x00, 0x06, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c,
|
||||
0x00, 0x00, 0x02, 0x66, 0x67, 0x00, 0x00, 0x02, 0x62, 0x67, 0x00, 0x00,
|
||||
0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x00, 0x00, 0x05, 0x73, 0x74, 0x61,
|
||||
0x72, 0x74, 0x00, 0x00, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x00,
|
||||
0x00, 0x02, 0x3c, 0x3c, 0x00, 0x00, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72,
|
||||
0x00, 0x00, 0x04, 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x0a, 0x68, 0x69,
|
||||
0x67, 0x68, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x73, 0x00, 0x00, 0x00, 0x00,
|
||||
0x37, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x10, 0x39, 0x04, 0x00, 0x00, 0x1d, 0x03, 0x00, 0x01, 0x04, 0x01, 0x32,
|
||||
0x03, 0x01, 0x01, 0x3d, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x09, 0x43,
|
||||
0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x00, 0x00, 0x04, 0x63,
|
||||
0x6f, 0x70, 0x79, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x02, 0x00, 0x04,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x39, 0x00, 0x00, 0x00,
|
||||
0x1d, 0x02, 0x00, 0x33, 0x02, 0x01, 0x3d, 0x02, 0x00, 0x00, 0x00, 0x02,
|
||||
0x00, 0x09, 0x43, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x00,
|
||||
0x00, 0x05, 0x70, 0x61, 0x73, 0x74, 0x65, 0x00, 0x00, 0x00, 0x03, 0xc8,
|
||||
0x00, 0x07, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3a,
|
||||
0x39, 0x04, 0x00, 0x00, 0x10, 0x03, 0x00, 0x1d, 0x07, 0x01, 0x01, 0x08,
|
||||
0x01, 0x32, 0x07, 0x02, 0x01, 0x27, 0x07, 0x00, 0x02, 0x3d, 0x03, 0x1d,
|
||||
0x07, 0x01, 0x01, 0x08, 0x01, 0x10, 0x09, 0x03, 0x34, 0x07, 0x04, 0x01,
|
||||
0x33, 0x07, 0x05, 0x01, 0x04, 0x07, 0x01, 0x07, 0x04, 0x5c, 0x08, 0x00,
|
||||
0x32, 0x07, 0x06, 0x01, 0x28, 0x07, 0x00, 0xc7, 0x01, 0x07, 0x04, 0x08,
|
||||
0x08, 0x11, 0x09, 0x64, 0x08, 0x23, 0x07, 0x33, 0x07, 0x07, 0x01, 0x05,
|
||||
0x07, 0x01, 0x07, 0x05, 0x66, 0x08, 0x1f, 0x08, 0x08, 0x5c, 0x09, 0x01,
|
||||
0x32, 0x08, 0x09, 0x01, 0x01, 0x09, 0x07, 0x32, 0x08, 0x0a, 0x01, 0x27,
|
||||
0x08, 0x00, 0x17, 0x66, 0x08, 0x1f, 0x08, 0x08, 0x5c, 0x09, 0x02, 0x32,
|
||||
0x08, 0x09, 0x01, 0x01, 0x09, 0x07, 0x32, 0x08, 0x0a, 0x01, 0x28, 0x08,
|
||||
0x00, 0x06, 0x10, 0x08, 0x0b, 0x26, 0x00, 0x7a, 0x66, 0x08, 0x1f, 0x08,
|
||||
0x08, 0x5c, 0x09, 0x03, 0x32, 0x08, 0x09, 0x01, 0x01, 0x09, 0x07, 0x32,
|
||||
0x08, 0x0a, 0x01, 0x28, 0x08, 0x00, 0x06, 0x10, 0x08, 0x0c, 0x26, 0x00,
|
||||
0x5d, 0x66, 0x08, 0x1f, 0x08, 0x08, 0x5c, 0x09, 0x04, 0x32, 0x08, 0x09,
|
||||
0x01, 0x01, 0x09, 0x07, 0x32, 0x08, 0x0a, 0x01, 0x28, 0x08, 0x00, 0x06,
|
||||
0x10, 0x08, 0x0d, 0x26, 0x00, 0x40, 0x66, 0x08, 0x1f, 0x08, 0x08, 0x5c,
|
||||
0x09, 0x05, 0x32, 0x08, 0x09, 0x01, 0x01, 0x09, 0x07, 0x32, 0x08, 0x0a,
|
||||
0x01, 0x28, 0x08, 0x00, 0x06, 0x10, 0x08, 0x0e, 0x26, 0x00, 0x23, 0x66,
|
||||
0x08, 0x1f, 0x08, 0x08, 0x5c, 0x09, 0x06, 0x32, 0x08, 0x09, 0x01, 0x01,
|
||||
0x09, 0x07, 0x32, 0x08, 0x0a, 0x01, 0x28, 0x08, 0x00, 0x06, 0x10, 0x08,
|
||||
0x0f, 0x26, 0x00, 0x06, 0x10, 0x08, 0x00, 0x26, 0x00, 0x00, 0x01, 0x03,
|
||||
0x08, 0x3d, 0x03, 0x10, 0x07, 0x10, 0x10, 0x08, 0x10, 0x32, 0x07, 0x11,
|
||||
0x01, 0x27, 0x07, 0x00, 0x0a, 0x10, 0x07, 0x10, 0x10, 0x08, 0x12, 0x32,
|
||||
0x07, 0x11, 0x01, 0x28, 0x07, 0x00, 0x02, 0x3d, 0x03, 0x5c, 0x08, 0x07,
|
||||
0x2f, 0x07, 0x13, 0x01, 0x33, 0x07, 0x14, 0x28, 0x07, 0x00, 0x02, 0x3d,
|
||||
0x03, 0x5c, 0x08, 0x08, 0x01, 0x09, 0x01, 0x5d, 0x08, 0x5c, 0x09, 0x09,
|
||||
0x5d, 0x08, 0x2f, 0x07, 0x15, 0x01, 0x33, 0x07, 0x05, 0x01, 0x06, 0x07,
|
||||
0x01, 0x07, 0x06, 0x66, 0x08, 0x1f, 0x08, 0x08, 0x5c, 0x09, 0x0a, 0x32,
|
||||
0x08, 0x09, 0x01, 0x01, 0x09, 0x07, 0x32, 0x08, 0x0a, 0x01, 0x28, 0x08,
|
||||
0x00, 0x06, 0x10, 0x08, 0x0b, 0x26, 0x00, 0xd1, 0x66, 0x08, 0x1f, 0x08,
|
||||
0x08, 0x5c, 0x09, 0x05, 0x32, 0x08, 0x09, 0x01, 0x01, 0x09, 0x07, 0x32,
|
||||
0x08, 0x0a, 0x01, 0x28, 0x08, 0x00, 0x06, 0x10, 0x08, 0x0e, 0x26, 0x00,
|
||||
0xb4, 0x66, 0x08, 0x1f, 0x08, 0x08, 0x5c, 0x09, 0x0b, 0x32, 0x08, 0x09,
|
||||
0x01, 0x01, 0x09, 0x07, 0x32, 0x08, 0x0a, 0x01, 0x28, 0x08, 0x00, 0x06,
|
||||
0x10, 0x08, 0x16, 0x26, 0x00, 0x97, 0x66, 0x08, 0x1f, 0x08, 0x08, 0x5c,
|
||||
0x09, 0x0c, 0x32, 0x08, 0x09, 0x01, 0x01, 0x09, 0x07, 0x32, 0x08, 0x0a,
|
||||
0x01, 0x28, 0x08, 0x00, 0x06, 0x10, 0x08, 0x17, 0x26, 0x00, 0x7a, 0x66,
|
||||
0x08, 0x1f, 0x08, 0x08, 0x5c, 0x09, 0x04, 0x32, 0x08, 0x09, 0x01, 0x01,
|
||||
0x09, 0x07, 0x32, 0x08, 0x0a, 0x01, 0x28, 0x08, 0x00, 0x06, 0x10, 0x08,
|
||||
0x0d, 0x26, 0x00, 0x5d, 0x66, 0x08, 0x1f, 0x08, 0x08, 0x5c, 0x09, 0x0d,
|
||||
0x32, 0x08, 0x09, 0x01, 0x01, 0x09, 0x07, 0x32, 0x08, 0x0a, 0x01, 0x28,
|
||||
0x08, 0x00, 0x06, 0x10, 0x08, 0x18, 0x26, 0x00, 0x40, 0x66, 0x08, 0x1f,
|
||||
0x08, 0x08, 0x5c, 0x09, 0x0e, 0x32, 0x08, 0x09, 0x01, 0x01, 0x09, 0x07,
|
||||
0x32, 0x08, 0x0a, 0x01, 0x28, 0x08, 0x00, 0x06, 0x10, 0x08, 0x19, 0x26,
|
||||
0x00, 0x23, 0x66, 0x08, 0x1f, 0x08, 0x08, 0x5c, 0x09, 0x0f, 0x32, 0x08,
|
||||
0x09, 0x01, 0x01, 0x09, 0x07, 0x32, 0x08, 0x0a, 0x01, 0x28, 0x08, 0x00,
|
||||
0x06, 0x10, 0x08, 0x1a, 0x26, 0x00, 0x06, 0x10, 0x08, 0x00, 0x26, 0x00,
|
||||
0x00, 0x01, 0x03, 0x08, 0x3d, 0x03, 0x00, 0x10, 0x00, 0x00, 0x02, 0x23,
|
||||
0x21, 0x00, 0x00, 0x00, 0x04, 0x62, 0x61, 0x73, 0x68, 0x00, 0x00, 0x00,
|
||||
0x02, 0x73, 0x68, 0x00, 0x00, 0x00, 0x04, 0x66, 0x69, 0x73, 0x68, 0x00,
|
||||
0x00, 0x00, 0x06, 0x70, 0x79, 0x74, 0x68, 0x6f, 0x6e, 0x00, 0x00, 0x00,
|
||||
0x04, 0x72, 0x75, 0x62, 0x79, 0x00, 0x00, 0x00, 0x03, 0x6c, 0x75, 0x61,
|
||||
0x00, 0x00, 0x00, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x14,
|
||||
0x66, 0x69, 0x6c, 0x65, 0x20, 0x2d, 0x2d, 0x6d, 0x69, 0x6d, 0x65, 0x2d,
|
||||
0x74, 0x79, 0x70, 0x65, 0x20, 0x2d, 0x62, 0x20, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0b, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x73, 0x63, 0x72,
|
||||
0x69, 0x70, 0x74, 0x00, 0x00, 0x00, 0x04, 0x64, 0x69, 0x66, 0x66, 0x00,
|
||||
0x00, 0x00, 0x04, 0x68, 0x74, 0x6d, 0x6c, 0x00, 0x00, 0x00, 0x0a, 0x6a,
|
||||
0x61, 0x76, 0x61, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x00, 0x00, 0x00,
|
||||
0x08, 0x6d, 0x61, 0x6b, 0x65, 0x66, 0x69, 0x6c, 0x65, 0x00, 0x00, 0x00,
|
||||
0x03, 0x2d, 0x63, 0x24, 0x00, 0x00, 0x1b, 0x00, 0x07, 0x64, 0x65, 0x66,
|
||||
0x61, 0x75, 0x6c, 0x74, 0x00, 0x00, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x00,
|
||||
0x00, 0x06, 0x65, 0x78, 0x69, 0x73, 0x74, 0x3f, 0x00, 0x00, 0x08, 0x72,
|
||||
0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x00, 0x00, 0x04, 0x6f, 0x70,
|
||||
0x65, 0x6e, 0x00, 0x00, 0x05, 0x63, 0x68, 0x6f, 0x6d, 0x70, 0x00, 0x00,
|
||||
0x0b, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x3f,
|
||||
0x00, 0x00, 0x08, 0x64, 0x6f, 0x77, 0x6e, 0x63, 0x61, 0x73, 0x65, 0x00,
|
||||
0x00, 0x06, 0x52, 0x65, 0x67, 0x65, 0x78, 0x70, 0x00, 0x00, 0x07, 0x63,
|
||||
0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x00, 0x00, 0x03, 0x3d, 0x3d, 0x3d,
|
||||
0x00, 0x00, 0x04, 0x62, 0x61, 0x73, 0x68, 0x00, 0x00, 0x04, 0x66, 0x69,
|
||||
0x73, 0x68, 0x00, 0x00, 0x06, 0x70, 0x79, 0x74, 0x68, 0x6f, 0x6e, 0x00,
|
||||
0x00, 0x04, 0x72, 0x75, 0x62, 0x79, 0x00, 0x00, 0x03, 0x6c, 0x75, 0x61,
|
||||
0x00, 0x00, 0x05, 0x6c, 0x69, 0x6e, 0x75, 0x78, 0x00, 0x00, 0x02, 0x21,
|
||||
0x3d, 0x00, 0x00, 0x03, 0x6d, 0x61, 0x63, 0x00, 0x00, 0x0f, 0x63, 0x6f,
|
||||
0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x5f, 0x65, 0x78, 0x69, 0x73, 0x74, 0x73,
|
||||
0x3f, 0x00, 0x00, 0x01, 0x21, 0x00, 0x00, 0x01, 0x60, 0x00, 0x00, 0x04,
|
||||
0x64, 0x69, 0x66, 0x66, 0x00, 0x00, 0x04, 0x68, 0x74, 0x6d, 0x6c, 0x00,
|
||||
0x00, 0x0a, 0x6a, 0x61, 0x76, 0x61, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
|
||||
0x00, 0x00, 0x08, 0x6d, 0x61, 0x6b, 0x65, 0x66, 0x69, 0x6c, 0x65, 0x00,
|
||||
0x00, 0x01, 0x63, 0x00, 0x00, 0x00, 0x01, 0x6b, 0x00, 0x01, 0x00, 0x0a,
|
||||
0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4e, 0x10, 0x02, 0x00, 0x10,
|
||||
0x03, 0x01, 0x10, 0x04, 0x02, 0x10, 0x05, 0x03, 0x10, 0x06, 0x04, 0x2f,
|
||||
0x01, 0x05, 0x05, 0x10, 0x02, 0x06, 0x10, 0x03, 0x07, 0x10, 0x04, 0x08,
|
||||
0x10, 0x05, 0x09, 0x10, 0x06, 0x0a, 0x10, 0x07, 0x0b, 0x10, 0x08, 0x0c,
|
||||
0x2f, 0x01, 0x0d, 0x07, 0x6b, 0x01, 0x0e, 0x00, 0x6b, 0x01, 0x0f, 0x01,
|
||||
0x6b, 0x01, 0x10, 0x02, 0x6b, 0x01, 0x11, 0x03, 0x6b, 0x01, 0x12, 0x04,
|
||||
0x6b, 0x01, 0x13, 0x05, 0x6b, 0x01, 0x14, 0x06, 0x6b, 0x01, 0x15, 0x07,
|
||||
0x3d, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x05, 0x74, 0x68, 0x65, 0x6d,
|
||||
0x65, 0x00, 0x00, 0x0a, 0x6c, 0x73, 0x70, 0x5f, 0x63, 0x6f, 0x6e, 0x66,
|
||||
0x69, 0x67, 0x00, 0x00, 0x09, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67,
|
||||
0x65, 0x73, 0x00, 0x00, 0x0c, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x65, 0x6e,
|
||||
0x64, 0x69, 0x6e, 0x67, 0x73, 0x00, 0x00, 0x0c, 0x68, 0x69, 0x67, 0x68,
|
||||
0x6c, 0x69, 0x67, 0x68, 0x74, 0x65, 0x72, 0x73, 0x00, 0x00, 0x0d, 0x61,
|
||||
0x74, 0x74, 0x72, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72,
|
||||
0x00, 0x00, 0x09, 0x62, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x75, 0x70,
|
||||
0x00, 0x00, 0x0a, 0x62, 0x5f, 0x73, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77,
|
||||
0x6e, 0x00, 0x00, 0x12, 0x62, 0x5f, 0x65, 0x78, 0x74, 0x72, 0x61, 0x5f,
|
||||
0x68, 0x69, 0x67, 0x68, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x73, 0x00, 0x00,
|
||||
0x05, 0x62, 0x5f, 0x62, 0x61, 0x72, 0x00, 0x00, 0x06, 0x62, 0x5f, 0x63,
|
||||
0x6f, 0x70, 0x79, 0x00, 0x00, 0x07, 0x62, 0x5f, 0x70, 0x61, 0x73, 0x74,
|
||||
0x65, 0x00, 0x00, 0x0d, 0x62, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x64,
|
||||
0x65, 0x74, 0x65, 0x63, 0x74, 0x00, 0x00, 0x0b, 0x61, 0x74, 0x74, 0x72,
|
||||
0x5f, 0x72, 0x65, 0x61, 0x64, 0x65, 0x72, 0x00, 0x00, 0x04, 0x62, 0x61,
|
||||
0x72, 0x3d, 0x00, 0x00, 0x07, 0x73, 0x74, 0x61, 0x72, 0x74, 0x75, 0x70,
|
||||
0x00, 0x00, 0x08, 0x73, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x00,
|
||||
0x00, 0x04, 0x63, 0x6f, 0x70, 0x79, 0x00, 0x00, 0x05, 0x70, 0x61, 0x73,
|
||||
0x74, 0x65, 0x00, 0x00, 0x0b, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x64, 0x65,
|
||||
0x74, 0x65, 0x63, 0x74, 0x00, 0x00, 0x10, 0x65, 0x78, 0x74, 0x72, 0x61,
|
||||
0x5f, 0x68, 0x69, 0x67, 0x68, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x73, 0x00,
|
||||
0x00, 0x04, 0x62, 0x69, 0x6e, 0x64, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00,
|
||||
0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x39,
|
||||
0x00, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x03, 0x02, 0x1a, 0x03, 0x00,
|
||||
0x3d, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x40, 0x62, 0x5f, 0x62,
|
||||
0x61, 0x72, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x03, 0x00, 0x04, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x39, 0x00, 0x00, 0x01, 0x01,
|
||||
0x02, 0x01, 0x01, 0x03, 0x02, 0x1a, 0x03, 0x00, 0x3d, 0x03, 0x00, 0x00,
|
||||
0x00, 0x01, 0x00, 0x0a, 0x40, 0x62, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74,
|
||||
0x75, 0x70, 0x00, 0x00, 0x00, 0x00, 0x31, 0x00, 0x03, 0x00, 0x04, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x39, 0x00, 0x00, 0x01, 0x01,
|
||||
0x02, 0x01, 0x01, 0x03, 0x02, 0x1a, 0x03, 0x00, 0x3d, 0x03, 0x00, 0x00,
|
||||
0x00, 0x01, 0x00, 0x0b, 0x40, 0x62, 0x5f, 0x73, 0x68, 0x75, 0x74, 0x64,
|
||||
0x6f, 0x77, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x03, 0x00, 0x04,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x39, 0x00, 0x00, 0x01,
|
||||
0x01, 0x02, 0x01, 0x01, 0x03, 0x02, 0x1a, 0x03, 0x00, 0x3d, 0x03, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x07, 0x40, 0x62, 0x5f, 0x63, 0x6f, 0x70, 0x79,
|
||||
0x00, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x0f, 0x39, 0x00, 0x00, 0x01, 0x01, 0x02, 0x01,
|
||||
0x01, 0x03, 0x02, 0x1a, 0x03, 0x00, 0x3d, 0x03, 0x00, 0x00, 0x00, 0x01,
|
||||
0x00, 0x08, 0x40, 0x62, 0x5f, 0x70, 0x61, 0x73, 0x74, 0x65, 0x00, 0x00,
|
||||
0x00, 0x00, 0x34, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x0f, 0x39, 0x00, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x03,
|
||||
0x02, 0x1a, 0x03, 0x00, 0x3d, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0e,
|
||||
0x40, 0x62, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x74, 0x65,
|
||||
0x63, 0x74, 0x00, 0x00, 0x00, 0x00, 0x39, 0x00, 0x03, 0x00, 0x04, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x39, 0x00, 0x00, 0x01, 0x01,
|
||||
0x02, 0x01, 0x01, 0x03, 0x02, 0x1a, 0x03, 0x00, 0x3d, 0x03, 0x00, 0x00,
|
||||
0x00, 0x01, 0x00, 0x13, 0x40, 0x62, 0x5f, 0x65, 0x78, 0x74, 0x72, 0x61,
|
||||
0x5f, 0x68, 0x69, 0x67, 0x68, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x73, 0x00,
|
||||
0x00, 0x00, 0x01, 0x43, 0x00, 0x08, 0x00, 0x0b, 0x00, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xc1, 0x39, 0x04, 0x40, 0x01, 0x26, 0x00, 0x06, 0x26,
|
||||
0x00, 0x05, 0x26, 0x00, 0x04, 0x11, 0x02, 0x11, 0x03, 0x01, 0x05, 0x04,
|
||||
0x01, 0x08, 0x01, 0x1d, 0x09, 0x00, 0x32, 0x08, 0x01, 0x01, 0x27, 0x08,
|
||||
0x00, 0x07, 0x01, 0x08, 0x01, 0x53, 0x01, 0x08, 0x01, 0x01, 0x08, 0x02,
|
||||
0x29, 0x08, 0x00, 0x03, 0x26, 0x00, 0x31, 0x12, 0x06, 0x1d, 0x08, 0x02,
|
||||
0x33, 0x08, 0x03, 0x01, 0x07, 0x08, 0x01, 0x08, 0x07, 0x10, 0x09, 0x04,
|
||||
0x62, 0x0a, 0x00, 0x34, 0x08, 0x05, 0x01, 0x30, 0x08, 0x06, 0x28, 0x08,
|
||||
0x00, 0x0d, 0x01, 0x08, 0x07, 0x01, 0x09, 0x05, 0x34, 0x08, 0x07, 0x00,
|
||||
0x26, 0x00, 0x02, 0x11, 0x08, 0x26, 0x00, 0x5b, 0x30, 0x08, 0x06, 0x28,
|
||||
0x08, 0x00, 0x22, 0x01, 0x08, 0x02, 0x1d, 0x09, 0x00, 0x32, 0x08, 0x01,
|
||||
0x01, 0x27, 0x08, 0x00, 0x07, 0x01, 0x08, 0x02, 0x53, 0x02, 0x08, 0x01,
|
||||
0x01, 0x08, 0x01, 0x62, 0x09, 0x01, 0x34, 0x08, 0x08, 0x00, 0x26, 0x00,
|
||||
0x32, 0x01, 0x08, 0x03, 0x1d, 0x09, 0x09, 0x32, 0x08, 0x01, 0x01, 0x28,
|
||||
0x08, 0x00, 0x22, 0x01, 0x08, 0x02, 0x1d, 0x09, 0x00, 0x32, 0x08, 0x01,
|
||||
0x01, 0x27, 0x08, 0x00, 0x07, 0x01, 0x08, 0x02, 0x53, 0x02, 0x08, 0x01,
|
||||
0x01, 0x08, 0x01, 0x62, 0x09, 0x02, 0x34, 0x08, 0x08, 0x00, 0x26, 0x00,
|
||||
0x02, 0x11, 0x08, 0x3d, 0x08, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x05, 0x41,
|
||||
0x72, 0x72, 0x61, 0x79, 0x00, 0x00, 0x05, 0x69, 0x73, 0x5f, 0x61, 0x3f,
|
||||
0x00, 0x00, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x00, 0x00, 0x03,
|
||||
0x6e, 0x65, 0x77, 0x00, 0x00, 0x03, 0x73, 0x65, 0x74, 0x00, 0x00, 0x17,
|
||||
0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x5f, 0x73, 0x69, 0x6e, 0x67, 0x6c,
|
||||
0x65, 0x74, 0x6f, 0x6e, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x00,
|
||||
0x00, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x67, 0x69, 0x76, 0x65,
|
||||
0x6e, 0x3f, 0x00, 0x00, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63,
|
||||
0x65, 0x5f, 0x65, 0x78, 0x65, 0x63, 0x00, 0x00, 0x04, 0x65, 0x61, 0x63,
|
||||
0x68, 0x00, 0x00, 0x06, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x00, 0x00,
|
||||
0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x26, 0x39, 0x04, 0x20, 0x01, 0x26, 0x00, 0x03, 0x26, 0x00,
|
||||
0x02, 0x11, 0x02, 0x01, 0x04, 0x03, 0x21, 0x05, 0x06, 0x00, 0x21, 0x06,
|
||||
0x01, 0x00, 0x01, 0x07, 0x01, 0x01, 0x08, 0x02, 0x01, 0x09, 0x04, 0x34,
|
||||
0x05, 0x00, 0x03, 0x3d, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x62,
|
||||
0x69, 0x6e, 0x64, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x03, 0x00, 0x05,
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x39, 0x04, 0x00, 0x00,
|
||||
0x21, 0x03, 0x02, 0x00, 0x62, 0x04, 0x00, 0x34, 0x03, 0x00, 0x00, 0x3d,
|
||||
0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x65, 0x61, 0x63, 0x68, 0x00,
|
||||
0x00, 0x00, 0x00, 0x87, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x5e, 0x39, 0x04, 0x00, 0x00, 0x19, 0x03, 0x00, 0x21,
|
||||
0x04, 0x01, 0x00, 0x23, 0x03, 0x27, 0x03, 0x00, 0x0f, 0x5e, 0x03, 0x00,
|
||||
0x19, 0x04, 0x00, 0x21, 0x05, 0x01, 0x00, 0x01, 0x06, 0x03, 0x25, 0x04,
|
||||
0x19, 0x03, 0x00, 0x21, 0x04, 0x01, 0x00, 0x23, 0x03, 0x01, 0x04, 0x01,
|
||||
0x23, 0x03, 0x27, 0x03, 0x00, 0x14, 0x52, 0x03, 0x00, 0x19, 0x04, 0x00,
|
||||
0x21, 0x05, 0x01, 0x00, 0x23, 0x04, 0x01, 0x05, 0x01, 0x01, 0x06, 0x03,
|
||||
0x25, 0x04, 0x19, 0x03, 0x00, 0x21, 0x04, 0x01, 0x00, 0x23, 0x03, 0x01,
|
||||
0x04, 0x01, 0x23, 0x03, 0x21, 0x04, 0x05, 0x01, 0x32, 0x03, 0x01, 0x01,
|
||||
0x3d, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0d, 0x40, 0x6b, 0x65, 0x79,
|
||||
0x5f, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x73, 0x00, 0x00, 0x02,
|
||||
0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x03, 0x00, 0x05, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x39, 0x04, 0x00, 0x00, 0x21,
|
||||
0x03, 0x02, 0x00, 0x62, 0x04, 0x00, 0x34, 0x03, 0x00, 0x00, 0x3d, 0x03,
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x65, 0x61, 0x63, 0x68, 0x00, 0x00,
|
||||
0x00, 0x00, 0x84, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x5e, 0x39, 0x04, 0x00, 0x00, 0x19, 0x03, 0x00, 0x21, 0x04,
|
||||
0x01, 0x00, 0x23, 0x03, 0x27, 0x03, 0x00, 0x0f, 0x5e, 0x03, 0x00, 0x19,
|
||||
0x04, 0x00, 0x21, 0x05, 0x01, 0x00, 0x01, 0x06, 0x03, 0x25, 0x04, 0x19,
|
||||
0x03, 0x00, 0x21, 0x04, 0x01, 0x00, 0x23, 0x03, 0x01, 0x04, 0x01, 0x23,
|
||||
0x03, 0x27, 0x03, 0x00, 0x14, 0x52, 0x03, 0x00, 0x19, 0x04, 0x00, 0x21,
|
||||
0x05, 0x01, 0x00, 0x23, 0x04, 0x01, 0x05, 0x01, 0x01, 0x06, 0x03, 0x25,
|
||||
0x04, 0x19, 0x03, 0x00, 0x21, 0x04, 0x01, 0x00, 0x23, 0x03, 0x01, 0x04,
|
||||
0x01, 0x23, 0x03, 0x21, 0x04, 0x03, 0x01, 0x32, 0x03, 0x01, 0x01, 0x3d,
|
||||
0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0a, 0x40, 0x6b, 0x65, 0x79, 0x5f,
|
||||
0x62, 0x69, 0x6e, 0x64, 0x73, 0x00, 0x00, 0x02, 0x3c, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x38, 0x00, 0x01, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x0a, 0x6b, 0x01, 0x00, 0x00, 0x6b, 0x01, 0x01, 0x01, 0x3d,
|
||||
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x10, 0x72, 0x65, 0x71, 0x75, 0x69,
|
||||
0x72, 0x65, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00,
|
||||
0x00, 0x04, 0x6c, 0x6f, 0x61, 0x64, 0x00, 0x00, 0x00, 0x01, 0x07, 0x00,
|
||||
0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0x39,
|
||||
0x04, 0x20, 0x00, 0x26, 0x00, 0x03, 0x26, 0x00, 0x02, 0x11, 0x02, 0x01,
|
||||
0x05, 0x01, 0x5c, 0x06, 0x00, 0x32, 0x05, 0x00, 0x01, 0x27, 0x05, 0x00,
|
||||
0x0b, 0x01, 0x05, 0x01, 0x5c, 0x06, 0x00, 0x45, 0x05, 0x01, 0x01, 0x05,
|
||||
0x1d, 0x05, 0x01, 0x01, 0x06, 0x01, 0x1d, 0x07, 0x01, 0x1d, 0x08, 0x02,
|
||||
0x33, 0x08, 0x03, 0x32, 0x07, 0x04, 0x01, 0x32, 0x05, 0x05, 0x02, 0x01,
|
||||
0x01, 0x05, 0x15, 0x05, 0x06, 0x01, 0x06, 0x01, 0x32, 0x05, 0x07, 0x01,
|
||||
0x28, 0x05, 0x00, 0x01, 0x40, 0x15, 0x05, 0x06, 0x01, 0x06, 0x01, 0x32,
|
||||
0x05, 0x08, 0x01, 0x1d, 0x05, 0x01, 0x01, 0x06, 0x01, 0x32, 0x05, 0x09,
|
||||
0x01, 0x01, 0x04, 0x05, 0x01, 0x06, 0x04, 0x01, 0x07, 0x02, 0x27, 0x07,
|
||||
0x00, 0x03, 0x15, 0x07, 0x0a, 0x01, 0x08, 0x01, 0x2f, 0x05, 0x0b, 0x03,
|
||||
0x3d, 0x05, 0x00, 0x01, 0x00, 0x00, 0x03, 0x2e, 0x72, 0x62, 0x00, 0x00,
|
||||
0x0c, 0x00, 0x09, 0x65, 0x6e, 0x64, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x3f,
|
||||
0x00, 0x00, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x00, 0x00, 0x01, 0x43, 0x00,
|
||||
0x00, 0x0b, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x66, 0x69, 0x6c,
|
||||
0x65, 0x00, 0x00, 0x07, 0x64, 0x69, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x00,
|
||||
0x00, 0x0b, 0x65, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x5f, 0x70, 0x61, 0x74,
|
||||
0x68, 0x00, 0x00, 0x07, 0x24, 0x4c, 0x4f, 0x41, 0x44, 0x45, 0x44, 0x00,
|
||||
0x00, 0x08, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x3f, 0x00, 0x00,
|
||||
0x02, 0x3c, 0x3c, 0x00, 0x00, 0x04, 0x72, 0x65, 0x61, 0x64, 0x00, 0x00,
|
||||
0x09, 0x24, 0x42, 0x49, 0x4e, 0x44, 0x5f, 0x54, 0x4f, 0x50, 0x00, 0x00,
|
||||
0x04, 0x65, 0x76, 0x61, 0x6c, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x00, 0x04,
|
||||
0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x39, 0x04,
|
||||
0x20, 0x00, 0x26, 0x00, 0x03, 0x26, 0x00, 0x02, 0x11, 0x02, 0x01, 0x04,
|
||||
0x01, 0x5c, 0x05, 0x00, 0x32, 0x04, 0x00, 0x01, 0x27, 0x04, 0x00, 0x0b,
|
||||
0x01, 0x04, 0x01, 0x5c, 0x05, 0x00, 0x45, 0x04, 0x01, 0x01, 0x04, 0x1d,
|
||||
0x04, 0x01, 0x01, 0x05, 0x01, 0x1d, 0x06, 0x01, 0x1d, 0x07, 0x02, 0x33,
|
||||
0x07, 0x03, 0x32, 0x06, 0x04, 0x01, 0x32, 0x04, 0x05, 0x02, 0x01, 0x01,
|
||||
0x04, 0x15, 0x04, 0x06, 0x01, 0x05, 0x01, 0x32, 0x04, 0x07, 0x01, 0x01,
|
||||
0x05, 0x01, 0x01, 0x06, 0x02, 0x2f, 0x04, 0x08, 0x02, 0x3d, 0x04, 0x00,
|
||||
0x01, 0x00, 0x00, 0x03, 0x2e, 0x72, 0x62, 0x00, 0x00, 0x09, 0x00, 0x09,
|
||||
0x65, 0x6e, 0x64, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x3f, 0x00, 0x00, 0x04,
|
||||
0x46, 0x69, 0x6c, 0x65, 0x00, 0x00, 0x01, 0x43, 0x00, 0x00, 0x0b, 0x63,
|
||||
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x00, 0x00,
|
||||
0x07, 0x64, 0x69, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x00, 0x00, 0x0b, 0x65,
|
||||
0x78, 0x70, 0x61, 0x6e, 0x64, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x00, 0x00,
|
||||
0x07, 0x24, 0x4c, 0x4f, 0x41, 0x44, 0x45, 0x44, 0x00, 0x00, 0x06, 0x64,
|
||||
0x65, 0x6c, 0x65, 0x74, 0x65, 0x00, 0x00, 0x10, 0x72, 0x65, 0x71, 0x75,
|
||||
0x69, 0x72, 0x65, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65,
|
||||
0x00, 0x4c, 0x56, 0x41, 0x52, 0x00, 0x00, 0x01, 0x78, 0x00, 0x00, 0x00,
|
||||
0x1d, 0x00, 0x03, 0x63, 0x6d, 0x64, 0x00, 0x04, 0x74, 0x65, 0x78, 0x74,
|
||||
0x00, 0x01, 0x66, 0x00, 0x07, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64,
|
||||
0x00, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x00, 0x0a, 0x6d, 0x6f, 0x64, 0x65,
|
||||
0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x0b, 0x6d, 0x6f, 0x64, 0x65,
|
||||
0x5f, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x00, 0x09, 0x6c, 0x61, 0x6e,
|
||||
0x67, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x00, 0x08, 0x66, 0x69, 0x6c, 0x65,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x00, 0x08, 0x73, 0x74, 0x61, 0x72, 0x74, 0x69,
|
||||
0x6e, 0x67, 0x00, 0x0a, 0x68, 0x69, 0x67, 0x68, 0x6c, 0x69, 0x67, 0x68,
|
||||
0x74, 0x73, 0x00, 0x04, 0x74, 0x79, 0x70, 0x65, 0x00, 0x0a, 0x66, 0x69,
|
||||
0x72, 0x73, 0x74, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x00, 0x07, 0x73, 0x68,
|
||||
0x65, 0x62, 0x61, 0x6e, 0x67, 0x00, 0x08, 0x6d, 0x69, 0x6d, 0x65, 0x74,
|
||||
0x79, 0x70, 0x65, 0x00, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x00, 0x05,
|
||||
0x6d, 0x6f, 0x64, 0x65, 0x73, 0x00, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x00,
|
||||
0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x03, 0x61, 0x70, 0x70,
|
||||
0x00, 0x03, 0x64, 0x73, 0x6c, 0x00, 0x01, 0x6b, 0x00, 0x03, 0x61, 0x63,
|
||||
0x74, 0x00, 0x03, 0x62, 0x6c, 0x6b, 0x00, 0x04, 0x6d, 0x6f, 0x64, 0x65,
|
||||
0x00, 0x03, 0x6b, 0x65, 0x79, 0x00, 0x04, 0x70, 0x61, 0x74, 0x68, 0x00,
|
||||
0x04, 0x62, 0x69, 0x6e, 0x64, 0x00, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x00,
|
||||
0x00, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0x00, 0x02, 0xff, 0xff, 0x00,
|
||||
0x02, 0xff, 0xff, 0x00, 0x02, 0xff, 0xff, 0x00, 0x02, 0xff, 0xff, 0x00,
|
||||
0x02, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0x00, 0x03, 0x00,
|
||||
0x04, 0xff, 0xff, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00,
|
||||
0x09, 0x00, 0x0a, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x00, 0x08, 0xff,
|
||||
0xff, 0x00, 0x0b, 0x00, 0x0c, 0x00, 0x0d, 0x00, 0x0e, 0xff, 0xff, 0x00,
|
||||
0x0f, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xff, 0x00,
|
||||
0x0f, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xff, 0x00,
|
||||
0x0f, 0x00, 0x10, 0x00, 0x11, 0x00, 0x12, 0xff, 0xff, 0x00, 0x0f, 0x00,
|
||||
0x13, 0x00, 0x14, 0x00, 0x15, 0x00, 0x16, 0xff, 0xff, 0x00, 0x17, 0x00,
|
||||
0x18, 0xff, 0xff, 0x00, 0x19, 0xff, 0xff, 0x00, 0x18, 0xff, 0xff, 0x00,
|
||||
0x19, 0xff, 0xff, 0x00, 0x1a, 0x00, 0x1b, 0xff, 0xff, 0x00, 0x1c, 0x00,
|
||||
0x1a, 0x00, 0x1b, 0xff, 0xff, 0x45, 0x4e, 0x44, 0x00, 0x00, 0x00, 0x00,
|
||||
0x08
|
||||
};
|
||||
constexpr unsigned int _tmp___crib_precompiled_mrb_len = 11293;
|
||||
@@ -3,74 +3,15 @@
|
||||
|
||||
#include "io/knot.h"
|
||||
#include "io/sysio.h"
|
||||
#include "pch.h"
|
||||
#include "syntax/trie.h"
|
||||
|
||||
struct Trie {
|
||||
struct TrieNode {
|
||||
bool is_word = false;
|
||||
std::array<TrieNode *, 128> children{};
|
||||
TrieNode() { children.fill(nullptr); }
|
||||
};
|
||||
|
||||
Trie() : root(new TrieNode()) {}
|
||||
~Trie() { clear_trie(root); }
|
||||
|
||||
void build(const std::vector<std::string> &words) {
|
||||
for (const auto &word : words) {
|
||||
TrieNode *node = root;
|
||||
for (char c : word) {
|
||||
unsigned char uc = static_cast<unsigned char>(c);
|
||||
if (!node->children[uc])
|
||||
node->children[uc] = new TrieNode();
|
||||
node = node->children[uc];
|
||||
}
|
||||
node->is_word = true;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t match(const char *text, uint32_t pos, uint32_t len,
|
||||
bool (*is_word_char)(char c)) const {
|
||||
const TrieNode *node = root;
|
||||
uint32_t max_len = 0;
|
||||
for (uint32_t i = pos; i < len; ++i) {
|
||||
unsigned char uc = static_cast<unsigned char>(text[i]);
|
||||
if (uc >= 128)
|
||||
return 0;
|
||||
if (!node->children[uc]) {
|
||||
if (node->is_word && !is_word_char(text[i]))
|
||||
return i - pos;
|
||||
break;
|
||||
}
|
||||
node = node->children[uc];
|
||||
if (node->is_word)
|
||||
max_len = i - pos + 1;
|
||||
}
|
||||
if (max_len > 0)
|
||||
if (pos + max_len < len && is_word_char(text[pos + max_len]))
|
||||
return 0;
|
||||
return max_len;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
clear_trie(root);
|
||||
root = new TrieNode();
|
||||
}
|
||||
|
||||
private:
|
||||
TrieNode *root;
|
||||
|
||||
void clear_trie(TrieNode *node) {
|
||||
if (!node)
|
||||
return;
|
||||
for (auto *child : node->children)
|
||||
clear_trie(child);
|
||||
delete node;
|
||||
}
|
||||
};
|
||||
#define MAX_LINES_LOOKAROUND 512
|
||||
|
||||
struct Highlight {
|
||||
uint32_t fg;
|
||||
uint32_t bg;
|
||||
uint8_t flags;
|
||||
uint32_t fg{0xFFFFFF};
|
||||
uint32_t bg{0x000000};
|
||||
uint8_t flags{0};
|
||||
};
|
||||
|
||||
enum struct TokenKind : uint8_t {
|
||||
@@ -90,65 +31,29 @@ const std::unordered_map<std::string, TokenKind> kind_map = {
|
||||
|
||||
extern std::array<Highlight, TOKEN_KIND_COUNT> highlights;
|
||||
|
||||
inline void load_theme(std::string filename) {
|
||||
uint32_t len = 0;
|
||||
char *raw = load_file(filename.c_str(), &len);
|
||||
if (!raw)
|
||||
return;
|
||||
std::string data(raw, len);
|
||||
free(raw);
|
||||
json j = json::parse(data);
|
||||
Highlight default_hl = {0xFFFFFF, 0, 0};
|
||||
if (j.contains("Default")) {
|
||||
auto def = j["Default"];
|
||||
if (def.contains("fg") && def["fg"].is_string())
|
||||
default_hl.fg = HEX(def["fg"]);
|
||||
if (def.contains("bg") && def["bg"].is_string())
|
||||
default_hl.bg = HEX(def["bg"]);
|
||||
if (def.contains("italic") && def["italic"].get<bool>())
|
||||
default_hl.flags |= CF_ITALIC;
|
||||
if (def.contains("bold") && def["bold"].get<bool>())
|
||||
default_hl.flags |= CF_BOLD;
|
||||
if (def.contains("underline") && def["underline"].get<bool>())
|
||||
default_hl.flags |= CF_UNDERLINE;
|
||||
if (def.contains("strikethrough") && def["strikethrough"].get<bool>())
|
||||
default_hl.flags |= CF_STRIKETHROUGH;
|
||||
}
|
||||
for (auto &hl : highlights)
|
||||
hl = default_hl;
|
||||
for (auto &[key, value] : j.items()) {
|
||||
if (key == "Default")
|
||||
continue;
|
||||
auto it = kind_map.find(key);
|
||||
if (it == kind_map.end())
|
||||
continue;
|
||||
Highlight hl = {0xFFFFFF, 0, 0};
|
||||
if (value.contains("fg") && value["fg"].is_string())
|
||||
hl.fg = HEX(value["fg"]);
|
||||
if (value.contains("bg") && value["bg"].is_string())
|
||||
hl.bg = HEX(value["bg"]);
|
||||
if (value.contains("italic") && value["italic"].get<bool>())
|
||||
hl.flags |= CF_ITALIC;
|
||||
if (value.contains("bold") && value["bold"].get<bool>())
|
||||
hl.flags |= CF_BOLD;
|
||||
if (value.contains("underline") && value["underline"].get<bool>())
|
||||
hl.flags |= CF_UNDERLINE;
|
||||
if (value.contains("strikethrough") && value["strikethrough"].get<bool>())
|
||||
hl.flags |= CF_STRIKETHROUGH;
|
||||
highlights[static_cast<uint8_t>(it->second)] = hl;
|
||||
}
|
||||
}
|
||||
|
||||
struct Token {
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
TokenKind type;
|
||||
};
|
||||
|
||||
struct StateBase {
|
||||
virtual ~StateBase() = default;
|
||||
virtual std::unique_ptr<StateBase> clone() const = 0;
|
||||
};
|
||||
|
||||
struct CustomState : StateBase {
|
||||
std::string value;
|
||||
explicit CustomState(std::string v) : value(std::move(v)) {}
|
||||
std::unique_ptr<StateBase> clone() const override {
|
||||
return std::make_unique<CustomState>(value);
|
||||
}
|
||||
};
|
||||
|
||||
struct LineData {
|
||||
std::shared_ptr<void> in_state{nullptr};
|
||||
std::unique_ptr<StateBase> out_state;
|
||||
std::vector<Token> tokens;
|
||||
std::shared_ptr<void> out_state{nullptr};
|
||||
std::unique_ptr<StateBase> in_state;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
490
include/syntax/extras.h
Normal file
490
include/syntax/extras.h
Normal file
@@ -0,0 +1,490 @@
|
||||
#ifndef SYNTAX_EXTRAS_H
|
||||
#define SYNTAX_EXTRAS_H
|
||||
|
||||
#include "io/knot.h"
|
||||
#include "syntax/decl.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
inline static const std::vector<std::pair<std::string, uint32_t>> color_map = {
|
||||
{"AliceBlue", 0xF0F8FF},
|
||||
{"AntiqueWhite", 0xFAEBD7},
|
||||
{"Aqua", 0x00FFFF},
|
||||
{"Aquamarine", 0x7FFFD4},
|
||||
{"Azure", 0xF0FFFF},
|
||||
{"Beige", 0xF5F5DC},
|
||||
{"Bisque", 0xFFE4C4},
|
||||
{"Black", 0x000000},
|
||||
{"BlanchedAlmond", 0xFFEBCD},
|
||||
{"Blue", 0x0000FF},
|
||||
{"BlueViolet", 0x8A2BE2},
|
||||
{"Brown", 0xA52A2A},
|
||||
{"BurlyWood", 0xDEB887},
|
||||
{"CadetBlue", 0x5F9EA0},
|
||||
{"Chartreuse", 0x7FFF00},
|
||||
{"Chocolate", 0xD2691E},
|
||||
{"Coral", 0xFF7F50},
|
||||
{"CornflowerBlue", 0x6495ED},
|
||||
{"Cornsilk", 0xFFF8DC},
|
||||
{"Crimson", 0xDC143C},
|
||||
{"Cyan", 0x00FFFF},
|
||||
{"DarkBlue", 0x00008B},
|
||||
{"DarkCyan", 0x008B8B},
|
||||
{"DarkGoldenRod", 0xB8860B},
|
||||
{"DarkGray", 0xA9A9A9},
|
||||
{"DarkGrey", 0xA9A9A9},
|
||||
{"DarkGreen", 0x006400},
|
||||
{"DarkKhaki", 0xBDB76B},
|
||||
{"DarkMagenta", 0x8B008B},
|
||||
{"DarkOliveGreen", 0x556B2F},
|
||||
{"DarkOrange", 0xFF8C00},
|
||||
{"DarkOrchid", 0x9932CC},
|
||||
{"DarkRed", 0x8B0000},
|
||||
{"DarkSalmon", 0xE9967A},
|
||||
{"DarkSeaGreen", 0x8FBC8F},
|
||||
{"DarkSlateBlue", 0x483D8B},
|
||||
{"DarkSlateGray", 0x2F4F4F},
|
||||
{"DarkSlateGrey", 0x2F4F4F},
|
||||
{"DarkTurquoise", 0x00CED1},
|
||||
{"DarkViolet", 0x9400D3},
|
||||
{"DeepPink", 0xFF1493},
|
||||
{"DeepSkyBlue", 0x00BFFF},
|
||||
{"DimGray", 0x696969},
|
||||
{"DimGrey", 0x696969},
|
||||
{"DodgerBlue", 0x1E90FF},
|
||||
{"FireBrick", 0xB22222},
|
||||
{"FloralWhite", 0xFFFAF0},
|
||||
{"ForestGreen", 0x228B22},
|
||||
{"Fuchsia", 0xFF00FF},
|
||||
{"Gainsboro", 0xDCDCDC},
|
||||
{"GhostWhite", 0xF8F8FF},
|
||||
{"Gold", 0xFFD700},
|
||||
{"GoldenRod", 0xDAA520},
|
||||
{"Gray", 0x808080},
|
||||
{"Grey", 0x808080},
|
||||
{"Green", 0x008000},
|
||||
{"GreenYellow", 0xADFF2F},
|
||||
{"HoneyDew", 0xF0FFF0},
|
||||
{"HotPink", 0xFF69B4},
|
||||
{"IndianRed", 0xCD5C5C},
|
||||
{"Indigo", 0x4B0082},
|
||||
{"Ivory", 0xFFFFF0},
|
||||
{"Khaki", 0xF0E68C},
|
||||
{"Lavender", 0xE6E6FA},
|
||||
{"LavenderBlush", 0xFFF0F5},
|
||||
{"LawnGreen", 0x7CFC00},
|
||||
{"LemonChiffon", 0xFFFACD},
|
||||
{"LightBlue", 0xADD8E6},
|
||||
{"LightCoral", 0xF08080},
|
||||
{"LightCyan", 0xE0FFFF},
|
||||
{"LightGoldenRodYellow", 0xFAFAD2},
|
||||
{"LightGray", 0xD3D3D3},
|
||||
{"LightGrey", 0xD3D3D3},
|
||||
{"LightGreen", 0x90EE90},
|
||||
{"LightPink", 0xFFB6C1},
|
||||
{"LightSalmon", 0xFFA07A},
|
||||
{"LightSeaGreen", 0x20B2AA},
|
||||
{"LightSkyBlue", 0x87CEFA},
|
||||
{"LightSlateGray", 0x778899},
|
||||
{"LightSlateGrey", 0x778899},
|
||||
{"LightSteelBlue", 0xB0C4DE},
|
||||
{"LightYellow", 0xFFFFE0},
|
||||
{"Lime", 0x00FF00},
|
||||
{"LimeGreen", 0x32CD32},
|
||||
{"Linen", 0xFAF0E6},
|
||||
{"Magenta", 0xFF00FF},
|
||||
{"Maroon", 0x800000},
|
||||
{"MediumAquaMarine", 0x66CDAA},
|
||||
{"MediumBlue", 0x0000CD},
|
||||
{"MediumOrchid", 0xBA55D3},
|
||||
{"MediumPurple", 0x9370DB},
|
||||
{"MediumSeaGreen", 0x3CB371},
|
||||
{"MediumSlateBlue", 0x7B68EE},
|
||||
{"MediumSpringGreen", 0x00FA9A},
|
||||
{"MediumTurquoise", 0x48D1CC},
|
||||
{"MediumVioletRed", 0xC71585},
|
||||
{"MidnightBlue", 0x191970},
|
||||
{"MintCream", 0xF5FFFA},
|
||||
{"MistyRose", 0xFFE4E1},
|
||||
{"Moccasin", 0xFFE4B5},
|
||||
{"NavajoWhite", 0xFFDEAD},
|
||||
{"Navy", 0x000080},
|
||||
{"OldLace", 0xFDF5E6},
|
||||
{"Olive", 0x808000},
|
||||
{"OliveDrab", 0x6B8E23},
|
||||
{"Orange", 0xFFA500},
|
||||
{"OrangeRed", 0xFF4500},
|
||||
{"Orchid", 0xDA70D6},
|
||||
{"PaleGoldenRod", 0xEEE8AA},
|
||||
{"PaleGreen", 0x98FB98},
|
||||
{"PaleTurquoise", 0xAFEEEE},
|
||||
{"PaleVioletRed", 0xDB7093},
|
||||
{"PapayaWhip", 0xFFEFD5},
|
||||
{"PeachPuff", 0xFFDAB9},
|
||||
{"Peru", 0xCD853F},
|
||||
{"Pink", 0xFFC0CB},
|
||||
{"Plum", 0xDDA0DD},
|
||||
{"PowderBlue", 0xB0E0E6},
|
||||
{"Purple", 0x800080},
|
||||
{"RebeccaPurple", 0x663399},
|
||||
{"Red", 0xFF0000},
|
||||
{"RosyBrown", 0xBC8F8F},
|
||||
{"RoyalBlue", 0x4169E1},
|
||||
{"SaddleBrown", 0x8B4513},
|
||||
{"Salmon", 0xFA8072},
|
||||
{"SandyBrown", 0xF4A460},
|
||||
{"SeaGreen", 0x2E8B57},
|
||||
{"SeaShell", 0xFFF5EE},
|
||||
{"Sienna", 0xA0522D},
|
||||
{"Silver", 0xC0C0C0},
|
||||
{"SkyBlue", 0x87CEEB},
|
||||
{"SlateBlue", 0x6A5ACD},
|
||||
{"SlateGray", 0x708090},
|
||||
{"SlateGrey", 0x708090},
|
||||
{"Snow", 0xFFFAFA},
|
||||
{"SpringGreen", 0x00FF7F},
|
||||
{"SteelBlue", 0x4682B4},
|
||||
{"Tan", 0xD2B48C},
|
||||
{"Teal", 0x008080},
|
||||
{"Thistle", 0xD8BFD8},
|
||||
{"Tomato", 0xFF6347},
|
||||
{"Turquoise", 0x40E0D0},
|
||||
{"Violet", 0xEE82EE},
|
||||
{"Wheat", 0xF5DEB3},
|
||||
{"White", 0xFFFFFF},
|
||||
{"WhiteSmoke", 0xF5F5F5},
|
||||
{"Yellow", 0xFFFF00},
|
||||
{"YellowGreen", 0x9ACD32},
|
||||
};
|
||||
|
||||
// Add word under cursor to this
|
||||
|
||||
struct ExtraHighlighter {
|
||||
std::vector<uint32_t> colors;
|
||||
std::array<std::vector<uint32_t>, 50> lines;
|
||||
Trie<uint32_t> css_colors = Trie<uint32_t>();
|
||||
uint32_t start = 0;
|
||||
|
||||
ExtraHighlighter() { css_colors.build(color_map, false); }
|
||||
|
||||
void render(Knot *root, uint32_t n_start, std::string word, bool is_css) {
|
||||
start = n_start;
|
||||
for (auto &line : lines)
|
||||
line.clear();
|
||||
LineIterator *it = begin_l_iter(root, start);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t idx = 0;
|
||||
uint32_t len;
|
||||
char *line;
|
||||
while (idx < 50 && (line = next_line(it, &len))) {
|
||||
lines[idx].assign(len, UINT32_MAX - 1);
|
||||
uint32_t i = 0;
|
||||
while (i < len) {
|
||||
if (is_css) {
|
||||
std::optional<uint32_t> color;
|
||||
uint32_t color_len = css_colors.match(
|
||||
line, i, len, [](char c) { return isalnum(c) || c == '_'; },
|
||||
&color);
|
||||
if (color) {
|
||||
for (uint32_t j = 0; j < color_len; j++)
|
||||
lines[idx][i + j] = *color;
|
||||
i += color_len;
|
||||
continue;
|
||||
} else if (i + 5 < len && (line[i] == 'r' || line[i] == 'R') &&
|
||||
(line[i + 1] == 'g' || line[i + 1] == 'G') &&
|
||||
(line[i + 2] == 'b' || line[i + 2] == 'B')) {
|
||||
uint32_t start = i;
|
||||
i += 3;
|
||||
if (line[i] == 'a' || line[i] == 'A')
|
||||
i++;
|
||||
if (line[i] == '(') {
|
||||
i++;
|
||||
bool is_percent = false;
|
||||
std::string r = "";
|
||||
while (i < len && line[i] >= '0' && line[i] <= '9')
|
||||
r += line[i++];
|
||||
if (r.empty())
|
||||
continue;
|
||||
while (i < len &&
|
||||
(line[i] == '.' || (line[i] >= '0' && line[i] <= '9')))
|
||||
i++;
|
||||
if (line[i] == '%') {
|
||||
is_percent = true;
|
||||
i++;
|
||||
}
|
||||
while (i < len && (line[i] == ',' || line[i] == ' '))
|
||||
i++;
|
||||
std::string g = "";
|
||||
while (i < len && line[i] >= '0' && line[i] <= '9')
|
||||
g += line[i++];
|
||||
if (g.empty())
|
||||
continue;
|
||||
while (i < len &&
|
||||
(line[i] == '.' || (line[i] >= '0' && line[i] <= '9')))
|
||||
i++;
|
||||
while (i < len &&
|
||||
(line[i] == ',' || line[i] == ' ' || line[i] == '%'))
|
||||
i++;
|
||||
std::string b = "";
|
||||
while (i < len && line[i] >= '0' && line[i] <= '9')
|
||||
b += line[i++];
|
||||
if (b.empty())
|
||||
continue;
|
||||
while (i < len &&
|
||||
(line[i] == ',' || line[i] == ' ' || line[i] == '.' ||
|
||||
line[i] == '/' || line[i] == '%' ||
|
||||
(line[i] >= '0' && line[i] <= '9')))
|
||||
i++;
|
||||
if (i < len && line[i] == ')')
|
||||
i++;
|
||||
else
|
||||
continue;
|
||||
uint32_t rr, gg, bb;
|
||||
if (is_percent) {
|
||||
rr = std::stoul(r) * 255 / 100;
|
||||
gg = std::stoul(g) * 255 / 100;
|
||||
bb = std::stoul(b) * 255 / 100;
|
||||
} else {
|
||||
rr = std::stoul(r);
|
||||
gg = std::stoul(g);
|
||||
bb = std::stoul(b);
|
||||
}
|
||||
rr = rr > 255 ? 255 : rr;
|
||||
gg = gg > 255 ? 255 : gg;
|
||||
bb = bb > 255 ? 255 : bb;
|
||||
uint32_t color = (rr << 16) | (gg << 8) | bb;
|
||||
for (uint32_t j = start; j < i; j++)
|
||||
lines[idx][j] = color;
|
||||
}
|
||||
continue;
|
||||
} else if (i + 5 < len && (line[i] == 'h' || line[i] == 'H') &&
|
||||
(line[i + 1] == 's' || line[i + 1] == 'S') &&
|
||||
(line[i + 2] == 'l' || line[i + 2] == 'L')) {
|
||||
uint32_t start = i;
|
||||
i += 3;
|
||||
if (line[i] == 'a' || line[i] == 'A')
|
||||
i++;
|
||||
if (line[i] == '(') {
|
||||
i++;
|
||||
std::string h = "";
|
||||
std::string h_unit = "";
|
||||
enum unit : uint8_t { deg, grad, rad, turn };
|
||||
unit u = deg;
|
||||
bool negative = false;
|
||||
if (i < len && (line[i] == '-' || line[i] == '+')) {
|
||||
negative = line[i] == '-';
|
||||
i++;
|
||||
}
|
||||
while (i < len && line[i] >= '0' && line[i] <= '9')
|
||||
h += line[i++];
|
||||
if (i < len && line[i] == '.') {
|
||||
h += '.';
|
||||
while (i < len && line[i] >= '0' && line[i] <= '9')
|
||||
h += line[i++];
|
||||
}
|
||||
if (h.empty())
|
||||
continue;
|
||||
while (i < len && ((line[i] >= 'a' && line[i] <= 'z') ||
|
||||
(line[i] >= 'A' && line[i] <= 'Z')))
|
||||
h_unit += line[i++];
|
||||
for (size_t x = 0; x < h_unit.size(); x++)
|
||||
h_unit[x] = tolower(h_unit[x]);
|
||||
if (h_unit.empty())
|
||||
u = deg;
|
||||
else if (h_unit == "deg")
|
||||
u = deg;
|
||||
else if (h_unit == "grad")
|
||||
u = grad;
|
||||
else if (h_unit == "rad")
|
||||
u = rad;
|
||||
else if (h_unit == "turn")
|
||||
u = turn;
|
||||
else
|
||||
continue;
|
||||
double hue = std::stod(h);
|
||||
if (negative)
|
||||
hue = -hue;
|
||||
switch (u) {
|
||||
case deg:
|
||||
break;
|
||||
case grad:
|
||||
hue = hue * 360.0 / 400.0;
|
||||
break;
|
||||
case rad:
|
||||
hue = hue * 180.0 / M_PI;
|
||||
break;
|
||||
case turn:
|
||||
hue = hue * 360.0;
|
||||
break;
|
||||
}
|
||||
hue = fmod(hue, 360.0);
|
||||
if (hue < 0)
|
||||
hue += 360.0;
|
||||
double h_final = hue / 360.0;
|
||||
while (i < len && (line[i] == ',' || line[i] == ' '))
|
||||
i++;
|
||||
std::string s = "";
|
||||
while (i < len && line[i] >= '0' && line[i] <= '9')
|
||||
s += line[i++];
|
||||
if (s.empty())
|
||||
continue;
|
||||
if (i < len && line[i] == '%')
|
||||
i++;
|
||||
else
|
||||
continue;
|
||||
while (i < len && (line[i] == ',' || line[i] == ' '))
|
||||
i++;
|
||||
std::string l = "";
|
||||
while (i < len && line[i] >= '0' && line[i] <= '9')
|
||||
l += line[i++];
|
||||
if (l.empty())
|
||||
continue;
|
||||
if (i < len && line[i] == '%')
|
||||
i++;
|
||||
else
|
||||
continue;
|
||||
while (i < len &&
|
||||
(line[i] == ',' || line[i] == ' ' || line[i] == '.' ||
|
||||
line[i] == '/' || line[i] == '%' ||
|
||||
(line[i] >= '0' && line[i] <= '9')))
|
||||
i++;
|
||||
if (i < len && line[i] == ')')
|
||||
i++;
|
||||
double s_val = std::stod(s) / 100.0;
|
||||
double l_val = std::stod(l) / 100.0;
|
||||
uint32_t color = hslToRgb(h_final, s_val, l_val);
|
||||
for (uint32_t j = start; j < i; j++)
|
||||
lines[idx][j] = color;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (i + 4 < len && line[i] == '#') {
|
||||
i++;
|
||||
uint32_t start = i;
|
||||
while (i < len && isxdigit(line[i]))
|
||||
i++;
|
||||
uint32_t color = 0;
|
||||
if (is_css && (i - start == 3 || i - start == 4)) {
|
||||
uint32_t r =
|
||||
std::stoul(std::string(line + start, 1), nullptr, 16) * 0x11;
|
||||
uint32_t g =
|
||||
std::stoul(std::string(line + start + 1, 1), nullptr, 16) *
|
||||
0x11;
|
||||
uint32_t b =
|
||||
std::stoul(std::string(line + start + 2, 1), nullptr, 16) *
|
||||
0x11;
|
||||
color = (r << 16) | (g << 8) | b;
|
||||
} else if ((is_css && (i - start == 8)) || i - start == 6) {
|
||||
uint32_t r = std::stoul(std::string(line + start, 2), nullptr, 16);
|
||||
uint32_t g =
|
||||
std::stoul(std::string(line + start + 2, 2), nullptr, 16);
|
||||
uint32_t b =
|
||||
std::stoul(std::string(line + start + 4, 2), nullptr, 16);
|
||||
color = (r << 16) | (g << 8) | b;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
for (uint32_t j = start - 1; j < i; j++)
|
||||
lines[idx][j] = color;
|
||||
continue;
|
||||
} else if (i + 5 < len && line[i] == '0' && line[i + 1] == 'x') {
|
||||
i += 2;
|
||||
uint32_t start = i;
|
||||
while (i < len && isxdigit(line[i]))
|
||||
i++;
|
||||
uint32_t color = 0;
|
||||
if (i - start == 6) {
|
||||
uint32_t r = std::stoul(std::string(line + start, 2), nullptr, 16);
|
||||
uint32_t g =
|
||||
std::stoul(std::string(line + start + 2, 2), nullptr, 16);
|
||||
uint32_t b =
|
||||
std::stoul(std::string(line + start + 4, 2), nullptr, 16);
|
||||
color = (r << 16) | (g << 8) | b;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if (color)
|
||||
color--;
|
||||
else
|
||||
color++;
|
||||
for (uint32_t j = start - 2; j < i; j++)
|
||||
lines[idx][j] = color;
|
||||
continue;
|
||||
}
|
||||
if (i < len && (isalnum(line[i]) || line[i] == '_')) {
|
||||
uint32_t start = i;
|
||||
uint32_t x = 0;
|
||||
bool found = true;
|
||||
while (i < len && (isalnum(line[i]) || line[i] == '_')) {
|
||||
if (x < word.size() && line[i] == word[x]) {
|
||||
i++;
|
||||
x++;
|
||||
} else {
|
||||
found = false;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (found && x == word.size())
|
||||
for (uint32_t j = start; j < i; j++)
|
||||
lines[idx][j] = UINT32_MAX;
|
||||
} else {
|
||||
i += utf8_codepoint_width(line[i]);
|
||||
}
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
}
|
||||
|
||||
std::optional<std::pair<uint32_t, uint32_t>> get(Coord pos) {
|
||||
uint32_t val;
|
||||
if (pos.row < start || pos.row >= start + 50 ||
|
||||
pos.col >= lines[pos.row - start].size() ||
|
||||
(val = lines[pos.row - start][pos.col]) == UINT32_MAX - 1)
|
||||
return std::nullopt;
|
||||
return (std::pair<uint32_t, uint32_t>){fg_for_bg(val), val};
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t fg_for_bg(uint32_t color) {
|
||||
uint8_t r = (color >> 16) & 0xFF;
|
||||
uint8_t g = (color >> 8) & 0xFF;
|
||||
uint8_t b = color & 0xFF;
|
||||
double luminance = 0.299 * r + 0.587 * g + 0.114 * b;
|
||||
return (luminance > 128) ? 0x010101 : 0xFFFFFF;
|
||||
}
|
||||
|
||||
uint32_t hslToRgb(double h, double s, double l) {
|
||||
double r, g, b;
|
||||
if (s == 0.0) {
|
||||
r = g = b = l;
|
||||
} else {
|
||||
auto hue2rgb = [](double p, double q, double t) -> double {
|
||||
if (t < 0)
|
||||
t += 1;
|
||||
if (t > 1)
|
||||
t -= 1;
|
||||
if (t < 1.0 / 6)
|
||||
return p + (q - p) * 6 * t;
|
||||
if (t < 1.0 / 2)
|
||||
return q;
|
||||
if (t < 2.0 / 3)
|
||||
return p + (q - p) * (2.0 / 3 - t) * 6;
|
||||
return p;
|
||||
};
|
||||
double q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
||||
double p = 2 * l - q;
|
||||
r = hue2rgb(p, q, h + 1.0 / 3);
|
||||
g = hue2rgb(p, q, h);
|
||||
b = hue2rgb(p, q, h - 1.0 / 3);
|
||||
}
|
||||
uint32_t R = static_cast<uint32_t>(std::clamp(r, 0.0, 1.0) * 255);
|
||||
uint32_t G = static_cast<uint32_t>(std::clamp(g, 0.0, 1.0) * 255);
|
||||
uint32_t B = static_cast<uint32_t>(std::clamp(b, 0.0, 1.0) * 255);
|
||||
return (R << 16) | (G << 8) | B;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -4,29 +4,19 @@
|
||||
#include "syntax/decl.h"
|
||||
|
||||
#define DEF_LANG(name) \
|
||||
std::shared_ptr<void> name##_parse(std::vector<Token> *tokens, \
|
||||
std::shared_ptr<void> in_state, \
|
||||
const char *text, uint32_t len); \
|
||||
bool name##_state_match(std::shared_ptr<void> state_1, \
|
||||
std::shared_ptr<void> state_2);
|
||||
std::unique_ptr<StateBase> name##_parse( \
|
||||
std::vector<Token> *tokens, StateBase *in_state, const char *text, \
|
||||
uint32_t len, uint32_t line_num); \
|
||||
bool name##_state_match(StateBase *state_1, StateBase *state_2);
|
||||
|
||||
#define LANG_A(name) \
|
||||
{ \
|
||||
#name, { name##_parse, name##_state_match } \
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline std::shared_ptr<T> ensure_state(std::shared_ptr<T> state) {
|
||||
using U = typename T::full_state_type;
|
||||
if (!state)
|
||||
state = std::make_shared<T>();
|
||||
if (!state.unique())
|
||||
state = std::make_shared<T>(*state);
|
||||
if (!state->full_state)
|
||||
state->full_state = std::make_shared<U>();
|
||||
else if (!state->full_state.unique())
|
||||
state->full_state = std::make_shared<U>(*state->full_state);
|
||||
return state;
|
||||
template <typename B, typename A>
|
||||
std::unique_ptr<B> static_unique_ptr_cast(std::unique_ptr<A> &&p) {
|
||||
return std::unique_ptr<B>(static_cast<B *>(p.release()));
|
||||
}
|
||||
|
||||
DEF_LANG(ruby);
|
||||
@@ -34,11 +24,10 @@ DEF_LANG(bash);
|
||||
|
||||
inline static const std::unordered_map<
|
||||
std::string,
|
||||
std::tuple<std::shared_ptr<void> (*)(std::vector<Token> *tokens,
|
||||
std::shared_ptr<void> in_state,
|
||||
const char *text, uint32_t len),
|
||||
bool (*)(std::shared_ptr<void> state_1,
|
||||
std::shared_ptr<void> state_2)>>
|
||||
std::tuple<std::unique_ptr<StateBase> (*)(
|
||||
std::vector<Token> *tokens, StateBase *in_state,
|
||||
const char *text, uint32_t len, uint32_t line_num),
|
||||
bool (*)(StateBase *state_1, StateBase *state_2)>>
|
||||
parsers = {
|
||||
LANG_A(ruby),
|
||||
LANG_A(bash),
|
||||
|
||||
136
include/syntax/line_map.h
Normal file
136
include/syntax/line_map.h
Normal file
@@ -0,0 +1,136 @@
|
||||
#ifndef LINE_MAP_H
|
||||
#define LINE_MAP_H
|
||||
|
||||
#include "syntax/decl.h"
|
||||
|
||||
struct LineKey {
|
||||
uint32_t line;
|
||||
uint32_t version;
|
||||
bool operator==(const LineKey &other) const {
|
||||
return line == other.line && version == other.version;
|
||||
}
|
||||
};
|
||||
|
||||
struct LineKeyHash {
|
||||
size_t operator()(const LineKey &key) const {
|
||||
uint64_t combined = (uint64_t(key.line) << 32) | key.version;
|
||||
return std::hash<uint64_t>()(combined);
|
||||
}
|
||||
};
|
||||
|
||||
struct EditDelta {
|
||||
uint32_t start_line;
|
||||
int64_t delta;
|
||||
};
|
||||
|
||||
struct LineMap {
|
||||
LineMap() : current_version(0) { edit_log.push_back({0, 0}); }
|
||||
|
||||
LineData *at(uint32_t line) {
|
||||
auto key_opt = resolve_line(line);
|
||||
if (!key_opt)
|
||||
return nullptr;
|
||||
LineKey key = *key_opt;
|
||||
if (key.version == current_version)
|
||||
return lines[key].get();
|
||||
auto data_ptr = std::move(lines[key]);
|
||||
lines.erase(key);
|
||||
key = {line, current_version};
|
||||
lines[key] = std::move(data_ptr);
|
||||
return lines[key].get();
|
||||
}
|
||||
|
||||
LineData *create_at(uint32_t line) {
|
||||
auto key_opt = resolve_line(line);
|
||||
LineKey key;
|
||||
std::unique_ptr<LineData> data_ptr;
|
||||
if (key_opt) {
|
||||
key = *key_opt;
|
||||
if (key.version == current_version)
|
||||
return lines[key].get();
|
||||
data_ptr = std::move(lines[key]);
|
||||
lines.erase(key);
|
||||
} else {
|
||||
data_ptr = std::make_unique<LineData>();
|
||||
}
|
||||
key = {line, current_version};
|
||||
lines[key] = std::move(data_ptr);
|
||||
return lines[key].get();
|
||||
}
|
||||
|
||||
void apply_edit(uint32_t start, int64_t delta) {
|
||||
if (delta < 0)
|
||||
batch_remove(start, -delta);
|
||||
current_version++;
|
||||
edit_log.push_back({start, delta});
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<LineKey, std::unique_ptr<LineData>, LineKeyHash> lines;
|
||||
|
||||
std::vector<EditDelta> edit_log;
|
||||
|
||||
uint32_t current_version;
|
||||
|
||||
void batch_remove(uint32_t line, uint32_t count) {
|
||||
std::vector<uint32_t> lines_t;
|
||||
lines_t.reserve(count);
|
||||
for (uint32_t i = 0; i < count; i++)
|
||||
lines_t.push_back(line + i);
|
||||
for (int64_t v = current_version; v >= 0; v--) {
|
||||
for (auto &l : lines_t) {
|
||||
if (l == UINT32_MAX)
|
||||
continue;
|
||||
LineKey key = {l, (uint32_t)v};
|
||||
if (lines.find(key) != lines.end()) {
|
||||
lines.erase(key);
|
||||
l = UINT32_MAX;
|
||||
}
|
||||
}
|
||||
bool all_removed = true;
|
||||
const auto &edit = edit_log[v];
|
||||
for (auto &l : lines_t) {
|
||||
if (l == UINT32_MAX)
|
||||
continue;
|
||||
all_removed = false;
|
||||
if (edit.delta > 0) {
|
||||
if (l >= edit.start_line) {
|
||||
if (l < edit.start_line + edit.delta)
|
||||
l = UINT32_MAX;
|
||||
else
|
||||
l -= edit.delta;
|
||||
}
|
||||
} else {
|
||||
if (l >= edit.start_line)
|
||||
l -= edit.delta;
|
||||
}
|
||||
}
|
||||
if (all_removed)
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::optional<LineKey> resolve_line(uint32_t line) {
|
||||
uint32_t current_line = line;
|
||||
for (int64_t v = current_version; v >= 0; v--) {
|
||||
LineKey key = {current_line, (uint32_t)v};
|
||||
if (lines.find(key) != lines.end())
|
||||
return key;
|
||||
const auto &edit = edit_log[v];
|
||||
if (edit.delta > 0) {
|
||||
if (current_line >= edit.start_line) {
|
||||
if (current_line < edit.start_line + edit.delta)
|
||||
return std::nullopt;
|
||||
current_line -= edit.delta;
|
||||
}
|
||||
} else {
|
||||
if (current_line >= edit.start_line)
|
||||
current_line -= edit.delta;
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,233 +0,0 @@
|
||||
#ifndef LINE_TREE_H
|
||||
#define LINE_TREE_H
|
||||
|
||||
#include "syntax/decl.h"
|
||||
|
||||
struct LineTree {
|
||||
void clear() {
|
||||
std::unique_lock lock(mtx);
|
||||
clear_node(root);
|
||||
root = nullptr;
|
||||
stack_size = 0;
|
||||
}
|
||||
void build(uint32_t x) {
|
||||
std::unique_lock lock(mtx);
|
||||
root = build_node(x);
|
||||
}
|
||||
LineData *at(uint32_t x) {
|
||||
std::shared_lock lock(mtx);
|
||||
LineNode *n = root;
|
||||
while (n) {
|
||||
uint32_t left_size = n->left ? n->left->size : 0;
|
||||
if (x < left_size) {
|
||||
n = n->left;
|
||||
} else if (x < left_size + n->data.size()) {
|
||||
return &n->data[x - left_size];
|
||||
} else {
|
||||
x -= left_size + n->data.size();
|
||||
n = n->right;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
LineData *start_iter(uint32_t x) {
|
||||
std::shared_lock lock(mtx);
|
||||
stack_size = 0;
|
||||
LineNode *n = root;
|
||||
while (n) {
|
||||
uint32_t left_size = n->left ? n->left->size : 0;
|
||||
if (x < left_size) {
|
||||
push(n, 0);
|
||||
n = n->left;
|
||||
} else if (x < left_size + n->data.size()) {
|
||||
push(n, x - left_size + 1);
|
||||
return &n->data[x - left_size];
|
||||
} else {
|
||||
x -= left_size + n->data.size();
|
||||
push(n, UINT32_MAX);
|
||||
n = n->right;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
void end_iter() { stack_size = 0; }
|
||||
LineData *next() {
|
||||
std::shared_lock lock(mtx);
|
||||
while (stack_size) {
|
||||
auto &f = stack[stack_size - 1];
|
||||
LineNode *n = f.node;
|
||||
if (f.index < n->data.size())
|
||||
return &n->data[f.index++];
|
||||
stack_size--;
|
||||
if (n->right) {
|
||||
n = n->right;
|
||||
while (n) {
|
||||
push(n, 0);
|
||||
if (!n->left)
|
||||
break;
|
||||
n = n->left;
|
||||
}
|
||||
return &stack[stack_size - 1].node->data[0];
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
void insert(uint32_t x, uint32_t y) {
|
||||
std::unique_lock lock(mtx);
|
||||
root = insert_node(root, x, y);
|
||||
}
|
||||
void erase(uint32_t x, uint32_t y) {
|
||||
std::unique_lock lock(mtx);
|
||||
root = erase_node(root, x, y);
|
||||
}
|
||||
uint32_t count() {
|
||||
std::shared_lock lock(mtx);
|
||||
return subtree_size(root);
|
||||
}
|
||||
~LineTree() { clear(); }
|
||||
|
||||
private:
|
||||
struct LineNode {
|
||||
LineNode *left = nullptr;
|
||||
LineNode *right = nullptr;
|
||||
uint8_t depth = 1;
|
||||
uint32_t size = 0;
|
||||
std::vector<LineData> data;
|
||||
};
|
||||
struct Frame {
|
||||
LineNode *node;
|
||||
uint32_t index;
|
||||
};
|
||||
void push(LineNode *n, uint32_t x) {
|
||||
stack[stack_size].node = n;
|
||||
stack[stack_size].index = x;
|
||||
stack_size++;
|
||||
}
|
||||
static void clear_node(LineNode *n) {
|
||||
if (!n)
|
||||
return;
|
||||
clear_node(n->left);
|
||||
clear_node(n->right);
|
||||
delete n;
|
||||
}
|
||||
LineNode *root = nullptr;
|
||||
Frame stack[32];
|
||||
std::atomic<uint8_t> stack_size = 0;
|
||||
std::shared_mutex mtx;
|
||||
static constexpr uint32_t LEAF_TARGET = 256;
|
||||
LineTree::LineNode *erase_node(LineNode *n, uint32_t x, uint32_t y) {
|
||||
if (!n)
|
||||
return nullptr;
|
||||
if (!n->left && !n->right) {
|
||||
n->data.erase(n->data.begin() + x, n->data.begin() + x + y);
|
||||
fix(n);
|
||||
return n;
|
||||
}
|
||||
uint32_t left_size = subtree_size(n->left);
|
||||
if (x < left_size)
|
||||
n->left = erase_node(n->left, x, y);
|
||||
else
|
||||
n->right = erase_node(n->right, x - left_size - n->data.size(), y);
|
||||
if (n->left && n->right &&
|
||||
subtree_size(n->left) + subtree_size(n->right) < 256) {
|
||||
return merge(n->left, n->right);
|
||||
}
|
||||
return rebalance(n);
|
||||
}
|
||||
LineTree::LineNode *insert_node(LineNode *n, uint32_t x, uint32_t y) {
|
||||
if (!n) {
|
||||
auto *leaf = new LineNode();
|
||||
leaf->data.resize(y);
|
||||
leaf->size = y;
|
||||
return leaf;
|
||||
}
|
||||
if (!n->left && !n->right) {
|
||||
n->data.insert(n->data.begin() + x, y, LineData{});
|
||||
fix(n);
|
||||
if (n->data.size() > 512)
|
||||
return split_leaf(n);
|
||||
return n;
|
||||
}
|
||||
uint32_t left_size = subtree_size(n->left);
|
||||
if (x <= left_size)
|
||||
n->left = insert_node(n->left, x, y);
|
||||
else
|
||||
n->right = insert_node(n->right, x - left_size - n->data.size(), y);
|
||||
return rebalance(n);
|
||||
}
|
||||
LineNode *build_node(uint32_t count) {
|
||||
if (count <= LEAF_TARGET) {
|
||||
auto *n = new LineNode();
|
||||
n->data.resize(count);
|
||||
n->size = count;
|
||||
return n;
|
||||
}
|
||||
uint32_t left_count = count / 2;
|
||||
uint32_t right_count = count - left_count;
|
||||
auto *n = new LineNode();
|
||||
n->left = build_node(left_count);
|
||||
n->right = build_node(right_count);
|
||||
fix(n);
|
||||
return n;
|
||||
}
|
||||
static LineNode *split_leaf(LineNode *n) {
|
||||
auto *right = new LineNode();
|
||||
size_t mid = n->data.size() / 2;
|
||||
right->data.assign(n->data.begin() + mid, n->data.end());
|
||||
n->data.resize(mid);
|
||||
fix(n);
|
||||
fix(right);
|
||||
auto *parent = new LineNode();
|
||||
parent->left = n;
|
||||
parent->right = right;
|
||||
fix(parent);
|
||||
return parent;
|
||||
}
|
||||
static LineNode *merge(LineNode *a, LineNode *b) {
|
||||
a->data.insert(a->data.end(), b->data.begin(), b->data.end());
|
||||
delete b;
|
||||
fix(a);
|
||||
return a;
|
||||
}
|
||||
static void fix(LineNode *n) {
|
||||
n->depth = 1 + MAX(height(n->left), height(n->right));
|
||||
n->size = subtree_size(n->left) + n->data.size() + subtree_size(n->right);
|
||||
}
|
||||
static LineNode *rotate_right(LineNode *y) {
|
||||
LineNode *x = y->left;
|
||||
LineNode *T2 = x->right;
|
||||
x->right = y;
|
||||
y->left = T2;
|
||||
fix(y);
|
||||
fix(x);
|
||||
return x;
|
||||
}
|
||||
static LineNode *rotate_left(LineNode *x) {
|
||||
LineNode *y = x->right;
|
||||
LineNode *T2 = y->left;
|
||||
y->left = x;
|
||||
x->right = T2;
|
||||
fix(x);
|
||||
fix(y);
|
||||
return y;
|
||||
}
|
||||
static LineNode *rebalance(LineNode *n) {
|
||||
fix(n);
|
||||
int balance = int(height(n->left)) - int(height(n->right));
|
||||
if (balance > 1) {
|
||||
if (height(n->left->left) < height(n->left->right))
|
||||
n->left = rotate_left(n->left);
|
||||
return rotate_right(n);
|
||||
}
|
||||
if (balance < -1) {
|
||||
if (height(n->right->right) < height(n->right->left))
|
||||
n->right = rotate_right(n->right);
|
||||
return rotate_left(n);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
static uint8_t height(LineNode *n) { return n ? n->depth : 0; }
|
||||
static uint32_t subtree_size(LineNode *n) { return n ? n->size : 0; }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,28 +1,27 @@
|
||||
#ifndef SYNTAX_PARSER_H
|
||||
#define SYNTAX_PARSER_H
|
||||
|
||||
#include "ruby/decl.h"
|
||||
#include "syntax/decl.h"
|
||||
#include "syntax/line_tree.h"
|
||||
#include "syntax/line_map.h"
|
||||
|
||||
struct Parser {
|
||||
Knot *root;
|
||||
std::shared_mutex *knot_mutex;
|
||||
struct Editor *editor = nullptr;
|
||||
std::string lang;
|
||||
std::shared_ptr<void> (*parse_func)(std::vector<Token> *tokens,
|
||||
std::shared_ptr<void> in_state,
|
||||
const char *text, uint32_t len);
|
||||
bool (*state_match_func)(std::shared_ptr<void> state_1,
|
||||
std::shared_ptr<void> state_2);
|
||||
std::atomic<uint32_t> scroll_max{UINT32_MAX - 2048};
|
||||
std::mutex mutex;
|
||||
std::mutex data_mutex;
|
||||
LineTree line_tree;
|
||||
std::set<uint32_t> dirty_lines;
|
||||
std::unique_ptr<StateBase> (*parse_func)(std::vector<Token> *tokens,
|
||||
StateBase *in_state,
|
||||
const char *text, uint32_t len,
|
||||
uint32_t line_num);
|
||||
bool (*state_match_func)(StateBase *state_1, StateBase *state_2);
|
||||
mrb_value parser_block = mrb_nil_value();
|
||||
mrb_value match_block = mrb_nil_value();
|
||||
bool is_custom{false};
|
||||
std::atomic<uint32_t> scroll_max{0};
|
||||
std::atomic<bool> scroll_dirty{false};
|
||||
LineMap line_map = LineMap();
|
||||
|
||||
Parser(Knot *n_root, std::shared_mutex *n_knot_mutex, std::string n_lang,
|
||||
uint32_t n_scroll_max);
|
||||
void edit(Knot *n_root, uint32_t start_line, uint32_t old_end_line,
|
||||
uint32_t new_end_line);
|
||||
Parser(Editor *editor, std::string n_lang, uint32_t n_scroll_max);
|
||||
void edit(uint32_t start_line, uint32_t removed_rows, uint32_t inserted_rows);
|
||||
void work();
|
||||
void scroll(uint32_t line);
|
||||
};
|
||||
|
||||
@@ -1,53 +1,53 @@
|
||||
ADD(Data)
|
||||
ADD(Shebang)
|
||||
ADD(Comment)
|
||||
ADD(Error)
|
||||
ADD(String)
|
||||
ADD(Escape)
|
||||
ADD(Interpolation)
|
||||
ADD(Regexp)
|
||||
ADD(Number)
|
||||
ADD(True)
|
||||
ADD(False)
|
||||
ADD(Char)
|
||||
ADD(Keyword)
|
||||
ADD(KeywordOperator)
|
||||
ADD(Operator)
|
||||
ADD(Function)
|
||||
ADD(Type)
|
||||
ADD(Constant)
|
||||
ADD(VariableInstance)
|
||||
ADD(VariableGlobal)
|
||||
ADD(Annotation)
|
||||
ADD(Directive)
|
||||
ADD(Label)
|
||||
ADD(Brace1)
|
||||
ADD(Brace2)
|
||||
ADD(Brace3)
|
||||
ADD(Brace4)
|
||||
ADD(Brace5)
|
||||
ADD(Heading1)
|
||||
ADD(Heading2)
|
||||
ADD(Heading3)
|
||||
ADD(Heading4)
|
||||
ADD(Heading5)
|
||||
ADD(Heading6)
|
||||
ADD(Blockquote)
|
||||
ADD(List)
|
||||
ADD(ListItem)
|
||||
ADD(Code)
|
||||
ADD(LanguageName)
|
||||
ADD(LinkLabel)
|
||||
ADD(ImageLabel)
|
||||
ADD(Link)
|
||||
ADD(Table)
|
||||
ADD(TableHeader)
|
||||
ADD(Italic)
|
||||
ADD(Bold)
|
||||
ADD(Underline)
|
||||
ADD(Strikethrough)
|
||||
ADD(HorixontalRule)
|
||||
ADD(Tag)
|
||||
ADD(Attribute)
|
||||
ADD(CheckDone)
|
||||
ADD(CheckNotDone)
|
||||
ADD(K_DATA)
|
||||
ADD(K_SHEBANG)
|
||||
ADD(K_COMMENT)
|
||||
ADD(K_ERROR)
|
||||
ADD(K_STRING)
|
||||
ADD(K_ESCAPE)
|
||||
ADD(K_INTERPOLATION)
|
||||
ADD(K_REGEXP)
|
||||
ADD(K_NUMBER)
|
||||
ADD(K_TRUE)
|
||||
ADD(K_FALSE)
|
||||
ADD(K_CHAR)
|
||||
ADD(K_KEYWORD)
|
||||
ADD(K_KEYWORDOPERATOR)
|
||||
ADD(K_OPERATOR)
|
||||
ADD(K_FUNCTION)
|
||||
ADD(K_TYPE)
|
||||
ADD(K_CONSTANT)
|
||||
ADD(K_VARIABLEINSTANCE)
|
||||
ADD(K_VARIABLEGLOBAL)
|
||||
ADD(K_ANNOTATION)
|
||||
ADD(K_DIRECTIVE)
|
||||
ADD(K_LABEL)
|
||||
ADD(K_BRACE1)
|
||||
ADD(K_BRACE2)
|
||||
ADD(K_BRACE3)
|
||||
ADD(K_BRACE4)
|
||||
ADD(K_BRACE5)
|
||||
ADD(K_HEADING1)
|
||||
ADD(K_HEADING2)
|
||||
ADD(K_HEADING3)
|
||||
ADD(K_HEADING4)
|
||||
ADD(K_HEADING5)
|
||||
ADD(K_HEADING6)
|
||||
ADD(K_BLOCKQUOTE)
|
||||
ADD(K_LIST)
|
||||
ADD(K_LISTITEM)
|
||||
ADD(K_CODE)
|
||||
ADD(K_LANGUAGENAME)
|
||||
ADD(K_LINKLABEL)
|
||||
ADD(K_IMAGELABEL)
|
||||
ADD(K_LINK)
|
||||
ADD(K_TABLE)
|
||||
ADD(K_TABLEHEADER)
|
||||
ADD(K_ITALIC)
|
||||
ADD(K_BOLD)
|
||||
ADD(K_UNDERLINE)
|
||||
ADD(K_STRIKETHROUGH)
|
||||
ADD(K_HORIXONTALRULE)
|
||||
ADD(K_TAG)
|
||||
ADD(K_ATTRIBUTE)
|
||||
ADD(K_CHECKDONE)
|
||||
ADD(K_CHECKNOTDONE)
|
||||
|
||||
140
include/syntax/trie.h
Normal file
140
include/syntax/trie.h
Normal file
@@ -0,0 +1,140 @@
|
||||
#ifndef SYNTAX_TRIE_H
|
||||
#define SYNTAX_TRIE_H
|
||||
|
||||
#include "utils/utils.h"
|
||||
|
||||
template <typename T> struct Trie {
|
||||
struct TrieNode {
|
||||
bool is_word = false;
|
||||
std::array<TrieNode *, 128> children{};
|
||||
std::conditional_t<std::is_void_v<T>, char, std::optional<T>> value;
|
||||
TrieNode() { children.fill(nullptr); }
|
||||
};
|
||||
|
||||
Trie() {}
|
||||
~Trie() { clear_trie(root); }
|
||||
|
||||
void build(const std::vector<std::string> &words, bool cs = true) {
|
||||
static_assert(std::is_void_v<T>, "This build() is for Trie<void> only");
|
||||
case_sensitive = cs;
|
||||
for (auto &w : words)
|
||||
insert(w);
|
||||
}
|
||||
|
||||
template <typename U = T>
|
||||
std::enable_if_t<!std::is_void_v<U>>
|
||||
build(const std::vector<std::pair<std::string, U>> &words, bool cs = true) {
|
||||
static_assert(!std::is_void_v<T>, "This build() is for typed Trie only");
|
||||
case_sensitive = cs;
|
||||
for (auto &[w, v] : words)
|
||||
insert(w, v);
|
||||
}
|
||||
|
||||
uint32_t match(const char *text, uint32_t pos, uint32_t len,
|
||||
bool (*is_word_char)(char c)) const {
|
||||
const TrieNode *node = root;
|
||||
uint32_t max_len = 0;
|
||||
for (uint32_t i = pos; i < len; ++i) {
|
||||
unsigned char uc = static_cast<unsigned char>(text[i]);
|
||||
if (uc >= 128)
|
||||
return 0;
|
||||
if (!case_sensitive && uc >= 'A' && uc <= 'Z')
|
||||
uc = uc - 'A' + 'a';
|
||||
if (!node->children[uc]) {
|
||||
if (node->is_word && !is_word_char(text[i]))
|
||||
return i - pos;
|
||||
break;
|
||||
}
|
||||
node = node->children[uc];
|
||||
if (node->is_word)
|
||||
max_len = i - pos + 1;
|
||||
}
|
||||
if (max_len > 0)
|
||||
if (pos + max_len < len && is_word_char(text[pos + max_len]))
|
||||
return 0;
|
||||
return max_len;
|
||||
}
|
||||
|
||||
template <typename U = T>
|
||||
uint32_t
|
||||
match(const char *text, uint32_t pos, uint32_t len,
|
||||
bool (*is_word_char)(char c),
|
||||
std::conditional_t<std::is_void_v<T>, void *, std::optional<T> *>
|
||||
out_val = nullptr) const {
|
||||
const TrieNode *node = root;
|
||||
const TrieNode *last_word_node = nullptr;
|
||||
uint32_t max_len = 0;
|
||||
for (uint32_t i = pos; i < len; ++i) {
|
||||
unsigned char uc = static_cast<unsigned char>(text[i]);
|
||||
if (uc >= 128)
|
||||
break;
|
||||
if (!case_sensitive && uc >= 'A' && uc <= 'Z')
|
||||
uc = uc - 'A' + 'a';
|
||||
if (!node->children[uc])
|
||||
break;
|
||||
node = node->children[uc];
|
||||
if (node->is_word) {
|
||||
last_word_node = node;
|
||||
max_len = i - pos + 1;
|
||||
}
|
||||
}
|
||||
if (!last_word_node) {
|
||||
if (out_val)
|
||||
*out_val = std::nullopt;
|
||||
return 0;
|
||||
}
|
||||
if (pos + max_len < len && is_word_char(text[pos + max_len])) {
|
||||
if (out_val)
|
||||
*out_val = std::nullopt;
|
||||
return 0;
|
||||
}
|
||||
if (out_val)
|
||||
*out_val = last_word_node->value;
|
||||
return max_len;
|
||||
}
|
||||
|
||||
private:
|
||||
TrieNode *root = new TrieNode();
|
||||
bool case_sensitive = true;
|
||||
|
||||
void insert(const std::string &word) {
|
||||
TrieNode *node = root;
|
||||
for (char c : word) {
|
||||
unsigned char uc = static_cast<unsigned char>(c);
|
||||
if (uc >= 128)
|
||||
return;
|
||||
if (!case_sensitive && uc >= 'A' && uc <= 'Z')
|
||||
uc = uc - 'A' + 'a';
|
||||
if (!node->children[uc])
|
||||
node->children[uc] = new TrieNode();
|
||||
node = node->children[uc];
|
||||
}
|
||||
node->is_word = true;
|
||||
}
|
||||
|
||||
template <typename U = T>
|
||||
std::enable_if_t<!std::is_void_v<U>> insert(const std::string &word,
|
||||
const U &val) {
|
||||
TrieNode *node = root;
|
||||
for (char c : word) {
|
||||
unsigned char uc = static_cast<unsigned char>(c);
|
||||
if (!case_sensitive && uc >= 'A' && uc <= 'Z')
|
||||
uc = uc - 'A' + 'a';
|
||||
if (!node->children[uc])
|
||||
node->children[uc] = new TrieNode();
|
||||
node = node->children[uc];
|
||||
}
|
||||
node->is_word = true;
|
||||
node->value = val;
|
||||
}
|
||||
|
||||
void clear_trie(TrieNode *node) {
|
||||
if (!node)
|
||||
return;
|
||||
for (auto *child : node->children)
|
||||
clear_trie(child);
|
||||
delete node;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -8,11 +8,13 @@
|
||||
struct Bar {
|
||||
Coord screen;
|
||||
std::string command = "";
|
||||
std::string log_line = "";
|
||||
uint32_t cursor = 0;
|
||||
|
||||
Bar(Coord screen) : screen(screen) {}
|
||||
void render();
|
||||
void handle(KeyEvent event);
|
||||
void init(Coord screen) { this->screen = screen; }
|
||||
void render(std::vector<ScreenCell> &buffer);
|
||||
void handle_event(KeyEvent event);
|
||||
void handle_command(std::string &command);
|
||||
void log(std::string message);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#ifndef UI_COMPLETIONBOX_H
|
||||
#define UI_COMPLETIONBOX_H
|
||||
|
||||
#include "io/sysio.h"
|
||||
#include "pch.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
struct CompletionBox {
|
||||
std::shared_mutex mtx;
|
||||
struct CompletionSession *session;
|
||||
bool hidden = true;
|
||||
std::vector<ScreenCell> cells;
|
||||
Coord size;
|
||||
Coord position;
|
||||
|
||||
CompletionBox(CompletionSession *s) : session(s) {}
|
||||
void render_update();
|
||||
void render(Coord pos);
|
||||
};
|
||||
|
||||
#endif
|
||||
// #ifndef UI_COMPLETIONBOX_H
|
||||
// #define UI_COMPLETIONBOX_H
|
||||
//
|
||||
// #include "io/sysio.h"
|
||||
// #include "pch.h"
|
||||
// #include "utils/utils.h"
|
||||
//
|
||||
// struct CompletionBox {
|
||||
// std::shared_mutex mtx;
|
||||
// struct CompletionSession *session;
|
||||
// bool hidden = true;
|
||||
// std::vector<ScreenCell> cells;
|
||||
// Coord size;
|
||||
// Coord position;
|
||||
//
|
||||
// CompletionBox(CompletionSession *s) : session(s) {}
|
||||
// void render_update();
|
||||
// void render(Coord pos);
|
||||
// };
|
||||
//
|
||||
// #endif
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#ifndef UI_DIAGNOSTICS_H
|
||||
#define UI_DIAGNOSTICS_H
|
||||
|
||||
#include "editor/decl.h"
|
||||
#include "io/sysio.h"
|
||||
#include "pch.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
struct DiagnosticBox {
|
||||
std::vector<VWarn> warnings;
|
||||
std::vector<ScreenCell> cells;
|
||||
Coord size;
|
||||
|
||||
void clear();
|
||||
void render_first();
|
||||
void render(Coord pos);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,22 +0,0 @@
|
||||
#ifndef UI_HOVER_H
|
||||
#define UI_HOVER_H
|
||||
|
||||
#include "editor/decl.h"
|
||||
#include "io/sysio.h"
|
||||
#include "pch.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
struct HoverBox {
|
||||
std::string text;
|
||||
std::atomic<bool> is_markup;
|
||||
uint32_t scroll_;
|
||||
std::vector<ScreenCell> cells;
|
||||
Coord size;
|
||||
|
||||
void clear();
|
||||
void scroll(int32_t number);
|
||||
void render_first(bool scroll = false);
|
||||
void render(Coord pos);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -4,23 +4,21 @@
|
||||
#include "pch.h"
|
||||
|
||||
template <typename T> struct Queue {
|
||||
std::queue<T> q;
|
||||
std::mutex m;
|
||||
|
||||
void push(T val) {
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
q.push(val);
|
||||
q.push(std::move(val));
|
||||
}
|
||||
std::optional<T> front() {
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
if (q.empty())
|
||||
return std::nullopt;
|
||||
return q.front();
|
||||
return std::move(q.front());
|
||||
}
|
||||
bool pop(T &val) {
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
if (q.empty())
|
||||
return false;
|
||||
val = q.front();
|
||||
val = std::move(q.front());
|
||||
q.pop();
|
||||
return true;
|
||||
}
|
||||
@@ -32,6 +30,49 @@ template <typename T> struct Queue {
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
return q.empty();
|
||||
}
|
||||
|
||||
private:
|
||||
std::queue<T> q;
|
||||
std::mutex m;
|
||||
};
|
||||
|
||||
template <typename T> struct UniqueQueue {
|
||||
bool push(const T &value) {
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
if (set.contains(value))
|
||||
return false;
|
||||
|
||||
dq.push_back(value);
|
||||
set.insert(value);
|
||||
return true;
|
||||
}
|
||||
bool pop(T &out) {
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
if (dq.empty())
|
||||
return false;
|
||||
out = dq.front();
|
||||
dq.pop_front();
|
||||
set.erase(out);
|
||||
return true;
|
||||
}
|
||||
bool empty() const {
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
return dq.empty();
|
||||
}
|
||||
void clear() {
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
dq.clear();
|
||||
set.clear();
|
||||
}
|
||||
size_t size() const {
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
return dq.size();
|
||||
}
|
||||
|
||||
private:
|
||||
std::deque<T> dq;
|
||||
std::set<T> set;
|
||||
mutable std::mutex m;
|
||||
};
|
||||
|
||||
struct Coord {
|
||||
@@ -52,6 +93,11 @@ struct Coord {
|
||||
bool operator>=(const Coord &other) const { return !(*this < other); }
|
||||
};
|
||||
|
||||
static inline bool inside(Coord c, Coord pos, Coord size) {
|
||||
return c.row >= pos.row && c.col >= pos.col && c.row - pos.row < size.row &&
|
||||
c.col - pos.col < size.col;
|
||||
}
|
||||
|
||||
struct Match {
|
||||
size_t start;
|
||||
size_t end;
|
||||
@@ -60,11 +106,19 @@ struct Match {
|
||||
|
||||
struct Language {
|
||||
std::string name;
|
||||
uint8_t lsp_id;
|
||||
std::string lsp_name;
|
||||
uint32_t color;
|
||||
const char *symbol;
|
||||
};
|
||||
|
||||
struct LSP {
|
||||
std::string command;
|
||||
std::vector<std::string> args;
|
||||
};
|
||||
|
||||
extern std::unordered_map<std::string, Language> languages;
|
||||
extern std::unordered_map<std::string, std::string> language_extensions;
|
||||
extern std::unordered_map<std::string, LSP> lsps;
|
||||
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define ABS(x) ((x) < 0 ? -(x) : (x))
|
||||
@@ -92,8 +146,10 @@ uint32_t get_visual_col_from_bytes(const char *line, uint32_t len,
|
||||
uint32_t byte_limit);
|
||||
uint32_t get_bytes_from_visual_col(const char *line, uint32_t len,
|
||||
uint32_t target_visual_col);
|
||||
uint32_t utf8_byte_offset_to_utf16(const char *s, uint32_t byte_pos);
|
||||
uint32_t utf16_offset_to_utf8(const char *s, uint32_t utf16_pos);
|
||||
size_t utf8_offset_to_utf16(const char *utf8, size_t utf8_len,
|
||||
size_t byte_offset);
|
||||
size_t utf16_offset_to_utf8(const char *utf8, size_t utf8_len,
|
||||
size_t utf16_offset);
|
||||
uint8_t utf8_codepoint_width(unsigned char c);
|
||||
|
||||
void log(const char *fmt, ...);
|
||||
@@ -102,13 +158,9 @@ std::string path_abs(const std::string &path_str);
|
||||
std::string path_to_file_uri(const std::string &path_str);
|
||||
std::string filename_from_path(const std::string &path);
|
||||
std::string get_exe_dir();
|
||||
char *load_file(const char *path, uint32_t *out_len);
|
||||
char *detect_file_type(const char *filename);
|
||||
char *load_file(const char *path, uint32_t *out_len, bool *out_eol);
|
||||
Language language_for_file(const char *filename);
|
||||
|
||||
void copy_to_clipboard(const char *text, size_t len);
|
||||
char *get_from_clipboard(uint32_t *out_len);
|
||||
|
||||
template <typename T>
|
||||
inline T *safe_get(std::map<uint16_t, T> &m, uint16_t key) {
|
||||
auto it = m.find(key);
|
||||
|
||||
119
include/windows/decl.h
Normal file
119
include/windows/decl.h
Normal file
@@ -0,0 +1,119 @@
|
||||
#ifndef TILING_DECL_H
|
||||
#define TILING_DECL_H
|
||||
|
||||
#include "io/sysio.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
struct Tile {
|
||||
bool hidden = false;
|
||||
uint32_t weight = 100;
|
||||
|
||||
virtual void render(std::vector<ScreenCell> &buffer, Coord size,
|
||||
Coord pos) = 0;
|
||||
virtual void handle_click(KeyEvent event, Coord size) = 0;
|
||||
virtual ~Tile() = default;
|
||||
};
|
||||
|
||||
struct Window : Tile {
|
||||
virtual ~Window() = default;
|
||||
virtual void handle_event(KeyEvent){};
|
||||
virtual void handle_command(std::string &) {};
|
||||
virtual void work() {};
|
||||
virtual std::array<std::string, 5> bar_info() { return {}; };
|
||||
};
|
||||
|
||||
struct Popup : Window {
|
||||
Coord pos;
|
||||
Coord size;
|
||||
virtual ~Popup() = default;
|
||||
};
|
||||
|
||||
struct TileBlock : Tile {
|
||||
bool vertical;
|
||||
std::vector<std::unique_ptr<Tile>> tiles;
|
||||
|
||||
void render(std::vector<ScreenCell> &buffer, Coord size, Coord pos) override {
|
||||
uint32_t total_weight = 0;
|
||||
for (auto &t : tiles) {
|
||||
if (!t->hidden)
|
||||
total_weight += t->weight;
|
||||
}
|
||||
if (total_weight == 0)
|
||||
return;
|
||||
for (auto &t : tiles) {
|
||||
if (t->hidden)
|
||||
continue;
|
||||
uint32_t proportion =
|
||||
t->weight * (vertical ? size.row : size.col) / total_weight;
|
||||
Coord tile_size = vertical ? Coord{.row = proportion, .col = size.col}
|
||||
: Coord{.row = size.row, .col = proportion};
|
||||
t->render(buffer, tile_size, pos);
|
||||
if (vertical)
|
||||
pos.row += tile_size.row;
|
||||
else
|
||||
pos.col += tile_size.col;
|
||||
}
|
||||
}
|
||||
|
||||
void handle_click(KeyEvent event, Coord size) override {
|
||||
uint32_t total_weight = 0;
|
||||
for (auto &t : tiles)
|
||||
if (!t->hidden)
|
||||
total_weight += t->weight;
|
||||
if (total_weight == 0)
|
||||
return;
|
||||
uint32_t i = 0;
|
||||
for (auto &t : tiles) {
|
||||
if (t->hidden)
|
||||
continue;
|
||||
uint32_t proportion =
|
||||
t->weight * (vertical ? size.row : size.col) / total_weight;
|
||||
Coord tile_size = vertical ? Coord{.row = proportion, .col = size.col}
|
||||
: Coord{.row = size.row, .col = proportion};
|
||||
if (vertical) {
|
||||
if (event.mouse_y < i + proportion) {
|
||||
event.mouse_y -= i;
|
||||
t->handle_click(event, tile_size);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (event.mouse_x < i + proportion) {
|
||||
event.mouse_x -= i;
|
||||
t->handle_click(event, tile_size);
|
||||
return;
|
||||
}
|
||||
}
|
||||
i += proportion;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct TileBase {
|
||||
std::unique_ptr<Tile> tile;
|
||||
Coord pos;
|
||||
Coord size;
|
||||
|
||||
inline bool hidden() { return this->tile->hidden; }
|
||||
void render(std::vector<ScreenCell> &buffer) {
|
||||
if (this->tile->hidden)
|
||||
return;
|
||||
this->tile->render(buffer, size, pos);
|
||||
}
|
||||
void handle_click(KeyEvent event) {
|
||||
event.mouse_x -= this->pos.col;
|
||||
event.mouse_y -= this->pos.row;
|
||||
this->tile->handle_click(event, size);
|
||||
}
|
||||
};
|
||||
|
||||
namespace layout {
|
||||
extern TileBase root_tile;
|
||||
extern Window *focused_window;
|
||||
extern std::vector<std::unique_ptr<Popup>> popups;
|
||||
extern std::vector<std::unique_ptr<TileBase>> floating_tiles;
|
||||
} // namespace layout
|
||||
|
||||
void render();
|
||||
void handle_click(KeyEvent event);
|
||||
|
||||
#endif
|
||||
39
installer.sh
Normal file
39
installer.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -eu
|
||||
|
||||
install() {
|
||||
BINARY_NAME="crib"
|
||||
BIN_URL="https://git.syedm.dev/SyedM/crib/releases/download/v0.0.5-alpha/crib"
|
||||
|
||||
echo "Install or update locally (~/.local/bin) or globally (/usr/bin)? [l/g]"
|
||||
read -r choice </dev/tty
|
||||
case "$choice" in
|
||||
l | L)
|
||||
INSTALL_DIR="$HOME/.local/bin"
|
||||
SUDO=""
|
||||
;;
|
||||
g | G)
|
||||
INSTALL_DIR="/usr/bin"
|
||||
SUDO="sudo"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid choice"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
$SUDO mkdir -p "$INSTALL_DIR"
|
||||
|
||||
echo "Downloading binary..."
|
||||
curl -L "$BIN_URL" -o /tmp/"$BINARY_NAME"
|
||||
$SUDO install -m 755 /tmp/"$BINARY_NAME" "$INSTALL_DIR/$BINARY_NAME"
|
||||
rm -f /tmp/"$BINARY_NAME"
|
||||
|
||||
echo
|
||||
echo "✔ Crib installed to $INSTALL_DIR"
|
||||
echo "Run with: $BINARY_NAME"
|
||||
echo "Add $INSTALL_DIR to PATH if needed."
|
||||
}
|
||||
|
||||
install "$@"
|
||||
1
libs/mruby
vendored
Submodule
1
libs/mruby
vendored
Submodule
Submodule libs/mruby added at 7d08c6246d
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ---------------------------------------------
|
||||
# ----------------------------------------------
|
||||
# Bash Syntax Highlighter Test Specification
|
||||
# ---------------------------------------------
|
||||
# ----------------------------------------------
|
||||
|
||||
VERSION="1.0.0"
|
||||
declare -a ITEMS=("alpha" "beta" "gamma" "delta")
|
||||
@@ -25,11 +25,10 @@ colorize() {
|
||||
handle_error() {
|
||||
log ERROR "An error occurred on line $1"
|
||||
}
|
||||
trap 'handle_error $LINENO' ERR
|
||||
|
||||
trap 'handle_error $LINENO' ERR
|
||||
# Multiline string test
|
||||
read -r -d '' MULTI <<'CPP'
|
||||
|
||||
int main() {
|
||||
|
||||
}
|
||||
@@ -46,7 +45,7 @@ while ((counter < 5)); do
|
||||
done
|
||||
|
||||
# Subshelled loops and alternating quoting
|
||||
for item in "${ITEMS[@]}"; do
|
||||
for item in "${ITEMS[@]}}"; do
|
||||
(
|
||||
msg="Processing $item"
|
||||
echo "$(colorize blue "$msg")"
|
||||
@@ -126,7 +125,7 @@ grep "world" <<<"$FOO" >/dev/null && log INFO "FOO contains world"
|
||||
diff <(echo foo) <(echo foo) >/dev/null && log INFO "diff matched"
|
||||
|
||||
# Command substitution with pipeline
|
||||
timestamp=$(date | sed 's/ /_/g')
|
||||
timestamp=$(date | sed 's//_/g')
|
||||
log INFO "Timestamp: $timestamp"
|
||||
|
||||
# Testing array slicing
|
||||
|
||||
@@ -21,6 +21,7 @@ a:focus-visible {
|
||||
|
||||
input::placeholder {
|
||||
color: #999;
|
||||
background-color: #523;
|
||||
}
|
||||
|
||||
/* CSS variables */
|
||||
|
||||
@@ -117,4 +117,3 @@ local tpl = `Value: ${counter}`
|
||||
|
||||
-- Regex-like string (for testing injection highlighting)
|
||||
local re = "/^%a+$/"
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ NotImplemented
|
||||
Ellipsis
|
||||
__name__ # builtin constant
|
||||
|
||||
|
||||
# ==============================
|
||||
# Imports
|
||||
# ==============================
|
||||
|
||||
169
samples/ruby.rb
169
samples/ruby.rb
@@ -4,52 +4,46 @@
|
||||
# Purpose: Test syntax highlighting + width calculation in your editor
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
# Basic output
|
||||
def greet
|
||||
puts "Hello, 世界! 👋🌏"
|
||||
end
|
||||
|
||||
# Emoji-heavy strings
|
||||
emojis = "👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏👋🌏"
|
||||
|
||||
# Mixed-width CJKssssssssssssssss LoadErssssssssssssssssssssssss
|
||||
cjk_samples = [
|
||||
"漢字テスト",
|
||||
"測試中文字串",
|
||||
"한국어 테스트",
|
||||
"ひらがなカタカナ😀混合",
|
||||
"大量の文字列🚀🚀🚀"
|
||||
'漢字テスト',
|
||||
'測試中文字串',
|
||||
'한국어 테스트',
|
||||
'ひらがなカタカナ混合'
|
||||
]
|
||||
|
||||
# Ruby regex with unicode
|
||||
$unicode_regex_multiline = /[一-龯ぁ-ん#{0x3000}ァ
|
||||
\-ヶー
|
||||
# a hex color: #FFFFFF shouldn't hl here: hsl(147rad, 50%, 47%) as it is not css-style file
|
||||
|
||||
0x603010 # another hex color
|
||||
|
||||
# Ruby regex with unicode
|
||||
$unicode_regex_multiline = /[一-龯ぁ-ん12288ァ
|
||||
\-ヶー
|
||||
s wow
|
||||
|
||||
々〆〤]/
|
||||
|
||||
UNICORE = %r{
|
||||
[s]
|
||||
{#{}}
|
||||
UNICORE = /
|
||||
s
|
||||
{#{ss}}
|
||||
\C-s\u{10}
|
||||
}
|
||||
|
||||
UNINITCORE = %{
|
||||
|
||||
/
|
||||
|
||||
UNINITCORE = %(
|
||||
|
||||
{{#{}}}
|
||||
|
||||
|
||||
test = "A:\x41 B:\101 C:\u0043 D:\u{44 45} NUL:\0 DEL:\c? CTRL_A:\cA META_X:\M-x CTRL_META_X:\C-\M-x MIX:\C-\M-z N:\N{UNICODE NAME}"
|
||||
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
# Unicode identifiers (valid in Ruby)
|
||||
变量 = 0x5_4eddaee
|
||||
π = 3.14_159e+2, ?\u0234, ?\,, ?\x0A, ?s, true, false, 0
|
||||
π = 0.314_159e+2, ?\u0234, "\,", ?\x0A, 's', true, false, 0
|
||||
挨拶 = -> { "こんに \n ちは" }
|
||||
|
||||
arr = Array.new()
|
||||
not_arr = NotArray.new()
|
||||
arr = []
|
||||
not_arr = NotABuiltin.new
|
||||
|
||||
raise NameError or SystemExit or CustomError or Errno or ErrorNotAtAll
|
||||
|
||||
@@ -60,7 +54,7 @@ end
|
||||
|
||||
# Iterate through CJK samples
|
||||
cjk_samples.each_with_index do |str, idx:|
|
||||
puts %Q! CJK[#{idx}] => #{str} (len=#{str.length})\! !
|
||||
puts %! CJK[#{idx}] => #{str} (len=#{str.length})\! !
|
||||
symbol = :"
|
||||
a
|
||||
"
|
||||
@@ -71,45 +65,47 @@ end
|
||||
puts "Emoji count: #{emojis.length}"
|
||||
|
||||
# Multi-line string with unicode
|
||||
multi = <<BASH
|
||||
# Function recursion demo
|
||||
factorial() {
|
||||
local n="$1"
|
||||
if ((n <= 1)); then
|
||||
echo 1
|
||||
else\ns
|
||||
local prev
|
||||
prev=$(factorial $((n - 1)))
|
||||
echo $((n * prev))
|
||||
before #{ interpol
|
||||
|
||||
# comment should be fine heres s
|
||||
$a / $-s+0xFF
|
||||
}s
|
||||
x
|
||||
a after
|
||||
fi
|
||||
} #{s}
|
||||
log INFO "factorial(5) = $(factorial 5)"
|
||||
multi = <<~BASH
|
||||
# Function recursion demo
|
||||
factorial() {
|
||||
local n="$1"
|
||||
if ((n <= 1)); then
|
||||
echo 1
|
||||
else\ns
|
||||
local prev
|
||||
prev=$(factorial $((n - 1)))
|
||||
echo $((n * prev))
|
||||
before #{ interpol
|
||||
# {' '}
|
||||
# comment should be fine heres s
|
||||
$a / $-s + 0xFF
|
||||
}s#{' '}
|
||||
x
|
||||
a after
|
||||
fi
|
||||
} #{s}
|
||||
log INFO "factorial(5) = $(factorial 5)"
|
||||
BASH
|
||||
|
||||
puts multi
|
||||
|
||||
|
||||
# Arrays mixing everything
|
||||
mixed = [
|
||||
"🐍 Ruby + Python? sacrilege! 🐍",
|
||||
"日本語とEnglishと🔧mix",
|
||||
"Spacing test →→→→→→→",
|
||||
"Zero-width joiner test: 👨👩👧👦 family emoji",
|
||||
'🐍 Ruby + Python? sacrilege! 🐍',
|
||||
'日本語とEnglishと🔧mix',
|
||||
'Spacing test →→→→→→→',
|
||||
'Zero-width joiner test: 👨👩👧👦 family emoji'
|
||||
]
|
||||
|
||||
two_docs = <<DOC1 , <<DOC2
|
||||
stuff for doc2
|
||||
two_docs = <<~DOC1, <<~DOC2
|
||||
stuff for doc2
|
||||
rdvajehvbaejbfh
|
||||
DOC1
|
||||
stuff for doc 2 with \#{not interpolation} and more
|
||||
stuff for doc 2 with #{!interpolation} and more
|
||||
DOC2
|
||||
|
||||
p = 0 <<22 # not a heredoc
|
||||
p = 0 << 22 # not a heredoc
|
||||
|
||||
mixed.each { |m| puts m }
|
||||
|
||||
@@ -126,10 +122,10 @@ end
|
||||
escaped = "Line1\nLine2\tTabbed 😀"
|
||||
puts escaped
|
||||
|
||||
p = 0 <<2
|
||||
p = 0 << 2
|
||||
# Frozen string literal test
|
||||
# frozen_string_literal: true
|
||||
const_str = "定数文字列🔒".freeze
|
||||
const_str = '定数文字列🔒'.freeze
|
||||
puts const_str
|
||||
|
||||
# End marker
|
||||
@@ -137,30 +133,26 @@ puts '--- END OF UNICODE TEST FILE ---'
|
||||
|
||||
# Ruby syntax highlighting test
|
||||
|
||||
=begin
|
||||
This is a multi-line comment.
|
||||
It spans multiple lines.
|
||||
Good for testing highlighting.
|
||||
|
||||
This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped linetest,
|
||||
|
||||
=end
|
||||
# This is a multi-line comment.
|
||||
# It spans multiple lines.
|
||||
# Good for testing highlighting.
|
||||
#
|
||||
# This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped line test, This is a wrapped linetest,
|
||||
#
|
||||
|
||||
# Constants
|
||||
|
||||
__END_
|
||||
|
||||
|
||||
PI = 3.14159
|
||||
MAX_ITER = 5
|
||||
# Module
|
||||
module Utilities
|
||||
def self.random_greeting
|
||||
["Hello", "Hi", "Hey", "Hola", "Bonjour", "Merhaba"].sample
|
||||
%w[Hello Hi Hey Hola Bonjour Merhaba].sample
|
||||
end
|
||||
|
||||
def self.factorial(n)
|
||||
return 1 if n <= 1
|
||||
|
||||
n * factorial(n - 1)
|
||||
end
|
||||
end
|
||||
@@ -221,18 +213,16 @@ end
|
||||
# Method definition
|
||||
def greet_person(name)
|
||||
puts "#{Utilities.random_greeting}, #{name}!"
|
||||
if (name == "harry")
|
||||
return true
|
||||
else
|
||||
return "s"
|
||||
end
|
||||
return true if name == 'harry'
|
||||
|
||||
's'
|
||||
end
|
||||
|
||||
h = a / a
|
||||
|
||||
# Calling methods
|
||||
greet_person("Alice")
|
||||
greet_person("Bob")
|
||||
greet_person('Alice')
|
||||
greet_person('Bob')
|
||||
|
||||
# Loops
|
||||
i = 0
|
||||
@@ -252,7 +242,7 @@ begin
|
||||
rescue ZeroDivisionError => e
|
||||
puts "Caught an error: #{e}"
|
||||
ensure
|
||||
puts "This runs no matter what"
|
||||
puts 'This runs no matter what'
|
||||
end
|
||||
|
||||
# Arrays of objects
|
||||
@@ -288,7 +278,7 @@ end
|
||||
end
|
||||
|
||||
# Special objects
|
||||
so = SpecialObject.new("Special", 10)
|
||||
so = SpecialObject.new('Special', 10)
|
||||
puts "Double: #{so.double_value}, Triple: #{so.triple_value}"
|
||||
|
||||
# String interpolation and formatting
|
||||
@@ -299,8 +289,8 @@ multi_line = <<~TEXT
|
||||
k kmW ;
|
||||
This is a multi-line string.
|
||||
It spans multiple lines.
|
||||
Gossn m
|
||||
dd
|
||||
Gossn sssmss
|
||||
ddsss
|
||||
od for testing highlighting.
|
||||
TEXT
|
||||
|
||||
@@ -308,7 +298,7 @@ puts multi_line
|
||||
|
||||
# Symbols and strings
|
||||
sym = :my_symbol == __dir__
|
||||
str = "my string"
|
||||
str = 'my string'
|
||||
puts "Symbol: #{sym}, String: #{str}"
|
||||
|
||||
# Random numbers
|
||||
@@ -327,28 +317,27 @@ end
|
||||
|
||||
# Block with yield
|
||||
def wrapper
|
||||
puts "Before block"
|
||||
puts 'Before block'
|
||||
yield if block_given?
|
||||
puts "After block"
|
||||
puts 'After block'
|
||||
end
|
||||
|
||||
# ss
|
||||
|
||||
wrapper { puts "Inside block" }
|
||||
wrapper { puts 'Inside block' }
|
||||
|
||||
# Sorting
|
||||
sorted = rand_nums.sort
|
||||
puts "Sorted: #{sorted.join(', ')}"
|
||||
|
||||
# Regex
|
||||
sample_text = "The quick brown fox jumps over the lazy dog"
|
||||
sample_text = 'The quick brown fox jumps over the lazy dog'
|
||||
puts "Match 'fox'?" if sample_text =~ /fox/
|
||||
|
||||
# End of test script
|
||||
puts "Ruby syntax highlighting test complete."
|
||||
puts 'Ruby syntax highlighting test complete.'
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
Anything here should be ignored >><<
|
||||
{{{}}}[[[]]](((000)))
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
# kitty @ --to="$KITTY_LISTEN_ON" set-spacing padding=8 margin=0 2>/dev/null || true
|
||||
@@ -1 +0,0 @@
|
||||
# kitty @ --to="$KITTY_LISTEN_ON" set-spacing padding=0 margin=0 2>/dev/null || true
|
||||
@@ -1,25 +1,24 @@
|
||||
#include "editor/editor.h"
|
||||
|
||||
void ensure_cursor(Editor *editor) {
|
||||
std::shared_lock knot_lock(editor->knot_mtx);
|
||||
if (editor->cursor < editor->scroll) {
|
||||
editor->cursor.row = editor->scroll.row;
|
||||
editor->cursor.col = editor->scroll.col;
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
void Editor::ensure_cursor() {
|
||||
if (this->cursor < this->scroll) {
|
||||
this->cursor.row = this->scroll.row;
|
||||
this->cursor.col = this->scroll.col;
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
return;
|
||||
}
|
||||
uint32_t numlen =
|
||||
EXTRA_META + static_cast<int>(std::log10(editor->root->line_count + 1));
|
||||
uint32_t render_width = editor->size.col - numlen;
|
||||
EXTRA_META + static_cast<int>(std::log10(this->root->line_count + 1));
|
||||
uint32_t render_width = this->size.col - numlen;
|
||||
uint32_t visual_rows = 0;
|
||||
uint32_t line_index = editor->scroll.row;
|
||||
uint32_t line_index = this->scroll.row;
|
||||
bool first_visual_line = true;
|
||||
LineIterator *it = begin_l_iter(editor->root, line_index);
|
||||
LineIterator *it = begin_l_iter(this->root, line_index);
|
||||
if (!it)
|
||||
return;
|
||||
Coord last_visible = editor->scroll;
|
||||
Coord last_visible = this->scroll;
|
||||
while (true) {
|
||||
if (visual_rows >= editor->size.row)
|
||||
if (visual_rows >= this->size.row)
|
||||
break;
|
||||
uint32_t line_len;
|
||||
char *line = next_line(it, &line_len);
|
||||
@@ -27,13 +26,13 @@ void ensure_cursor(Editor *editor) {
|
||||
break;
|
||||
if (line_len > 0 && line[line_len - 1] == '\n')
|
||||
line_len--;
|
||||
uint32_t offset = first_visual_line ? editor->scroll.col : 0;
|
||||
uint32_t offset = first_visual_line ? this->scroll.col : 0;
|
||||
first_visual_line = false;
|
||||
while (offset < line_len || (line_len == 0 && offset == 0)) {
|
||||
Coord current = {line_index, offset};
|
||||
last_visible = current;
|
||||
visual_rows++;
|
||||
if (visual_rows >= editor->size.row)
|
||||
if (visual_rows >= this->size.row)
|
||||
break;
|
||||
uint32_t col = 0;
|
||||
uint32_t advance = 0;
|
||||
@@ -48,9 +47,9 @@ void ensure_cursor(Editor *editor) {
|
||||
left -= g;
|
||||
col += w;
|
||||
}
|
||||
if (line_index == editor->cursor.row) {
|
||||
if (editor->cursor.col >= offset &&
|
||||
editor->cursor.col <= offset + advance) {
|
||||
if (line_index == this->cursor.row) {
|
||||
if (this->cursor.col >= offset &&
|
||||
this->cursor.col <= offset + advance) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
@@ -64,20 +63,19 @@ void ensure_cursor(Editor *editor) {
|
||||
}
|
||||
line_index++;
|
||||
}
|
||||
editor->cursor.row = last_visible.row;
|
||||
editor->cursor.col = last_visible.col;
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
this->cursor.row = last_visible.row;
|
||||
this->cursor.col = last_visible.col;
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
}
|
||||
|
||||
void ensure_scroll(Editor *editor) {
|
||||
std::shared_lock knot_lock(editor->knot_mtx);
|
||||
void Editor::ensure_scroll() {
|
||||
uint32_t numlen =
|
||||
EXTRA_META + static_cast<int>(std::log10(editor->root->line_count + 1));
|
||||
uint32_t render_width = editor->size.col - numlen;
|
||||
if (editor->cursor < editor->scroll) {
|
||||
LineIterator *it = begin_l_iter(editor->root, editor->cursor.row);
|
||||
EXTRA_META + static_cast<int>(std::log10(this->root->line_count + 1));
|
||||
uint32_t render_width = this->size.col - numlen;
|
||||
if (this->cursor < this->scroll) {
|
||||
LineIterator *it = begin_l_iter(this->root, this->cursor.row);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t len;
|
||||
@@ -98,9 +96,9 @@ void ensure_scroll(Editor *editor) {
|
||||
int width = display_width(line + offset, inc);
|
||||
if (cols + width > render_width) {
|
||||
cols = 0;
|
||||
if (editor->cursor.col > old_offset && editor->cursor.col <= offset) {
|
||||
editor->scroll.row = editor->cursor.row;
|
||||
editor->scroll.col = old_offset;
|
||||
if (this->cursor.col > old_offset && this->cursor.col <= offset) {
|
||||
this->scroll.row = this->cursor.row;
|
||||
this->scroll.col = old_offset;
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
@@ -112,14 +110,14 @@ void ensure_scroll(Editor *editor) {
|
||||
}
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
editor->scroll.row = editor->cursor.row;
|
||||
editor->scroll.col = (editor->cursor.col == 0) ? 0 : old_offset;
|
||||
} else if (editor->cursor.row - editor->scroll.row < editor->size.row * 2) {
|
||||
uint32_t line_index = editor->scroll.row;
|
||||
LineIterator *it = begin_l_iter(editor->root, line_index);
|
||||
this->scroll.row = this->cursor.row;
|
||||
this->scroll.col = (this->cursor.col == 0) ? 0 : old_offset;
|
||||
} else if (this->cursor.row - this->scroll.row < this->size.row * 2) {
|
||||
uint32_t line_index = this->scroll.row;
|
||||
LineIterator *it = begin_l_iter(this->root, line_index);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t max_visual_lines = editor->size.row;
|
||||
uint32_t max_visual_lines = this->size.row;
|
||||
Coord *scroll_queue = (Coord *)malloc(sizeof(Coord) * max_visual_lines);
|
||||
uint32_t q_head = 0;
|
||||
uint32_t q_size = 0;
|
||||
@@ -133,7 +131,7 @@ void ensure_scroll(Editor *editor) {
|
||||
line_len--;
|
||||
uint32_t current_byte_offset = 0;
|
||||
if (first_visual_line) {
|
||||
current_byte_offset += editor->scroll.col;
|
||||
current_byte_offset += this->scroll.col;
|
||||
first_visual_line = false;
|
||||
}
|
||||
while (current_byte_offset < line_len ||
|
||||
@@ -160,16 +158,16 @@ void ensure_scroll(Editor *editor) {
|
||||
line_left -= cluster_len;
|
||||
col += width;
|
||||
}
|
||||
if (line_index == editor->cursor.row) {
|
||||
if (line_index == this->cursor.row) {
|
||||
bool cursor_found = false;
|
||||
if (editor->cursor.col >= current_byte_offset &&
|
||||
editor->cursor.col < current_byte_offset + local_render_offset)
|
||||
if (this->cursor.col >= current_byte_offset &&
|
||||
this->cursor.col < current_byte_offset + local_render_offset)
|
||||
cursor_found = true;
|
||||
else if (editor->cursor.col == line_len &&
|
||||
else if (this->cursor.col == line_len &&
|
||||
current_byte_offset + local_render_offset == line_len)
|
||||
cursor_found = true;
|
||||
if (cursor_found) {
|
||||
editor->scroll = scroll_queue[q_head];
|
||||
this->scroll = scroll_queue[q_head];
|
||||
free(scroll_queue);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
@@ -186,10 +184,10 @@ void ensure_scroll(Editor *editor) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
} else {
|
||||
editor->scroll.row = (editor->cursor.row > editor->size.row * 1.5)
|
||||
? editor->cursor.row - editor->size.row * 1.5
|
||||
: 0;
|
||||
editor->scroll.col = 0;
|
||||
ensure_scroll(editor);
|
||||
this->scroll.row = (this->cursor.row > this->size.row * 1.5)
|
||||
? this->cursor.row - this->size.row * 1.5
|
||||
: 0;
|
||||
this->scroll.col = 0;
|
||||
this->ensure_scroll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,12 +32,9 @@ uint32_t scan_right(const char *line, uint32_t len, uint32_t off) {
|
||||
return i;
|
||||
}
|
||||
|
||||
void word_boundaries_exclusive(Editor *editor, Coord coord, uint32_t *prev_col,
|
||||
uint32_t *next_col) {
|
||||
if (!editor)
|
||||
return;
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
LineIterator *it = begin_l_iter(editor->root, coord.row);
|
||||
void Editor::word_boundaries_exclusive(Coord coord, uint32_t *prev_col,
|
||||
uint32_t *next_col) {
|
||||
LineIterator *it = begin_l_iter(this->root, coord.row);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t line_len;
|
||||
@@ -85,13 +82,10 @@ uint32_t word_jump_left(const char *line, size_t len, uint32_t col) {
|
||||
return static_cast<uint32_t>(last);
|
||||
}
|
||||
|
||||
void word_boundaries(Editor *editor, Coord coord, uint32_t *prev_col,
|
||||
uint32_t *next_col, uint32_t *prev_clusters,
|
||||
uint32_t *next_clusters) {
|
||||
if (!editor)
|
||||
return;
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
LineIterator *it = begin_l_iter(editor->root, coord.row);
|
||||
void Editor::word_boundaries(Coord coord, uint32_t *prev_col,
|
||||
uint32_t *next_col, uint32_t *prev_clusters,
|
||||
uint32_t *next_clusters) {
|
||||
LineIterator *it = begin_l_iter(this->root, coord.row);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t line_len;
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
#include "editor/editor.h"
|
||||
#include "main.h"
|
||||
|
||||
Coord editor_hit_test(Editor *editor, uint32_t x, uint32_t y) {
|
||||
if (mode == INSERT)
|
||||
x++;
|
||||
Coord Editor::click_coord(uint32_t x, uint32_t y) {
|
||||
uint32_t numlen =
|
||||
EXTRA_META + static_cast<int>(std::log10(editor->root->line_count + 1));
|
||||
uint32_t render_width = editor->size.col - numlen;
|
||||
x = MAX(x, numlen) - numlen;
|
||||
EXTRA_META + static_cast<int>(std::log10(this->root->line_count + 1));
|
||||
uint32_t render_width = this->size.col - numlen;
|
||||
x = MAX(x, numlen) - numlen - 1;
|
||||
uint32_t target_visual_row = y;
|
||||
uint32_t visual_row = 0;
|
||||
uint32_t line_index = editor->scroll.row;
|
||||
uint32_t last_line_index = editor->scroll.row;
|
||||
uint32_t last_col = editor->scroll.col;
|
||||
uint32_t line_index = this->scroll.row;
|
||||
uint32_t last_line_index = this->scroll.row;
|
||||
uint32_t last_col = this->scroll.col;
|
||||
bool first_visual_line = true;
|
||||
std::shared_lock knot_lock(editor->knot_mtx);
|
||||
LineIterator *it = begin_l_iter(editor->root, line_index);
|
||||
LineIterator *it = begin_l_iter(this->root, line_index);
|
||||
if (!it)
|
||||
return editor->scroll;
|
||||
return this->scroll;
|
||||
while (visual_row <= target_visual_row) {
|
||||
uint32_t line_len;
|
||||
char *line = next_line(it, &line_len);
|
||||
@@ -27,7 +23,7 @@ Coord editor_hit_test(Editor *editor, uint32_t x, uint32_t y) {
|
||||
line_len--;
|
||||
last_line_index = line_index;
|
||||
last_col = line_len;
|
||||
uint32_t offset = first_visual_line ? editor->scroll.col : 0;
|
||||
uint32_t offset = first_visual_line ? this->scroll.col : 0;
|
||||
first_visual_line = false;
|
||||
while (offset < line_len || (line_len == 0 && offset == 0)) {
|
||||
uint32_t col = 0;
|
||||
|
||||
13
src/editor/commands.cc
Normal file
13
src/editor/commands.cc
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "editor/editor.h"
|
||||
#include "main.h"
|
||||
|
||||
void Editor::handle_command(std::string &command) {
|
||||
if (command == "w") {
|
||||
this->save();
|
||||
}
|
||||
if (command == "wq") {
|
||||
this->save();
|
||||
command = "q";
|
||||
ui::bar.handle_command(command);
|
||||
}
|
||||
}
|
||||
@@ -1,440 +1,458 @@
|
||||
#include "editor/decl.h"
|
||||
#include "editor/editor.h"
|
||||
#include "io/knot.h"
|
||||
#include "io/sysio.h"
|
||||
#include "lsp/lsp.h"
|
||||
#include "main.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
inline static std::string completion_prefix(Editor *editor) {
|
||||
Coord hook = editor->completion.hook;
|
||||
Coord cur = editor->cursor;
|
||||
if (hook.row != cur.row || cur.col < hook.col)
|
||||
return "";
|
||||
LineIterator *it = begin_l_iter(editor->root, hook.row);
|
||||
char *line = next_line(it, nullptr);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return "";
|
||||
}
|
||||
uint32_t start = utf16_offset_to_utf8(line, hook.col);
|
||||
uint32_t end = editor->cursor.col;
|
||||
std::string prefix(line + start, end - start);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return prefix;
|
||||
}
|
||||
|
||||
void completion_filter(Editor *editor) {
|
||||
auto &session = editor->completion;
|
||||
std::string prefix = completion_prefix(editor);
|
||||
session.visible.clear();
|
||||
for (size_t i = 0; i < session.items.size(); ++i) {
|
||||
const auto &item = session.items[i];
|
||||
const std::string &key = item.filter;
|
||||
if (key.size() >= prefix.size() &&
|
||||
key.compare(0, prefix.size(), prefix) == 0)
|
||||
session.visible.push_back(i);
|
||||
}
|
||||
if (session.visible.empty()) {
|
||||
session.box.hidden = true;
|
||||
return;
|
||||
}
|
||||
if (std::find(session.visible.begin(), session.visible.end(),
|
||||
session.select) == session.visible.end())
|
||||
session.select = session.visible[0];
|
||||
session.box.hidden = false;
|
||||
session.box.render_update();
|
||||
}
|
||||
|
||||
void completion_request(Editor *editor) {
|
||||
Coord hook = editor->cursor;
|
||||
word_boundaries(editor, editor->cursor, &hook.col, nullptr, nullptr, nullptr);
|
||||
editor->completion.hook = hook;
|
||||
editor->completion.complete = false;
|
||||
editor->completion.active = false;
|
||||
editor->completion.items.clear();
|
||||
editor->completion.visible.clear();
|
||||
editor->completion.select = 0;
|
||||
editor->completion.version = editor->lsp_version;
|
||||
LSPPending *pending = new LSPPending();
|
||||
pending->editor = editor;
|
||||
pending->method = "textDocument/completion";
|
||||
pending->callback = [](Editor *editor, std::string, json message) {
|
||||
auto &session = editor->completion;
|
||||
std::unique_lock lock(session.mtx);
|
||||
std::vector<json> items_json;
|
||||
std::vector<char> end_chars_def;
|
||||
int insert_text_format = 1;
|
||||
int insert_text_mode = 1;
|
||||
if (message.contains("result")) {
|
||||
auto &result = message["result"];
|
||||
if (result.is_array()) {
|
||||
items_json = result.get<std::vector<json>>();
|
||||
session.complete = true;
|
||||
if (items_json.empty())
|
||||
return;
|
||||
editor->completion.active = true;
|
||||
} else if (result.is_object() && result.contains("items")) {
|
||||
auto &list = result;
|
||||
items_json = list["items"].get<std::vector<json>>();
|
||||
if (items_json.empty())
|
||||
return;
|
||||
editor->completion.active = true;
|
||||
session.complete = !list.value("isIncomplete", false);
|
||||
if (list.contains("itemDefaults") && list["itemDefaults"].is_object()) {
|
||||
auto &defs = list["itemDefaults"];
|
||||
if (defs.contains("insertTextFormat") &&
|
||||
defs["insertTextFormat"].is_number())
|
||||
insert_text_format = defs["insertTextFormat"].get<int>();
|
||||
if (defs.contains("insertTextMode") &&
|
||||
defs["insertTextMode"].is_number())
|
||||
insert_text_mode = defs["insertTextMode"].get<int>();
|
||||
if (defs.contains("textEdit"))
|
||||
if (defs["textEdit"].is_array())
|
||||
for (auto &c : defs["textEdit"]) {
|
||||
if (!c.is_string())
|
||||
continue;
|
||||
std::string str = c.get<std::string>();
|
||||
if (str.size() != 1)
|
||||
continue;
|
||||
end_chars_def.push_back(str[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
session.items.reserve(items_json.size() + 1);
|
||||
session.visible.reserve(items_json.size() + 1);
|
||||
for (auto &item_json : items_json) {
|
||||
CompletionItem item;
|
||||
item.original = item_json;
|
||||
item.label = item_json.value("label", "");
|
||||
item.kind = item_json.value("kind", 0);
|
||||
if (item_json.contains("detail") && item_json["detail"].is_string())
|
||||
item.detail = item_json["detail"].get<std::string>();
|
||||
if (item_json.contains("documentation")) {
|
||||
if (item_json["documentation"].is_string()) {
|
||||
item.documentation = item_json["documentation"].get<std::string>();
|
||||
} else if (item_json["documentation"].contains("value") &&
|
||||
item_json["documentation"]["value"].is_string()) {
|
||||
item.is_markup =
|
||||
item_json["documentation"]["kind"].get<std::string>() ==
|
||||
"markdown";
|
||||
std::string documentation =
|
||||
item_json["documentation"]["value"].get<std::string>();
|
||||
if (documentation.size() > 1024)
|
||||
item.is_markup = false;
|
||||
if (item.is_markup) {
|
||||
item.documentation =
|
||||
substitute_fence(documentation, editor->lang.name);
|
||||
} else {
|
||||
item.documentation = documentation;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item_json.contains("deprecated") &&
|
||||
item_json["deprecated"].is_boolean())
|
||||
item.deprecated = item_json["deprecated"].get<bool>();
|
||||
auto tags = item_json.value("tags", std::vector<int>());
|
||||
for (auto tag : tags)
|
||||
if (tag == 1)
|
||||
item.deprecated = true;
|
||||
item.sort = item_json.value("sortText", item.label);
|
||||
item.filter = item_json.value("filterText", item.label);
|
||||
if (item_json.contains("preselect") &&
|
||||
item_json["preselect"].is_boolean() &&
|
||||
item_json["preselect"].get<bool>())
|
||||
session.select = session.items.size() - 1;
|
||||
TextEdit edit;
|
||||
if (item_json.contains("textEdit")) {
|
||||
auto &te = item_json["textEdit"];
|
||||
if (te.contains("newText")) {
|
||||
edit.text = te.value("newText", "");
|
||||
if (te.contains("replace")) {
|
||||
edit.start.row = te["replace"]["start"]["line"];
|
||||
edit.start.col = te["replace"]["start"]["character"];
|
||||
edit.end.row = te["replace"]["end"]["line"];
|
||||
edit.end.col = te["replace"]["end"]["character"];
|
||||
} else if (te.contains("insert")) {
|
||||
edit.start.row = te["insert"]["start"]["line"];
|
||||
edit.start.col = te["insert"]["start"]["character"];
|
||||
edit.end.row = te["insert"]["end"]["line"];
|
||||
edit.end.col = te["insert"]["end"]["character"];
|
||||
} else if (te.contains("range")) {
|
||||
edit.start.row = te["range"]["start"]["line"];
|
||||
edit.start.col = te["range"]["start"]["character"];
|
||||
edit.end.row = te["range"]["end"]["line"];
|
||||
edit.end.col = te["range"]["end"]["character"];
|
||||
} else {
|
||||
edit.start = session.hook;
|
||||
edit.end = editor->cursor;
|
||||
}
|
||||
}
|
||||
} else if (item_json.contains("insertText") &&
|
||||
item_json["insertText"].is_string()) {
|
||||
edit.text = item_json["insertText"].get<std::string>();
|
||||
edit.start = session.hook;
|
||||
edit.end = editor->cursor;
|
||||
} else {
|
||||
edit.text = item.label;
|
||||
edit.start = session.hook;
|
||||
edit.end = editor->cursor;
|
||||
}
|
||||
utf8_normalize_edit(editor, &edit);
|
||||
item.edits.push_back(edit);
|
||||
if (item_json.contains("additionalTextEdits")) {
|
||||
for (auto &te : item_json["additionalTextEdits"]) {
|
||||
TextEdit edit;
|
||||
edit.text = te.value("newText", "");
|
||||
edit.start.row = te["range"]["start"]["line"];
|
||||
edit.start.col = te["range"]["start"]["character"];
|
||||
edit.end.row = te["range"]["end"]["line"];
|
||||
edit.end.col = te["range"]["end"]["character"];
|
||||
utf8_normalize_edit(editor, &edit);
|
||||
item.edits.push_back(edit);
|
||||
}
|
||||
}
|
||||
item.snippet = insert_text_format == 2;
|
||||
if (item_json.contains("insertTextFormat"))
|
||||
item.snippet = item_json["insertTextFormat"].get<int>() == 2;
|
||||
if (item_json.contains("insertTextMode"))
|
||||
item.asis = item_json["insertTextMode"].get<int>() == 1;
|
||||
if (item_json.contains("commitCharacters"))
|
||||
for (auto &c : item_json["commitCharacters"])
|
||||
if (c.is_string() && c.get<std::string>().size() == 1)
|
||||
item.end_chars.push_back(c.get<std::string>()[0]);
|
||||
session.items.push_back(std::move(item));
|
||||
session.visible.push_back(session.items.size() - 1);
|
||||
}
|
||||
session.box.hidden = false;
|
||||
session.box.render_update();
|
||||
};
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
LineIterator *it = begin_l_iter(editor->root, hook.row);
|
||||
char *line = next_line(it, nullptr);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
uint32_t col = utf8_byte_offset_to_utf16(line, editor->cursor.col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
lock.unlock();
|
||||
json message = {
|
||||
{"jsonrpc", "2.0"},
|
||||
{"method", "textDocument/completion"},
|
||||
{"params",
|
||||
{{"textDocument", {{"uri", editor->uri}}},
|
||||
{"position", {{"line", editor->cursor.row}, {"character", col}}}}}};
|
||||
if (editor->completion.trigger > 0) {
|
||||
json context = {{"triggerKind", editor->completion.trigger}};
|
||||
if (editor->completion.trigger == 2 && editor->completion.trigger_char)
|
||||
context["triggerCharacter"] =
|
||||
std::string(1, *editor->completion.trigger_char);
|
||||
message["params"]["context"] = context;
|
||||
}
|
||||
lsp_send(editor->lsp, message, pending);
|
||||
}
|
||||
|
||||
void handle_completion(Editor *editor, KeyEvent event) {
|
||||
if (!editor->lsp || !editor->lsp->allow_completion)
|
||||
return;
|
||||
if (mode != INSERT) {
|
||||
editor->completion.active = false;
|
||||
return;
|
||||
}
|
||||
std::unique_lock lock(editor->completion.mtx);
|
||||
if (event.key_type == KEY_PASTE) {
|
||||
editor->completion.active = false;
|
||||
return;
|
||||
} else if (event.key_type == KEY_CHAR) {
|
||||
char ch = *event.c;
|
||||
if (!editor->completion.active) {
|
||||
for (char c : editor->lsp->trigger_chars)
|
||||
if (c == ch) {
|
||||
editor->completion.trigger = 2;
|
||||
editor->completion.trigger_char = c;
|
||||
completion_request(editor);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!editor->completion.items.empty()) {
|
||||
const auto &item = editor->completion.items[editor->completion.select];
|
||||
const std::vector<char> &end_chars =
|
||||
item.end_chars.empty() ? editor->lsp->end_chars : item.end_chars;
|
||||
for (char c : end_chars)
|
||||
if (c == ch) {
|
||||
complete_accept(editor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
|
||||
(ch >= '0' && ch <= '9') || ch == '_') {
|
||||
if (editor->completion.active) {
|
||||
if (editor->completion.complete)
|
||||
completion_filter(editor);
|
||||
else
|
||||
completion_request(editor);
|
||||
} else {
|
||||
editor->completion.trigger = 3;
|
||||
completion_request(editor);
|
||||
}
|
||||
} else if (ch == CTRL('\\')) {
|
||||
if (editor->completion.active && !editor->completion.visible.empty()) {
|
||||
complete_accept(editor);
|
||||
} else {
|
||||
editor->completion.trigger = 1;
|
||||
completion_request(editor);
|
||||
}
|
||||
} else if (ch == CTRL('p')) {
|
||||
if (editor->completion.active)
|
||||
complete_next(editor);
|
||||
} else if (ch == CTRL('o')) {
|
||||
if (editor->completion.active)
|
||||
complete_prev(editor);
|
||||
} else if (ch == 0x7F || ch == 0x08 || ch == CTRL('W')) {
|
||||
if (editor->completion.active) {
|
||||
if (editor->completion.complete) {
|
||||
if (editor->cursor <= editor->completion.hook)
|
||||
editor->completion.active = false;
|
||||
else
|
||||
completion_filter(editor);
|
||||
} else {
|
||||
if (editor->cursor <= editor->completion.hook)
|
||||
editor->completion.active = false;
|
||||
else
|
||||
completion_request(editor);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
editor->completion.active = false;
|
||||
}
|
||||
} else if (event.key_type == KEY_MOUSE && event.mouse_modifier == 0) {
|
||||
// Prolly remove mouse support here
|
||||
// auto &box = editor->completion.box;
|
||||
// if (event.mouse_y >= box.position.row &&
|
||||
// event.mouse_x >= box.position.col) {
|
||||
// uint32_t row = event.mouse_y - box.position.row;
|
||||
// uint32_t col = event.mouse_x - box.position.col;
|
||||
// if (row < box.size.row && col < box.size.col) {
|
||||
// uint8_t idx = 0;
|
||||
// /* TODO: fix index relative to scroll */
|
||||
// complete_select(editor, idx);
|
||||
// }
|
||||
// }
|
||||
// if it is being implemented then stop main event handler from processing
|
||||
// when click inside the box
|
||||
editor->completion.active = false;
|
||||
} else {
|
||||
editor->completion.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
void completion_resolve_doc(Editor *editor) {
|
||||
auto &item = editor->completion.items[editor->completion.select];
|
||||
if (item.documentation)
|
||||
return;
|
||||
item.documentation = "";
|
||||
LSPPending *pending = new LSPPending();
|
||||
pending->editor = editor;
|
||||
pending->method = "completionItem/resolve";
|
||||
pending->callback = [](Editor *editor, std::string, json message) {
|
||||
std::unique_lock lock(editor->completion.mtx);
|
||||
auto &item = editor->completion.items[editor->completion.select];
|
||||
if (message["result"].contains("documentation")) {
|
||||
if (message["result"]["documentation"].is_string()) {
|
||||
item.documentation =
|
||||
message["result"]["documentation"].get<std::string>();
|
||||
} else if (message["result"]["documentation"].contains("value") &&
|
||||
message["result"]["documentation"]["value"].is_string()) {
|
||||
item.is_markup =
|
||||
message["result"]["documentation"]["kind"].get<std::string>() ==
|
||||
"markdown";
|
||||
std::string documentation =
|
||||
message["result"]["documentation"]["value"].get<std::string>();
|
||||
if (documentation.size() > 1024)
|
||||
item.is_markup = false;
|
||||
if (item.is_markup) {
|
||||
item.documentation =
|
||||
substitute_fence(documentation, editor->lang.name);
|
||||
} else {
|
||||
item.documentation = documentation;
|
||||
}
|
||||
}
|
||||
}
|
||||
editor->completion.box.render_update();
|
||||
};
|
||||
json message = {{"jsonrpc", "2.0"},
|
||||
{"method", "completionItem/resolve"},
|
||||
{"params", item.original}};
|
||||
lsp_send(editor->lsp, message, pending);
|
||||
}
|
||||
|
||||
void complete_accept(Editor *editor) {
|
||||
if (!editor->completion.active || editor->completion.box.hidden)
|
||||
return;
|
||||
auto &item = editor->completion.items[editor->completion.select];
|
||||
// TODO: support snippets and asis here
|
||||
// once indentation engine is implemented
|
||||
if (editor->completion.version != editor->lsp_version) {
|
||||
int delta_col = 0;
|
||||
TextEdit &e = item.edits[0];
|
||||
if (e.end.row == editor->cursor.row) {
|
||||
delta_col = editor->cursor.col - e.end.col;
|
||||
e.end.col = editor->cursor.col;
|
||||
for (size_t i = 1; i < item.edits.size(); ++i) {
|
||||
TextEdit &e = item.edits[i];
|
||||
if (e.start.row == editor->cursor.row) {
|
||||
e.start.col += delta_col;
|
||||
if (e.end.row == editor->cursor.row)
|
||||
e.end.col += delta_col;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
apply_lsp_edits(editor, item.edits, true);
|
||||
editor->completion.active = false;
|
||||
}
|
||||
|
||||
inline static int visible_index(const CompletionSession &s) {
|
||||
for (size_t i = 0; i < s.visible.size(); ++i)
|
||||
if (s.visible[i] == s.select)
|
||||
return (int)i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void complete_next(Editor *editor) {
|
||||
auto &s = editor->completion;
|
||||
if (!s.active || s.box.hidden || s.visible.empty())
|
||||
return;
|
||||
int vi = visible_index(s);
|
||||
if (vi < 0)
|
||||
vi = 0;
|
||||
else
|
||||
vi = (vi + 1) % s.visible.size();
|
||||
s.select = s.visible[vi];
|
||||
completion_resolve_doc(editor);
|
||||
editor->completion.box.render_update();
|
||||
}
|
||||
|
||||
void complete_prev(Editor *editor) {
|
||||
auto &s = editor->completion;
|
||||
if (!s.active || s.box.hidden || s.visible.empty())
|
||||
return;
|
||||
int vi = visible_index(s);
|
||||
if (vi < 0)
|
||||
vi = 0;
|
||||
else
|
||||
vi = (vi + s.visible.size() - 1) % s.visible.size();
|
||||
s.select = s.visible[vi];
|
||||
completion_resolve_doc(editor);
|
||||
editor->completion.box.render_update();
|
||||
}
|
||||
|
||||
void complete_select(Editor *editor, uint8_t index) {
|
||||
editor->completion.select = index;
|
||||
complete_accept(editor);
|
||||
}
|
||||
// #include "editor/decl.h"
|
||||
// #include "editor/editor.h"
|
||||
// #include "io/knot.h"
|
||||
// #include "io/sysio.h"
|
||||
// #include "lsp/lsp.h"
|
||||
// #include "main.h"
|
||||
// #include "ui/completionbox.h"
|
||||
// #include "utils/utils.h"
|
||||
//
|
||||
// inline static std::string completion_prefix(Editor *editor) {
|
||||
// Coord hook = editor->completion.hook;
|
||||
// Coord cur = editor->cursor;
|
||||
// if (hook.row != cur.row || cur.col < hook.col)
|
||||
// return "";
|
||||
// LineIterator *it = begin_l_iter(editor->root, hook.row);
|
||||
// uint32_t line_len;
|
||||
// char *line = next_line(it, &line_len);
|
||||
// if (!line) {
|
||||
// free(it->buffer);
|
||||
// free(it);
|
||||
// return "";
|
||||
// }
|
||||
// std::string prefix(line + hook.col, cur.col - hook.col);
|
||||
// free(it->buffer);
|
||||
// free(it);
|
||||
// return prefix;
|
||||
// }
|
||||
//
|
||||
// inline static void completion_adjust_scroll(CompletionSession &s) {
|
||||
// if (s.visible.empty())
|
||||
// return;
|
||||
// int vi = -1;
|
||||
// for (size_t i = 0; i < s.visible.size(); i++)
|
||||
// if (s.visible[i] == s.select) {
|
||||
// vi = (int)i;
|
||||
// break;
|
||||
// }
|
||||
// if (vi < 0)
|
||||
// return;
|
||||
// if ((uint32_t)vi < s.scroll)
|
||||
// s.scroll = vi;
|
||||
// else if ((uint32_t)vi >= s.scroll + 8)
|
||||
// s.scroll = vi - 7;
|
||||
// }
|
||||
//
|
||||
// void completion_filter(Editor *editor) {
|
||||
// auto &session = editor->completion;
|
||||
// std::string prefix = completion_prefix(editor);
|
||||
// session.visible.clear();
|
||||
// for (size_t i = 0; i < session.items.size(); ++i) {
|
||||
// const auto &item = session.items[i];
|
||||
// const std::string &key = item.filter;
|
||||
// if (key.size() >= prefix.size() &&
|
||||
// key.compare(0, prefix.size(), prefix) == 0)
|
||||
// session.visible.push_back(i);
|
||||
// }
|
||||
// if (session.visible.empty()) {
|
||||
// session.box.hidden = true;
|
||||
// return;
|
||||
// }
|
||||
// if (std::find(session.visible.begin(), session.visible.end(),
|
||||
// session.select) == session.visible.end())
|
||||
// session.select = session.visible[0];
|
||||
// session.box.hidden = false;
|
||||
// session.scroll = 0;
|
||||
// completion_adjust_scroll(session);
|
||||
// session.box.render_update();
|
||||
// }
|
||||
//
|
||||
// void completion_request(Editor *editor) {
|
||||
// Coord hook = editor->cursor;
|
||||
// editor->word_boundaries(editor->cursor, &hook.col, nullptr, nullptr,
|
||||
// nullptr); editor->completion.hook = hook; editor->completion.complete =
|
||||
// false; editor->completion.active = false; editor->completion.items.clear();
|
||||
// editor->completion.visible.clear();
|
||||
// editor->completion.select = 0;
|
||||
// editor->completion.version = editor->lsp_version;
|
||||
// LSPPending *pending = new LSPPending();
|
||||
// pending->editor = editor;
|
||||
// pending->callback = [](Editor *editor, const json &message) {
|
||||
// auto &session = editor->completion;
|
||||
// std::unique_lock lock(session.mtx);
|
||||
// std::vector<json> items_json;
|
||||
// std::vector<char> end_chars_def;
|
||||
// int insert_text_format = 1;
|
||||
// int insert_text_mode = 1;
|
||||
// if (message.contains("result")) {
|
||||
// auto &result = message["result"];
|
||||
// if (result.is_array()) {
|
||||
// items_json = result.get<std::vector<json>>();
|
||||
// session.complete = true;
|
||||
// if (items_json.empty())
|
||||
// return;
|
||||
// editor->completion.active = true;
|
||||
// } else if (result.is_object() && result.contains("items")) {
|
||||
// auto &list = result;
|
||||
// items_json = list["items"].get<std::vector<json>>();
|
||||
// if (items_json.empty())
|
||||
// return;
|
||||
// editor->completion.active = true;
|
||||
// session.complete = !list.value("isIncomplete", false);
|
||||
// if (list.contains("itemDefaults") &&
|
||||
// list["itemDefaults"].is_object()) {
|
||||
// auto &defs = list["itemDefaults"];
|
||||
// if (defs.contains("insertTextFormat") &&
|
||||
// defs["insertTextFormat"].is_number())
|
||||
// insert_text_format = defs["insertTextFormat"].get<int>();
|
||||
// if (defs.contains("insertTextMode") &&
|
||||
// defs["insertTextMode"].is_number())
|
||||
// insert_text_mode = defs["insertTextMode"].get<int>();
|
||||
// if (defs.contains("textEdit"))
|
||||
// if (defs["textEdit"].is_array())
|
||||
// for (auto &c : defs["textEdit"]) {
|
||||
// if (!c.is_string())
|
||||
// continue;
|
||||
// std::string str = c.get<std::string>();
|
||||
// if (str.size() != 1)
|
||||
// continue;
|
||||
// end_chars_def.push_back(str[0]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// session.items.reserve(items_json.size() + 1);
|
||||
// session.visible.reserve(items_json.size() + 1);
|
||||
// for (auto &item_json : items_json) {
|
||||
// CompletionItem item;
|
||||
// item.original = item_json;
|
||||
// item.label = item_json.value("label", "");
|
||||
// item.kind = item_json.value("kind", 0);
|
||||
// if (item_json.contains("detail") && item_json["detail"].is_string())
|
||||
// item.detail = item_json["detail"].get<std::string>();
|
||||
// if (item_json.contains("documentation")) {
|
||||
// if (item_json["documentation"].is_string()) {
|
||||
// item.documentation = item_json["documentation"].get<std::string>();
|
||||
// } else if (item_json["documentation"].contains("value") &&
|
||||
// item_json["documentation"]["value"].is_string()) {
|
||||
// item.is_markup =
|
||||
// item_json["documentation"]["kind"].get<std::string>() ==
|
||||
// "markdown";
|
||||
// std::string documentation =
|
||||
// item_json["documentation"]["value"].get<std::string>();
|
||||
// if (documentation.size() > 1024)
|
||||
// item.is_markup = false;
|
||||
// if (item.is_markup) {
|
||||
// item.documentation =
|
||||
// substitute_fence(documentation, editor->lang.name);
|
||||
// } else {
|
||||
// item.documentation = documentation;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (item_json.contains("deprecated") &&
|
||||
// item_json["deprecated"].is_boolean())
|
||||
// item.deprecated = item_json["deprecated"].get<bool>();
|
||||
// auto tags = item_json.value("tags", std::vector<int>());
|
||||
// for (auto tag : tags)
|
||||
// if (tag == 1)
|
||||
// item.deprecated = true;
|
||||
// item.sort = item_json.value("sortText", item.label);
|
||||
// item.filter = item_json.value("filterText", item.label);
|
||||
// if (item_json.contains("preselect") &&
|
||||
// item_json["preselect"].is_boolean() &&
|
||||
// item_json["preselect"].get<bool>())
|
||||
// session.select = session.items.size() - 1;
|
||||
// TextEdit edit;
|
||||
// if (item_json.contains("textEdit")) {
|
||||
// auto &te = item_json["textEdit"];
|
||||
// if (te.contains("newText")) {
|
||||
// edit.text = te.value("newText", "");
|
||||
// if (te.contains("replace")) {
|
||||
// edit.start.row = te["replace"]["start"]["line"];
|
||||
// edit.start.col = te["replace"]["start"]["character"];
|
||||
// edit.end.row = te["replace"]["end"]["line"];
|
||||
// edit.end.col = te["replace"]["end"]["character"];
|
||||
// } else if (te.contains("insert")) {
|
||||
// edit.start.row = te["insert"]["start"]["line"];
|
||||
// edit.start.col = te["insert"]["start"]["character"];
|
||||
// edit.end.row = te["insert"]["end"]["line"];
|
||||
// edit.end.col = te["insert"]["end"]["character"];
|
||||
// } else if (te.contains("range")) {
|
||||
// edit.start.row = te["range"]["start"]["line"];
|
||||
// edit.start.col = te["range"]["start"]["character"];
|
||||
// edit.end.row = te["range"]["end"]["line"];
|
||||
// edit.end.col = te["range"]["end"]["character"];
|
||||
// } else {
|
||||
// edit.start = session.hook;
|
||||
// edit.end = editor->cursor;
|
||||
// }
|
||||
// }
|
||||
// } else if (item_json.contains("insertText") &&
|
||||
// item_json["insertText"].is_string()) {
|
||||
// edit.text = item_json["insertText"].get<std::string>();
|
||||
// edit.start = session.hook;
|
||||
// edit.end = editor->cursor;
|
||||
// } else {
|
||||
// edit.text = item.label;
|
||||
// edit.start = session.hook;
|
||||
// edit.end = editor->cursor;
|
||||
// }
|
||||
// editor->utf8_normalize_edit(&edit);
|
||||
// item.edits.push_back(edit);
|
||||
// if (item_json.contains("additionalTextEdits")) {
|
||||
// for (auto &te : item_json["additionalTextEdits"]) {
|
||||
// TextEdit edit;
|
||||
// edit.text = te.value("newText", "");
|
||||
// edit.start.row = te["range"]["start"]["line"];
|
||||
// edit.start.col = te["range"]["start"]["character"];
|
||||
// edit.end.row = te["range"]["end"]["line"];
|
||||
// edit.end.col = te["range"]["end"]["character"];
|
||||
// editor->utf8_normalize_edit(&edit);
|
||||
// item.edits.push_back(edit);
|
||||
// }
|
||||
// }
|
||||
// item.snippet = insert_text_format == 2;
|
||||
// if (item_json.contains("insertTextFormat"))
|
||||
// item.snippet = item_json["insertTextFormat"].get<int>() == 2;
|
||||
// if (item_json.contains("insertTextMode"))
|
||||
// item.asis = item_json["insertTextMode"].get<int>() == 1;
|
||||
// if (item_json.contains("commitCharacters"))
|
||||
// for (auto &c : item_json["commitCharacters"])
|
||||
// if (c.is_string() && c.get<std::string>().size() == 1)
|
||||
// item.end_chars.push_back(c.get<std::string>()[0]);
|
||||
// session.items.push_back(std::move(item));
|
||||
// session.visible.push_back(session.items.size() - 1);
|
||||
// }
|
||||
// session.box.hidden = false;
|
||||
// session.box.render_update();
|
||||
// };
|
||||
// LineIterator *it = begin_l_iter(editor->root, hook.row);
|
||||
// uint32_t length;
|
||||
// char *line = next_line(it, &length);
|
||||
// if (!line) {
|
||||
// free(it->buffer);
|
||||
// free(it);
|
||||
// return;
|
||||
// }
|
||||
// uint32_t col = utf8_offset_to_utf16(line, length, editor->cursor.col);
|
||||
// free(it->buffer);
|
||||
// free(it);
|
||||
// json message = {
|
||||
// {"jsonrpc", "2.0"},
|
||||
// {"method", "textDocument/completion"},
|
||||
// {"params",
|
||||
// {{"textDocument", {{"uri", editor->uri}}},
|
||||
// {"position", {{"line", editor->cursor.row}, {"character", col}}}}}};
|
||||
// if (editor->completion.trigger > 0) {
|
||||
// json context = {{"triggerKind", editor->completion.trigger}};
|
||||
// if (editor->completion.trigger == 2 && editor->completion.trigger_char)
|
||||
// context["triggerCharacter"] =
|
||||
// std::string(1, *editor->completion.trigger_char);
|
||||
// message["params"]["context"] = context;
|
||||
// }
|
||||
// lsp_send(editor->lsp, message, pending);
|
||||
// }
|
||||
//
|
||||
// // Move this into the box and merge the box and this guy
|
||||
// void CompletionSession::handle(KeyEvent event) {
|
||||
// if (!editor->lsp || !editor->lsp->allow_completion)
|
||||
// return;
|
||||
// if (mode != INSERT) {
|
||||
// this->active = false;
|
||||
// return;
|
||||
// }
|
||||
// std::unique_lock lock(this->mtx);
|
||||
// if (event.key_type == KEY_PASTE) {
|
||||
// this->active = false;
|
||||
// return;
|
||||
// } else if (event.key_type == KEY_CHAR) {
|
||||
// char ch = *event.c;
|
||||
// if (!this->active) {
|
||||
// for (char c : editor->lsp->trigger_chars)
|
||||
// if (c == ch) {
|
||||
// this->trigger = 2;
|
||||
// this->trigger_char = c;
|
||||
// completion_request(editor);
|
||||
// return;
|
||||
// }
|
||||
// } else {
|
||||
// if (!editor->completion.items.empty()) {
|
||||
// const auto &item =
|
||||
// editor->completion.items[editor->completion.select]; const
|
||||
// std::vector<char> &end_chars =
|
||||
// item.end_chars.empty() ? editor->lsp->end_chars : item.end_chars;
|
||||
// for (char c : end_chars)
|
||||
// if (c == ch) {
|
||||
// this->accept();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
|
||||
// (ch >= '0' && ch <= '9') || ch == '_') {
|
||||
// if (this->active) {
|
||||
// if (this->complete)
|
||||
// completion_filter(editor);
|
||||
// else
|
||||
// completion_request(editor);
|
||||
// } else {
|
||||
// this->trigger = 3;
|
||||
// completion_request(editor);
|
||||
// }
|
||||
// } else if (ch == CTRL('\\')) {
|
||||
// if (this->active && !this->visible.empty()) {
|
||||
// this->accept();
|
||||
// } else {
|
||||
// this->trigger = 1;
|
||||
// completion_request(editor);
|
||||
// }
|
||||
// } else if (ch == CTRL('p')) {
|
||||
// if (this->active)
|
||||
// this->next();
|
||||
// } else if (ch == CTRL('o')) {
|
||||
// if (this->active)
|
||||
// this->prev();
|
||||
// } else if (ch == 0x7F || ch == 0x08 || ch == CTRL('W')) {
|
||||
// if (this->active) {
|
||||
// if (this->complete) {
|
||||
// if (editor->cursor <= this->hook)
|
||||
// this->active = false;
|
||||
// else
|
||||
// completion_filter(editor);
|
||||
// } else {
|
||||
// if (editor->cursor <= this->hook)
|
||||
// this->active = false;
|
||||
// else
|
||||
// completion_request(editor);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// this->active = false;
|
||||
// }
|
||||
// } else if (event.key_type == KEY_MOUSE && event.mouse_modifier == 0) {
|
||||
// // Prolly add mouse support here
|
||||
// // auto &box = this->box;
|
||||
// // if (event.mouse_y >= box.position.row &&
|
||||
// // event.mouse_x >= box.position.col) {
|
||||
// // uint32_t row = event.mouse_y - box.position.row;
|
||||
// // uint32_t col = event.mouse_x - box.position.col;
|
||||
// // if (row < box.size.row && col < box.size.col) {
|
||||
// // uint8_t idx = 0;
|
||||
// // /* TODO: fix index relative to scroll */
|
||||
// // complete_select(editor, idx);
|
||||
// // }
|
||||
// // }
|
||||
// // if it is being implemented then stop main event handler from
|
||||
// processing
|
||||
// // when click inside the box
|
||||
// this->active = false;
|
||||
// } else {
|
||||
// this->active = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// void CompletionSession::resolve_doc() {
|
||||
// auto &item = this->items[this->select];
|
||||
// if (item.documentation)
|
||||
// return;
|
||||
// item.documentation = "";
|
||||
// LSPPending *pending = new LSPPending();
|
||||
// pending->editor = editor;
|
||||
// pending->callback = [](Editor *editor, const json &message) {
|
||||
// std::unique_lock lock(editor->completion.mtx);
|
||||
// auto &item = editor->completion.items[editor->completion.select];
|
||||
// if (message["result"].contains("documentation")) {
|
||||
// if (message["result"]["documentation"].is_string()) {
|
||||
// item.documentation =
|
||||
// message["result"]["documentation"].get<std::string>();
|
||||
// } else if (message["result"]["documentation"].contains("value") &&
|
||||
// message["result"]["documentation"]["value"].is_string()) {
|
||||
// item.is_markup =
|
||||
// message["result"]["documentation"]["kind"].get<std::string>() ==
|
||||
// "markdown";
|
||||
// std::string documentation =
|
||||
// message["result"]["documentation"]["value"].get<std::string>();
|
||||
// if (documentation.size() > 1024)
|
||||
// item.is_markup = false;
|
||||
// if (item.is_markup) {
|
||||
// item.documentation =
|
||||
// substitute_fence(documentation, editor->lang.name);
|
||||
// } else {
|
||||
// item.documentation = documentation;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// editor->completion.box.render_update();
|
||||
// };
|
||||
// json message = {{"jsonrpc", "2.0"},
|
||||
// {"method", "completionItem/resolve"},
|
||||
// {"params", item.original}};
|
||||
// lsp_send(editor->lsp, message, pending);
|
||||
// }
|
||||
//
|
||||
// void CompletionSession::accept() {
|
||||
// if (!this->active || this->box.hidden)
|
||||
// return;
|
||||
// auto &item = this->items[this->select];
|
||||
// // TODO: support snippets and asis here
|
||||
// // once indentation engine is implemented
|
||||
// if (this->version != editor->lsp_version) {
|
||||
// int delta_col = 0;
|
||||
// TextEdit &e = item.edits[0];
|
||||
// if (e.end.row == editor->cursor.row) {
|
||||
// delta_col = editor->cursor.col - e.end.col;
|
||||
// e.end.col = editor->cursor.col;
|
||||
// for (size_t i = 1; i < item.edits.size(); ++i) {
|
||||
// TextEdit &e = item.edits[i];
|
||||
// if (e.start.row == editor->cursor.row) {
|
||||
// e.start.col += delta_col;
|
||||
// if (e.end.row == editor->cursor.row)
|
||||
// e.end.col += delta_col;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// editor->apply_lsp_edits(item.edits, true);
|
||||
// this->active = false;
|
||||
// }
|
||||
//
|
||||
// inline static int visible_index(const CompletionSession &s) {
|
||||
// for (size_t i = 0; i < s.visible.size(); ++i)
|
||||
// if (s.visible[i] == s.select)
|
||||
// return (int)i;
|
||||
// return -1;
|
||||
// }
|
||||
//
|
||||
// void CompletionSession::next() {
|
||||
// if (!this->active || this->box.hidden || this->visible.empty())
|
||||
// return;
|
||||
// int vi = visible_index(*this);
|
||||
// if (vi < 0)
|
||||
// vi = 0;
|
||||
// else
|
||||
// vi = (vi + 1) % this->visible.size();
|
||||
// this->select = this->visible[vi];
|
||||
// this->resolve_doc();
|
||||
// completion_adjust_scroll(*this);
|
||||
// this->box.render_update();
|
||||
// }
|
||||
//
|
||||
// void CompletionSession::prev() {
|
||||
// if (!this->active || this->box.hidden || this->visible.empty())
|
||||
// return;
|
||||
// int vi = visible_index(*this);
|
||||
// if (vi < 0)
|
||||
// vi = 0;
|
||||
// else
|
||||
// vi = (vi + this->visible.size() - 1) % this->visible.size();
|
||||
// this->select = this->visible[vi];
|
||||
// this->resolve_doc();
|
||||
// completion_adjust_scroll(*this);
|
||||
// this->box.render_update();
|
||||
// }
|
||||
//
|
||||
// void CompletionSession::choose(uint8_t index) {
|
||||
// this->select = index;
|
||||
// this->accept();
|
||||
// }
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "editor/editor.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
Coord move_right(Editor *editor, Coord cursor, uint32_t number) {
|
||||
Coord Editor::move_right(Coord cursor, uint32_t number) {
|
||||
Coord result = cursor;
|
||||
if (!editor || !editor->root || number == 0)
|
||||
if (!this->root || number == 0)
|
||||
return result;
|
||||
uint32_t row = result.row;
|
||||
uint32_t col = result.col;
|
||||
uint32_t line_len = 0;
|
||||
LineIterator *it = begin_l_iter(editor->root, row);
|
||||
LineIterator *it = begin_l_iter(this->root, row);
|
||||
if (!it)
|
||||
return result;
|
||||
char *line = next_line(it, &line_len);
|
||||
@@ -22,7 +22,7 @@ Coord move_right(Editor *editor, Coord cursor, uint32_t number) {
|
||||
while (number > 0) {
|
||||
if (col >= line_len) {
|
||||
uint32_t next_row = row + 1;
|
||||
if (next_row >= editor->root->line_count) {
|
||||
if (next_row >= this->root->line_count) {
|
||||
col = line_len;
|
||||
break;
|
||||
}
|
||||
@@ -49,14 +49,16 @@ Coord move_right(Editor *editor, Coord cursor, uint32_t number) {
|
||||
return result;
|
||||
}
|
||||
|
||||
Coord move_left(Editor *editor, Coord cursor, uint32_t number) {
|
||||
Coord Editor::move_left(Coord cursor, uint32_t number) {
|
||||
Coord result = cursor;
|
||||
if (!editor || !editor->root || number == 0)
|
||||
if (!this->root || number == 0)
|
||||
return result;
|
||||
uint32_t row = result.row;
|
||||
uint32_t col = result.col;
|
||||
uint32_t len = 0;
|
||||
LineIterator *it = begin_l_iter(editor->root, row);
|
||||
LineIterator *it = begin_l_iter(this->root, row);
|
||||
if (!it)
|
||||
return result;
|
||||
char *line = next_line(it, &len);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
@@ -102,29 +104,28 @@ Coord move_left(Editor *editor, Coord cursor, uint32_t number) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void cursor_down(Editor *editor, uint32_t number) {
|
||||
if (!editor || !editor->root || number == 0)
|
||||
void Editor::cursor_down(uint32_t number) {
|
||||
if (!this->root || number == 0)
|
||||
return;
|
||||
uint32_t visual_col = editor->cursor_preffered;
|
||||
uint32_t visual_col = this->cursor_preffered;
|
||||
if (visual_col == UINT32_MAX) {
|
||||
uint32_t len;
|
||||
LineIterator *it = begin_l_iter(editor->root, editor->cursor.row);
|
||||
LineIterator *it = begin_l_iter(this->root, this->cursor.row);
|
||||
char *line = next_line(it, &len);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
editor->cursor_preffered =
|
||||
get_visual_col_from_bytes(line, len, editor->cursor.col);
|
||||
visual_col = editor->cursor_preffered;
|
||||
this->cursor_preffered =
|
||||
get_visual_col_from_bytes(line, len, this->cursor.col);
|
||||
visual_col = this->cursor_preffered;
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
}
|
||||
editor->cursor.row =
|
||||
MIN(editor->cursor.row + number, editor->root->line_count - 1);
|
||||
this->cursor.row = MIN(this->cursor.row + number, this->root->line_count - 1);
|
||||
uint32_t len;
|
||||
LineIterator *it = begin_l_iter(editor->root, editor->cursor.row);
|
||||
LineIterator *it = begin_l_iter(this->root, this->cursor.row);
|
||||
char *line = next_line(it, &len);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
@@ -133,26 +134,26 @@ void cursor_down(Editor *editor, uint32_t number) {
|
||||
}
|
||||
if (len > 0 && line[len - 1] == '\n')
|
||||
--len;
|
||||
editor->cursor.col = get_bytes_from_visual_col(line, len, visual_col);
|
||||
this->cursor.col = get_bytes_from_visual_col(line, len, visual_col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
}
|
||||
|
||||
void cursor_up(Editor *editor, uint32_t number) {
|
||||
if (!editor || !editor->root || number == 0 || editor->cursor.row == 0)
|
||||
void Editor::cursor_up(uint32_t number) {
|
||||
if (!this->root || number == 0 || this->cursor.row == 0)
|
||||
return;
|
||||
uint32_t len;
|
||||
LineIterator *it = begin_l_iter(editor->root, editor->cursor.row);
|
||||
LineIterator *it = begin_l_iter(this->root, this->cursor.row);
|
||||
char *line_content = next_line(it, &len);
|
||||
if (!line_content)
|
||||
return;
|
||||
if (editor->cursor_preffered == UINT32_MAX)
|
||||
editor->cursor_preffered =
|
||||
get_visual_col_from_bytes(line_content, len, editor->cursor.col);
|
||||
uint32_t visual_col = editor->cursor_preffered;
|
||||
if (this->cursor_preffered == UINT32_MAX)
|
||||
this->cursor_preffered =
|
||||
get_visual_col_from_bytes(line_content, len, this->cursor.col);
|
||||
uint32_t visual_col = this->cursor_preffered;
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
uint32_t target_row = editor->cursor.row;
|
||||
uint32_t target_row = this->cursor.row;
|
||||
while (number > 0 && target_row > 0) {
|
||||
target_row--;
|
||||
if (target_row == 0) {
|
||||
@@ -161,32 +162,31 @@ void cursor_up(Editor *editor, uint32_t number) {
|
||||
}
|
||||
number--;
|
||||
}
|
||||
it = begin_l_iter(editor->root, target_row);
|
||||
it = begin_l_iter(this->root, target_row);
|
||||
line_content = next_line(it, &len);
|
||||
if (line_content) {
|
||||
if (len > 0 && line_content[len - 1] == '\n')
|
||||
--len;
|
||||
editor->cursor.row = target_row;
|
||||
editor->cursor.col =
|
||||
get_bytes_from_visual_col(line_content, len, visual_col);
|
||||
this->cursor.row = target_row;
|
||||
this->cursor.col = get_bytes_from_visual_col(line_content, len, visual_col);
|
||||
} else {
|
||||
editor->cursor.row = 0;
|
||||
editor->cursor.col = 0;
|
||||
this->cursor.row = 0;
|
||||
this->cursor.col = 0;
|
||||
}
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
}
|
||||
|
||||
void cursor_right(Editor *editor, uint32_t number) {
|
||||
if (!editor || !editor->root || number == 0)
|
||||
void Editor::cursor_right(uint32_t number) {
|
||||
if (!this->root || number == 0)
|
||||
return;
|
||||
editor->cursor = move_right(editor, editor->cursor, number);
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
this->cursor = this->move_right(this->cursor, number);
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
}
|
||||
|
||||
void cursor_left(Editor *editor, uint32_t number) {
|
||||
if (!editor || !editor->root || number == 0)
|
||||
void Editor::cursor_left(uint32_t number) {
|
||||
if (!this->root || number == 0)
|
||||
return;
|
||||
editor->cursor = move_left(editor, editor->cursor, number);
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
this->cursor = this->move_left(this->cursor, number);
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
}
|
||||
|
||||
@@ -1,236 +1,268 @@
|
||||
#include "editor/editor.h"
|
||||
#include "lsp/lsp.h"
|
||||
#include "utils/utils.h"
|
||||
#include <cstdint>
|
||||
|
||||
void edit_erase(Editor *editor, Coord pos, int64_t len) {
|
||||
void Editor::edit_erase(Coord pos, int64_t len) {
|
||||
if (len == 0)
|
||||
return;
|
||||
if (len < 0) {
|
||||
std::shared_lock lock_1(editor->knot_mtx);
|
||||
uint32_t cursor_original =
|
||||
line_to_byte(editor->root, editor->cursor.row, nullptr) +
|
||||
editor->cursor.col;
|
||||
uint32_t byte_pos = line_to_byte(editor->root, pos.row, nullptr) + pos.col;
|
||||
Coord point = move_left(editor, pos, -len);
|
||||
line_to_byte(this->root, this->cursor.row, nullptr) + this->cursor.col;
|
||||
uint32_t byte_pos = line_to_byte(this->root, pos.row, nullptr) + pos.col;
|
||||
Coord point = this->move_left(pos, -len);
|
||||
json lsp_range;
|
||||
bool do_lsp = (editor->lsp != nullptr);
|
||||
bool do_lsp = (this->lsp != nullptr);
|
||||
if (do_lsp) {
|
||||
LineIterator *it = begin_l_iter(editor->root, point.row);
|
||||
char *line = next_line(it, nullptr);
|
||||
LineIterator *it = begin_l_iter(this->root, point.row);
|
||||
uint32_t len;
|
||||
char *line = next_line(it, &len);
|
||||
int utf16_start = 0;
|
||||
if (line)
|
||||
utf16_start = utf8_byte_offset_to_utf16(line, point.col);
|
||||
utf16_start = utf8_offset_to_utf16(line, len, point.col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
it = begin_l_iter(editor->root, pos.row);
|
||||
line = next_line(it, nullptr);
|
||||
it = begin_l_iter(this->root, pos.row);
|
||||
line = next_line(it, &len);
|
||||
int utf16_end = 0;
|
||||
if (line)
|
||||
utf16_end = utf8_byte_offset_to_utf16(line, pos.col);
|
||||
utf16_end = utf8_offset_to_utf16(line, len, pos.col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
lsp_range = {{"start", {{"line", point.row}, {"character", utf16_start}}},
|
||||
{"end", {{"line", pos.row}, {"character", utf16_end}}}};
|
||||
}
|
||||
uint32_t start = line_to_byte(editor->root, point.row, nullptr) + point.col;
|
||||
uint32_t start = line_to_byte(this->root, point.row, nullptr) + point.col;
|
||||
if (cursor_original > start && cursor_original <= byte_pos) {
|
||||
editor->cursor = point;
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
this->cursor = point;
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
} else if (cursor_original > byte_pos) {
|
||||
uint32_t cursor_new = cursor_original - (byte_pos - start);
|
||||
uint32_t new_col;
|
||||
uint32_t new_row = byte_to_line(editor->root, cursor_new, &new_col);
|
||||
editor->cursor = {new_row, new_col};
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
uint32_t new_row = byte_to_line(this->root, cursor_new, &new_col);
|
||||
this->cursor = {new_row, new_col};
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
}
|
||||
lock_1.unlock();
|
||||
uint32_t start_row = point.row;
|
||||
uint32_t end_row = pos.row;
|
||||
apply_hook_deletion(editor, start_row + 1, end_row);
|
||||
std::unique_lock lock_2(editor->knot_mtx);
|
||||
editor->root = erase(editor->root, start, byte_pos - start);
|
||||
lock_2.unlock();
|
||||
if (editor->parser)
|
||||
editor->parser->edit(editor->root, start_row, end_row, start_row);
|
||||
this->apply_hook_deletion(start_row + 1, end_row);
|
||||
this->root = erase(this->root, start, byte_pos - start);
|
||||
if (this->parser)
|
||||
this->parser->edit(start_row, end_row - start_row, 0);
|
||||
if (do_lsp) {
|
||||
if (editor->lsp->incremental_sync) {
|
||||
json message = {
|
||||
{"jsonrpc", "2.0"},
|
||||
auto lsp = this->lsp.load();
|
||||
if (lsp->incremental_sync) {
|
||||
auto message = std::make_unique<LSPMessage>();
|
||||
message->message = {
|
||||
{"method", "textDocument/didChange"},
|
||||
{"params",
|
||||
{{"textDocument",
|
||||
{{"uri", editor->uri}, {"version", ++editor->lsp_version}}},
|
||||
{{"uri", this->uri}, {"version", ++this->lsp_version}}},
|
||||
{"contentChanges",
|
||||
json::array({{{"range", lsp_range}, {"text", ""}}})}}}};
|
||||
lsp_send(editor->lsp, message, nullptr);
|
||||
lsp->send(std::move(message));
|
||||
} else {
|
||||
char *buf = read(editor->root, 0, editor->root->char_count);
|
||||
char *buf = read(this->root, 0, this->root->char_count);
|
||||
std::string text(buf);
|
||||
free(buf);
|
||||
json message = {
|
||||
{"jsonrpc", "2.0"},
|
||||
auto message = std::make_unique<LSPMessage>();
|
||||
message->message = {
|
||||
{"method", "textDocument/didChange"},
|
||||
{"params",
|
||||
{{"textDocument",
|
||||
{{"uri", editor->uri}, {"version", ++editor->lsp_version}}},
|
||||
{{"uri", this->uri}, {"version", ++this->lsp_version}}},
|
||||
{"contentChanges", json::array({{{"text", text}}})}}}};
|
||||
lsp_send(editor->lsp, message, nullptr);
|
||||
lsp->send(std::move(message));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::shared_lock lock_1(editor->knot_mtx);
|
||||
uint32_t cursor_original =
|
||||
line_to_byte(editor->root, editor->cursor.row, nullptr) +
|
||||
editor->cursor.col;
|
||||
uint32_t byte_pos = line_to_byte(editor->root, pos.row, nullptr) + pos.col;
|
||||
Coord point = move_right(editor, pos, len);
|
||||
line_to_byte(this->root, this->cursor.row, nullptr) + this->cursor.col;
|
||||
uint32_t byte_pos = line_to_byte(this->root, pos.row, nullptr) + pos.col;
|
||||
Coord point = this->move_right(pos, len);
|
||||
json lsp_range;
|
||||
bool do_lsp = (editor->lsp != nullptr);
|
||||
bool do_lsp = (this->lsp != nullptr);
|
||||
if (do_lsp) {
|
||||
LineIterator *it = begin_l_iter(editor->root, pos.row);
|
||||
char *line = next_line(it, nullptr);
|
||||
LineIterator *it = begin_l_iter(this->root, pos.row);
|
||||
uint32_t line_len;
|
||||
char *line = next_line(it, &line_len);
|
||||
int utf16_start = 0;
|
||||
if (line)
|
||||
utf16_start = utf8_byte_offset_to_utf16(line, pos.col);
|
||||
utf16_start = utf8_offset_to_utf16(line, line_len, pos.col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
it = begin_l_iter(editor->root, point.row);
|
||||
line = next_line(it, nullptr);
|
||||
it = begin_l_iter(this->root, point.row);
|
||||
line = next_line(it, &line_len);
|
||||
int utf16_end = 0;
|
||||
if (line)
|
||||
utf16_end = utf8_byte_offset_to_utf16(line, point.col);
|
||||
utf16_end = utf8_offset_to_utf16(line, line_len, point.col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
lsp_range = {{"start", {{"line", pos.row}, {"character", utf16_start}}},
|
||||
{"end", {{"line", point.row}, {"character", utf16_end}}}};
|
||||
}
|
||||
uint32_t end = line_to_byte(editor->root, point.row, nullptr) + point.col;
|
||||
uint32_t end = line_to_byte(this->root, point.row, nullptr) + point.col;
|
||||
if (cursor_original > byte_pos && cursor_original <= end) {
|
||||
editor->cursor = pos;
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
this->cursor = pos;
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
} else if (cursor_original > end) {
|
||||
uint32_t cursor_new = cursor_original - (end - byte_pos);
|
||||
uint32_t new_col;
|
||||
uint32_t new_row = byte_to_line(editor->root, cursor_new, &new_col);
|
||||
editor->cursor = {new_row, new_col};
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
uint32_t new_row = byte_to_line(this->root, cursor_new, &new_col);
|
||||
this->cursor = {new_row, new_col};
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
}
|
||||
lock_1.unlock();
|
||||
uint32_t start_row = pos.row;
|
||||
uint32_t end_row = point.row;
|
||||
apply_hook_deletion(editor, start_row + 1, end_row);
|
||||
std::unique_lock lock_2(editor->knot_mtx);
|
||||
editor->root = erase(editor->root, byte_pos, end - byte_pos);
|
||||
lock_2.unlock();
|
||||
if (editor->parser)
|
||||
editor->parser->edit(editor->root, start_row, end_row, start_row);
|
||||
this->apply_hook_deletion(start_row + 1, end_row);
|
||||
this->root = erase(this->root, byte_pos, end - byte_pos);
|
||||
if (this->parser)
|
||||
this->parser->edit(start_row, end_row - start_row, 0);
|
||||
if (do_lsp) {
|
||||
if (editor->lsp->incremental_sync) {
|
||||
json message = {
|
||||
{"jsonrpc", "2.0"},
|
||||
auto lsp = this->lsp.load();
|
||||
if (lsp->incremental_sync) {
|
||||
auto message = std::make_unique<LSPMessage>();
|
||||
message->message = {
|
||||
{"method", "textDocument/didChange"},
|
||||
{"params",
|
||||
{{"textDocument",
|
||||
{{"uri", editor->uri}, {"version", ++editor->lsp_version}}},
|
||||
{{"uri", this->uri}, {"version", ++this->lsp_version}}},
|
||||
{"contentChanges",
|
||||
json::array({{{"range", lsp_range}, {"text", ""}}})}}}};
|
||||
lsp_send(editor->lsp, message, nullptr);
|
||||
lsp->send(std::move(message));
|
||||
} else {
|
||||
char *buf = read(editor->root, 0, editor->root->char_count);
|
||||
char *buf = read(this->root, 0, this->root->char_count);
|
||||
std::string text(buf);
|
||||
free(buf);
|
||||
json message = {
|
||||
{"jsonrpc", "2.0"},
|
||||
auto message = std::make_unique<LSPMessage>();
|
||||
message->message = {
|
||||
{"method", "textDocument/didChange"},
|
||||
{"params",
|
||||
{{"textDocument",
|
||||
{{"uri", editor->uri}, {"version", ++editor->lsp_version}}},
|
||||
{{"uri", this->uri}, {"version", ++this->lsp_version}}},
|
||||
{"contentChanges", json::array({{{"text", text}}})}}}};
|
||||
lsp_send(editor->lsp, message, nullptr);
|
||||
lsp->send(std::move(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void edit_insert(Editor *editor, Coord pos, char *data, uint32_t len) {
|
||||
std::shared_lock lock_1(editor->knot_mtx);
|
||||
void Editor::edit_insert(Coord pos, char *data, uint32_t len) {
|
||||
uint32_t cursor_original =
|
||||
line_to_byte(editor->root, editor->cursor.row, nullptr) +
|
||||
editor->cursor.col;
|
||||
uint32_t byte_pos = line_to_byte(editor->root, pos.row, nullptr) + pos.col;
|
||||
line_to_byte(this->root, this->cursor.row, nullptr) + this->cursor.col;
|
||||
uint32_t byte_pos = line_to_byte(this->root, pos.row, nullptr) + pos.col;
|
||||
if (cursor_original > byte_pos) {
|
||||
uint32_t cursor_new = cursor_original + len;
|
||||
uint32_t new_col;
|
||||
uint32_t new_row = byte_to_line(editor->root, cursor_new, &new_col);
|
||||
editor->cursor = {new_row, new_col};
|
||||
uint32_t new_row = byte_to_line(this->root, cursor_new, &new_col);
|
||||
this->cursor = {new_row, new_col};
|
||||
}
|
||||
lock_1.unlock();
|
||||
std::unique_lock lock_2(editor->knot_mtx);
|
||||
editor->root = insert(editor->root, byte_pos, data, len);
|
||||
LineIterator *it = begin_l_iter(this->root, pos.row);
|
||||
uint32_t line_len;
|
||||
char *line = next_line(it, &line_len);
|
||||
int utf16_col = 0;
|
||||
if (line)
|
||||
utf16_col = utf8_offset_to_utf16(line, line_len, pos.col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
this->root = insert(this->root, byte_pos, data, len);
|
||||
uint32_t rows = 0;
|
||||
for (uint32_t i = 0; i < len; i++)
|
||||
if (data[i] == '\n')
|
||||
rows++;
|
||||
apply_hook_insertion(editor, pos.row, rows);
|
||||
lock_2.unlock();
|
||||
if (editor->parser)
|
||||
editor->parser->edit(editor->root, pos.row, pos.row, pos.row + rows);
|
||||
if (editor->lsp) {
|
||||
if (editor->lsp->incremental_sync) {
|
||||
lock_1.lock();
|
||||
LineIterator *it = begin_l_iter(editor->root, pos.row);
|
||||
char *line = next_line(it, nullptr);
|
||||
int utf16_col = 0;
|
||||
if (line)
|
||||
utf16_col = utf8_byte_offset_to_utf16(line, pos.col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
lock_1.unlock();
|
||||
json message = {
|
||||
{"jsonrpc", "2.0"},
|
||||
this->apply_hook_insertion(pos.row, rows);
|
||||
if (this->parser)
|
||||
this->parser->edit(pos.row, 0, rows);
|
||||
auto lsp = this->lsp.load();
|
||||
if (lsp) {
|
||||
if (lsp->incremental_sync) {
|
||||
auto message = std::make_unique<LSPMessage>();
|
||||
message->message = {
|
||||
{"method", "textDocument/didChange"},
|
||||
{"params",
|
||||
{{"textDocument",
|
||||
{{"uri", editor->uri}, {"version", ++editor->lsp_version}}},
|
||||
{{"uri", this->uri}, {"version", ++this->lsp_version}}},
|
||||
{"contentChanges",
|
||||
json::array(
|
||||
{{{"range",
|
||||
{{"start", {{"line", pos.row}, {"character", utf16_col}}},
|
||||
{"end", {{"line", pos.row}, {"character", utf16_col}}}}},
|
||||
{"text", std::string(data, len)}}})}}}};
|
||||
lsp_send(editor->lsp, message, nullptr);
|
||||
lsp->send(std::move(message));
|
||||
} else {
|
||||
char *buf = read(editor->root, 0, editor->root->char_count);
|
||||
char *buf = read(this->root, 0, this->root->char_count);
|
||||
std::string text(buf);
|
||||
free(buf);
|
||||
json message = {
|
||||
{"jsonrpc", "2.0"},
|
||||
auto message = std::make_unique<LSPMessage>();
|
||||
message->message = {
|
||||
{"method", "textDocument/didChange"},
|
||||
{"params",
|
||||
{{"textDocument",
|
||||
{{"uri", editor->uri}, {"version", ++editor->lsp_version}}},
|
||||
{{"uri", this->uri}, {"version", ++this->lsp_version}}},
|
||||
{"contentChanges", json::array({{{"text", text}}})}}}};
|
||||
lsp_send(editor->lsp, message, nullptr);
|
||||
lsp->send(std::move(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void edit_replace(Editor *editor, Coord start, Coord end, const char *text,
|
||||
uint32_t len) {
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
void Editor::edit_replace(Coord start, Coord end, const char *text,
|
||||
uint32_t len) {
|
||||
uint32_t start_byte =
|
||||
line_to_byte(editor->root, start.row, nullptr) + start.col;
|
||||
uint32_t end_byte = line_to_byte(editor->root, end.row, nullptr) + end.col;
|
||||
char *buf = read(editor->root, start_byte, end_byte - start_byte);
|
||||
if (!buf)
|
||||
return;
|
||||
lock.unlock();
|
||||
uint32_t erase_len =
|
||||
count_clusters(buf, end_byte - start_byte, 0, end_byte - start_byte);
|
||||
free(buf);
|
||||
if (erase_len != 0)
|
||||
edit_erase(editor, start, erase_len);
|
||||
line_to_byte(this->root, start.row, nullptr) + start.col;
|
||||
uint32_t end_byte = line_to_byte(this->root, end.row, nullptr) + end.col;
|
||||
LineIterator *it = begin_l_iter(this->root, start.row);
|
||||
uint32_t line_len;
|
||||
char *line = next_line(it, &line_len);
|
||||
int utf16_start = 0;
|
||||
if (line)
|
||||
utf16_start = utf8_offset_to_utf16(line, line_len, start.col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
it = begin_l_iter(this->root, end.row);
|
||||
line = next_line(it, &line_len);
|
||||
int utf16_end = 0;
|
||||
if (line)
|
||||
utf16_end = utf8_offset_to_utf16(line, line_len, end.col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
if (start_byte != end_byte)
|
||||
this->root = erase(this->root, start_byte, end_byte - start_byte);
|
||||
if (len > 0)
|
||||
edit_insert(editor, start, const_cast<char *>(text), len);
|
||||
this->root = insert(this->root, start_byte, (char *)text, len);
|
||||
uint32_t rows = 0;
|
||||
for (uint32_t i = 0; i < len; i++)
|
||||
if (text[i] == '\n')
|
||||
rows++;
|
||||
if (this->parser)
|
||||
this->parser->edit(start.row, end.row - start.row, rows);
|
||||
auto lsp = this->lsp.load();
|
||||
if (lsp) {
|
||||
if (lsp->incremental_sync) {
|
||||
auto message = std::make_unique<LSPMessage>();
|
||||
message->message = {
|
||||
{"method", "textDocument/didChange"},
|
||||
{"params",
|
||||
{{"textDocument",
|
||||
{{"uri", this->uri}, {"version", ++this->lsp_version}}},
|
||||
{"contentChanges",
|
||||
json::array(
|
||||
{{{"range",
|
||||
{{"start",
|
||||
{{"line", start.row}, {"character", utf16_start}}},
|
||||
{"end", {{"line", end.row}, {"character", utf16_end}}}}},
|
||||
{"text", std::string(text, len)}}})}}}};
|
||||
lsp->send(std::move(message));
|
||||
} else {
|
||||
char *buf = read(this->root, 0, this->root->char_count);
|
||||
std::string full_text(buf);
|
||||
free(buf);
|
||||
auto message = std::make_unique<LSPMessage>();
|
||||
message->message = {
|
||||
{"method", "textDocument/didChange"},
|
||||
{"params",
|
||||
{{"textDocument",
|
||||
{{"uri", this->uri}, {"version", ++this->lsp_version}}},
|
||||
{"contentChanges", json::array({{{"text", full_text}}})}}}};
|
||||
lsp->send(std::move(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,88 +1,107 @@
|
||||
#include "editor/editor.h"
|
||||
#include "editor/decl.h"
|
||||
#include "lsp/lsp.h"
|
||||
#include "main.h"
|
||||
#include "syntax/langs.h"
|
||||
#include "utils/utils.h"
|
||||
#include <shared_mutex>
|
||||
|
||||
Editor *new_editor(const char *filename_arg, Coord position, Coord size) {
|
||||
Editor *editor = new Editor();
|
||||
if (!editor)
|
||||
return nullptr;
|
||||
Editor::Editor(const char *filename_arg, uint8_t eol) {
|
||||
uint32_t len = 0;
|
||||
std::string filename = path_abs(filename_arg);
|
||||
char *str = load_file(filename.c_str(), &len);
|
||||
this->unix_eol = eol & 1;
|
||||
char *str = load_file(filename.c_str(), &len, &this->unix_eol);
|
||||
if (!str) {
|
||||
free_editor(editor);
|
||||
return nullptr;
|
||||
str = (char *)malloc(1);
|
||||
*str = '\n';
|
||||
len = 1;
|
||||
}
|
||||
editor->filename = filename;
|
||||
editor->uri = path_to_file_uri(filename);
|
||||
editor->position = position;
|
||||
editor->size = size;
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
if ((eol >> 1) & 1)
|
||||
this->unix_eol = eol & 1;
|
||||
this->filename = filename;
|
||||
this->uri = path_to_file_uri(filename);
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
if (len == 0) {
|
||||
free(str);
|
||||
str = (char *)malloc(1);
|
||||
*str = '\n';
|
||||
len = 1;
|
||||
}
|
||||
editor->root = load(str, len, optimal_chunk_size(len));
|
||||
this->scroll = {0, 0};
|
||||
this->cursor = {0, 0};
|
||||
this->size = {20, 20};
|
||||
this->root = load(str, len, optimal_chunk_size(len));
|
||||
free(str);
|
||||
editor->lang = language_for_file(filename.c_str());
|
||||
if (editor->lang.name != "unknown")
|
||||
editor->parser = new Parser(editor->root, &editor->knot_mtx,
|
||||
editor->lang.name, size.row + 5);
|
||||
if (len <= (1024 * 28))
|
||||
request_add_to_lsp(editor->lang, editor);
|
||||
editor->indents.compute_indent(editor);
|
||||
return editor;
|
||||
this->lang = language_for_file(filename.c_str());
|
||||
if (parsers.find(this->lang.name) != parsers.end())
|
||||
this->parser = new Parser(this, this->lang.name, size.row + 5);
|
||||
if (this->lang.name == "css" || this->lang.name == "html" ||
|
||||
this->lang.name == "javascript" || this->lang.name == "markdown" ||
|
||||
this->lang.name == "typescript")
|
||||
this->is_css_color = true;
|
||||
if (len <= (1024 * 28)) {
|
||||
std::lock_guard lock(lsp::lsp_mutex);
|
||||
lsp::new_editors.push_back(this);
|
||||
}
|
||||
this->indents.compute_indent(this);
|
||||
}
|
||||
|
||||
void free_editor(Editor *editor) {
|
||||
remove_from_lsp(editor);
|
||||
if (editor->parser)
|
||||
delete editor->parser;
|
||||
editor->parser = nullptr;
|
||||
free_rope(editor->root);
|
||||
delete editor;
|
||||
Editor::~Editor() {
|
||||
auto lsp = this->lsp.load();
|
||||
if (lsp)
|
||||
lsp->remove(this);
|
||||
if (this->parser)
|
||||
delete this->parser;
|
||||
this->parser = nullptr;
|
||||
free_rope(this->root);
|
||||
}
|
||||
|
||||
void save_file(Editor *editor) {
|
||||
if (!editor || !editor->root)
|
||||
void Editor::save() {
|
||||
if (!this->root)
|
||||
return;
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
int version = editor->lsp_version;
|
||||
char *str = read(editor->root, 0, editor->root->char_count);
|
||||
int version = this->lsp_version;
|
||||
uint32_t char_count = this->root->char_count;
|
||||
char *str = read(this->root, 0, char_count);
|
||||
if (!str)
|
||||
return;
|
||||
lock.unlock();
|
||||
std::ofstream out(editor->filename);
|
||||
out.write(str, editor->root->char_count);
|
||||
std::ofstream out(this->filename);
|
||||
if (!this->unix_eol) {
|
||||
for (uint32_t i = 0; i < char_count; ++i) {
|
||||
if (str[i] == '\n')
|
||||
out.put('\r');
|
||||
out.put(str[i]);
|
||||
}
|
||||
} else {
|
||||
out.write(str, char_count);
|
||||
}
|
||||
out.close();
|
||||
free(str);
|
||||
if (editor->lsp) {
|
||||
json save_msg = {{"jsonrpc", "2.0"},
|
||||
{"method", "textDocument/didSave"},
|
||||
{"params", {{"textDocument", {{"uri", editor->uri}}}}}};
|
||||
lsp_send(editor->lsp, save_msg, nullptr);
|
||||
if (editor->lsp->allow_formatting) {
|
||||
json msg = {{"jsonrpc", "2.0"},
|
||||
{"method", "textDocument/formatting"},
|
||||
{"params",
|
||||
{{"textDocument", {{"uri", editor->uri}}},
|
||||
{"options",
|
||||
{{"tabSize", 2},
|
||||
{"insertSpaces", true},
|
||||
{"trimTrailingWhitespace", true},
|
||||
{"trimFinalNewlines", true}}}}}};
|
||||
LSPPending *pending = new LSPPending();
|
||||
pending->editor = editor;
|
||||
pending->method = "textDocument/formatting";
|
||||
pending->callback = [save_msg, version](Editor *editor, std::string,
|
||||
json message) {
|
||||
if (version != editor->lsp_version)
|
||||
ui::bar.log("Written " + std::to_string(char_count) + " bytes to " +
|
||||
this->filename);
|
||||
auto lsp = this->lsp.load();
|
||||
if (lsp) {
|
||||
log("Saving %s", this->filename.c_str());
|
||||
auto message = std::make_unique<LSPMessage>();
|
||||
message->message = {{"method", "textDocument/didSave"},
|
||||
{"params", {{"textDocument", {{"uri", this->uri}}}}}};
|
||||
lsp->send(std::move(message));
|
||||
if (lsp->allow_formatting) {
|
||||
log("Formatting %s", this->filename.c_str());
|
||||
json s_msg = {{"method", "textDocument/formatting"},
|
||||
{"params",
|
||||
{{"textDocument", {{"uri", this->uri}}},
|
||||
{"options",
|
||||
{{"tabSize", 2},
|
||||
{"insertSpaces", true},
|
||||
{"trimTrailingWhitespace", true},
|
||||
{"trimFinalNewlines", true}}}}}};
|
||||
auto save_msg = std::make_unique<LSPMessage>();
|
||||
save_msg->editor = this;
|
||||
save_msg->message = s_msg;
|
||||
save_msg->callback = [s_msg, version](const LSPMessage &msg) {
|
||||
log("Formattin");
|
||||
if (version != msg.editor->lsp_version)
|
||||
return;
|
||||
auto &edits = message["result"];
|
||||
auto &edits = msg.message["result"];
|
||||
if (edits.is_array()) {
|
||||
std::vector<TextEdit> t_edits;
|
||||
t_edits.reserve(edits.size());
|
||||
@@ -93,23 +112,35 @@ void save_file(Editor *editor) {
|
||||
t_edit.start.col = edit["range"]["start"]["character"];
|
||||
t_edit.end.row = edit["range"]["end"]["line"];
|
||||
t_edit.end.col = edit["range"]["end"]["character"];
|
||||
utf8_normalize_edit(editor, &t_edit);
|
||||
msg.editor->utf8_normalize_edit(&t_edit);
|
||||
t_edits.push_back(t_edit);
|
||||
}
|
||||
apply_lsp_edits(editor, t_edits, false);
|
||||
ensure_scroll(editor);
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
char *str = read(editor->root, 0, editor->root->char_count);
|
||||
msg.editor->apply_lsp_edits(t_edits, false);
|
||||
msg.editor->ensure_cursor();
|
||||
uint32_t char_count = msg.editor->root->char_count;
|
||||
char *str = read(msg.editor->root, 0, char_count);
|
||||
if (!str)
|
||||
return;
|
||||
lock.unlock();
|
||||
std::ofstream out(editor->filename);
|
||||
out.write(str, editor->root->char_count);
|
||||
std::ofstream out(msg.editor->filename);
|
||||
if (!msg.editor->unix_eol) {
|
||||
for (uint32_t i = 0; i < char_count; ++i) {
|
||||
if (str[i] == '\n')
|
||||
out.put('\r');
|
||||
out.put(str[i]);
|
||||
}
|
||||
} else {
|
||||
out.write(str, char_count);
|
||||
}
|
||||
out.close();
|
||||
free(str);
|
||||
lsp_send(editor->lsp, save_msg, nullptr);
|
||||
auto save_msg = std::make_unique<LSPMessage>();
|
||||
save_msg->editor = msg.editor;
|
||||
save_msg->message = s_msg;
|
||||
save_msg->callback = [](const LSPMessage &) {};
|
||||
msg.editor->lsp.load()->send(std::move(save_msg));
|
||||
}
|
||||
};
|
||||
lsp_send(editor->lsp, msg, pending);
|
||||
lsp->send(std::move(save_msg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,205 +1,59 @@
|
||||
#include "editor/editor.h"
|
||||
#include "lsp/lsp.h"
|
||||
#include "extentions/hover.h"
|
||||
#include "io/sysio.h"
|
||||
#include "main.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
void handle_editor_event(Editor *editor, KeyEvent event) {
|
||||
static std::chrono::steady_clock::time_point last_click_time =
|
||||
std::chrono::steady_clock::now();
|
||||
static uint32_t click_count = 0;
|
||||
static Coord last_click_pos = {UINT32_MAX, UINT32_MAX};
|
||||
Coord start = editor->cursor;
|
||||
void Editor::handle_event(KeyEvent event) {
|
||||
uint8_t old_mode = mode;
|
||||
if (editor->hover_active)
|
||||
editor->hover_active = false;
|
||||
if (event.key_type == KEY_MOUSE) {
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
now - last_click_time)
|
||||
.count();
|
||||
switch (event.mouse_state) {
|
||||
case SCROLL:
|
||||
switch (event.mouse_direction) {
|
||||
case SCROLL_UP:
|
||||
scroll_up(editor, 4);
|
||||
ensure_cursor(editor);
|
||||
break;
|
||||
case SCROLL_DOWN:
|
||||
scroll_down(editor, 4);
|
||||
ensure_cursor(editor);
|
||||
break;
|
||||
case SCROLL_LEFT:
|
||||
cursor_left(editor, 10);
|
||||
break;
|
||||
case SCROLL_RIGHT:
|
||||
cursor_right(editor, 10);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PRESS:
|
||||
if (event.mouse_button == LEFT_BTN) {
|
||||
Coord cur_pos = {event.mouse_x, event.mouse_y};
|
||||
if (duration < 250 && last_click_pos == cur_pos)
|
||||
click_count++;
|
||||
else
|
||||
click_count = 1;
|
||||
last_click_time = now;
|
||||
last_click_pos = cur_pos;
|
||||
Coord p = editor_hit_test(editor, event.mouse_x, event.mouse_y);
|
||||
if (p.row == UINT32_MAX && p.col == UINT32_MAX)
|
||||
return;
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
if (click_count == 1) {
|
||||
editor->cursor = p;
|
||||
editor->selection = p;
|
||||
if (mode == SELECT) {
|
||||
mode = NORMAL;
|
||||
editor->selection_active = false;
|
||||
}
|
||||
} else if (click_count == 2) {
|
||||
uint32_t prev_col, next_col;
|
||||
word_boundaries(editor, editor->cursor, &prev_col, &next_col, nullptr,
|
||||
nullptr);
|
||||
if (editor->cursor < editor->selection)
|
||||
editor->cursor = {editor->cursor.row, prev_col};
|
||||
else
|
||||
editor->cursor = {editor->cursor.row, next_col};
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
editor->selection_type = WORD;
|
||||
mode = SELECT;
|
||||
editor->selection_active = true;
|
||||
} else if (click_count >= 3) {
|
||||
if (editor->cursor < editor->selection) {
|
||||
editor->cursor = {p.row, 0};
|
||||
} else {
|
||||
uint32_t line_len;
|
||||
LineIterator *it = begin_l_iter(editor->root, p.row);
|
||||
char *line = next_line(it, &line_len);
|
||||
if (!line)
|
||||
return;
|
||||
if (line_len > 0 && line[line_len - 1] == '\n')
|
||||
line_len--;
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
editor->cursor = {p.row, line_len};
|
||||
}
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
editor->selection_type = LINE;
|
||||
mode = SELECT;
|
||||
editor->selection_active = true;
|
||||
click_count = 3;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DRAG:
|
||||
if (event.mouse_button == LEFT_BTN) {
|
||||
Coord p = editor_hit_test(editor, event.mouse_x, event.mouse_y);
|
||||
if (p.row == UINT32_MAX && p.col == UINT32_MAX)
|
||||
return;
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
mode = SELECT;
|
||||
if (!editor->selection_active) {
|
||||
editor->selection_active = true;
|
||||
editor->selection_type = CHAR;
|
||||
}
|
||||
uint32_t prev_col, next_col, line_len;
|
||||
switch (editor->selection_type) {
|
||||
case CHAR:
|
||||
editor->cursor = p;
|
||||
break;
|
||||
case WORD:
|
||||
word_boundaries(editor, p, &prev_col, &next_col, nullptr, nullptr);
|
||||
if (editor->cursor < editor->selection)
|
||||
editor->cursor = {p.row, prev_col};
|
||||
else
|
||||
editor->cursor = {p.row, next_col};
|
||||
break;
|
||||
case LINE:
|
||||
if (editor->cursor < editor->selection) {
|
||||
editor->cursor = {p.row, 0};
|
||||
} else {
|
||||
LineIterator *it = begin_l_iter(editor->root, p.row);
|
||||
char *line = next_line(it, &line_len);
|
||||
if (!line)
|
||||
return;
|
||||
if (line_len > 0 && line[line_len - 1] == '\n')
|
||||
line_len--;
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
editor->cursor = {p.row, line_len};
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RELEASE:
|
||||
if (event.mouse_button == LEFT_BTN)
|
||||
if (editor->cursor.row == editor->selection.row &&
|
||||
editor->cursor.col == editor->selection.col) {
|
||||
mode = NORMAL;
|
||||
editor->selection_active = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!this->hover_popup->hidden)
|
||||
this->hover_popup->hidden = true;
|
||||
if (event.key_type == KEY_SPECIAL) {
|
||||
switch (event.special_modifier) {
|
||||
case 0:
|
||||
switch (event.special_key) {
|
||||
case KEY_DOWN:
|
||||
cursor_down(editor, 1);
|
||||
this->cursor_down(1);
|
||||
break;
|
||||
case KEY_UP:
|
||||
cursor_up(editor, 1);
|
||||
this->cursor_up(1);
|
||||
break;
|
||||
case KEY_LEFT:
|
||||
cursor_left(editor, 1);
|
||||
this->cursor_left(1);
|
||||
break;
|
||||
case KEY_RIGHT:
|
||||
cursor_right(editor, 1);
|
||||
this->cursor_right(1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CNTRL:
|
||||
uint32_t prev_col, next_col;
|
||||
word_boundaries(editor, editor->cursor, &prev_col, &next_col, nullptr,
|
||||
nullptr);
|
||||
switch (event.special_key) {
|
||||
case KEY_DOWN:
|
||||
cursor_down(editor, 5);
|
||||
this->cursor_down(5);
|
||||
break;
|
||||
case KEY_UP:
|
||||
cursor_up(editor, 5);
|
||||
this->cursor_up(5);
|
||||
break;
|
||||
case KEY_LEFT:
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
if (prev_col == editor->cursor.col)
|
||||
cursor_left(editor, 1);
|
||||
else
|
||||
editor->cursor = {editor->cursor.row, prev_col};
|
||||
break;
|
||||
this->cursor_prev_word();
|
||||
case KEY_RIGHT:
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
if (next_col == editor->cursor.col)
|
||||
cursor_right(editor, 1);
|
||||
else
|
||||
editor->cursor = {editor->cursor.row, next_col};
|
||||
this->cursor_next_word();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ALT:
|
||||
switch (event.special_key) {
|
||||
case KEY_DOWN:
|
||||
move_line_down(editor);
|
||||
this->move_line_down();
|
||||
break;
|
||||
case KEY_UP:
|
||||
move_line_up(editor);
|
||||
this->move_line_up();
|
||||
break;
|
||||
case KEY_LEFT:
|
||||
cursor_left(editor, 8);
|
||||
this->cursor_left(8);
|
||||
break;
|
||||
case KEY_RIGHT:
|
||||
cursor_right(editor, 8);
|
||||
this->cursor_right(8);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -210,174 +64,86 @@ void handle_editor_event(Editor *editor, KeyEvent event) {
|
||||
if (event.key_type == KEY_CHAR && event.len == 1) {
|
||||
switch (event.c[0]) {
|
||||
case 'u':
|
||||
if (editor->root->line_count > 0) {
|
||||
editor->cursor.row = editor->root->line_count - 1;
|
||||
LineIterator *it = begin_l_iter(editor->root, editor->cursor.row);
|
||||
if (!it)
|
||||
break;
|
||||
uint32_t line_len;
|
||||
char *line = next_line(it, &line_len);
|
||||
if (!line)
|
||||
break;
|
||||
if (line_len > 0 && line[line_len - 1] == '\n')
|
||||
line_len--;
|
||||
line_len = count_clusters(line, line_len, 0, line_len);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
editor->cursor.col = line_len;
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
mode = SELECT;
|
||||
editor->selection_active = true;
|
||||
editor->selection = {0, 0};
|
||||
editor->selection_type = LINE;
|
||||
}
|
||||
this->select_all();
|
||||
break;
|
||||
case CTRL('h'):
|
||||
editor->hover.scroll(-1);
|
||||
editor->hover_active = true;
|
||||
this->hover_popup->scroll(-1);
|
||||
this->hover_popup->hidden = false;
|
||||
break;
|
||||
case CTRL('l'):
|
||||
editor->hover.scroll(1);
|
||||
editor->hover_active = true;
|
||||
this->hover_popup->scroll(1);
|
||||
this->hover_popup->hidden = false;
|
||||
break;
|
||||
case 'h':
|
||||
if (editor->lsp && editor->lsp->allow_hover) {
|
||||
LineIterator *it = begin_l_iter(editor->root, editor->cursor.row);
|
||||
char *line = next_line(it, nullptr);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
break;
|
||||
}
|
||||
uint32_t col = utf8_byte_offset_to_utf16(line, editor->cursor.col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
json hover_request = {
|
||||
{"jsonrpc", "2.0"},
|
||||
{"method", "textDocument/hover"},
|
||||
{"params",
|
||||
{{"textDocument", {{"uri", editor->uri}}},
|
||||
{"position",
|
||||
{{"line", editor->cursor.row}, {"character", col}}}}}};
|
||||
LSPPending *pending = new LSPPending();
|
||||
pending->editor = editor;
|
||||
pending->method = "textDocument/hover";
|
||||
pending->callback = [](Editor *editor, std::string, json hover) {
|
||||
if (hover.contains("result") && !hover["result"].is_null()) {
|
||||
auto &contents = hover["result"]["contents"];
|
||||
std::string hover_text = "";
|
||||
bool is_markup = false;
|
||||
if (contents.is_object()) {
|
||||
hover_text += contents["value"].get<std::string>();
|
||||
is_markup = (contents["kind"].get<std::string>() == "markdown");
|
||||
} else if (contents.is_array()) {
|
||||
for (auto &block : contents) {
|
||||
if (block.is_string()) {
|
||||
hover_text += block.get<std::string>() + "\n";
|
||||
} else if (block.is_object() && block.contains("language") &&
|
||||
block.contains("value")) {
|
||||
std::string lang = block["language"].get<std::string>();
|
||||
std::string val = block["value"].get<std::string>();
|
||||
is_markup = true;
|
||||
hover_text += "```" + lang + "\n" + val + "\n```\n";
|
||||
}
|
||||
}
|
||||
} else if (contents.is_string()) {
|
||||
hover_text += contents.get<std::string>();
|
||||
}
|
||||
if (!hover_text.empty()) {
|
||||
editor->hover.clear();
|
||||
editor->hover.text = clean_text(hover_text);
|
||||
editor->hover.is_markup = is_markup;
|
||||
editor->hover.render_first();
|
||||
editor->hover_active = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
lsp_send(editor->lsp, hover_request, pending);
|
||||
}
|
||||
this->fetch_lsp_hover();
|
||||
break;
|
||||
case 'a':
|
||||
case 'a': {
|
||||
mode = INSERT;
|
||||
cursor_right(editor, 1);
|
||||
if (start.row != editor->cursor.row)
|
||||
cursor_left(editor, 1);
|
||||
break;
|
||||
Coord start = this->cursor;
|
||||
this->cursor_right(1);
|
||||
if (start.row != this->cursor.row)
|
||||
this->cursor_left(1);
|
||||
} break;
|
||||
case 'i':
|
||||
mode = INSERT;
|
||||
break;
|
||||
case 'n':
|
||||
mode = JUMPER;
|
||||
editor->jumper_set = true;
|
||||
this->jumper_set = true;
|
||||
break;
|
||||
case 'm':
|
||||
mode = JUMPER;
|
||||
editor->jumper_set = false;
|
||||
this->jumper_set = false;
|
||||
break;
|
||||
case 'N':
|
||||
for (uint8_t i = 0; i < 94; i++)
|
||||
if (editor->hooks[i] == editor->cursor.row + 1) {
|
||||
editor->hooks[i] = 0;
|
||||
break;
|
||||
}
|
||||
this->clear_hooks_at_line(this->cursor.row);
|
||||
break;
|
||||
case 's':
|
||||
case 'v':
|
||||
mode = SELECT;
|
||||
editor->selection_active = true;
|
||||
editor->selection = editor->cursor;
|
||||
editor->selection_type = CHAR;
|
||||
this->selection_active = true;
|
||||
this->selection = this->cursor;
|
||||
this->selection_type = CHAR;
|
||||
break;
|
||||
case ';':
|
||||
case ':':
|
||||
mode = RUNNER;
|
||||
break;
|
||||
case 0x7F:
|
||||
cursor_left(editor, 1);
|
||||
this->cursor_left(1);
|
||||
break;
|
||||
case ' ':
|
||||
cursor_right(editor, 1);
|
||||
this->cursor_right(1);
|
||||
break;
|
||||
case '\r':
|
||||
case '\n':
|
||||
cursor_down(editor, 1);
|
||||
this->cursor_down(1);
|
||||
break;
|
||||
case '\\':
|
||||
case '|':
|
||||
cursor_up(editor, 1);
|
||||
this->cursor_up(1);
|
||||
break;
|
||||
case CTRL('d'):
|
||||
scroll_down(editor, 1);
|
||||
ensure_cursor(editor);
|
||||
this->scroll_down(1);
|
||||
this->ensure_cursor();
|
||||
break;
|
||||
case CTRL('u'):
|
||||
scroll_up(editor, 1);
|
||||
ensure_cursor(editor);
|
||||
this->scroll_up(1);
|
||||
this->ensure_cursor();
|
||||
break;
|
||||
case '>':
|
||||
case '.': {
|
||||
uint32_t delta = editor->indents.indent_line(editor->cursor.row);
|
||||
editor->cursor.col = start.col + delta;
|
||||
editor->cursor.row = start.row;
|
||||
} break;
|
||||
case '.':
|
||||
this->indent_current_line();
|
||||
break;
|
||||
case '<':
|
||||
case ',': {
|
||||
uint32_t delta = editor->indents.dedent_line(editor->cursor.row);
|
||||
editor->cursor.col = MAX((int64_t)start.col - delta, 0);
|
||||
editor->cursor.row = start.row;
|
||||
} break;
|
||||
case ',':
|
||||
this->dedent_current_line();
|
||||
break;
|
||||
case CTRL('s'):
|
||||
save_file(editor);
|
||||
this->save();
|
||||
break;
|
||||
case 'p':
|
||||
uint32_t len;
|
||||
char *text = get_from_clipboard(&len);
|
||||
if (text) {
|
||||
edit_insert(editor, editor->cursor, text, len);
|
||||
uint32_t grapheme_len = count_clusters(text, len, 0, len);
|
||||
cursor_right(editor, grapheme_len);
|
||||
free(text);
|
||||
}
|
||||
this->paste();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -386,268 +152,90 @@ void handle_editor_event(Editor *editor, KeyEvent event) {
|
||||
if (event.key_type == KEY_CHAR) {
|
||||
if (event.len == 1) {
|
||||
if (event.c[0] == '\t') {
|
||||
edit_insert(editor, editor->cursor, (char *)" ", 2);
|
||||
cursor_right(editor, 2);
|
||||
this->indents.insert_tab(this->cursor);
|
||||
} else if (event.c[0] == '\n' || event.c[0] == '\r') {
|
||||
editor->indents.insert_new_line(editor->cursor);
|
||||
this->indents.insert_new_line(this->cursor);
|
||||
} else if (event.c[0] == CTRL('W')) {
|
||||
uint32_t prev_col_byte, prev_col_cluster;
|
||||
word_boundaries(editor, editor->cursor, &prev_col_byte, nullptr,
|
||||
&prev_col_cluster, nullptr);
|
||||
if (prev_col_byte == editor->cursor.col)
|
||||
edit_erase(editor, editor->cursor, -1);
|
||||
else
|
||||
edit_erase(editor, editor->cursor, -(int64_t)prev_col_cluster);
|
||||
this->delete_prev_word();
|
||||
} else if (isprint((unsigned char)(event.c[0]))) {
|
||||
char c = event.c[0];
|
||||
uint32_t col = editor->cursor.col;
|
||||
LineIterator *it = begin_l_iter(editor->root, editor->cursor.row);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t len;
|
||||
char *line = next_line(it, &len);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
bool skip_insert = false;
|
||||
if (line && col < len) {
|
||||
char next = line[col];
|
||||
if ((c == '}' && next == '}') || (c == ')' && next == ')') ||
|
||||
(c == ']' && next == ']') || (c == '"' && next == '"') ||
|
||||
(c == '\'' && next == '\'')) {
|
||||
cursor_right(editor, 1);
|
||||
skip_insert = true;
|
||||
}
|
||||
}
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
if (!skip_insert) {
|
||||
char closing = 0;
|
||||
switch (c) {
|
||||
case '{':
|
||||
closing = '}';
|
||||
break;
|
||||
case '(':
|
||||
closing = ')';
|
||||
break;
|
||||
case '[':
|
||||
closing = ']';
|
||||
break;
|
||||
case '"':
|
||||
closing = '"';
|
||||
break;
|
||||
case '\'':
|
||||
closing = '\'';
|
||||
break;
|
||||
}
|
||||
if (closing) {
|
||||
char pair[2] = {c, closing};
|
||||
edit_insert(editor, editor->cursor, pair, 2);
|
||||
cursor_right(editor, 1);
|
||||
} else {
|
||||
edit_insert(editor, editor->cursor, &c, 1);
|
||||
cursor_right(editor, 1);
|
||||
}
|
||||
if (editor->lsp && editor->lsp->allow_formatting_on_type) {
|
||||
for (char ch : editor->lsp->format_chars) {
|
||||
if (ch == c) {
|
||||
LineIterator *it =
|
||||
begin_l_iter(editor->root, editor->cursor.row);
|
||||
if (!it)
|
||||
return;
|
||||
char *line = next_line(it, nullptr);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
uint32_t col =
|
||||
utf8_byte_offset_to_utf16(line, editor->cursor.col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
int version = editor->lsp_version;
|
||||
json message = {
|
||||
{"jsonrpc", "2.0"},
|
||||
{"method", "textDocument/onTypeFormatting"},
|
||||
{"params",
|
||||
{{"textDocument", {{"uri", editor->uri}}},
|
||||
{"position",
|
||||
{{"line", editor->cursor.row}, {"character", col}}},
|
||||
{"ch", std::string(1, c)},
|
||||
{"options",
|
||||
{{"tabSize", 2},
|
||||
{"insertSpaces", true},
|
||||
{"trimTrailingWhitespace", true},
|
||||
{"trimFinalNewlines", true}}}}}};
|
||||
LSPPending *pending = new LSPPending();
|
||||
pending->editor = editor;
|
||||
pending->method = "textDocument/onTypeFormatting";
|
||||
pending->callback = [version](Editor *editor, std::string,
|
||||
json message) {
|
||||
if (version != editor->lsp_version)
|
||||
return;
|
||||
auto &edits = message["result"];
|
||||
if (edits.is_array()) {
|
||||
std::vector<TextEdit> t_edits;
|
||||
t_edits.reserve(edits.size());
|
||||
for (auto &edit : edits) {
|
||||
TextEdit t_edit;
|
||||
t_edit.text = edit.value("newText", "");
|
||||
t_edit.start.row = edit["range"]["start"]["line"];
|
||||
t_edit.start.col = edit["range"]["start"]["character"];
|
||||
t_edit.end.row = edit["range"]["end"]["line"];
|
||||
t_edit.end.col = edit["range"]["end"]["character"];
|
||||
utf8_normalize_edit(editor, &t_edit);
|
||||
t_edits.push_back(t_edit);
|
||||
}
|
||||
apply_lsp_edits(editor, t_edits, false);
|
||||
ensure_scroll(editor);
|
||||
}
|
||||
};
|
||||
lsp_send(editor->lsp, message, pending);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this->insert_char(event.c[0]);
|
||||
} else if (event.c[0] == 0x7F || event.c[0] == 0x08) {
|
||||
Coord prev_pos = editor->cursor;
|
||||
if (prev_pos.col > 0)
|
||||
prev_pos.col--;
|
||||
LineIterator *it = begin_l_iter(editor->root, editor->cursor.row);
|
||||
if (!it)
|
||||
return;
|
||||
char *line = next_line(it, nullptr);
|
||||
char prev_char = line[prev_pos.col];
|
||||
char next_char = line[editor->cursor.col];
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
bool is_pair = (prev_char == '{' && next_char == '}') ||
|
||||
(prev_char == '(' && next_char == ')') ||
|
||||
(prev_char == '[' && next_char == ']') ||
|
||||
(prev_char == '"' && next_char == '"') ||
|
||||
(prev_char == '\'' && next_char == '\'');
|
||||
if (is_pair) {
|
||||
edit_erase(editor, editor->cursor, 1);
|
||||
edit_erase(editor, prev_pos, 1);
|
||||
} else {
|
||||
edit_erase(editor, editor->cursor, -1);
|
||||
}
|
||||
this->backspace_edit();
|
||||
} else if (event.c[0] == 0x1B) {
|
||||
Coord prev_pos = editor->cursor;
|
||||
mode = NORMAL;
|
||||
cursor_left(editor, 1);
|
||||
if (prev_pos.row != editor->cursor.row)
|
||||
cursor_right(editor, 1);
|
||||
this->normal_mode();
|
||||
}
|
||||
} else if (event.len > 1) {
|
||||
edit_insert(editor, editor->cursor, event.c, event.len);
|
||||
cursor_right(editor, 1);
|
||||
this->edit_insert(this->cursor, event.c, event.len);
|
||||
this->cursor_right(1);
|
||||
}
|
||||
} else if (event.key_type == KEY_SPECIAL &&
|
||||
event.special_key == KEY_DELETE) {
|
||||
switch (event.special_modifier) {
|
||||
case 0:
|
||||
edit_erase(editor, editor->cursor, 1);
|
||||
this->edit_erase(this->cursor, 1);
|
||||
break;
|
||||
case CNTRL:
|
||||
uint32_t next_col_byte, next_col_cluster;
|
||||
word_boundaries(editor, editor->cursor, nullptr, &next_col_byte,
|
||||
nullptr, &next_col_cluster);
|
||||
if (next_col_byte == editor->cursor.col)
|
||||
edit_erase(editor, editor->cursor, 1);
|
||||
else
|
||||
edit_erase(editor, editor->cursor, next_col_cluster);
|
||||
this->delete_next_word();
|
||||
break;
|
||||
}
|
||||
} else if (event.key_type == KEY_PASTE) {
|
||||
if (event.c) {
|
||||
edit_insert(editor, editor->cursor, event.c, event.len);
|
||||
uint32_t grapheme_len =
|
||||
count_clusters(event.c, event.len, 0, event.len);
|
||||
cursor_right(editor, grapheme_len);
|
||||
}
|
||||
this->insert_str(event.c, event.len);
|
||||
}
|
||||
break;
|
||||
case SELECT:
|
||||
if (event.key_type == KEY_CHAR && event.len == 1) {
|
||||
uint32_t len;
|
||||
char *text;
|
||||
Coord start;
|
||||
switch (event.c[0]) {
|
||||
case 0x1B:
|
||||
case 's':
|
||||
case 'v':
|
||||
editor->selection_active = false;
|
||||
this->selection_active = false;
|
||||
mode = NORMAL;
|
||||
break;
|
||||
case 'y':
|
||||
text = get_selection(editor, &len, nullptr);
|
||||
copy_to_clipboard(text, len);
|
||||
free(text);
|
||||
editor->selection_active = false;
|
||||
this->copy();
|
||||
mode = NORMAL;
|
||||
break;
|
||||
case 'x':
|
||||
text = get_selection(editor, &len, &start);
|
||||
copy_to_clipboard(text, len);
|
||||
len = count_clusters(text, len, 0, len);
|
||||
edit_erase(editor, start, len);
|
||||
free(text);
|
||||
editor->selection_active = false;
|
||||
this->cut();
|
||||
mode = NORMAL;
|
||||
break;
|
||||
case 'p':
|
||||
text = get_from_clipboard(&len);
|
||||
if (text) {
|
||||
Coord start, end;
|
||||
if (editor->cursor >= editor->selection) {
|
||||
start = editor->selection;
|
||||
end = move_right(editor, editor->cursor, 1);
|
||||
} else {
|
||||
start = editor->cursor;
|
||||
end = move_right(editor, editor->selection, 1);
|
||||
}
|
||||
uint32_t start_byte =
|
||||
line_to_byte(editor->root, start.row, nullptr) + start.col;
|
||||
uint32_t end_byte =
|
||||
line_to_byte(editor->root, end.row, nullptr) + end.col;
|
||||
edit_erase(editor, start, end_byte - start_byte);
|
||||
edit_insert(editor, editor->cursor, text, len);
|
||||
free(text);
|
||||
}
|
||||
editor->selection_active = false;
|
||||
this->paste();
|
||||
mode = NORMAL;
|
||||
break;
|
||||
case '<':
|
||||
case ',':
|
||||
this->dedent_selection();
|
||||
break;
|
||||
case '>':
|
||||
case '.':
|
||||
this->indent_selection();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case JUMPER:
|
||||
if (event.key_type == KEY_CHAR && event.len == 1 &&
|
||||
(event.c[0] >= '!' && event.c[0] <= '~')) {
|
||||
if (editor->jumper_set) {
|
||||
if (this->jumper_set) {
|
||||
for (uint8_t i = 0; i < 94; i++)
|
||||
if (editor->hooks[i] == editor->cursor.row + 1) {
|
||||
editor->hooks[i] = 0;
|
||||
if (this->hooks[i] == this->cursor.row + 1) {
|
||||
this->hooks[i] = 0;
|
||||
break;
|
||||
}
|
||||
editor->hooks[event.c[0] - '!'] = editor->cursor.row + 1;
|
||||
this->hooks[event.c[0] - '!'] = this->cursor.row + 1;
|
||||
} else {
|
||||
uint32_t line = editor->hooks[event.c[0] - '!'] - 1;
|
||||
uint32_t line = this->hooks[event.c[0] - '!'] - 1;
|
||||
if (line > 0) {
|
||||
editor->cursor = {line, 0};
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
this->cursor = {line, 0};
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
}
|
||||
}
|
||||
}
|
||||
mode = NORMAL;
|
||||
break;
|
||||
}
|
||||
if (old_mode == mode || mode != INSERT)
|
||||
handle_completion(editor, event);
|
||||
ensure_scroll(editor);
|
||||
if ((event.key_type == KEY_CHAR || event.key_type == KEY_PASTE) && event.c)
|
||||
free(event.c);
|
||||
// if (old_mode == mode || mode != INSERT)
|
||||
// this->completion.handle(event);
|
||||
this->ensure_scroll();
|
||||
}
|
||||
|
||||
563
src/editor/helpers.cc
Normal file
563
src/editor/helpers.cc
Normal file
@@ -0,0 +1,563 @@
|
||||
#include "editor/helpers.h"
|
||||
#include "editor/editor.h"
|
||||
#include "extentions/hover.h"
|
||||
#include "io/sysio.h"
|
||||
#include "lsp/lsp.h"
|
||||
#include "main.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
void Editor::cut() {
|
||||
if (ABS((int64_t)this->cursor.row - (int64_t)this->selection.row) > 1500) {
|
||||
ui::bar.log("Selection too large!");
|
||||
return;
|
||||
}
|
||||
if (mode != SELECT)
|
||||
return;
|
||||
Coord start;
|
||||
uint32_t len;
|
||||
char *text = this->get_selection(&len, &start);
|
||||
ruby_copy(text, len);
|
||||
len = count_clusters(text, len, 0, len);
|
||||
this->edit_erase(start, len);
|
||||
free(text);
|
||||
this->selection_active = false;
|
||||
}
|
||||
|
||||
void Editor::copy() {
|
||||
if (ABS((int64_t)this->cursor.row - (int64_t)this->selection.row) > 1500) {
|
||||
ui::bar.log("Selection too large!");
|
||||
return;
|
||||
}
|
||||
if (mode != SELECT)
|
||||
return;
|
||||
uint32_t len;
|
||||
char *text = this->get_selection(&len, nullptr);
|
||||
ruby_copy(text, len);
|
||||
free(text);
|
||||
this->selection_active = false;
|
||||
}
|
||||
|
||||
void Editor::paste() {
|
||||
if (mode == NORMAL) {
|
||||
std::string text = ruby_paste();
|
||||
if (text.empty())
|
||||
return;
|
||||
this->insert_str((char *)text.c_str(), text.length());
|
||||
} else if (mode == SELECT) {
|
||||
std::string text = ruby_paste();
|
||||
if (!text.empty()) {
|
||||
Coord start, end;
|
||||
this->selection_bounds(&start, &end);
|
||||
uint32_t start_byte =
|
||||
line_to_byte(this->root, start.row, nullptr) + start.col;
|
||||
uint32_t end_byte = line_to_byte(this->root, end.row, nullptr) + end.col;
|
||||
this->edit_erase(start, end_byte - start_byte);
|
||||
this->edit_insert(this->cursor, (char *)text.c_str(), text.length());
|
||||
}
|
||||
this->selection_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::insert_str(char *c, uint32_t len) {
|
||||
if (c) {
|
||||
this->edit_insert(this->cursor, c, len);
|
||||
uint32_t grapheme_len = count_clusters(c, len, 0, len);
|
||||
this->cursor_right(grapheme_len);
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::indent_current_line() {
|
||||
Coord start = this->cursor;
|
||||
uint32_t delta = this->indents.indent_line(this->cursor.row);
|
||||
this->cursor.col = start.col + delta;
|
||||
this->cursor.row = start.row;
|
||||
}
|
||||
|
||||
void Editor::dedent_current_line() {
|
||||
Coord start = this->cursor;
|
||||
uint32_t delta = this->indents.dedent_line(this->cursor.row);
|
||||
this->cursor.col = MAX((int64_t)start.col - delta, 0);
|
||||
this->cursor.row = start.row;
|
||||
}
|
||||
|
||||
static void move_coord_by_delta(Coord &c, uint32_t row, int64_t delta) {
|
||||
if (c.row == row) {
|
||||
int64_t new_col = (int64_t)c.col + delta;
|
||||
c.col = (uint32_t)MAX(new_col, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::indent_selection() {
|
||||
uint32_t top = MIN(this->cursor.row, this->selection.row);
|
||||
uint32_t bot = MAX(this->cursor.row, this->selection.row);
|
||||
if (bot - top > 1500) {
|
||||
ui::bar.log("Can't indent more than 1500 lines at once!");
|
||||
return;
|
||||
}
|
||||
if (bot - top >= 2)
|
||||
this->indents.indent_block(top + 1, bot - 1);
|
||||
uint32_t delta_top = this->indents.indent_line(top);
|
||||
uint32_t delta_bot =
|
||||
(bot == top) ? delta_top : this->indents.indent_line(bot);
|
||||
move_coord_by_delta(this->cursor, top, delta_top);
|
||||
move_coord_by_delta(this->selection, top, delta_top);
|
||||
if (bot != top) {
|
||||
move_coord_by_delta(this->cursor, bot, delta_bot);
|
||||
move_coord_by_delta(this->selection, bot, delta_bot);
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::dedent_selection() {
|
||||
uint32_t top = MIN(this->cursor.row, this->selection.row);
|
||||
uint32_t bot = MAX(this->cursor.row, this->selection.row);
|
||||
if (bot - top > 1500) {
|
||||
ui::bar.log("Can't dedent more than 1500 lines at once!");
|
||||
return;
|
||||
}
|
||||
if (bot - top >= 2)
|
||||
this->indents.dedent_block(top + 1, bot - 1);
|
||||
uint32_t delta_top = this->indents.dedent_line(top);
|
||||
uint32_t delta_bot =
|
||||
(bot == top) ? delta_top : this->indents.dedent_line(bot);
|
||||
move_coord_by_delta(this->cursor, top, -(int64_t)delta_top);
|
||||
move_coord_by_delta(this->selection, top, -(int64_t)delta_top);
|
||||
if (bot != top) {
|
||||
move_coord_by_delta(this->cursor, bot, -(int64_t)delta_bot);
|
||||
move_coord_by_delta(this->selection, bot, -(int64_t)delta_bot);
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::insert_char(char c) {
|
||||
uint32_t col = this->cursor.col;
|
||||
LineIterator *it = begin_l_iter(this->root, this->cursor.row);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t len;
|
||||
char *line = next_line(it, &len);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
bool skip_insert = false;
|
||||
if (line && col < len) {
|
||||
char next = line[col];
|
||||
if ((c == '}' && next == '}') || (c == ')' && next == ')') ||
|
||||
(c == ']' && next == ']') || (c == '"' && next == '"') ||
|
||||
(c == '\'' && next == '\'')) {
|
||||
this->cursor_right(1);
|
||||
skip_insert = true;
|
||||
}
|
||||
}
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
if (!skip_insert) {
|
||||
char closing = 0;
|
||||
switch (c) {
|
||||
case '{':
|
||||
closing = '}';
|
||||
break;
|
||||
case '(':
|
||||
closing = ')';
|
||||
break;
|
||||
case '[':
|
||||
closing = ']';
|
||||
break;
|
||||
case '"':
|
||||
closing = '"';
|
||||
break;
|
||||
case '\'':
|
||||
closing = '\'';
|
||||
break;
|
||||
}
|
||||
if (closing) {
|
||||
char pair[2] = {c, closing};
|
||||
this->edit_insert(this->cursor, pair, 2);
|
||||
this->cursor_right(1);
|
||||
} else {
|
||||
this->edit_insert(this->cursor, &c, 1);
|
||||
this->cursor_right(1);
|
||||
}
|
||||
auto lsp = this->lsp.load();
|
||||
if (lsp && lsp->allow_formatting_on_type) {
|
||||
for (char ch : lsp->format_chars) {
|
||||
if (ch == c) {
|
||||
LineIterator *it = begin_l_iter(this->root, this->cursor.row);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t len;
|
||||
char *line = next_line(it, &len);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
uint32_t col = utf8_offset_to_utf16(line, len, this->cursor.col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
int version = this->lsp_version;
|
||||
auto message = std::make_unique<LSPMessage>();
|
||||
message->message = {
|
||||
{"method", "textDocument/onTypeFormatting"},
|
||||
{"params",
|
||||
{{"textDocument", {{"uri", this->uri}}},
|
||||
{"position", {{"line", this->cursor.row}, {"character", col}}},
|
||||
{"ch", std::string(1, c)},
|
||||
{"options",
|
||||
{{"tabSize", 2},
|
||||
{"insertSpaces", true},
|
||||
{"trimTrailingWhitespace", true},
|
||||
{"trimFinalNewlines", true}}}}}};
|
||||
message->editor = this;
|
||||
message->callback = [version](const LSPMessage &message) {
|
||||
if (version != message.editor->lsp_version)
|
||||
return;
|
||||
auto &edits = message.message["result"];
|
||||
if (edits.is_array()) {
|
||||
std::vector<TextEdit> t_edits;
|
||||
t_edits.reserve(edits.size());
|
||||
for (auto &edit : edits) {
|
||||
TextEdit t_edit;
|
||||
t_edit.text = edit.value("newText", "");
|
||||
t_edit.start.row = edit["range"]["start"]["line"];
|
||||
t_edit.start.col = edit["range"]["start"]["character"];
|
||||
t_edit.end.row = edit["range"]["end"]["line"];
|
||||
t_edit.end.col = edit["range"]["end"]["character"];
|
||||
message.editor->utf8_normalize_edit(&t_edit);
|
||||
t_edits.push_back(t_edit);
|
||||
}
|
||||
message.editor->apply_lsp_edits(t_edits, false);
|
||||
message.editor->ensure_scroll();
|
||||
}
|
||||
};
|
||||
lsp->send(std::move(message));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::normal_mode() {
|
||||
Coord prev_pos = this->cursor;
|
||||
mode = NORMAL;
|
||||
this->cursor_left(1);
|
||||
if (prev_pos.row != this->cursor.row)
|
||||
this->cursor_right(1);
|
||||
}
|
||||
|
||||
void Editor::backspace_edit() {
|
||||
Coord prev_pos = this->cursor;
|
||||
if (prev_pos.col > 0)
|
||||
prev_pos.col--;
|
||||
LineIterator *it = begin_l_iter(this->root, this->cursor.row);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t len;
|
||||
char *line = next_line(it, &len);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
if (len > 0 && line[len - 1] == '\n')
|
||||
--len;
|
||||
char prev_char = (prev_pos.col < len) ? line[prev_pos.col] : 0;
|
||||
char next_char = (this->cursor.col < len) ? line[this->cursor.col] : 0;
|
||||
bool before_content = false;
|
||||
if (this->cursor.col > 0) {
|
||||
before_content = true;
|
||||
for (uint32_t i = 0; i < this->cursor.col; i++)
|
||||
if (line[i] != ' ' && line[i] != '\t') {
|
||||
before_content = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
if (before_content) {
|
||||
this->dedent_current_line();
|
||||
return;
|
||||
}
|
||||
bool is_pair = (prev_char == '{' && next_char == '}') ||
|
||||
(prev_char == '(' && next_char == ')') ||
|
||||
(prev_char == '[' && next_char == ']') ||
|
||||
(prev_char == '"' && next_char == '"') ||
|
||||
(prev_char == '\'' && next_char == '\'');
|
||||
if (is_pair) {
|
||||
this->edit_erase(this->cursor, 1);
|
||||
this->edit_erase(prev_pos, 1);
|
||||
} else {
|
||||
this->edit_erase(this->cursor, -1);
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::delete_prev_word() {
|
||||
uint32_t prev_col_byte, prev_col_cluster;
|
||||
this->word_boundaries(this->cursor, &prev_col_byte, nullptr,
|
||||
&prev_col_cluster, nullptr);
|
||||
if (prev_col_byte == this->cursor.col)
|
||||
this->edit_erase(this->cursor, -1);
|
||||
else
|
||||
this->edit_erase(this->cursor, -(int64_t)prev_col_cluster);
|
||||
}
|
||||
|
||||
void Editor::delete_next_word() {
|
||||
uint32_t next_col_byte, next_col_cluster;
|
||||
this->word_boundaries(this->cursor, nullptr, &next_col_byte, nullptr,
|
||||
&next_col_cluster);
|
||||
if (next_col_byte == this->cursor.col)
|
||||
this->edit_erase(this->cursor, 1);
|
||||
else
|
||||
this->edit_erase(this->cursor, next_col_cluster);
|
||||
}
|
||||
|
||||
void Editor::clear_hooks_at_line(uint32_t line) {
|
||||
for (uint8_t i = 0; i < 94; i++)
|
||||
if (this->hooks[i] == line + 1) {
|
||||
this->hooks[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::cursor_prev_word() {
|
||||
uint32_t prev_col;
|
||||
word_boundaries(this->cursor, &prev_col, nullptr, nullptr, nullptr);
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
if (prev_col == this->cursor.col)
|
||||
cursor_left(1);
|
||||
else
|
||||
this->cursor = {this->cursor.row, prev_col};
|
||||
}
|
||||
|
||||
void Editor::cursor_next_word() {
|
||||
uint32_t next_col;
|
||||
word_boundaries(this->cursor, nullptr, &next_col, nullptr, nullptr);
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
if (next_col == this->cursor.col)
|
||||
this->cursor_right(1);
|
||||
else
|
||||
this->cursor = {this->cursor.row, next_col};
|
||||
}
|
||||
|
||||
void Editor::select_all() {
|
||||
if (this->root->line_count > 0) {
|
||||
this->cursor.row = this->root->line_count - 1;
|
||||
LineIterator *it = begin_l_iter(this->root, this->cursor.row);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t line_len;
|
||||
char *line = next_line(it, &line_len);
|
||||
if (!line)
|
||||
return;
|
||||
if (line_len > 0 && line[line_len - 1] == '\n')
|
||||
line_len--;
|
||||
line_len = count_clusters(line, line_len, 0, line_len);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
this->cursor.col = line_len;
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
mode = SELECT;
|
||||
this->selection_active = true;
|
||||
this->selection = {0, 0};
|
||||
this->selection_type = LINE;
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::fetch_lsp_hover() {
|
||||
auto lsp = this->lsp.load();
|
||||
if (lsp && lsp->allow_hover) {
|
||||
LineIterator *it = begin_l_iter(this->root, this->cursor.row);
|
||||
uint32_t line_len;
|
||||
char *line = next_line(it, &line_len);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
uint32_t col = utf8_offset_to_utf16(line, line_len, this->cursor.col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
auto message = std::make_unique<LSPMessage>();
|
||||
message->message = {
|
||||
{"method", "textDocument/hover"},
|
||||
{"params",
|
||||
{{"textDocument", {{"uri", this->uri}}},
|
||||
{"position", {{"line", this->cursor.row}, {"character", col}}}}}};
|
||||
message->editor = this;
|
||||
message->callback = [](const LSPMessage &message) {
|
||||
auto &hover = message.message;
|
||||
if (hover.contains("result") && !hover["result"].is_null()) {
|
||||
auto &contents = hover["result"]["contents"];
|
||||
std::string hover_text = "";
|
||||
bool is_markup = false;
|
||||
if (contents.is_object()) {
|
||||
hover_text += contents["value"].get<std::string>();
|
||||
is_markup = (contents["kind"].get<std::string>() == "markdown");
|
||||
} else if (contents.is_array()) {
|
||||
for (auto &block : contents) {
|
||||
if (block.is_string()) {
|
||||
hover_text += block.get<std::string>() + "\n";
|
||||
} else if (block.is_object() && block.contains("language") &&
|
||||
block.contains("value")) {
|
||||
std::string lang = block["language"].get<std::string>();
|
||||
std::string val = block["value"].get<std::string>();
|
||||
is_markup = true;
|
||||
hover_text += "```" + lang + "\n" + val + "\n```\n";
|
||||
}
|
||||
}
|
||||
} else if (contents.is_string()) {
|
||||
hover_text += contents.get<std::string>();
|
||||
}
|
||||
if (!hover_text.empty()) {
|
||||
message.editor->hover_popup->clear();
|
||||
message.editor->hover_popup->text = clean_text(hover_text);
|
||||
message.editor->hover_popup->is_markup = is_markup;
|
||||
message.editor->hover_popup->hidden = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
lsp->send(std::move(message));
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::handle_click(KeyEvent event, Coord size) {
|
||||
layout::focused_window = this;
|
||||
this->size = size;
|
||||
static std::chrono::steady_clock::time_point last_click_time =
|
||||
std::chrono::steady_clock::now();
|
||||
static uint32_t click_count = 0;
|
||||
static Coord last_click_pos = {UINT32_MAX, UINT32_MAX};
|
||||
if (!this->hover_popup->hidden)
|
||||
this->hover_popup->hidden = true;
|
||||
if (event.key_type == KEY_MOUSE) {
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
now - last_click_time)
|
||||
.count();
|
||||
switch (event.mouse_state) {
|
||||
case SCROLL:
|
||||
switch (event.mouse_direction) {
|
||||
case SCROLL_UP:
|
||||
this->scroll_up(4);
|
||||
this->ensure_cursor();
|
||||
break;
|
||||
case SCROLL_DOWN:
|
||||
this->scroll_down(4);
|
||||
this->ensure_cursor();
|
||||
break;
|
||||
case SCROLL_LEFT:
|
||||
this->cursor_left(10);
|
||||
break;
|
||||
case SCROLL_RIGHT:
|
||||
this->cursor_right(10);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PRESS:
|
||||
if (event.mouse_button == LEFT_BTN) {
|
||||
Coord cur_pos = {event.mouse_x, event.mouse_y};
|
||||
if (duration < 250 && last_click_pos == cur_pos)
|
||||
click_count++;
|
||||
else
|
||||
click_count = 1;
|
||||
last_click_time = now;
|
||||
last_click_pos = cur_pos;
|
||||
Coord p = this->click_coord(event.mouse_x, event.mouse_y);
|
||||
if (p.row == UINT32_MAX && p.col == UINT32_MAX)
|
||||
return;
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
if (click_count == 1) {
|
||||
this->cursor = p;
|
||||
this->selection = p;
|
||||
if (mode == SELECT) {
|
||||
mode = NORMAL;
|
||||
this->selection_active = false;
|
||||
}
|
||||
} else if (click_count == 2) {
|
||||
uint32_t prev_col, next_col;
|
||||
this->word_boundaries(this->cursor, &prev_col, &next_col, nullptr,
|
||||
nullptr);
|
||||
if (this->cursor < this->selection)
|
||||
this->cursor = {this->cursor.row, prev_col};
|
||||
else
|
||||
this->cursor = {this->cursor.row, next_col};
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
this->selection_type = WORD;
|
||||
mode = SELECT;
|
||||
this->selection_active = true;
|
||||
} else if (click_count >= 3) {
|
||||
if (this->cursor < this->selection) {
|
||||
this->cursor = {p.row, 0};
|
||||
} else {
|
||||
uint32_t line_len;
|
||||
LineIterator *it = begin_l_iter(this->root, p.row);
|
||||
char *line = next_line(it, &line_len);
|
||||
if (!line)
|
||||
return;
|
||||
if (line_len > 0 && line[line_len - 1] == '\n')
|
||||
line_len--;
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
this->cursor = {p.row, line_len};
|
||||
}
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
this->selection_type = LINE;
|
||||
mode = SELECT;
|
||||
this->selection_active = true;
|
||||
click_count = 3;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DRAG:
|
||||
if (event.mouse_button == LEFT_BTN) {
|
||||
Coord p = this->click_coord(event.mouse_x, event.mouse_y);
|
||||
if (p.row == UINT32_MAX && p.col == UINT32_MAX)
|
||||
return;
|
||||
this->cursor_preffered = UINT32_MAX;
|
||||
mode = SELECT;
|
||||
if (!this->selection_active) {
|
||||
this->selection_active = true;
|
||||
this->selection_type = CHAR;
|
||||
}
|
||||
uint32_t prev_col, next_col, line_len;
|
||||
switch (this->selection_type) {
|
||||
case CHAR:
|
||||
this->cursor = p;
|
||||
break;
|
||||
case WORD:
|
||||
this->word_boundaries(p, &prev_col, &next_col, nullptr, nullptr);
|
||||
if (this->cursor < this->selection)
|
||||
this->cursor = {p.row, prev_col};
|
||||
else
|
||||
this->cursor = {p.row, next_col};
|
||||
break;
|
||||
case LINE:
|
||||
if (this->cursor < this->selection) {
|
||||
this->cursor = {p.row, 0};
|
||||
} else {
|
||||
LineIterator *it = begin_l_iter(this->root, p.row);
|
||||
char *line = next_line(it, &line_len);
|
||||
if (!line)
|
||||
return;
|
||||
if (line_len > 0 && line[line_len - 1] == '\n')
|
||||
line_len--;
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
this->cursor = {p.row, line_len};
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RELEASE:
|
||||
if (event.mouse_button == LEFT_BTN)
|
||||
if (this->cursor.row == this->selection.row &&
|
||||
this->cursor.col == this->selection.col) {
|
||||
mode = NORMAL;
|
||||
this->selection_active = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,18 @@ void IndentationEngine::compute_indent(Editor *n_editor) {
|
||||
indent = 2;
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
auto x = kLangtoBlockStartsEnd.find(editor->lang.name);
|
||||
if (x != kLangtoBlockStartsEnd.end())
|
||||
start_end = &x->second;
|
||||
x = kLangtoBlockStartsStart.find(editor->lang.name);
|
||||
if (x != kLangtoBlockStartsStart.end())
|
||||
start_start = &x->second;
|
||||
x = kLangtoBlockEndsFull.find(editor->lang.name);
|
||||
if (x != kLangtoBlockEndsFull.end())
|
||||
end_full = &x->second;
|
||||
x = kLangtoBlockEndsStart.find(editor->lang.name);
|
||||
if (x != kLangtoBlockEndsStart.end())
|
||||
end_start = &x->second;
|
||||
}
|
||||
|
||||
uint32_t IndentationEngine::indent_real(char *line, uint32_t len) {
|
||||
@@ -56,7 +68,6 @@ uint32_t IndentationEngine::indent_real(char *line, uint32_t len) {
|
||||
}
|
||||
|
||||
uint32_t IndentationEngine::indent_expected(uint32_t row) {
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
uint32_t line_idx = row;
|
||||
if (row == 0)
|
||||
return 0;
|
||||
@@ -75,18 +86,16 @@ uint32_t IndentationEngine::indent_expected(uint32_t row) {
|
||||
if (len == 0)
|
||||
continue;
|
||||
c_indent = indent_real(line, len);
|
||||
auto is_end_set = kLangtoBlockStartsEnd.find(editor->lang.name);
|
||||
auto is_start_set = kLangtoBlockStartsStart.find(editor->lang.name);
|
||||
bool is_end = false;
|
||||
if (is_end_set != kLangtoBlockStartsEnd.end())
|
||||
for (auto end : is_end_set->second)
|
||||
if (start_end)
|
||||
for (auto end : *start_end)
|
||||
if (ends_with(line, end)) {
|
||||
c_indent++;
|
||||
is_end = true;
|
||||
break;
|
||||
}
|
||||
if (!is_end && is_start_set != kLangtoBlockStartsStart.end())
|
||||
for (auto end : is_start_set->second)
|
||||
if (!is_end && start_start)
|
||||
for (auto end : *start_start)
|
||||
if (starts_with(line, end)) {
|
||||
c_indent++;
|
||||
break;
|
||||
@@ -99,7 +108,6 @@ uint32_t IndentationEngine::indent_expected(uint32_t row) {
|
||||
}
|
||||
|
||||
uint32_t IndentationEngine::set_indent(uint32_t row, int64_t new_indent) {
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
LineIterator *it = begin_l_iter(editor->root, row);
|
||||
if (!it)
|
||||
return 0;
|
||||
@@ -112,7 +120,6 @@ uint32_t IndentationEngine::set_indent(uint32_t row, int64_t new_indent) {
|
||||
}
|
||||
if (len > 0 && line[len - 1] == '\n')
|
||||
--len;
|
||||
lock.unlock();
|
||||
if (new_indent <= 0)
|
||||
new_indent = 0;
|
||||
uint32_t ws_len = 0;
|
||||
@@ -125,14 +132,13 @@ uint32_t IndentationEngine::set_indent(uint32_t row, int64_t new_indent) {
|
||||
new_ws.assign(new_indent * indent, ' ');
|
||||
Coord start = {row, 0};
|
||||
Coord end = {row, ws_len};
|
||||
edit_replace(editor, start, end, new_ws.c_str(), new_ws.length());
|
||||
editor->edit_replace(start, end, new_ws.c_str(), new_ws.length());
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return len - ws_len + (new_indent * indent);
|
||||
}
|
||||
|
||||
uint32_t IndentationEngine::indent_line(uint32_t row) {
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
LineIterator *it = begin_l_iter(editor->root, row);
|
||||
if (!it)
|
||||
return 0;
|
||||
@@ -143,7 +149,6 @@ uint32_t IndentationEngine::indent_line(uint32_t row) {
|
||||
free(it);
|
||||
return 0;
|
||||
}
|
||||
lock.unlock();
|
||||
if (len > 0 && line[len - 1] == '\n')
|
||||
--len;
|
||||
uint32_t new_indent = indent_real(line, len) + 1;
|
||||
@@ -155,15 +160,14 @@ uint32_t IndentationEngine::indent_line(uint32_t row) {
|
||||
new_ws.assign(new_indent, '\t');
|
||||
else
|
||||
new_ws.assign(new_indent * indent, ' ');
|
||||
edit_replace(editor, {row, 0}, {row, ws_len}, new_ws.c_str(),
|
||||
new_indent * indent);
|
||||
editor->edit_replace({row, 0}, {row, ws_len}, new_ws.c_str(),
|
||||
new_indent * indent);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return (uint32_t)ABS((int64_t)ws_len - (new_indent * indent));
|
||||
}
|
||||
|
||||
uint32_t IndentationEngine::dedent_line(uint32_t row) {
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
LineIterator *it = begin_l_iter(editor->root, row);
|
||||
if (!it)
|
||||
return 0;
|
||||
@@ -174,7 +178,6 @@ uint32_t IndentationEngine::dedent_line(uint32_t row) {
|
||||
free(it);
|
||||
return 0;
|
||||
}
|
||||
lock.unlock();
|
||||
if (len > 0 && line[len - 1] == '\n')
|
||||
--len;
|
||||
int64_t new_indent = (int64_t)indent_real(line, len) - 1;
|
||||
@@ -188,16 +191,107 @@ uint32_t IndentationEngine::dedent_line(uint32_t row) {
|
||||
new_ws.assign(new_indent, '\t');
|
||||
else
|
||||
new_ws.assign(new_indent * indent, ' ');
|
||||
edit_replace(editor, {row, 0}, {row, ws_len}, new_ws.c_str(),
|
||||
new_indent * indent);
|
||||
editor->edit_replace({row, 0}, {row, ws_len}, new_ws.c_str(),
|
||||
new_indent * indent);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return (uint32_t)ABS((int64_t)ws_len - (new_indent * indent));
|
||||
}
|
||||
|
||||
void IndentationEngine::insert_new_line(Coord cursor) {
|
||||
std::string formatted;
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
void IndentationEngine::indent_block(uint32_t start_row, uint32_t end_row) {
|
||||
indent_block(start_row, end_row, +1);
|
||||
}
|
||||
|
||||
void IndentationEngine::dedent_block(uint32_t start_row, uint32_t end_row) {
|
||||
indent_block(start_row, end_row, -1);
|
||||
}
|
||||
|
||||
void IndentationEngine::indent_block(uint32_t start_row, uint32_t end_row,
|
||||
int delta) {
|
||||
if (start_row > end_row)
|
||||
std::swap(start_row, end_row);
|
||||
uint32_t start_len, end_len;
|
||||
uint32_t start_off = line_to_byte(editor->root, start_row, &start_len);
|
||||
uint32_t end_off = line_to_byte(editor->root, end_row, &end_len);
|
||||
uint32_t total_len = (end_off - start_off) + end_len;
|
||||
char *block = read(editor->root, start_off, total_len);
|
||||
if (!block)
|
||||
return;
|
||||
uint32_t cap = total_len + 128;
|
||||
char *out = (char *)malloc(cap);
|
||||
uint32_t out_len = 0;
|
||||
char *p = block;
|
||||
char *end = block + total_len;
|
||||
while (p < end) {
|
||||
char *line_start = p;
|
||||
while (p < end && *p != '\n')
|
||||
p++;
|
||||
uint32_t len = (uint32_t)(p - line_start);
|
||||
uint32_t ws = 0;
|
||||
while (ws < len && (line_start[ws] == ' ' || line_start[ws] == '\t'))
|
||||
ws++;
|
||||
uint32_t real_indent = indent_real(line_start, len);
|
||||
int64_t new_indent = (int64_t)real_indent + delta;
|
||||
if (new_indent < 0)
|
||||
new_indent = 0;
|
||||
uint32_t indent_chars = (indent == 1) ? new_indent : new_indent * indent;
|
||||
uint32_t new_line_len = indent_chars + (len - ws);
|
||||
if (out_len + new_line_len + 2 >= cap) {
|
||||
cap = (cap * 2) + new_line_len + 32;
|
||||
out = (char *)realloc(out, cap);
|
||||
}
|
||||
if (indent == 1) {
|
||||
memset(out + out_len, '\t', indent_chars);
|
||||
out_len += indent_chars;
|
||||
} else {
|
||||
memset(out + out_len, ' ', indent_chars);
|
||||
out_len += indent_chars;
|
||||
}
|
||||
memcpy(out + out_len, line_start + ws, len - ws);
|
||||
out_len += (len - ws);
|
||||
if (p < end && *p == '\n') {
|
||||
out[out_len++] = '\n';
|
||||
p++;
|
||||
}
|
||||
}
|
||||
free(block);
|
||||
editor->edit_replace({start_row, 0}, {end_row, end_len}, out, out_len);
|
||||
free(out);
|
||||
}
|
||||
|
||||
void IndentationEngine::insert_tab(Coord cursor) {
|
||||
LineIterator *it = begin_l_iter(editor->root, cursor.row);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t len;
|
||||
char *line = next_line(it, &len);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
if (len > 0 && line[len - 1] == '\n')
|
||||
--len;
|
||||
uint32_t ws_len = 0;
|
||||
while (ws_len < len && (line[ws_len] == ' ' || line[ws_len] == '\t'))
|
||||
ws_len++;
|
||||
std::string insert;
|
||||
if (cursor.col <= ws_len) {
|
||||
if (indent == 1)
|
||||
insert = "\t";
|
||||
else
|
||||
insert.assign(indent - ((cursor.col) % indent), ' ');
|
||||
} else {
|
||||
insert = "\t";
|
||||
}
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
editor->edit_insert(cursor, (char *)insert.c_str(), insert.size());
|
||||
editor->cursor.col += insert.size();
|
||||
}
|
||||
|
||||
void IndentationEngine::insert_new_line(Coord cursor) {
|
||||
std::string formatted;
|
||||
LineIterator *it = begin_l_iter(editor->root, cursor.row);
|
||||
if (!it)
|
||||
return;
|
||||
@@ -208,29 +302,25 @@ void IndentationEngine::insert_new_line(Coord cursor) {
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
lock.unlock();
|
||||
if (len > 0 && line[len - 1] == '\n')
|
||||
--len;
|
||||
if (cursor.col >= len) {
|
||||
auto is_end_full = kLangtoBlockEndsFull.find(editor->lang.name);
|
||||
auto is_end_start = kLangtoBlockEndsStart.find(editor->lang.name);
|
||||
bool end_matched = false;
|
||||
if (is_end_full != kLangtoBlockEndsFull.end())
|
||||
for (auto end : is_end_full->second)
|
||||
if (end_full)
|
||||
for (auto end : *end_full)
|
||||
if (end == trim(line)) {
|
||||
cursor.col =
|
||||
set_indent(cursor.row, (int64_t)indent_expected(cursor.row) - 1);
|
||||
cursor.col = set_indent(
|
||||
cursor.row, (int64_t)indent_expected(cursor.row) - (int64_t)1);
|
||||
end_matched = true;
|
||||
break;
|
||||
}
|
||||
if (!end_matched && is_end_start != kLangtoBlockEndsStart.end())
|
||||
for (auto end : is_end_start->second)
|
||||
if (!end_matched && end_start)
|
||||
for (auto end : *end_start)
|
||||
if (starts_with(trim(line), end)) {
|
||||
cursor.col =
|
||||
set_indent(cursor.row, (int64_t)indent_expected(cursor.row) - 1);
|
||||
cursor.col = set_indent(
|
||||
cursor.row, (int64_t)indent_expected(cursor.row) - (int64_t)1);
|
||||
break;
|
||||
}
|
||||
lock.lock();
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
it = begin_l_iter(editor->root, cursor.row);
|
||||
@@ -244,41 +334,35 @@ void IndentationEngine::insert_new_line(Coord cursor) {
|
||||
}
|
||||
if (len > 0 && line[len - 1] == '\n')
|
||||
--len;
|
||||
lock.unlock();
|
||||
}
|
||||
std::string ending = trim(std::string(line + cursor.col, len - cursor.col));
|
||||
std::string before = trim(std::string(line, cursor.col));
|
||||
uint32_t c_indent = indent_real(line, len);
|
||||
int64_t c_indent = indent_real(line, len);
|
||||
if (!ending.empty()) {
|
||||
bool ending_valid = false;
|
||||
bool starting_valid = false;
|
||||
auto is_end_full = kLangtoBlockEndsFull.find(editor->lang.name);
|
||||
auto is_end_start = kLangtoBlockEndsStart.find(editor->lang.name);
|
||||
auto is_end_set = kLangtoBlockStartsEnd.find(editor->lang.name);
|
||||
auto is_start_set = kLangtoBlockStartsStart.find(editor->lang.name);
|
||||
if (is_end_full != kLangtoBlockEndsFull.end())
|
||||
for (auto end : is_end_full->second)
|
||||
if (end_full)
|
||||
for (auto end : *end_full)
|
||||
if (ending == end) {
|
||||
ending_valid = true;
|
||||
break;
|
||||
}
|
||||
if (!ending_valid && is_end_start != kLangtoBlockEndsStart.end())
|
||||
for (auto end : is_end_start->second)
|
||||
if (!ending_valid && end_start)
|
||||
for (auto end : *end_start)
|
||||
if (starts_with(ending, end)) {
|
||||
ending_valid = true;
|
||||
break;
|
||||
}
|
||||
if (is_end_set != kLangtoBlockStartsEnd.end())
|
||||
for (auto end : is_end_set->second)
|
||||
if (start_end)
|
||||
for (auto end : *start_end)
|
||||
if (ends_with(before, end)) {
|
||||
c_indent++;
|
||||
starting_valid = true;
|
||||
break;
|
||||
}
|
||||
if (!starting_valid && is_start_set != kLangtoBlockStartsStart.end())
|
||||
for (auto end : is_start_set->second)
|
||||
if (!starting_valid && start_start)
|
||||
for (auto end : *start_start)
|
||||
if (starts_with(before, end)) {
|
||||
c_indent++;
|
||||
starting_valid = true;
|
||||
break;
|
||||
}
|
||||
if (ending_valid && starting_valid)
|
||||
@@ -289,51 +373,55 @@ void IndentationEngine::insert_new_line(Coord cursor) {
|
||||
else if (ending_valid)
|
||||
c_indent--;
|
||||
}
|
||||
auto is_end_set = kLangtoBlockStartsEnd.find(editor->lang.name);
|
||||
auto is_start_set = kLangtoBlockStartsStart.find(editor->lang.name);
|
||||
bool is_end = false;
|
||||
if (is_end_set != kLangtoBlockStartsEnd.end())
|
||||
for (auto end : is_end_set->second)
|
||||
if (start_end)
|
||||
for (auto end : *start_end)
|
||||
if (ends_with(before, end)) {
|
||||
c_indent++;
|
||||
is_end = true;
|
||||
break;
|
||||
}
|
||||
if (!is_end && is_start_set != kLangtoBlockStartsStart.end())
|
||||
for (auto end : is_start_set->second)
|
||||
if (!is_end && start_start)
|
||||
for (auto end : *start_start)
|
||||
if (starts_with(before, end)) {
|
||||
c_indent++;
|
||||
break;
|
||||
}
|
||||
if (c_indent < 0)
|
||||
c_indent = 0;
|
||||
formatted = "\n" +
|
||||
(indent == 1 ? std::string(c_indent, '\t')
|
||||
: std::string(c_indent * indent, ' ')) +
|
||||
ending;
|
||||
Coord new_cursor = {cursor.row + 1, c_indent * indent};
|
||||
edit_replace(editor, cursor, {cursor.row, len}, formatted.data(),
|
||||
formatted.size());
|
||||
Coord new_cursor = {cursor.row + 1, (uint32_t)c_indent * indent};
|
||||
editor->edit_replace(cursor, {cursor.row, len}, formatted.data(),
|
||||
formatted.size());
|
||||
editor->cursor = new_cursor;
|
||||
editor->cursor_preffered = UINT32_MAX;
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
if (!editor->lsp || !editor->lsp->allow_formatting_on_type)
|
||||
auto lsp = editor->lsp.load();
|
||||
if (!lsp || !lsp->allow_formatting_on_type)
|
||||
return;
|
||||
for (char ch : editor->lsp->format_chars) {
|
||||
for (char ch : lsp->format_chars) {
|
||||
if (ch == '\n') {
|
||||
LineIterator *it = begin_l_iter(editor->root, editor->cursor.row);
|
||||
if (!it)
|
||||
return;
|
||||
char *line = next_line(it, nullptr);
|
||||
uint32_t line_len;
|
||||
char *line = next_line(it, &line_len);
|
||||
if (!line) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
uint32_t col = utf8_byte_offset_to_utf16(line, editor->cursor.col);
|
||||
uint32_t col = utf8_offset_to_utf16(line, line_len, editor->cursor.col);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
int version = editor->lsp_version;
|
||||
json message = {
|
||||
auto message = std::make_unique<LSPMessage>();
|
||||
message->editor = editor;
|
||||
message->message = {
|
||||
{"jsonrpc", "2.0"},
|
||||
{"method", "textDocument/onTypeFormatting"},
|
||||
{"params",
|
||||
@@ -345,13 +433,10 @@ void IndentationEngine::insert_new_line(Coord cursor) {
|
||||
{"insertSpaces", true},
|
||||
{"trimTrailingWhitespace", true},
|
||||
{"trimFinalNewlines", true}}}}}};
|
||||
LSPPending *pending = new LSPPending();
|
||||
pending->editor = editor;
|
||||
pending->method = "textDocument/onTypeFormatting";
|
||||
pending->callback = [version](Editor *editor, std::string, json message) {
|
||||
if (version != editor->lsp_version)
|
||||
message->callback = [version](const LSPMessage &message) {
|
||||
if (version != message.editor->lsp_version)
|
||||
return;
|
||||
auto &edits = message["result"];
|
||||
auto &edits = message.message["result"];
|
||||
if (edits.is_array()) {
|
||||
std::vector<TextEdit> t_edits;
|
||||
t_edits.reserve(edits.size());
|
||||
@@ -362,14 +447,14 @@ void IndentationEngine::insert_new_line(Coord cursor) {
|
||||
t_edit.start.col = edit["range"]["start"]["character"];
|
||||
t_edit.end.row = edit["range"]["end"]["line"];
|
||||
t_edit.end.col = edit["range"]["end"]["character"];
|
||||
utf8_normalize_edit(editor, &t_edit);
|
||||
message.editor->utf8_normalize_edit(&t_edit);
|
||||
t_edits.push_back(t_edit);
|
||||
}
|
||||
apply_lsp_edits(editor, t_edits, false);
|
||||
ensure_scroll(editor);
|
||||
message.editor->apply_lsp_edits(t_edits, false);
|
||||
message.editor->ensure_scroll();
|
||||
}
|
||||
};
|
||||
lsp_send(editor->lsp, message, pending);
|
||||
lsp->send(std::move(message));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,52 +2,47 @@
|
||||
#include "editor/editor.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
void apply_lsp_edits(Editor *editor, std::vector<TextEdit> edits, bool move) {
|
||||
void Editor::apply_lsp_edits(std::vector<TextEdit> edits, bool move) {
|
||||
if (!edits.size())
|
||||
return;
|
||||
TextEdit first = edits[0];
|
||||
Coord cursor = editor->cursor;
|
||||
Coord cursor = this->cursor;
|
||||
std::sort(
|
||||
edits.begin(), edits.end(),
|
||||
[](const TextEdit &a, const TextEdit &b) { return a.start > b.start; });
|
||||
for (const auto &edit : edits)
|
||||
edit_replace(editor, edit.start, edit.end, edit.text.c_str(),
|
||||
edit.text.size());
|
||||
this->edit_replace(edit.start, edit.end, edit.text.c_str(),
|
||||
edit.text.size());
|
||||
if (move) {
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
editor->cursor = first.start;
|
||||
editor->cursor =
|
||||
move_right(editor, editor->cursor,
|
||||
count_clusters(first.text.c_str(), first.text.size(), 0,
|
||||
first.text.size()));
|
||||
this->cursor = first.start;
|
||||
this->cursor = this->move_right(
|
||||
this->cursor, count_clusters(first.text.c_str(), first.text.size(), 0,
|
||||
first.text.size()));
|
||||
} else {
|
||||
if (cursor.row >= editor->root->line_count) {
|
||||
editor->cursor.row = editor->root->line_count - 1;
|
||||
editor->cursor.col = 0;
|
||||
if (cursor.row >= this->root->line_count) {
|
||||
this->cursor.row = this->root->line_count - 1;
|
||||
this->cursor.col = 0;
|
||||
} else {
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
uint32_t len;
|
||||
line_to_byte(editor->root, cursor.row, &len);
|
||||
line_to_byte(this->root, cursor.row, &len);
|
||||
len--;
|
||||
editor->cursor.row = cursor.row;
|
||||
editor->cursor.col = cursor.col < len ? cursor.col : len;
|
||||
this->cursor.row = cursor.row;
|
||||
this->cursor.col = cursor.col < len ? cursor.col : len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void editor_lsp_handle(Editor *editor, json msg) {
|
||||
void Editor::lsp_handle(json msg) {
|
||||
if (msg.contains("method") &&
|
||||
msg["method"] == "textDocument/publishDiagnostics") {
|
||||
std::unique_lock lock(editor->v_mtx);
|
||||
editor->warnings.clear();
|
||||
this->warnings.clear();
|
||||
json diagnostics = msg["params"]["diagnostics"];
|
||||
for (size_t i = 0; i < diagnostics.size(); i++) {
|
||||
json d = diagnostics[i];
|
||||
VWarn w;
|
||||
w.line = d["range"]["start"]["line"];
|
||||
w.start = d["range"]["start"]["character"];
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
LineIterator *it = begin_l_iter(editor->root, w.line);
|
||||
LineIterator *it = begin_l_iter(this->root, w.line);
|
||||
if (!it)
|
||||
continue;
|
||||
uint32_t len;
|
||||
@@ -59,11 +54,10 @@ void editor_lsp_handle(Editor *editor, json msg) {
|
||||
}
|
||||
if (len > 0 && line[len - 1] == '\n')
|
||||
--len;
|
||||
lock.unlock();
|
||||
w.start = utf16_offset_to_utf8(line, w.start);
|
||||
w.start = utf16_offset_to_utf8(line, len, w.start);
|
||||
uint32_t end = d["range"]["end"]["character"];
|
||||
if (d["range"]["end"]["line"] == w.line)
|
||||
w.end = utf16_offset_to_utf8(line, end);
|
||||
w.end = utf16_offset_to_utf8(line, len, end);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
std::string text = trim(d["message"].get<std::string>());
|
||||
@@ -102,9 +96,9 @@ void editor_lsp_handle(Editor *editor, json msg) {
|
||||
w.type = 1;
|
||||
if (d.contains("severity"))
|
||||
w.type = d["severity"].get<int>();
|
||||
editor->warnings.push_back(w);
|
||||
this->warnings.push_back(w);
|
||||
}
|
||||
std::sort(editor->warnings.begin(), editor->warnings.end());
|
||||
editor->warnings_dirty = true;
|
||||
std::sort(this->warnings.begin(), this->warnings.end());
|
||||
this->warnings_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,120 +1,108 @@
|
||||
#include "editor/editor.h"
|
||||
#include "main.h"
|
||||
|
||||
void move_line_up(Editor *editor) {
|
||||
if (!editor || !editor->root || editor->cursor.row == 0)
|
||||
void Editor::move_line_up() {
|
||||
if (!this->root || this->cursor.row == 0)
|
||||
return;
|
||||
if (mode == NORMAL || mode == INSERT) {
|
||||
uint32_t line_len, line_cluster_len;
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
LineIterator *it = begin_l_iter(editor->root, editor->cursor.row);
|
||||
LineIterator *it = begin_l_iter(this->root, this->cursor.row);
|
||||
char *line = next_line(it, &line_len);
|
||||
if (!line) {
|
||||
lock.unlock();
|
||||
if (!line)
|
||||
return;
|
||||
}
|
||||
if (line_len > 0 && line[line_len - 1] == '\n')
|
||||
line_len--;
|
||||
line_cluster_len = count_clusters(line, line_len, 0, line_len);
|
||||
uint32_t target_row = editor->cursor.row - 1;
|
||||
uint32_t up_by = editor->cursor.row - target_row;
|
||||
uint32_t target_row = this->cursor.row - 1;
|
||||
uint32_t up_by = this->cursor.row - target_row;
|
||||
if (up_by > 1)
|
||||
up_by--;
|
||||
lock.unlock();
|
||||
Coord cursor = editor->cursor;
|
||||
edit_erase(editor, {cursor.row, 0}, line_cluster_len);
|
||||
edit_erase(editor, {cursor.row, 0}, -1);
|
||||
edit_insert(editor, {cursor.row - up_by, 0}, (char *)"\n", 1);
|
||||
edit_insert(editor, {cursor.row - up_by, 0}, line, line_len);
|
||||
Coord cursor = this->cursor;
|
||||
edit_erase({cursor.row, 0}, line_cluster_len);
|
||||
edit_erase({cursor.row, 0}, -1);
|
||||
edit_insert({cursor.row - up_by, 0}, (char *)"\n", 1);
|
||||
edit_insert({cursor.row - up_by, 0}, line, line_len);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
editor->cursor = {cursor.row - up_by, cursor.col};
|
||||
this->cursor = {cursor.row - up_by, cursor.col};
|
||||
} else if (mode == SELECT) {
|
||||
uint32_t start_row = MIN(editor->cursor.row, editor->selection.row);
|
||||
uint32_t end_row = MAX(editor->cursor.row, editor->selection.row);
|
||||
uint32_t start_byte = line_to_byte(editor->root, start_row, nullptr);
|
||||
uint32_t end_byte = line_to_byte(editor->root, end_row + 1, nullptr);
|
||||
char *selected_text = read(editor->root, start_byte, end_byte - start_byte);
|
||||
uint32_t start_row = MIN(this->cursor.row, this->selection.row);
|
||||
uint32_t end_row = MAX(this->cursor.row, this->selection.row);
|
||||
uint32_t start_byte = line_to_byte(this->root, start_row, nullptr);
|
||||
uint32_t end_byte = line_to_byte(this->root, end_row + 1, nullptr);
|
||||
char *selected_text = read(this->root, start_byte, end_byte - start_byte);
|
||||
if (!selected_text)
|
||||
return;
|
||||
uint32_t selected_len = count_clusters(selected_text, end_byte - start_byte,
|
||||
0, end_byte - start_byte);
|
||||
Coord cursor = editor->cursor;
|
||||
Coord selection = editor->selection;
|
||||
edit_erase(editor, {start_row, 0}, selected_len);
|
||||
edit_insert(editor, {start_row - 1, 0}, selected_text,
|
||||
end_byte - start_byte);
|
||||
Coord cursor = this->cursor;
|
||||
Coord selection = this->selection;
|
||||
edit_erase({start_row, 0}, selected_len);
|
||||
edit_insert({start_row - 1, 0}, selected_text, end_byte - start_byte);
|
||||
free(selected_text);
|
||||
editor->cursor = {cursor.row - 1, cursor.col};
|
||||
editor->selection = {selection.row - 1, selection.col};
|
||||
this->cursor = {cursor.row - 1, cursor.col};
|
||||
this->selection = {selection.row - 1, selection.col};
|
||||
}
|
||||
}
|
||||
|
||||
void move_line_down(Editor *editor) {
|
||||
if (!editor || !editor->root)
|
||||
void Editor::move_line_down() {
|
||||
if (!this->root)
|
||||
return;
|
||||
if (mode == NORMAL || mode == INSERT) {
|
||||
if (editor->cursor.row >= editor->root->line_count - 1)
|
||||
if (this->cursor.row >= this->root->line_count - 1)
|
||||
return;
|
||||
uint32_t line_len, line_cluster_len;
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
LineIterator *it = begin_l_iter(editor->root, editor->cursor.row);
|
||||
LineIterator *it = begin_l_iter(this->root, this->cursor.row);
|
||||
char *line = next_line(it, &line_len);
|
||||
if (!line) {
|
||||
lock.unlock();
|
||||
if (!line)
|
||||
return;
|
||||
}
|
||||
if (line_len && line[line_len - 1] == '\n')
|
||||
line_len--;
|
||||
line_cluster_len = count_clusters(line, line_len, 0, line_len);
|
||||
uint32_t target_row = editor->cursor.row + 1;
|
||||
if (target_row >= editor->root->line_count) {
|
||||
free(line);
|
||||
lock.unlock();
|
||||
uint32_t target_row = this->cursor.row + 1;
|
||||
if (target_row >= this->root->line_count) {
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
}
|
||||
uint32_t down_by = target_row - editor->cursor.row;
|
||||
uint32_t down_by = target_row - this->cursor.row;
|
||||
if (down_by > 1)
|
||||
down_by--;
|
||||
uint32_t ln;
|
||||
line_to_byte(editor->root, editor->cursor.row + down_by - 1, &ln);
|
||||
lock.unlock();
|
||||
Coord cursor = editor->cursor;
|
||||
edit_erase(editor, {cursor.row, 0}, line_cluster_len);
|
||||
edit_erase(editor, {cursor.row, 0}, -1);
|
||||
edit_insert(editor, {cursor.row + down_by, 0}, (char *)"\n", 1);
|
||||
edit_insert(editor, {cursor.row + down_by, 0}, line, line_len);
|
||||
line_to_byte(this->root, this->cursor.row + down_by - 1, &ln);
|
||||
Coord cursor = this->cursor;
|
||||
edit_erase({cursor.row, 0}, line_cluster_len);
|
||||
edit_erase({cursor.row, 0}, -1);
|
||||
edit_insert({cursor.row + down_by, 0}, (char *)"\n", 1);
|
||||
edit_insert({cursor.row + down_by, 0}, line, line_len);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
editor->cursor = {cursor.row + down_by, cursor.col};
|
||||
this->cursor = {cursor.row + down_by, cursor.col};
|
||||
} else if (mode == SELECT) {
|
||||
if (editor->cursor.row >= editor->root->line_count - 1 ||
|
||||
editor->selection.row >= editor->root->line_count - 1)
|
||||
if (this->cursor.row >= this->root->line_count - 1 ||
|
||||
this->selection.row >= this->root->line_count - 1)
|
||||
return;
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
uint32_t start_row = MIN(editor->cursor.row, editor->selection.row);
|
||||
uint32_t end_row = MAX(editor->cursor.row, editor->selection.row);
|
||||
uint32_t start_row = MIN(this->cursor.row, this->selection.row);
|
||||
uint32_t end_row = MAX(this->cursor.row, this->selection.row);
|
||||
uint32_t target_row = end_row + 1;
|
||||
if (target_row >= editor->root->line_count)
|
||||
if (target_row >= this->root->line_count)
|
||||
return;
|
||||
uint32_t down_by = target_row - end_row;
|
||||
if (down_by > 1)
|
||||
down_by--;
|
||||
uint32_t start_byte = line_to_byte(editor->root, start_row, nullptr);
|
||||
uint32_t end_byte = line_to_byte(editor->root, end_row + 1, nullptr);
|
||||
char *selected_text = read(editor->root, start_byte, end_byte - start_byte);
|
||||
lock.unlock();
|
||||
uint32_t start_byte = line_to_byte(this->root, start_row, nullptr);
|
||||
uint32_t end_byte = line_to_byte(this->root, end_row + 1, nullptr);
|
||||
char *selected_text = read(this->root, start_byte, end_byte - start_byte);
|
||||
if (!selected_text)
|
||||
return;
|
||||
uint32_t selected_len = count_clusters(selected_text, end_byte - start_byte,
|
||||
0, end_byte - start_byte);
|
||||
Coord cursor = editor->cursor;
|
||||
Coord selection = editor->selection;
|
||||
edit_erase(editor, {start_row, 0}, selected_len);
|
||||
edit_insert(editor, {start_row + down_by, 0}, selected_text,
|
||||
end_byte - start_byte);
|
||||
Coord cursor = this->cursor;
|
||||
Coord selection = this->selection;
|
||||
edit_erase({start_row, 0}, selected_len);
|
||||
edit_insert({start_row + down_by, 0}, selected_text, end_byte - start_byte);
|
||||
free(selected_text);
|
||||
editor->cursor = {cursor.row + down_by, cursor.col};
|
||||
editor->selection = {selection.row + down_by, selection.col};
|
||||
this->cursor = {cursor.row + down_by, cursor.col};
|
||||
this->selection = {selection.row + down_by, selection.col};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
#include "editor/editor.h"
|
||||
#include "io/sysio.h"
|
||||
#include "main.h"
|
||||
#include "syntax/decl.h"
|
||||
#include "syntax/parser.h"
|
||||
|
||||
void render_editor(Editor *editor) {
|
||||
void Editor::render(std::vector<ScreenCell> &buffer, Coord size, Coord pos) {
|
||||
this->size = size;
|
||||
uint32_t sel_start = 0, sel_end = 0;
|
||||
uint32_t numlen =
|
||||
EXTRA_META + static_cast<int>(std::log10(editor->root->line_count + 1));
|
||||
uint32_t render_width = editor->size.col - numlen;
|
||||
uint32_t render_x = editor->position.col + numlen;
|
||||
EXTRA_META + static_cast<int>(std::log10(this->root->line_count + 1));
|
||||
uint32_t render_width = size.col - numlen;
|
||||
uint32_t render_x = pos.col + numlen + 1;
|
||||
std::vector<std::pair<uint32_t, char>> v;
|
||||
for (size_t i = 0; i < 94; ++i)
|
||||
if (editor->hooks[i] != 0)
|
||||
v.push_back({editor->hooks[i], '!' + i});
|
||||
if (this->hooks[i] != 0)
|
||||
v.push_back({this->hooks[i], '!' + i});
|
||||
std::sort(v.begin(), v.end());
|
||||
auto hook_it = v.begin();
|
||||
while (hook_it != v.end() && hook_it->first <= editor->scroll.row)
|
||||
while (hook_it != v.end() && hook_it->first <= this->scroll.row)
|
||||
++hook_it;
|
||||
std::unique_lock warn_lock(editor->v_mtx);
|
||||
auto warn_it = editor->warnings.begin();
|
||||
while (warn_it != editor->warnings.end() &&
|
||||
warn_it->line < editor->scroll.row)
|
||||
auto warn_it = this->warnings.begin();
|
||||
while (warn_it != this->warnings.end() && warn_it->line < this->scroll.row)
|
||||
++warn_it;
|
||||
std::unique_lock<std::mutex> lock;
|
||||
if (editor->parser)
|
||||
lock = std::unique_lock<std::mutex>(editor->parser->mutex);
|
||||
LineData *line_data = nullptr;
|
||||
auto get_type = [&](uint32_t col) {
|
||||
if (!line_data)
|
||||
@@ -34,41 +31,54 @@ void render_editor(Editor *editor) {
|
||||
return (int)token.type;
|
||||
return 0;
|
||||
};
|
||||
std::shared_lock knot_lock(editor->knot_mtx);
|
||||
if (editor->selection_active) {
|
||||
Coord screen = {io::rows, io::cols};
|
||||
auto update = [&](uint32_t row, uint32_t col, std::string text, uint32_t fg,
|
||||
uint32_t bg, uint8_t flags, uint32_t u_color,
|
||||
uint32_t width) {
|
||||
if (row >= screen.row || col >= screen.col)
|
||||
return;
|
||||
ScreenCell &c = buffer[row * screen.col + col];
|
||||
c.utf8 = text;
|
||||
c.width = width;
|
||||
c.fg = fg;
|
||||
c.bg = bg;
|
||||
c.flags = flags;
|
||||
c.ul_color = u_color;
|
||||
};
|
||||
if (this->selection_active) {
|
||||
Coord start, end;
|
||||
if (editor->cursor >= editor->selection) {
|
||||
if (this->cursor >= this->selection) {
|
||||
uint32_t prev_col, next_col;
|
||||
switch (editor->selection_type) {
|
||||
switch (this->selection_type) {
|
||||
case CHAR:
|
||||
start = editor->selection;
|
||||
end = move_right(editor, editor->cursor, 1);
|
||||
start = this->selection;
|
||||
end = this->move_right(this->cursor, 1);
|
||||
break;
|
||||
case WORD:
|
||||
word_boundaries(editor, editor->selection, &prev_col, &next_col,
|
||||
nullptr, nullptr);
|
||||
start = {editor->selection.row, prev_col};
|
||||
end = editor->cursor;
|
||||
this->word_boundaries(this->selection, &prev_col, &next_col, nullptr,
|
||||
nullptr);
|
||||
start = {this->selection.row, prev_col};
|
||||
end = this->cursor;
|
||||
break;
|
||||
case LINE:
|
||||
start = {editor->selection.row, 0};
|
||||
end = editor->cursor;
|
||||
start = {this->selection.row, 0};
|
||||
end = this->cursor;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
start = editor->cursor;
|
||||
start = this->cursor;
|
||||
uint32_t prev_col, next_col, line_len;
|
||||
switch (editor->selection_type) {
|
||||
switch (this->selection_type) {
|
||||
case CHAR:
|
||||
end = move_right(editor, editor->selection, 1);
|
||||
end = this->move_right(this->selection, 1);
|
||||
break;
|
||||
case WORD:
|
||||
word_boundaries(editor, editor->selection, &prev_col, &next_col,
|
||||
nullptr, nullptr);
|
||||
end = {editor->selection.row, next_col};
|
||||
this->word_boundaries(this->selection, &prev_col, &next_col, nullptr,
|
||||
nullptr);
|
||||
end = {this->selection.row, next_col};
|
||||
break;
|
||||
case LINE:
|
||||
LineIterator *it = begin_l_iter(editor->root, editor->selection.row);
|
||||
LineIterator *it = begin_l_iter(this->root, this->selection.row);
|
||||
char *line = next_line(it, &line_len);
|
||||
if (!line)
|
||||
return;
|
||||
@@ -76,27 +86,37 @@ void render_editor(Editor *editor) {
|
||||
line_len--;
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
end = {editor->selection.row, line_len};
|
||||
end = {this->selection.row, line_len};
|
||||
break;
|
||||
}
|
||||
}
|
||||
sel_start = line_to_byte(editor->root, start.row, nullptr) + start.col;
|
||||
sel_end = line_to_byte(editor->root, end.row, nullptr) + end.col;
|
||||
sel_start = line_to_byte(this->root, start.row, nullptr) + start.col;
|
||||
sel_end = line_to_byte(this->root, end.row, nullptr) + end.col;
|
||||
}
|
||||
Coord cursor = {UINT32_MAX, UINT32_MAX};
|
||||
uint32_t line_index = editor->scroll.row;
|
||||
LineIterator *it = begin_l_iter(editor->root, line_index);
|
||||
uint32_t line_index = this->scroll.row;
|
||||
LineIterator *it = begin_l_iter(this->root, line_index);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t prev_col, next_col;
|
||||
std::string word;
|
||||
this->word_boundaries_exclusive(this->cursor, &prev_col, &next_col);
|
||||
if (next_col - prev_col > 0 && next_col - prev_col < 256 - 4) {
|
||||
uint32_t offset = line_to_byte(this->root, this->cursor.row, nullptr);
|
||||
char *word_ptr = read(this->root, offset + prev_col, next_col - prev_col);
|
||||
if (word_ptr) {
|
||||
word = std::string(word_ptr, next_col - prev_col);
|
||||
free(word_ptr);
|
||||
}
|
||||
}
|
||||
this->extra_hl.render(this->root, line_index, word, this->is_css_color);
|
||||
uint32_t rendered_rows = 0;
|
||||
uint32_t global_byte_offset = line_to_byte(editor->root, line_index, nullptr);
|
||||
while (rendered_rows < editor->size.row) {
|
||||
uint32_t global_byte_offset = line_to_byte(this->root, line_index, nullptr);
|
||||
while (rendered_rows < this->size.row) {
|
||||
uint32_t line_len;
|
||||
char *line = next_line(it, &line_len);
|
||||
if (line_data)
|
||||
line_data = editor->parser->line_tree.next();
|
||||
else
|
||||
line_data = editor->parser->line_tree.start_iter(line_index);
|
||||
if (this->parser)
|
||||
line_data = this->parser->line_map.at(line_index);
|
||||
if (!line)
|
||||
break;
|
||||
if (line_len > 0 && line[line_len - 1] == '\n')
|
||||
@@ -110,59 +130,64 @@ void render_editor(Editor *editor) {
|
||||
(line[content_start] == ' ' || line[content_start] == '\t'))
|
||||
content_start++;
|
||||
std::vector<VWarn> line_warnings;
|
||||
while (warn_it != editor->warnings.end() && warn_it->line == line_index) {
|
||||
while (warn_it != this->warnings.end() && warn_it->line == line_index) {
|
||||
line_warnings.push_back(*warn_it);
|
||||
++warn_it;
|
||||
}
|
||||
uint32_t current_byte_offset = 0;
|
||||
if (rendered_rows == 0)
|
||||
current_byte_offset += editor->scroll.col;
|
||||
while (current_byte_offset < line_len && rendered_rows < editor->size.row) {
|
||||
uint32_t color = editor->cursor.row == line_index ? 0x222222 : 0;
|
||||
current_byte_offset += this->scroll.col;
|
||||
while (current_byte_offset < line_len && rendered_rows < this->size.row) {
|
||||
uint32_t color = this->cursor.row == line_index ? 0x222222 : 0;
|
||||
if (current_byte_offset == 0 || rendered_rows == 0) {
|
||||
const char *hook = nullptr;
|
||||
const char *hook = "";
|
||||
char h[2] = {0, 0};
|
||||
if (hook_it != v.end() && hook_it->first == line_index + 1) {
|
||||
h[0] = hook_it->second;
|
||||
hook = h;
|
||||
hook_it++;
|
||||
}
|
||||
update(editor->position.row + rendered_rows, editor->position.col, hook,
|
||||
0xAAAAAA, 0, 0);
|
||||
update(pos.row + rendered_rows, pos.col, hook, 0xAAAAAA, 0, 0, 0, 1);
|
||||
char buf[16];
|
||||
int len =
|
||||
snprintf(buf, sizeof(buf), "%*u ", numlen - 3, line_index + 1);
|
||||
int len = snprintf(buf, sizeof(buf), "%*u ", numlen, line_index + 1);
|
||||
uint32_t num_color =
|
||||
editor->cursor.row == line_index ? 0xFFFFFF : 0x555555;
|
||||
this->cursor.row == line_index ? 0xFFFFFF : 0x555555;
|
||||
for (int i = 0; i < len; i++)
|
||||
update(editor->position.row + rendered_rows,
|
||||
editor->position.col + i + 2, (char[2]){buf[i], 0}, num_color,
|
||||
0, 0);
|
||||
update(pos.row + rendered_rows, pos.col + i, (char[2]){buf[i], 0},
|
||||
num_color, 0, 0, 0, 1);
|
||||
} else {
|
||||
for (uint32_t i = 0; i < numlen; i++)
|
||||
update(editor->position.row + rendered_rows, editor->position.col + i,
|
||||
" ", 0, 0, 0);
|
||||
for (uint32_t i = 0; i < numlen + 1; i++)
|
||||
update(pos.row + rendered_rows, pos.col + i, " ", 0, 0, 0, 0, 1);
|
||||
}
|
||||
uint32_t col = 0;
|
||||
uint32_t local_render_offset = 0;
|
||||
uint32_t line_left = line_len - current_byte_offset;
|
||||
while (line_left > 0 && col < render_width) {
|
||||
if (line_index == editor->cursor.row &&
|
||||
editor->cursor.col == (current_byte_offset + local_render_offset)) {
|
||||
cursor.row = editor->position.row + rendered_rows;
|
||||
if (line_index == this->cursor.row &&
|
||||
this->cursor.col == (current_byte_offset + local_render_offset)) {
|
||||
cursor.row = pos.row + rendered_rows;
|
||||
cursor.col = render_x + col;
|
||||
}
|
||||
uint32_t absolute_byte_pos =
|
||||
global_byte_offset + current_byte_offset + local_render_offset;
|
||||
const Highlight *hl = nullptr;
|
||||
if (editor->parser)
|
||||
if (this->parser)
|
||||
hl = &highlights[get_type(current_byte_offset + local_render_offset)];
|
||||
uint32_t fg = hl ? hl->fg : 0xFFFFFF;
|
||||
uint32_t bg = hl ? hl->bg : 0;
|
||||
uint8_t fl = hl ? hl->flags : 0;
|
||||
if (editor->selection_active && absolute_byte_pos >= sel_start &&
|
||||
std::optional<std::pair<uint32_t, uint32_t>> extra = this->extra_hl.get(
|
||||
{line_index, current_byte_offset + local_render_offset});
|
||||
uint32_t fg = extra && extra->second != UINT32_MAX
|
||||
? extra->first
|
||||
: (hl ? hl->fg : 0xFFFFFF);
|
||||
uint32_t bg = extra && extra->second != UINT32_MAX
|
||||
? extra->second
|
||||
: (hl ? hl->bg : 0x000000);
|
||||
uint8_t fl =
|
||||
(hl ? hl->flags : 0) |
|
||||
(extra ? (extra->second != UINT32_MAX ? CF_BOLD : CF_UNDERLINE)
|
||||
: 0);
|
||||
if (this->selection_active && absolute_byte_pos >= sel_start &&
|
||||
absolute_byte_pos < sel_end)
|
||||
bg = 0x555555;
|
||||
bg = bg | 0x555555;
|
||||
uint32_t u_color = 0;
|
||||
for (const auto &w : line_warnings) {
|
||||
if (w.start <= current_byte_offset + local_render_offset &&
|
||||
@@ -196,40 +221,39 @@ void render_editor(Editor *editor) {
|
||||
break;
|
||||
if (current_byte_offset + local_render_offset >= content_start &&
|
||||
current_byte_offset + local_render_offset < content_end) {
|
||||
update(editor->position.row + rendered_rows, render_x + col,
|
||||
cluster.c_str(), fg, bg | color, fl, u_color);
|
||||
update(pos.row + rendered_rows, render_x + col, cluster.c_str(), fg,
|
||||
bg | color, fl, u_color, width);
|
||||
} else {
|
||||
if (cluster[0] == ' ') {
|
||||
update(editor->position.row + rendered_rows, render_x + col, "·",
|
||||
0x282828, bg | color, fl, u_color);
|
||||
update(pos.row + rendered_rows, render_x + col, "·", 0x282828,
|
||||
bg | color, fl, u_color, 1);
|
||||
} else {
|
||||
update(editor->position.row + rendered_rows, render_x + col, "-> ",
|
||||
0x282828, bg | color, (fl & ~CF_BOLD) | CF_ITALIC, u_color);
|
||||
update(pos.row + rendered_rows, render_x + col, "-> ", 0x282828,
|
||||
bg | color, (fl & ~CF_BOLD) | CF_ITALIC, u_color, 4);
|
||||
}
|
||||
}
|
||||
local_render_offset += cluster_len;
|
||||
line_left -= cluster_len;
|
||||
col += width;
|
||||
while (width-- > 1)
|
||||
update(editor->position.row + rendered_rows, render_x + col - width,
|
||||
"\x1b", fg, bg | color, fl);
|
||||
update(pos.row + rendered_rows, render_x + col - width, "\x1b", fg,
|
||||
bg | color, fl, u_color, 0);
|
||||
}
|
||||
if (line_index == editor->cursor.row &&
|
||||
editor->cursor.col == (current_byte_offset + local_render_offset)) {
|
||||
cursor.row = editor->position.row + rendered_rows;
|
||||
if (line_index == this->cursor.row &&
|
||||
this->cursor.col == (current_byte_offset + local_render_offset)) {
|
||||
cursor.row = pos.row + rendered_rows;
|
||||
cursor.col = render_x + col;
|
||||
}
|
||||
if (editor->selection_active &&
|
||||
if (this->selection_active &&
|
||||
global_byte_offset + line_len + 1 > sel_start &&
|
||||
global_byte_offset + line_len + 1 <= sel_end && col < render_width) {
|
||||
update(editor->position.row + rendered_rows, render_x + col, " ", 0,
|
||||
0x555555 | color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col, " ", 0,
|
||||
0x555555 | color, 0, 0, 1);
|
||||
col++;
|
||||
}
|
||||
if (!line_warnings.empty() && line_left == 0) {
|
||||
VWarn warn = line_warnings.front();
|
||||
update(editor->position.row + rendered_rows, render_x + col, " ", 0,
|
||||
color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col, " ", 0, color, 0, 0, 1);
|
||||
col++;
|
||||
for (size_t i = 0; i < line_warnings.size(); i++) {
|
||||
if (line_warnings[i].type < warn.type)
|
||||
@@ -255,18 +279,18 @@ void render_editor(Editor *editor) {
|
||||
goto final;
|
||||
final:
|
||||
if (col < render_width) {
|
||||
update(editor->position.row + rendered_rows, render_x + col,
|
||||
err_sym, fg_color, color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col, err_sym, fg_color,
|
||||
color, 0, 0, 1);
|
||||
col++;
|
||||
update(editor->position.row + rendered_rows, render_x + col, " ",
|
||||
fg_color, color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col, " ", fg_color,
|
||||
color, 0, 0, 1);
|
||||
col++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (col < render_width) {
|
||||
update(editor->position.row + rendered_rows, render_x + col, " ", 0,
|
||||
0 | color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col, " ", 0, 0 | color, 0,
|
||||
0, 1);
|
||||
col++;
|
||||
}
|
||||
size_t warn_idx = 0;
|
||||
@@ -292,19 +316,19 @@ void render_editor(Editor *editor) {
|
||||
int width = display_width(cluster.c_str(), cluster_len);
|
||||
if (col + width > render_width)
|
||||
break;
|
||||
update(editor->position.row + rendered_rows, render_x + col,
|
||||
cluster.c_str(), fg_color, color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col, cluster.c_str(),
|
||||
fg_color, color, 0, 0, width);
|
||||
col += width;
|
||||
warn_idx += cluster_len;
|
||||
while (width-- > 1)
|
||||
update(editor->position.row + rendered_rows, render_x + col - width,
|
||||
"\x1b", fg_color, color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col - width, "\x1b",
|
||||
fg_color, color, 0, 0, 0);
|
||||
}
|
||||
line_warnings.clear();
|
||||
}
|
||||
while (col < render_width) {
|
||||
update(editor->position.row + rendered_rows, render_x + col, " ", 0,
|
||||
0 | color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col, " ", 0, 0 | color, 0, 0,
|
||||
1);
|
||||
col++;
|
||||
}
|
||||
rendered_rows++;
|
||||
@@ -312,40 +336,36 @@ void render_editor(Editor *editor) {
|
||||
}
|
||||
if (line_len == 0 ||
|
||||
(current_byte_offset >= line_len && rendered_rows == 0)) {
|
||||
uint32_t color = editor->cursor.row == line_index ? 0x222222 : 0;
|
||||
const char *hook = nullptr;
|
||||
uint32_t color = this->cursor.row == line_index ? 0x222222 : 0;
|
||||
const char *hook = "";
|
||||
char h[2] = {0, 0};
|
||||
if (hook_it != v.end() && hook_it->first == line_index + 1) {
|
||||
h[0] = hook_it->second;
|
||||
hook = h;
|
||||
hook_it++;
|
||||
}
|
||||
update(editor->position.row + rendered_rows, editor->position.col, hook,
|
||||
0xAAAAAA, 0, 0);
|
||||
update(pos.row + rendered_rows, pos.col, hook, 0xAAAAAA, 0, 0, 0, 1);
|
||||
char buf[16];
|
||||
int len = snprintf(buf, sizeof(buf), "%*u ", numlen - 3, line_index + 1);
|
||||
uint32_t num_color =
|
||||
editor->cursor.row == line_index ? 0xFFFFFF : 0x555555;
|
||||
int len = snprintf(buf, sizeof(buf), "%*u ", numlen, line_index + 1);
|
||||
uint32_t num_color = this->cursor.row == line_index ? 0xFFFFFF : 0x555555;
|
||||
for (int i = 0; i < len; i++)
|
||||
update(editor->position.row + rendered_rows,
|
||||
editor->position.col + i + 2, (char[2]){buf[i], 0}, num_color, 0,
|
||||
0);
|
||||
if (editor->cursor.row == line_index) {
|
||||
cursor.row = editor->position.row + rendered_rows;
|
||||
update(pos.row + rendered_rows, pos.col + i, (char[2]){buf[i], 0},
|
||||
num_color, 0, 0, 0, 1);
|
||||
if (this->cursor.row == line_index) {
|
||||
cursor.row = pos.row + rendered_rows;
|
||||
cursor.col = render_x;
|
||||
}
|
||||
uint32_t col = 0;
|
||||
if (editor->selection_active &&
|
||||
if (this->selection_active &&
|
||||
global_byte_offset + line_len + 1 > sel_start &&
|
||||
global_byte_offset + line_len + 1 <= sel_end) {
|
||||
update(editor->position.row + rendered_rows, render_x + col, " ", 0,
|
||||
0x555555 | color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col, " ", 0,
|
||||
0x555555 | color, 0, 0, 1);
|
||||
col++;
|
||||
}
|
||||
if (!line_warnings.empty()) {
|
||||
VWarn warn = line_warnings.front();
|
||||
update(editor->position.row + rendered_rows, render_x + col, " ", 0,
|
||||
color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col, " ", 0, color, 0, 0, 1);
|
||||
col++;
|
||||
for (size_t i = 0; i < line_warnings.size(); i++) {
|
||||
if (line_warnings[i].type < warn.type)
|
||||
@@ -371,18 +391,18 @@ void render_editor(Editor *editor) {
|
||||
goto final2;
|
||||
final2:
|
||||
if (col < render_width) {
|
||||
update(editor->position.row + rendered_rows, render_x + col,
|
||||
err_sym, fg_color, color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col, err_sym, fg_color,
|
||||
color, 0, 0, 1);
|
||||
col++;
|
||||
update(editor->position.row + rendered_rows, render_x + col, " ",
|
||||
fg_color, color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col, " ", fg_color,
|
||||
color, 0, 0, 1);
|
||||
col++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (col < render_width) {
|
||||
update(editor->position.row + rendered_rows, render_x + col, " ", 0,
|
||||
0 | color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col, " ", 0, 0 | color, 0,
|
||||
0, 1);
|
||||
col++;
|
||||
}
|
||||
size_t warn_idx = 0;
|
||||
@@ -408,18 +428,18 @@ void render_editor(Editor *editor) {
|
||||
int width = display_width(cluster.c_str(), cluster_len);
|
||||
if (col + width > render_width)
|
||||
break;
|
||||
update(editor->position.row + rendered_rows, render_x + col,
|
||||
cluster.c_str(), fg_color, color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col, cluster.c_str(),
|
||||
fg_color, color, 0, 0, width);
|
||||
col += width;
|
||||
warn_idx += cluster_len;
|
||||
while (width-- > 1)
|
||||
update(editor->position.row + rendered_rows, render_x + col - width,
|
||||
"\x1b", fg_color, color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col - width, "\x1b",
|
||||
fg_color, color, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
while (col < render_width) {
|
||||
update(editor->position.row + rendered_rows, render_x + col, " ", 0,
|
||||
0 | color, 0);
|
||||
update(pos.row + rendered_rows, render_x + col, " ", 0, 0 | color, 0, 0,
|
||||
1);
|
||||
col++;
|
||||
}
|
||||
rendered_rows++;
|
||||
@@ -427,12 +447,9 @@ void render_editor(Editor *editor) {
|
||||
global_byte_offset += line_len + 1;
|
||||
line_index++;
|
||||
}
|
||||
if (lock.owns_lock())
|
||||
lock.unlock();
|
||||
while (rendered_rows < editor->size.row) {
|
||||
for (uint32_t col = 0; col < editor->size.col; col++)
|
||||
update(editor->position.row + rendered_rows, editor->position.col + col,
|
||||
" ", 0xFFFFFF, 0, 0);
|
||||
while (rendered_rows < this->size.row) {
|
||||
for (uint32_t col = 0; col < this->size.col; col++)
|
||||
update(pos.row + rendered_rows, pos.col + col, " ", 0xFFFFFF, 0, 0, 0, 1);
|
||||
rendered_rows++;
|
||||
}
|
||||
if (cursor.row != UINT32_MAX && cursor.col != UINT32_MAX) {
|
||||
@@ -450,15 +467,13 @@ void render_editor(Editor *editor) {
|
||||
break;
|
||||
}
|
||||
set_cursor(cursor.row, cursor.col, type, true);
|
||||
if (editor->completion.active && !editor->completion.box.hidden)
|
||||
editor->completion.box.render(cursor);
|
||||
else if (editor->hover_active)
|
||||
editor->hover.render(cursor);
|
||||
else if (editor->diagnostics_active)
|
||||
editor->diagnostics.render(cursor);
|
||||
if (!this->hover_popup->hidden)
|
||||
this->hover_popup->pos = cursor;
|
||||
if (!this->diagnostic_popup->hidden)
|
||||
this->diagnostic_popup->pos = cursor;
|
||||
}
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
if (editor->parser)
|
||||
editor->parser->scroll(line_index + 5);
|
||||
if (this->parser)
|
||||
this->parser->scroll(line_index + 5);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "editor/editor.h"
|
||||
|
||||
void scroll_up(Editor *editor, int32_t number) {
|
||||
if (!editor || number == 0)
|
||||
void Editor::scroll_up(uint32_t number) {
|
||||
if (number == 0)
|
||||
return;
|
||||
uint32_t numlen =
|
||||
EXTRA_META + static_cast<int>(std::log10(editor->root->line_count + 1));
|
||||
uint32_t render_width = editor->size.col - numlen;
|
||||
uint32_t line_index = editor->scroll.row;
|
||||
LineIterator *it = begin_l_iter(editor->root, line_index);
|
||||
EXTRA_META + static_cast<int>(std::log10(this->root->line_count + 1));
|
||||
uint32_t render_width = this->size.col - numlen;
|
||||
uint32_t line_index = this->scroll.row;
|
||||
LineIterator *it = begin_l_iter(this->root, line_index);
|
||||
if (!it)
|
||||
return;
|
||||
uint32_t len;
|
||||
@@ -23,10 +23,9 @@ void scroll_up(Editor *editor, int32_t number) {
|
||||
uint32_t col = 0;
|
||||
std::vector<uint32_t> segment_starts;
|
||||
segment_starts.reserve(16);
|
||||
if (current_byte_offset < editor->scroll.col)
|
||||
if (current_byte_offset < this->scroll.col)
|
||||
segment_starts.push_back(0);
|
||||
while (current_byte_offset < editor->scroll.col &&
|
||||
current_byte_offset < len) {
|
||||
while (current_byte_offset < this->scroll.col && current_byte_offset < len) {
|
||||
uint32_t cluster_len = grapheme_next_character_break_utf8(
|
||||
line + current_byte_offset, len - current_byte_offset);
|
||||
int width = display_width(line + current_byte_offset, cluster_len);
|
||||
@@ -40,7 +39,7 @@ void scroll_up(Editor *editor, int32_t number) {
|
||||
for (auto it_seg = segment_starts.rbegin(); it_seg != segment_starts.rend();
|
||||
++it_seg) {
|
||||
if (--number == 0) {
|
||||
editor->scroll = {line_index, *it_seg};
|
||||
this->scroll = {line_index, *it_seg};
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
@@ -48,7 +47,7 @@ void scroll_up(Editor *editor, int32_t number) {
|
||||
}
|
||||
line = prev_line(it, &len);
|
||||
if (!line) {
|
||||
editor->scroll = {0, 0};
|
||||
this->scroll = {0, 0};
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
@@ -57,7 +56,7 @@ void scroll_up(Editor *editor, int32_t number) {
|
||||
line_index--;
|
||||
line = prev_line(it, &len);
|
||||
if (!line) {
|
||||
editor->scroll = {0, 0};
|
||||
this->scroll = {0, 0};
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
@@ -83,7 +82,7 @@ void scroll_up(Editor *editor, int32_t number) {
|
||||
for (auto it_seg = segment_starts.rbegin(); it_seg != segment_starts.rend();
|
||||
++it_seg) {
|
||||
if (--number == 0) {
|
||||
editor->scroll = {line_index, *it_seg};
|
||||
this->scroll = {line_index, *it_seg};
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
return;
|
||||
@@ -94,17 +93,17 @@ void scroll_up(Editor *editor, int32_t number) {
|
||||
free(it);
|
||||
}
|
||||
|
||||
void scroll_down(Editor *editor, uint32_t number) {
|
||||
if (!editor || number == 0)
|
||||
void Editor::scroll_down(uint32_t number) {
|
||||
if (number == 0)
|
||||
return;
|
||||
uint32_t numlen =
|
||||
EXTRA_META + static_cast<int>(std::log10(editor->root->line_count + 1));
|
||||
uint32_t render_width = editor->size.col - numlen;
|
||||
uint32_t line_index = editor->scroll.row;
|
||||
LineIterator *it = begin_l_iter(editor->root, line_index);
|
||||
EXTRA_META + static_cast<int>(std::log10(this->root->line_count + 1));
|
||||
uint32_t render_width = this->size.col - numlen;
|
||||
uint32_t line_index = this->scroll.row;
|
||||
LineIterator *it = begin_l_iter(this->root, line_index);
|
||||
if (!it)
|
||||
return;
|
||||
const uint32_t max_visual_lines = editor->size.row;
|
||||
const uint32_t max_visual_lines = this->size.row;
|
||||
Coord *scroll_queue = (Coord *)malloc(sizeof(Coord) * max_visual_lines);
|
||||
uint32_t q_head = 0;
|
||||
uint32_t q_size = 0;
|
||||
@@ -119,7 +118,7 @@ void scroll_down(Editor *editor, uint32_t number) {
|
||||
line_len--;
|
||||
uint32_t current_byte_offset = 0;
|
||||
if (first_visual_line) {
|
||||
current_byte_offset += editor->scroll.col;
|
||||
current_byte_offset += this->scroll.col;
|
||||
first_visual_line = false;
|
||||
}
|
||||
while (current_byte_offset < line_len ||
|
||||
@@ -134,7 +133,7 @@ void scroll_down(Editor *editor, uint32_t number) {
|
||||
}
|
||||
visual_seen++;
|
||||
if (visual_seen >= number + max_visual_lines) {
|
||||
editor->scroll = scroll_queue[q_head];
|
||||
this->scroll = scroll_queue[q_head];
|
||||
free(scroll_queue);
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
@@ -162,7 +161,7 @@ void scroll_down(Editor *editor, uint32_t number) {
|
||||
}
|
||||
if (q_size > 0) {
|
||||
uint32_t advance = (q_size > number) ? number : (q_size - 1);
|
||||
editor->scroll = scroll_queue[(q_head + advance) % max_visual_lines];
|
||||
this->scroll = scroll_queue[(q_head + advance) % max_visual_lines];
|
||||
}
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
|
||||
@@ -1,46 +1,97 @@
|
||||
#include "editor/editor.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
char *get_selection(Editor *editor, uint32_t *out_len, Coord *out_start) {
|
||||
std::shared_lock lock(editor->knot_mtx);
|
||||
void Editor::selection_bounds(Coord *out_start, Coord *out_end) {
|
||||
Coord start, end;
|
||||
if (editor->cursor >= editor->selection) {
|
||||
uint32_t prev_col, next_col;
|
||||
switch (editor->selection_type) {
|
||||
if (this->cursor >= this->selection) {
|
||||
uint32_t prev_col;
|
||||
switch (this->selection_type) {
|
||||
case CHAR:
|
||||
start = editor->selection;
|
||||
end = move_right(editor, editor->cursor, 1);
|
||||
start = this->selection;
|
||||
end = this->move_right(this->cursor, 1);
|
||||
break;
|
||||
case WORD:
|
||||
word_boundaries(editor, editor->selection, &prev_col, &next_col, nullptr,
|
||||
nullptr);
|
||||
start = {editor->selection.row, prev_col};
|
||||
end = editor->cursor;
|
||||
this->word_boundaries(this->selection, &prev_col, nullptr, nullptr,
|
||||
nullptr);
|
||||
start = {this->selection.row, prev_col};
|
||||
end = this->cursor;
|
||||
break;
|
||||
case LINE:
|
||||
start = {editor->selection.row, 0};
|
||||
end = editor->cursor;
|
||||
start = {this->selection.row, 0};
|
||||
end = this->cursor;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
start = editor->cursor;
|
||||
uint32_t prev_col, next_col, line_len;
|
||||
switch (editor->selection_type) {
|
||||
start = this->cursor;
|
||||
uint32_t next_col, line_len;
|
||||
switch (this->selection_type) {
|
||||
case CHAR:
|
||||
end = move_right(editor, editor->selection, 1);
|
||||
end = this->move_right(this->selection, 1);
|
||||
break;
|
||||
case WORD:
|
||||
word_boundaries(editor, editor->selection, &prev_col, &next_col, nullptr,
|
||||
nullptr);
|
||||
end = {editor->selection.row, next_col};
|
||||
this->word_boundaries(this->selection, nullptr, &next_col, nullptr,
|
||||
nullptr);
|
||||
end = {this->selection.row, next_col};
|
||||
break;
|
||||
case LINE:
|
||||
LineIterator *it = begin_l_iter(editor->root, editor->selection.row);
|
||||
LineIterator *it = begin_l_iter(this->root, this->selection.row);
|
||||
char *line = next_line(it, &line_len);
|
||||
if (!line)
|
||||
return;
|
||||
if (line_len > 0 && line[line_len - 1] == '\n')
|
||||
line_len--;
|
||||
end = {this->selection.row, line_len};
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (out_start)
|
||||
*out_start = start;
|
||||
if (out_end)
|
||||
*out_end = end;
|
||||
}
|
||||
|
||||
char *Editor::get_selection(uint32_t *out_len, Coord *out_start) {
|
||||
Coord start, end;
|
||||
if (this->cursor >= this->selection) {
|
||||
uint32_t prev_col;
|
||||
switch (this->selection_type) {
|
||||
case CHAR:
|
||||
start = this->selection;
|
||||
end = this->move_right(this->cursor, 1);
|
||||
break;
|
||||
case WORD:
|
||||
this->word_boundaries(this->selection, &prev_col, nullptr, nullptr,
|
||||
nullptr);
|
||||
start = {this->selection.row, prev_col};
|
||||
end = this->cursor;
|
||||
break;
|
||||
case LINE:
|
||||
start = {this->selection.row, 0};
|
||||
end = this->cursor;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
start = this->cursor;
|
||||
uint32_t next_col, line_len;
|
||||
switch (this->selection_type) {
|
||||
case CHAR:
|
||||
end = this->move_right(this->selection, 1);
|
||||
break;
|
||||
case WORD:
|
||||
this->word_boundaries(this->selection, nullptr, &next_col, nullptr,
|
||||
nullptr);
|
||||
end = {this->selection.row, next_col};
|
||||
break;
|
||||
case LINE:
|
||||
LineIterator *it = begin_l_iter(this->root, this->selection.row);
|
||||
char *line = next_line(it, &line_len);
|
||||
if (!line)
|
||||
return nullptr;
|
||||
if (line_len > 0 && line[line_len - 1] == '\n')
|
||||
line_len--;
|
||||
end = {editor->selection.row, line_len};
|
||||
end = {this->selection.row, line_len};
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
break;
|
||||
@@ -49,9 +100,9 @@ char *get_selection(Editor *editor, uint32_t *out_len, Coord *out_start) {
|
||||
if (out_start)
|
||||
*out_start = start;
|
||||
uint32_t start_byte =
|
||||
line_to_byte(editor->root, start.row, nullptr) + start.col;
|
||||
uint32_t end_byte = line_to_byte(editor->root, end.row, nullptr) + end.col;
|
||||
char *text = read(editor->root, start_byte, end_byte - start_byte);
|
||||
line_to_byte(this->root, start.row, nullptr) + start.col;
|
||||
uint32_t end_byte = line_to_byte(this->root, end.row, nullptr) + end.col;
|
||||
char *text = read(this->root, start_byte, end_byte - start_byte);
|
||||
if (out_len)
|
||||
*out_len = end_byte - start_byte;
|
||||
return text;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "editor/editor.h"
|
||||
|
||||
void hover_diagnostic(Editor *editor) {
|
||||
std::shared_lock lock(editor->v_mtx);
|
||||
static uint32_t last_line = UINT32_MAX;
|
||||
if (last_line == editor->cursor.row && !editor->warnings_dirty)
|
||||
return;
|
||||
@@ -15,23 +14,22 @@ void hover_diagnostic(Editor *editor) {
|
||||
std::upper_bound(editor->warnings.begin(), editor->warnings.end(), dummy);
|
||||
std::vector<VWarn> warnings_at_line(first, last);
|
||||
if (warnings_at_line.size() == 0) {
|
||||
editor->diagnostics_active = false;
|
||||
editor->diagnostic_popup->hidden = true;
|
||||
return;
|
||||
}
|
||||
editor->diagnostics.clear();
|
||||
editor->diagnostics.warnings.swap(warnings_at_line);
|
||||
editor->diagnostics.render_first();
|
||||
editor->diagnostics_active = true;
|
||||
editor->diagnostic_popup->clear();
|
||||
editor->diagnostic_popup->warnings.swap(warnings_at_line);
|
||||
editor->diagnostic_popup->hidden = false;
|
||||
}
|
||||
|
||||
void editor_worker(Editor *editor) {
|
||||
if (!editor || !editor->root)
|
||||
void Editor::work() {
|
||||
if (!this->root)
|
||||
return;
|
||||
if (editor->parser)
|
||||
editor->parser->work();
|
||||
hover_diagnostic(editor);
|
||||
if (editor->completion.active && editor->completion.hover_dirty) {
|
||||
editor->completion.hover.render_first();
|
||||
editor->completion.hover_dirty = false;
|
||||
}
|
||||
if (this->parser)
|
||||
this->parser->work();
|
||||
hover_diagnostic(this);
|
||||
// if (this->completion.active && this->completion.hover_dirty) {
|
||||
// this->completion.hover.render_first();
|
||||
// this->completion.hover_dirty = false;
|
||||
// }
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user