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

Shows me absolutely nothing #155

Open
JohnWilliston opened this issue Jan 1, 2025 · 19 comments
Open

Shows me absolutely nothing #155

JohnWilliston opened this issue Jan 1, 2025 · 19 comments

Comments

@JohnWilliston
Copy link

I feel like I must be missing the obvious completely. I added the sample configuration for the plugin to my Lazy setup, the plugin installed successfully, I changed directory to inside a Git repo, opened a file, and the :Flog and :FlogSplit commands work fine by show me absolutely nothing as a result. Any ideas? The tool looks great, but I have no idea why it's not doing anything.

@TamaMcGlinn
Copy link
Contributor

TamaMcGlinn commented Jan 1, 2025

Can you try :!git log ? If that shows an error perhaps it can point you in the right direction. An empty buffer is the expected result if you just created the repo and there are no commits yet.

@rbong
Copy link
Owner

rbong commented Jan 1, 2025

Yes, the only thing that would cause this is if it's a new git repo.

If that's not the case please post your configuration and the repo you're having issues with if possible.

@JohnWilliston
Copy link
Author

First, thanks for the super-speedy reply: I didn't expect that at all on a holiday, and Happy New Year to y'all while I'm at it! Second, in answer to your questions, yes, the :!git log command works just fine, showing me the commits in whatever repo I'm editing. I see this problem with literally every repo I've tried, so I'm guessing my configuration is somehow at issue.

Speaking of which, I refer you to the FlogDebug repo I just created on GitHub which both (1) provides you my current Neovim configuration, and (2) serves as a repo that has the problem. I added a simple readme to explain the steps to reproduce the problem.

And I suppose I should say: please be gentle! I've been using Vim for decades, but I've only just adopted Neovim over the last couple months. I'm still working on my configuration and imagine I'm doing all kinds of things wrong. Please let me know if there's something else I can do to help. I think it would be great to be able to use the plugin. Cheers!

@rbong
Copy link
Owner

rbong commented Jan 1, 2025

Thank you for providing your config and a repo. Unfortunately, I installed and loaded your config successfully (despite getting some warnings) but still could not reproduce the issue. Apologies for the difficulty getting to the bottom of this.

I opened README.md in your provided repo, ran :Flog, and saw the expected output:

2025-01-01-140439_1095x726_scrot

What do you get from these commands?

nvim --version
git --version

@JohnWilliston
Copy link
Author

Well I guess that's good news at least! I'm glad to hear the plugin works just fine with my config. Now I just have to figure out why it's not working for me, which is weird. For sake of reference, I'm running Neovim on my Windows 11 Pro x64 PC. The versions of the tools you mention are as follows, copied/pasted from my Windows terminal:

Wed  1/01/25 13:57:38 Mem(22%) Dirs() LastCmd(0)
C:\Users\John\AppData\Local\nvim> nvim --version && git --version
NVIM v0.10.3
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info
git version 2.47.1.windows.1

Does that help?

@JohnWilliston
Copy link
Author

JohnWilliston commented Jan 1, 2025

Aha! Now I'm getting somewhere! When I use Neovim in either CMD or PowerShell, your plugin works perfectly. But when I launch the Windows Terminal app, it fails with an empty screen every time. That gives me a starting point to investigate further on my end as I believe the underlying favorite terminal application that's launching is TCC by JP Software. I've been using it for years on Windows to give me aliases, directory stacks, better batch files, and most of what I'm used to having on Linux or macOS that Windows is still (pathetically) missing. I'll dig into your plugin code to see if I can find the specific shell commands being issued; it's probably got something to do with those. Any advice/pointers would be helpful.

@rbong
Copy link
Owner

rbong commented Jan 1, 2025

Does Fugitive work with your terminal? If you run :Git to get the current status and :Git log --graph, does it work?

@JohnWilliston
Copy link
Author

JohnWilliston commented Jan 2, 2025

