From e8f0ba33a18f8492f2508aea452faf8bdfa3cbb2 Mon Sep 17 00:00:00 2001 From: Donaldttt Date: Sat, 23 Jul 2022 03:18:11 -0400 Subject: [PATCH 1/7] fix conflict key mapping --- .exp-coc-config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.exp-coc-config b/.exp-coc-config index 9855c30..a943b35 100644 --- a/.exp-coc-config +++ b/.exp-coc-config @@ -83,8 +83,8 @@ autocmd CursorHold * silent call CocActionAsync('highlight') nmap rn (coc-rename) " Formatting selected code. -xmap f (coc-format-selected) -nmap f (coc-format-selected) +xmap f (coc-format-selected) +nmap f (coc-format-selected) augroup mygroup autocmd! From 4fa8c114de68daaad3d4ed9b6e28f0d7df4f05ed Mon Sep 17 00:00:00 2001 From: NAME Date: Sat, 23 Jul 2022 05:13:45 -0400 Subject: [PATCH 2/7] try to use seperate airline for neovim(not complete) --- .vimrc.bundles | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/.vimrc.bundles b/.vimrc.bundles index e6dcb49..879369c 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -49,8 +49,12 @@ " { Plug 'mg979/vim-visual-multi' " } + "if has('nvim') && str2float(g:nvim_version) >= 0.5 + " Plug 'nvim-lualine/lualine.nvim' + "else Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' + "endif " For nvim-bufferline " { @@ -80,6 +84,18 @@ call plug#end() +" Helper functions +" { + + function! SetAirlineTheme(theme) + if has('nvim') && str2float(g:nvim_version) >= 0.5 + else + execute("AirlineTheme " . a:theme) + endif + endfunction + +" } + " Plugin Preferences " { " NerdTree { @@ -107,6 +123,11 @@ endif " } + + "if has('nvim') && str2float(g:nvim_version) >= 0.5 && isdirectory(expand(plugin_dir . "/lualine.nvim")) + " nvim-lualine/lualine.nvim { + " } + "else " vim-airline { " Set configuration options for the statusline plugin vim-airline. " Use the powerline theme and optionally enable powerline symbols. @@ -122,7 +143,8 @@ "let g:airline_theme = 'solarized' endif " } - + "endif + " junegunnjunegunn/fzf { " [Buffers] Jump to the existing window if possible let g:fzf_buffers_jump = 1 @@ -167,10 +189,12 @@ " Inversion if g:colors_name == "github_light" colorscheme github_dark - :AirlineTheme afterglow + call SetAirlineTheme("afterglow") + ":AirlineTheme afterglow else colorscheme github_light - :AirlineTheme silver + call SetAirlineTheme("silver") + ":AirlineTheme silver endif endfunction @@ -191,11 +215,13 @@ if g:colors_name == "afterglow" set background=light colorscheme PaperColor - :AirlineTheme silver + call SetAirlineTheme("silver") + ":AirlineTheme silver else set background=dark colorscheme afterglow - :AirlineTheme afterglow + call SetAirlineTheme("afterglow") + ":AirlineTheme afterglow endif endfunction From b5f69d0e1ae758ed4bd5870e307df4f5c0775ee4 Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Sat, 23 Jul 2022 14:37:10 -0400 Subject: [PATCH 3/7] check if curl is installed --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index 651709c..eb79799 100755 --- a/install.sh +++ b/install.sh @@ -147,6 +147,7 @@ set_up_vim() { program_must_exist "vim" program_must_exist "git" + program_must_exist "curl" sync_repo "$APP_PATH" \ "$REPO_URI" \ From e907e8d76b5181d6e8688fd008aa4f3dce7b6704 Mon Sep 17 00:00:00 2001 From: Donaldttt Date: Sat, 23 Jul 2022 15:05:58 -0400 Subject: [PATCH 4/7] . --- .vimrc | 8 +++++++- .vimrc.bundles | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.vimrc b/.vimrc index daf7d2f..c6d87d2 100644 --- a/.vimrc +++ b/.vimrc @@ -1,9 +1,15 @@ " Modeline and Notes { " Environment { " get current neovim version + let g:vim_version = -1 if has('nvim') - let g:nvim_version = matchstr(execute('version'), 'NVIM v\zs[^\n]*') + let g:vim_type = 'nvim' + let g:vim_version = matchstr(execute('version'), 'NVIM v\zs[^\n]*') + else + let g:vim_type = 'vim' + let g:vim_version = matchstr(execute('version'), 'NVIM v\zs[^\n]*') endif + let g:vim_version = str2float(g:vim_version) " The default leader is '\', but many people prefer ',' as it's in a standard let mapleader = ',' diff --git a/.vimrc.bundles b/.vimrc.bundles index e6dcb49..56ba981 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -78,10 +78,17 @@ Plug 'NLKNguyen/papercolor-theme' " } + if g:vim_type == 'nvim' && g:vim_version > 0.5 + Plug 'xiyaowong/nvim-transparent' + endif call plug#end() " Plugin Preferences " { + " xiyaowong/nvim-transparent { + + " } + " NerdTree { if isdirectory(expand(plugin_dir . "/nerdtree")) let g:NERDShutUp=1 @@ -157,7 +164,7 @@ " has('nvim') check if it's running on nvim rather than " having neovim on your machine - if isdirectory(expand(plugin_dir . "/github-nvim-theme")) && has('nvim') && str2float(g:nvim_version) >= 0.5 + if isdirectory(expand(plugin_dir . "/github-nvim-theme")) && has('nvim') && g:vim_version >= 0.5 let g:github_function_style = "italic" "let g:github_sidebars = ["qf", "vista_kind", "terminal", "packer"] colorscheme github_dark @@ -180,7 +187,8 @@ " { " vim theme "elseif isdirectory(expand(plugin_dir . "/jellybeans.vim")) && !has('nvim') - elseif isdirectory(expand(plugin_dir . "/vim-afterglow")) + elseif isdirectory(expand(plugin_dir . "/vim-afterglow")) + let g:afterglow_inherit_background=1 colorscheme afterglow let g:airline_theme='afterglow' From a90479ac1883c1d5d4b7060055f0f496dd948047 Mon Sep 17 00:00:00 2001 From: Donaldttt Date: Sat, 23 Jul 2022 17:22:31 -0400 Subject: [PATCH 5/7] support transparent backgroud toggle and state saving when close --- .vimrc | 2 - .vimrc.bundles | 196 ++++++++++++++++++++++++++++++++++++------------- 2 files changed, 147 insertions(+), 51 deletions(-) diff --git a/.vimrc b/.vimrc index c6d87d2..19405d5 100644 --- a/.vimrc +++ b/.vimrc @@ -19,8 +19,6 @@ " General { - set background=dark " Assume a dark background - noremap h :noh " turn off highlight filetype plugin indent on " Automatically detect file types. diff --git a/.vimrc.bundles b/.vimrc.bundles index a2e1f63..c0431af 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -8,6 +8,7 @@ " Plugin directory let config_dir = '~/.dotfiles/' let plugin_dir = '~/.vim/plugged/' + let g:vim_dir = '~/.vim/' call plug#begin(plugin_dir) Plug 'neoclide/coc.nvim', {'branch': 'release'} @@ -77,7 +78,6 @@ " vim theme " { - Plug 'nanotech/jellybeans.vim' Plug 'danilo-augusto/vim-afterglow' Plug 'NLKNguyen/papercolor-theme' " } @@ -90,13 +90,6 @@ " Helper functions " { - function! SetAirlineTheme(theme) - if has('nvim') && str2float(g:nvim_version) >= 0.5 - else - execute("AirlineTheme " . a:theme) - endif - endfunction - " } " Plugin Preferences @@ -112,7 +105,7 @@ nnoremap e :NERDTreeToggle "nmap e :NERDTreeFind - let NERDTreeShowBookmarks=1 + "let NERDTreeShowBookmarks=1 "let NERDTreeIgnore=['\.py[cd]$', '\~$', '\.swo$', '\.swp$', '^\.git$', '^\.hg$', '^\.svn$', '\.bzr$'] let NERDTreeChDirMode=0 let NERDTreeQuitOnOpen=1 @@ -181,6 +174,89 @@ " THEME APPEARANCE " { + " dark or light + if filereadable(expand(g:vim_dir . '.light_theme.signal')) + let g:theme_color = 'light' + else + let g:theme_color = 'dark' + endif + + " what to use for dark theme + let g:dark_theme = '' + + " what to use for light theme + let g:light_theme = '' + + " transparent backgroud for supported terminal emulator + if filereadable(expand(g:vim_dir . '.transparent_theme.signal')) + let g:transparent_theme = v:true + else + let g:transparent_theme = v:false + endif + + " Change bottom airline/lualine theme + " Currently only support airline + function! SetAirlineTheme(theme) + if has('nvim') && g:vim_version >= 0.5 + else + execute('AirlineTheme ' . a:theme) + endif + endfunction + + function! EnableTransparent() + if g:vim_type == 'nvim' && g:vim_version > 0.5 + :TransparentEnable + elseif g:theme_color == 'dark' + let g:afterglow_inherit_background=1 + execute("colorscheme " . g:dark_theme) + elseif g:theme_color == 'light' + let g:PaperColor_Theme_Options = { + \ 'theme': { + \ 'default.light': { + \ 'transparent_background': 1 + \ } + \ } + \ } + execute("colorscheme " . g:light_theme) + endif + endfunction + + function! DisableTransparent() + if g:vim_type == 'nvim' && g:vim_version > 0.5 + :TransparentDisable + elseif g:theme_color == 'dark' + let g:afterglow_inherit_background=0 + execute("colorscheme " . g:dark_theme) + elseif g:theme_color == 'light' + let g:PaperColor_Theme_Options = { + \ 'theme': { + \ 'default.light': { + \ 'transparent_background': 0 + \ } + \ } + \ } + execute("colorscheme " . g:light_theme) + endif + endfunction + + " ToggleTransparent background + " only works in dark theme + function! ToggleTransparent() + if g:transparent_theme == v:true + call DisableTransparent() + let g:transparent_theme = v:false + if filereadable(expand(g:vim_dir . '.transparent_theme.signal')) + call delete(expand(g:vim_dir . ".transparent_theme.signal")) + endif + else + call EnableTransparent() + let g:transparent_theme = v:true + call system("touch " . g:vim_dir . ".transparent_theme.signal") + endif + endfunction + + noremap tb :call ToggleTransparent() + " { " nvim only theme @@ -189,53 +265,75 @@ if isdirectory(expand(plugin_dir . "/github-nvim-theme")) && has('nvim') && g:vim_version >= 0.5 let g:github_function_style = "italic" "let g:github_sidebars = ["qf", "vista_kind", "terminal", "packer"] - colorscheme github_dark + let g:dark_theme = 'github_dark' + let g:light_theme = 'github_light' - " Allow to trigger background - function! ToggleBG() - " Inversion - if g:colors_name == "github_light" - colorscheme github_dark - call SetAirlineTheme("afterglow") - ":AirlineTheme afterglow - else - colorscheme github_light - call SetAirlineTheme("silver") - ":AirlineTheme silver - endif - endfunction - - noremap bg :call ToggleBG() " } " { " vim theme - "elseif isdirectory(expand(plugin_dir . "/jellybeans.vim")) && !has('nvim') - elseif isdirectory(expand(plugin_dir . "/vim-afterglow")) - - let g:afterglow_inherit_background=1 - colorscheme afterglow - let g:airline_theme='afterglow' - - " Allow to trigger background - function! ToggleBG() - " Inversion - if g:colors_name == "afterglow" - set background=light - colorscheme PaperColor - call SetAirlineTheme("silver") - ":AirlineTheme silver - else - set background=dark - colorscheme afterglow - call SetAirlineTheme("afterglow") - ":AirlineTheme afterglow - endif - endfunction - - noremap bg :call ToggleBG() + elseif isdirectory(expand(plugin_dir . "/vim-afterglow")) + if isdirectory(expand(plugin_dir . "/papercolor-theme")) + let g:light_theme = 'PaperColor' + endif + "let g:afterglow_inherit_background=1 + let g:dark_theme = 'afterglow' endif " } + + if g:theme_color == 'dark' + set background=dark + execute("colorscheme " . g:dark_theme) + let g:airline_theme='afterglow' + else + set background=light + execute("colorscheme " . g:light_theme) + let g:airline_theme='silver' + endif + + " since in .vimrc we cannot call plugin function as they + " are not loaded (:help startup) + if g:transparent_theme + if g:vim_type == 'nvim' && g:vim_version > 0.5 + let g:transparent_enabled = v:true + else + call EnableTransparent() + endif + else + if g:vim_type == 'nvim' && g:vim_version > 0.5 + let g:transparent_enabled = v:false + else + call DisableTransparent() + endif + endif + + " Allow to trigger background + function! ToggleBG() + " Inversion + if g:theme_color == "dark" + set background=light + execute("colorscheme " . g:light_theme) + call SetAirlineTheme("silver") + let g:theme_color = 'light' + call system("touch " . g:vim_dir . ".light_theme.signal") + else + set background=dark + execute("colorscheme " . g:dark_theme) + call SetAirlineTheme("afterglow") + let g:theme_color = 'dark' + if filereadable(expand(g:vim_dir . '.light_theme.signal')) + call delete(expand(g:vim_dir . ".light_theme.signal")) + endif + endif + + if g:transparent_theme + call EnableTransparent() + else + call DisableTransparent() + endif + endfunction + + noremap bg :call ToggleBG() " } From 0746603f6e45c66a6466755f475666de303db60b Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Sat, 23 Jul 2022 17:28:06 -0400 Subject: [PATCH 6/7] fix bugs --- .vimrc.bundles | 1 + 1 file changed, 1 insertion(+) diff --git a/.vimrc.bundles b/.vimrc.bundles index c0431af..8d603a0 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -198,6 +198,7 @@ " Currently only support airline function! SetAirlineTheme(theme) if has('nvim') && g:vim_version >= 0.5 + execute('AirlineTheme ' . a:theme) else execute('AirlineTheme ' . a:theme) endif From 3a22bdb66a18288fbdb094e8036020391206c3f4 Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Sat, 23 Jul 2022 17:33:06 -0400 Subject: [PATCH 7/7] update comment --- .vimrc.bundles | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.vimrc.bundles b/.vimrc.bundles index 8d603a0..b2f320c 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -1,3 +1,7 @@ +" If anything not work as expected. Please make sure all plugins +" are installed by running: +" :PlugInstall + " Environment { " Basics { @@ -16,14 +20,14 @@ " syntax highlighting(and more) for typescript " { Plug 'leafgarland/typescript-vim' - " } + " } " { Plug 'alvan/vim-closetag' let g:closetag_filenames = '*.html,*.xhtml,*.phtml, *.js' " } "{ - Plug 'altercation/vim-colors-solarized' + "Plug 'altercation/vim-colors-solarized' "} Plug 'scrooloose/nerdtree' @@ -170,8 +174,6 @@ " } " } - - " THEME APPEARANCE " { " dark or light