diff options
author | LostNeophyte <[email protected]> | 2023-01-25 18:55:31 +0100 |
---|---|---|
committer | LostNeophyte <[email protected]> | 2023-01-25 18:55:31 +0100 |
commit | 75b653cc623a8cd6de397e42f21b838a065eb0e0 (patch) | |
tree | 7b43499c99423651d7e75662bb4628569834e28f /lua/lvim/core/terminal.lua | |
parent | 4f02e54d923414eb6690d64c7e334f624a2a9342 (diff) |
refactor!: put all plugin options under `opts`
Diffstat (limited to 'lua/lvim/core/terminal.lua')
-rw-r--r-- | lua/lvim/core/terminal.lua | 78 |
1 files changed, 40 insertions, 38 deletions
diff --git a/lua/lvim/core/terminal.lua b/lua/lvim/core/terminal.lua index e9c46182..34892303 100644 --- a/lua/lvim/core/terminal.lua +++ b/lua/lvim/core/terminal.lua @@ -3,41 +3,43 @@ local Log = require "lvim.core.log" M.config = function() local config = { - -- size can be a number or function which is passed the current terminal - size = 20, - open_mapping = [[<c-\>]], - hide_numbers = true, -- hide the number column in toggleterm buffers - shade_filetypes = {}, - shade_terminals = true, - shading_factor = 2, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light - start_in_insert = true, - insert_mappings = true, -- whether or not the open mapping applies in insert mode - persist_size = false, - -- direction = 'vertical' | 'horizontal' | 'window' | 'float', - direction = "float", - close_on_exit = true, -- close the terminal window when the process exits - shell = vim.o.shell, -- change the default shell - -- This field is only relevant if direction is set to 'float' - float_opts = { - -- The border key is *almost* the same as 'nvim_win_open' - -- see :h nvim_win_open for details on borders however - -- the 'curved' border is a custom border type - -- not natively supported but implemented in this plugin. - -- border = 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open - border = "curved", - -- width = <value>, - -- height = <value>, - winblend = 0, - highlights = { - border = "Normal", - background = "Normal", + opts = { + -- size can be a number or function which is passed the current terminal + size = 20, + open_mapping = [[<c-\>]], + hide_numbers = true, -- hide the number column in toggleterm buffers + shade_filetypes = {}, + shade_terminals = true, + shading_factor = 2, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light + start_in_insert = true, + insert_mappings = true, -- whether or not the open mapping applies in insert mode + persist_size = false, + -- direction = 'vertical' | 'horizontal' | 'window' | 'float', + direction = "float", + close_on_exit = true, -- close the terminal window when the process exits + shell = vim.o.shell, -- change the default shell + -- This field is only relevant if direction is set to 'float' + float_opts = { + -- The border key is *almost* the same as 'nvim_win_open' + -- see :h nvim_win_open for details on borders however + -- the 'curved' border is a custom border type + -- not natively supported but implemented in this plugin. + -- border = 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open + border = "curved", + -- width = <value>, + -- height = <value>, + winblend = 0, + highlights = { + border = "Normal", + background = "Normal", + }, }, + -- Add executables on the config.lua + -- { cmd, keymap, description, direction, size } + -- lvim.builtin.terminal.execs = {...} to overwrite + -- lvim.builtin.terminal.execs[#lvim.builtin.terminal.execs+1] = {"gdb", "tg", "GNU Debugger"} + -- TODO: pls add mappings in which key and refactor this }, - -- Add executables on the config.lua - -- { cmd, keymap, description, direction, size } - -- lvim.builtin.terminal.execs = {...} to overwrite - -- lvim.builtin.terminal.execs[#lvim.builtin.terminal.execs+1] = {"gdb", "tg", "GNU Debugger"} - -- TODO: pls add mappings in which key and refactor this execs = { { nil, "<M-1>", "Horizontal Terminal", "horizontal", 0.3 }, { nil, "<M-2>", "Vertical Terminal", "vertical", 0.4 }, @@ -67,7 +69,7 @@ end ---@param size number ---@return integer local function get_dynamic_terminal_size(direction, size) - size = size or lvim.builtin.terminal.size + size = size or lvim.builtin.terminal.opts.size if direction ~= "float" and tostring(size):find(".", 1, true) then size = math.min(size, 1.0) local buf_sizes = get_buf_size() @@ -80,13 +82,13 @@ end M.setup = function() local terminal = require "toggleterm" - terminal.setup(lvim.builtin.terminal) + terminal.setup(lvim.builtin.terminal.opts) for i, exec in pairs(lvim.builtin.terminal.execs) do - local direction = exec[4] or lvim.builtin.terminal.direction + local direction = exec[4] or lvim.builtin.terminal.opts.direction local opts = { - cmd = exec[1] or lvim.builtin.terminal.shell, + cmd = exec[1] or lvim.builtin.terminal.opts.shell, keymap = exec[2], label = exec[3], -- NOTE: unable to consistently bind id/count <= 9, see #2146 @@ -128,7 +130,7 @@ M.toggle_log_view = function(logfile) end Log:debug("attempting to open: " .. logfile) log_viewer = log_viewer .. " " .. logfile - local term_opts = vim.tbl_deep_extend("force", lvim.builtin.terminal, { + local term_opts = vim.tbl_deep_extend("force", lvim.builtin.terminal.opts, { cmd = log_viewer, open_mapping = lvim.log.viewer.layout_config.open_mapping, direction = lvim.log.viewer.layout_config.direction, |