mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-14 09:20:04 -04:00
highlight: use custom highlight groups
This commit is contained in:
parent
2d224ac3bf
commit
282e18edd1
4 changed files with 235 additions and 33 deletions
|
|
@ -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.
|
edits. If you encounter such breakage, hiting `zx` should fix folding.
|
||||||
In any case, feel free to open an issue with the reproducing steps.
|
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:
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||||
|
|
|
||||||
32
doc/tags
32
doc/tags
|
|
@ -5,9 +5,41 @@
|
||||||
:TSInstall nvim-treesitter.txt /*:TSInstall*
|
:TSInstall nvim-treesitter.txt /*:TSInstall*
|
||||||
:TSInstallInfo nvim-treesitter.txt /*:TSInstallInfo*
|
:TSInstallInfo nvim-treesitter.txt /*:TSInstallInfo*
|
||||||
:TSModuleInfo nvim-treesitter.txt /*:TSModuleInfo*
|
: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 nvim-treesitter.txt /*nvim-treesitter*
|
||||||
nvim-treesitter-commands nvim-treesitter.txt /*nvim-treesitter-commands*
|
nvim-treesitter-commands nvim-treesitter.txt /*nvim-treesitter-commands*
|
||||||
nvim-treesitter-functions nvim-treesitter.txt /*nvim-treesitter-functions*
|
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-intro nvim-treesitter.txt /*nvim-treesitter-intro*
|
||||||
nvim-treesitter-quickstart nvim-treesitter.txt /*nvim-treesitter-quickstart*
|
nvim-treesitter-quickstart nvim-treesitter.txt /*nvim-treesitter-quickstart*
|
||||||
nvim-treesitter-utils nvim-treesitter.txt /*nvim-treesitter-utils*
|
nvim-treesitter-utils nvim-treesitter.txt /*nvim-treesitter-utils*
|
||||||
|
|
|
||||||
|
|
@ -11,45 +11,45 @@ local M = {
|
||||||
local hlmap = vim.treesitter.TSHighlighter.hl_map
|
local hlmap = vim.treesitter.TSHighlighter.hl_map
|
||||||
|
|
||||||
-- Misc
|
-- Misc
|
||||||
hlmap.error = "Error"
|
hlmap.error = "TSError"
|
||||||
hlmap["punctuation.delimiter"] = "Delimiter"
|
hlmap["punctuation.delimiter"] = "TSPunctDelimiter"
|
||||||
hlmap["punctuation.bracket"] = "Delimiter"
|
hlmap["punctuation.bracket"] = "TSPunctBracket"
|
||||||
hlmap["punctuation.special"] = "Delimiter"
|
hlmap["punctuation.special"] = "TSPunctSpecial"
|
||||||
|
|
||||||
-- Constants
|
-- Constants
|
||||||
hlmap["constant"] = "Constant"
|
hlmap["constant"] = "TSConstant"
|
||||||
hlmap["constant.builtin"] = "Special"
|
hlmap["constant.builtin"] = "TSConstBuiltin"
|
||||||
hlmap["constant.macro"] = "Define"
|
hlmap["constant.macro"] = "TSConstMacro"
|
||||||
hlmap["string"] = "String"
|
hlmap["string"] = "TSString"
|
||||||
hlmap["string.regex"] = "String"
|
hlmap["string.regex"] = "TSStringRegex"
|
||||||
hlmap["string.escape"] = "SpecialChar"
|
hlmap["string.escape"] = "TSStringEscape"
|
||||||
hlmap["character"] = "Character"
|
hlmap["character"] = "TSCharacter"
|
||||||
hlmap["number"] = "Number"
|
hlmap["number"] = "TSNumber"
|
||||||
hlmap["boolean"] = "Boolean"
|
hlmap["boolean"] = "TSBoolean"
|
||||||
hlmap["float"] = "Float"
|
hlmap["float"] = "TSFloat"
|
||||||
|
|
||||||
-- Functions
|
-- Functions
|
||||||
hlmap["function"] = "Function"
|
hlmap["function"] = "TSFunction"
|
||||||
hlmap["function.builtin"] = "Special"
|
hlmap["function.builtin"] = "TSFuncBuiltin"
|
||||||
hlmap["function.macro"] = "Macro"
|
hlmap["function.macro"] = "TSFuncMacro"
|
||||||
hlmap["parameter"] = "Identifier"
|
hlmap["parameter"] = "TSIdentifier"
|
||||||
hlmap["method"] = "Function"
|
hlmap["method"] = "TSMethod"
|
||||||
hlmap["field"] = "Identifier"
|
hlmap["field"] = "TSField"
|
||||||
hlmap["property"] = "Identifier"
|
hlmap["property"] = "TSProperty"
|
||||||
hlmap["constructor"] = "Special"
|
hlmap["constructor"] = "TSConstructor"
|
||||||
|
|
||||||
-- Keywords
|
-- Keywords
|
||||||
hlmap["conditional"] = "Conditional"
|
hlmap["conditional"] = "TSConditional"
|
||||||
hlmap["repeat"] = "Repeat"
|
hlmap["repeat"] = "TSRepeat"
|
||||||
hlmap["label"] = "Label"
|
hlmap["label"] = "TSLabel"
|
||||||
hlmap["operator"] = "Operator"
|
hlmap["operator"] = "TSOperator"
|
||||||
hlmap["keyword"] = "Keyword"
|
hlmap["keyword"] = "TSKeyword"
|
||||||
hlmap["exception"] = "Exception"
|
hlmap["exception"] = "TSException"
|
||||||
|
|
||||||
hlmap["type"] = "Type"
|
hlmap["type"] = "TSType"
|
||||||
hlmap["type.builtin"] = "Type"
|
hlmap["type.builtin"] = "TSTypeBuiltin"
|
||||||
hlmap["structure"] = "Structure"
|
hlmap["structure"] = "TSStructure"
|
||||||
hlmap["include"] = "Include"
|
hlmap["include"] = "TSInclude"
|
||||||
|
|
||||||
function M.attach(bufnr, lang)
|
function M.attach(bufnr, lang)
|
||||||
local bufnr = bufnr or api.nvim_get_current_buf()
|
local bufnr = bufnr or api.nvim_get_current_buf()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
" Last Change: 2020 avril 25
|
" Last Change: 2020 juin 21
|
||||||
|
|
||||||
if exists('g:loaded_nvim_treesitter')
|
if exists('g:loaded_nvim_treesitter')
|
||||||
finish
|
finish
|
||||||
|
|
@ -18,3 +18,42 @@ ts_available_modules = function()
|
||||||
end
|
end
|
||||||
require'nvim-treesitter'.setup()
|
require'nvim-treesitter'.setup()
|
||||||
EOF
|
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
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue