From 8a5e461840fd5b873aa509b0550e2667a691e755 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Mon, 22 Jul 2024 18:02:02 +0200 Subject: [PATCH] Update .gitmodules Update .config/nvim/init.lua Add .config/nvim/pack/plugins/start/chadtree --- .gitmodules | 3 +++ dot_config/nvim/init.lua | 24 ++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 043ed56..338ee2b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -17,3 +17,6 @@ [submodule "dot_config/nvim/pack/plugins/start/auto-pairs"] path = dot_config/nvim/pack/plugins/start/auto-pairs url = https://github.com/jiangmiao/auto-pairs +[submodule "dot_config/nvim/pack/plugins/start/chadtree"] + path = dot_config/nvim/pack/plugins/start/chadtree + url = https://github.com/ms-jpq/chadtree diff --git a/dot_config/nvim/init.lua b/dot_config/nvim/init.lua index 5ce7ec6..29d9428 100644 --- a/dot_config/nvim/init.lua +++ b/dot_config/nvim/init.lua @@ -3,6 +3,9 @@ vim.cmd.colorscheme "catppuccin-frappe" vim.g.mapleader = " " vim.wo.relativenumber = true +-- CHADTree +vim.api.nvim_set_keymap('n', 'v', 'CHADopen', { noremap = true, silent = true }) + -- Telescope local builtin = require('telescope.builtin') vim.keymap.set('n', 'ff', builtin.find_files, {}) @@ -70,5 +73,22 @@ vim.api.nvim_create_autocmd("LspAttach", { end, }) --- Formatting -vim.api.nvim_set_keymap('n', 'qf', 'lua vim.lsp.buf.format()', { noremap = true, silent = true }) +-- Function to format the current buffer on save +local function lsp_format_on_save(bufnr) + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ async = false }) + end, + }) +end + +-- Create an autocmd for LspAttach event +vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local bufnr = args.buf + -- Set up the buffer-local autocmd for formatting on save + lsp_format_on_save(bufnr) + end, +}) +