Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve lsp semantic token and treesitter support #14

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
39faac2
feat(highlights): organize syntax groups into single file
zbroniszewski Mar 20, 2023
ad7d06c
feat(highlights): add remaining default syntax groups
zbroniszewski Mar 20, 2023
8a31b32
feat(highlights)!: change `Identifier` group color to `C.red`
zbroniszewski Mar 20, 2023
0a96647
feat(highlights)!: change `Function` group color to `C.blue`
zbroniszewski Mar 20, 2023
58e4ed2
fix(highlights): link LSP tokens to Treesitter groups
zbroniszewski Mar 20, 2023
0418c6b
fix(highlights): handle edge case priorities of LSP token/TS groups
zbroniszewski Mar 20, 2023
c366bfd
feat(highlights): add TypeScript filetype groups for LSP tokens
zbroniszewski Mar 20, 2023
8da057e
docs: add Neovim-0.9-LSP-Semantic-Tokens.md
zbroniszewski Mar 20, 2023
b2aa2a3
chore(docs): remove Neovim-0.9-LSP-Semantic-Tokens.md
zbroniszewski Mar 20, 2023
db3d56a
chore(highlights): keep Treesitter groups together
zbroniszewski Mar 20, 2023
5be3a1f
chore: remove unnecessary `set_contains` util
zbroniszewski Mar 20, 2023
8f97349
fix: handle undefined event in autocmd
zbroniszewski Mar 20, 2023
21a7a6e
fix(lsp): do not link LSP hl groups to TS hl groups
zbroniszewski Mar 26, 2023
93824a8
feat(lsp): set LSP semantic hl groups not linked by default
zbroniszewski Mar 26, 2023
0930b17
feat(highlight): change `Macro` highlight color
zbroniszewski Mar 26, 2023
368dc74
chore: remove autocmds
zbroniszewski Mar 26, 2023
f0b0b38
chore(highlight): use `link` where possible
zbroniszewski Mar 26, 2023
1a552d4
feat(highlight): keep Treesitter default hl group for `@operator`
zbroniszewski Mar 26, 2023
e211f8f
feat(highlight): change color of `Operator` to white
zbroniszewski Mar 26, 2023
d0c02f5
feat(lsp): link additional semantic token hl groups
zbroniszewski Mar 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions lua/astrotheme/groups/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,7 @@ local function callback()
return {
Normal = { fg = C.text, bg = C.base },
NormalNC = { fg = C.text, bg = C.mantle },
Comment = { fg = C.subtext1, bg = C.none },
Constant = { fg = C.yellow, bg = C.none },
String = { fg = C.green, bg = C.none },
Character = { fg = C.green, bg = C.none },
Number = { fg = C.orange, bg = C.none },
Boolean = { fg = C.blue, bg = C.none },
Float = { fg = C.yellow, bg = C.none },
Identifier = { fg = C.blue, bg = C.none },
Function = { fg = C.yellow, bg = C.none },
Statement = { fg = C.purple, bg = C.none },
Conditional = { fg = C.light_purple, bg = C.none },
Repeat = { fg = C.purple, bg = C.none },
Label = { fg = C.blue, bg = C.none },
Operator = { fg = C.purple, bg = C.none },
Keyword = { fg = C.purple, bg = C.none },
Exception = { fg = C.purple, bg = C.none },
Preproc = { fg = C.yellow, bg = C.none },
Include = { fg = C.purple, bg = C.none },
Define = { fg = C.purple, bg = C.none },
Title = { fg = C.cyan, bg = C.none },
Macro = { fg = C.purple, bg = C.none },
PreCondit = { fg = C.blue, bg = C.none },
Type = { fg = C.blue, bg = C.none },
StorageClass = { fg = C.blue, bg = C.none },
Structure = { fg = C.yellow, bg = C.none },
Typedef = { fg = C.yellow, bg = C.none },
Special = { fg = C.blue, bg = C.none },
SpecialComment = { fg = C.grey, bg = C.none },
Error = { fg = C.red, bg = C.none },
Todo = { fg = C.purple, bg = C.none },
Underlined = { fg = C.cyan, bg = C.none },
Cursor = { fg = C.none, bg = C.none },
ColorColumn = { fg = C.none, bg = C.overlay1 },
CursorLineNr = { fg = C.text, bg = C.none },
Expand Down
32 changes: 14 additions & 18 deletions lua/astrotheme/groups/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,20 @@ local function callback()
LspReferenceText = { fg = C.none, bg = C.surface1 },
LspReferenceWrite = { fg = C.none, bg = C.surface1 },
ProviderTruncateLine = { fg = C.overlay0 },
["@lsp.type.enum"] = { link = "@type" },
["@lsp.type.keyword"] = { link = "@keyword" },
["@lsp.type.interface"] = { link = "@interface" },
["@lsp.type.method"] = { link = "@function" },
["@lsp.type.namespace"] = { link = "@namespace" },
["@lsp.type.parameter"] = { link = "@parameter" },
["@lsp.type.property"] = { link = "@property" },
["@lsp.type.class"] = { link = "@namespace" },
["@lsp.type.decorator"] = { link = "@method" },
["@lsp.type.enumMember"] = { link = "@constant" },
["@lsp.type.function"] = { link = "@function" },
["@lsp.type.macro"] = { link = "@function.macro" },
["@lsp.type.type"] = { link = "@type" },
["@lsp.type.typeParameter"] = { link = "@parameter" },
["@lsp.type.variable"] = {}, -- use treesitter styles for regular variables
["@lsp.typemod.method.defaultLibrary"] = { link = "@function.builtin" },
["@lsp.typemod.function.defaultLibrary"] = { link = "@function.builtin" },
["@lsp.typemod.variable.defaultLibrary"] = { link = "@variable.builtin" },
-- LSP Semantic Tokens
-- Ref: :help lsp-semantic-highlight
["@lsp.type.builtinType"] = { fg = C.yellow, bg = C.none },
["@lsp.type.keyword"] = { link = "Keyword" },
["@lsp.type.operator"] = { link = "Operator" },
["@lsp.typemod.enumMember.defaultLibrary"] = { fg = C.cyan, bg = C.none },
["@lsp.typemod.function.defaultLibrary"] = { fg = C.cyan, bg = C.none },
["@lsp.typemod.function.global"] = { fg = C.cyan, bg = C.none },
["@lsp.typemod.method.defaultLibrary"] = { fg = C.cyan, bg = C.none },
["@lsp.typemod.method.reference"] = { link = "Function" },
["@lsp.typemod.method.trait"] = { link = "Function" },
["@lsp.typemod.selfKeyword.defaultLibrary"] = { link = "Keyword" },
["@lsp.typemod.variable.defaultLibrary"] = { fg = C.yellow, bg = C.none },
["@lsp.typemod.variable.readonly"] = { link = "Constant" },
}
end

