I’m not sure why you bring up go. Is it the formatter in general? Because I thought Go likes tabs over spaces.
Yes, tabs are better than spaces, but using the standard formatter is better than caring about spaces vs. tabs. By orders of magnitude. Just stop caring and let the auto formatter do its job.
I wish that were true but it simply is not. Formatting files with spaces is just pure irritation. ie: if I want to tab and it inserts 4 spaces, not the 3 I have set as my default and then need to backup, I can’t just hit backspace, I have to hit it 4 times. That is only one example but forcing spaces has to be the most irritating thing I could think of forcing. I hope they don’t force this through the compiler at some point as it will probably be enough to force me to go back to go.
We are not all the same and attempting to force too much will only push people away. I understand standardization but tabs gives you 100% standard formatting without forcing anyone to view things your way. It also cuts the file size down drastically by getting rid of all of those space characters. Anyone arguing for spaces at this point just aren’t using their heads as there isn’t a single good reason for using them.
Glenn
I added those settings to my init.lua file but it has no effect on it. Still inserting 4 spaces. I’ve spent hours now trying to figure this out and nothing will stop it from doing this. I have no zig specific stuff installed and yet, any file with a .zig immediately adds spaces instead of tabs and ignores all of my settings. I don’t even have to save the file, it just does it.
Your setting to put at the top of every file doesn’t work either.
Thanks for the attempt though,
Glenn
Starting with a blank ~/.config/nvim/init.lua
, I just added this line:
vim.cmd([[autocmd FileType zig set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab]])
and it seems to force tabs only. From there, you would have to see if this would still work with your other init.lua
settings, maybe adding them piece by piece to see if anything makes it stop working.
That did it. I’m not sure why as I already had all of those options in my init.lua file but as opt values. Either way this fixed my issue.
Thanks again,
Glenn
Believe me, I’m familiar with the argument.
The interesting thing is that this is purely incidental, there’s nothing essential about it at all. Indentation is indentation. We (meaning IDK, programmers, and especially the ones who work on editors) have decided that the display width of tab indents can be adjusted, but won’t extend the same courtesy to space indents.
It’s all code! There’s no reason whatsoever that the Zig-standard 4-space indent can’t be set to take up two columns, six, eight, whatever. It’s trivially easy to detect the difference between indentation and normal spacing.
We just… don’t do it. Who knows why. Perhaps the endless Tab Wars are too much fun. No idea.
In my case, I think my mental model evolved from the time I was in desktop publishing (kids: look it up.) Indenting with spaces and adjusting line / paragraph spacing with carriage returns was a cardinal sin. You’re using the wrong tool. Spaces are for inter-word separation and tab stops are for indenting and precise horizontal placement. Carriage returns will provide line or paragraph spacing according to the paragraph formatting rules you should have set up. So now in the world of code, I just feel like it should be the same.
It sure made the process of producing well-formatted and aesthetically pleasing documents much easier.
You know what, I’m gonna code in MS Word now. lol
You wouldn’t be the first to do your programming in Word. (at least you get spell check).