highlight: use custom highlight groups

This commit is contained in:
Thomas Vigouroux
2020-06-21 19:43:02 +02:00
committed by Thomas Vigouroux
parent 2d224ac3bf
commit 282e18edd1
4 changed files with 235 additions and 33 deletions

View File

@@ -166,4 +166,135 @@ Note: This is highly experimental, and folding can break on some types of
edits. If you encounter such breakage, hiting `zx` should fix folding.
In any case, feel free to open an issue with the reproducing steps.
==============================================================================
HIGHLIGHTS *nvim-treesitter-highlights*
TSError
`TSPunctDelimiter`
*hl-TSPunctDelimiter*
For delimiters ie: `.`
`TSPunctBracket`
*hl-TSPunctBracket*
For brackets and parens.
`TSPunctSpecial`
*hl-TSPunctSpecial*
For special punctutation that does not fall in the catagories before.
`TSConstant`
*hl-TSConstant*
For constants
`TSConstBuiltin`
*hl-TSConstBuiltin*
For constant that are built in the language: `nil` in Lua.
`TSConstMacro`
*hl-TSConstMacro*
For constants that are defined by macros: `NULL` in C.
`TSString`
*hl-TSString*
For strings.
`TSStringRegex`
*hl-TSStringRegex*
For regexes.
`TSStringEscape`
*hl-TSStringEscape*
For escape characters within a string.
`TSCharacter`
*hl-TSCharacter*
For characters.
`TSNumber`
*hl-TSNumber*
For integers.
`TSBoolean`
*hl-TSBoolean*
For booleans.
`TSFloat`
*hl-TSFloat*
For floats.
`TSFunction`
*hl-TSFunction*
For function (calls and definitions).
`TSFuncBuiltin`
*hl-TSFuncBuiltin*
For builtin functions: `table.insert` in Lua.
`TSFuncMacro`
*hl-TSFuncMacro*
For macro defined fuctions (calls and definitions): each `macro_rules` in
Rust.
`TSParameter`
*hl-TSParameter*
For parameters of a function.
`TSMethod`
*hl-TSMethod*
For method calls and definitions.
`TSField`
*hl-TSField*
For fields.
`TSProperty`
*hl-TSProperty*
Same as `TSField`.
`TSConstructor`
*hl-TSConstructor*
For constructor calls and definitions: `{}` in Lua, and Java constructors.
`TSConditional`
*hl-TSConditional*
For keywords related to conditionnals.
`TSRepeat`
*hl-TSRepeat*
For keywords related to loops.
`TSLabel`
*hl-TSLabel*
For labels: `labe:` in C and `:label:` in Lua.
`TSOperator`
*hl-TSOperator*
For any operator: `+`, but also `->` and `*` in C.
`TSKeyword`
*hl-TSKeyword*
For keywords that don't fall in previous categories.
`TSException`
*hl-TSException*
For exception related keywords.
`TSType`
*hl-TSType*
For types.
`TSTypeBuiltin`
*hl-TSTypeBuiltin*
For builtin types (you guessed it, right ?).
`TSStructure`
*hl-TSStructure*
This is left as an exercise for the reader.
`TSInclude`
*hl-TSInclude*
For includes: `#include` in C, `use` or `extern crate` in Rust, or `require`
in Lua
vim:tw=78:ts=8:noet:ft=help:norl:

View File

