Skip to content

Commit

Permalink
Merge branch 'color2'
Browse files Browse the repository at this point in the history
  • Loading branch information
wellcomez committed Nov 4, 2024
2 parents d732f88 + 7f56f95 commit ab417cf
Show file tree
Hide file tree
Showing 532 changed files with 6,598 additions and 4,258 deletions.
181 changes: 99 additions & 82 deletions d.lua
Original file line number Diff line number Diff line change
@@ -1,87 +1,75 @@
-- Define highlight groups and output file path
---@type
local highlight_groups = {
"LineNr",
"Comment", -- "Variable",
"Constant", "String", "Function", "Keyword", "Type", "Character", "Number", "Boolean", "Float", "Identifier",
"Function", "Statement", "Conditional", "Repeat", "Label", "Operator", "Keyword", "Exception",
"PreProc", "Include", "Define", "Macro", "PreCondit", "Type", "StorageClass", "Structure",
"Typedef", "Special", "SpecialChar", "Tag", "Delimiter", "SpecialComment", "Debug",
"Underlined", "Ignore", "Error", "Added", "Changed", "Removed", "CursorLine", "CursorColumn",
"Visual", "StatusLine", "Normal", "DiagnosticError", "DiagnosticWarn", "DiagnosticInfo",
"DiagnosticHint", -- >
"DiffAdd",
"DiffChange",
"DiffDelete",
"LspReferenceText",
"LspReferenceRead",
"LspReferenceWrite",
"@variable", -- ; various variable names
"@variable.builtin", -- ; built-in variable names (e.g. `this`)
"@variable.parameter", -- ; parameters of a function
"@variable.parameter.builtin",-- ; special parameters (e.g. `_`, `it`)
"@variable.member", -- ; object and struct fields
"@constant", -- ; constant identifiers
"@constant.builtin", -- ; built-in constant values
"@constant.macro", -- ; constants defined by the preprocessor
"@module", -- ; modules or namespaces
"@module.builtin", -- ; built-in modules or namespaces
"@label", -- ; GOTO and other labels (e.g. `label:` in C), including heredoc labels
"@function", -- ; function definitions
"@function.builtin", -- ; built-in functions
"@function.call", -- ; function calls
"@function.macro", -- ; preprocessor macros
"@function.method", -- ; method definitions
"@function.method.call",-- ; method calls
"@constructor", -- ; constructor calls and definitions
"@operator", -- ; symbolic operators (e.g. `+` / `*`)
"@String",
"@type", -- ; type or class definitions and annotations
"@type.builtin", -- ; built-in types
"@type.definition", -- ; identifiers in type definitions (e.g. `typedef <type> <identifier>` in C)
"@type.class",
"@attribute", -- ; attribute annotations (e.g. Python decorators, Rust lifetimes)
"@attribute.builtin", -- ; builtin annotations (e.g. `@property` in Python)
"@property", -- ; the key in key/value pairs
"@Comment",
"@keyword", "@keyword.coroutine", "@keyword.function", "@keyword.operator", "@keyword.import",
"@keyword.type", "@keyword.modifier", "@keyword.repeat", "@keyword.return", "@keyword.debug",
"@keyword.exception", "@keyword.conditional", "@keyword.conditional.ternary",
"@keyword.directive", "@keyword.directive.define",
"@string", -- ; string literals
"@string.documentation", -- ; string documenting code (e.g. Python docstrings)
"@string.regexp", -- ; regular expressions
"@string.escape", -- ; escape sequences
"@string.special", -- ; other special strings (e.g. dates)
"@string.special.symbol", --; symbols or atoms
"@string.special.url", --; URIs (e.g. hyperlinks)
"@string.special.path", --; filenames
"@character", -- ; character literals
"@character.special", -- ; special characters (e.g. wildcards)
"@boolean", -- ; boolean literals
"@number", -- ; numeric literals
"@number.float", -- ; floating-point number literals
"@markup.strong", -- ; bold text
"@markup.italic", -- ; italic text
"@markup.strikethrough", -- ; struck-through text
"@markup.underline", -- ; underlined text (only for literal underline markup!)
"@markup.heading", -- ; headings, titles (including markers)
"@markup.heading.1",-- ; top-level heading
"@markup.heading.2",-- ; section heading
"@markup.heading.3", -- ; subsection heading
"@markup.heading.4", -- ; and so on
"@markup.heading.5", -- ; and so forth
"@markup.heading.6", -- ; six levels ought to be enough for anybody
"@markup.quote", -- ; block quotes
"@markup.math", -- ; math environments (e.g. `$ ... $` in LaTeX)
"@markup.link", -- ; text references, footnotes, citations, etc.
"@markup.link.label", -- ; link, reference descriptions
"@markup.link.url", -- ; URL-style links
"@markup.raw", -- ; literal or verbatim text (e.g. inline code)
"@markup.raw.block", -- ; literal or verbatim text as a stand-alone block (use priority 90 for blocks with injections)
"@markup.list", -- ; list markers
"@markup.list.checked", -- ; checked todo-style list markers
"@markup.list.unchecked" -- ; unchecked todo-style list markers
local highlight_groups = {"LineNr", "Comment", -- "Variable",
"Constant", "String", "Function", "Keyword", "Type", "Character", "Number", "Boolean", "Float", "Identifier",
"Function", "Statement", "Conditional", "Repeat", "Label", "Operator", "Keyword", "Exception",
"PreProc", "Include", "Define", "Macro", "PreCondit", "Type", "StorageClass", "Structure",
"Typedef", "Special", "SpecialChar", "Tag", "Delimiter", "SpecialComment", "Debug",
"Underlined", "Ignore", "Error", "Added", "Changed", "Removed", "CursorLine", "CursorColumn",
"Visual", "StatusLine", "Normal", "DiagnosticError", "DiagnosticWarn", "DiagnosticInfo",
"DiagnosticHint", -- >
"DiffAdd", "DiffChange", "DiffDelete", "LspReferenceText", "LspReferenceRead", "LspReferenceWrite", "@variable", -- ; various variable names
"@variable.builtin", -- ; built-in variable names (e.g. `this`)
"@variable.parameter", -- ; parameters of a function
"@variable.parameter.builtin", -- ; special parameters (e.g. `_`, `it`)
"@variable.member", -- ; object and struct fields
"@constant", -- ; constant identifiers
"@constant.builtin", -- ; built-in constant values
"@constant.macro", -- ; constants defined by the preprocessor
"@module", -- ; modules or namespaces
"@module.builtin", -- ; built-in modules or namespaces
"@label", -- ; GOTO and other labels (e.g. `label:` in C), including heredoc labels
"@function", -- ; function definitions
"@function.builtin", -- ; built-in functions
"@function.call", -- ; function calls
"@function.macro", -- ; preprocessor macros
"@function.method", -- ; method definitions
"@function.method.call", -- ; method calls
"@constructor", -- ; constructor calls and definitions
"@operator", -- ; symbolic operators (e.g. `+` / `*`)
"@String", "@type", -- ; type or class definitions and annotations
"@type.builtin", -- ; built-in types
"@type.definition", -- ; identifiers in type definitions (e.g. `typedef <type> <identifier>` in C)
"@type.class", "@attribute", -- ; attribute annotations (e.g. Python decorators, Rust lifetimes)
"@attribute.builtin", -- ; builtin annotations (e.g. `@property` in Python)
"@property", -- ; the key in key/value pairs
"@Comment", "@keyword", "@keyword.coroutine", "@keyword.function", "@keyword.operator", "@keyword.import",
"@keyword.type", "@keyword.modifier", "@keyword.repeat", "@keyword.return", "@keyword.debug",
"@keyword.exception", "@keyword.conditional", "@keyword.conditional.ternary",
"@keyword.directive", "@keyword.directive.define", "@string", -- ; string literals
"@string.documentation", -- ; string documenting code (e.g. Python docstrings)
"@string.regexp", -- ; regular expressions
"@string.escape", -- ; escape sequences
"@string.special", -- ; other special strings (e.g. dates)
"@string.special.symbol", -- ; symbols or atoms
"@string.special.url", -- ; URIs (e.g. hyperlinks)
"@string.special.path", -- ; filenames
"@character", -- ; character literals
"@character.special", -- ; special characters (e.g. wildcards)
"@boolean", -- ; boolean literals
"@number", -- ; numeric literals
"@number.float", -- ; floating-point number literals
"@markup.strong", -- ; bold text
"@markup.italic", -- ; italic text
"@markup.strikethrough", -- ; struck-through text
"@markup.underline", -- ; underlined text (only for literal underline markup!)
"@markup.heading", -- ; headings, titles (including markers)
"@markup.heading.1", -- ; top-level heading
"@markup.heading.2", -- ; section heading
"@markup.heading.3", -- ; subsection heading
"@markup.heading.4", -- ; and so on
"@markup.heading.5", -- ; and so forth
"@markup.heading.6", -- ; six levels ought to be enough for anybody
"@markup.quote", -- ; block quotes
"@markup.math", -- ; math environments (e.g. `$ ... $` in LaTeX)
"@markup.link", -- ; text references, footnotes, citations, etc.
"@markup.link.label", -- ; link, reference descriptions
"@markup.link.url", -- ; URL-style links
"@markup.raw", -- ; literal or verbatim text (e.g. inline code)
"@markup.raw.block", -- ; literal or verbatim text as a stand-alone block (use priority 90 for blocks with injections)
"@markup.list", -- ; list markers
"@markup.list.checked", -- ; checked todo-style list markers
"@markup.list.unchecked" -- ; unchecked todo-style list markers
}
local function get_available_themes()
local themes = {}
Expand All @@ -105,6 +93,23 @@ local function get_available_themes()
return themes
end
local colorscheme = vim.g.colors_name

local function save_hlresult(search_highlight, group, f)
f:write(" - Group: " .. '"' .. group .. '"' .. "\n")
local c = search_highlight.fg
if c then
local k = "foreground"
local d = string.format("#%06x", c)
f:write(" " .. tostring(k) .. ": \"" .. tostring(d) .. "\"\n")
end
c = search_highlight.bg
if c then
local k = "background"
local d = string.format("#%06x", c)
f:write(" " .. tostring(k) .. ": \"" .. tostring(d) .. "\"\n")
end
end

local function save_scheme(colorscheme)
local output_file = colorscheme .. ".yml" -- Path to the output file
-- Function to get highlight settings and write to a file
Expand Down Expand Up @@ -132,6 +137,18 @@ local function save_scheme(colorscheme)
f:write("\n")
end

local search_highlight = vim.api.nvim_get_hl(0, {
name = 'Search',
link = false
})

local incsearch_highlight = vim.api.nvim_get_hl(0, {
name = 'IncSearch',
link = false
})
save_hlresult(search_highlight, "search", f)
save_hlresult(incsearch_highlight, "insearch", f)

-- Close the file
f:close()

Expand Down
2 changes: 1 addition & 1 deletion pkg/femto
Submodule femto updated 3 files
+20 −13 buffer.go
+1 −1 cellview.go
+35 −0 view.go
16 changes: 12 additions & 4 deletions pkg/highlight/highlighter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
"strings"
"unicode/utf8"

lspcore "zen108.com/lspvi/pkg/lsp"
hlresult "zen108.com/lspvi/pkg/highlight/result"
// lspcore "zen108.com/lspvi/pkg/lsp"
)

