diff --git a/README.md b/README.md index ff4ca0b..2b0adac 100644 --- a/README.md +++ b/README.md @@ -165,7 +165,11 @@ The mappings that are listed in the `setup` call above are the default bindings. * `` = `tab drop` (`` is also suggested) * `` = 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 diff --git a/lua/lf.lua b/lua/lf.lua index cce9b4b..e0f8989 100644 --- a/lua/lf.lua +++ b/lua/lf.lua @@ -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) diff --git a/lua/lf/main.lua b/lua/lf/main.lua index dba7844..9eb9189 100644 --- a/lua/lf/main.lua +++ b/lua/lf/main.lua @@ -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 =