From 3e3b6d689bacce140ba1c5fd31ac7e2a79a08ae3 Mon Sep 17 00:00:00 2001 From: lefv Date: Thu, 20 Feb 2025 23:57:44 -0500 Subject: [PATCH] Added autocommand. --- lua/config/autocmds.lua | 62 ++++++++++++++++++++++++++++++++++++++ lua/config/keymaps.lua | 7 ++--- lua/config/options.lua | 3 +- lua/plugins/telescope.lua | 17 ++++++++++- lua/plugins/toggleterm.lua | 21 +++++++------ 5 files changed, 92 insertions(+), 18 deletions(-) diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index 27e9e06..b97ee8a 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -1,3 +1,65 @@ -- 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 +-- autocmds.lua +local function create_dev_output() + local group = vim.api.nvim_create_augroup("DevOutput", { clear = true }) + + -- Create the command + vim.api.nvim_create_user_command("DevOutput", function() + local buf = vim.api.nvim_create_buf(false, true) + vim.api.nvim_command("split") + vim.api.nvim_win_set_buf(0, buf) + vim.api.nvim_command("wincmd J") + vim.api.nvim_buf_set_name(buf, "[Development Output]") + vim.api.nvim_buf_set_option(buf, "buftype", "nofile") + vim.api.nvim_buf_set_option(buf, "swapfile", false) + vim.api.nvim_buf_set_option(buf, "bufhidden", "hide") + vim.api.nvim_buf_set_option(buf, "filetype", "DevOutput") + vim.api.nvim_win_set_height(0, 10) + return buf + end, {}) + + -- Make the dev_print function globally available + _G.dev_print = function(msg) + local bufnr = nil + for _, buf in ipairs(vim.api.nvim_list_bufs()) do + if vim.api.nvim_buf_get_name(buf):match("Development Output") then + bufnr = buf + break + end + end + + if not bufnr then + bufnr = vim.api.nvim_exec2("DevOutput", { output = true }).output + end + + local timestamp = os.date("%H:%M:%S") + local formatted_msg = string.format("[%s] %s", timestamp, msg) + vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, { formatted_msg }) + + for _, win in ipairs(vim.api.nvim_list_wins()) do + if vim.api.nvim_win_get_buf(win) == bufnr then + vim.api.nvim_win_set_cursor( + win, + { vim.api.nvim_buf_line_count(bufnr), 0 } + ) + break + end + end + end + + -- Optional: Add any autocmds related to the output window + vim.api.nvim_create_autocmd("FileType", { + group = group, + pattern = "DevOutput", + callback = function() + -- Set any buffer-local options for DevOutput buffers + vim.opt_local.wrap = true + vim.opt_local.number = true + end, + }) +end + +-- Initialize the dev output setup +create_dev_output() diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 69b0954..c107a2b 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -8,12 +8,9 @@ -- "SomeCommandName", -- Replace "SomeCommandName" with your desired command -- { noremap = true, silent = true } -- ) - - vim.api.nvim_set_keymap( "n", - "qw", - "SessionManager save_current_session", + "<^P>", + "lua dev_print('Key combo detected!')", { noremap = true, silent = true } ) - diff --git a/lua/config/options.lua b/lua/config/options.lua index 17942e5..9420d3b 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -2,6 +2,5 @@ -- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua -- Add any additional options here vim.opt.wrap = true -vim.g.perl_host_prog = '/usr/bin/perl' +vim.g.perl_host_prog = "/usr/bin/perl" vim.g.loaded_perl_provider = 0 - diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 64447d8..dc78db6 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -37,10 +37,25 @@ return { { "telescope.nvim", dependencies = { + "nvim-lua/plenary.nvim", "nvim-telescope/telescope-fzf-native.nvim", build = "make", config = function() - require("telescope").load_extension("fzf") + local telescope = require("telescope") + local builtin = require("telescope.builtin") + + -- Load fzf extension + telescope.load_extension("fzf") + + -- Configure telescope settings + telescope.setup({ + defaults = { + layout_strategy = "horizontal", + sorting_strategy = "ascending", + layout_config = { prompt_position = "top" }, + winblend = 0, + }, + }) end, }, }, diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua index e645ecd..2915bc9 100644 --- a/lua/plugins/toggleterm.lua +++ b/lua/plugins/toggleterm.lua @@ -3,15 +3,16 @@ return { -- { "akinsho/toggleterm.nvim", version = "*", config = true }, -- or { - 'akinsho/toggleterm.nvim', - version = "*", - opts = {--[[ things you want to change go here]] + "akinsho/toggleterm.nvim", + version = "*", + opts = { --[[ things you want to change go here]] direction = "vertical", + shell = "/opt/homebrew/bin/tmux", }, config = function() - local toggleterm = require('toggleterm') - toggleterm.setup() - vim.cmd [[ + local toggleterm = require("toggleterm") + toggleterm.setup() + vim.cmd([[ tnoremap exe v:count1 . "ToggleTerm" " By applying the mappings this way you can pass a count to your @@ -19,7 +20,7 @@ return { " For example: 2 will open terminal 2 nnoremap exe v:count1 . "ToggleTerm" inoremap exe v:count1 . "ToggleTerm" - ]] - end, - } -} + ]]) + end, + }, +}