This commit is contained in:
Nachuan Tang
2023-02-05 19:05:39 -05:00
3 changed files with 174 additions and 36 deletions
+5 -3
View File
@@ -7,7 +7,7 @@
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]*')
let g:vim_version = matchstr(execute('version'), 'Vi IMproved \zs[^\n]*')
endif
let g:vim_version = str2float(g:vim_version)
let g:dotfile_path = '~/.dotfiles/'
@@ -78,8 +78,8 @@
" Vim UI {
"
set tabpagemax=15 " Only show 15 tabs
set showmode " Display the current mode
" set tabpagemax=15 " Only show 15 tabs
" set showmode " Display the current mode
set cursorline " Highlight current line
set cmdheight=1 " get rid of the extra useless line at the bottom(not working, probably a plugin is changing the value)
@@ -91,6 +91,7 @@
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
@@ -109,6 +110,7 @@
set scrolloff=5 " Minimum lines to keep above and below cursor
set sidescrolloff=5 " Minimum lines to keep at the left or right of the cursor
" }
" Formatting {
+68 -32
View File
@@ -55,11 +55,6 @@
Plug 'jiangmiao/auto-pairs'
Plug 'mg979/vim-visual-multi'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" The bottom buffer display
Plug 'bling/vim-bufferline'
Plug 'easymotion/vim-easymotion'
Plug 'vim-scripts/restore_view.vim'
@@ -77,10 +72,19 @@
" put text in neibouring tmux pane into auto complete
Plug 'wellle/tmux-complete.vim'
Plug 'NoahTheDuke/vim-just'
Plug 'ludovicchabant/vim-gutentags'
Plug 'ludovicchabant/vim-gutentags', { 'for': ['c', 'cpp'] }
Plug 'lambdalisue/readablefold.vim'
" only work with vim
if g:vim_type == 'vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
endif
" The bottom buffer display
Plug 'bling/vim-bufferline'
" only work with nvim > 0.5
" For other versions, just loading the plugin may
" cause error
@@ -92,11 +96,17 @@
Plug 'EdenEast/nightfox.nvim'
Plug 'projekt0n/github-nvim-theme'
Plug 'nvim-lualine/lualine.nvim'
" partial code execution
" Plug 'michaelb/sniprun', {'do': 'bash install.sh'}
endif
if g:vim_version >= 0.7
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-tree/nvim-web-devicons'
endif
if g:vim_version >= 0.8
Plug 'nvim-tree/nvim-tree.lua'
endif
endif
@@ -137,6 +147,7 @@ endif
" ludovicchabant/vim-gutentags {
set statusline+=%{gutentags#statusline()}
let g:gutentags_cache_dir=g:vim_dir . '/.vimtags/'
let g:gutentags_project_root=['.git', '.hg', '.svn', '.bzr', '_darcs', '_FOSSIL_', '.fslckout', 'src']
"}
" easymotion/vim-easymotion {
@@ -191,7 +202,7 @@ endif
" }
" NerdTree {
if isdirectory(expand(plugin_dir . "/nerdtree"))
if g:vim_type == 'vim' && isdirectory(expand(plugin_dir . "/nerdtree"))
let g:NERDShutUp=1
" work around for nerdtree bug: https://github.com/preservim/nerdtree/issues/1321
@@ -210,12 +221,27 @@ endif
let NERDTreeKeepTreeInNewTab = 1
endif
" }
" nvim-tree.lua {
if g:vim_type == 'nvim' && isdirectory(expand(plugin_dir . "/nvim-tree.lua"))
nnoremap <leader>e :NvimTreeFindFileToggle<CR>
nnoremap <leader>r :NvimTreeRefresh<CR>
" 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 && isdirectory(expand(plugin_dir . "/lualine.nvim"))
" nvim-lualine/lualine.nvim {
" }
"else
" vim-airline {
if g:vim_type == 'vim' && isdirectory(expand(plugin_dir . "/airline"))
" Set configuration options for the statusline plugin vim-airline.
" Use the powerline theme and optionally enable powerline symbols.
let g:airline_section_b = ''
@@ -253,6 +279,7 @@ endif
if isdirectory(expand(plugin_dir . "/vim-airline-themes/"))
"let g:airline_theme = 'solarized'
endif
endif
" }
"endif
@@ -320,9 +347,9 @@ endif
" dark or light
if filereadable(expand(g:vim_dir . '.light_theme.signal'))
let g:theme_color = 'light'
let g:dark_or_white_theme = 'light'
else
let g:theme_color = 'dark'
let g:dark_or_white_theme = 'dark'
endif
" what to use for dark theme
@@ -349,21 +376,21 @@ endif
set background=dark
hi clear
execute("colorscheme " . g:dark_theme)
let g:theme_color = 'dark'
let g:dark_or_white_theme = 'dark'
endfunction
function! SetLightTheme()
set background=light
hi clear
execute("colorscheme " . g:light_theme)
let g:theme_color = 'light'
let g:dark_or_white_theme = 'light'
endfunction
" Change bottom airline/lualine theme
" Currently only support airline
function! SetAirlineTheme(theme)
if has('nvim') && g:vim_version >= 0.5
execute('AirlineTheme ' . a:theme)
if g:vim_type == 'nvim' && g:vim_version >= 0.5
"execute('AirlineTheme ' . a:theme)
else
execute('AirlineTheme ' . a:theme)
endif
@@ -374,6 +401,7 @@ endif
function! TransparentBackgroundFix()
"if !has('nvim') || g:vim_version < 0.5
if v:true
"if v:false
highlight SignColumn ctermbg=none
"highlight CursorLineNr ctermbg=none
highlight CocWarningHighlight ctermbg=none
@@ -384,7 +412,7 @@ endif
highlight CocWarningSign ctermbg=none
highlight CocInfoSign ctermbg=none
highlight CocHintSign ctermbg=none
if g:theme_color == 'dark'
if g:dark_or_white_theme == 'dark'
highlight! link TempColor Visual
highlight! link CocFloating TempColor
highlight! link CocErrorFloat TempColor
@@ -398,7 +426,7 @@ endif
function! EnableTransparent()
if g:vim_type == 'nvim' && g:vim_version > 0.5
:TransparentEnable
elseif g:theme_color == 'dark'
elseif g:dark_or_white_theme == 'dark'
let g:PaperColor_Theme_Options = {
\ 'theme': {
\ 'default.dark': {
@@ -407,7 +435,7 @@ endif
\ }
\ }
execute("colorscheme " . g:dark_theme)
elseif g:theme_color == 'light'
elseif g:dark_or_white_theme == 'light'
let g:PaperColor_Theme_Options = {
\ 'theme': {
\ 'default.light': {
@@ -422,7 +450,7 @@ endif
function! DisableTransparent()
if g:vim_type == 'nvim' && g:vim_version > 0.5
:TransparentDisable
elseif g:theme_color == 'dark'
elseif g:dark_or_white_theme == 'dark'
let g:PaperColor_Theme_Options = {
\ 'theme': {
\ 'default.dark': {
@@ -431,7 +459,7 @@ endif
\ }
\ }
execute("colorscheme " . g:dark_theme)
elseif g:theme_color == 'light'
elseif g:dark_or_white_theme == 'light'
let g:PaperColor_Theme_Options = {
\ 'theme': {
\ 'default.light': {
@@ -458,17 +486,17 @@ endif
" ToggleTransparent background
" only works in dark theme
function! ToggleTransparent()
if g:transparent_dark_theme && g:theme_color == 'dark'
if g:transparent_dark_theme && g:dark_or_white_theme == 'dark'
call DisableTransparent()
let g:transparent_dark_theme = v:false
call DeleteSignalFile('.transparent_dark_theme.signal')
elseif g:transparent_light_theme && g:theme_color == 'light'
elseif g:transparent_light_theme && g:dark_or_white_theme == 'light'
call DisableTransparent()
let g:transparent_light_theme = v:false
call DeleteSignalFile('.transparent_light_theme.signal')
else
call EnableTransparent()
if g:theme_color == 'dark'
if g:dark_or_white_theme == 'dark'
let g:transparent_dark_theme = v:true
call CreateSignalFile('.transparent_dark_theme.signal')
else
@@ -481,22 +509,30 @@ endif
" vim theme
if isdirectory(expand(plugin_dir . "/papercolor-theme"))
" improve coc color in this theme
let g:light_theme = 'PaperColor'
let g:dark_theme = 'PaperColor'
endif
if !has('nvim') && isdirectory(expand(plugin_dir . "/papercolor-theme"))
set t_Co=256
" improve coc color in this theme
let g:light_theme = 'PaperColor'
let g:dark_theme = 'PaperColor'
"let g:airline_dark_theme = "papercolor"
"let g:airline_light_theme = "papercolor"
endif
" nvim only theme
if isdirectory(expand(plugin_dir . "/nightfox.nvim")) && isdirectory(expand(plugin_dir . "/github-nvim-theme")) && has('nvim') && g:vim_version >= 0.5
if has('nvim')
if g:vim_version >= 0.8 && isdirectory(expand(plugin_dir . "/nightfox.nvim"))
let g:light_theme = 'dawnfox'
"let g:dark_theme = 'nightfox'
end
if g:vim_version >= 0.5 && isdirectory(expand(plugin_dir . "/github-nvim-theme"))
let g:dark_theme = 'github_dark'
let g:airline_dark_theme = "hybrid"
endif
end
endif
if g:theme_color == 'dark'
if g:dark_or_white_theme == 'dark'
let g:airline_theme=g:airline_dark_theme
call SetDarkTheme()
else
@@ -506,7 +542,7 @@ endif
" Since in .vimrc we cannot call plugin function as they
" are not loaded (:help startup)
if g:transparent_dark_theme && g:theme_color == 'dark' || g:transparent_light_theme && g:theme_color == 'light'
if g:transparent_dark_theme && g:dark_or_white_theme == 'dark' || g:transparent_light_theme && g:dark_or_white_theme == 'light'
if g:vim_type == 'nvim' && g:vim_version > 0.5
let g:transparent_enabled = v:true
else
@@ -524,7 +560,7 @@ endif
" Allow to trigger background
function! ToggleBG()
" Inversion
if g:theme_color == "dark"
if g:dark_or_white_theme == "dark"
call SetLightTheme()
call SetAirlineTheme(g:airline_light_theme)
call CreateSignalFile('.light_theme.signal')
@@ -535,7 +571,7 @@ endif
call DeleteSignalFile(".light_theme.signal")
endif
if g:transparent_dark_theme && g:theme_color == 'dark' || g:transparent_light_theme && g:theme_color == 'light'
if g:transparent_dark_theme && g:dark_or_white_theme == 'dark' || g:transparent_light_theme && g:dark_or_white_theme == 'light'
call EnableTransparent()
else
call DisableTransparent()
+101 -1
View File
@@ -1,5 +1,5 @@
require'nvim-treesitter.configs'.setup {
require('nvim-treesitter.configs').setup {
-- ensure_installed = { "c", "bash", "lua" },
sync_install = false,
auto_install = true,
@@ -9,3 +9,103 @@ require'nvim-treesitter.configs'.setup {
additional_vim_regex_highlighting = false,
},
}
require('lualine').setup {
options = {
theme = 'auto', -- lualine theme
disabled_filetypes = { -- Filetypes to disable lualine for.
statusline = {}, -- only ignores the ft for statusline.
winbar = {}, -- only ignores the ft for winbar.
'NvimTree'
},
},
sections = {
lualine_a = {'mode'},
lualine_b = {},
lualine_c = {
{
'buffers',
mode = 4,
filetype_names = {
TelescopePrompt = 'Telescope',
dashboard = 'Dashboard',
packer = 'Packer',
fzf = 'FZF',
alpha = 'Alpha',
NvimTree = 'NvimTree'
},
}
},
-- lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_x = {'encoding'},
lualine_y = {},
lualine_z = {'location'}
},
-- tabline = {
-- lualine_a = {
-- {
-- 'buffers',
-- mode = 4,
-- }
-- },
-- lualine_b = {},
-- lualine_c = {},
-- lualine_x = {},
-- lualine_y = {},
-- lualine_z = {'tabs'}
-- },
-- winbar = {
-- lualine_a = {},
-- lualine_b = {},
-- lualine_c = {'filename'},
-- lualine_x = {},
-- lualine_y = {},
-- lualine_z = {}
-- },
}
-- nvim-tree configuration
--
-- disable netrw at the very start of your init.lua (strongly advised)
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- set termguicolors to enable highlight groups
vim.opt.termguicolors = true
-- setup with some options
require("nvim-tree").setup({
sort_by = "case_sensitive",
view = {
width = 30,
mappings = {
list = {
{ key = "C-[", action = "dir_up" },
{ key = "C-]", action = "cd" },
{ key = "<C-k>", action = "toggle_file_info" },
},
},
},
renderer = {
group_empty = true,
},
filters = {
dotfiles = false,
},
actions = {
open_file = {
quit_on_open = true,
resize_window = true,
window_picker = {
exclude = {
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
buftype = { "nofile", "terminal", "help" },
},
},
},
},
})
--
-- nvim-tree configuration end