christopher-francisco / tmux-status.nvim

Get tmux status components for your statusline
MIT License
38 stars 0 forks source link

Plugin not working for me. #3

Open eldar opened 1 month ago

eldar commented 1 month ago

Hey,

The plugin is really cool but I think I'm missing something in the configuration and it doesn't work for me. Here's the screenshot with the plugin configuration which also demonstrates that it's not working for me. I'm likely missing something really obvious. Thanks for your help!

tmux-status-line

christopher-francisco commented 1 month ago

Hi @eldar, thanks for opening this issue. Could you try something real quick for me?

Copy the object you're passing to require("lualine").setup() on your left buffer, and then comment out the entire thing, including tmux-status. In fact, comment out the whole file.

Then go to your file on the right buffer, and paste the object into a brand new opts property (i.e: opts = { ...object goes here... } after dependencies where you're including lualine.nvim.

You want something like this:

return {
  {
    'nvim-lualine/lualine.nvim',
    dependencies = {  ... }
    opts = { ...paste your object here... }
  },
  {
    'christopher-francisco/tmux-status.nvim',
   ...etc
}
Dronakurl commented 1 month ago

Hi, I also have issues. Here is my config

return {
  {
    "nvim-lualine/lualine.nvim",
    opts = {
      sections = {
        lualine_a = { "mode" },
        lualine_c = {
          {
            require("tmux-status").tmux_windows,
            cond = require("tmux-status").show,
            padding = { left = 3 },
          },
        },
        -- lualine_x = { "diagnostics" },
        lualine_y = {},
        lualine_z = {
          {
            "filename",
            path = 3,
          },
          function()
            return " " .. os.date("%R")
          end,
        },
      },
    },
  },
  {
    "christopher-francisco/tmux-status.nvim",
    lazy = false,
    opts = {},
  },
}

I use nvim 0.10.1 and LazyVim. When I include only one component, loading the plugin crashes:

.config/nvim/lua/plugins/lualine.lua:9: module 'tmux-status' not found:
    no field package.preload['tmux-status']
cache_loader: module tmux-status not found
cache_loader_lib: module tmux-status not found
    no file './tmux-status.lua'
    no file '/home/runner/work/neovim/neovim/.deps/usr/share/luajit-2.1/tmux-status.lua'
    no file '/usr/local/share/lua/5.1/tmux-status.lua'
    no file '/usr/local/share/lua/5.1/tmux-status/init.lua'
    no file '/home/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/tmux-status.lua'
    no file '/home/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/tmux-status/init.lua'
    no file './tmux-status.so'
    no file '/usr/local/lib/lua/5.1/tmux-status.so'
    no file '/home/runner/work/neovim/neovim/.deps/usr/lib/lua/5.1/tmux-status.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'

# stacktrace:
  - .config/nvim/lua/plugins/lualine.lua:9 _in_ **load**
  - .config/nvim/lua/config/lazy.lua:9
  - .config/nvim/init.lua:2
09:48:09 PM msg_show 33 lines yanked
09:48:06 PM ms
eldar commented 1 month ago

@christopher-francisco Hey! I did what you suggested and I'm getting this now:

Error detected while processing /users/eldar/dotfiles/.config/nvim/init.lua:                                                                                                                                
Failed to load `plugins.lualine`                                                                                                                                                                            

/users/eldar/.config/nvim/lua/plugins/lualine.lua:20: module 'tmux-status' not found:                                                                                                                       
^Ino field package.preload['tmux-status']                                                                                                                                                                   
cache_loader: module tmux-status not found                                                                                                                                                                  
cache_loader_lib: module tmux-status not found                                                                                                                                                              
christopher-francisco commented 1 month ago

Gotcha @eldar @Dronakurl - thank you both. I'll try installing it with Lazyvim and post my findings

christopher-francisco commented 1 month ago

I've followed the instructions in LazyVim docs for installing a new plugin, but I'm seeing a similar issue.

I think we may need to figure out whether require() can or cannot be used with LazyVim, as it seems to be the cause

This is my file:

-- ~/.config/lazyvim/lua/plugins/ui.lua

return {
  {
    "christopher-francisco/tmux-status.nvim",
    lazy = true,
    opts = {},
  },
  {
    "nvim-lualine/lualine.nvim",
    opts = {
      sections = {
        lualine_c = {
          {
            require("tmux-status").tmux_windows,
            cond = require("tmux-status").show,
            padding = { left = 3 },
          },
        },
      },
    },
  },
}
Dronakurl commented 1 month ago

I have configured another plugin, battery.nvim. I also has a require, but I packed it to a local function. I tried something similiar with tmux-status.nvim, but still could not get it to work. The errors stopped, but the show condition was never positive. When I removed the condition, I saw not windows, but (very strange) a command prompt in the lualine.

local nvimbattery = {
  function()
    return require("battery").get_status_line()
  end,
  -- color = { fg = colors.violet, bg = colors.bg },
}

return {
  {
    "justinhj/battery.nvim",
    enabled = true,
    config = function()
      ---@diagnostic disable-next-line: missing-fields
      require("battery").setup({})
    end,
  },
  {
    "nvim-lualine/lualine.nvim",
    enabled = true,
    event = "VeryLazy",
    opts = {
      sections = {
        lualine_a = { "mode" },
        lualine_b = { "branch" },
        lualine_c = {
          {
            "filename",
            path = 3,
          },
        },
        lualine_y = {},
        lualine_z = {
          nvimbattery,
          function()
            return " " .. os.date("%R")
          end,
        },
      },
    },
  },
}
christopher-francisco commented 1 month ago

@Dronakurl - I tried your approach and it's working now. See code below

(PS: note my config dir is .config/lazyvim instead of .config/nvim because I'm using NVIM_APPNAME env variable so that I can boot LazyVim without deleting/uninstalling/backingup my own config)

-- ~/.config/lazyvim/lua/plugins/ui.lua

return {
  {
    "christopher-francisco/tmux-status.nvim",
    lazy = true,
    opts = {},
  },
  {
    "nvim-lualine/lualine.nvim",
    opts = {
      sections = {
        lualine_c = {
          {
            function()
              return require("tmux-status").tmux_windows()
            end,
            cond = function()
              return require("tmux-status").show()
            end,
            padding = { left = 3 },
          },
        },
      },
    },
  },
}
image
Dronakurl commented 1 month ago

So for me, there is no error message, the tmux line gets hidden, but there is no window name that is displayed. I copied it directly into my config, overriding my lualine config completely.

I tried with a clean lazyvim install with only this config and found that it displays the folder I am currently in. It seems, that the prompt of my shell is somehow used.

eldar commented 1 month ago

@christopher-francisco The latest code snippet you shared still doesn't work for me. No error messages but tmux's own bar is still there and nothing is shown in Lualine.

christopher-francisco commented 1 month ago

@Dronakurl - that's good then. It's showing you the current dir. You can make it display the tmux window name instead. Take a look at the config object in the README!

christopher-francisco commented 1 month ago

@eldar it sounds like the configuration file itself isn't being evaluated.

If you just try to override lualine with a "hello world", does it work?

eldar commented 1 month ago

Lualine by itself works for me. I place tmux-status in the same config file so I'm pretty sure it's loaded - I have other plugins in the same directory that are loaded by Lazy without issues.

christopher-francisco commented 1 month ago

@eldar I'm out of ideas to be honest. If there are no errors, and the tmux status is still showing, the only thing I can think of is that the plugin is not being loaded. Are you 100% sure your lualine file is being used? Could it be maybe be accidentally overriden by a different one or the default one?

edte commented 1 month ago

hello,how colud i only show current window name not all window in current session, require("tmux-status").tmux_windows will show all window

eldar commented 1 month ago

@christopher-francisco

The plugin is loaded for me and so is Lualine which does work - they are defined in the same file, so there is no overwriting. Here's the Lazy plugin manager output:

image

Here is the config again:

return {
  {
    'nvim-lualine/lualine.nvim',
    dependencies = { 'nvim-tree/nvim-web-devicons' },
    opts = {
      sections = {
        -- Other Status Line components
        -- lualine_a = { ... },
        lualine_b = {
          {
            "filename",
            path = 1,
          }
        },
        lualine_c = {
          {
            function()
              return require("tmux-status").tmux_windows()
            end,
            cond = function()
              return require("tmux-status").show()
            end,
            padding = { left = 3 },
          },
        }
      }
    }
  },
  {
    "christopher-francisco/tmux-status.nvim",
    lazy = false,
    opts = {},
  },
}

I'm not sure if it's something in my config that I'm missing or it is some problem with my setup (tmux on the remote machine, neovim built with Nix, etc).