@@ -5,9 +5,41 @@
:TSInstall nvim-treesitter.txt /*:TSInstall*
:TSInstallInfo nvim-treesitter.txt /*:TSInstallInfo*
:TSModuleInfo nvim-treesitter.txt /*:TSModuleInfo*
hl-TSBoolean nvim-treesitter.txt /*hl-TSBoolean*
hl-TSCharacter nvim-treesitter.txt /*hl-TSCharacter*
hl-TSConditional nvim-treesitter.txt /*hl-TSConditional*
hl-TSConstBuiltin nvim-treesitter.txt /*hl-TSConstBuiltin*
hl-TSConstMacro nvim-treesitter.txt /*hl-TSConstMacro*
hl-TSConstant nvim-treesitter.txt /*hl-TSConstant*
hl-TSConstructor nvim-treesitter.txt /*hl-TSConstructor*
hl-TSException nvim-treesitter.txt /*hl-TSException*
hl-TSField nvim-treesitter.txt /*hl-TSField*
hl-TSFloat nvim-treesitter.txt /*hl-TSFloat*
hl-TSFuncBuiltin nvim-treesitter.txt /*hl-TSFuncBuiltin*
hl-TSFuncMacro nvim-treesitter.txt /*hl-TSFuncMacro*
hl-TSFunction nvim-treesitter.txt /*hl-TSFunction*
hl-TSInclude nvim-treesitter.txt /*hl-TSInclude*
hl-TSKeyword nvim-treesitter.txt /*hl-TSKeyword*
hl-TSLabel nvim-treesitter.txt /*hl-TSLabel*
hl-TSMethod nvim-treesitter.txt /*hl-TSMethod*
hl-TSNumber nvim-treesitter.txt /*hl-TSNumber*
hl-TSOperator nvim-treesitter.txt /*hl-TSOperator*
hl-TSParameter nvim-treesitter.txt /*hl-TSParameter*
hl-TSProperty nvim-treesitter.txt /*hl-TSProperty*
hl-TSPunctBracket nvim-treesitter.txt /*hl-TSPunctBracket*
hl-TSPunctDelimiter nvim-treesitter.txt /*hl-TSPunctDelimiter*
hl-TSPunctSpecial nvim-treesitter.txt /*hl-TSPunctSpecial*
hl-TSRepeat nvim-treesitter.txt /*hl-TSRepeat*
hl-TSString nvim-treesitter.txt /*hl-TSString*
hl-TSStringEscape nvim-treesitter.txt /*hl-TSStringEscape*
hl-TSStringRegex nvim-treesitter.txt /*hl-TSStringRegex*
hl-TSStructure nvim-treesitter.txt /*hl-TSStructure*
hl-TSType nvim-treesitter.txt /*hl-TSType*
hl-TSTypeBuiltin nvim-treesitter.txt /*hl-TSTypeBuiltin*
nvim-treesitter nvim-treesitter.txt /*nvim-treesitter*
nvim-treesitter-commands nvim-treesitter.txt /*nvim-treesitter-commands*
nvim-treesitter-functions nvim-treesitter.txt /*nvim-treesitter-functions*
nvim-treesitter-highlights nvim-treesitter.txt /*nvim-treesitter-highlights*
nvim-treesitter-intro nvim-treesitter.txt /*nvim-treesitter-intro*
nvim-treesitter-quickstart nvim-treesitter.txt /*nvim-treesitter-quickstart*
nvim-treesitter-utils nvim-treesitter.txt /*nvim-treesitter-utils*

View File

@@ -11,45 +11,45 @@ local M = {
local hlmap = vim.treesitter.TSHighlighter.hl_map
-- Misc
hlmap.error = "Error"
hlmap["punctuation.delimiter"] = "Delimiter"
hlmap["punctuation.bracket"] = "Delimiter"
hlmap["punctuation.special"] = "Delimiter"
hlmap.error = "TSError"
hlmap["punctuation.delimiter"] = "TSPunctDelimiter"
hlmap["punctuation.bracket"] = "TSPunctBracket"
hlmap["punctuation.special"] = "TSPunctSpecial"
-- Constants
hlmap["constant"] = "Constant"
hlmap["constant.builtin"] = "Special"
hlmap["constant.macro"] = "Define"
hlmap["string"] = "String"
hlmap["string.regex"] = "String"
hlmap["string.escape"] = "SpecialChar"
hlmap["character"] = "Character"
hlmap["number"] = "Number"
hlmap["boolean"] = "Boolean"
hlmap["float"] = "Float"
hlmap["constant"] = "TSConstant"
hlmap["constant.builtin"] = "TSConstBuiltin"
hlmap["constant.macro"] = "TSConstMacro"
hlmap["string"] = "TSString"
hlmap["string.regex"] = "TSStringRegex"
hlmap["string.escape"] = "TSStringEscape"
hlmap["character"] = "TSCharacter"
hlmap["number"] = "TSNumber"
hlmap["boolean"] = "TSBoolean"
hlmap["float"] = "TSFloat"
-- Functions
hlmap["function"] = "Function"
hlmap["function.builtin"] = "Special"
hlmap["function.macro"] = "Macro"
hlmap["parameter"] = "Identifier"
hlmap["method"] = "Function"
hlmap["field"] = "Identifier"
hlmap["property"] = "Identifier"
hlmap["constructor"] = "Special"
hlmap["function"] = "TSFunction"
hlmap["function.builtin"] = "TSFuncBuiltin"
hlmap["function.macro"] = "TSFuncMacro"
hlmap["parameter"] = "TSIdentifier"
hlmap["method"] = "TSMethod"
hlmap["field"] = "TSField"
hlmap["property"] = "TSProperty"
hlmap["constructor"] = "TSConstructor"
-- Keywords
hlmap["conditional"] = "Conditional"
hlmap["repeat"] = "Repeat"
hlmap["label"] = "Label"
hlmap["operator"] = "Operator"
hlmap["keyword"] = "Keyword"
hlmap["exception"] = "Exception"
hlmap["conditional"] = "TSConditional"
hlmap["repeat"] = "TSRepeat"
hlmap["label"] = "TSLabel"
hlmap["operator"] = "TSOperator"
hlmap["keyword"] = "TSKeyword"
hlmap["exception"] = "TSException"
hlmap["type"] = "Type"
hlmap["type.builtin"] = "Type"
hlmap["structure"] = "Structure"
hlmap["include"] = "Include"
hlmap["type"] = "TSType"
hlmap["type.builtin"] = "TSTypeBuiltin"
hlmap["structure"] = "TSStructure"
hlmap["include"] = "TSInclude"
function M.attach(bufnr, lang)
local bufnr = bufnr or api.nvim_get_current_buf()

View File

@@ -1,4 +1,4 @@
" Last Change: 2020 avril 25
" Last Change: 2020 juin 21
if exists('g:loaded_nvim_treesitter')
finish
@@ -18,3 +18,42 @@ ts_available_modules = function()
end
require'nvim-treesitter'.setup()
EOF
highlight link TSError Error
highlight link TSPunctDelimiter Delimiter
highlight link TSPunctBracket Delimiter
highlight link TSPunctSpecial Delimiter
highlight link TSConstant Constant
highlight link TSConstBuiltin Special
highlight link TSConstMacro Define
highlight link TSString String
highlight link TSStringRegex String
highlight link TSStringEscape SpecialChar
highlight link TSCharacter Character
highlight link TSNumber Number
highlight link TSBoolean Boolean
highlight link TSFloat TSFloat
highlight link TSFunction Function
highlight link TSFuncBuiltin Special
highlight link TSFuncMacro Macro
highlight link TSParameter Identifier
highlight link TSMethod Function
highlight link TSField Identifier
highlight link TSProperty Identifier
highlight link TSConstructor Special
highlight link TSConditional Conditional
highlight link TSRepeat Repeat
highlight link TSLabel Label
highlight link TSOperator Operator
highlight link TSKeyword Keyword
highlight link TSException Exception
highlight link TSType Type
highlight link TSTypeBuiltin Type
highlight link TSStructure Structure
highlight link TSInclude Include