Expand Down
10 changes: 5 additions & 5 deletions lua/astrotheme/groups/plugins/nvim-treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ local function callback()
["@function.macro"] = { fg = C.yellow },
["@function.macro.rust"] = { fg = C.orange },
["@include"] = { fg = C.purple },
["@keyword"] = { fg = C.purple },
["@keyword.function"] = { fg = C.purple },
["@keyword"] = { link = "Keyword" },
["@keyword.function"] = { link = "Keyword" },
["@keyword.function.rust"] = { fg = C.orange },
["@keyword.operator"] = { fg = C.purple },
["@keyword.operator"] = { link = "Keyword" },
["@label"] = { fg = C.blue },
["@literal.markdown"] = { fg = C.green },
["@method"] = { fg = C.blue },
["@namespace"] = { fg = C.purple },
["@namespace"] = { link = "Keyword" },
["@namespace.rust"] = { fg = C.yellow },
["@none.markdown"] = { fg = C.text },
["@number"] = { fg = C.orange },
["@operator"] = { fg = C.cyan },
["@parameter"] = { fg = C.red },
["@parameter.reference"] = { fg = C.cyan },
["@property"] = { fg = C.yellow },
Expand All @@ -56,6 +55,7 @@ local function callback()
["@title.markdown"] = { fg = C.red },
["@type"] = { fg = C.blue },
["@type.builtin"] = { fg = C.blue },
["@type.qualifier.typescript"] = { link = "Keyword" },
["@type.rust"] = { fg = C.yellow },
["@variable"] = { fg = C.red },
["@variable.builtin"] = { fg = C.yellow },
Expand Down
60 changes: 60 additions & 0 deletions lua/astrotheme/groups/syntax.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
-- Subgroups inherit highlights from their primary groups by default.
-- While unnecessary, we define all subgroups and their highlights
-- for completeness.
--
-- Syntax group hierachry (e.g.):
-- - Constant (Primary group)
-- - String (Subgroup)
-- - Character (Subgroup)
--
-- Ref: :help group-name
local syntax_groups = {
-- Comment
Comment = { fg = C.subtext1, bg = C.none }, -- any comment
-- Constant
Constant = { fg = C.yellow, bg = C.none }, -- any constant
String = { fg = C.green, bg = C.none }, -- a string constant: "this is a string"
Character = { fg = C.green, bg = C.none }, -- a character constant: 'c', '\n'
Number = { fg = C.orange, bg = C.none }, -- a number constant: 234, 0xff
Boolean = { fg = C.blue, bg = C.none }, -- a boolean constant: TRUE, false
Float = { fg = C.yellow, bg = C.none }, -- a floating point constant: 2.3e10
-- Identifier
Identifier = { fg = C.red, bg = C.none }, -- any variable name
Function = { fg = C.blue, bg = C.none }, -- function name (also: methods for classes)
-- Statement
Statement = { fg = C.purple, bg = C.none }, -- any statement
Conditional = { fg = C.light_purple, bg = C.none }, -- if, then, else, endif, switch, etc.
Repeat = { fg = C.purple, bg = C.none }, -- for, do, while, etc.
Label = { fg = C.blue, bg = C.none }, -- case, default, etc.
Operator = { fg = C.white, bg = C.none }, -- "sizeof", "+", "*", etc.
Keyword = { fg = C.purple, bg = C.none }, -- any other keyword
Exception = { fg = C.purple, bg = C.none }, -- try, catch, throw
-- Preproc
PreProc = { fg = C.yellow, bg = C.none }, -- generic Preprocessor
Include = { fg = C.purple, bg = C.none }, -- preprocessor #include
Define = { fg = C.purple, bg = C.none }, -- preprocessor #define
Macro = { fg = C.orange, bg = C.none }, -- same as Define
PreCondit = { fg = C.blue, bg = C.none }, -- preprocessor #if, #else, #endif, etc.
-- Type
Type = { fg = C.blue, bg = C.none }, -- int, long, char, etc.
StorageClass = { fg = C.blue, bg = C.none }, -- static, register, volatile, etc.
Structure = { fg = C.yellow, bg = C.none }, -- struct, union, enum, etc.
Typedef = { fg = C.yellow, bg = C.none }, -- A typedef
-- Special
Special = { fg = C.blue, bg = C.none }, -- any special symbol
SpecialChar = { fg = C.blue, bg = C.none }, -- special character in a constant
Tag = { fg = C.blue, bg = C.none }, -- you can use CTRL-] on this
Delimiter = { fg = C.blue, bg = C.none }, -- character that needs attention
SpecialComment = { fg = C.grey, bg = C.none }, -- special things inside a comment
Debug = { fg = C.blue, bg = C.none }, -- debugging statements
-- Underlined
Underlined = { fg = C.cyan, bg = C.none }, -- text that stands out, HTML links
-- Ignore
Ignore = { fg = C.none, bg = C.none }, -- left blank, hidden |hl-Ignore|
-- Error
Error = { fg = C.red, bg = C.none }, -- any erroneous construct
-- Todo
Todo = { fg = C.purple, bg = C.none }, -- anything that needs extra attention; mostly the keywords TODO FIXME and XXX
}

return syntax_groups
1 change: 1 addition & 0 deletions lua/astrotheme/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function M.load(theme)
local highlights = {}
highlights = util.get_hl_modules(highlights, "astrotheme.groups", {
"base",
"syntax",
"lsp",
"astronvim",
})
Expand Down