From 795287e3ec351def221f9b44d358a182062e203a Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 22 Jul 2025 13:17:40 -0400 Subject: toggleterm config + misc stuff --- nvim/after/plugin/mini.lua | 11 ++++++++++ nvim/after/plugin/toggleterm.lua | 47 ++++++++++++++++++++++++++++++++++++++++ nvim/lua/commands.lua | 18 +++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 nvim/after/plugin/mini.lua create mode 100644 nvim/after/plugin/toggleterm.lua diff --git a/nvim/after/plugin/mini.lua b/nvim/after/plugin/mini.lua new file mode 100644 index 0000000..92e42b4 --- /dev/null +++ b/nvim/after/plugin/mini.lua @@ -0,0 +1,11 @@ +require('mini.files').setup({ + mappings = { + close = '', + go_in = '', + go_in_plus = '', + go_out = '', + go_out_plus = '', + }, +}) + +require('mini.trailspace').setup() diff --git a/nvim/after/plugin/toggleterm.lua b/nvim/after/plugin/toggleterm.lua new file mode 100644 index 0000000..61742f6 --- /dev/null +++ b/nvim/after/plugin/toggleterm.lua @@ -0,0 +1,47 @@ +local Terminal = require('toggleterm.terminal').Terminal + +-- lazygit +local lazygit = Terminal:new({ + cmd = 'lazygit', + display_name = 'lazygit', + dir = 'git_dir', + hidden = true, + direction = 'float', + winbar = { enabled = false, }, + float_opts = { + border = 'rounded', + } +}) + +function _lazygit_toggle() + lazygit:toggle() +end + +-- julia +local jlrepl = Terminal:new({ + cmd = 'julia', + on_open = function() + local key = vim.api.nvim_replace_termcodes([[]], true, false, true) + vim.api.nvim_feedkeys(key, 'n', false) + vim.keymap.set('n', 'jr', 'lua _jlrepl_exec()', { noremap = true, silent = true }) + end, + on_close = function() + vim.keymap.set('n', 'jr', '') + end, +}) + +function _jlrepl_exec() + jlrepl:send(string.format('include("%s")', vim.fn.expand('%:p')), true) +end + +function _jlrepl_open() + if not jlrepl:is_open() then + jlrepl:open() + end +end + +-- repl send +local trim_spaces = true +vim.keymap.set("v", "s", function() + require("toggleterm").send_lines_to_terminal("single_line", trim_spaces, { args = vim.v.count }) +end) diff --git a/nvim/lua/commands.lua b/nvim/lua/commands.lua index 8714158..aea15ca 100644 --- a/nvim/lua/commands.lua +++ b/nvim/lua/commands.lua @@ -8,3 +8,21 @@ vim.api.nvim_create_autocmd("ColorScheme", { } end, }) + +vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, { + pattern = '*.jl', + callback = function(ev) + vim.keymap.set('n', 'js', 'lua _jlrepl_open()', { noremap = true, silent = true , buffer = true }) + end +}) + +vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, { + pattern = '*.tex', + callback = function(ev) + vim.keymap.set('i', '', [[: silent exec '.!inkscape-figures create "'.getline('.').'" "'.b:vimtex.root.'/figures/"':w]], { buffer = true}) + vim.keymap.set('n', '', [[: silent exec '!inkscape-figures edit "'.b:vimtex.root.'/figures/" > /dev/null 2>&1 &':redraw!]], { buffer = true}) + + vim.keymap.set('i', '', [[: silent exec '.!xoppdog shake "'.getline('.').'" "'.b:vimtex.root.'/figures/"':w]], { buffer = true}) + vim.keymap.set('n', '', [[: silent exec '!xoppdog fetch "'.b:vimtex.root.'/figures/" > /dev/null 2>&1 &':redraw!]], { buffer = true}) + end +}) -- cgit v1.3