func sliceStart(slc []byte, index int) []byte {
Expand Down Expand Up @@ -87,7 +88,7 @@ type Highlighter struct {
lastRegion *region
Def *Def
// Tdongshangnezha reeSitter
Tree lspcore.TreesiterSymbolLine
HighLights hlresult.HLResult
}

// NewHighlighter returns a new highlighter from the given syntax definition
Expand Down Expand Up @@ -361,8 +362,8 @@ func (h *Highlighter) HighlightMatches(input LineStates, startline, endline int)
}
line := input.LineBytes(i)
var match_tree_match LineMatch = make(LineMatch)
if len(h.Tree) > 0 {
if sym_in_line, ok := h.Tree[i]; ok {
if len(h.HighLights.Tree) > 0 {
if sym_in_line, ok := h.HighLights.Tree[i]; ok {
for _, v := range sym_in_line {
x := []string{"@" + v.SymbolName}
ind := strings.Index(v.SymbolName, ".")
Expand Down Expand Up @@ -410,6 +411,13 @@ func (h *Highlighter) HighlightMatches(input LineStates, startline, endline int)
input.SetMatch(i, match)
}
}
func (b *Highlighter) UpdateCurrentPos(result hlresult.MatchPosition) {
b.HighLights.Current = result
}

func (b *Highlighter) UpdateHLResult(result hlresult.HLResult) {
b.HighLights = result
}

// ReHighlightStates will scan down from `startline` and set the appropriate end of line state
// for each line until it comes across the same state in two consecutive lines
Expand Down
86 changes: 86 additions & 0 deletions pkg/highlight/result/hlresult.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package hlresult

import lspcore "zen108.com/lspvi/pkg/lsp"

type MatchPosition struct {
Begin, End, Y int
}
type SearchLine struct {
Lines map[int][]MatchPosition
}

func NewSearchLine() SearchLine {
return SearchLine{Lines: make(map[int][]MatchPosition)}
}
func (l *SearchLine) Add(pos MatchPosition) {
if _, yes := l.Lines[pos.Y]; !yes {
l.Lines[pos.Y] = []MatchPosition{}
}
l.Lines[pos.Y] = append(l.Lines[pos.Y], pos)
}

type HLResult struct {
Tree lspcore.TreesiterSymbolLine
Current MatchPosition
SearchResult SearchLine
}

func (h *HLResult) Update() {
for line := range h.SearchResult.Lines {
h.update_line(line)
}
}
func (h *HLResult) GetPosition(lineno int) []MatchPosition {
return h.SearchResult.Lines[lineno]
}
func (h *HLResult) update_line(lineno int) {
sym_in_line := h.Tree[lineno]
search_result := h.SearchResult.Lines[lineno]
if len(search_result) > 0 {
var new_outline = []lspcore.TreeSitterSymbol{}
word_index := 0
for _, outline := range sym_in_line {
split := false
for i := word_index; i < len(search_result); i++ {
word := search_result[i]
if word.End < int(outline.Begin.Column) {
word_index++
continue
}
if int(outline.Begin.Column) <= word.Begin && int(outline.End.Column) >= word.End {
// word_index++
col1 := outline
col1.End.Column = uint32(word.Begin)
col2 := outline
col2.Begin.Column = uint32(word.End)
split = true
if col1.Begin.Column < col1.End.Column {
new_outline = append(new_outline, col1)
}
// new_outline = append(new_outline, lspcore.TreeSitterSymbol{
// SymbolName: "search",
// Begin: lspcore.Point{Row: uint32(lineno), Column: uint32(word.Begin)},
// End: lspcore.Point{Row: uint32(lineno), Column: uint32(word.End)},
// })
if col2.End.Column > col2.Begin.Column {
// new_outline = append(new_outline, col2)
}
} else if word.End < int(outline.Begin.Column) {
// word_index++
// new_outline = append(new_outline, lspcore.TreeSitterSymbol{
// SymbolName: "search",
// Begin: lspcore.Point{Row: uint32(lineno), Column: uint32(word.Begin)},
// End: lspcore.Point{Row: uint32(lineno), Column: uint32(word.End)},
// })
} else {

break
}
}
if !split {
new_outline = append(new_outline, outline)
}
}
h.Tree[lineno] = new_outline
}
}
4 changes: 4 additions & 0 deletions pkg/treesittertheme/colorscheme/aurora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,7 @@ Data:
- Group: "@markup.list.unchecked"
foreground: "#4c77e4"

- Group: "search"
background: "#303047"
- Group: "insearch"
background: "#57109a"
16 changes: 11 additions & 5 deletions pkg/treesittertheme/colorscheme/base16-3024.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@ Data:
background: "#90300"

- Group: "LspReferenceText"
special: 8420732
underline: true
special: 8420732

- Group: "LspReferenceRead"
special: 8420732
underline: true
special: 8420732

- Group: "LspReferenceWrite"
special: 8420732
underline: true
special: 8420732

- Group: "@variable"
foreground: "#db2d20"
Expand Down Expand Up @@ -330,8 +330,8 @@ Data:
foreground: "#1a252"

- Group: "@string.special.url"
foreground: "#e8bbd0"
underline: true
foreground: "#e8bbd0"

- Group: "@string.special.path"
foreground: "#cdab53"
Expand Down Expand Up @@ -397,8 +397,8 @@ Data:
foreground: "#cdab53"

- Group: "@markup.link.url"
foreground: "#e8bbd0"
underline: true
foreground: "#e8bbd0"

- Group: "@markup.raw"
foreground: "#e8bbd0"
Expand All @@ -415,3 +415,9 @@ Data:
- Group: "@markup.list.unchecked"
foreground: "#cdab53"

- Group: "search"
foreground: "#3a3432"
background: "#fded02"
- Group: "insearch"
foreground: "#3a3432"
background: "#e8bbd0"
Loading

0 comments on commit ab417cf

Please sign in to comment.