Adding Comments.nvim

This commit is contained in:
Zoe Roux
2022-03-10 14:35:44 +01:00
parent d5872ce741
commit 83274014ad
7 changed files with 45 additions and 12 deletions
+4 -4
View File
@@ -2,10 +2,10 @@ local M = {}
M.setup = function()
local signs = {
{ name = "DiagnosticSignError", text = "" },
{ name = "DiagnosticSignWarn", text = "" },
{ name = "DiagnosticSignInfo", text = "" },
{ name = "DiagnosticSignHint", text = "" },
{ name = "DiagnosticSignError", text = "" },
{ name = "DiagnosticSignWarn", text = "" },
{ name = "DiagnosticSignHint", text = "" },
{ name = "DiagnosticSignInfo", text = "" },
}
for _, sign in ipairs(signs) do
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
+4 -2
View File
@@ -44,7 +44,6 @@ return packer.startup(function(use)
use "tpope/vim-surround"
use "tpope/vim-unimpaired"
use "tpope/vim-commentary"
use "tpope/vim-speeddating"
use "tpope/vim-repeat"
@@ -63,7 +62,6 @@ return packer.startup(function(use)
'neovim/nvim-lspconfig',
'williamboman/nvim-lsp-installer',
}
use { "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" }
use {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
@@ -73,6 +71,10 @@ return packer.startup(function(use)
"L3MON4D3/LuaSnip",
}
use { "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" }
use "numToStr/Comment.nvim"
use "JoosepAlviste/nvim-ts-context-commentstring"
use { "lukas-reineke/virt-column.nvim", config = function() require("virt-column").setup() end }
use "lukas-reineke/indent-blankline.nvim"
+5 -4
View File
@@ -53,12 +53,13 @@ keymap("v", "<", "<gv", opts)
keymap("v", ">", ">gv", opts)
-- Move in insert mode --
keymap("i", "<C-j>", "<Down>", opts)
keymap("i", "<C-k>", "<Up>", opts)
keymap("i", "<C-h>", "<Left>", opts)
keymap("i", "<C-l>", "<Right>", opts)
keymap("i", "<A-j>", "<Down>", opts)
keymap("i", "<A-k>", "<Up>", opts)
keymap("i", "<A-h>", "<Left>", opts)
keymap("i", "<A-l>", "<Right>", opts)
keymap("i", "<C-BS>", "<C-w>", opts)
keymap("i", "<C-H>", "<C-w>", opts) -- Keymap for CTRL-BACKSPACE on some termial emulators.
vim.cmd [[ augroup highlight_yank
autocmd!
@@ -0,0 +1,26 @@
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,
ignore = '^$',
padding = true,
sticky = true,
})
@@ -1,3 +1,4 @@
require "treesitter.treesitter"
require "treesitter.indent-line"
require "treesitter.comments"
@@ -19,10 +19,12 @@ telescope.setup({
path_display = { "truncate" },
mappings = {
i = {
["<CR>"] = actions.file_edit
["<CR>"] = actions.file_edit,
["<A-k>"] = actions.move_selection_previous,
["<A-j>"] = actions.move_selection_next,
},
n = {
["<CR>"] = actions.file_edit
["<CR>"] = actions.file_edit,
},
},
},
@@ -12,6 +12,7 @@ wk.register({
l = {
d = { "<cmd>Trouble document_diagnostics<cr>", "Document Diagnostics" },
w = { "<cmd>Trouble workspace_diagnostics<cr>", "Workspace Diagnostics" },
t = { "<cmd>TroubleToggle<CR>", "Toogle trouble window" },
},
}, {
prefix = "<leader>",