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

Files in after get loaded even when not using Dracula #83

Closed
benknoble opened this issue May 17, 2018 · 9 comments
Closed

Files in after get loaded even when not using Dracula #83

benknoble opened this issue May 17, 2018 · 9 comments
Labels

Comments

@benknoble
Copy link
Member

What happened

Start vim as follows:

vim -u <(cat <<DOG
set nocp
filetype plugin on
syntax enable
set bg=dark
" Replace the below lines with whatever you need to get Dracula on the runtimepath
runtime bundle/pathogen/autoload/pathogen.vim
execute pathogen#infect()
DOG                                          
) a_file.vim

Once inside, do

:verbose hi vimOption

Note that it is linked to a Dracula group.

But :colorscheme reports default.

What I expected to happen

Without enabling dracula, I get vimOption xxx links to PreProc

When my colorscheme is not dracula, highlight groups should not be linked to Dracula groups.

Screenshot

Machine Info

  • Vim type (vim/gvim/neovim): vim
  • Vim version: 8.0.1800
  • OS: OS X 10.11.6
  • Terminal/Terminal Emulator/VTE: Terminal.app
  • TERM environment variable: xterm-256color

Additional Info

Part of the fix will be not using after directories, as they always get loaded by vim when on the runtimepath. We want to only be included when doing :colorscheme dracula.

@benknoble
Copy link
Member Author

Note that the difficulty is they are automatically sourced by vim when on 'rtp', and I feel like we'd be fighting vim to put them in after, then request that they only get loaded on ColorScheme event and guard against that.

I almost wonder if it wouldn't make more sense to move the stuff to autoload as functions (e.g. autoload/dracula/css.vim has a function for setting up dracula-css highlights) and the calling them in the colors file (e.g. call dracula#css#highlight()). The problem there is that the whole point of syntax files is to only be loaded when editing e.g. a css file, so then you end up triggering a whole bunch of syntax highlights that don't need to be there.

I'm not sure what the best answer is, to be honest. Other popular schemes like Gruvbox, Solarized, and Jellybeans seem to lump all of it in the colors file, which isn't necessarily my preference in terms of maintenance later but it works without any issues.

@dsifford
Copy link
Member

The problem there is that the whole point of syntax files is to only be loaded when editing e.g. a css file, so then you end up triggering a whole bunch of syntax highlights that don't need to be there.

This is just how vim works.

If during your vim session you edit a css file one time, the css groups and highlight regions remain loaded for the duration of your vim session. The same for all other languages.

That's why we do adjustments in ftplugins -- because it allows us to override changes between syntaxes on the fly without it being an issue.

I don't think we should change the way that we're currently doing things just so that a few people can have the ability to hot swap their colorschemes on the fly without some of the dracula adjustments carrying over. If they want a fresh slate, just reload vim.

@benknoble
Copy link
Member Author

benknoble commented May 17, 2018

I don't think we should change the way that we're currently doing things just so that a few people can have the ability to hot swap their colorschemes on the fly without some of the dracula adjustments carrying over. If they want a fresh slate, just reload vim.

In my example above, I'm not hot-swapping. I actually set the colorscheme in my vimrc, but because Dracula was on the runtimepath some of it's adjustments came into effect. This to me is a bug, esp. since the Dracula groups are all cleared.

RE: css example, I understand that and agree. If that's a non-issue, then perhaps the autoload is a potential solution that allows us to keep the split file structure without always loading the files irrespective of the colorscheme.

@dsifford
Copy link
Member

I think we should just add a check to the top of all the files that checks for g:colors_name ==# 'dracula'. Wouldn't that solve the issue?

@benknoble
Copy link
Member Author

It would solve the issue for anybody who doesn't swap colorschemes during a session, which I think was your point.

I'm still not necessarily thrilled about the idea of dracula not playing nice with other schemes (i.e. 'hot-swapping' is very broken), but I don't personally swap often anyways.

@dsifford
Copy link
Member

most color schemes do a syntax reset before setting their highlight groups, so I don't consider that not playing well with others. There shouldn't be any issue that I'm aware of, but I suppose I could be missing something.

@benknoble
Copy link
Member Author

syntax reset (and hi clear) don't affect links, so my example from the original issue text, vimOption, stays linked no matter what. But DraculaCyanItalic gets cleared and so now in

set background=dark

background is just plain white.

As I said, I don't swap often, but it could be a pain point for some users (and might prove to be if I'm writing a custom scheme and then sourcing it to check it out--without a special vimrc to not load dracula, the plugin files get in the way).

@dsifford
Copy link
Member

I still maintain that adding checks in the ftplugin should fix the issues you're describing.

Busy with other things at the moment, I can fix later on this evening or tomorrow

@benknoble
Copy link
Member Author

Alright. We'll try it.

dsifford added a commit that referenced this issue May 18, 2018
dsifford added a commit that referenced this issue May 24, 2018
* address issues #82, #83, #84

* address code review issues

* remove fzf autocmd per code review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants