1
0

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:
Jeff Lance 2024-02-24 20:06:05 +01:00
parent 33a166cf01
commit 3fab56646f
5 changed files with 69 additions and 34 deletions

View File

@ -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

View File

@ -12,11 +12,11 @@ local M = {}
M.setup = function()
-- ============
-- key mappings
-- key mappings examples using nvim or lvim api.
--
-- vim-surround shortcuts as example
-- vim.api.nvim_set_keymap("n", "sw", "<Plug>Ysurroundiw", { noremap = true, silent = true })
-- vim.api.nvim_set_keymap("n", "Sw", "<Plug>YSurroundiw", { noremap = true, silent = true })
-- lvim.keys.normal_mode["<C-t>"] = ":FloatermToggle terminal<CR>"
--
lvim.leader = ";"
@ -28,7 +28,6 @@ M.setup = function()
lvim.keys.normal_mode["<C-r>"] = "<CMD>redo<CR>"
lvim.keys.normal_mode["<C-[>"] = ":<<CR>"
lvim.keys.normal_mode["<C-]>"] = ":><CR>"
lvim.keys.normal_mode["<C-t>"] = ":FloatermNew --name=term --width=0.8"
end

View File

@ -274,6 +274,7 @@ M.setup = function()
})
end,
},
-- rnvimr
{
"kevinhwang91/rnvimr",
cmd = "RnvimrToggle",
@ -284,9 +285,9 @@ M.setup = function()
let g:rnvimr_edit_cmd = 'drop'
let g:rnvimr_draw_border = 1
let g:rnvimr_hide_gitignore = 1
let g:rnvimr_border_attr = {'fg': 14, 'bg': -1}
" let g:rnvimr_border_attr = {'fg': 14, 'bg': 0}
let g:rnvimr_enable_bw = 1
let g:rnvimr_shadow_winblend = 70
" let g:rnvimr_shadow_winblend = 70
let g:rnvimr_ranger_cmd = ['ranger', '--cmd=set draw_borders both']
]])
end,

View File

@ -34,7 +34,7 @@ M.setup = function()
}
-- remap neo-tree shortcut to rnvimr
lvim.builtin.which_key.mappings["e"] = { "<CMD>RnvimrToggle<CR>", "File explorer" }
-- lvim.builtin.which_key.mappings["e"] = { "<CMD>RnvimrToggle<CR>", "File explorer" }
-- remap dashboard
lvim.builtin.which_key.mappings["d"] = lvim.builtin.which_key.mappings[";"]
@ -99,6 +99,8 @@ M.setup = function()
lvim.builtin.which_key.mappings["x"] = { "<CMD>w! <BAR> q!<CR>", "Save and quit" }
lvim.builtin.which_key.mappings[";"] = {}
-- lvim.builtin.which_key.mappings["e"] = { ":lua require('user.functions').xplr_toggle()<CR>", "File manager" }
lvim.builtin.which_key.mappings["e"] = { ":RnvimrToggle<CR>", "File manager" }
lvim.builtin.terminal.open_mapping = "<C-t>"
end