mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-06 07:24:39 +02:00
feat(coding)!: use native comments on 0.10, with support for ts_context_commentstring
This commit is contained in:
parent
f02507b159
commit
d999be7401
2 changed files with 28 additions and 11 deletions
|
@ -210,18 +210,22 @@ return {
|
||||||
opts = {
|
opts = {
|
||||||
enable_autocmd = false,
|
enable_autocmd = false,
|
||||||
},
|
},
|
||||||
},
|
init = function()
|
||||||
{
|
if vim.fn.has("nvim-0.10") == 1 then
|
||||||
"echasnovski/mini.comment",
|
-- Majestically override the native `get_commentstring` function.
|
||||||
event = "VeryLazy",
|
vim.schedule(function()
|
||||||
opts = {
|
LazyVim.inject.set_upvalue(
|
||||||
options = {
|
LazyVim.inject.get_upvalue(require("vim._comment").textobject, "get_comment_parts"),
|
||||||
custom_commentstring = function()
|
"get_commentstring",
|
||||||
|
function()
|
||||||
return require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring
|
return require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
{ import = "lazyvim.plugins.extras.coding.mini-comment", enabled = vim.fn.has("nvim-0.10") == 0 },
|
||||||
},
|
|
||||||
|
|
||||||
-- Better text-objects
|
-- Better text-objects
|
||||||
{
|
{
|
||||||
|
|
13
lua/lazyvim/plugins/extras/coding/mini-comment.lua
Normal file
13
lua/lazyvim/plugins/extras/coding/mini-comment.lua
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
"echasnovski/mini.comment",
|
||||||
|
event = "VeryLazy",
|
||||||
|
opts = {
|
||||||
|
options = {
|
||||||
|
custom_commentstring = function()
|
||||||
|
return require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue