This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathinit.lua
94 lines (82 loc) · 2.57 KB
/
init.lua
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
local comment = {}
comment.settings = {
--- Add a space b/w comment and the line
--- @type boolean
padding = true,
--- Whether the cursor should stay at its position
--- NOTE: This only affects NORMAL mode mappings and doesn't work with dot-repeat
--- @type boolean
sticky = true,
--- Lines to be ignored while comment/uncomment.
--- Could be a regex string or a function that returns a regex string.
--- Example: Use '^$' to ignore empty lines
--- @type string|fun():string
ignore = nil,
--- Passes to ts-context-commentstring to get commentstring in JSX
pre_hook = function(ctx)
-- Only calculate commentstring for tsx filetypes
if vim.bo.filetype == "typescriptreact" then
local comment_utils = require("Comment.utils")
-- Detemine whether to use linewise or blockwise commentstring
local type = ctx.ctype == comment_utils.ctype.line and "__default" or "__multiline"
-- Determine the location where to calculate commentstring from
local location = nil
if ctx.ctype == comment_utils.ctype.block then
location = require("ts_context_commentstring.utils").get_cursor_location()
elseif ctx.cmotion == comment_utils.cmotion.v or ctx.cmotion == comment_utils.cmotion.V then
location = require("ts_context_commentstring.utils").get_visual_start_location()
end
return require("ts_context_commentstring.internal").calculate_commentstring({
key = type,
location = location,
})
end
end,
}
comment.packages = {
["Comment.nvim"] = {
"numToStr/Comment.nvim",
},
}
comment.configs = {}
comment.configs["Comment.nvim"] = function()
local config = vim.tbl_extend("force", doom.features.comment.settings, {
-- Disable mappings as we'll handle it in binds.lua
mappings = {
basic = false,
extra = false,
extended = false,
},
})
require("Comment").setup(config)
end
comment.binds = {
{
"gc",
[[<cmd>lua require("Comment.api").call('toggle.linewise', '@g')<CR>]],
name = "Comment motion",
},
{
"gc",
[[<Esc><cmd>lua require("Comment.api").toggle.linewise(vim.fn.visualmode())<CR>]],
name = "Comment line",
mode = "v",
},
{
"gb",
[[<Esc><cmd>lua require("Comment.api").toggle.blockwise(vim.fn.visualmode())<CR>]],
name = "Comment block",
mode = "v",
},
{
"gcc",
[[<cmd>lua require("Comment.api").toggle.linewise.current()<CR>]],
name = "Comment line",
},
{
"gcA",
[[<cmd>lua require("Comment.api").insert.linewise.eol()<CR>]],
name = "Comment end of line",
},
}
return comment