feat(plugins): utilize ts_context_commentstring for all filetypes
This commit is contained in:
parent
74a287d897
commit
a957874880
2 changed files with 12 additions and 19 deletions
|
@ -2,14 +2,7 @@ local config = require('cosmic.config')
|
||||||
|
|
||||||
require('Comment').setup(vim.tbl_deep_extend('force', {
|
require('Comment').setup(vim.tbl_deep_extend('force', {
|
||||||
pre_hook = function(ctx)
|
pre_hook = function(ctx)
|
||||||
-- Only calculate commentstring for tsx filetypes
|
|
||||||
if vim.bo.filetype == 'typescriptreact' then
|
|
||||||
local U = require('Comment.utils')
|
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
|
local location = nil
|
||||||
if ctx.ctype == U.ctype.block then
|
if ctx.ctype == U.ctype.block then
|
||||||
location = require('ts_context_commentstring.utils').get_cursor_location()
|
location = require('ts_context_commentstring.utils').get_cursor_location()
|
||||||
|
@ -18,9 +11,8 @@ require('Comment').setup(vim.tbl_deep_extend('force', {
|
||||||
end
|
end
|
||||||
|
|
||||||
return require('ts_context_commentstring.internal').calculate_commentstring({
|
return require('ts_context_commentstring.internal').calculate_commentstring({
|
||||||
key = type,
|
key = ctx.ctype == U.ctype.line and '__default' or '__multiline',
|
||||||
location = location,
|
location = location,
|
||||||
})
|
})
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
}, config.comments or {}))
|
}, config.comments or {}))
|
||||||
|
|
|
@ -27,6 +27,7 @@ local defaults = {
|
||||||
},
|
},
|
||||||
context_commentstring = {
|
context_commentstring = {
|
||||||
enable = true,
|
enable = true,
|
||||||
|
enable_autocmd = false,
|
||||||
},
|
},
|
||||||
refactor = {
|
refactor = {
|
||||||
highlight_definitions = { enable = true },
|
highlight_definitions = { enable = true },
|
||||||
|
|
Loading…
Add table
Reference in a new issue