sainnhe / gruvbox-material

Gruvbox with Material Palette
MIT License
1.9k stars 164 forks source link

colors only display on sudo, not normal vim #151

Closed saltbr1nger closed 1 year ago

saltbr1nger commented 1 year ago

https://imgur.com/a/upANM5O

Installed theme, followed manual installation directions. No colors show at all when normal vim, but sudo vim will show proper colors. Same thing for default color schemes. Not sure what's going wrong here.

antoineco commented 1 year ago

sudo vim is showing some colors, but definitely not gruvbox-material colors.

Do you have syntax on inside you vimrc?

saltbr1nger commented 1 year ago

Yeah. Here's my .vimrc:

" All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by " the call to :runtime you can find below. If you wish to change any of those " settings, you should do it in this file (/etc/vim/vimrc), since debian.vim " will be overwritten everytime an upgrade of the vim packages is performed. " It is recommended to make changes after sourcing debian.vim since it alters " the value of the 'compatible' option.

runtime! debian.vim

" Vim will load $VIMRUNTIME/defaults.vim if the user does not have a vimrc. " This happens after /etc/vim/vimrc(.local) are loaded, so it will override " any settings in these files. " If you don't want that to happen, uncomment the below line to prevent " defaults.vim from being loaded. "let g:skip_defaults_vim = 1

" Uncomment the next line to make Vim more Vi-compatible " NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous " options, so any other options should be set AFTER setting 'compatible'. "set compatible

" Vim5 and later versions support syntax highlighting. Uncommenting the next " line enables syntax highlighting by default. if has("syntax") syntax on endif

" If using a dark background within the editing area and syntax highlighting " turn on this option as well "set background=dark

" Uncomment the following to have Vim jump to the last position when " reopening a file "au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif

" Uncomment the following to have Vim load indentation rules and plugins " according to the detected filetype. "filetype plugin indent on

" The following are commented out as they cause vim to behave a lot " differently from regular Vi. They are highly recommended though. set showcmd " Show (partial) command in status line. set showmatch " Show matching brackets. set ignorecase " Do case insensitive matching set smartcase " Do smart case matching set incsearch " Incremental search set autowrite " Automatically save before commands like :next and :make set hidden " Hide buffers when they are abandoned set mouse=a " Enable mouse usage (all modes)

" Source a global configuration file if available "if filereadable("/etc/vim/vimrc.local") " source /etc/vim/vimrc.local "endif

set termguicolors

set background=dark

let g:gruvbox_material_background='soft'

colorscheme gruvbox-material

antoineco commented 1 year ago

It looks like the following options are missing from your vimrc:

filetype plugin on  " load filetype specific plugins
filetype indent on  " load filetype specific indentations

These are critical to detect the file type automatically and load the associated scripts.

saltbr1nger commented 1 year ago

I'm a huge noob at this. I added those exact lines and nothing happens. But I also dont know what specific plugins or indentations I should be referencing either.

antoineco commented 1 year ago

The file type plugins are part of Vim, there is nothing to enable on your side.

If the colorscheme doesn't load, it means it wasn't installed properly, and you should see an error while starting Vim.

saltbr1nger commented 1 year ago

Hmm, ok. Well I have added filetype on, filetype plugin on, filetype indent on, syntax on; no errors executing vim or :colo gruvbox-material. Unfortunately, normal vim startup still does not show any syntax colors, and only sudo vim startup will display colors.

I wonder if it might be because i have multiple vimrc files? i have them in /etc/vim/vimrc (& vimrc.tiny) ~/.vimrc /usr/share/vim/vimrc (& vimrc.tiny) /usr/share/vim/vim82/gvimrc_example.vim /usr/share/vim/vim82/vimrc_example.vim

plus a bunch of vimrc and vimrc.tiny in /snap/corexx/xxxx/ directories which i suspect are backups.

could it be that my ~/.vimrc is being superceded by another vimrc file configuration?

antoineco commented 1 year ago

I don't think so, ~/.vimrc is usually the last RC file to be loaded as far as I know. Try the :version command to see what RC files are being considered by your installation.

If you type :colorscheme in Vim, what does it return? What about :syntax and :filetype?

saltbr1nger commented 1 year ago

:version gives me Vi IMproved 8.2 system vimrc file: $VIM/vimrc user vimrc file: $HOME/.vimrc 2nd user vimrc: ~/.vim/vimrc user exrc file: $HOME/exrc defaults file: $VIMRUNTIME/defaults.vim fall-back for $VIM: /usr/share/vim

:colorscheme gives me gruvbox-material ':syntax' No Syntax items defined for this buffer ':filetype' shows detection: ON plugin: ON indent: ON

antoineco commented 1 year ago

':syntax' No Syntax items defined for this buffer

There you go.

You opened a file type which Vim doesn't have syntax highlights for (you can force a file type with e.g. :set ft=sh just to try).

Open a .sh or a .vim file, or even you .vimrc. Those should work out of the box. If not, you have a larger issue with your Vim installation, which is out of scope for this project.

saltbr1nger commented 1 year ago

Yeah, it turned out to be an issue with my Vim installation overall. Purged and reinstalled, seems to be working as intended now.