feat(plugins): utilize ts_context_commentstring for all filetypes

This commit is contained in:
Matt Leong 2021-12-20 15:44:25 -08:00
parent 74a287d897
commit a957874880
2 changed files with 12 additions and 19 deletions

View file

@ -2,14 +2,7 @@ local config = require('cosmic.config')
require('Comment').setup(vim.tbl_deep_extend('force', {
pre_hook = function(ctx)
-- Only calculate commentstring for tsx filetypes
if vim.bo.filetype == 'typescriptreact' then
local U = require('Comment.utils')
-- Detemine whether to use linewise or blockwise commentstring
local type = ctx.ctype == U.ctype.line and '__default' or '__multiline'
-- Determine the location where to calculate commentstring from
local location = nil
if ctx.ctype == U.ctype.block then
location = require('ts_context_commentstring.utils').get_cursor_location()
@ -18,9 +11,8 @@ require('Comment').setup(vim.tbl_deep_extend('force', {
end
return require('ts_context_commentstring.internal').calculate_commentstring({
key = type,
key = ctx.ctype == U.ctype.line and '__default' or '__multiline',
location = location,
})
end
end,
}, config.comments or {}))

View file

@ -27,6 +27,7 @@ local defaults = {
},
context_commentstring = {
enable = true,
enable_autocmd = false,
},
refactor = {
highlight_definitions = { enable = true },