Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current char hex code in statusline #329

Closed
cpkio opened this issue Sep 2, 2021 · 20 comments
Closed

Current char hex code in statusline #329

cpkio opened this issue Sep 2, 2021 · 20 comments
Labels
new feature New feature or feature request

Comments

@cpkio
Copy link

cpkio commented Sep 2, 2021

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.

@cpkio cpkio added the new feature New feature or feature request label Sep 2, 2021
@shadmansaleh
Copy link
Member

shadmansaleh commented Sep 2, 2021

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
Copy link
Author

cpkio commented Sep 2, 2021

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

This comment was marked as outdated.

@cpkio
Copy link
Author

cpkio commented Sep 2, 2021

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
Copy link
Member

shadmansaleh commented Sep 2, 2021

What's your entire lualine config ?

@cpkio
Copy link
Author

cpkio commented Sep 2, 2021

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

@shadmansaleh
Copy link
Member

shadmansaleh commented Sep 2, 2021

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
Copy link
Author

cpkio commented Sep 2, 2021

'%B' is not shown anyway.

@shadmansaleh
Copy link
Member

shadmansaleh commented Sep 2, 2021

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

@cpkio
Copy link
Author

cpkio commented Sep 2, 2021

Of course it is 🤷‍♂️

@shadmansaleh
Copy link
Member

shadmansaleh commented Sep 2, 2021

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
Copy link
Author

cpkio commented Sep 2, 2021

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
Copy link
Member

shadmansaleh commented Sep 2, 2021

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
Copy link
Author

cpkio commented Sep 2, 2021

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
Copy link
Member

shadmansaleh commented Sep 2, 2021

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
Copy link
Author

cpkio commented Sep 2, 2021

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
Copy link
Member

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

@cpkio
Copy link
Author

cpkio commented Sep 2, 2021

Yes. Renaming it didn't help.

@shadmansaleh
Copy link
Member

What did you rename it to ?

@cpkio
Copy link
Author

cpkio commented Sep 2, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or feature request
Projects
None yet
Development

No branches or pull requests

2 participants