From de3d212847e554cbd82ac6ad88133f92524fc5dd Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Thu, 23 Feb 2023 09:52:50 -0500 Subject: [PATCH] . --- .vimrc | 59 +++++++--------------------------------- .vimrc.bundles | 71 ++++++++++++++---------------------------------- config/theme.vim | 3 ++ 3 files changed, 34 insertions(+), 99 deletions(-) diff --git a/.vimrc b/.vimrc index 4414486..397284d 100644 --- a/.vimrc +++ b/.vimrc @@ -1,5 +1,3 @@ -" Modeline and Notes { -" Environment { " get current neovim version let g:vim_version = -1 @@ -34,22 +32,19 @@ let mapleader = ',' let maplocalleader = '_' -" } - " General { noremap h :noh " turn off highlight filetype plugin indent on " Automatically detect file types. syntax on " Syntax highlighting - "set mouse=a " Automatically enable mouse usage + set mouse=a " Automatically enable mouse usage set mousehide " Hide the mouse cursor while typing - scriptencoding utf-8 - + " scriptencoding utf-8 " Most prefer to automatically switch to the current file directory when " a new buffer is opened; - autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9\]*://" | lcd %:p:h | endif + " autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9\]*://" | lcd %:p:h | endif " Always switch to the current file directory set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter') @@ -104,15 +99,10 @@ set cmdheight=1 " get rid of the extra useless line at the bottom(if not working, probably a plugin is changing the value) - "highlight clear SignColumn " SignColumn should match background - "highlight clear LineNr " Current line number row will have same background color in relative mode - "highlight clear CursorLineNr " Remove highlight color from current line number - if has('cmdline_info') set ruler " Show the ruler set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids set showcmd " Show partial commands in status line and - endif set backspace=indent,eol,start " Backspace for dummies @@ -136,7 +126,6 @@ " Formatting { - "set nowrap " Do not wrap long lines set autoindent " Indent at the same level of the previous line set expandtab " Tabs are spaces, not tabs set shiftwidth=4 " Use indents of 4 spaces @@ -173,33 +162,16 @@ noremap j gj noremap k gk - " Stupid shift key fixes - " if !exists('g:spf13_no_keyfixes') - " if has("user_commands") - " command! -bang -nargs=* -complete=file E e - " command! -bang -nargs=* -complete=file W w - " command! -bang -nargs=* -complete=file Wq wq - " command! -bang -nargs=* -complete=file WQ wq - " command! -bang Wa wa - " command! -bang WA wa - " command! -bang Q q - " command! -bang QA qa - " command! -bang Qa qa - " endif - - " cmap Tabe tabe - " endif - " Yank from the cursor to the end of the line, to be consistent with C and D. nnoremap Y y$ - if has('nvim') - set foldmethod=expr - set foldexpr=nvim_treesitter#foldexpr() - else - set foldmethod=syntax - autocmd FileType python set foldmethod=indent - endif +" if has('nvim') +" set foldmethod=expr +" set foldexpr=nvim_treesitter#foldexpr() +" else +" set foldmethod=syntax +" autocmd FileType python,vim set foldmethod=indent +" endif " so when a buffer open it wouldn't be fold by default set nofoldenable @@ -229,9 +201,6 @@ map zl zL map zh zH - " Easier formatting - " nnoremap q gwip - " Functions { " Initialize directories for undo, swap, viewdir @@ -306,14 +275,6 @@ vnoremap p "0p -" TIPS: :hi can be used to check current highlight options -" Coc has wired floating color, this is an attempt to fix it -" highlight CocFloating ctermbg=green -" highlight FgCocErrorFloatBgCocFloating cterm=bold ctermfg=124 guifg=DarkRed ctermbg=green - -" c highlight fix -" highlight cComment ctermfg=12 guifg=#458588 - " copy to system set clipboard=unnamed diff --git a/.vimrc.bundles b/.vimrc.bundles index ed1a76c..d4cb177 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -37,7 +37,7 @@ Plug 'dstein64/vim-startuptime' Plug 'simeji/winresizer' - Plug 'rust-lang/rust.vim' + Plug 'rust-lang/rust.vim', { 'for': ['rust'] } Plug 'tpope/vim-surround' Plug 'rhysd/conflict-marker.vim' @@ -64,7 +64,7 @@ Plug 'tpope/vim-commentary' " put text in neibouring tmux pane into auto complete - Plug 'wellle/tmux-complete.vim' + " Plug 'wellle/tmux-complete.vim' Plug 'ludovicchabant/vim-gutentags', { 'for': ['c', 'cpp'] } Plug 'lambdalisue/readablefold.vim' @@ -80,7 +80,7 @@ " The bottom buffer display Plug 'Donaldttt/vim-bufferline' Plug 'ryanoasis/vim-devicons' - " Plug 'Yggdroot/indentLine' + Plug 'junegunn/goyo.vim' endif if executable('node') @@ -182,6 +182,13 @@ endfunction \ { 'header': [' RECENT'], 'type': 'files' }, \ { 'header': [' SESSIONS'], 'type': 'sessions' }, \ ] + + " session related KeyBinding. These KeyBinding uses function from startify + nnoremap s :SSave + nnoremap l :SLoad + nnoremap d :SDelete! + nnoremap c :SClose + endif " } " @@ -237,6 +244,7 @@ endfunction " } " bling/vim-bufferline { + if HasPlug("vim-bufferline") && HasPlug("vim-airline") let g:bufferline_echo = 0 let g:bufferline_modified = '+' @@ -248,11 +256,14 @@ endfunction let g:bufferline_fixed_index = -1 let g:bufferline_inactive_highlight = 'StatusLineNC' let g:bufferline_active_highlight = 'StatusLine' + endif " } " mbbill/undotree { + if HasPlug("undotree") nnoremap ut :UndotreeToggle + endif " } " airblade/vim-rooter { @@ -299,20 +310,11 @@ endfunction " nvim-tree.lua { if g:vim_type == 'nvim' && HasPlug("nvim-tree.lua") - " Hide vim bottom statusline - " autocmd FileType NvimTree setlocal noshowmode noruler laststatus=0 noshowcmd - " set noshowmode noruler laststatus=0 noshowcmd - " autocmd BufRead,BufNewFile NvimTree set laststatus=0 " This will work instead endif " } - "if has('nvim') && str2float(g:nvim_version) >= 0.5 && HasPlug("lualine.nvim") - " nvim-lualine/lualine.nvim { - " } - "else - " " vim-airline { - if g:vim_type == 'vim' && HasPlug("vim-airline") + if HasPlug("vim-airline") " Set configuration options for the statusline plugin vim-airline. " Use the powerline theme and optionally enable powerline symbols. @@ -360,6 +362,7 @@ endfunction "endif " junegunn/fzf { + if HasPlug("fzf") && HasPlug("fzf.vim") " [Buffers] Jump to the existing window if possible let g:fzf_buffers_jump = 1 @@ -373,7 +376,6 @@ endfunction let g:fzf_preview_window = ['right:50%', 'ctrl-/'] end - " check if ripgrep is installed if ! executable('rg') command! -bang -nargs=* Rg @@ -383,11 +385,11 @@ endfunction endif noremap r :Rg noremap f :Files + endif " } " neoclide/coc.nvim { if HasPlug("coc.nvim") && executable('node') - " add desired extensions to the following global variable " coc-clangd: c/c++, may need to install clangd seperatly if filereadable(g:mydotfiles_directory . "/coc-nvim-config.vim") @@ -447,9 +449,6 @@ endfunction call system("touch " . g:vim_dir . a:name) endfunction - " all signal files: - " .transparent_light_theme.signal - " .transparent_dark_theme.signal function! SignalFileExists(filename) if filereadable(g:vim_dir . a:filename) return v:true @@ -489,7 +488,9 @@ endfunction if g:vim_type == 'nvim' && g:vim_version >= 0.5 "execute('AirlineTheme ' . a:theme) else - execute('AirlineTheme ' . a:theme) + if HasPlug('vim-airline') && HasPlug('vim-airline-themes') + execute('AirlineTheme ' . a:theme) + endif endif endfunction @@ -497,29 +498,6 @@ endfunction " There is no plugin for this for nvim < 0.5 or vim without lua support function! TransparentBackgroundFix() if !has('nvim') || g:vim_version < 0.5 - " if v:true - " if v:true - highlight CursorLineNr ctermbg=none - highlight SignColumn ctermbg=none - if v:false - "highlight CursorLineNr ctermbg=none - highlight CocWarningHighlight ctermbg=none - highlight CocErrorSign ctermbg=none ctermfg=9 cterm=bold - highlight CocErrorHighlight ctermbg=none ctermfg=9 cterm=underline,bold - highlight CocInfoHighlight ctermbg=none - highlight CocHintHighlight ctermbg=none - highlight CocWarningSign ctermbg=none - highlight CocInfoSign ctermbg=none - highlight CocHintSign ctermbg=none - if g:dark_or_light_theme == 'dark' - highlight! link TempColor Visual - highlight! link CocFloating TempColor - highlight! link CocErrorFloat TempColor - highlight! link CocWarningFloat TempColor - highlight! link CocInfoFloat TempColor - highlight! link CocHintFloat TempColor - endif - endif endif endfunction @@ -572,7 +550,6 @@ endfunction \ } \ } execute("colorscheme " . g:light_theme) - DeleteSignalFile() endif endif endfunction @@ -663,7 +640,7 @@ endfunction call SetDarkTheme() call SetStatusLineTheme(g:airline_dark_theme) " for saving theme state - call DeleteSignalFile(".light_theme.signal") + call DeleteSignalFile('.light_theme.signal') endif if (g:transparent_dark_theme && g:dark_or_light_theme == 'dark') || (g:transparent_light_theme && g:dark_or_light_theme == 'light') @@ -715,12 +692,6 @@ endfunction nnoremap % :vsplit nnoremap " :split - " session related KeyBinding. These KeyBinding uses function from startify - nnoremap s :SSave - nnoremap l :SLoad - nnoremap d :SDelete! - nnoremap c :SClose - " } " " Lua configuration diff --git a/config/theme.vim b/config/theme.vim index cba118d..6d483a0 100644 --- a/config/theme.vim +++ b/config/theme.vim @@ -60,6 +60,9 @@ function! CocThemeFix() hi Error cterm=underline ctermfg=124 ctermbg=none hi javaError cterm=underline ctermfg=124 ctermbg=none + + highlight CursorLineNr ctermbg=none + highlight SignColumn ctermbg=none endfunction call CocThemeFix()