nvim: comment.nvim + treesitter

This commit is contained in:
PowerUser64 2022-01-08 05:18:04 -08:00
parent a542d40a10
commit 68259adac0

View file

@ -95,7 +95,7 @@ return require('packer').startup({function()
context_commentstring = {
enable = true,
enable_autocmd = false,
}
},
}
end,
}
@ -277,28 +277,35 @@ return require('packer').startup({function()
use { -- cheat.sh integration
'dbeniamine/cheat.sh-vim',
}
-- use { -- Comments (gb and gc)
-- 'numToStr/Comment.nvim',
-- config = function()
-- require('Comment').setup {
-- pre_hook = function(ctx)
-- local U = require 'Comment.utils'
--
-- 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 = ctx.ctype == U.ctype.line and '__default' or '__multiline',
-- location = location,
-- }
-- end,
-- }
-- end
-- }
use { -- Comments (gb and gc)
'numToStr/Comment.nvim',
config = function()
require('Comment').setup {
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,
}
end
}
-- use { -- lewis6991: spellsitter: Spell checking in treesitter files
-- 'lewis6991/spellsitter.nvim',
-- config = function()
@ -317,9 +324,6 @@ return require('packer').startup({function()
require('foldsigns').setup()
end,
}
use { -- tpope: commentary
'tpope/vim-commentary',
}
use { -- tpope: surround
'tpope/vim-surround'
}