Added autocommand.

pull/126/head^2
lefv 2025-02-20 23:57:44 -05:00
parent 611a480fb7
commit 3e3b6d689b
5 changed files with 92 additions and 18 deletions

View File

@ -1,3 +1,65 @@
-- Autocmds are automatically loaded on the VeryLazy event -- 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 -- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
-- Add any additional autocmds here -- 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()

View File

@ -8,12 +8,9 @@
-- "<cmd>SomeCommandName<CR>", -- Replace "SomeCommandName" with your desired command -- "<cmd>SomeCommandName<CR>", -- Replace "SomeCommandName" with your desired command
-- { noremap = true, silent = true } -- { noremap = true, silent = true }
-- ) -- )
vim.api.nvim_set_keymap( vim.api.nvim_set_keymap(
"n", "n",
"<leader>qw", "<^P>",
"<cmd>SessionManager save_current_session<CR>", "<cmd>lua dev_print('Key combo detected!')<CR>",
{ noremap = true, silent = true } { noremap = true, silent = true }
) )

View File

@ -2,6 +2,5 @@
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua -- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
-- Add any additional options here -- Add any additional options here
vim.opt.wrap = true 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 vim.g.loaded_perl_provider = 0

View File

@ -37,10 +37,25 @@ return {
{ {
"telescope.nvim", "telescope.nvim",
dependencies = { dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope-fzf-native.nvim", "nvim-telescope/telescope-fzf-native.nvim",
build = "make", build = "make",
config = function() 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, end,
}, },
}, },

View File

@ -3,15 +3,16 @@ return {
-- { "akinsho/toggleterm.nvim", version = "*", config = true }, -- { "akinsho/toggleterm.nvim", version = "*", config = true },
-- or -- or
{ {
'akinsho/toggleterm.nvim', "akinsho/toggleterm.nvim",
version = "*", version = "*",
opts = {--[[ things you want to change go here]] opts = { --[[ things you want to change go here]]
direction = "vertical", direction = "vertical",
shell = "/opt/homebrew/bin/tmux",
}, },
config = function() config = function()
local toggleterm = require('toggleterm') local toggleterm = require("toggleterm")
toggleterm.setup() toggleterm.setup()
vim.cmd [[ vim.cmd([[
tnoremap <silent><c-t> <Cmd>exe v:count1 . "ToggleTerm"<CR> tnoremap <silent><c-t> <Cmd>exe v:count1 . "ToggleTerm"<CR>
" By applying the mappings this way you can pass a count to your " By applying the mappings this way you can pass a count to your
@ -19,7 +20,7 @@ return {
" For example: 2<C-t> will open terminal 2 " For example: 2<C-t> will open terminal 2
nnoremap <silent><c-t> <Cmd>exe v:count1 . "ToggleTerm"<CR> nnoremap <silent><c-t> <Cmd>exe v:count1 . "ToggleTerm"<CR>
inoremap <silent><c-t> <Esc><Cmd>exe v:count1 . "ToggleTerm"<CR> inoremap <silent><c-t> <Esc><Cmd>exe v:count1 . "ToggleTerm"<CR>
]] ]])
end, end,
} },
} }