nvim-lualine / lualine.nvim

A blazing fast and easy to configure neovim statusline plugin written in pure lua.
MIT License
5.93k stars 462 forks source link

Current char hex code in statusline #329

Closed cpkio closed 3 years ago

cpkio commented 3 years ago

Can you add current character under cursor hex as a component (like 0x2014)? I would gladly write this myself but I dont yet understand how to do it in Lua.

shadmansaleh commented 3 years ago

I dont yet understand how to do it in Lua

You don't need to just use '%B'.

https://github.com/shadmansaleh/lualine.nvim#vims-statusline-items-as-lualine-component

cpkio commented 3 years ago

Note of this sections = {lualine_c = {'%=', '%t%m', '%3p'}} or this sections = {lualine_c = {"os.data('%a')", 'data'}} output anything on on my system.

shadmansaleh commented 3 years ago

Did you install shadmansaleh/lualine.nvim ?

cpkio commented 3 years ago

Yes, I've even modified the default settings after playing for a while. Found out you made a typo, Lua is os.date('%a'), not os.data. But sections = {lualine_c = {'%=', '%t%m', '%3p'}} settings dont work for some reason.

shadmansaleh commented 3 years ago

What's your entire lualine config ?

cpkio commented 3 years ago
require('lualine').setup({ sections = {
        lualine_a = { {'mode', lower = false} },
        lualine_b = { 'branch' },
        lualine_c = { vim.fn.getcwd, {'filename', color = "PmenuSelBold"} },
    },
})
shadmansaleh commented 3 years ago

getcwd expects different arguments then what's given to lualines function components.

Lualines function conponents get somthing like function(self, is_active) so when lualine calls getcwd with those it errors out . You should wrap it witha function to ignore the args or pass it as a function name

lualine_c = {function() return vim.fn.getcwd() end}

or

lualine_c = {'getcwd'}

Try:

require('lualine').setup({ sections = {
        lualine_a = { {'mode', lower = false} },
        lualine_b = { 'branch' },
        lualine_c = { 'getcwd', {'filename', color = "PmenuSelBold"}, '%B' },
    },
})
cpkio commented 3 years ago

'%B' is not shown anyway.

shadmansaleh commented 3 years ago

Is your cursor on a char ? It's working for me.

cpkio commented 3 years ago

Of course it is 🤷‍♂️

shadmansaleh commented 3 years ago

Of course it is 🤷‍♂️

I just can't think of any reason for that not to work as I just ran that config and it worked :P

Can you give a screenshot ?

What does this command say ?

:lua print(vim.inspect(require'lualine'.get_config()))
cpkio commented 3 years ago

Error executing lua [string ":lua"]:1: attempt to call field 'get_config' (a nil value). There's no such function?

2021-09-02_181546 2021-09-02_181606

shadmansaleh commented 3 years ago

You have hoob3rt/lualine.nvim installed not shadmansaleh/lualine.nvim . Those features aren't available in this repo . You'll have to use my fork .

cpkio commented 3 years ago

Your fork didn't load, so I had to revert to original: Error detected while processing C:\NvimLua\nvim\init.lua: E5113: Error while calling lua chunk: ...ata\site\pack\user\start\lualine.nvim\lua\lualine.lua:256: attempt to index field 'config_module' (a number value)

shadmansaleh commented 3 years ago

Use this and try to reproduce the crash without any other plugins influence. And provide the minimal example with which you can reproduce the problem.

cpkio commented 3 years ago

I'm on Windows so I cannot use bash script. I've created an isolated installation by creating separate nvim and nvim-data... directories and setting the XDG_* variables. Strangely enough, now your plugin works (it still cannot do stuff like 0x%B for 0x2014 for example, but anyway…). And I only had a few plugins installed to get this problem. Will try finding out what plugin is intervening with yours.

shadmansaleh commented 3 years ago

Do you have you lualine configuration file named lualine_config.lua?

cpkio commented 3 years ago

Yes. Renaming it didn't help.

shadmansaleh commented 3 years ago

What did you rename it to ?

cpkio commented 3 years ago

Sorry, renamed the wrong one. Now its working. Thanks for your efforts! 👍