Skip to content

Commit

Permalink
Merge pull request #58 from sminez/ts-support
Browse files Browse the repository at this point in the history
feat: tree-sitter based syntax highlighting
  • Loading branch information
sminez authored Dec 19, 2024
2 parents f2e781c + a2c5dbc commit dccd6b5
Show file tree
Hide file tree
Showing 34 changed files with 3,006 additions and 817 deletions.
130 changes: 129 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ serde_json = "1.0.133"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = [ "fmt" ] }
unicode-width = "0.2.0"
tree-sitter = "0.24.4"
libloading = "0.8.6"
streaming-iterator = "0.1.9"
toml = "0.8.19"

[dev-dependencies]
simple_test_case = "1.2.0"
Expand Down
138 changes: 138 additions & 0 deletions data/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Config file for the ad text editor
# For details of the TOML file format see https://toml.io/en/v1.0.0

# Whether or not the 9p filesystem interface should attempt to automount via fuse on startup
auto_mount = false
# Whether or not tab characters should be automatically replaced with `tabstop` spaces
expand_tab = true
# The number of spaces to render tab characters with
tabstop = 4
# Whether or not leading whitespace should be copied to new lines on pressing Return
match_indent = true
# Number of seconds to persist status messages for
status_timeout = 3
# Number of milliseconds allowed between left mouse clicks for registering a double click
double_click_ms = 200
# Maximum number of lines used when rendering the minibuffer state
minibuffer_lines = 8
# Shell command to be used for listing files when running the `find file` and `find repo file` commands
find_command = "fd -t f"


# Configuration for tree-sitter based syntax highlighting. See :help for details on the required
# directory structure.
[tree_sitter]
# The directory to search for compiled *.so files for parsing each language.
parser_dir = "~/.ad/tree-sitter/parsers"
# The directory to search for syntax highlighting queries.
syntax_query_dir = "~/.ad/tree-sitter/queries"


# Global color scheme settings
[colorscheme]
# The default background color for all UI elements
bg = "#1B1720"
# The default foreground color for all UI elements
fg = "#E6D29E"
# The background color for the status bar
bar_bg = "#4E415C"
# The foreground color for the sign / number column
signcol_fg = "#544863"
# The background highlight color for the selected line in the mini-buffer
minibuffer_hl = "#3E3549"

# Syntax highlighting settings for tree-sitter query captures
# Each key in this table should match a corresponding capture in one of your syntax highlighting
# queries. For example, if you had the following in your $lang.scm file:
#
# (line_comment) @comment
# (block_comment) @comment
#
# then the `comment` key in this table will define the styling for nodes matching line and block
# comments.
#
# The supported styling properties are:
# - fg: string RRGGBB hex color code
# - bg: string RRGGBB hex color code
# - bold: boolean
# - italic: boolean
# - underline: boolean
[colorscheme.syntax]
# Required styling for default text and selections
default = { fg = "#E6D29E", bg = "#1B1720" }
dot = { fg = "#E6D29E", bg = "#336677" }
load = { fg = "#E6D29E", bg = "#957FB8" }
exec = { fg = "#E6D29E", bg = "#Bf616A" }
# Styling for tree-sitter query captures
boolean = { fg = "#DCA561", bold = true }
character = { fg = "#61DCA5", italic = true }
comment = { fg = "#624354", italic = true }
constant = { fg = "#FF9E3B" }
function = { fg = "#957FB8" }
keyword = { fg = "#Bf616A" }
module = { fg = "#2D4F67" }
number = { fg = "#D27E99" }
punctuation = { fg = "#9CABCA" }
string = { fg = "#61DCA5" }
type = { fg = "#7E9CD8" }
variable = { fg = "#E6C384" }


# Key mappings to programs that must be available on $PATH or commands.
# ~/.ad/bin is auto-added to the path
[keys.normal]
"<space> F" = { run = "fmt" }
">" = { run = "indent" }
"<" = { run = "unindent" }
# Window & Column management
"<space> w /" = { run = "new-column" }
"<space> w -" = { run = "new-window" }
"<space> w h" = { run = "prev-column" }
"<space> w j" = { run = "next-window" }
"<space> w k" = { run = "prev-window" }
"<space> w l" = { run = "next-column" }


# Language configuration

[[languages]]
name = "bash"
extensions = ["sh", "bash"]
first_lines = ["#!/usr/bin/bash", "#!/usr/bin/sh", "#!/usr/bin/env bash", "#!/usr/bin/env sh"]

[[languages]]
name = "dart"
extensions = ["dart"]
lsp.command = "dart"
lsp.args = ["language-server", "--protocol=lsp"]
lsp.roots = ["melos.yaml", "pubspec.yaml"]

[[languages]]
name = "graphql"
extensions = ["graphql"]

[[languages]]
name = "json"
extensions = ["json"]

[[languages]]
name = "proto"
extensions = ["proto"]

[[languages]]
name = "rust"
extensions = ["rs"]
lsp.command = "rust-analyzer"
lsp.roots = ["Cargo.toml"]

[[languages]]
name = "scheme"
extensions = ["scm"]

[[languages]]
name = "sql"
extensions = ["sql"]

[[languages]]
name = "toml"
extensions = ["toml"]
Loading

0 comments on commit dccd6b5

Please sign in to comment.