diff options
-rw-r--r-- | lua/lv-floatterm/init.lua | 62 | ||||
-rw-r--r-- | lua/lv-utils/init.lua | 12 | ||||
-rw-r--r-- | lua/lv-which-key/init.lua | 16 | ||||
-rw-r--r-- | lua/plugins.lua | 14 |
4 files changed, 66 insertions, 38 deletions
diff --git a/lua/lv-floatterm/init.lua b/lua/lv-floatterm/init.lua index 0901c1f6..5cd6a4ae 100644 --- a/lua/lv-floatterm/init.lua +++ b/lua/lv-floatterm/init.lua @@ -1,39 +1,43 @@ local M = {} M.config = function() - require'FTerm'.setup({ - dimensions = { - height = 0.8, - width = 0.8, - x = 0.5, - y = 0.5 - }, - border = 'single' -- or 'double' - }) + local status_ok, fterm = pcall(require, "FTerm") + if not status_ok then + return + end - -- Create LazyGit Terminal - local term = require("FTerm.terminal") - local lazy = term:new():setup({ - cmd = "lazygit", - dimensions = { - height = 0.9, - width = 0.9 - } - }) + fterm.setup { + dimensions = { + height = 0.8, + width = 0.8, + x = 0.5, + y = 0.5, + }, + border = "single", -- or 'double' + } - local function is_installed(exe) - return vim.fn.executable(exe) == 1 - end + -- Create LazyGit Terminal + local term = require "FTerm.terminal" + local lazy = term:new():setup { + cmd = "lazygit", + dimensions = { + height = 0.9, + width = 0.9, + }, + } + + local function is_installed(exe) + return vim.fn.executable(exe) == 1 + end - -- Use this to toggle gitui in a floating terminal - function _G.__fterm_lazygit() - if is_installed("lazygit") ~= true then - print("Please install lazygit. Check documentation for more information") - return - end - lazy:toggle() + -- Use this to toggle gitui in a floating terminal + function _G.__fterm_lazygit() + if is_installed "lazygit" ~= true then + print "Please install lazygit. Check documentation for more information" + return end + lazy:toggle() + end end return M - diff --git a/lua/lv-utils/init.lua b/lua/lv-utils/init.lua index db3deb87..656905f2 100644 --- a/lua/lv-utils/init.lua +++ b/lua/lv-utils/init.lua @@ -1,5 +1,12 @@ local lv_utils = {} +function lv_utils.reload_lv_config() + vim.cmd "source ~/.config/nvim/lv-config.lua" + vim.cmd "source ~/.config/nvim/lua/plugins.lua" + vim.cmd ":PackerCompile" + vim.cmd ":PackerInstall" +end + function lv_utils.define_augroups(definitions) -- {{{1 -- Create autocommand groups based on the passed definitions -- @@ -24,7 +31,7 @@ end lv_utils.define_augroups { - _user_autocommands = O.user_autocommands, + _user_autocommands = O.user_autocommands, _general_settings = { { "TextYankPost", @@ -46,6 +53,7 @@ lv_utils.define_augroups { "*", "setlocal formatoptions-=c formatoptions-=r formatoptions-=o", }, + { "BufWritePost", "lv-config.lua", "lua require('lv-utils').reload_lv_config()" }, { "VimLeavePre", "*", "set title set titleold=" }, }, -- _solidity = { @@ -65,7 +73,7 @@ lv_utils.define_augroups { }, _auto_resize = { -- will cause split windows to be resized evenly if main window is resized - {'VimResized ', '*', 'wincmd ='}, + { "VimResized ", "*", "wincmd =" }, }, -- _mode_switching = { -- -- will switch between absolute and relative line numbers depending on mode diff --git a/lua/lv-which-key/init.lua b/lua/lv-which-key/init.lua index a14a82b6..8edb244b 100644 --- a/lua/lv-which-key/init.lua +++ b/lua/lv-which-key/init.lua @@ -120,7 +120,7 @@ local mappings = { name = "Packer", c = { "<cmd>PackerCompile<cr>", "Compile" }, i = { "<cmd>PackerInstall<cr>", "Install" }, - r = { ":luafile %<cr>", "Reload" }, + r = { "<cmd>lua require('lv-utils').reload_lv_config()<cr>", "Reload" }, s = { "<cmd>PackerSync<cr>", "Sync" }, u = { "<cmd>PackerUpdate<cr>", "Update" }, }, @@ -266,9 +266,19 @@ end if O.plugin.floatterm.active then vim.api.nvim_set_keymap("n", "<leader>gg", "<CMD>lua _G.__fterm_lazygit()<CR>", { noremap = true, silent = true }) vim.api.nvim_set_keymap("n", "<A-i>", "<CMD>lua require('FTerm').toggle()<CR>", { noremap = true, silent = true }) - vim.api.nvim_set_keymap("t", "<A-i>", "<C-\\><C-n><CMD>lua require('FTerm').toggle()<CR>", { noremap = true, silent = true }) + vim.api.nvim_set_keymap( + "t", + "<A-i>", + "<C-\\><C-n><CMD>lua require('FTerm').toggle()<CR>", + { noremap = true, silent = true } + ) vim.api.nvim_set_keymap("n", "<A-l>", "<CMD>lua _G.__fterm_lazygit()<CR>", { noremap = true, silent = true }) - vim.api.nvim_set_keymap("t", "<A-l>", "<C-\\><C-n><CMD>lua _G.__fterm_lazygit()<CR>", { noremap = true, silent = true }) + vim.api.nvim_set_keymap( + "t", + "<A-l>", + "<C-\\><C-n><CMD>lua _G.__fterm_lazygit()<CR>", + { noremap = true, silent = true } + ) mappings["gg"] = "LazyGit" end if O.plugin.telescope_project.active then diff --git a/lua/plugins.lua b/lua/plugins.lua index 50f96517..33efdf05 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -202,14 +202,18 @@ return require("packer").startup(function(use) use { "mfussenegger/nvim-dap", config = function() - require "dap" + local status_ok, dap = pcall(require, "dap") + if not status_ok then + return + end + -- require "dap" vim.fn.sign_define("DapBreakpoint", { text = "ï—£", texthl = "LspDiagnosticsSignError", linehl = "", numhl = "", }) - require("dap").defaults.fallback.terminal_win_cmd = "50vsplit new" + dap.defaults.fallback.terminal_win_cmd = "50vsplit new" end, disable = not O.plugin.debug.active, } @@ -219,7 +223,7 @@ return require("packer").startup(function(use) "numToStr/FTerm.nvim", event = "BufWinEnter", config = function() - require('lv-floatterm').config() + require("lv-floatterm").config() end, disable = not O.plugin.floatterm.active, } @@ -235,7 +239,9 @@ return require("packer").startup(function(use) use { "nvim-telescope/telescope-project.nvim", event = "BufRead", - setup = function () vim.cmd[[packadd telescope.nvim]] end, + setup = function() + vim.cmd [[packadd telescope.nvim]] + end, disable = not O.plugin.telescope_project.active, } |