├── go.mod ├── README.md ├── go.sum ├── Makefile ├── .github └── workflows │ └── release.yaml ├── plugin └── treesitter.vim ├── autoload └── treesittervim.vim └── cmd └── treesitter-server ├── generate ├── main.go └── parser.go ├── main.go └── highlight.go /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/mattn/vim-treesitter 2 | 3 | go 1.18 4 | 5 | require github.com/smacker/go-tree-sitter v0.0.0-20220404154745-d5f0a70b82af 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vim-treesitter 2 | 3 | THIS IS VERY EXPERIMENTAL PLUGIN 4 | 5 | treesitter for Vim8 6 | 7 | ## Installation 8 | 9 | ``` 10 | $ cd server 11 | $ go build 12 | ``` 13 | 14 | ## License 15 | 16 | MIT 17 | 18 | This is based on https://github.com/JasonWoof/vim-treesitter 19 | 20 | ## Author 21 | 22 | Yasuhiro Matsumoto (a.k.a. mattn) 23 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= 2 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 3 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 4 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 5 | github.com/smacker/go-tree-sitter v0.0.0-20220404154745-d5f0a70b82af h1:jyV2G6CY1KlTemIXMV5ZP4g4kNuCk0llchI0m7mWLFY= 6 | github.com/smacker/go-tree-sitter v0.0.0-20220404154745-d5f0a70b82af/go.mod h1:EiUuVMUfLQj8Sul+S8aKWJwQy7FRYnJCO2EWzf8F5hk= 7 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 8 | github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= 9 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 10 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 11 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 12 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 13 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | BIN := treesitter-server 2 | VERSION := $$(make -s show-version) 3 | CURRENT_REVISION := $(shell git rev-parse --short HEAD) 4 | BUILD_LDFLAGS := "-s -w -X main.revision=$(CURRENT_REVISION)" 5 | GOBIN ?= $(shell go env GOPATH)/bin 6 | export GO111MODULE=on 7 | 8 | .PHONY: all 9 | all: clean build 10 | 11 | .PHONY: build 12 | build: 13 | go build -ldflags=$(BUILD_LDFLAGS) -o ./cmd/$(BIN) . 14 | 15 | .PHONY: install 16 | install: 17 | go install -ldflags=$(BUILD_LDFLAGS) . 18 | 19 | .PHONY: show-version 20 | show-version: $(GOBIN)/gobump 21 | @gobump show -r cmd/treesitter-server 22 | 23 | $(GOBIN)/gobump: 24 | @go install github.com/x-motemen/gobump/cmd/gobump@latest 25 | 26 | $(GOBIN)/goxz: 27 | @go install github.com/Songmu/goxz/cmd/goxz@latest 28 | 29 | $(GOBIN)/ghr: 30 | go install github.com/tcnksm/ghr@latest 31 | 32 | .PHONY: cross 33 | cross: $(GOBIN)/goxz 34 | @goxz -n $(BIN) -pv=v$(VERSION) -build-ldflags=$(BUILD_LDFLAGS) ./cmd/$(BIN) 35 | 36 | .PHONY: test 37 | 38 | test: build 39 | go test -v ./... 40 | 41 | .PHONY: clean 42 | clean: 43 | rm -rf $(BIN) goxz 44 | go clean 45 | 46 | .PHONY: bump 47 | bump: $(GOBIN)/gobump 48 | ifneq ($(shell git status --porcelain),) 49 | $(error git workspace is dirty) 50 | endif 51 | ifneq ($(shell git rev-parse --abbrev-ref HEAD),master) 52 | $(error current branch is not master) 53 | endif 54 | @gobump up -w . 55 | git commit -am "bump up version to $(VERSION)" 56 | git tag "v$(VERSION)" 57 | git push origin master 58 | git push origin "refs/tags/v$(VERSION)" 59 | 60 | .PHONY: upload 61 | upload: $(GOBIN)/ghr 62 | ghr "v$(VERSION)" goxz 63 | 64 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*' 7 | 8 | jobs: 9 | release-linux: 10 | name: Release Linux 11 | runs-on: ubuntu-latest 12 | defaults: 13 | run: 14 | shell: bash 15 | steps: 16 | - uses: actions/setup-go@v2 17 | with: 18 | go-version: '1.18' 19 | 20 | - name: Add $GOPATH/bin to $PATH 21 | run: | 22 | echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH" 23 | 24 | - uses: actions/checkout@v2 25 | 26 | - name: Build 27 | env: 28 | GOARCH: 'amd64' 29 | CGO_ENABLED: 1 30 | run: | 31 | mkdir -p dist 32 | go build -o dist/treesitter-server-linux-amd64 ./cmd/treesitter-server 33 | shell: bash 34 | 35 | - name: Upload 36 | uses: actions/upload-artifact@v3 37 | with: 38 | name: dist-linux 39 | path: dist/treesitter-server-* 40 | 41 | release-macos: 42 | name: Release macOS 43 | runs-on: macos-latest 44 | defaults: 45 | run: 46 | shell: bash 47 | steps: 48 | - run: brew update 49 | 50 | - uses: actions/setup-go@v2 51 | with: 52 | go-version: '1.18' 53 | 54 | - name: Add $GOPATH/bin to $PATH 55 | run: | 56 | echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH" 57 | 58 | - uses: actions/checkout@v2 59 | 60 | - name: Build 61 | run: | 62 | mkdir -p dist 63 | go build -o dist/treesitter-server-macos-amd64 ./cmd/treesitter-server 64 | env: 65 | GOARCH: 'amd64' 66 | CGO_ENABLED: 1 67 | shell: bash 68 | 69 | - name: Upload 70 | uses: actions/upload-artifact@v3 71 | with: 72 | name: dist-macos 73 | path: dist/treesitter-server-* 74 | 75 | release-windows: 76 | name: Release Windows 77 | runs-on: windows-latest 78 | defaults: 79 | run: 80 | shell: bash 81 | steps: 82 | - uses: msys2/setup-msys2@v2 83 | with: 84 | update: true 85 | msystem: MINGW64 86 | path-type: inherit 87 | 88 | - uses: actions/setup-go@v2 89 | with: 90 | go-version: '1.18' 91 | 92 | - name: Add $GOPATH/bin to $PATH 93 | run: | 94 | echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH" 95 | shell: msys2 {0} 96 | 97 | - uses: actions/checkout@v2 98 | 99 | - name: Build 100 | run: | 101 | mkdir -p dist 102 | go build -o dist/treesitter-server-windows-amd64.exe ./cmd/treesitter-server 103 | env: 104 | GOARCH: 'amd64' 105 | CGO_ENABLED: 1 106 | shell: bash 107 | 108 | - name: Upload 109 | uses: actions/upload-artifact@v3 110 | with: 111 | name: dist-windows 112 | path: dist/treesitter-server-* 113 | 114 | upload: 115 | name: Upload Releases 116 | runs-on: ubuntu-latest 117 | needs: [release-linux, release-macos, release-windows] 118 | defaults: 119 | run: 120 | shell: bash 121 | 122 | steps: 123 | - name: Download Artifact (linux) 124 | uses: actions/download-artifact@v2 125 | with: 126 | name: dist-linux 127 | 128 | - name: Download Artifact (macos) 129 | uses: actions/download-artifact@v2 130 | with: 131 | name: dist-macos 132 | 133 | - name: Download Artifact (windows) 134 | uses: actions/download-artifact@v2 135 | with: 136 | name: dist-windows 137 | 138 | - name: Create Release 139 | env: 140 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 141 | uses: softprops/action-gh-release@9993ae85344fa542b3edb2533f97011277698cf6 142 | with: 143 | tag_name: ${{ github.ref }} 144 | name: Release ${{ github.ref_name }} 145 | draft: false 146 | prerelease: false 147 | files: | 148 | ./treesitter-server-* 149 | -------------------------------------------------------------------------------- /plugin/treesitter.vim: -------------------------------------------------------------------------------- 1 | " Copied from https://github.com/nvim-treesitter/nvim-treesitter/blob/2b785889a4d0613465f72eccabd42468b345658d/plugin/nvim-treesitter.vim 2 | 3 | if !has('patch-8.1.1') 4 | finish 5 | endif 6 | 7 | augroup treesitter 8 | au! 9 | autocmd TextChanged * call treesittervim#fire(1) 10 | autocmd TextChangedI * call treesittervim#fire(1) 11 | autocmd CursorMoved * call treesittervim#fire(0) 12 | autocmd SafeState * call treesittervim#fire(0) 13 | if exists('##TextChangedP') 14 | autocmd TextChangedP * call treesittervim#fire(1) 15 | endif 16 | augroup END 17 | 18 | if exists('g:loaded_vim_treesitter') 19 | finish 20 | endif 21 | 22 | let g:loaded_vim_treesitter = 1 23 | 24 | function s:has_attr(attr, mode) 25 | let norm_color = synIDattr(hlID('Normal'), a:attr, a:mode) 26 | return strlen(norm_color) > 0 27 | endfunction 28 | 29 | " if the ctermfg or guifg is not known by nvim then using the 30 | " fg or foreground highlighting value will cause an E419 error 31 | " so we check to see if either highlight has been set if not default to NONE 32 | let cterm_normal = s:has_attr('fg', 'cterm') ? 'fg' : 'NONE' 33 | let gui_normal = s:has_attr('fg', 'gui') ? 'foreground' : 'NONE' 34 | 35 | execute 'highlight default TSNone term=NONE cterm=NONE gui=NONE guifg='.gui_normal.' ctermfg='.cterm_normal 36 | 37 | highlight default link TSPunctDelimiter Delimiter 38 | highlight default link TSPunctBracket Delimiter 39 | highlight default link TSPunctSpecial Delimiter 40 | 41 | highlight default link TSConstant Constant 42 | highlight default link TSConstBuiltin Special 43 | highlight default link TSConstMacro Define 44 | highlight default link TSString String 45 | highlight default link TSStringRegex String 46 | highlight default link TSStringEscape SpecialChar 47 | highlight default link TSStringSpecial SpecialChar 48 | highlight default link TSCharacter Character 49 | highlight default link TSNumber Number 50 | highlight default link TSBoolean Boolean 51 | highlight default link TSFloat Float 52 | 53 | highlight default link TSFunction Function 54 | highlight default link TSFuncBuiltin Special 55 | highlight default link TSFuncMacro Macro 56 | highlight default link TSParameter Identifier 57 | highlight default link TSParameterReference TSParameter 58 | highlight default link TSMethod Function 59 | highlight default link TSField Identifier 60 | highlight default link TSProperty Identifier 61 | highlight default link TSConstructor Special 62 | highlight default link TSAnnotation PreProc 63 | highlight default link TSAttribute PreProc 64 | highlight default link TSNamespace Include 65 | highlight default link TSSymbol Identifier 66 | 67 | highlight default link TSConditional Conditional 68 | highlight default link TSRepeat Repeat 69 | highlight default link TSLabel Label 70 | highlight default link TSOperator Operator 71 | highlight default link TSKeyword Keyword 72 | highlight default link TSKeywordFunction Keyword 73 | highlight default link TSKeywordOperator TSOperator 74 | highlight default link TSKeywordReturn TSKeyword 75 | highlight default link TSException Exception 76 | 77 | highlight default link TSType Type 78 | highlight default link TSTypeBuiltin Type 79 | highlight default link TSInclude Include 80 | 81 | highlight default link TSVariableBuiltin Special 82 | 83 | highlight default link TSText TSNone 84 | highlight default TSStrong term=bold cterm=bold gui=bold 85 | highlight default TSEmphasis term=italic cterm=italic gui=italic 86 | highlight default TSUnderline term=underline cterm=underline gui=underline 87 | highlight default TSStrike term=strikethrough cterm=strikethrough gui=strikethrough 88 | highlight default link TSMath Special 89 | highlight default link TSTextReference Constant 90 | highlight default link TSEnvironment Macro 91 | highlight default link TSEnvironmentName Type 92 | highlight default link TSTitle Title 93 | highlight default link TSLiteral String 94 | highlight default link TSURI Underlined 95 | 96 | highlight default link TSComment Comment 97 | highlight default link TSNote SpecialComment 98 | highlight default link TSWarning Todo 99 | highlight default link TSDanger WarningMsg 100 | 101 | highlight default link TSTag Label 102 | highlight default link TSTagDelimiter Delimiter 103 | highlight default link TSTagAttribute TSProperty 104 | -------------------------------------------------------------------------------- /autoload/treesittervim.vim: -------------------------------------------------------------------------------- 1 | let s:dir = expand(':h:h') 2 | let s:server = fnamemodify(s:dir . '/cmd/treesitter-server/treesitter-server', ':p') 3 | if has('win32') 4 | let s:server = substitute(s:server, '/', '\\', 'g') . '.exe' 5 | endif 6 | 7 | let s:disabled = 0 8 | function! s:start_server() abort 9 | if s:disabled 10 | augroup treesitter 11 | au! 12 | augroup END 13 | return 0 14 | endif 15 | 16 | if !executable(s:server) 17 | let l:dir = s:dir . '/cmd/treesitter-server' 18 | if has('win32') 19 | let l:dir = substitute(l:dir, '/', '\\', 'g') 20 | endif 21 | let s:disabled = 1 22 | echohl WarningMsg | echomsg 'Building treesitter-server...' | echohl None 23 | sleep 1 24 | let l:cwd = getcwd() 25 | try 26 | call chdir(l:dir) 27 | !go build 28 | catch 29 | finally 30 | call chdir(l:cwd) 31 | endtry 32 | if !executable(s:server) 33 | return 0 34 | endif 35 | let s:disabled = 0 36 | endif 37 | let s:job = job_start(s:server, {'noblock': 1}) 38 | let s:ch = job_getchannel(s:job) 39 | return 1 40 | endfunction 41 | 42 | function! s:prop_type_add(name, attr) abort 43 | if empty(prop_type_get(a:name)) 44 | call prop_type_add(a:name, a:attr) 45 | endif 46 | endfunction 47 | 48 | let s:syntax = ['TSAnnotation', 'TSAttribute', 'TSBoolean', 'TSCharacter', 'TSComment', 'TSConditional', 'TSConstBuiltin', 'TSConstMacro', 'TSConstant', 'TSConstructor', 'TSDanger', 'TSEmphasis', 'TSEnvironment', 'TSEnvironmentName', 'TSException', 'TSField', 'TSFloat', 'TSFuncBuiltin', 'TSFuncMacro', 'TSFunction', 'TSInclude', 'TSKeyword', 'TSKeywordFunction', 'TSKeywordOperator', 'TSKeywordReturn', 'TSLabel', 'TSLiteral', 'TSMath', 'TSMethod', 'TSNamespace', 'TSNone', 'TSNote', 'TSNumber', 'TSOperator', 'TSParameter', 'TSParameterReference', 'TSProperty', 'TSPunctBracket', 'TSPunctDelimiter', 'TSPunctSpecial', 'TSRepeat', 'TSStrike', 'TSString', 'TSStringEscape', 'TSStringRegex', 'TSStringSpecial', 'TSStrong', 'TSSymbol', 'TSTag', 'TSTagAttribute', 'TSTagDelimiter', 'TSText', 'TSTextReference', 'TSTitle', 'TSType', 'TSTypeBuiltin', 'TSURI', 'TSUnderline', 'TSVariableBuiltin', 'TSWarning'] 49 | for s:s in s:syntax 50 | call s:prop_type_add(s:s, {'highlight': s:s}) 51 | endfor 52 | unlet s:s 53 | 54 | function! treesittervim#handle(ch, msg) abort 55 | try 56 | let l:v = json_decode(a:msg) 57 | if l:v[0] == 'version' 58 | call s:handle_version(l:v[1]) 59 | elseif l:v[0] == 'syntax' 60 | call s:handle_syntax(l:v[1]) 61 | elseif l:v[0] == 'textobj' 62 | call s:handle_textobj(l:v[1]) 63 | endif 64 | catch 65 | endtry 66 | endfunction 67 | 68 | function! treesittervim#redraw(range) abort 69 | call s:clear() 70 | for l:line in b:treesitter_proplines[a:range[0] : a:range[1]] 71 | for l:prop in l:line 72 | try 73 | call prop_add(l:prop.row, l:prop.col, l:prop.attr) 74 | catch 75 | endtry 76 | endfor 77 | endfor 78 | endfunction 79 | 80 | function! s:handle_syntax(value) abort 81 | if &l:syntax != '' 82 | let b:treesitter_syntax = &l:syntax 83 | let &l:syntax = '' 84 | endif 85 | let b:treesitter_proplines = a:value 86 | let b:treesitter_range = [-1, -1] 87 | call treesittervim#fire(0) 88 | endfunc 89 | 90 | function! s:clear() abort 91 | for l:v in s:syntax 92 | call prop_remove({'type': l:v, 'all': v:true}) 93 | endfor 94 | endfunction 95 | 96 | function! treesittervim#syntax() abort 97 | try 98 | let l:lines = join(getline(1, '$'), "\n") 99 | call ch_sendraw(s:ch, json_encode(['syntax', &filetype, l:lines]) . "\n", {'callback': 'treesittervim#handle'}) 100 | catch 101 | echomsg v:exception 102 | endtry 103 | endfunction 104 | 105 | function! s:handle_version(value) abort 106 | try 107 | echomsg a:value 108 | catch 109 | endtry 110 | endfunc 111 | 112 | function! treesittervim#version() abort 113 | try 114 | let l:lines = join(getline(1, '$'), "\n") 115 | call ch_sendraw(s:ch, json_encode(['version']) . "\n", {'callback': 'treesittervim#handle'}) 116 | catch 117 | echomsg v:exception 118 | endtry 119 | endfunction 120 | 121 | function! s:handle_textobj(value) abort 122 | try 123 | call cursor(a:value['start'].row+1, a:value['start'].column+1) 124 | normal v 125 | call cursor(a:value['end'].row+1, a:value['end'].column) 126 | catch 127 | endtry 128 | endfunc 129 | 130 | function! treesittervim#textobj() abort 131 | try 132 | let l:lines = join(getline(1, '$'), "\n") 133 | call ch_sendraw(s:ch, json_encode(['textobj', &filetype, l:lines, '' . (col('.')-1), '' . (line('.')-1)]) . "\n", {'callback': 'treesittervim#handle'}) 134 | catch 135 | echomsg v:exception 136 | endtry 137 | endfunction 138 | 139 | function! treesittervim#fire(update) abort 140 | if !exists('s:ch') 141 | if !s:start_server() 142 | return 143 | endif 144 | endif 145 | 146 | if a:update || empty(get(b:, 'treesitter_proplines', [])) 147 | call treesittervim#syntax() 148 | else 149 | let l:curpos = getcurpos() 150 | let l:range = [line('w0')-1, line('w$')-1] 151 | let cache_range = get(b:, 'treesitter_range', [-1, -1]) 152 | if l:range ==# l:cache_range 153 | return 154 | endif 155 | let b:treesitter_range = l:range 156 | call treesittervim#redraw(range) 157 | endif 158 | endfunction 159 | -------------------------------------------------------------------------------- /cmd/treesitter-server/generate/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "flag" 6 | "fmt" 7 | "io" 8 | "log" 9 | "net/http" 10 | "os" 11 | "strings" 12 | ) 13 | 14 | func camel(s string) string { 15 | isToUpper := false 16 | r := "" 17 | for k, v := range s { 18 | if k == 0 { 19 | r = strings.ToUpper(string(s[0])) 20 | } else { 21 | if isToUpper { 22 | r += strings.ToUpper(string(v)) 23 | isToUpper = false 24 | } else { 25 | if v == '_' || v == '.' { 26 | isToUpper = true 27 | } else { 28 | r += string(v) 29 | } 30 | } 31 | } 32 | } 33 | r = strings.Replace(r, "Punctuation", "Punct", -1) 34 | if r != "Constant" { 35 | r = strings.Replace(r, "Constant", "Const", -1) 36 | } 37 | return r 38 | } 39 | 40 | var languages = []string{ 41 | "bash", 42 | "c", 43 | "cpp", 44 | "csharp", 45 | "css", 46 | "dockerfile", 47 | "ecma", 48 | "elm", 49 | "go", 50 | "hcl", 51 | "html", 52 | "html_tags", 53 | "java", 54 | "javascript", 55 | "json", 56 | "jsx", 57 | "lua", 58 | "ocaml", 59 | "php", 60 | "python", 61 | "ruby", 62 | "rust", 63 | //"scala", 64 | "svelte", 65 | "toml", 66 | "tsx", 67 | "typescript", 68 | "yaml", 69 | } 70 | 71 | type idmap struct { 72 | Name string 73 | Color string 74 | } 75 | 76 | func has(m []idmap, name string) bool { 77 | for _, s := range m { 78 | if s.Name == name { 79 | return true 80 | } 81 | } 82 | return false 83 | } 84 | 85 | func generate(l string) ([]idmap, []idmap, []string) { 86 | log.Printf("Generating highlights for %v", l) 87 | resp, err := http.Get("https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/820b4a9c211a49c878ce3f19ed5c349509e7988f/queries/" + l + "/highlights.scm") 88 | if err != nil { 89 | log.Fatal(err) 90 | } 91 | defer resp.Body.Close() 92 | 93 | in := bufio.NewReader(resp.Body) 94 | 95 | var inherits []string 96 | bb, err := in.Peek(1) 97 | if err != nil { 98 | log.Fatal(err) 99 | } 100 | if bb[0] == ';' { 101 | b, _, err := in.ReadLine() 102 | if err != nil { 103 | log.Fatal(err) 104 | } 105 | line := string(b) 106 | if strings.HasPrefix(line, "; inherits:") { 107 | inherits = strings.Split(line[11:], ",") 108 | for i, v := range inherits { 109 | inherits[i] = strings.TrimSpace(v) 110 | } 111 | log.Println(inherits) 112 | } 113 | } 114 | p := NewParser(in) 115 | 116 | symbols := []idmap{} 117 | keywords := []idmap{} 118 | 119 | var prev *Node 120 | for { 121 | n, err := p.ParseAny(false) 122 | if err != nil { 123 | if err == io.EOF { 124 | break 125 | } 126 | log.Fatal(err) 127 | } 128 | if n.t == NodeIdent && n.v.(string)[0] == '@' { 129 | if prev.t == NodeCell { 130 | if prev.car.t == NodeIdent { 131 | name := prev.car.v.(string) 132 | if !has(symbols, name) { 133 | symbols = append(symbols, idmap{ 134 | Name: name, 135 | Color: "TS" + camel(n.v.(string)[1:]), 136 | }) 137 | } 138 | } else if prev.car.t == NodeNil { 139 | name := "nil" 140 | if !has(symbols, name) { 141 | symbols = append(symbols, idmap{ 142 | Name: name, 143 | Color: "TS" + camel(n.v.(string)[1:]), 144 | }) 145 | } 146 | } 147 | } else if prev.t == NodeString { 148 | name := prev.v.(string) 149 | if !has(keywords, name) { 150 | keywords = append(keywords, idmap{ 151 | Name: name, 152 | Color: "TS" + camel(n.v.(string)[1:]), 153 | }) 154 | } 155 | } else if prev.t == NodeArray { 156 | curr := prev 157 | for curr != nil { 158 | if curr.car == nil { 159 | break 160 | } 161 | if curr.car.t == NodeCell && curr.car.car != nil { 162 | var name string 163 | if curr.car.car.v != nil { 164 | name = curr.car.car.v.(string) 165 | } else { 166 | name = "nil" 167 | } 168 | if !has(symbols, name) { 169 | symbols = append(symbols, idmap{ 170 | Name: name, 171 | Color: "TS" + camel(n.v.(string)[1:]), 172 | }) 173 | } 174 | } else if curr.car.t == NodeString { 175 | name := curr.car.v.(string) 176 | if !has(keywords, name) { 177 | keywords = append(keywords, idmap{ 178 | Name: name, 179 | Color: "TS" + camel(n.v.(string)[1:]), 180 | }) 181 | } 182 | } 183 | if curr.cdr == nil || curr.cdr.t == NodeNil { 184 | break 185 | } 186 | curr = curr.cdr 187 | } 188 | } else { 189 | //fmt.Println(n) 190 | } 191 | } 192 | prev = n 193 | } 194 | 195 | return symbols, keywords, inherits 196 | } 197 | 198 | func main() { 199 | var fname string 200 | flag.StringVar(&fname, "o", "", "output file") 201 | flag.Parse() 202 | 203 | var out io.Writer = os.Stdout 204 | if fname != "" { 205 | f, err := os.Create(fname) 206 | if err != nil { 207 | log.Fatal(err) 208 | } 209 | defer f.Close() 210 | out = f 211 | } 212 | symbols := map[string][]idmap{} 213 | keywords := map[string][]idmap{} 214 | inherits := map[string][]string{} 215 | for _, l := range languages { 216 | s, k, i := generate(l) 217 | symbols[l] = s 218 | keywords[l] = k 219 | inherits[l] = i 220 | } 221 | 222 | for _, l := range languages { 223 | if len(inherits[l]) > 0 { 224 | log.Println("Merging", inherits[l]) 225 | mergedSymbols := []idmap{} 226 | mergedKeywords := []idmap{} 227 | for _, v := range inherits[l] { 228 | for _, sv := range symbols[v] { 229 | if !has(mergedSymbols, sv.Name) { 230 | mergedSymbols = append(mergedSymbols, sv) 231 | } 232 | } 233 | for _, kw := range keywords[v] { 234 | if !has(mergedKeywords, kw.Name) { 235 | mergedKeywords = append(mergedKeywords, kw) 236 | } 237 | } 238 | } 239 | for _, sv := range symbols[l] { 240 | if !has(mergedSymbols, sv.Name) { 241 | mergedSymbols = append(mergedSymbols, sv) 242 | } 243 | } 244 | for _, kw := range keywords[l] { 245 | if !has(mergedKeywords, kw.Name) { 246 | mergedKeywords = append(mergedKeywords, kw) 247 | } 248 | } 249 | symbols[l] = mergedSymbols 250 | keywords[l] = mergedKeywords 251 | } 252 | } 253 | 254 | fmt.Fprintln(out, "package main") 255 | fmt.Fprintln(out, "") 256 | 257 | fmt.Fprintln(out, `var symbols = map[string]map[string]string {`) 258 | for _, l := range languages { 259 | fmt.Fprintf(out, "\t%q: {\n", l) 260 | for _, s := range symbols[l] { 261 | fmt.Fprintf(out, "\t\t%q: %q,\n", s.Name, s.Color) 262 | } 263 | fmt.Fprintln(out, "\t},") 264 | } 265 | fmt.Fprintln(out, "}") 266 | 267 | fmt.Fprintln(out, `var keywords = map[string]map[string]string {`) 268 | for _, l := range languages { 269 | fmt.Fprintf(out, "\t%q: {\n", l) 270 | for _, s := range keywords[l] { 271 | fmt.Fprintf(out, "\t\t%q: %q,\n", s.Name, s.Color) 272 | } 273 | fmt.Fprintln(out, "\t},") 274 | } 275 | fmt.Fprintln(out, "}") 276 | } 277 | -------------------------------------------------------------------------------- /cmd/treesitter-server/generate/parser.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "bytes" 6 | "errors" 7 | "fmt" 8 | "io" 9 | "strconv" 10 | "strings" 11 | "unicode" 12 | ) 13 | 14 | var ( 15 | EOF = errors.New("unexpected end of file") 16 | ) 17 | 18 | type NodeType int 19 | 20 | const ( 21 | NodeNil NodeType = iota 22 | NodeT 23 | NodeInt 24 | NodeDouble 25 | NodeString 26 | NodeQuote 27 | NodeBquote 28 | NodeIdent 29 | NodeCell 30 | NodeArray 31 | NodeError 32 | ) 33 | 34 | type Node struct { 35 | t NodeType 36 | v interface{} 37 | car *Node 38 | cdr *Node 39 | } 40 | 41 | func (n *Node) String() string { 42 | if n == nil { 43 | return "nil" 44 | } 45 | var buf bytes.Buffer 46 | switch n.t { 47 | case NodeArray: 48 | curr := n 49 | fmt.Fprint(&buf, "[") 50 | for curr != nil { 51 | if curr.car != nil { 52 | fmt.Fprint(&buf, curr.car) 53 | } else { 54 | fmt.Fprint(&buf, "nil") 55 | } 56 | if curr.cdr == nil || curr.cdr.t == NodeNil { 57 | break 58 | } 59 | fmt.Fprint(&buf, " ") 60 | curr = curr.cdr 61 | } 62 | fmt.Fprint(&buf, "]") 63 | case NodeCell: 64 | curr := n 65 | fmt.Fprint(&buf, "(") 66 | for curr != nil { 67 | if curr.car != nil { 68 | fmt.Fprint(&buf, curr.car) 69 | } else { 70 | fmt.Fprint(&buf, "nil") 71 | } 72 | if curr.cdr == nil || curr.cdr.t == NodeNil { 73 | break 74 | } 75 | if curr.cdr.t != NodeCell { 76 | fmt.Fprint(&buf, " . ") 77 | fmt.Fprint(&buf, curr.cdr) 78 | break 79 | } 80 | fmt.Fprint(&buf, " ") 81 | curr = curr.cdr 82 | } 83 | fmt.Fprint(&buf, ")") 84 | case NodeNil: 85 | fmt.Fprint(&buf, "nil") 86 | case NodeT: 87 | fmt.Fprint(&buf, "t") 88 | case NodeQuote: 89 | fmt.Fprintf(&buf, "'%v", n.car) 90 | case NodeBquote: 91 | fmt.Fprintf(&buf, "`%v", n.car) 92 | case NodeString: 93 | fmt.Fprintf(&buf, "%q", n.v) 94 | default: 95 | fmt.Fprint(&buf, n.v) 96 | } 97 | return buf.String() 98 | } 99 | 100 | func NewParser(r io.Reader) *Parser { 101 | return &Parser{ 102 | buf: bufio.NewReader(r), 103 | } 104 | } 105 | 106 | type Parser struct { 107 | buf *bufio.Reader 108 | pos int 109 | } 110 | 111 | func (p *Parser) NewError(err error) *Node { 112 | return &Node{ 113 | t: NodeError, 114 | v: err, 115 | } 116 | } 117 | 118 | func (p *Parser) SkipWhite() { 119 | for { 120 | r, err := p.readRune() 121 | if err != nil { 122 | return 123 | } 124 | if r == ';' { 125 | for { 126 | r, err = p.readRune() 127 | if err != nil { 128 | return 129 | } 130 | if r == '\n' { 131 | break 132 | } 133 | } 134 | continue 135 | } 136 | if !unicode.IsSpace(r) { 137 | p.unreadRune() 138 | return 139 | } 140 | } 141 | } 142 | 143 | func (p *Parser) ParseParen(bq bool) (*Node, error) { 144 | first := true 145 | head := &Node{ 146 | t: NodeCell, 147 | } 148 | curr := head 149 | for { 150 | p.SkipWhite() 151 | b, err := p.buf.Peek(1) 152 | if err == io.EOF || (len(b) > 0 && b[0] == ')') { 153 | break 154 | } 155 | quote := err == nil && b[0] == ',' 156 | if quote { 157 | p.buf.ReadByte() 158 | } 159 | 160 | child, err := p.ParseAny(false) 161 | if err != nil { 162 | return nil, err 163 | } 164 | if child == nil { 165 | break 166 | } 167 | if bq && !quote { 168 | child = &Node{ 169 | t: NodeQuote, 170 | car: child, 171 | } 172 | } 173 | 174 | if child.t == NodeIdent && child.v.(string) == "." && !first { 175 | p.SkipWhite() 176 | b, err := p.buf.Peek(1) 177 | if err == io.EOF || (len(b) > 0 && b[0] == ')') { 178 | break 179 | } 180 | child, err = p.ParseAny(false) 181 | if err != nil { 182 | if err == io.EOF { 183 | break 184 | } 185 | return nil, err 186 | } 187 | curr.cdr = child 188 | } else if head.car != nil { 189 | x := &Node{ 190 | t: NodeCell, 191 | car: &Node{ 192 | t: NodeNil, 193 | }, 194 | } 195 | curr.cdr = x 196 | curr = x 197 | } 198 | first = false 199 | curr.car = child 200 | } 201 | if head.car == nil && head.cdr == nil { 202 | head.t = NodeNil 203 | } 204 | 205 | return head, nil 206 | } 207 | 208 | func (p *Parser) ParseString() (*Node, error) { 209 | var buf bytes.Buffer 210 | for { 211 | r, err := p.readRune() 212 | if err != nil { 213 | if err == io.EOF { 214 | break 215 | } 216 | return nil, err 217 | } 218 | 219 | if r == '\\' { 220 | r, err = p.readRune() 221 | if err != nil { 222 | return nil, err 223 | } 224 | switch r { 225 | case '\\': 226 | r = '\\' 227 | case 'n': 228 | r = '\n' 229 | case 'r': 230 | r = '\r' 231 | case 't': 232 | r = '\t' 233 | case 'b': 234 | r = '\b' 235 | case 'f': 236 | r = '\f' 237 | case '"': 238 | buf.WriteRune(r) 239 | continue 240 | } 241 | } 242 | if r == '"' { 243 | break 244 | } 245 | buf.WriteRune(r) 246 | } 247 | return &Node{ 248 | t: NodeString, 249 | v: buf.String(), 250 | }, nil 251 | } 252 | 253 | func (p *Parser) ParseArray() (*Node, error) { 254 | head := &Node{ 255 | t: NodeArray, 256 | } 257 | curr := head 258 | for { 259 | p.SkipWhite() 260 | b, err := p.buf.Peek(1) 261 | if err == io.EOF { 262 | break 263 | } 264 | if len(b) > 0 && b[0] == ']' { 265 | p.readRune() 266 | break 267 | } 268 | child, err := p.ParseAny(false) 269 | if err != nil { 270 | return nil, err 271 | } 272 | if child == nil { 273 | break 274 | } 275 | if head.car != nil { 276 | x := &Node{ 277 | t: NodeCell, 278 | car: &Node{ 279 | t: NodeNil, 280 | }, 281 | } 282 | curr.cdr = x 283 | curr = x 284 | } 285 | curr.car = child 286 | } 287 | if head.car == nil && head.cdr == nil { 288 | head.t = NodeNil 289 | } 290 | return head, nil 291 | } 292 | 293 | func (p *Parser) ParseQuote() (*Node, error) { 294 | node, err := p.ParseAny(false) 295 | if err != nil { 296 | return nil, err 297 | } 298 | return &Node{ 299 | t: NodeQuote, 300 | car: node, 301 | }, nil 302 | } 303 | 304 | func (p *Parser) ParseBquote() (*Node, error) { 305 | node, err := p.ParseAny(true) 306 | if err != nil { 307 | return nil, err 308 | } 309 | return &Node{ 310 | t: NodeBquote, 311 | car: node, 312 | }, nil 313 | } 314 | func isSymbolLetter(r rune) bool { 315 | return strings.ContainsRune(`+-*/<>=&%?.@_#$:*`, r) 316 | } 317 | 318 | func (p *Parser) Pos() int { 319 | return p.pos 320 | } 321 | 322 | func (p *Parser) readRune() (rune, error) { 323 | r, n, err := p.buf.ReadRune() 324 | p.pos += n 325 | return r, err 326 | } 327 | 328 | func (p *Parser) unreadRune() error { 329 | err := p.buf.UnreadRune() 330 | p.pos -= 1 331 | return err 332 | } 333 | 334 | func (p *Parser) ParsePrimitive() (*Node, error) { 335 | var buf bytes.Buffer 336 | for { 337 | r, err := p.readRune() 338 | if err != nil { 339 | if err == io.EOF { 340 | break 341 | } 342 | return nil, err 343 | } 344 | 345 | if !unicode.IsLetter(r) && !unicode.IsDigit(r) && !isSymbolLetter(r) { 346 | p.unreadRune() 347 | break 348 | } 349 | buf.WriteRune(r) 350 | } 351 | 352 | s := buf.String() 353 | 354 | if s == "nil" { 355 | return &Node{ 356 | t: NodeNil, 357 | v: nil, 358 | }, nil 359 | } 360 | if s == "t" { 361 | return &Node{ 362 | t: NodeT, 363 | v: true, 364 | }, nil 365 | } 366 | if i, err := strconv.ParseInt(s, 10, 64); err == nil { 367 | return &Node{ 368 | t: NodeInt, 369 | v: i, 370 | }, nil 371 | } 372 | if f, err := strconv.ParseFloat(s, 64); err == nil { 373 | return &Node{ 374 | t: NodeDouble, 375 | v: f, 376 | }, nil 377 | } 378 | return &Node{ 379 | t: NodeIdent, 380 | v: s, 381 | }, nil 382 | } 383 | 384 | func (p *Parser) ParseAny(bq bool) (*Node, error) { 385 | p.SkipWhite() 386 | r, err := p.readRune() 387 | if err != nil { 388 | return nil, err 389 | } 390 | 391 | if r == '(' { 392 | node, err := p.ParseParen(bq) 393 | if err != nil { 394 | return nil, err 395 | } 396 | r, err := p.readRune() 397 | if err != nil || r != ')' { 398 | return nil, EOF 399 | } 400 | return node, nil 401 | } 402 | if unicode.IsLetter(r) || unicode.IsDigit(r) || isSymbolLetter(r) { 403 | p.unreadRune() 404 | return p.ParsePrimitive() 405 | } 406 | if r == '[' { 407 | return p.ParseArray() 408 | } 409 | if r == '\'' { 410 | return p.ParseQuote() 411 | } 412 | if r == '`' { 413 | return p.ParseBquote() 414 | } 415 | if r == '"' { 416 | return p.ParseString() 417 | } 418 | return nil, fmt.Errorf("invalid token: '%c' (%d)", r, p.Pos()) 419 | } 420 | 421 | func (p *Parser) Parse() (*Node, error) { 422 | return p.ParseAny(false) 423 | } 424 | -------------------------------------------------------------------------------- /cmd/treesitter-server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | //go:generate go run generate/main.go generate/parser.go -o highlight.go 4 | 5 | import ( 6 | "bufio" 7 | "bytes" 8 | "encoding/json" 9 | "flag" 10 | "fmt" 11 | "os" 12 | "runtime" 13 | "strconv" 14 | 15 | sitter "github.com/smacker/go-tree-sitter" 16 | "github.com/smacker/go-tree-sitter/bash" 17 | "github.com/smacker/go-tree-sitter/c" 18 | "github.com/smacker/go-tree-sitter/cpp" 19 | "github.com/smacker/go-tree-sitter/csharp" 20 | "github.com/smacker/go-tree-sitter/css" 21 | "github.com/smacker/go-tree-sitter/dockerfile" 22 | "github.com/smacker/go-tree-sitter/elm" 23 | "github.com/smacker/go-tree-sitter/golang" 24 | "github.com/smacker/go-tree-sitter/hcl" 25 | "github.com/smacker/go-tree-sitter/html" 26 | "github.com/smacker/go-tree-sitter/java" 27 | "github.com/smacker/go-tree-sitter/javascript" 28 | "github.com/smacker/go-tree-sitter/lua" 29 | "github.com/smacker/go-tree-sitter/ocaml" 30 | "github.com/smacker/go-tree-sitter/php" 31 | "github.com/smacker/go-tree-sitter/python" 32 | "github.com/smacker/go-tree-sitter/ruby" 33 | "github.com/smacker/go-tree-sitter/rust" 34 | "github.com/smacker/go-tree-sitter/scala" 35 | "github.com/smacker/go-tree-sitter/svelte" 36 | "github.com/smacker/go-tree-sitter/toml" 37 | "github.com/smacker/go-tree-sitter/typescript/tsx" 38 | "github.com/smacker/go-tree-sitter/typescript/typescript" 39 | "github.com/smacker/go-tree-sitter/yaml" 40 | ) 41 | 42 | const name = "treesitter-server" 43 | 44 | const version = "0.0.1" 45 | 46 | var revision = "HEAD" 47 | 48 | const ( 49 | EOL = 0 50 | PLAIN = 1 51 | SYMBOL = 2 52 | KEYWORD = 3 53 | IDENTIFIER = 4 54 | SPECIAL_CHAR = 5 55 | STRING = 6 56 | NUMBER = 7 57 | ERROR = 8 58 | COMMENT = 9 59 | ) 60 | 61 | var debug bool 62 | var languages = map[string]func() *sitter.Language{ 63 | "bash": bash.GetLanguage, 64 | "c": c.GetLanguage, 65 | "cpp": cpp.GetLanguage, 66 | "csharp": csharp.GetLanguage, 67 | "css": css.GetLanguage, 68 | "dockerfile": dockerfile.GetLanguage, 69 | "elm": elm.GetLanguage, 70 | "go": golang.GetLanguage, 71 | "hcl": hcl.GetLanguage, 72 | "html": html.GetLanguage, 73 | "java": java.GetLanguage, 74 | "javascript": javascript.GetLanguage, 75 | "lua": lua.GetLanguage, 76 | "ocaml": ocaml.GetLanguage, 77 | "php": php.GetLanguage, 78 | "python": python.GetLanguage, 79 | "ruby": ruby.GetLanguage, 80 | "rust": rust.GetLanguage, 81 | "scala": scala.GetLanguage, 82 | "svelte": svelte.GetLanguage, 83 | "toml": toml.GetLanguage, 84 | "typescript": typescript.GetLanguage, 85 | "tsx": tsx.GetLanguage, 86 | "yaml": yaml.GetLanguage, 87 | } 88 | 89 | func has(kw []string, s string) bool { 90 | for _, k := range kw { 91 | if k == s { 92 | return true 93 | } 94 | } 95 | return false 96 | } 97 | 98 | type Response [2]interface{} 99 | 100 | type Point struct { 101 | Row uint32 `json:"row"` 102 | Column uint32 `json:"column"` 103 | } 104 | 105 | type Node struct { 106 | Type string `json:"type"` 107 | Start Point `json:"start"` 108 | End Point `json:"end"` 109 | } 110 | 111 | type Colorizer struct { 112 | row int 113 | column int 114 | colors []string 115 | line *[]Prop 116 | lines []*[]Prop 117 | } 118 | 119 | func NewColorizer(row, column int) *Colorizer { 120 | return &Colorizer{ 121 | row: row, 122 | column: column, 123 | colors: []string{""}, 124 | line: &[]Prop{}, 125 | lines: []*[]Prop{}, 126 | } 127 | } 128 | 129 | func (c *Colorizer) ExtendLine(length int) { 130 | // length must be > 0 or EOL 131 | if len(*c.line) == 0 { 132 | c.lines = append(c.lines, c.line) 133 | } 134 | if len(*c.line) > 0 && (*c.line)[0].Attr.Type == c.colors[0] { 135 | if length == EOL { 136 | (*c.line)[0].Attr.Length = EOL 137 | } else { 138 | (*c.line)[0].Attr.Length += length 139 | } 140 | } else { 141 | *c.line = append([]Prop{{Attr: PropAttr{Length: length, Type: c.colors[0]}}}, (*c.line)...) 142 | } 143 | if length == EOL { 144 | c.line = &[]Prop{} 145 | } 146 | } 147 | 148 | func (c *Colorizer) AdvanceTo(row, column int) { 149 | // Handle line wraps within colored area 150 | for row > c.row { 151 | c.ExtendLine(EOL) 152 | c.row += 1 153 | c.column = 0 154 | } 155 | if column > c.column { 156 | c.ExtendLine(column - c.column) 157 | c.column = column 158 | } 159 | } 160 | 161 | func (c *Colorizer) Start(color string, row, column int) { 162 | c.AdvanceTo(row, column) 163 | c.colors = append([]string{color}, c.colors...) 164 | } 165 | 166 | func (c *Colorizer) End(row, column int) { 167 | c.AdvanceTo(row, column) 168 | c.colors = c.colors[1:] 169 | } 170 | 171 | type PropAttr struct { 172 | Length int `json:"length"` 173 | Type string `json:"type"` 174 | } 175 | 176 | type Prop struct { 177 | Row int `json:"row"` 178 | Col int `json:"col"` 179 | Attr PropAttr `json:"attr"` 180 | } 181 | 182 | func (c *Colorizer) Render() [][]Prop { 183 | lines := [][]Prop{} 184 | for i := 0; i < len(c.lines); i++ { 185 | props := []Prop{} 186 | col := 1 187 | for j := len(*(c.lines[i])) - 1; j >= 0; j-- { 188 | v := (*(c.lines[i]))[j] 189 | props = append(props, Prop{Row: i + 1, Col: col, Attr: v.Attr}) 190 | col += v.Attr.Length 191 | } 192 | lines = append(lines, props) 193 | } 194 | return lines 195 | } 196 | 197 | func doTextObj(parser *sitter.Parser, lname string, code string, column uint32, row uint32) { 198 | f, ok := languages[lname] 199 | if !ok { 200 | return 201 | } 202 | lang := f() 203 | parser.Reset() 204 | parser.SetLanguage(lang) 205 | root := parser.Parse(nil, []byte(code)).RootNode() 206 | pt := sitter.Point{ 207 | Row: row, 208 | Column: column, 209 | } 210 | node := root.NamedDescendantForPointRange(pt, pt) 211 | if node == nil { 212 | json.NewEncoder(os.Stdout).Encode(Response{"textobj", "not found"}) 213 | } else { 214 | json.NewEncoder(os.Stdout).Encode(Response{"textobj", &Node{ 215 | Type: node.Type(), 216 | Start: Point{ 217 | Row: node.StartPoint().Row, 218 | Column: node.StartPoint().Column, 219 | }, 220 | End: Point{ 221 | Row: node.EndPoint().Row, 222 | Column: node.EndPoint().Column, 223 | }, 224 | }}) 225 | } 226 | } 227 | 228 | func doSyntax(parser *sitter.Parser, lname string, code string) { 229 | f, ok := languages[lname] 230 | if !ok { 231 | return 232 | } 233 | lang := f() 234 | parser.Reset() 235 | parser.SetLanguage(lang) 236 | root := parser.Parse(nil, []byte(code)).RootNode() 237 | 238 | colorizer := NewColorizer(int(root.StartPoint().Row), int(root.StartPoint().Column)) 239 | types := []string{} 240 | var process_node func(node *sitter.Node) 241 | process_node = func(node *sitter.Node) { 242 | nt := node.Type() 243 | if debug { 244 | fmt.Println(nt) 245 | } 246 | types = append(types, nt) 247 | color := "" 248 | if lang.SymbolType(node.Symbol()) == sitter.SymbolTypeAnonymous { 249 | if v, ok := keywords[lname][nt]; ok { 250 | color = v 251 | } 252 | } else { 253 | if v, ok := symbols[lname][nt]; ok { 254 | color = v 255 | } 256 | } 257 | 258 | if color != "" { 259 | colorizer.Start(color, int(node.StartPoint().Row), int(node.StartPoint().Column)) 260 | } 261 | 262 | for i := 0; i < int(node.ChildCount()); i++ { 263 | process_node(node.Child(i)) 264 | } 265 | 266 | types = append(types, "/"+nt) 267 | 268 | if color != "" { 269 | colorizer.End(int(node.EndPoint().Row), int(node.EndPoint().Column)) 270 | } 271 | } 272 | process_node(root) 273 | json.NewEncoder(os.Stdout).Encode(Response{"syntax", colorizer.Render()}) 274 | } 275 | 276 | func readLine(reader *bufio.Reader, buf *bytes.Buffer) error { 277 | for { 278 | b, prefix, err := reader.ReadLine() 279 | if err != nil { 280 | return err 281 | } 282 | buf.Write(b) 283 | if !prefix { 284 | break 285 | } 286 | } 287 | return nil 288 | } 289 | 290 | func main() { 291 | var showVersion bool 292 | flag.BoolVar(&debug, "debug", false, "debug") 293 | flag.BoolVar(&showVersion, "V", false, "Print the version") 294 | flag.Parse() 295 | 296 | if showVersion { 297 | fmt.Printf("%s %s (rev: %s/%s)\n", name, version, revision, runtime.Version()) 298 | return 299 | } 300 | 301 | parser := sitter.NewParser() 302 | reader := bufio.NewReader(os.Stdin) 303 | for { 304 | var buf bytes.Buffer 305 | err := readLine(reader, &buf) 306 | if err != nil { 307 | break 308 | } 309 | var input []string 310 | err = json.Unmarshal(buf.Bytes(), &input) 311 | if err != nil { 312 | continue 313 | } 314 | if input[0] == "version" { 315 | json.NewEncoder(os.Stdout).Encode(Response{"version", version}) 316 | } else if input[0] == "syntax" && len(input) == 3 { 317 | doSyntax(parser, input[1], input[2]) 318 | } else if input[0] == "textobj" /*&& len(input) == 5*/ { 319 | col, _ := strconv.Atoi(input[3]) 320 | line, _ := strconv.Atoi(input[4]) 321 | doTextObj(parser, input[1], input[2], uint32(col), uint32(line)) 322 | } else { 323 | json.NewEncoder(os.Stdout).Encode(Response{"error", "invalid command"}) 324 | } 325 | } 326 | } 327 | -------------------------------------------------------------------------------- /cmd/treesitter-server/highlight.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var symbols = map[string]map[string]string { 4 | "bash": { 5 | "simple_expansion": "TSNone", 6 | "expansion": "TSNone", 7 | "heredoc_start": "TSPunctDelimiter", 8 | "string": "TSString", 9 | "raw_string": "TSString", 10 | "heredoc_body": "TSString", 11 | "special_variable_name": "TSConstant", 12 | "comment": "TSComment", 13 | "test_operator": "TSString", 14 | "variable_name": "TSVariable", 15 | "regex": "TSStringRegex", 16 | }, 17 | "c": { 18 | "identifier": "TSVariable", 19 | "preproc_directive": "TSKeyword", 20 | "true": "TSBoolean", 21 | "false": "TSBoolean", 22 | "string_literal": "TSString", 23 | "system_lib_string": "TSString", 24 | "escape_sequence": "TSStringEscape", 25 | "null": "TSConstBuiltin", 26 | "number_literal": "TSNumber", 27 | "char_literal": "TSCharacter", 28 | "preproc_arg": "TSFunctionMacro", 29 | "preproc_defined": "TSFunctionMacro", 30 | "statement_identifier": "TSLabel", 31 | "type_identifier": "TSType", 32 | "primitive_type": "TSType", 33 | "sized_type_specifier": "TSType", 34 | "type_descriptor": "TSType", 35 | "comment": "TSComment", 36 | "preproc_params": "TSParameter", 37 | "ERROR": "TSError", 38 | }, 39 | "cpp": { 40 | "identifier": "TSVariable", 41 | "preproc_directive": "TSKeyword", 42 | "true": "TSBoolean", 43 | "false": "TSBoolean", 44 | "string_literal": "TSString", 45 | "system_lib_string": "TSString", 46 | "escape_sequence": "TSStringEscape", 47 | "null": "TSConstBuiltin", 48 | "number_literal": "TSNumber", 49 | "char_literal": "TSCharacter", 50 | "preproc_arg": "TSFunctionMacro", 51 | "preproc_defined": "TSFunctionMacro", 52 | "statement_identifier": "TSLabel", 53 | "type_identifier": "TSType", 54 | "primitive_type": "TSType", 55 | "sized_type_specifier": "TSType", 56 | "type_descriptor": "TSType", 57 | "comment": "TSComment", 58 | "preproc_params": "TSParameter", 59 | "ERROR": "TSError", 60 | "namespace_identifier": "TSNamespace", 61 | "operator_name": "TSFunction", 62 | "this": "TSVariableBuiltin", 63 | "nullptr": "TSConstant", 64 | "raw_string_literal": "TSString", 65 | "auto": "TSKeyword", 66 | "attribute": "TSAttribute", 67 | }, 68 | "csharp": { 69 | }, 70 | "css": { 71 | "at_keyword": "TSKeyword", 72 | "to": "TSKeyword", 73 | "from": "TSKeyword", 74 | "important": "TSKeyword", 75 | "comment": "TSComment", 76 | "tag_name": "TSType", 77 | "nesting_selector": "TSType", 78 | "universal_selector": "TSType", 79 | "function_name": "TSFunction", 80 | "class_name": "TSProperty", 81 | "id_name": "TSProperty", 82 | "namespace_name": "TSProperty", 83 | "property_name": "TSProperty", 84 | "feature_name": "TSProperty", 85 | "attribute_name": "TSProperty", 86 | "string_value": "TSString", 87 | "color_value": "TSString", 88 | "unit": "TSString", 89 | "integer_value": "TSNumber", 90 | "float_value": "TSNumber", 91 | "ERROR": "TSError", 92 | }, 93 | "dockerfile": { 94 | "comment": "TSComment", 95 | "double_quoted_string": "TSString", 96 | }, 97 | "ecma": { 98 | "identifier": "TSVariable", 99 | "property_identifier": "TSProperty", 100 | "shorthand_property_identifier": "TSProperty", 101 | "this": "TSVariableBuiltin", 102 | "super": "TSVariableBuiltin", 103 | "true": "TSBoolean", 104 | "false": "TSBoolean", 105 | "null": "TSConstBuiltin", 106 | "comment": "TSComment", 107 | "string": "TSString", 108 | "regex": "TSPunctDelimiter", 109 | "regex_pattern": "TSStringRegex", 110 | "template_string": "TSString", 111 | "number": "TSNumber", 112 | "template_substitution": "TSNone", 113 | }, 114 | "elm": { 115 | }, 116 | "go": { 117 | "type_identifier": "TSType", 118 | "field_identifier": "TSProperty", 119 | "identifier": "TSVariable", 120 | "package_identifier": "TSVariable", 121 | "interpreted_string_literal": "TSString", 122 | "raw_string_literal": "TSString", 123 | "rune_literal": "TSString", 124 | "escape_sequence": "TSStringEscape", 125 | "int_literal": "TSNumber", 126 | "float_literal": "TSFloat", 127 | "imaginary_literal": "TSNumber", 128 | "true": "TSBoolean", 129 | "false": "TSBoolean", 130 | "nil": "TSConstBuiltin", 131 | "comment": "TSComment", 132 | "ERROR": "TSError", 133 | }, 134 | "hcl": { 135 | "ellipsis": "TSPunctSpecial", 136 | "quoted_template_start": "TSString", 137 | "quoted_template_end": "TSString", 138 | "template_literal": "TSString", 139 | "heredoc_identifier": "TSPunctDelimiter", 140 | "heredoc_start": "TSPunctDelimiter", 141 | "numeric_lit": "TSNumber", 142 | "bool_lit": "TSBoolean", 143 | "null_lit": "TSConstant", 144 | "comment": "TSComment", 145 | "identifier": "TSVariable", 146 | "ERROR": "TSError", 147 | }, 148 | "html": { 149 | "tag_name": "TSTag", 150 | "erroneous_end_tag_name": "TSError", 151 | "comment": "TSComment", 152 | "attribute_name": "TSProperty", 153 | "attribute_value": "TSString", 154 | "quoted_attribute_value": "TSString", 155 | "text": "TSNone", 156 | "doctype": "TSConstant", 157 | }, 158 | "html_tags": { 159 | "tag_name": "TSTag", 160 | "erroneous_end_tag_name": "TSError", 161 | "comment": "TSComment", 162 | "attribute_name": "TSProperty", 163 | "attribute_value": "TSString", 164 | "quoted_attribute_value": "TSString", 165 | "text": "TSNone", 166 | }, 167 | "java": { 168 | "identifier": "TSVariable", 169 | "super": "TSFunctionBuiltin", 170 | "type_identifier": "TSType", 171 | "boolean_type": "TSTypeBuiltin", 172 | "integral_type": "TSTypeBuiltin", 173 | "floating_point_type": "TSTypeBuiltin", 174 | "void_type": "TSTypeBuiltin", 175 | "this": "TSVariableBuiltin", 176 | "hex_integer_literal": "TSNumber", 177 | "decimal_integer_literal": "TSNumber", 178 | "octal_integer_literal": "TSNumber", 179 | "binary_integer_literal": "TSNumber", 180 | "decimal_floating_point_literal": "TSFloat", 181 | "hex_floating_point_literal": "TSFloat", 182 | "character_literal": "TSCharacter", 183 | "string_literal": "TSString", 184 | "null_literal": "TSConstBuiltin", 185 | "comment": "TSComment", 186 | "true": "TSBoolean", 187 | "false": "TSBoolean", 188 | }, 189 | "javascript": { 190 | "identifier": "TSVariable", 191 | "property_identifier": "TSProperty", 192 | "shorthand_property_identifier": "TSProperty", 193 | "this": "TSVariableBuiltin", 194 | "super": "TSVariableBuiltin", 195 | "true": "TSBoolean", 196 | "false": "TSBoolean", 197 | "null": "TSConstBuiltin", 198 | "comment": "TSComment", 199 | "string": "TSString", 200 | "regex": "TSPunctDelimiter", 201 | "regex_pattern": "TSStringRegex", 202 | "template_string": "TSString", 203 | "number": "TSNumber", 204 | "template_substitution": "TSNone", 205 | "jsx_text": "TSNone", 206 | }, 207 | "json": { 208 | "true": "TSBoolean", 209 | "false": "TSBoolean", 210 | "null": "TSConstBuiltin", 211 | "number": "TSNumber", 212 | "ERROR": "TSError", 213 | }, 214 | "jsx": { 215 | "jsx_text": "TSNone", 216 | }, 217 | "lua": { 218 | "self": "TSVariableBuiltin", 219 | "break_statement": "TSKeyword", 220 | "identifier": "TSVariable", 221 | "false": "TSBoolean", 222 | "true": "TSBoolean", 223 | "nil": "TSConstBuiltin", 224 | "spread": "TSConstant", 225 | "property_identifier": "TSProperty", 226 | "method": "TSMethod", 227 | "comment": "TSComment", 228 | "string": "TSString", 229 | "number": "TSNumber", 230 | "label_statement": "TSLabel", 231 | "shebang": "TSComment", 232 | "ERROR": "TSError", 233 | }, 234 | "ocaml": { 235 | "module_name": "TSNamespace", 236 | "module_type_name": "TSNamespace", 237 | "class_name": "TSType", 238 | "class_type_name": "TSType", 239 | "type_constructor": "TSType", 240 | "constructor_name": "TSConstructor", 241 | "tag": "TSConstructor", 242 | "method_name": "TSMethod", 243 | "value_name": "TSVariable", 244 | "type_variable": "TSVariable", 245 | "value_pattern": "TSParameter", 246 | "label_name": "TSProperty", 247 | "field_name": "TSProperty", 248 | "instance_variable_name": "TSProperty", 249 | "boolean": "TSConstant", 250 | "unit": "TSConstant", 251 | "number": "TSNumber", 252 | "signed_number": "TSNumber", 253 | "character": "TSCharacter", 254 | "string": "TSString", 255 | "quoted_string": "TSString", 256 | "escape_sequence": "TSStringEscape", 257 | "conversion_specification": "TSPunctSpecial", 258 | "pretty_printing_indication": "TSPunctSpecial", 259 | "prefix_operator": "TSOperator", 260 | "sign_operator": "TSOperator", 261 | "infix_operator": "TSOperator", 262 | "hash_operator": "TSOperator", 263 | "indexing_operator": "TSOperator", 264 | "let_operator": "TSOperator", 265 | "and_operator": "TSOperator", 266 | "match_operator": "TSOperator", 267 | "attribute_id": "TSProperty", 268 | "comment": "TSComment", 269 | "line_number_directive": "TSComment", 270 | "directive": "TSComment", 271 | "shebang": "TSComment", 272 | "ERROR": "TSError", 273 | }, 274 | "php": { 275 | "variable_name": "TSVariable", 276 | "primitive_type": "TSTypeBuiltin", 277 | "cast_type": "TSTypeBuiltin", 278 | "named_type": "TSType", 279 | "relative_scope": "TSVariableBuiltin", 280 | "string": "TSString", 281 | "heredoc": "TSString", 282 | "boolean": "TSBoolean", 283 | "null": "TSConstBuiltin", 284 | "integer": "TSNumber", 285 | "float": "TSFloat", 286 | "comment": "TSComment", 287 | "php_tag": "TSPunctBracket", 288 | "ERROR": "TSError", 289 | }, 290 | "python": { 291 | "identifier": "TSVariable", 292 | "interpolation": "TSNone", 293 | "decorator": "TSFunction", 294 | "none": "TSConstBuiltin", 295 | "true": "TSBoolean", 296 | "false": "TSBoolean", 297 | "integer": "TSNumber", 298 | "float": "TSFloat", 299 | "comment": "TSComment", 300 | "string": "TSString", 301 | "escape_sequence": "TSStringEscape", 302 | "ellipsis": "TSPunctDelimiter", 303 | "ERROR": "TSError", 304 | }, 305 | "ruby": { 306 | "identifier": "TSVariable", 307 | "interpolation": "TSNone", 308 | "constant": "TSType", 309 | "class_variable": "TSLabel", 310 | "instance_variable": "TSLabel", 311 | "self": "TSVariableBuiltin", 312 | "super": "TSVariableBuiltin", 313 | "string": "TSString", 314 | "bare_string": "TSString", 315 | "subshell": "TSString", 316 | "heredoc_body": "TSString", 317 | "bare_symbol": "TSConstant", 318 | "heredoc_beginning": "TSConstant", 319 | "heredoc_end": "TSConstant", 320 | "simple_symbol": "TSSymbol", 321 | "delimited_symbol": "TSSymbol", 322 | "hash_key_symbol": "TSSymbol", 323 | "regex": "TSStringRegex", 324 | "escape_sequence": "TSStringEscape", 325 | "integer": "TSNumber", 326 | "float": "TSFloat", 327 | "nil": "TSBoolean", 328 | "true": "TSBoolean", 329 | "false": "TSBoolean", 330 | "comment": "TSComment", 331 | "ERROR": "TSError", 332 | }, 333 | "rust": { 334 | "identifier": "TSVariable", 335 | "type_identifier": "TSType", 336 | "primitive_type": "TSTypeBuiltin", 337 | "field_identifier": "TSField", 338 | "crate": "TSNamespace", 339 | "metavariable": "TSFunctionMacro", 340 | "line_comment": "TSComment", 341 | "block_comment": "TSComment", 342 | "self": "TSVariableBuiltin", 343 | "mutable_specifier": "TSKeyword", 344 | "super": "TSKeyword", 345 | "char_literal": "TSString", 346 | "string_literal": "TSString", 347 | "raw_string_literal": "TSString", 348 | "boolean_literal": "TSBoolean", 349 | "integer_literal": "TSNumber", 350 | "float_literal": "TSFloat", 351 | "escape_sequence": "TSStringEscape", 352 | }, 353 | "svelte": { 354 | "tag_name": "TSTag", 355 | "erroneous_end_tag_name": "TSError", 356 | "comment": "TSComment", 357 | "attribute_name": "TSProperty", 358 | "attribute_value": "TSString", 359 | "quoted_attribute_value": "TSString", 360 | "text": "TSNone", 361 | "raw_text_expr": "TSNone", 362 | "special_block_keyword": "TSKeyword", 363 | "then": "TSKeyword", 364 | "as": "TSKeyword", 365 | }, 366 | "toml": { 367 | "bare_key": "TSTypeBuiltin", 368 | "string": "TSString", 369 | "boolean": "TSConstBuiltin", 370 | "integer": "TSNumber", 371 | "float": "TSFloat", 372 | "comment": "TSComment", 373 | "ERROR": "TSError", 374 | }, 375 | "tsx": { 376 | "type_identifier": "TSType", 377 | "predefined_type": "TSTypeBuiltin", 378 | "undefined": "TSVariableBuiltin", 379 | "jsx_text": "TSNone", 380 | }, 381 | "typescript": { 382 | "identifier": "TSVariable", 383 | "property_identifier": "TSProperty", 384 | "shorthand_property_identifier": "TSProperty", 385 | "this": "TSVariableBuiltin", 386 | "super": "TSVariableBuiltin", 387 | "true": "TSBoolean", 388 | "false": "TSBoolean", 389 | "null": "TSConstBuiltin", 390 | "comment": "TSComment", 391 | "string": "TSString", 392 | "regex": "TSPunctDelimiter", 393 | "regex_pattern": "TSStringRegex", 394 | "template_string": "TSString", 395 | "number": "TSNumber", 396 | "template_substitution": "TSNone", 397 | "type_identifier": "TSType", 398 | "predefined_type": "TSTypeBuiltin", 399 | "undefined": "TSVariableBuiltin", 400 | }, 401 | "yaml": { 402 | "boolean_scalar": "TSBoolean", 403 | "null_scalar": "TSConstBuiltin", 404 | "double_quote_scalar": "TSString", 405 | "single_quote_scalar": "TSString", 406 | "escape_sequence": "TSStringEscape", 407 | "integer_scalar": "TSNumber", 408 | "float_scalar": "TSNumber", 409 | "comment": "TSComment", 410 | "anchor_name": "TSType", 411 | "alias_name": "TSType", 412 | "tag": "TSType", 413 | "yaml_directive": "TSKeyword", 414 | "ERROR": "TSError", 415 | }, 416 | } 417 | var keywords = map[string]map[string]string { 418 | "bash": { 419 | "(": "TSPunctBracket", 420 | ")": "TSPunctBracket", 421 | "{": "TSPunctBracket", 422 | "}": "TSPunctBracket", 423 | "[": "TSPunctBracket", 424 | "]": "TSPunctBracket", 425 | ";": "TSPunctDelimiter", 426 | ";;": "TSPunctDelimiter", 427 | "$": "TSPunctSpecial", 428 | ">": "TSOperator", 429 | "<": "TSOperator", 430 | "&": "TSOperator", 431 | "&&": "TSOperator", 432 | "|": "TSOperator", 433 | "||": "TSOperator", 434 | "=": "TSOperator", 435 | "=~": "TSOperator", 436 | "==": "TSOperator", 437 | "!=": "TSOperator", 438 | "if": "TSConditional", 439 | "then": "TSConditional", 440 | "else": "TSConditional", 441 | "elif": "TSConditional", 442 | "fi": "TSConditional", 443 | "case": "TSConditional", 444 | "in": "TSConditional", 445 | "esac": "TSConditional", 446 | "for": "TSRepeat", 447 | "do": "TSRepeat", 448 | "done": "TSRepeat", 449 | "while": "TSRepeat", 450 | "declare": "TSKeyword", 451 | "export": "TSKeyword", 452 | "local": "TSKeyword", 453 | "readonly": "TSKeyword", 454 | "unset": "TSKeyword", 455 | "function": "TSKeywordFunction", 456 | }, 457 | "c": { 458 | "const": "TSKeyword", 459 | "default": "TSKeyword", 460 | "enum": "TSKeyword", 461 | "extern": "TSKeyword", 462 | "inline": "TSKeyword", 463 | "sizeof": "TSKeyword", 464 | "static": "TSKeyword", 465 | "struct": "TSKeyword", 466 | "typedef": "TSKeyword", 467 | "union": "TSKeyword", 468 | "volatile": "TSKeyword", 469 | "goto": "TSKeyword", 470 | "register": "TSKeyword", 471 | "return": "TSKeywordReturn", 472 | "while": "TSRepeat", 473 | "for": "TSRepeat", 474 | "do": "TSRepeat", 475 | "continue": "TSRepeat", 476 | "break": "TSRepeat", 477 | "if": "TSConditional", 478 | "else": "TSConditional", 479 | "case": "TSConditional", 480 | "switch": "TSConditional", 481 | "#define": "TSConstMacro", 482 | "#if": "TSKeyword", 483 | "#ifdef": "TSKeyword", 484 | "#ifndef": "TSKeyword", 485 | "#else": "TSKeyword", 486 | "#elif": "TSKeyword", 487 | "#endif": "TSKeyword", 488 | "#include": "TSInclude", 489 | "=": "TSOperator", 490 | "-": "TSOperator", 491 | "*": "TSOperator", 492 | "/": "TSOperator", 493 | "+": "TSOperator", 494 | "%": "TSOperator", 495 | "~": "TSOperator", 496 | "|": "TSOperator", 497 | "&": "TSOperator", 498 | "^": "TSOperator", 499 | "<<": "TSOperator", 500 | ">>": "TSOperator", 501 | "->": "TSOperator", 502 | "<": "TSOperator", 503 | "<=": "TSOperator", 504 | ">=": "TSOperator", 505 | ">": "TSOperator", 506 | "==": "TSOperator", 507 | "!=": "TSOperator", 508 | "!": "TSOperator", 509 | "&&": "TSOperator", 510 | "||": "TSOperator", 511 | "-=": "TSOperator", 512 | "+=": "TSOperator", 513 | "*=": "TSOperator", 514 | "/=": "TSOperator", 515 | "%=": "TSOperator", 516 | "|=": "TSOperator", 517 | "&=": "TSOperator", 518 | "^=": "TSOperator", 519 | ">>=": "TSOperator", 520 | "<<=": "TSOperator", 521 | "--": "TSOperator", 522 | "++": "TSOperator", 523 | ".": "TSPunctDelimiter", 524 | ";": "TSPunctDelimiter", 525 | ":": "TSPunctDelimiter", 526 | ",": "TSPunctDelimiter", 527 | "...": "TSPunctSpecial", 528 | "(": "TSPunctBracket", 529 | ")": "TSPunctBracket", 530 | "[": "TSPunctBracket", 531 | "]": "TSPunctBracket", 532 | "{": "TSPunctBracket", 533 | "}": "TSPunctBracket", 534 | }, 535 | "cpp": { 536 | "const": "TSKeyword", 537 | "default": "TSKeyword", 538 | "enum": "TSKeyword", 539 | "extern": "TSKeyword", 540 | "inline": "TSKeyword", 541 | "sizeof": "TSKeyword", 542 | "static": "TSKeyword", 543 | "struct": "TSKeyword", 544 | "typedef": "TSKeyword", 545 | "union": "TSKeyword", 546 | "volatile": "TSKeyword", 547 | "goto": "TSKeyword", 548 | "register": "TSKeyword", 549 | "return": "TSKeywordReturn", 550 | "while": "TSRepeat", 551 | "for": "TSRepeat", 552 | "do": "TSRepeat", 553 | "continue": "TSRepeat", 554 | "break": "TSRepeat", 555 | "if": "TSConditional", 556 | "else": "TSConditional", 557 | "case": "TSConditional", 558 | "switch": "TSConditional", 559 | "#define": "TSConstMacro", 560 | "#if": "TSKeyword", 561 | "#ifdef": "TSKeyword", 562 | "#ifndef": "TSKeyword", 563 | "#else": "TSKeyword", 564 | "#elif": "TSKeyword", 565 | "#endif": "TSKeyword", 566 | "#include": "TSInclude", 567 | "=": "TSOperator", 568 | "-": "TSOperator", 569 | "*": "TSOperator", 570 | "/": "TSOperator", 571 | "+": "TSOperator", 572 | "%": "TSOperator", 573 | "~": "TSOperator", 574 | "|": "TSOperator", 575 | "&": "TSOperator", 576 | "^": "TSOperator", 577 | "<<": "TSOperator", 578 | ">>": "TSOperator", 579 | "->": "TSOperator", 580 | "<": "TSOperator", 581 | "<=": "TSOperator", 582 | ">=": "TSOperator", 583 | ">": "TSOperator", 584 | "==": "TSOperator", 585 | "!=": "TSOperator", 586 | "!": "TSOperator", 587 | "&&": "TSOperator", 588 | "||": "TSOperator", 589 | "-=": "TSOperator", 590 | "+=": "TSOperator", 591 | "*=": "TSOperator", 592 | "/=": "TSOperator", 593 | "%=": "TSOperator", 594 | "|=": "TSOperator", 595 | "&=": "TSOperator", 596 | "^=": "TSOperator", 597 | ">>=": "TSOperator", 598 | "<<=": "TSOperator", 599 | "--": "TSOperator", 600 | "++": "TSOperator", 601 | ".": "TSPunctDelimiter", 602 | ";": "TSPunctDelimiter", 603 | ":": "TSPunctDelimiter", 604 | ",": "TSPunctDelimiter", 605 | "...": "TSPunctSpecial", 606 | "(": "TSPunctBracket", 607 | ")": "TSPunctBracket", 608 | "[": "TSPunctBracket", 609 | "]": "TSPunctBracket", 610 | "{": "TSPunctBracket", 611 | "}": "TSPunctBracket", 612 | "try": "TSException", 613 | "catch": "TSException", 614 | "noexcept": "TSException", 615 | "throw": "TSException", 616 | "class": "TSKeyword", 617 | "decltype": "TSKeyword", 618 | "constexpr": "TSKeyword", 619 | "explicit": "TSKeyword", 620 | "final": "TSKeyword", 621 | "friend": "TSKeyword", 622 | "mutable": "TSKeyword", 623 | "namespace": "TSKeyword", 624 | "override": "TSKeyword", 625 | "private": "TSKeyword", 626 | "protected": "TSKeyword", 627 | "public": "TSKeyword", 628 | "template": "TSKeyword", 629 | "typename": "TSKeyword", 630 | "using": "TSKeyword", 631 | "virtual": "TSKeyword", 632 | "new": "TSKeywordOperator", 633 | "delete": "TSKeywordOperator", 634 | "::": "TSOperator", 635 | }, 636 | "csharp": { 637 | }, 638 | "css": { 639 | "@media": "TSKeyword", 640 | "@import": "TSKeyword", 641 | "@charset": "TSKeyword", 642 | "@namespace": "TSKeyword", 643 | "@supports": "TSKeyword", 644 | "@keyframes": "TSKeyword", 645 | "~": "TSOperator", 646 | ">": "TSOperator", 647 | "+": "TSOperator", 648 | "-": "TSOperator", 649 | "*": "TSOperator", 650 | "/": "TSOperator", 651 | "=": "TSOperator", 652 | "^=": "TSOperator", 653 | "|=": "TSOperator", 654 | "~=": "TSOperator", 655 | "$=": "TSOperator", 656 | "*=": "TSOperator", 657 | "and": "TSOperator", 658 | "or": "TSOperator", 659 | "not": "TSOperator", 660 | "only": "TSOperator", 661 | "#": "TSPunctDelimiter", 662 | ",": "TSPunctDelimiter", 663 | ".": "TSPunctDelimiter", 664 | ":": "TSPunctDelimiter", 665 | "::": "TSPunctDelimiter", 666 | ";": "TSPunctDelimiter", 667 | "{": "TSPunctBracket", 668 | ")": "TSPunctBracket", 669 | "(": "TSPunctBracket", 670 | "}": "TSPunctBracket", 671 | }, 672 | "dockerfile": { 673 | "FROM": "TSKeyword", 674 | "AS": "TSKeyword", 675 | "RUN": "TSKeyword", 676 | "CMD": "TSKeyword", 677 | "LABEL": "TSKeyword", 678 | "EXPOSE": "TSKeyword", 679 | "ENV": "TSKeyword", 680 | "ADD": "TSKeyword", 681 | "COPY": "TSKeyword", 682 | "ENTRYPOINT": "TSKeyword", 683 | "VOLUME": "TSKeyword", 684 | "USER": "TSKeyword", 685 | "WORKDIR": "TSKeyword", 686 | "ARG": "TSKeyword", 687 | "ONBUILD": "TSKeyword", 688 | "STOPSIGNAL": "TSKeyword", 689 | "HEALTHCHECK": "TSKeyword", 690 | "SHELL": "TSKeyword", 691 | "MAINTAINER": "TSKeyword", 692 | "CROSS_BUILD": "TSKeyword", 693 | ":": "TSOperator", 694 | "@": "TSOperator", 695 | }, 696 | "ecma": { 697 | "...": "TSPunctSpecial", 698 | ";": "TSPunctDelimiter", 699 | ".": "TSPunctDelimiter", 700 | ",": "TSPunctDelimiter", 701 | "?.": "TSPunctDelimiter", 702 | "--": "TSOperator", 703 | "-": "TSOperator", 704 | "-=": "TSOperator", 705 | "&&": "TSOperator", 706 | "+": "TSOperator", 707 | "++": "TSOperator", 708 | "+=": "TSOperator", 709 | "&=": "TSOperator", 710 | "/=": "TSOperator", 711 | "**=": "TSOperator", 712 | "<<=": "TSOperator", 713 | "<": "TSOperator", 714 | "<=": "TSOperator", 715 | "<<": "TSOperator", 716 | "=": "TSOperator", 717 | "==": "TSOperator", 718 | "===": "TSOperator", 719 | "!=": "TSOperator", 720 | "!==": "TSOperator", 721 | "=>": "TSOperator", 722 | ">": "TSOperator", 723 | ">=": "TSOperator", 724 | ">>": "TSOperator", 725 | "||": "TSOperator", 726 | "%": "TSOperator", 727 | "%=": "TSOperator", 728 | "*": "TSOperator", 729 | "**": "TSOperator", 730 | ">>>": "TSOperator", 731 | "&": "TSOperator", 732 | "|": "TSOperator", 733 | "^": "TSOperator", 734 | "??": "TSOperator", 735 | "*=": "TSOperator", 736 | ">>=": "TSOperator", 737 | ">>>=": "TSOperator", 738 | "^=": "TSOperator", 739 | "|=": "TSOperator", 740 | "&&=": "TSOperator", 741 | "||=": "TSOperator", 742 | "??=": "TSOperator", 743 | "(": "TSPunctBracket", 744 | ")": "TSPunctBracket", 745 | "[": "TSPunctBracket", 746 | "]": "TSPunctBracket", 747 | "{": "TSPunctBracket", 748 | "}": "TSPunctBracket", 749 | "if": "TSConditional", 750 | "else": "TSConditional", 751 | "switch": "TSConditional", 752 | "case": "TSConditional", 753 | "default": "TSConditional", 754 | "import": "TSInclude", 755 | "from": "TSInclude", 756 | "as": "TSInclude", 757 | "for": "TSRepeat", 758 | "of": "TSRepeat", 759 | "do": "TSRepeat", 760 | "while": "TSRepeat", 761 | "continue": "TSRepeat", 762 | "async": "TSKeyword", 763 | "await": "TSKeyword", 764 | "break": "TSKeyword", 765 | "class": "TSKeyword", 766 | "const": "TSKeyword", 767 | "debugger": "TSKeyword", 768 | "export": "TSKeyword", 769 | "extends": "TSKeyword", 770 | "get": "TSKeyword", 771 | "in": "TSKeyword", 772 | "instanceof": "TSKeyword", 773 | "let": "TSKeyword", 774 | "set": "TSKeyword", 775 | "static": "TSKeyword", 776 | "target": "TSKeyword", 777 | "typeof": "TSKeyword", 778 | "var": "TSKeyword", 779 | "void": "TSKeyword", 780 | "with": "TSKeyword", 781 | "return": "TSKeywordReturn", 782 | "yield": "TSKeywordReturn", 783 | "function": "TSKeywordFunction", 784 | "new": "TSKeywordOperator", 785 | "delete": "TSKeywordOperator", 786 | "throw": "TSException", 787 | "try": "TSException", 788 | "catch": "TSException", 789 | "finally": "TSException", 790 | }, 791 | "elm": { 792 | }, 793 | "go": { 794 | "--": "TSOperator", 795 | "-": "TSOperator", 796 | "-=": "TSOperator", 797 | ":=": "TSOperator", 798 | "!": "TSOperator", 799 | "!=": "TSOperator", 800 | "...": "TSOperator", 801 | "*": "TSOperator", 802 | "*=": "TSOperator", 803 | "/": "TSOperator", 804 | "/=": "TSOperator", 805 | "&": "TSOperator", 806 | "&&": "TSOperator", 807 | "&=": "TSOperator", 808 | "%": "TSOperator", 809 | "%=": "TSOperator", 810 | "^": "TSOperator", 811 | "^=": "TSOperator", 812 | "+": "TSOperator", 813 | "++": "TSOperator", 814 | "+=": "TSOperator", 815 | "<-": "TSOperator", 816 | "<": "TSOperator", 817 | "<<": "TSOperator", 818 | "<<=": "TSOperator", 819 | "<=": "TSOperator", 820 | "=": "TSOperator", 821 | "==": "TSOperator", 822 | ">": "TSOperator", 823 | ">=": "TSOperator", 824 | ">>": "TSOperator", 825 | ">>=": "TSOperator", 826 | "|": "TSOperator", 827 | "|=": "TSOperator", 828 | "||": "TSOperator", 829 | "break": "TSKeyword", 830 | "chan": "TSKeyword", 831 | "const": "TSKeyword", 832 | "continue": "TSKeyword", 833 | "default": "TSKeyword", 834 | "defer": "TSKeyword", 835 | "go": "TSKeyword", 836 | "goto": "TSKeyword", 837 | "interface": "TSKeyword", 838 | "map": "TSKeyword", 839 | "range": "TSKeyword", 840 | "select": "TSKeyword", 841 | "struct": "TSKeyword", 842 | "type": "TSKeyword", 843 | "var": "TSKeyword", 844 | "fallthrough": "TSKeyword", 845 | "func": "TSKeywordFunction", 846 | "return": "TSKeywordReturn", 847 | "for": "TSRepeat", 848 | "import": "TSInclude", 849 | "package": "TSInclude", 850 | "else": "TSConditional", 851 | "case": "TSConditional", 852 | "switch": "TSConditional", 853 | "if": "TSConditional", 854 | ".": "TSPunctDelimiter", 855 | ",": "TSPunctDelimiter", 856 | ":": "TSPunctDelimiter", 857 | ";": "TSPunctDelimiter", 858 | "(": "TSPunctBracket", 859 | ")": "TSPunctBracket", 860 | "{": "TSPunctBracket", 861 | "}": "TSPunctBracket", 862 | "[": "TSPunctBracket", 863 | "]": "TSPunctBracket", 864 | }, 865 | "hcl": { 866 | "!": "TSOperator", 867 | "*": "TSOperator", 868 | "/": "TSOperator", 869 | "%": "TSOperator", 870 | "+": "TSOperator", 871 | "-": "TSOperator", 872 | ">": "TSOperator", 873 | ">=": "TSOperator", 874 | "<": "TSOperator", 875 | "<=": "TSOperator", 876 | "==": "TSOperator", 877 | "!=": "TSOperator", 878 | "&&": "TSOperator", 879 | "||": "TSOperator", 880 | "{": "TSPunctBracket", 881 | "}": "TSPunctBracket", 882 | "[": "TSPunctBracket", 883 | "]": "TSPunctBracket", 884 | "(": "TSPunctBracket", 885 | ")": "TSPunctBracket", 886 | ".": "TSPunctDelimiter", 887 | ".*": "TSPunctDelimiter", 888 | ",": "TSPunctDelimiter", 889 | "[*]": "TSPunctDelimiter", 890 | "?": "TSPunctSpecial", 891 | "=>": "TSPunctSpecial", 892 | ":": "TSNone", 893 | "=": "TSNone", 894 | "for": "TSRepeat", 895 | "in": "TSRepeat", 896 | "if": "TSConditional", 897 | }, 898 | "html": { 899 | "<": "TSTagDelimiter", 900 | ">": "TSTagDelimiter", 901 | "": "TSTagDelimiter", 903 | "=": "TSOperator", 904 | "": "TSTagDelimiter", 909 | "": "TSTagDelimiter", 911 | "=": "TSOperator", 912 | }, 913 | "java": { 914 | "@": "TSOperator", 915 | "+": "TSOperator", 916 | ":": "TSOperator", 917 | "++": "TSOperator", 918 | "-": "TSOperator", 919 | "--": "TSOperator", 920 | "&": "TSOperator", 921 | "&&": "TSOperator", 922 | "|": "TSOperator", 923 | "||": "TSOperator", 924 | "!=": "TSOperator", 925 | "==": "TSOperator", 926 | "*": "TSOperator", 927 | "/": "TSOperator", 928 | "%": "TSOperator", 929 | "<": "TSOperator", 930 | "<=": "TSOperator", 931 | ">": "TSOperator", 932 | ">=": "TSOperator", 933 | "=": "TSOperator", 934 | "-=": "TSOperator", 935 | "+=": "TSOperator", 936 | "*=": "TSOperator", 937 | "/=": "TSOperator", 938 | "%=": "TSOperator", 939 | "->": "TSOperator", 940 | "^": "TSOperator", 941 | "^=": "TSOperator", 942 | "&=": "TSOperator", 943 | "|=": "TSOperator", 944 | "~": "TSOperator", 945 | ">>": "TSOperator", 946 | ">>>": "TSOperator", 947 | "<<": "TSOperator", 948 | "::": "TSOperator", 949 | "abstract": "TSKeyword", 950 | "assert": "TSKeyword", 951 | "break": "TSKeyword", 952 | "class": "TSKeyword", 953 | "record": "TSKeyword", 954 | "continue": "TSKeyword", 955 | "default": "TSKeyword", 956 | "enum": "TSKeyword", 957 | "exports": "TSKeyword", 958 | "extends": "TSKeyword", 959 | "final": "TSKeyword", 960 | "implements": "TSKeyword", 961 | "instanceof": "TSKeyword", 962 | "interface": "TSKeyword", 963 | "module": "TSKeyword", 964 | "native": "TSKeyword", 965 | "open": "TSKeyword", 966 | "opens": "TSKeyword", 967 | "package": "TSKeyword", 968 | "private": "TSKeyword", 969 | "protected": "TSKeyword", 970 | "provides": "TSKeyword", 971 | "public": "TSKeyword", 972 | "requires": "TSKeyword", 973 | "static": "TSKeyword", 974 | "strictfp": "TSKeyword", 975 | "synchronized": "TSKeyword", 976 | "to": "TSKeyword", 977 | "transient": "TSKeyword", 978 | "transitive": "TSKeyword", 979 | "uses": "TSKeyword", 980 | "volatile": "TSKeyword", 981 | "with": "TSKeyword", 982 | "return": "TSKeywordReturn", 983 | "yield": "TSKeywordReturn", 984 | "new": "TSKeywordOperator", 985 | "if": "TSConditional", 986 | "else": "TSConditional", 987 | "switch": "TSConditional", 988 | "case": "TSConditional", 989 | "for": "TSRepeat", 990 | "while": "TSRepeat", 991 | "do": "TSRepeat", 992 | "import": "TSInclude", 993 | ";": "TSPunctDelimiter", 994 | ".": "TSPunctDelimiter", 995 | "...": "TSPunctDelimiter", 996 | ",": "TSPunctDelimiter", 997 | "[": "TSPunctBracket", 998 | "]": "TSPunctBracket", 999 | "{": "TSPunctBracket", 1000 | "}": "TSPunctBracket", 1001 | "(": "TSPunctBracket", 1002 | ")": "TSPunctBracket", 1003 | "throw": "TSException", 1004 | "throws": "TSException", 1005 | "finally": "TSException", 1006 | "try": "TSException", 1007 | "catch": "TSException", 1008 | }, 1009 | "javascript": { 1010 | "...": "TSPunctSpecial", 1011 | ";": "TSPunctDelimiter", 1012 | ".": "TSPunctDelimiter", 1013 | ",": "TSPunctDelimiter", 1014 | "?.": "TSPunctDelimiter", 1015 | "--": "TSOperator", 1016 | "-": "TSOperator", 1017 | "-=": "TSOperator", 1018 | "&&": "TSOperator", 1019 | "+": "TSOperator", 1020 | "++": "TSOperator", 1021 | "+=": "TSOperator", 1022 | "&=": "TSOperator", 1023 | "/=": "TSOperator", 1024 | "**=": "TSOperator", 1025 | "<<=": "TSOperator", 1026 | "<": "TSOperator", 1027 | "<=": "TSOperator", 1028 | "<<": "TSOperator", 1029 | "=": "TSOperator", 1030 | "==": "TSOperator", 1031 | "===": "TSOperator", 1032 | "!=": "TSOperator", 1033 | "!==": "TSOperator", 1034 | "=>": "TSOperator", 1035 | ">": "TSOperator", 1036 | ">=": "TSOperator", 1037 | ">>": "TSOperator", 1038 | "||": "TSOperator", 1039 | "%": "TSOperator", 1040 | "%=": "TSOperator", 1041 | "*": "TSOperator", 1042 | "**": "TSOperator", 1043 | ">>>": "TSOperator", 1044 | "&": "TSOperator", 1045 | "|": "TSOperator", 1046 | "^": "TSOperator", 1047 | "??": "TSOperator", 1048 | "*=": "TSOperator", 1049 | ">>=": "TSOperator", 1050 | ">>>=": "TSOperator", 1051 | "^=": "TSOperator", 1052 | "|=": "TSOperator", 1053 | "&&=": "TSOperator", 1054 | "||=": "TSOperator", 1055 | "??=": "TSOperator", 1056 | "(": "TSPunctBracket", 1057 | ")": "TSPunctBracket", 1058 | "[": "TSPunctBracket", 1059 | "]": "TSPunctBracket", 1060 | "{": "TSPunctBracket", 1061 | "}": "TSPunctBracket", 1062 | "if": "TSConditional", 1063 | "else": "TSConditional", 1064 | "switch": "TSConditional", 1065 | "case": "TSConditional", 1066 | "default": "TSConditional", 1067 | "import": "TSInclude", 1068 | "from": "TSInclude", 1069 | "as": "TSInclude", 1070 | "for": "TSRepeat", 1071 | "of": "TSRepeat", 1072 | "do": "TSRepeat", 1073 | "while": "TSRepeat", 1074 | "continue": "TSRepeat", 1075 | "async": "TSKeyword", 1076 | "await": "TSKeyword", 1077 | "break": "TSKeyword", 1078 | "class": "TSKeyword", 1079 | "const": "TSKeyword", 1080 | "debugger": "TSKeyword", 1081 | "export": "TSKeyword", 1082 | "extends": "TSKeyword", 1083 | "get": "TSKeyword", 1084 | "in": "TSKeyword", 1085 | "instanceof": "TSKeyword", 1086 | "let": "TSKeyword", 1087 | "set": "TSKeyword", 1088 | "static": "TSKeyword", 1089 | "target": "TSKeyword", 1090 | "typeof": "TSKeyword", 1091 | "var": "TSKeyword", 1092 | "void": "TSKeyword", 1093 | "with": "TSKeyword", 1094 | "return": "TSKeywordReturn", 1095 | "yield": "TSKeywordReturn", 1096 | "function": "TSKeywordFunction", 1097 | "new": "TSKeywordOperator", 1098 | "delete": "TSKeywordOperator", 1099 | "throw": "TSException", 1100 | "try": "TSException", 1101 | "catch": "TSException", 1102 | "finally": "TSException", 1103 | }, 1104 | "json": { 1105 | ",": "TSPunctDelimiter", 1106 | "[": "TSPunctBracket", 1107 | "]": "TSPunctBracket", 1108 | "{": "TSPunctBracket", 1109 | "}": "TSPunctBracket", 1110 | }, 1111 | "jsx": { 1112 | }, 1113 | "lua": { 1114 | "else": "TSConditional", 1115 | "elseif": "TSConditional", 1116 | "then": "TSConditional", 1117 | "in": "TSKeyword", 1118 | "local": "TSKeyword", 1119 | "goto": "TSKeyword", 1120 | "return": "TSKeywordReturn", 1121 | "not": "TSKeywordOperator", 1122 | "and": "TSKeywordOperator", 1123 | "or": "TSKeywordOperator", 1124 | "=": "TSOperator", 1125 | "~=": "TSOperator", 1126 | "==": "TSOperator", 1127 | "<=": "TSOperator", 1128 | ">=": "TSOperator", 1129 | "<": "TSOperator", 1130 | ">": "TSOperator", 1131 | "+": "TSOperator", 1132 | "-": "TSOperator", 1133 | "%": "TSOperator", 1134 | "/": "TSOperator", 1135 | "//": "TSOperator", 1136 | "*": "TSOperator", 1137 | "^": "TSOperator", 1138 | "&": "TSOperator", 1139 | "~": "TSOperator", 1140 | "|": "TSOperator", 1141 | ">>": "TSOperator", 1142 | "<<": "TSOperator", 1143 | "..": "TSOperator", 1144 | "#": "TSOperator", 1145 | ",": "TSPunctDelimiter", 1146 | ".": "TSPunctDelimiter", 1147 | ":": "TSPunctDelimiter", 1148 | "(": "TSPunctBracket", 1149 | ")": "TSPunctBracket", 1150 | "[": "TSPunctBracket", 1151 | "]": "TSPunctBracket", 1152 | "{": "TSPunctBracket", 1153 | "}": "TSPunctBracket", 1154 | }, 1155 | "ocaml": { 1156 | "and": "TSKeyword", 1157 | "as": "TSKeyword", 1158 | "assert": "TSKeyword", 1159 | "begin": "TSKeyword", 1160 | "class": "TSKeyword", 1161 | "constraint": "TSKeyword", 1162 | "end": "TSKeyword", 1163 | "external": "TSKeyword", 1164 | "in": "TSKeyword", 1165 | "inherit": "TSKeyword", 1166 | "initializer": "TSKeyword", 1167 | "lazy": "TSKeyword", 1168 | "let": "TSKeyword", 1169 | "match": "TSKeyword", 1170 | "method": "TSKeyword", 1171 | "module": "TSKeyword", 1172 | "mutable": "TSKeyword", 1173 | "new": "TSKeyword", 1174 | "nonrec": "TSKeyword", 1175 | "object": "TSKeyword", 1176 | "of": "TSKeyword", 1177 | "private": "TSKeyword", 1178 | "rec": "TSKeyword", 1179 | "sig": "TSKeyword", 1180 | "struct": "TSKeyword", 1181 | "type": "TSKeyword", 1182 | "val": "TSKeyword", 1183 | "virtual": "TSKeyword", 1184 | "when": "TSKeyword", 1185 | "with": "TSKeyword", 1186 | "fun": "TSKeywordFunction", 1187 | "function": "TSKeywordFunction", 1188 | "functor": "TSKeywordFunction", 1189 | "if": "TSConditional", 1190 | "then": "TSConditional", 1191 | "else": "TSConditional", 1192 | "exception": "TSException", 1193 | "try": "TSException", 1194 | "include": "TSInclude", 1195 | "open": "TSInclude", 1196 | "for": "TSRepeat", 1197 | "to": "TSRepeat", 1198 | "downto": "TSRepeat", 1199 | "while": "TSRepeat", 1200 | "do": "TSRepeat", 1201 | "done": "TSRepeat", 1202 | "%": "TSPunctSpecial", 1203 | "(": "TSPunctBracket", 1204 | ")": "TSPunctBracket", 1205 | "[": "TSPunctBracket", 1206 | "]": "TSPunctBracket", 1207 | "{": "TSPunctBracket", 1208 | "}": "TSPunctBracket", 1209 | "[|": "TSPunctBracket", 1210 | "|]": "TSPunctBracket", 1211 | "[<": "TSPunctBracket", 1212 | "[>": "TSPunctBracket", 1213 | ",": "TSPunctDelimiter", 1214 | ".": "TSPunctDelimiter", 1215 | ";": "TSPunctDelimiter", 1216 | ":": "TSPunctDelimiter", 1217 | "=": "TSPunctDelimiter", 1218 | "|": "TSPunctDelimiter", 1219 | "~": "TSPunctDelimiter", 1220 | "?": "TSPunctDelimiter", 1221 | "+": "TSPunctDelimiter", 1222 | "-": "TSPunctDelimiter", 1223 | "!": "TSPunctDelimiter", 1224 | ">": "TSPunctDelimiter", 1225 | "&": "TSPunctDelimiter", 1226 | "->": "TSPunctDelimiter", 1227 | ";;": "TSPunctDelimiter", 1228 | ":>": "TSPunctDelimiter", 1229 | "+=": "TSPunctDelimiter", 1230 | ":=": "TSPunctDelimiter", 1231 | "..": "TSPunctDelimiter", 1232 | "*": "TSOperator", 1233 | "#": "TSOperator", 1234 | "::": "TSOperator", 1235 | "<-": "TSOperator", 1236 | }, 1237 | "php": { 1238 | "as": "TSKeywordOperator", 1239 | "fn": "TSKeywordFunction", 1240 | "function": "TSKeywordFunction", 1241 | "$": "TSKeyword", 1242 | "abstract": "TSKeyword", 1243 | "break": "TSKeyword", 1244 | "class": "TSKeyword", 1245 | "const": "TSKeyword", 1246 | "continue": "TSKeyword", 1247 | "declare": "TSKeyword", 1248 | "default": "TSKeyword", 1249 | "echo": "TSKeyword", 1250 | "enddeclare": "TSKeyword", 1251 | "extends": "TSKeyword", 1252 | "final": "TSKeyword", 1253 | "global": "TSKeyword", 1254 | "implements": "TSKeyword", 1255 | "insteadof": "TSKeyword", 1256 | "interface": "TSKeyword", 1257 | "namespace": "TSKeyword", 1258 | "new": "TSKeyword", 1259 | "private": "TSKeyword", 1260 | "protected": "TSKeyword", 1261 | "public": "TSKeyword", 1262 | "static": "TSKeyword", 1263 | "trait": "TSKeyword", 1264 | "return": "TSKeywordReturn", 1265 | "case": "TSConditional", 1266 | "else": "TSConditional", 1267 | "elseif": "TSConditional", 1268 | "endif": "TSConditional", 1269 | "endswitch": "TSConditional", 1270 | "if": "TSConditional", 1271 | "switch": "TSConditional", 1272 | "match": "TSConditional", 1273 | "do": "TSRepeat", 1274 | "endfor": "TSRepeat", 1275 | "endforeach": "TSRepeat", 1276 | "endwhile": "TSRepeat", 1277 | "for": "TSRepeat", 1278 | "foreach": "TSRepeat", 1279 | "while": "TSRepeat", 1280 | "catch": "TSException", 1281 | "finally": "TSException", 1282 | "throw": "TSException", 1283 | "try": "TSException", 1284 | "include_once": "TSInclude", 1285 | "include": "TSInclude", 1286 | "require_once": "TSInclude", 1287 | "require": "TSInclude", 1288 | "use": "TSInclude", 1289 | ",": "TSPunctDelimiter", 1290 | ";": "TSPunctDelimiter", 1291 | ".": "TSPunctDelimiter", 1292 | "?>": "TSPunctBracket", 1293 | "(": "TSPunctBracket", 1294 | ")": "TSPunctBracket", 1295 | "[": "TSPunctBracket", 1296 | "]": "TSPunctBracket", 1297 | "{": "TSPunctBracket", 1298 | "}": "TSPunctBracket", 1299 | "=": "TSOperator", 1300 | "-": "TSOperator", 1301 | "*": "TSOperator", 1302 | "/": "TSOperator", 1303 | "+": "TSOperator", 1304 | "%": "TSOperator", 1305 | "~": "TSOperator", 1306 | "|": "TSOperator", 1307 | "&": "TSOperator", 1308 | "<<": "TSOperator", 1309 | ">>": "TSOperator", 1310 | "->": "TSOperator", 1311 | "<": "TSOperator", 1312 | "<=": "TSOperator", 1313 | ">=": "TSOperator", 1314 | ">": "TSOperator", 1315 | "==": "TSOperator", 1316 | "!=": "TSOperator", 1317 | "===": "TSOperator", 1318 | "!==": "TSOperator", 1319 | "!": "TSOperator", 1320 | "&&": "TSOperator", 1321 | "||": "TSOperator", 1322 | "-=": "TSOperator", 1323 | "+=": "TSOperator", 1324 | "*=": "TSOperator", 1325 | "/=": "TSOperator", 1326 | "%=": "TSOperator", 1327 | "|=": "TSOperator", 1328 | "&=": "TSOperator", 1329 | "--": "TSOperator", 1330 | "++": "TSOperator", 1331 | }, 1332 | "python": { 1333 | "-": "TSOperator", 1334 | "-=": "TSOperator", 1335 | ":=": "TSOperator", 1336 | "!=": "TSOperator", 1337 | "*": "TSOperator", 1338 | "**": "TSOperator", 1339 | "**=": "TSOperator", 1340 | "*=": "TSOperator", 1341 | "/": "TSOperator", 1342 | "//": "TSOperator", 1343 | "//=": "TSOperator", 1344 | "/=": "TSOperator", 1345 | "&": "TSOperator", 1346 | "&=": "TSOperator", 1347 | "%": "TSOperator", 1348 | "%=": "TSOperator", 1349 | "^": "TSOperator", 1350 | "^=": "TSOperator", 1351 | "+": "TSOperator", 1352 | "+=": "TSOperator", 1353 | "<": "TSOperator", 1354 | "<<": "TSOperator", 1355 | "<<=": "TSOperator", 1356 | "<=": "TSOperator", 1357 | "<>": "TSOperator", 1358 | "=": "TSOperator", 1359 | "==": "TSOperator", 1360 | ">": "TSOperator", 1361 | ">=": "TSOperator", 1362 | ">>": "TSOperator", 1363 | ">>=": "TSOperator", 1364 | "@": "TSOperator", 1365 | "@=": "TSOperator", 1366 | "|": "TSOperator", 1367 | "|=": "TSOperator", 1368 | "~": "TSOperator", 1369 | "->": "TSOperator", 1370 | "and": "TSKeywordOperator", 1371 | "in": "TSKeywordOperator", 1372 | "is": "TSKeywordOperator", 1373 | "not": "TSKeywordOperator", 1374 | "or": "TSKeywordOperator", 1375 | "del": "TSKeywordOperator", 1376 | "def": "TSKeywordFunction", 1377 | "lambda": "TSKeywordFunction", 1378 | "assert": "TSKeyword", 1379 | "async": "TSKeyword", 1380 | "await": "TSKeyword", 1381 | "class": "TSKeyword", 1382 | "except": "TSKeyword", 1383 | "exec": "TSKeyword", 1384 | "finally": "TSKeyword", 1385 | "global": "TSKeyword", 1386 | "nonlocal": "TSKeyword", 1387 | "pass": "TSKeyword", 1388 | "print": "TSKeyword", 1389 | "raise": "TSKeyword", 1390 | "try": "TSKeyword", 1391 | "with": "TSKeyword", 1392 | "as": "TSKeyword", 1393 | "return": "TSKeywordReturn", 1394 | "yield": "TSKeywordReturn", 1395 | "from": "TSInclude", 1396 | "import": "TSInclude", 1397 | "if": "TSConditional", 1398 | "elif": "TSConditional", 1399 | "else": "TSConditional", 1400 | "for": "TSRepeat", 1401 | "while": "TSRepeat", 1402 | "break": "TSRepeat", 1403 | "continue": "TSRepeat", 1404 | "(": "TSPunctBracket", 1405 | ")": "TSPunctBracket", 1406 | "[": "TSPunctBracket", 1407 | "]": "TSPunctBracket", 1408 | "{": "TSPunctBracket", 1409 | "}": "TSPunctBracket", 1410 | ",": "TSPunctDelimiter", 1411 | ".": "TSPunctDelimiter", 1412 | ":": "TSPunctDelimiter", 1413 | }, 1414 | "ruby": { 1415 | "alias": "TSKeyword", 1416 | "begin": "TSKeyword", 1417 | "break": "TSKeyword", 1418 | "class": "TSKeyword", 1419 | "def": "TSKeyword", 1420 | "do": "TSKeyword", 1421 | "end": "TSKeyword", 1422 | "ensure": "TSKeyword", 1423 | "module": "TSKeyword", 1424 | "next": "TSKeyword", 1425 | "rescue": "TSKeyword", 1426 | "retry": "TSKeyword", 1427 | "then": "TSKeyword", 1428 | "return": "TSKeywordReturn", 1429 | "yield": "TSKeywordReturn", 1430 | "and": "TSKeywordOperator", 1431 | "or": "TSKeywordOperator", 1432 | "in": "TSKeywordOperator", 1433 | "case": "TSConditional", 1434 | "else": "TSConditional", 1435 | "elsif": "TSConditional", 1436 | "if": "TSConditional", 1437 | "unless": "TSConditional", 1438 | "when": "TSConditional", 1439 | "for": "TSRepeat", 1440 | "until": "TSRepeat", 1441 | "while": "TSRepeat", 1442 | "defined?": "TSFunction", 1443 | "=": "TSOperator", 1444 | "=>": "TSOperator", 1445 | "->": "TSOperator", 1446 | "+": "TSOperator", 1447 | "-": "TSOperator", 1448 | "*": "TSOperator", 1449 | "/": "TSOperator", 1450 | ",": "TSPunctDelimiter", 1451 | ";": "TSPunctDelimiter", 1452 | ".": "TSPunctDelimiter", 1453 | "(": "TSPunctBracket", 1454 | ")": "TSPunctBracket", 1455 | "[": "TSPunctBracket", 1456 | "]": "TSPunctBracket", 1457 | "{": "TSPunctBracket", 1458 | "}": "TSPunctBracket", 1459 | "%w(": "TSPunctBracket", 1460 | "%i(": "TSPunctBracket", 1461 | }, 1462 | "rust": { 1463 | "$": "TSFunctionMacro", 1464 | "(": "TSPunctBracket", 1465 | ")": "TSPunctBracket", 1466 | "[": "TSPunctBracket", 1467 | "]": "TSPunctBracket", 1468 | "{": "TSPunctBracket", 1469 | "}": "TSPunctBracket", 1470 | "::": "TSPunctDelimiter", 1471 | ".": "TSPunctDelimiter", 1472 | ";": "TSPunctDelimiter", 1473 | ",": "TSPunctDelimiter", 1474 | "use": "TSInclude", 1475 | "mod": "TSInclude", 1476 | "break": "TSKeyword", 1477 | "const": "TSKeyword", 1478 | "default": "TSKeyword", 1479 | "dyn": "TSKeyword", 1480 | "enum": "TSKeyword", 1481 | "extern": "TSKeyword", 1482 | "impl": "TSKeyword", 1483 | "let": "TSKeyword", 1484 | "macro_rules!": "TSKeyword", 1485 | "match": "TSKeyword", 1486 | "move": "TSKeyword", 1487 | "pub": "TSKeyword", 1488 | "ref": "TSKeyword", 1489 | "static": "TSKeyword", 1490 | "struct": "TSKeyword", 1491 | "trait": "TSKeyword", 1492 | "type": "TSKeyword", 1493 | "union": "TSKeyword", 1494 | "unsafe": "TSKeyword", 1495 | "async": "TSKeyword", 1496 | "await": "TSKeyword", 1497 | "where": "TSKeyword", 1498 | "return": "TSKeywordReturn", 1499 | "fn": "TSKeywordFunction", 1500 | "continue": "TSConditional", 1501 | "else": "TSConditional", 1502 | "if": "TSConditional", 1503 | "for": "TSRepeat", 1504 | "in": "TSRepeat", 1505 | "loop": "TSRepeat", 1506 | "while": "TSRepeat", 1507 | "as": "TSKeywordOperator", 1508 | "*": "TSOperator", 1509 | "'": "TSOperator", 1510 | "->": "TSOperator", 1511 | "=>": "TSOperator", 1512 | "<=": "TSOperator", 1513 | "=": "TSOperator", 1514 | "==": "TSOperator", 1515 | "!": "TSOperator", 1516 | "!=": "TSOperator", 1517 | "%": "TSOperator", 1518 | "%=": "TSOperator", 1519 | "&": "TSOperator", 1520 | "&=": "TSOperator", 1521 | "&&": "TSOperator", 1522 | "|": "TSOperator", 1523 | "|=": "TSOperator", 1524 | "||": "TSOperator", 1525 | "^": "TSOperator", 1526 | "^=": "TSOperator", 1527 | "*=": "TSOperator", 1528 | "-": "TSOperator", 1529 | "-=": "TSOperator", 1530 | "+": "TSOperator", 1531 | "+=": "TSOperator", 1532 | "/": "TSOperator", 1533 | "/=": "TSOperator", 1534 | ">": "TSOperator", 1535 | "<": "TSOperator", 1536 | ">=": "TSOperator", 1537 | ">>": "TSOperator", 1538 | "<<": "TSOperator", 1539 | ">>=": "TSOperator", 1540 | "@": "TSOperator", 1541 | "..": "TSOperator", 1542 | "..=": "TSOperator", 1543 | "?": "TSOperator", 1544 | }, 1545 | "svelte": { 1546 | "<": "TSTagDelimiter", 1547 | ">": "TSTagDelimiter", 1548 | "": "TSTagDelimiter", 1550 | "=": "TSOperator", 1551 | "{": "TSPunctBracket", 1552 | "}": "TSPunctBracket", 1553 | "#": "TSTagDelimiter", 1554 | ":": "TSTagDelimiter", 1555 | "/": "TSTagDelimiter", 1556 | "@": "TSTagDelimiter", 1557 | }, 1558 | "toml": { 1559 | }, 1560 | "tsx": { 1561 | "abstract": "TSKeyword", 1562 | "declare": "TSKeyword", 1563 | "enum": "TSKeyword", 1564 | "export": "TSKeyword", 1565 | "implements": "TSKeyword", 1566 | "interface": "TSKeyword", 1567 | "keyof": "TSKeyword", 1568 | "namespace": "TSKeyword", 1569 | "private": "TSKeyword", 1570 | "protected": "TSKeyword", 1571 | "public": "TSKeyword", 1572 | "type": "TSKeyword", 1573 | "readonly": "TSKeyword", 1574 | }, 1575 | "typescript": { 1576 | "...": "TSPunctSpecial", 1577 | ";": "TSPunctDelimiter", 1578 | ".": "TSPunctDelimiter", 1579 | ",": "TSPunctDelimiter", 1580 | "?.": "TSPunctDelimiter", 1581 | "--": "TSOperator", 1582 | "-": "TSOperator", 1583 | "-=": "TSOperator", 1584 | "&&": "TSOperator", 1585 | "+": "TSOperator", 1586 | "++": "TSOperator", 1587 | "+=": "TSOperator", 1588 | "&=": "TSOperator", 1589 | "/=": "TSOperator", 1590 | "**=": "TSOperator", 1591 | "<<=": "TSOperator", 1592 | "<": "TSOperator", 1593 | "<=": "TSOperator", 1594 | "<<": "TSOperator", 1595 | "=": "TSOperator", 1596 | "==": "TSOperator", 1597 | "===": "TSOperator", 1598 | "!=": "TSOperator", 1599 | "!==": "TSOperator", 1600 | "=>": "TSOperator", 1601 | ">": "TSOperator", 1602 | ">=": "TSOperator", 1603 | ">>": "TSOperator", 1604 | "||": "TSOperator", 1605 | "%": "TSOperator", 1606 | "%=": "TSOperator", 1607 | "*": "TSOperator", 1608 | "**": "TSOperator", 1609 | ">>>": "TSOperator", 1610 | "&": "TSOperator", 1611 | "|": "TSOperator", 1612 | "^": "TSOperator", 1613 | "??": "TSOperator", 1614 | "*=": "TSOperator", 1615 | ">>=": "TSOperator", 1616 | ">>>=": "TSOperator", 1617 | "^=": "TSOperator", 1618 | "|=": "TSOperator", 1619 | "&&=": "TSOperator", 1620 | "||=": "TSOperator", 1621 | "??=": "TSOperator", 1622 | "(": "TSPunctBracket", 1623 | ")": "TSPunctBracket", 1624 | "[": "TSPunctBracket", 1625 | "]": "TSPunctBracket", 1626 | "{": "TSPunctBracket", 1627 | "}": "TSPunctBracket", 1628 | "if": "TSConditional", 1629 | "else": "TSConditional", 1630 | "switch": "TSConditional", 1631 | "case": "TSConditional", 1632 | "default": "TSConditional", 1633 | "import": "TSInclude", 1634 | "from": "TSInclude", 1635 | "as": "TSInclude", 1636 | "for": "TSRepeat", 1637 | "of": "TSRepeat", 1638 | "do": "TSRepeat", 1639 | "while": "TSRepeat", 1640 | "continue": "TSRepeat", 1641 | "async": "TSKeyword", 1642 | "await": "TSKeyword", 1643 | "break": "TSKeyword", 1644 | "class": "TSKeyword", 1645 | "const": "TSKeyword", 1646 | "debugger": "TSKeyword", 1647 | "export": "TSKeyword", 1648 | "extends": "TSKeyword", 1649 | "get": "TSKeyword", 1650 | "in": "TSKeyword", 1651 | "instanceof": "TSKeyword", 1652 | "let": "TSKeyword", 1653 | "set": "TSKeyword", 1654 | "static": "TSKeyword", 1655 | "target": "TSKeyword", 1656 | "typeof": "TSKeyword", 1657 | "var": "TSKeyword", 1658 | "void": "TSKeyword", 1659 | "with": "TSKeyword", 1660 | "return": "TSKeywordReturn", 1661 | "yield": "TSKeywordReturn", 1662 | "function": "TSKeywordFunction", 1663 | "new": "TSKeywordOperator", 1664 | "delete": "TSKeywordOperator", 1665 | "throw": "TSException", 1666 | "try": "TSException", 1667 | "catch": "TSException", 1668 | "finally": "TSException", 1669 | "abstract": "TSKeyword", 1670 | "declare": "TSKeyword", 1671 | "enum": "TSKeyword", 1672 | "implements": "TSKeyword", 1673 | "interface": "TSKeyword", 1674 | "keyof": "TSKeyword", 1675 | "namespace": "TSKeyword", 1676 | "private": "TSKeyword", 1677 | "protected": "TSKeyword", 1678 | "public": "TSKeyword", 1679 | "type": "TSKeyword", 1680 | "readonly": "TSKeyword", 1681 | }, 1682 | "yaml": { 1683 | ",": "TSPunctDelimiter", 1684 | "-": "TSPunctDelimiter", 1685 | ":": "TSPunctDelimiter", 1686 | ">": "TSPunctDelimiter", 1687 | "?": "TSPunctDelimiter", 1688 | "|": "TSPunctDelimiter", 1689 | "[": "TSPunctBracket", 1690 | "]": "TSPunctBracket", 1691 | "{": "TSPunctBracket", 1692 | "}": "TSPunctBracket", 1693 | "*": "TSPunctSpecial", 1694 | "&": "TSPunctSpecial", 1695 | }, 1696 | } 1697 | --------------------------------------------------------------------------------