mirror of
https://github.com/dcarrillo/dotfiles.git
synced 2025-07-02 21:19:25 +00:00
[neovim] Refactor
This commit is contained in:
@ -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",
|
||||
})
|
||||
|
||||
|
@ -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())
|
||||
|
@ -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",
|
||||
},
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
require("avante").setup({
|
||||
provider = "copilot",
|
||||
-- provider = "copilot",
|
||||
provider = "claude",
|
||||
claude = {
|
||||
api_key_name = "cmd:secret-tool lookup description ANTHROPIC_API_KEY",
|
||||
},
|
||||
web_search_engine = {
|
||||
provider = "tavily",
|
||||
},
|
||||
|
@ -15,6 +15,10 @@ require("blink.cmp").setup({
|
||||
enabled = false,
|
||||
},
|
||||
},
|
||||
documentation = {
|
||||
auto_show = true,
|
||||
auto_show_delay_ms = 200,
|
||||
},
|
||||
menu = {
|
||||
-- don't show completion menu automatically when searching
|
||||
auto_show = function(ctx)
|
||||
|
@ -28,10 +28,18 @@ local prompts = {
|
||||
|
||||
require("CopilotChat").setup({
|
||||
highlight_headers = false,
|
||||
separator = "———",
|
||||
-- separator = "———",
|
||||
error_header = "> [!ERROR] Error",
|
||||
debug = false,
|
||||
show_user_selection = false,
|
||||
clear_chat_on_new_prompt = false,
|
||||
prompts = prompts,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
pattern = "copilot-chat",
|
||||
callback = function()
|
||||
vim.opt_local.relativenumber = false
|
||||
vim.opt_local.number = false
|
||||
end,
|
||||
})
|
||||
|
@ -7,6 +7,7 @@ require("nvim-treesitter.configs").setup({
|
||||
"gomod",
|
||||
"gosum",
|
||||
"gowork",
|
||||
"helm",
|
||||
"java",
|
||||
"javascript",
|
||||
"json",
|
||||
|
Reference in New Issue
Block a user