snailed
/
taolf
Archived
2
0
Fork 0

feature: escape_quit

This commit is contained in:
Lucas Burns 2022-04-23 18:40:09 -05:00
parent ed908785bf
commit 2bb2967f07
No known key found for this signature in database
GPG Key ID: C011CBEF6628B679
3 changed files with 14 additions and 6 deletions

View File

@ -25,6 +25,7 @@ require("lf").setup({
border = "double", -- border kind: single double shadow curved
height = 0.80, -- height of the *floating* window
width = 0.85, -- width of the *floating* window
escape_quit = true, -- map escape to the quit command (so it doesn't go into a meta normal mode)
mappings = true, -- whether terminal buffer mapping is enabled
tmux = false, -- tmux statusline can be disabled on opening of Lf
highlights = { -- highlights passed to toggleterm

View File

@ -8,6 +8,7 @@
--- @field border string: border kind: single double shadow curved
--- @field height number: height of the *floating* window
--- @field width number: width of the *floating* window
--- @field escape_quit boolean: whether escape should be mapped to quit
--- @field mappings boolean: whether terminal buffer mappings should be set
--- @field tmux boolean: whether tmux statusline should be changed by this plugin
--- @field highlights table: highlight table to pass to `toggleterm`
@ -41,6 +42,7 @@ local function init()
border = "double",
height = 0.80,
width = 0.85,
escape_quit = true,
mappings = true,
tmux = false,
highlights = {},
@ -63,7 +65,7 @@ end
init()
local notify = require("lf.utils").notify
-- local notify = require("lf.utils").notify
---Verify that configuration options that are numbers are numbers or can be converted to numbers
---@param field string | number: `Config` field to check

View File

@ -107,7 +107,7 @@ function Lf:__create_term()
width = math.floor(vim.o.columns * self.cfg.width),
height = math.floor(vim.o.lines * self.cfg.height),
winblend = self.cfg.winblend,
highlights = {border = "Normal", background = "Normal"},
highlights = {border = "Normal", background = "Normal"}
}
}
)
@ -170,10 +170,11 @@ function Lf:__open_in(path)
end)(path)
)
-- if not path:exists() then
-- M.error = ("directory doesn't exist: %s"):format(path)
-- return
-- end
if not path:exists() then
utils.info("Current file doesn't exist")
-- M.error = ("directory doesn't exist: %s"):format(path)
-- return
end
-- Should be fine, but just checking
if not path:is_dir() then
@ -217,6 +218,10 @@ function Lf:__on_open(term)
utils.tmux(true)
end
if self.cfg.escape_quit then
map("t", "<Esc>", "q", {buffer = term.bufnr})
end
for key, mapping in pairs(self.cfg.default_actions) do
map(
"t",