joshdick / onedark.vim

A dark Vim/Neovim color scheme inspired by Atom's One Dark syntax theme.
MIT License
3.9k stars 531 forks source link

Vim8: Starting with onedark enabled produces errors, has to be set after vim is running #110

Closed DemarcatedTitle closed 6 years ago

DemarcatedTitle commented 7 years ago

Terminal Emulator Info

Terminal emulator(s) and their version(s) used, if applicable: Replace this text if applicable; otherwise delete this section

Output From vim --version

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 30 2017 17:33:26)
Included patches: 1-1168
Compiled by me
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +file_in_path    +mouse_sgr       +tag_old_static
+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +float           +mouse_urxvt     -tcl
+balloon_eval    +folding         +mouse_xterm     +termguicolors
+browse          -footer          +multi_byte      +terminal
++builtin_terms  +fork()          +multi_lang      +terminfo
+byte_offset     +gettext         -mzscheme        +termresponse
+channel         -hangul_input    +netbeans_intg   +textobjects
+cindent         +iconv           +num64           +timers
+clientserver    +insert_expand   +packages        +title
+clipboard       +job             +path_extra      +toolbar
+cmdline_compl   +jumplist        +perl            +user_commands
+cmdline_hist    +keymap          +persistent_undo +vertsplit
+cmdline_info    +lambda          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con_gui  +lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      +X11
+dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     +xim
+emacs_tags      +mouseshape      +startuptime     +xpm
+eval            +mouse_dec       +statusline      +xsmp_interact
+ex_extra        -mouse_gpm       -sun_workshop    +xterm_clipboard
+extra_search    -mouse_jsbterm   +syntax          -xterm_save
+farsi           +mouse_netterm   +tag_binary
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/local/share/vim"
 f-b for $VIMRUNTIME: "/usr/local/share/vim/vim80"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2   -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -ldl  -L/usr/lib -llua5.1 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.22/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config -lpython2.7   -lruby-2.3 -lpthread -lgmp -ldl -lcrypt -lm

Issue Description

I start vim with colo set to one dark, it throws errors. I start it without, no errors thrown.

After vim is started, setting colo to onedark works fine.

Error detected while processing /home/author/.vim/pack/plugins/start/onedark.vim/colors/onedark.vim: line 110: E117: Unknown function: onedark#GetColors E15: Invalid expression: onedark#GetColors() line 112: E121: Undefined variable: s:colors E15: Invalid expression: s:colors.red (truncated)

joshdick commented 7 years ago

This is probably happening because colorscheme onedark is probably being run before autoload/onedark.vim is loaded in your .vimrc, but autoload/onedark.vim should be loaded first.

Pasting or linking to your .vimrc would help me confirm whether that's the case.

DemarcatedTitle commented 7 years ago

I feel like it's probably pretty long, but here it goes: Error still happens when colo set at very bottom

let g:syntastic_javascript_checkers = ['eslint']
"HTML vs html matters
" let g:syntastic_html_checkers= ['jshint']
let g:syntastic_html_checkers= ['eslint']
let g:syntastic_json_checkers = ['jsonlint']
if $SHELL =~ 'bin/fish'
  set shell=/bin/sh
endif
set term=xterm-256color
" let g:ycm_path_to_python_interpreter = '/usr/bin/python'
"***
set foldmethod=marker
" Enable the list of buffers
let g:airline#extensions#tabline#enabled = 1
"
" " Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
" Move to the next buffer
nmap <leader>l :bnext<CR>
" " Move to the previous buffer
nmap <leader>h :bprevious<CR>
" " Move to the previous buffer
nmap <leader>q :bd<CR>
let NERDTreeQuitOnOpen=1
set t_Co=256 
highlight normal ctermbg=none

"Backup settings for mucomplete
set completeopt+=menuone

"************************
" let g:mucomplete#enable_auto_at_startup = 1
" ^This might be kind of unusable. Typing is slooooow if i'm just writing a
" basic comment. 
" set complete-=i
" set complete-=t
let g:mucomplete#chains = { 'default' : ['file', 'ulti','omni'] }
set noshowmode shortmess+=c
set completeopt-=preview
set completeopt+=menuone,noinsert,noselect
" set completeopt+=noinsert
" set noinfercase
" let g:clang_library_path = '/usr/local/opt/llvm/lib/libclang.dylib'
" let g:clang_user_options = '-std=c++14'
" let g:clang_complete_auto = 1
" let g:mucomplete#enable_auto_at_startup = 1
"
" From Sam's vimrc************************************
set smartindent
set autoindent
set autoread                                                 " reload files when changed on disk, i.e. via `git checkout`
set backspace=2                                              " Fix broken backspace in some setups
set backupcopy=yes                                           " see :help crontab
set clipboard=unnamed                                        " yank and paste with the system clipboard
set directory-=.                                             " don't store swapfiles in the current directory
set encoding=utf-8
set ignorecase                                               " case-insensitive search
set incsearch                                                " search as you type
set laststatus=2                                             " always show statusline
set list                                                     " show trailing whitespace
set listchars=tab:▸\ 
" ,trail:▫
set number                                                   " show line numbers
set ruler                                                    " show where you are
set scrolloff=3                                              " show context above/below cursorline
set showcmd
set smartcase                                                " case-sensitive search if any caps
set tabstop=8                                                " actual tabs occupy 8 characters
set wildignore=log/**,node_modules/**,target/**,tmp/**,*.rbc
set wildmenu                                                 " show a navigable menu for tab completion
set wildmode=longest,list,full
" set noexpandtab
" set shiftwidth=2
" set softtabstop=2
set shiftwidth=4
set softtabstop=4
" From Sam's vimrc^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
autocmd BufRead,BufNewFile *.wiki setlocal spell

set fdm=marker
set nocompatible
filetype plugin on

au FileType vimwiki set textwidth=80
au FileType python set formatoptions=croql
command! -nargs=+ NewGrep execute 'silent grep! -m 1 -r <args>' | copen 10
set runtimepath^=~/.vim/bundle/ctrlp.vim
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/node_modules/* 
" :g//# 
" ^ when typed and executed, does an interesting thing that shows you the lines where your search 
" query is found
" This makes leader space remove the highlight from a search
nnoremap <leader><space> :noh<cr>
nnoremap <leader>t :put =strftime('%c')<cr>
" line 111 is for transparency friendliness. 
hi Normal ctermbg=none
highlight NonText ctermbg=none

" ##snippet stuff
" For ultisnips and mucomplete apparently ultisnips needs to be the up to date
" one, not the one from the vim-addon-manager package installed with apt-get
let g:UltiSnipsExpandTrigger = "<nop>"
let g:ulti_expand_or_jump_res = 0
function ExpandSnippetOrCarriageReturn()
    let snippet = UltiSnips#ExpandSnippetOrJump()
    if g:ulti_expand_or_jump_res > 0
        return snippet
    else
        return "\<CR>"
    endif
endfunction
inoremap <expr> <CR> pumvisible() ? "<C-R>=ExpandSnippetOrCarriageReturn()<CR>" : "\<CR>"

let g:jsx_ext_required = 0
let g:UltiSnipsSnippetDirectories=["UltiSnips"]
autocmd FileType javascript.jsx,javascript setlocal formatprg=prettier\ --tab-width\ 4
" autocmd BufWritePre *.js :normal gggqG
nmap <leader>f gggqG
let g:neoformat_try_formatprg = 1
autocmd BufWritePre *.js Neoformat

colo codedark 

syntax on 

let g:onedark_termcolors=256
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
colo onedark
DemarcatedTitle commented 7 years ago

This is probably happening because colorscheme onedark is probably being run before autoload/onedark.vim is loaded in your .vimrc, but autoload/onedark.vim should be loaded first.

See, I thought it was some kind of race condition type of thing. I recently compiled vim 8 on this machine and I know they made some changes, particularly regarding async stuff and adding a default package management system, which I opted to use over pathogen.

packloadall seems to be what fixes it.

I would like to add something to the readme and submit a pr if this solution seems appropriate to you.

joshdick commented 6 years ago

I was unable to reproduce this issue using Vim 8.0.1175 on macOS High Sierra, installed with Homebrew, using your configuration (I commented out the syntastic statusline part of your configuration, which should not be related.)

To be clear, you have this file at ~/.vim/colors/onedark.vim and this file at ~/.vim/autoload/onedark.vim?

DemarcatedTitle commented 6 years ago

I have the repo in ~/.vim/pack/plugins/start/and haven't ran into trouble after adding packloadall to my .vimrc.

joshdick commented 6 years ago

I see, I didn't realize you were using the Vim 8 packages mechanism instead of following the installation instructions in the README. After reading :help packages it seems like I could make some symlinks inside the repo that make the plugin behave better as a Vim 8 package, but I couldn't get it to work; I could never get the current autoload/onedark.vim file to load before the colorscheme attempts to call onedark#GetColors(). There has to be a better solution than using packloadall, but I can't figure out what it is.

gorillamoe commented 6 years ago

I second this!

When using Vim's (new) native package management capabilities, this package/plugin spits out errors.

packloadall seems to be a good workaround for this.

nvs commented 6 years ago

Rather than installing into pack/*/start and having to explicitly rely on packloadall, an alternative is to put things in pack/*/opt. This allows the following:

packadd! onedark.vim
colorscheme onedark
gorillamoe commented 6 years ago

@nvs I should have thought about this before. This is way better! Thanks for enlightening us!

joshdick commented 6 years ago

Great solution @nvs, about to push an update to the README.

qdouasbin commented 5 years ago

I was unable to reproduce this issue using Vim 8.0.1175 on macOS High Sierra, installed with Homebrew, using your configuration (I commented out the syntastic statusline part of your configuration, which should not be related.)

To be clear, you have this file at ~/.vim/colors/onedark.vim and this file at ~/.vim/autoload/onedark.vim?

Thanks for this answer! I had the same problem but simply forgot to copy the autoload file. The problem was that on;y the colors/onedark.vim was loaded.