about summary refs log tree commit diff
path: root/fnl/nvrc/packs/treesitter.fnl
blob: 3e725dd8571d6ca280b3519db9a94a33a4688fad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
(import-macros {: highlight!} :nvrc.macro.color)

(local {: setup} (require :nvim-treesitter.configs))

(setup {:ensure_installed [:fennel :lua :nix :rust :haskell :c :go :typst :comment]
        :highlight {:enable true :use_languagetree true}
        :incremental_selection {:enable true
                                :keymaps {:init_selection :gnn
                                          :node_incremental :grn
                                          :scope_incremental :grc
                                          :node_decremental :grm}}
        :refactor {:highlight_definitions {:enable true}
                   :highlight_current_scope {:enable false}
                   :smart_rename {:enable true :keymaps {:smart_rename :grr}}
                   :navigation {:enable true
                                :keymaps {:goto_definition :gnd
                                          :list_definitions :gnD
                                          :goto_next_usage :<M-2>
                                          :goto_previous_usage :<M-1>}}}
        :textobjects {:select {:enable true
                               :lookahead true
                               :keymaps {:af "@function.outer"
                                         :if "@function.inner"
                                         :aC "@class.outer"
                                         :iC "@class.inner"
                                         :ac "@conditional.outer"
                                         :ic "@conditional.inner"
                                         :ae "@block.outer"
                                         :ie "@block.inner"
                                         :al "@loop.outer"
                                         :il "@loop.inner"
                                         :is "@statement.inner"
                                         :as "@statement.outer"
                                         :ad "@comment.outer"
                                         :am "@call.outer"
                                         :im "@call.inner"}}
                      :swap {:enable true
                             :swap_next {:<M-l> "@parameter.inner"
                                         :<C-e> "@parameter.inner"
                                         :<M-j> "@function.outer"}
                             :swap_previous {:<M-h> "@parameter.inner"
                                             :<C-r> "@parameter.inner"
                                             :<M-k> "@function.outer"}}
                      :move {:enable true
                             :set_jumps true
                             :goto_next_start {"]f" "@function.outer"
                                               "][" "@class.outer"}
                             :goto_next_end {"]F" "@function.outer"
                                             "]]" "@class.outer"}
                             :goto_previous_start {"[f" "@function.outer"
                                                   "[[" "@class.outer"}
                             :goto_previous_end {"[F" "@function.outer"
                                                 "[]" "@class.outer"}}}
        :indent {:enable true}})

; Treesitter colour corrections
; Match jellybeans.vim colourscheme
(highlight! "@variable" {:link :Normal})

; (highlight! "@constant.builtin" {:link :Constant})
;
; (highlight! "@type.builtin" {:link :Type})

(highlight! "@keyword.modifier" {:link :StorageClass})
(highlight! "@keyword.directive" {:link :PreProc})
; (highlight! "@keyword.function" {:link :Define})

; (highlight! "@punctuation.delimiter" {:link :Normal})
(highlight! "@punctuation.bracket" {:link :Normal})

;; C/C++
(highlight! "@keyword.import.c" {:link :PreProc})
(highlight! "@keyword.import.cpp" {:link "@keyword.import.c"})

;; Ruby
(highlight! "@variable.member.ruby" {:link :rubyInstanceVariable})

(highlight! "@keyword.type.ruby" {:link :rubyClass})
(highlight! "@keyword.ruby" {:link :rubyClass})