Update home/.config/lvim/lua/user/functions.lua
Update home/.config/lvim/lua/user/keybindings.lua Update home/.config/lvim/lua/user/luasnip-helper-funcs.lua Update home/.config/lvim/lua/user/plugins.lua Update home/.config/lvim/lua/user/whichkey.lua
This commit is contained in:
@@ -8,26 +8,59 @@ Last Modified By : Jeff Lance <email@jefflance.me>
|
||||
|
||||
|
||||
|
||||
-- function Surround(w_or_W)
|
||||
-- local open_char = vim.fn.input("Surround with: ")
|
||||
-- local closed_char = nil
|
||||
-- if open_char == "(" then closed_char = ")" end
|
||||
-- if open_char == "[" then closed_char = "]" end
|
||||
-- if open_char == "{" then closed_char = "}" end
|
||||
-- if open_char == "<" then closed_char = ">" end
|
||||
-- if open_char == "'" then closed_char = "'" end
|
||||
-- if open_char == '"' then closed_char = '"' end
|
||||
-- if open_char == "`" then closed_char = "`" end
|
||||
-- if open_char == "/" then closed_char = "/" end
|
||||
-- if open_char == "|" then closed_char = "|" end
|
||||
local M = {}
|
||||
|
||||
-- if w_or_W == "w" then
|
||||
-- vim.cmd("normal! ciw" .. open_char)
|
||||
-- elseif w_or_W == "W" then
|
||||
-- vim.cmd([[normal! ciW]] .. open_char)
|
||||
-- end
|
||||
-- vim.cmd("normal! p")
|
||||
-- vim.cmd("normal! a" .. closed_char)
|
||||
-- vim.cmd("normal! a")
|
||||
-- end
|
||||
--- Get current buffer size
|
||||
---@return {width: number, height: number}
|
||||
local function get_buf_size()
|
||||
local cbuf = vim.api.nvim_get_current_buf()
|
||||
local bufinfo = vim.tbl_filter(function(buf)
|
||||
return buf.bufnr == cbuf
|
||||
end, vim.fn.getwininfo(vim.api.nvim_get_current_win()))[1]
|
||||
if bufinfo == nil then
|
||||
return { width = -1, height = -1 }
|
||||
end
|
||||
return { width = bufinfo.width, height = bufinfo.height }
|
||||
end
|
||||
|
||||
--- Get the dynamic terminal size in cells
|
||||
---@param direction string
|
||||
---@param size number
|
||||
---@return integer
|
||||
local function get_dynamic_terminal_size(direction, size)
|
||||
size = size or lvim.builtin.terminal.size
|
||||
if direction ~= "float" and tostring(size):find(".", 1, true) then
|
||||
size = math.min(size, 1.0)
|
||||
local buf_sizes = get_buf_size()
|
||||
local buf_size = direction == "horizontal" and buf_sizes.height or buf_sizes.width
|
||||
return buf_size * size
|
||||
else
|
||||
return size
|
||||
end
|
||||
end
|
||||
|
||||
M.xplr_toggle = function()
|
||||
local Terminal = require("toggleterm.terminal").Terminal
|
||||
local direction = "float"
|
||||
|
||||
local xplr = Terminal:new {
|
||||
cmd = "ranger",
|
||||
hidden = true,
|
||||
direction = direction,
|
||||
-- size = 20 | function()
|
||||
-- return get_dynamic_terminal_size("float", 0.8)
|
||||
-- end,
|
||||
float_opts = {
|
||||
border = "curved",
|
||||
},
|
||||
on_open = function(_)
|
||||
vim.cmd "startinsert!"
|
||||
end,
|
||||
on_close = function(_) end,
|
||||
count = 200,
|
||||
}
|
||||
xplr:toggle()
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
|
||||
Reference in New Issue
Block a user