summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/user/comment.lua22
-rw-r--r--lua/user/keymaps.lua4
-rw-r--r--lua/user/plugins.lua2
-rw-r--r--lua/user/treesitter.lua8
4 files changed, 34 insertions, 2 deletions
diff --git a/lua/user/comment.lua b/lua/user/comment.lua
new file mode 100644
index 0000000..2fa4a56
--- /dev/null
+++ b/lua/user/comment.lua
@@ -0,0 +1,22 @@
+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,
+}
diff --git a/lua/user/keymaps.lua b/lua/user/keymaps.lua
index fb8fdb4..9534dec 100644
--- a/lua/user/keymaps.lua
+++ b/lua/user/keymaps.lua
@@ -68,3 +68,7 @@ keymap("t", "<C-h>", "<C-\\><C-N><C-w>h", term_opts)
keymap("t", "<C-j>", "<C-\\><C-N><C-w>j", term_opts)
keymap("t", "<C-k>", "<C-\\><C-N><C-w>k", term_opts)
keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", term_opts)
+
+-- Comment
+keymap("n", "<leader>/", "<cmd>lua require('Comment').toggle()<CR>", opts)
+keymap("v", "<leader>/", ":lua require(\"Comment.api\").gc(vim.fn.visualmode())<cr>", opts)
diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua
index 74fcb73..3e2c87c 100644
--- a/lua/user/plugins.lua
+++ b/lua/user/plugins.lua
@@ -45,6 +45,7 @@ return packer.startup(function(use)
use "nvim-lua/popup.nvim" -- An implementation of the Popup API from vim in Neovim
use "nvim-lua/plenary.nvim" -- Useful lua functions used ny lots of plugins
use "windwp/nvim-autopairs" -- Autopairs, integrates with both cmp and treesitter
+ use "numToStr/Comment.nvim" -- Easily comment stuff
-- Colorschemes
-- use "lunarvim/colorschemes" -- A bunch of colorschemes you can try out
@@ -75,6 +76,7 @@ return packer.startup(function(use)
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate",
}
+ use 'JoosepAlviste/nvim-ts-context-commentstring'
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
diff --git a/lua/user/treesitter.lua b/lua/user/treesitter.lua
index b5754d6..6f14cfc 100644
--- a/lua/user/treesitter.lua
+++ b/lua/user/treesitter.lua
@@ -8,12 +8,16 @@ configs.setup {
sync_install = false, -- install languages synchronously (only applied to `ensure_installed`)
ignore_install = { "" }, -- List of parsers to ignore installing
autopairs = {
- enable = true,
- },
+ enable = true,
+ },
highlight = {
enable = true, -- false will disable the whole extension
disable = { "" }, -- list of language that will be disabled
additional_vim_regex_highlighting = true,
},
indent = { enable = true, disable = { "yaml" } },
+ context_commentstring = {
+ enable = true,
+ enable_autocmd = false,
+ },
}