nvim: replace comment plugin

This commit is contained in:
tastytea 2022-08-16 02:49:33 +02:00
parent 15c21ad586
commit 2730bb8c55
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
3 changed files with 43 additions and 5 deletions

View File

@ -2,9 +2,39 @@ require('my/plugins')
require('my/keymaps')
require('my/tools')
vim.g.tcomment_opleader1 = '<Leader>c'
vim.g.tcomment_mapleader1 = ''
vim.g.tcomment_mapleader2 = ''
require('Comment').setup({
toggler = {
line = '<Leader>cc',
block = '<Leader>CC'
},
opleader = {
line = '<Leader>c',
block = '<Leader>C'
},
extra = {
above = '<Leader>cO',
below = '<Leader>co',
eol = '<Leader>cA',
},
pre_hook = function(ctx)
local comment_utils = require "Comment.utils"
local context_utils = require('ts_context_commentstring.utils')
local context_internal = require('ts_context_commentstring.internal')
local location = nil
if ctx.ctype == comment_utils.ctype.blockwise then
location = context_utils.get_cursor_location()
elseif ctx.cmotion == comment_utils.cmotion.v or ctx.cmotion == comment_utils.cmotion.V then
location = context_utils.utils.get_visual_start_location()
end
return context_internal.calculate_commentstring {
key = ctx.ctype == comment_utils.ctype.linewise and "__default" or "__multiline",
location = location,
}
end
})
map('i', '<M-c>', '<Leader>cA')
local neogit = require('neogit')
neogit.setup {

View File

@ -6,6 +6,10 @@ require'nvim-treesitter.configs'.setup {
enable = true,
additional_vim_regex_highlighting = { 'org' }
},
context_commentstring = {
enable = true,
enable_autocmd = false -- handled by Comment
}
}
require('orgmode').setup{}

View File

@ -28,6 +28,10 @@ require('packer').startup(function(use)
tag = '*',
requires = 'https://github.com/nvim-treesitter/nvim-treesitter'
}
use {
'https://github.com/JoosepAlviste/nvim-ts-context-commentstring',
requires = 'https://github.com/nvim-treesitter/nvim-treesitter'
}
-- completion
use {
@ -77,8 +81,8 @@ require('packer').startup(function(use)
-- coding
use {
'https://github.com/tomtom/tcomment_vim',
-- tag = '*' -- NOTE: reactivate when tagged after 2022-08-15
'https://github.com/numToStr/Comment.nvim',
tag = '*'
}
use {
'https://github.com/TimUntersberger/neogit',