I don't think I've ever used that command before, but yes, it works in the Windows Terminal directly (running TCC to be clear, the one shell that apparently doesn't work properly with the Flog plugin) and with :!git log --graph in Neovim. Wait, as I re-read your question, should the :Git command be available? Because Neovim tells me it's an unknown command, and I do know those are case sensitive. UPDATE: Even if I explicitly install the Fugitive plugin, and then the :Git (capitalized) command works fine, the problem still persists. Hmph.

@rbong
Copy link
Owner

rbong commented Jan 2, 2025

It is likely a special character used in the log command.

You can copy the last used log command in the Flog window by running this command:

:let @+ = b:flog_state.prev_log_cmd

If you run this in your terminal you may be able to narrow down what's causing issues. Though, when Flog runs this command, it uses io.popen() in Luajit, so if you can run a Luajit script that outputs the command it will be closer:

local handle = io.popen("<paste here>")

for line in handle:lines() do
	print(line)
end

In my terminal, I have to redirect the output to a paginator to view it properly:

luajit run_git.lua | less

I'm not sure what the proper way to do this for your terminal is.

Here's what that output should look like:

2025-01-02-154535_1918x1055_scrot

Here, my paginator is changing escape characters to ESC, so yours may look slightly different.

If you want to narrow it down even further on your own, the problem is likely in the shell escaping logic, which you can find in flog/autoload/flog/shell.vim.

@JohnWilliston
Copy link
Author

JohnWilliston commented Jan 2, 2025

Bingo! I was able to retrieve the command with the helpful information you provided. It runs fine in CMD and PowerShell, but when I run the same command in TCC, I get the following error immediately:

image

I confess I'm not familiar with what's going wrong there, though maybe it's just plain old string escaping? Thanks in advance for any thoughts. I've filed an issue with the JP Software support forums as well. I imagine one way or another I'll get it working.

UPDATE: Finally found a way to copy the output of the command as text:

Thu  1/02/25 13:03:12 Mem(26%) Dirs() LastCmd(0)
E:\Src\Dotfiles> git -C E:/Src/Dotfiles --git-dir E:/Src/Dotfiles/.git log --parents --topo-order --no-color --pretty="format:__START""n""h""n""p""n""D""n""ad [""h] {""an}""d ""s" --date=iso --max-count=5000 --

fatal: {an}d: no such path in the working tree.
Use 'git <command> -- <path>...' to specify paths that do not exist locally.

@rbong
Copy link
Owner

rbong commented Jan 2, 2025

Flog should be giving an error if a shell command fails. I'm not sure what settings you should be using in Neovim for your shell but it should work assuming it is supported and set up right. Settings can impact how escaping characters works in Flog as well, so I would recommend finding how the various shell settings should be configured in Vim/Neovim.

There are various settings for shells that start with shell, starting with :help 'shell'.

@JohnWilliston
Copy link
Author

JohnWilliston commented Jan 2, 2025

First, thanks for acquainting me with those details about configuring a shell for Neovim. I had no idea I even needed to do that. I can't find any information specifically on using TCC with it, but maybe I can poke around a bit and see if piping options or things like that make a difference.

FWIW, the author of the TCC software says the command is a bit odd but shouldn't present any parsing problems for TCC. He also offered me a workaround I've embraced, which I'll explain here for others' sake. To wit, he suggested I change the COMSPEC environment variable to a shell that works (e.g., CMD) before running Neovim and then change it back after I'm done. I wrapped this all in a simple nvim.bat file whose contents is:

@echo off
setlocal
set ComSpec=cmd.exe
nvim.exe %*

That lets the Flog plugin run just fine within Neovim. I suspect he's got some kind of interpreter issue that's barfing on that command for some reason, but that workaround has me up and "flogging away", so to speak. Sorry, I couldn't help the bad pun!

@TamaMcGlinn
Copy link
Contributor

@JohnWilliston it doesn't make sense to me that you should care what terminal NeoVim is run inside of. When I was stuck with Windows at a previous job, I started NeoVim natively, and then ran a MinGW bash shell inside of that via a binding.

What difference does it make to run NeoVim from TCC rather than from CMD ?

@rbong
Copy link
Owner

rbong commented Jan 3, 2025

What difference does it make to run NeoVim from TCC rather than from CMD ?

Special characters, usually... it's probably the same in this case but it looks like it might be having a problem with quoting too.

@JohnWilliston
Copy link
Author

What difference does it make to run NeoVim from TCC rather than from CMD ?

Because I try to live in the terminal as much as possible, and CMD is the most pathetic shell of all in my experience. TCC offers almost perfect compatibility with it (cases like this one being weird exceptions) yet also adds:

  • Lots of additional commands
  • GUI features if you use their TakeCommand application
  • Extended functionality for CMD commands
  • Support for command and directory aliases
  • Enhanced file wildcards and filtering by file attributes
  • Colorized directory listings and such
  • Tons of batch-file extensions
  • An interactive batch file debugger
  • Built in support for FTP, TFTP, FTPS, HTTP, HTTPS, Jabber, etc.
  • A plugin manager to extend its functionality

And more stuff I'm sure I'm forgetting. You're right that I could use Bash through various means, not the least of which being WSL2 these days, but I'm trying to stick with a do-everything environment rather than live in multiple shells for different purposes. TCC is the only one I know that can do it all.

@rbong
Copy link
Owner

rbong commented Jan 3, 2025

WSL2 can be slow. I don't want to force anyone to use a particular terminal with Flog, but also it is hard to support Windows because I don't have any desire to set up a bunch of shells on Windows... Sorry for the difficulty.

@JohnWilliston
Copy link
Author

WSL2 can be slow. I don't want to force anyone to use a particular terminal with Flog, but also it is hard to support Windows because I don't have any desire to set up a bunch of shells on Windows... Sorry for the difficulty.

I don't blame you one bit! The day I can stop using Windows is the day I do stop using Windows. You've been very helpful as it is, more so than I anticipated. And if I haven't already said it, thanks for writing the plugin in the first place! It's great to be able to use it. I still have a lot to learn, but maybe I can ditch my Git GUI (GitKraken) with all the features Flog provides.

@TamaMcGlinn
Copy link
Contributor

TamaMcGlinn commented Jan 4, 2025

@JohnWilliston I'm not suggesting you switch from TCC, but rather that you open NeoVim first (with a desktop shortcut or any other means than inside TCC), and then open TCC inside of NeoVim. It will have the added benefit of being able to use NeoVim as a terminal multiplexer, since terminal buffers are just buffers like any other, so you can put them in tabs & splits, or even run things without any opened view and use fzf's :Buffers or similar to recall it when you need that terminal.

I made a tiny plugin vim-termhere; it was explicitly designed to reduce the differences for me between linux and windows work, as well as reduce the friction in using :term directly. It does assume you have a doskey.cmd file, and you will want to change l:bash_start_command= to start up TCC instead (PR welcome!).

@JohnWilliston
Copy link
Author

I'll give your plugin a look. To date (as you can see if you reviewed my config) I've been fiddling around trying to get toggleterm and the toggleterm manager to work for me, and I had to take a few steps to get it to launch terminals using TCC as the shell. It's so much easier for me on Linux or macOS: I typically just use tmux and work seamlessly with Neovim inside one of its panes. But Windows is an incompetent nightmare mess by comparison. I confess, though, it hadn't yet occurred to me to try using Neovim as the authoritative terminal multiplexer. That's an interesting notion. I find using terminals in Neovim a bit rough around the edges when you want more than one, but maybe I could get that to work for me. Thanks for the suggestion.

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

No branches or pull requests

3 participants