This commit is contained in:
Nachuan Tang
2023-02-24 14:19:03 -05:00
3 changed files with 34 additions and 99 deletions
+10 -49
View File
@@ -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 <leader>h :noh<CR> " 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<bang> <args>
" command! -bang -nargs=* -complete=file W w<bang> <args>
" command! -bang -nargs=* -complete=file Wq wq<bang> <args>
" command! -bang -nargs=* -complete=file WQ wq<bang> <args>
" command! -bang Wa wa<bang>
" command! -bang WA wa<bang>
" command! -bang Q q<bang>
" command! -bang QA qa<bang>
" command! -bang Qa qa<bang>
" 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 <silent> <leader>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
set clipboard=unnamedplus
+21 -50
View File
@@ -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 <silent> <leader><leader>s :SSave<CR>
nnoremap <silent> <leader><leader>l :SLoad<CR>
nnoremap <silent> <leader><leader>d :SDelete!<CR>
nnoremap <silent> <leader><leader>c :SClose<CR>
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 <leader>ut :UndotreeToggle<CR>
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 <leader><leader>r :Rg<CR>
noremap <leader><leader>f :Files<CR>
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 <silent> <C-w>% :vsplit<CR>
nnoremap <silent> <C-w>" :split<CR>
" session related KeyBinding. These KeyBinding uses function from startify
nnoremap <silent> <leader><leader>s :SSave<CR>
nnoremap <silent> <leader><leader>l :SLoad<CR>
nnoremap <silent> <leader><leader>d :SDelete!<CR>
nnoremap <silent> <leader><leader>c :SClose<CR>
" }
"
" Lua configuration
+3
View File
@@ -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()