diff --git a/.config/nvim/lua/config/autocmds.lua b/.config/nvim/lua/config/autocmds.lua index 27e9e06..5b9bf50 100644 --- a/.config/nvim/lua/config/autocmds.lua +++ b/.config/nvim/lua/config/autocmds.lua @@ -1,3 +1,30 @@ --- Autocmds are automatically loaded on the VeryLazy event --- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua --- Add any additional autocmds here +local augroup = vim.api.nvim_create_augroup +local autocmd = vim.api.nvim_create_autocmd + +augroup("go_fmt", { clear = true }) + +autocmd("FileType", { + group = "go_fmt", + pattern = "go", + callback = function() + vim.api.nvim_buf_set_keymap( + 0, + "n", + "F", + ":lua FormatGoCurrentLine()", + { noremap = true, silent = true } + ) + end, +}) + +function FormatGoCurrentLine() + local line = vim.api.nvim_get_current_line() + local formatted_line = line:gsub("%(", "(\n"):gsub(",%s*", ",\n"):gsub("%)", ",\n)") + formatted_line = formatted_line:gsub(",\n%)", "\n)") + local lines = vim.split(formatted_line, "\n") + -- Ensure the last parameter has a comma + if #lines > 2 and not lines[#lines - 1]:match(",$") then + lines[#lines - 1] = lines[#lines - 1] .. "," + end + vim.api.nvim_buf_set_lines(0, vim.fn.line(".") - 1, vim.fn.line("."), false, lines) +end diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index f226058..8d45b66 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -1,8 +1,3 @@ --- Keymaps are automatically loaded on the VeryLazy event --- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua --- Add any additional keymaps here --- - local map = vim.keymap.set -- map("n", ";", ":", { desc = "CMD enter command mode" }) @@ -52,10 +47,17 @@ map("n", "P", function() require("powershell").toggle_term() end, { noremap = true }) --- Obsidian -map("", "of", " ObsidianFollowLink ", { desc = "Follow Link" }) -map("", "ol", " ObsidianLinks ", { desc = "Show All Links" }) - -- CodeCopmanion map("", "Ca", "CodeCompanionActions ", { desc = "CodeCompanion Actions" }) map("", "Cc", "CodeCompanionChat ", { desc = "CodeCompanion Chat" }) + +-- Custom +map("", "rw", '"hy:%s/h//g', { noremap = true, silent = true, desc = "Replace Word" }) + +map("", "rt", ":VtrSendLinesToRunner", { + noremap = true, + silent = true, + desc = "Send selected text to tmux pane", +}) + +map("", "rp", ":VtrAttachToPane", { noremap = true, silent = true, desc = "Attach to tmux pane" }) diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua index 3ea1454..0a70d88 100644 --- a/.config/nvim/lua/config/options.lua +++ b/.config/nvim/lua/config/options.lua @@ -1,3 +1,2 @@ --- Options are automatically loaded before lazy.nvim startup --- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua --- Add any additional options here +vim.api.nvim_set_option_value("colorcolumn", "70", {}) +vim.api.nvim_set_option_value("textwidth", 70, {}) diff --git a/.config/nvim/lua/plugins/nvchad.lua b/.config/nvim/lua/plugins/debug.lua similarity index 100% rename from .config/nvim/lua/plugins/nvchad.lua rename to .config/nvim/lua/plugins/debug.lua diff --git a/.config/nvim/lua/plugins/example.lua b/.config/nvim/lua/plugins/example.lua deleted file mode 100644 index 98f7063..0000000 --- a/.config/nvim/lua/plugins/example.lua +++ /dev/null @@ -1,24 +0,0 @@ -return { - -- -- the opts function can also be used to change the default opts: - -- { - -- "nvim-lualine/lualine.nvim", - -- event = "VeryLazy", - -- opts = function(_, opts) - -- table.insert(opts.sections.lualine_x, "😄") - -- end, - -- }, - -- - -- -- or you can return new options to override all the defaults - -- { - -- "nvim-lualine/lualine.nvim", - -- event = "VeryLazy", - -- opts = function() - -- return { - -- --[[add your custom lualine config here]] - -- } - -- end, - -- }, - -- - -- -- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc - -- { import = "lazyvim.plugins.extras.lang.json" }, -} diff --git a/.config/nvim/lua/plugins/tmux.lua b/.config/nvim/lua/plugins/misc.lua similarity index 100% rename from .config/nvim/lua/plugins/tmux.lua rename to .config/nvim/lua/plugins/misc.lua