@@ -10,6 +10,16 @@ local M = {
10
10
latex = ' %%s' ,
11
11
}
12
12
13
+ local javascript_special_nodes = {
14
+ comment = { M .cxx_l , M .cxx_b },
15
+ jsx_attribute = { M .cxx_l , M .cxx_b },
16
+ jsx_element = { ' {/* %s */}' , ' {/* %s */}' },
17
+ jsx_fragment = { ' {/* %s */}' , ' {/* %s */}' },
18
+ jsx_opening_element = { M .cxx_l , M .cxx_b },
19
+ call_expression = { M .cxx_l , M .cxx_b },
20
+ statement_block = { M .cxx_l , M .cxx_b },
21
+ }
22
+
13
23
--- Lang table that contains commentstring (linewise/blockwise) for mutliple filetypes
14
24
--- @type table { filetype = { linewise , blockwise } }
15
25
local L = {
@@ -28,28 +38,8 @@ local L = {
28
38
html = { M .html_b , M .html_b },
29
39
idris = { M .dash , M .haskell_b },
30
40
java = { M .cxx_l , M .cxx_b },
31
- javascript = {
32
- M .cxx_l ,
33
- M .cxx_b ,
34
-
35
- jsx_fragment = { ' {/* %s */}' },
36
- jsx_element = { ' {/* %s */}' },
37
- jsx_attribute = { ' // %s' },
38
- jsx_expression = { ' // %s' , ' /*%s*/' },
39
- call_expression = { ' // %s' , ' /*%s*/' },
40
- statement_block = { ' // %s' },
41
- },
42
- javascriptreact = {
43
- M .cxx_l ,
44
- M .cxx_b ,
45
-
46
- jsx_fragment = { ' {/* %s */}' },
47
- jsx_element = { ' {/* %s */}' },
48
- jsx_attribute = { ' // %s' },
49
- jsx_expression = { ' // %s' , ' /*%s*/' },
50
- call_expression = { ' // %s' , ' /*%s*/' },
51
- statement_block = { ' // %s' },
52
- },
41
+ javascript = vim .tbl_deep_extend (' keep' , { M .cxx_l , M .cxx_b }, javascript_special_nodes ),
42
+ javascriptreact = vim .tbl_deep_extend (' keep' , { M .cxx_l , M .cxx_b }, javascript_special_nodes ),
53
43
julia = { M .hash , ' #=%s=#' },
54
44
lidris = { M .dash , M .haskell_b },
55
45
lua = { M .dash , ' --[[%s--]]' },
@@ -67,8 +57,8 @@ local L = {
67
57
terraform = { M .hash , M .cxx_b },
68
58
tex = { M .latex },
69
59
toml = { M .hash },
70
- typescript = { M .cxx_l , M .cxx_b },
71
- typescriptreact = { M .cxx_l , M .cxx_b },
60
+ typescript = vim . tbl_deep_extend ( ' keep ' , { M .cxx_l , M .cxx_b }, javascript_special_nodes ) ,
61
+ typescriptreact = vim . tbl_deep_extend ( ' keep ' , { M .cxx_l , M .cxx_b }, javascript_special_nodes ) ,
72
62
vim = { ' "%s' },
73
63
xml = { M .html_b , M .html_b },
74
64
yaml = { M .hash },
@@ -91,16 +81,17 @@ return setmetatable({}, {
91
81
end ,
92
82
93
83
calculate = function (ctx )
84
+ P (ctx )
94
85
local lang = L [ctx .lang ]
95
86
if not lang then
96
87
return
97
88
end
98
89
99
- if not ctx .contained then
90
+ if not ctx .node then
100
91
return lang [ctx .ctype ] or lang [1 ]
101
92
end
102
93
103
- local config = lang [ctx .contained :type ()]
94
+ local config = lang [ctx .node :type ()]
104
95
if not config then
105
96
return lang [ctx .ctype ] or lang [1 ]
106
97
end
0 commit comments