snailed
/
taolf
Archived
2
0
Fork 0

feature: global variable indicating that lf is running

This commit is contained in:
Lucas Burns 2022-05-29 17:16:06 -05:00
parent c001b14238
commit e08863d953
No known key found for this signature in database
GPG Key ID: C011CBEF6628B679
3 changed files with 13 additions and 0 deletions

View File

@ -165,7 +165,11 @@ The mappings that are listed in the `setup` call above are the default bindings.
* `<C-o>` = `tab drop` (`<A-o>` is also suggested)
* `<A-u>` = resize the floating window
### Notes
* Until a custom filetype can be set, a global variable `vim.g.inside_lf` is used to indicate that the file manager is running
### TODO
- [ ] Set custom filetype (filetype inheritance?)
- [ ] `:LfToggle` command
- [ ] Save previous size when terminal is closed, so it is restored on open
- [ ] Set Lualine to `Lf` title

View File

@ -1,6 +1,9 @@
local M = {}
local loaded = false
-- Global variable that acts as a 'filetype' sort of deal, until a custom filetype can be set
vim.g.inside_lf = false
local utils = require("lf.utils")
local function has_feature(cfg)

View File

@ -222,8 +222,12 @@ end
---@param term Terminal
function Lf:__on_open(term)
self.bufnr = api.nvim_get_current_buf()
-- TODO: Find a way to set custom filetype
-- api.nvim_buf_set_option(self.bufnr, "filetype", "lf_term")
-- For now, use a global variable that can act as a filetype
vim.g.inside_lf = true
if self.cfg.tmux then
utils.tmux(true)
end
@ -319,6 +323,8 @@ function Lf:__callback(term)
utils.tmux(false)
end
vim.g.inside_lf = false
if (self.cfg.default_action == "cd" or self.cfg.default_action == "lcd") and uv.fs_stat(self.lastdir_tmpfile) then
-- Since plenary is already being used, this is used instead of `io`
local last_dir =