ziglang / zig.vim

Vim configuration for Zig
MIT License
448 stars 56 forks source link

Shell text gets inserted into .zig file when opening it #63

Open Trainraider opened 2 years ago

Trainraider commented 2 years ago

So, when I open a .zig file, something happens with my shell. I'm using starship on top of fish, and its configuring to run pfetch when it starts up. The output of pfetch somehow gets tangled up in the .zig file if zig.vim is running. So an error appears containing the pfetch output. If I ignore it and enter the file, everything looks okay. If I make no changes and I save and exit, the pfetch output is actually saved to the file. Here's my config.fish:

1 alias ls=lsd                                                                     
2 export VISUAL=vim                                                                
3 export EDITOR=vim                                                                
4                                                                                  
5 pfetch                                                                           
6 starship init fish | source

Error when opening a .zig file. Error contains pfetch output:

Error detected while processing /home/trainraider/.local/share/nvim/plugged/zig.vim/ftplugin/zig.vim:
line   41:
E474: Unidentified byte: ^[[?7l^[[1m^[[32m ___________^@^[[32m|_          \^@  ^[[32m| ^[[37m| _____ ^[[32m|^@  ^
[[32m| ^[[37m| | | | ^[[32m|^@  ^[[32m| ^[[37m| | | | ^[[32m|^@  ^[[32m|^[[37m\__^[[37m___/ ^[[32m|^@  ^[[32m\__
_______/^@^[[0m^[[7A^[[17C^[[32m^[[1m^[[33m^[[1mtrainraider^[[1m@^[[33m^[[1mlenovo-laptop^[[0m^[[47D^[[7C^[[37m^[
[0m^@^[[17C^[[32m^[[1mos^[[0m^[[2D^[[7C^[[37mLinux Mint 20.2^[[0m^@^[[17C^[[32m^[[1mhost^[[0m^[[4D^[[7C^[[37m82B5
Lenovo Legion 5 15ARH05^[[0m^@^[[17C^[[32m^[[1mkernel^[[0m^[[6D^[[7C^[[37m5.13.0-1009-oem^[[0m^@^[[17C^[[32m^[[1
muptime^[[0m^[[6D^[[7C^[[37m2d 23h 51m^[[0m^@^[[17C^[[32m^[[1mpkgs^[[0m^[[4D^[[7C^[[37m2852^[[0m^@^[[17C^[[32m^[[
1mmemory^[[0m^[[6D^[[7C^[[37m3565M / 7315M^[[0m^@^@^[[?7h{^@ "zig_exe": "/snap/zig/4090/zig",^@ "lib_dir": "/snap
/zig/4090/lib",^@ "std_dir": "/snap/zig/4090/lib/std",^@ "global_cache_dir": "/home/trainraider/.cache/zig",^@ "v
ersion": "0.9.0-dev.952+0c091feb5"^@}^@
E474: Failed to parse ^[[?7l^[[1m^[[32m ___________^@^[[32m|_          \^@  ^[[32m| ^[[37m| _____ ^[[32m|^@  ^[[3
2m| ^[[37m| | | | ^[[32m|^@  ^[[32m| ^[[37m| | | | ^[[32m|^@  ^[[32m| ^[[37m\__^[[37m___/ ^[[32m|^@  ^[[32m\_____
____/^@^[[0m^[[7A^[[17C^[[32m^[[1m^[[33m^[[1mtrainraider^[[1m@^[[33m^[[1mlenovo-laptop^[[0m^[[47D^[[7C^[[37m^[[0m
^@^[[17C^[[32m^[[1mos^[[0m^[[2D^[[7C^[[37mLinux Mint 20.2^[[0m^@^[[17C^[[32m^[[1mhost^[[0m^[[4D^[[7C^[[37m82B5 Le
novo Legion 5 15ARH05^[[0m^@^[[17C^[[32m^[[1mkernel^[[0m^[[6D^[[7C^[[37m5.13.0-1009-oem^[[0m^@^[[17C^[[32m^[[1mup
time^[[0m^[[6D^[[7C^[[37m2d 23h 51m^[[0m^@^[[17C^[[32m^[[1mpkgs^[[0m^[[4D^[[7C^[[37m2852^[[0m^@^[[17C^[[32m^[[1mm
emory^[[0m^[[6D^[[7C^[[37m3565M / 7315M^[[0m^@^@^[[?7h{^@ "zig_exe": "/snap/zig/4090/zig",^@ "lib_dir": "/snap/zi
g/4090/lib",^@ "std_dir": "/snap/zig/4090/lib/std",^@ "global_cache_dir": "/home/trainraider/.cache/zig",^@ "vers
ion": "0.9.0-dev.952+0c091feb5"^@}^@
Press ENTER or type command to continue

Main.zig:

^[[?7l^[[1m^[[32m ___________                                                
^[[32m|_          \                                                          
^[[32m| ^[[37m| _____ ^[[32m|                                              
^[[32m| ^[[37m| | | | ^[[32m|                                              
^[[32m| ^[[37m| | | | ^[[32m|                                              
^[[32m| ^[[37m\__^[[37m___/ ^[[32m|                                        
^[[32m\_________/                                                          
^[[0m^[[7A^[[17C^[[32m^[[1m^[[33m^[[1mtrainraider^[[1m@^[[33m^[[1mlenovo-laptop^[[0m^[[47D^[[7C^[[37m^[[0    m
^[[17C^[[32m^[[1mos^[[0m^[[2D^[[7C^[[37mLinux Mint 20.2^[[0m                 
^[[17C^[[32m^[[1mhost^[[0m^[[4D^[[7C^[[37m82B5 Lenovo Legion 5 15ARH05^[[0m  
^[[17C^[[32m^[[1mkernel^[[0m^[[6D^[[7C^[[37m5.13.0-1009-oem^[[0m             
^[[17C^[[32m^[[1muptime^[[0m^[[6D^[[7C^[[37m2d 23h 57m^[[0m                  
^[[17C^[[32m^[[1mpkgs^[[0m^[[4D^[[7C^[[37m2852^[[0m                          
^[[17C^[[32m^[[1mmemory^[[0m^[[6D^[[7C^[[37m3685M / 7315M^[[0m               

^[[?7hconst std = @import("std");                                            

pub fn main() anyerror!void {                                                
    std.log.info("All your codebase are belong to us.", .{});                
}          
matu3ba commented 2 years ago
  1. This looks like ANSI escape codes are not properly handled. So it looks like a problem from the terminal emulator you use and the vim setup.
  2. You provide an incomplete example. How do you open the file? vim main.zig ?
  3. What is pfetch and did you try to remove it?
matu3ba commented 1 year ago

No activity from the issuer to reproduce the issue with a minimal setup example (including vim config, shell config and used versions) since more than a year. Can this be closed?

wongjustin99 commented 11 months ago

I hit this same problem, and it ended up being because my VIM config was set up for interactive zsh shell (which I set up so I could have my zsh aliases).

set shell=zsh\ -i

Since I don't really use them any longer, I've removed it to fix it. however, it was really hard to figure out what was going on originally.