1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2025-07-03 01:59:26 +00:00

[neovim] Refactor

This commit is contained in:
2025-02-21 16:24:32 +01:00
parent b8fcf02379
commit 8d7675acf4
8 changed files with 67 additions and 38 deletions

View File

@ -6,7 +6,7 @@ vim.api.nvim_create_autocmd("TextYankPost", {
})
-- resize splits if window got resized
vim.api.nvim_create_autocmd({ "VimResized" }, {
vim.api.nvim_create_autocmd("VimResized", {
callback = function()
local current_tab = vim.fn.tabpagenr()
vim.cmd("tabdo wincmd =")
@ -15,7 +15,7 @@ vim.api.nvim_create_autocmd({ "VimResized" }, {
})
-- Set expandtab=true in several file types
vim.api.nvim_create_autocmd({ "FileType" }, {
vim.api.nvim_create_autocmd("FileType", {
pattern = { "go", "makefile", "lua" },
callback = function()
vim.opt_local.expandtab = false
@ -23,19 +23,33 @@ vim.api.nvim_create_autocmd({ "FileType" }, {
})
-- Use 'q' to quit from common plugins
vim.api.nvim_create_autocmd({ "FileType" }, {
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"PlenaryTestPopup",
"checkhealth",
"dbout",
"gitsigns-blame",
"grug-far",
"help",
"lspinfo",
"man",
"neotest-output",
"neotest-output-panel",
"neotest-summary",
"notify",
"qf",
"query",
"checkhealth",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
vim.schedule(function()
vim.keymap.set("n", "q", function()
vim.cmd("close")
pcall(vim.api.nvim_buf_delete, event.buf, { force = true })
end, {
buffer = event.buf,
silent = true,
desc = "Quit buffer",
})
end)
end,
})
@ -48,14 +62,10 @@ vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
]])
end,
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "hcl",
command = "setlocal shiftwidth=2 tabstop=2",
})
-- helm files indentation
-- Set hcl and helm indentation to 2
vim.api.nvim_create_autocmd("FileType", {
pattern = "helm",
pattern = { "hcl", "helm" },
command = "setlocal shiftwidth=2 tabstop=2",
})

View File

@ -131,6 +131,12 @@ keymap(
"<cmd>Lspsaga peek_definition<cr>",
vim.tbl_extend("force", opts, { desc = "Peek the definition of the directive under the cursor" })
)
keymap(
"n",
"<leader>lt",
"<cmd>Lspsaga peek_type_definition<cr>",
vim.tbl_extend("force", opts, { desc = "Peek the type definition of the directive under the cursor" })
)
keymap({ "n", "v" }, "<leader>lf", function()
require("conform").format({ async = true, lsp_fallback = true })
end, vim.tbl_extend("force", opts, { desc = "Format the current buffer or selection" }))
@ -152,10 +158,6 @@ keymap(
)
-- Copilot
keymap({ "n", "v" }, "<leader>coh", function()
local actions = require("CopilotChat.actions")
require("CopilotChat.integrations.telescope").pick(actions.help_actions())
end, vim.tbl_extend("force", opts, { desc = "CopilotChat - Help actions" }))
keymap({ "n", "v" }, "<leader>cop", function()
local actions = require("CopilotChat.actions")
require("CopilotChat.integrations.telescope").pick(actions.prompt_actions())

View File

@ -264,9 +264,6 @@ require("lazy").setup({
version = "v7",
},
{ "mzlogin/vim-markdown-toc" },
{
"jghauser/follow-md-links.nvim",
},
-- Copilot
{
@ -288,6 +285,7 @@ require("lazy").setup({
{
"copilotc-nvim/copilotchat.nvim",
branch = "main",
build = "make tiktoken",
event = "VeryLazy",
},