feat(plugins): switch to Comment.nvim
This commit is contained in:
parent
0ffbbf00d9
commit
efb15a9c55
3 changed files with 33 additions and 2 deletions
|
@ -71,6 +71,9 @@ config.lsp = {
|
||||||
-- See https://github.com/rmagatti/auto-session#%EF%B8%8F-configuration
|
-- See https://github.com/rmagatti/auto-session#%EF%B8%8F-configuration
|
||||||
config.auto_session = {}
|
config.auto_session = {}
|
||||||
|
|
||||||
|
-- https://github.com/numToStr/Comment.nvim#configuration-optional
|
||||||
|
config.comments = {}
|
||||||
|
|
||||||
-- See https://github.com/folke/todo-comments.nvim#%EF%B8%8F-configuration
|
-- See https://github.com/folke/todo-comments.nvim#%EF%B8%8F-configuration
|
||||||
config.todo_comments = {}
|
config.todo_comments = {}
|
||||||
|
|
||||||
|
|
|
@ -225,9 +225,11 @@ return packer.startup(function()
|
||||||
|
|
||||||
-- comments and stuff
|
-- comments and stuff
|
||||||
use({
|
use({
|
||||||
'b3nj5m1n/kommentary',
|
'numToStr/Comment.nvim',
|
||||||
|
config = function()
|
||||||
|
require('cosmic.plugins.comments')
|
||||||
|
end,
|
||||||
event = 'BufWinEnter',
|
event = 'BufWinEnter',
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'kommentary'),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- todo highlights
|
-- todo highlights
|
||||||
|
|
26
lua/cosmic/plugins/comments/init.lua
Normal file
26
lua/cosmic/plugins/comments/init.lua
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
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()
|
||||||
|
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.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,
|
||||||
|
}, config.comments or {}))
|
Loading…
Add table
Reference in a new issue