mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-24 09:48:59 +02:00
fix(comments): better way of using ts-context-commentstring with native comments
This commit is contained in:
parent
72abb893ac
commit
1d23c98da1
1 changed files with 10 additions and 16 deletions
|
@ -188,24 +188,18 @@ return {
|
||||||
opts = {
|
opts = {
|
||||||
enable_autocmd = false,
|
enable_autocmd = false,
|
||||||
},
|
},
|
||||||
},
|
init = function()
|
||||||
{
|
|
||||||
import = "lazyvim.plugins.extras.coding.mini-comment",
|
|
||||||
enabled = function()
|
|
||||||
if vim.fn.has("nvim-0.10") == 1 then
|
if vim.fn.has("nvim-0.10") == 1 then
|
||||||
-- Majestically override the native `get_commentstring` function.
|
local get_option = vim.filetype.get_option
|
||||||
vim.schedule(function()
|
vim.filetype.get_option = function(filetype, option)
|
||||||
LazyVim.inject.set_upvalue(
|
return option == "commentstring" and require("ts_context_commentstring.internal").calculate_commentstring()
|
||||||
LazyVim.inject.get_upvalue(require("vim._comment").textobject, "get_comment_parts"),
|
or get_option(filetype, option)
|
||||||
"get_commentstring",
|
|
||||||
function()
|
|
||||||
return require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring
|
|
||||||
end
|
end
|
||||||
)
|
|
||||||
end)
|
|
||||||
else
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
import = "lazyvim.plugins.extras.coding.mini-comment",
|
||||||
|
enabled = vim.fn.has("nvim-0.10") == 0,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue