joshdick / onedark.vim

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

How do I change the selected line color? #299

Closed Macko-pp closed 2 years ago

Macko-pp commented 2 years ago

Terminal Emulator Info

Hyper 3.2.0

Output From vim --version

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Dec 17 2021 18:32:29)
macOS version - arm64
Included patches: 1-2671, 3402, 3409, 3428, 3489
Compiled by root@apple.com
Normal version without GUI.  Features included (+) or not (-):
+acl               -farsi             +mouse_sgr         +tag_binary
-arabic            +file_in_path      -mouse_sysmouse    -tag_old_static
+autocmd           +find_in_path      -mouse_urxvt       -tag_any_white
+autochdir         +float             +mouse_xterm       -tcl
-autoservername    +folding           +multi_byte        -termguicolors
-balloon_eval      -footer            +multi_lang        +terminal
-balloon_eval_term +fork()            -mzscheme          +terminfo
-browse            -gettext           +netbeans_intg     +termresponse
+builtin_terms     -hangul_input      +num64             +textobjects
+byte_offset       +iconv             +packages          +textprop
+channel           +insert_expand     +path_extra        +timers
+cindent           +ipv6              -perl              +title
-clientserver      +job               +persistent_undo   -toolbar
+clipboard         +jumplist          +popupwin          +user_commands
+cmdline_compl     -keymap            +postscript        -vartabs
+cmdline_hist      +lambda            +printer           +vertsplit
+cmdline_info      -langmap           -profile           +virtualedit
+comments          +libcall           -python            +visual
-conceal           +linebreak         -python3           +visualextra
+cryptv            +lispindent        +quickfix          +viminfo
+cscope            +listcmds          +reltime           +vreplace
+cursorbind        +localmap          -rightleft         +wildignore
+cursorshape       -lua               +ruby/dyn          +wildmenu
+dialog_con        +menu              +scrollbind        +windows
+diff              +mksession         +signs             +writebackup
+digraphs          +modify_fname      +smartindent       -X11
-dnd               +mouse             -sound             -xfontset
-ebcdic            -mouseshape        +spell             -xim
-emacs_tags        -mouse_dec         +startuptime       -xpm
+eval              -mouse_gpm         +statusline        -xsmp
+ex_extra          -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+extra_search      -mouse_netterm     +syntax            -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa

Issue Description

I took a look at this issue because it covered what I wanted to do, it worked, but the line where the cursor is still maintained the old brown color which I didn't want. I know there is a way to fix this using the same method I used to fix the bg but I don't know how to do it.

Thanks in advance!

joshdick commented 2 years ago

If I correctly understand what you're asking, the same README example referenced in the issue you linked can be slightly tweaked to override the CursorLine highlight, which styles what I think you mean by "the line where the cursor is" (this would need to appear before the colorscheme onedark line in your ~/.vimrc):

" `gui` is the hex color code used in GUI mode/nvim true-color mode
" `cterm` is the color code used in 256-color mode
" `cterm16` is the color code used in 16-color mode
if (has("autocmd"))
  augroup colorset
    autocmd!
    let s:cursor_grey = { "gui": "#2C323C", "cterm": "236", "cterm16": "0" } " Tweak to personal taste
    autocmd ColorScheme * call onedark#set_highlight("CursorLine", { "bg": s:cursor_grey })
  augroup END
endif

Alternatively, your mention of "brown" makes me think you're running the theme in 256-color mode. If you are able to use true-color mode per the REAMDE, the colors will look better in general / the default CursorLine color should look grey and not brown.

Macko-pp commented 2 years ago

Hi! Sorry for the late response, I have been trying for a couple of days and have not been able to change the color of the cursor line even with the snippet you gave me. I have grown to like it because it differentiates the bg from the cursor line making it easier to find. I also have another question, how do I actually configure true color? I haven't been able to find something to actually put into my vimrc and the set termguicolors isn't working. Thanks for the help!

joshdick commented 2 years ago

Hi! Sorry for the late response, I have been trying for a couple of days and have not been able to change the color of the cursor line even with the snippet you gave me.

I realized I had one copy-paste mistake in the snippet but just edited it and fixed that, can you try again?

How do I actually configure true color?

Can you confirm that you tried following Step 2 of the installation instructions exactly as written?

Macko-pp commented 2 years ago

Hi! I am sooo sorry for responding this late, but I just haven't had time to respond. Anyways, I tried what you said and also changed to termcolors: 16 because I installed a hyper onedark theme and it worked! The only thing is that the comments are white for some reason :|

Screen Shot 2022-03-24 at 8 30 14 AM

Thanks for all the help!

joshdick commented 2 years ago

No worries and you're welcome!

16-color mode is specifically designed to work with the terminal themes that ship with onedark.vim itself: https://github.com/joshdick/onedark.vim/tree/main/term Using 16-color mode with any other terminal theme can result in behavior like you're seeing.

Even so, you're better off switching to true-color mode as I previously mentioned, if your terminal supports it. True-color mode will always show proper colors regardless of your terminal's configured colors.