comment hotkeys + manager
This commit is contained in:
parent
8a1f67d50f
commit
e31fb9b976
29
lua/configs/comment.lua
Normal file
29
lua/configs/comment.lua
Normal file
@ -0,0 +1,29 @@
|
||||
local M = {}
|
||||
|
||||
function M.config()
|
||||
local status_ok, comment = pcall(require, "Comment")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
return M
|
||||
|
@ -25,4 +25,7 @@ map("n", "<S-h>", "<cmd>bprevious<CR>", opts)
|
||||
map('n', '<leader>e', '<cmd>NvimTreeToggle<CR>', opts)
|
||||
map('n', '<leader>o', '<cmd>NvimTreeFocus<CR>', opts)
|
||||
|
||||
-- Comment
|
||||
map('n', '<leader>/', '<cmd>lua require(\'Comment.api\').toggle_current_linewise()<CR>', opts)
|
||||
map('v', '<leader>/', '<esc><cmd>lua require(\'Comment.api\').toggle_linewise_op(vim.fn.visualmode())<CR>', opts)
|
||||
|
||||
|
@ -92,6 +92,9 @@ packer.startup {
|
||||
-- Quality of Life
|
||||
--
|
||||
|
||||
-- Commenting
|
||||
use { 'numToStr/Comment.nvim', config = function() require'configs.comment'.config() end }
|
||||
|
||||
-- Automatically colorize color strings (#f1b8f1)
|
||||
use { 'norcalli/nvim-colorizer.lua', config = function() require'configs.colorizer'.config() end }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user