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

Bug: Filetype icon for terminal acting weird #1253

Open
2 tasks done
MarcoBuess opened this issue Jun 5, 2024 · 4 comments
Open
2 tasks done

Bug: Filetype icon for terminal acting weird #1253

MarcoBuess opened this issue Jun 5, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@MarcoBuess
Copy link

MarcoBuess commented Jun 5, 2024

Self Checks

  • I'm using the latest lualine. commit 0a5a668
  • I didn't find the issue in existing issues or PRs.

How to reproduce the problem

Launching a terminal with term and thus starting vim.opt.shell will result in this filetype icon.
image

Expected behaviour

Launching a terminal with term pwsh will yield the expected result.
image

I don't quite get the difference other than that term pwsh will spawn 2 instances of pwsh as oppsed to term which will spawn just one instance of pwsh. In both cases filetype will be set to terminal by an autocommand. I tried several filetypes in the term session, but the icon didn't change. It also behaves the same for me no matter what shell you set. I even tried cmd.

Minimal config to reproduce the issue

-- Shell
vim.opt.shell = fn.executable("pwsh") and "pwsh" or "powershell"
vim.opt.shellcmdflag =
"-NonInteractive -NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;$PSStyle.OutputRendering = [System.Management.Automation.OutputRendering]::PlainText;"
vim.opt.shellpipe = '2>&1 | %{ "$_" } | Tee-Object %s; exit $LastExitCode'
vim.opt.shellquote = ""
vim.opt.shellredir = '2>&1 | %{ "$_" } | Out-File %s; exit $LastExitCode'
vim.opt.shellxquote = ""

Additional information

OS: Windows 11 (10.0.22631)
Neovim: v0.10.0, Release, LuaJIT 2.1.1713484068
lualine: 0a5a668
Terminal: Windows Terminal v1.20.11381.0

@MarcoBuess MarcoBuess added the bug Something isn't working label Jun 5, 2024
@MarcoBuess
Copy link
Author

MarcoBuess commented Jun 5, 2024

I just tested devicons.get_icon_by_filetype(vim.bo.filetype) which is returning the correct icon/highlight group while in the affected buffer.

@MarcoBuess
Copy link
Author

So the problem lies somewhere here:
https://github.com/nvim-lualine/lualine.nvim/blob/0a5a66803c7407767b799067986b4dc3036e1983/lua/lualine/components/filetype.lua#L34C34-L34C73

Lines 35-37 would potentially recover the problem but don't get triggert as icon != null. Any particular reason why getting the icon like that instead of just using vim.bo.filetype in general? vim.bo.filetype would also kinda allow the users to make small modifications by changing a buffers file type, which might be a good thing?

@MarcoBuess
Copy link
Author

MarcoBuess commented Jun 5, 2024

Seems like @arsmoriendy already found the same thing and filed a PR: #1252

@arsmoriendy
Copy link

Unfortunately some of my tests failed. One of the reason being that the filetype component test only simulates the buffer's filename and not the filetype (line 303 in component_spec.lua) . I will try to look further into it this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants