diff options
author | Caleb Marshall <caleb@mrshl.net> | 2024-03-09 14:23:25 -0600 |
---|---|---|
committer | Christian Clason <c.clason@uni-graz.at> | 2024-03-16 20:37:56 +0800 |
commit | 542c910a1d3ffd29b59278b740abd7487315cb47 (patch) | |
tree | ca1cf6062652d30485797352aac7e364c65f5e2c | |
parent | ee89ba1d7531b184d5abc6b311db258da26bae42 (diff) | |
download | rneovim-542c910a1d3ffd29b59278b740abd7487315cb47.tar.gz rneovim-542c910a1d3ffd29b59278b740abd7487315cb47.tar.bz2 rneovim-542c910a1d3ffd29b59278b740abd7487315cb47.zip |
fix(lsp): add missing LSP semantic token highlight links
Added the following LSP semantic token types to be linked to highlight
groups by default:
* @lsp.type.event
* @lsp.type.keyword
* @lsp.type.modifier
* @lsp.type.number
* @lsp.type.operator
* @lsp.type.regexp
* @lsp.type.string
-rw-r--r-- | runtime/doc/lsp.txt | 7 | ||||
-rw-r--r-- | src/nvim/highlight_group.c | 7 | ||||
-rw-r--r-- | test/functional/plugin/lsp/semantic_tokens_spec.lua | 75 |
3 files changed, 74 insertions, 15 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index cecf7c8d38..5488226f78 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -460,13 +460,20 @@ The following groups are linked by default to standard |group-name|s: @lsp.type.decorator Function @lsp.type.enum Structure @lsp.type.enumMember Constant +@lsp.type.event Type @lsp.type.function Function @lsp.type.interface Structure +@lsp.type.keyword Keyword @lsp.type.macro Macro @lsp.type.method Function +@lsp.type.modifier Type @lsp.type.namespace Structure +@lsp.type.number Number +@lsp.type.operator Operator @lsp.type.parameter Identifier @lsp.type.property Identifier +@lsp.type.regexp SpecialChar +@lsp.type.string String @lsp.type.struct Structure @lsp.type.type Type @lsp.type.typeParameter TypeDef diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index 1474a2ba06..682df8bcb5 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -290,13 +290,20 @@ static const char *highlight_init_both[] = { "default link @lsp.type.decorator @attribute", "default link @lsp.type.enum @type", "default link @lsp.type.enumMember @constant", + "default link @lsp.type.event @type", "default link @lsp.type.function @function", "default link @lsp.type.interface @type", + "default link @lsp.type.keyword @keyword", "default link @lsp.type.macro @constant.macro", "default link @lsp.type.method @function.method", + "default link @lsp.type.modifier @type.qualifier", "default link @lsp.type.namespace @module", + "default link @lsp.type.number @number", + "default link @lsp.type.operator @operator", "default link @lsp.type.parameter @variable.parameter", "default link @lsp.type.property @property", + "default link @lsp.type.regexp @string.regexp", + "default link @lsp.type.string @string", "default link @lsp.type.struct @type", "default link @lsp.type.type @type", "default link @lsp.type.typeParameter @type.definition", diff --git a/test/functional/plugin/lsp/semantic_tokens_spec.lua b/test/functional/plugin/lsp/semantic_tokens_spec.lua index 77e39c81c8..ad09ab08b3 100644 --- a/test/functional/plugin/lsp/semantic_tokens_spec.lua +++ b/test/functional/plugin/lsp/semantic_tokens_spec.lua @@ -37,6 +37,8 @@ describe('semantic token highlighting', function() [7] = { bold = true, foreground = Screen.colors.DarkCyan }, [8] = { bold = true, foreground = Screen.colors.SlateBlue }, [9] = { bold = true, foreground = tonumber('0x6a0dad') }, + [10] = { bold = true, foreground = Screen.colors.Brown }, + [11] = { foreground = Screen.colors.Magenta1 }, } command([[ hi link @lsp.type.namespace Type ]]) command([[ hi link @lsp.type.function Special ]]) @@ -837,11 +839,13 @@ b = "as"]], { it = 'rust-analyzer', text = [[pub fn main() { - break rust; - /// what? + println!("Hello world!"); + break rust; + /// what? } ]], - response = [[{"data": [0, 0, 3, 1, 0, 0, 4, 2, 1, 0, 0, 3, 4, 14, 524290, 0, 4, 1, 45, 0, 0, 1, 1, 45, 0, 0, 2, 1, 26, 0, 1, 4, 5, 1, 8192, 0, 6, 4, 52, 0, 0, 4, 1, 48, 0, 1, 4, 9, 0, 1, 1, 0, 1, 26, 0], "resultId": "1"}]], + response = [[{"data": [0, 0, 3, 1, 0, 0, 4, 2, 1, 0, 0, 3, 4, 14, 524290, 0, 4, 1, 45, 0, 0, 1, 1, 45, 0, 0, 2, 1, 26, 0, 1, 4, 8, 17, 0, 0, 8, 1, 45, 0, 0, 1, 14, 2, 0, 0, 14, 1, 45, 0, 0, 1, 1, 48, 0, 1, 4, 5, 1, 8192, 0, 6, 4, 52, 0, 0, 4, 1, 48, 0, 1, 4, 9, 0, 1, 1, 0, 1, 26, 0 ], "resultId": "1"}]], + legend = [[{ "tokenTypes": [ "comment", "keyword", "string", "number", "regexp", "operator", "namespace", "type", "struct", "class", "interface", "enum", "enumMember", "typeParameter", "function", "method", "property", "macro", "variable", @@ -904,6 +908,46 @@ b = "as"]], }, { line = 1, + modifiers = {}, + start_col = 4, + end_col = 12, + type = 'macro', -- println! + marked = true, + }, + { + line = 1, + modifiers = {}, + start_col = 12, + end_col = 13, + type = 'parenthesis', + marked = true, + }, + { + line = 1, + modifiers = {}, + start_col = 13, + end_col = 27, + type = 'string', -- "Hello world!" + marked = true, + }, + { + line = 1, + modifiers = {}, + start_col = 27, + end_col = 28, + type = 'parenthesis', + marked = true, + }, + { + line = 1, + modifiers = {}, + start_col = 28, + end_col = 29, + type = 'semicolon', + marked = true, + }, + { + line = 2, modifiers = { controlFlow = true }, start_col = 4, end_col = 9, -- break @@ -911,31 +955,31 @@ b = "as"]], marked = true, }, { - line = 1, + line = 2, modifiers = {}, start_col = 10, - end_col = 13, -- rust + end_col = 14, -- rust type = 'unresolvedReference', marked = true, }, { - line = 1, + line = 2, modifiers = {}, - start_col = 13, - end_col = 13, + start_col = 14, + end_col = 15, type = 'semicolon', marked = true, }, { - line = 2, + line = 3, modifiers = { documentation = true }, start_col = 4, - end_col = 11, + end_col = 13, type = 'comment', -- /// what? marked = true, }, { - line = 3, + line = 4, modifiers = {}, start_col = 0, end_col = 1, @@ -946,12 +990,13 @@ b = "as"]], expected_screen = function() screen:expect { grid = [[ - pub fn {8:main}() { | - break rust; | - //{6:/ what?} | + {10:pub} {10:fn} {8:main}() { | + {5:println!}({11:"Hello world!"}); | + {10:break} rust; | + {6:/// what?} | } | ^ | - {1:~ }|*10 + {1:~ }|*9 | ]], } |