structure change. Colorscheme picker. etc.
This commit is contained in:
@@ -10,12 +10,14 @@
|
|||||||
let after_directory = g:mydotfiles_directory . 'config/vi-plugs/coc-theme/after/'
|
let after_directory = g:mydotfiles_directory . 'config/vi-plugs/coc-theme/after/'
|
||||||
|
|
||||||
" detect vim type(vim or nvim)
|
" detect vim type(vim or nvim)
|
||||||
|
let g:vim_v = 0
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
let g:vim_type = 'nvim'
|
let g:vim_type = 'nvim'
|
||||||
let g:vim_version = matchstr(execute('version'), 'NVIM v\zs[^\n]*')
|
let g:vim_version = matchstr(execute('version'), 'NVIM v\zs[^\n]*')
|
||||||
else
|
else
|
||||||
let g:vim_type = 'vim'
|
let g:vim_type = 'vim'
|
||||||
let g:vim_version = matchstr(execute('version'), 'Vi IMproved \zs[^\n]*')
|
let g:vim_version = matchstr(execute('version'), 'Vi IMproved \zs[^\n]*')
|
||||||
|
let g:vim_v = v:version
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" detect operating system (Windows/Linux/Darwin)
|
" detect operating system (Windows/Linux/Darwin)
|
||||||
@@ -100,12 +102,12 @@
|
|||||||
"
|
"
|
||||||
" set tabpagemax=15 " Only show 15 tabs
|
" set tabpagemax=15 " Only show 15 tabs
|
||||||
" set showmode " Display the current mode
|
" set showmode " Display the current mode
|
||||||
" set cursorline " Highlight current line
|
set nocursorline " Highlight current line
|
||||||
|
|
||||||
" get rid of current line highlight, instead just highlight the number column
|
" get rid of current line highlight, instead just highlight the number column
|
||||||
augroup CLClear
|
" augroup CLClear
|
||||||
autocmd! ColorScheme * hi clear CursorLine
|
" autocmd! ColorScheme * hi clear CursorLine
|
||||||
augroup END
|
" augroup END
|
||||||
|
|
||||||
set cmdheight=1 " get rid of the extra useless line at the bottom(if not working, probably a plugin is changing the value)
|
set cmdheight=1 " get rid of the extra useless line at the bottom(if not working, probably a plugin is changing the value)
|
||||||
|
|
||||||
@@ -141,8 +143,12 @@
|
|||||||
set shiftwidth=4 " Use indents of 4 spaces
|
set shiftwidth=4 " Use indents of 4 spaces
|
||||||
set tabstop=4 " An indentation every four columns
|
set tabstop=4 " An indentation every four columns
|
||||||
set softtabstop=4 " Let backspace delete indent
|
set softtabstop=4 " Let backspace delete indent
|
||||||
autocmd FileType javascript,typescript set tabstop=2 shiftwidth=2 softtabstop=2
|
augroup FileFormat
|
||||||
autocmd FileType c,cpp,python,java set tabstop=4 shiftwidth=4 softtabstop=4
|
autocmd!
|
||||||
|
autocmd FileType javascript,typescript,lua setlocal tabstop=2 shiftwidth=2 softtabstop=2
|
||||||
|
" autocmd FileType c,cpp,python,java setlocal tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
augroup END
|
||||||
|
|
||||||
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
|
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
|
||||||
set splitright " Puts new vsplit windows to the right of the current
|
set splitright " Puts new vsplit windows to the right of the current
|
||||||
set splitbelow " Puts new split windows to the bottom of the current
|
set splitbelow " Puts new split windows to the bottom of the current
|
||||||
|
|||||||
+261
-265
@@ -3,54 +3,64 @@
|
|||||||
" OPTIONS
|
" OPTIONS
|
||||||
" PLUGIN_INSTALL
|
" PLUGIN_INSTALL
|
||||||
" UTILITIES
|
" UTILITIES
|
||||||
" PLUGIN_CONFIGURATION
|
" PLUGIN_CONFIGURATION " THEME_CONFIGURATION
|
||||||
" THEME_CONFIGURATION
|
|
||||||
" KEY_MAPS
|
" KEY_MAPS
|
||||||
" OTHER_CONFIGS
|
" OTHER_CONFIGS
|
||||||
|
|
||||||
|
let g:debug_mode = v:false
|
||||||
|
let g:high_performence = v:false " set true will also disable animation
|
||||||
|
let g:autocomplte_enable = v:true
|
||||||
|
let g:copilot_enable = v:false
|
||||||
|
|
||||||
let g:high_performence = v:false
|
|
||||||
" only used by neovim
|
" only used by neovim
|
||||||
let g:classic_vim_ui = v:false
|
let g:classic_vim_ui = v:false
|
||||||
let g:animation_enable = v:true
|
let g:animation_enable = v:true
|
||||||
|
|
||||||
|
let g:swap_dict = [
|
||||||
|
\ ['false', '0', 'dark' ],
|
||||||
|
\ ['true' , '1', 'light']]
|
||||||
|
" convinient function to swap between two options
|
||||||
|
nmap <leader><leader>t :call SwapWord()<CR>
|
||||||
|
|
||||||
" PLUGIN_INSTALL
|
" PLUGIN_INSTALL
|
||||||
" {
|
" {
|
||||||
" Plugin environment
|
" Plugin environment
|
||||||
let g:mydotfiles_directory = expand('~/.dotfiles/')
|
let g:mydotfiles_directory = expand('~/.dotfiles/')
|
||||||
let s:plugin_dir = expand('~/.vim/plugged/')
|
let s:plugin_dir = expand('~/.vim/plugged/')
|
||||||
|
let g:config_file_path = g:vim_dir . ".config.vim"
|
||||||
call plug#begin(s:plugin_dir)
|
call plug#begin(s:plugin_dir)
|
||||||
|
|
||||||
" https://github.com/junegunn/vim-plug/wiki/tips
|
" https://github.com/junegunn/vim-plug/wiki/tips
|
||||||
function! Cond(cond, ...)
|
function! Cond(cond, ...)
|
||||||
let opts = get(a:000, 0, {})
|
let opts = get(a:000, 0, {})
|
||||||
return a:cond ? opts : extend(opts, { 'on': [], 'for': [] })
|
return a:cond ? opts : extend(opts, { 'on': [], 'for': [] })
|
||||||
endfunction
|
endfunction
|
||||||
|
let g:animation_enable = g:high_performence ? v:false : g:animation_enable
|
||||||
|
|
||||||
"""""""""""""""""""""""
|
|
||||||
"""" THEME_PLUGINS """"
|
"""" THEME_PLUGINS """"
|
||||||
"""""""""""""""""""""""
|
|
||||||
|
|
||||||
Plug 'sainnhe/everforest', Cond(g:vim_type == 'vim')
|
Plug 'sainnhe/everforest'
|
||||||
Plug 'NLKNguyen/papercolor-theme'
|
if !g:high_performence
|
||||||
|
Plug 'jacoborus/tender.vim'
|
||||||
|
Plug 'cocopon/iceberg.vim'
|
||||||
|
Plug 'catppuccin/nvim', Cond( has('nvim-0.8.2') \|\| g:vim_v >= 900 , { 'as': 'catppuccin' })
|
||||||
|
Plug 'NLKNguyen/papercolor-theme'
|
||||||
|
Plug 'EdenEast/nightfox.nvim', Cond(has('nvim-0.5'))
|
||||||
|
Plug 'projekt0n/github-nvim-theme', Cond(has('nvim-0.5'), { 'tag': 'v0.0.7' })
|
||||||
|
Plug 'folke/tokyonight.nvim', Cond(g:vim_type == 'nvim', { 'branch': 'main' })
|
||||||
|
endif
|
||||||
|
|
||||||
" Neovim only
|
|
||||||
Plug 'EdenEast/nightfox.nvim', Cond(g:vim_type == 'nvim' && g:vim_version >= 0.5)
|
|
||||||
Plug 'projekt0n/github-nvim-theme', Cond(g:vim_type == 'nvim' && g:vim_version >= 0.5, { 'tag': 'v0.0.7' })
|
|
||||||
|
|
||||||
"""""""""""""""""""""""
|
|
||||||
"""""""" END """"""""""
|
"""""""" END """"""""""
|
||||||
"""""""""""""""""""""""
|
Plug 'lervag/vimtex'
|
||||||
|
Plug 'github/copilot.vim', Cond(( g:vim_type == 'nvim' \|\| g:vim_v >= 900 )
|
||||||
|
\ && g:copilot_enable && executable('node'))
|
||||||
|
|
||||||
|
Plug 'gelguy/wilder.nvim', Cond((g:vim_type == 'vim' \|\| g:classic_vim_ui) && !g:high_performence)
|
||||||
Plug 'gelguy/wilder.nvim', Cond(g:vim_type == 'vim' \|\| g:classic_vim_ui)
|
|
||||||
" To use Python remote plugin features in Vim for wilder, can be skipped
|
" To use Python remote plugin features in Vim for wilder, can be skipped
|
||||||
" Plug 'roxma/nvim-yarp', Cond(g:vim_type == 'vim')
|
" Plug 'roxma/nvim-yarp', Cond(g:vim_type == 'vim')
|
||||||
" Plug 'roxma/vim-hug-neovim-rpc', Cond(g:vim_type == 'vim')
|
" Plug 'roxma/vim-hug-neovim-rpc', Cond(g:vim_type == 'vim')
|
||||||
|
|
||||||
Plug 'dstein64/vim-startuptime'
|
Plug 'dstein64/vim-startuptime', Cond(!g:high_performence)
|
||||||
Plug 'simeji/winresizer'
|
Plug 'simeji/winresizer', Cond(!g:high_performence)
|
||||||
Plug 'rust-lang/rust.vim', { 'for': ['rust'] }
|
Plug 'rust-lang/rust.vim', { 'for': ['rust'] }
|
||||||
|
|
||||||
Plug 'machakann/vim-sandwich'
|
Plug 'machakann/vim-sandwich'
|
||||||
@@ -58,29 +68,27 @@ let g:animation_enable = v:true
|
|||||||
|
|
||||||
Plug 'jiangmiao/auto-pairs'
|
Plug 'jiangmiao/auto-pairs'
|
||||||
" Plug 'mg979/vim-visual-multi'
|
" Plug 'mg979/vim-visual-multi'
|
||||||
Plug 'RRethy/vim-illuminate'
|
Plug 'RRethy/vim-illuminate', Cond(!g:high_performence)
|
||||||
"Plug 'easymotion/vim-easymotion'
|
"Plug 'easymotion/vim-easymotion'
|
||||||
Plug 'mhinz/vim-startify'
|
Plug 'mhinz/vim-startify'
|
||||||
Plug 'ludovicchabant/vim-gutentags', Cond(!exists('g:vscode'), { 'for': ['c', 'cpp'] })
|
Plug 'ludovicchabant/vim-gutentags'
|
||||||
|
|
||||||
Plug 'christoomey/vim-tmux-navigator'
|
Plug 'christoomey/vim-tmux-navigator'
|
||||||
Plug 'airblade/vim-rooter'
|
Plug 'airblade/vim-rooter'
|
||||||
Plug 'roxma/vim-tmux-clipboard', Cond(executable('tmux'))
|
Plug 'roxma/vim-tmux-clipboard', Cond(executable('tmux'))
|
||||||
Plug 'liuchengxu/vista.vim'
|
Plug 'liuchengxu/vista.vim', Cond(!g:high_performence)
|
||||||
|
|
||||||
"""""""""""""""""""""""
|
|
||||||
"" ESSENTIAL_PLUGINS ""
|
"" ESSENTIAL_PLUGINS ""
|
||||||
"""""""""""""""""""""""
|
|
||||||
|
|
||||||
" Comment stuff out
|
" Comment stuff out
|
||||||
Plug 'tpope/vim-commentary'
|
Plug 'tpope/vim-commentary'
|
||||||
Plug 'vim-scripts/restore_view.vim'
|
Plug 'vim-scripts/restore_view.vim'
|
||||||
|
|
||||||
" vim only plugins
|
" vim only plugins
|
||||||
Plug 'scrooloose/nerdtree', Cond(g:vim_type == 'vim' \|\| g:vim_version < 0.8, { 'on' : ['NERDTreeToggle', 'NERDTreeFind'] })
|
Plug 'scrooloose/nerdtree', Cond(g:vim_type == 'vim' \|\| g:vim_v < 800, { 'on' : ['NERDTreeToggle', 'NERDTreeFind'] })
|
||||||
Plug 'tiagofumo/vim-nerdtree-syntax-highlight', Cond(g:vim_type == 'vim' && !g:high_performence)
|
Plug 'tiagofumo/vim-nerdtree-syntax-highlight', Cond(g:vim_type == 'vim' && !g:high_performence)
|
||||||
|
|
||||||
Plug 'neoclide/coc.nvim', Cond(!exists('g:vscode') && executable('node'), {'branch': 'release'})
|
Plug 'neoclide/coc.nvim', Cond(g:autocomplte_enable && executable('node'), {'branch': 'release'})
|
||||||
|
|
||||||
" only work with vim
|
" only work with vim
|
||||||
if g:vim_type == 'vim'
|
if g:vim_type == 'vim'
|
||||||
@@ -103,22 +111,22 @@ let g:animation_enable = v:true
|
|||||||
if g:vim_version >= 0.5
|
if g:vim_version >= 0.5
|
||||||
Plug 'xiyaowong/nvim-transparent'
|
Plug 'xiyaowong/nvim-transparent'
|
||||||
Plug 'lukas-reineke/indent-blankline.nvim', Cond(!g:animation_enable)
|
Plug 'lukas-reineke/indent-blankline.nvim', Cond(!g:animation_enable)
|
||||||
Plug 'echasnovski/mini.indentscope'
|
Plug 'echasnovski/mini.indentscope', Cond(g:animation_enable)
|
||||||
Plug 'echasnovski/mini.animate'
|
Plug 'echasnovski/mini.animate', Cond(g:animation_enable)
|
||||||
|
|
||||||
Plug 'nvim-lualine/lualine.nvim'
|
Plug 'nvim-lualine/lualine.nvim'
|
||||||
Plug 'karb94/neoscroll.nvim'
|
Plug 'karb94/neoscroll.nvim', Cond(g:animation_enable)
|
||||||
Plug 'petertriho/nvim-scrollbar'
|
Plug 'petertriho/nvim-scrollbar', Cond(g:animation_enable)
|
||||||
Plug 'folke/which-key.nvim'
|
Plug 'folke/which-key.nvim', Cond(!g:high_performence)
|
||||||
endif
|
endif
|
||||||
if g:vim_version >= 0.7
|
if g:vim_version >= 0.7
|
||||||
Plug 'nvim-treesitter/nvim-treesitter', Cond(!exists('g:vscode') && executable('make'), {'do': ':TSUpdate'})
|
Plug 'nvim-treesitter/nvim-treesitter', Cond(executable('make'), {'do': ':TSUpdate'})
|
||||||
|
|
||||||
" for telescope
|
" for telescope
|
||||||
Plug 'nvim-lua/plenary.nvim'
|
Plug 'nvim-lua/plenary.nvim'
|
||||||
Plug 'nvim-telescope/telescope.nvim', Cond(g:vim_type == 'nvim', { 'tag': '0.1.x' })
|
Plug 'nvim-telescope/telescope.nvim', Cond(g:vim_type == 'nvim', { 'branch': '0.1.x' })
|
||||||
" c plugin for telescope to make it faster
|
" c plugin for telescope to make it faster
|
||||||
Plug 'nvim-telescope/telescope-fzf-native.nvim', Cond(!exists('g:vscode') && executable('make'), { 'do': 'make' })
|
Plug 'nvim-telescope/telescope-fzf-native.nvim', Cond(executable('make'), { 'do': 'make' })
|
||||||
|
|
||||||
" comment out this plugin if the machine doesn't have required
|
" comment out this plugin if the machine doesn't have required
|
||||||
" font install
|
" font install
|
||||||
@@ -128,19 +136,24 @@ let g:animation_enable = v:true
|
|||||||
if g:vim_version >= 0.8
|
if g:vim_version >= 0.8
|
||||||
Plug 'nvim-tree/nvim-tree.lua'
|
Plug 'nvim-tree/nvim-tree.lua'
|
||||||
|
|
||||||
Plug 'rcarriga/nvim-notify'
|
Plug 'rcarriga/nvim-notify', Cond(!g:high_performence && g:animation_enable)
|
||||||
Plug 'folke/noice.nvim'
|
Plug 'folke/noice.nvim', Cond(!g:high_performence && g:animation_enable)
|
||||||
Plug 'MunifTanjim/nui.nvim'
|
Plug 'MunifTanjim/nui.nvim', Cond(!g:high_performence && g:animation_enable)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
" Automatically install missing plugins at startup
|
augroup InitConfig
|
||||||
autocmd VimEnter *
|
autocmd VimLeave * call SaveConfig()
|
||||||
\ if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
|
|
||||||
\| PlugInstall --sync | q
|
" Automatically install missing plugins at startup
|
||||||
\| endif
|
autocmd VimEnter *
|
||||||
|
\ if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
|
||||||
|
\| PlugInstall --sync | q
|
||||||
|
\| endif
|
||||||
|
augroup end
|
||||||
|
|
||||||
" }
|
" }
|
||||||
|
|
||||||
" UTILITIES
|
" UTILITIES
|
||||||
@@ -149,7 +162,8 @@ let g:animation_enable = v:true
|
|||||||
" special filetypes probably defined by plugins that we don't want other
|
" special filetypes probably defined by plugins that we don't want other
|
||||||
" plugins to mess around with them
|
" plugins to mess around with them
|
||||||
|
|
||||||
let g:special_fts = ['help', 'nerdtree']
|
" import ultilities functions
|
||||||
|
execute('source ' . g:mydotfiles_directory . '/utils.vim')
|
||||||
|
|
||||||
function! HasPlug(plug_name, ...)
|
function! HasPlug(plug_name, ...)
|
||||||
let plug_dir_name = get(a:, 1, a:plug_name) " optional argument for the name of plug's folder
|
let plug_dir_name = get(a:, 1, a:plug_name) " optional argument for the name of plug's folder
|
||||||
@@ -165,19 +179,60 @@ function! HasPlug(plug_name, ...)
|
|||||||
return v:false
|
return v:false
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! SaveConfig()
|
||||||
|
let p = ReadVariable(g:config_file_path)
|
||||||
|
if type(p) != type({})
|
||||||
|
let p = {}
|
||||||
|
endif
|
||||||
|
|
||||||
|
let config = has_key(p, g:vim_type) && type(p[g:vim_type]) == 4
|
||||||
|
\ ? p[g:vim_type] : {}
|
||||||
|
let config = Merge(config, g:my_config)
|
||||||
|
|
||||||
|
" vim and nvim may have diferenrt available plugins
|
||||||
|
let p[g:vim_type] = config
|
||||||
|
call SaveVariable(p, g:config_file_path)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! LoadConfig()
|
||||||
|
let result = ReadVariable(g:config_file_path)
|
||||||
|
" if it is dictionary
|
||||||
|
if type(result) == 4
|
||||||
|
if has_key(result, g:vim_type)
|
||||||
|
let config = result[g:vim_type]
|
||||||
|
if type(config) == 4 | return config | endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
return {}
|
||||||
|
endfunction
|
||||||
|
|
||||||
" }
|
" }
|
||||||
|
|
||||||
" PLUGIN_CONFIGURATION
|
" PLUGIN_CONFIGURATION
|
||||||
" {
|
" {
|
||||||
|
|
||||||
|
if HasPlug('Copilot.vim')
|
||||||
|
" imap <expr> <C-n> <Plug>(copilot-next)
|
||||||
|
" imap <expr> <C-p> <Plug>(copilot-prev)
|
||||||
|
endif
|
||||||
|
|
||||||
|
if HasPlug('vimtex')
|
||||||
|
if g:os == 'Darwin'
|
||||||
|
let g:vimtex_view_method = 'skim'
|
||||||
|
endif
|
||||||
|
nmap <leader>lv <plug>(vimtex-view)
|
||||||
|
nmap <leader>lc :VimtexCompile<CR>
|
||||||
|
let g:vimtex_quickfix_open_on_warning = 0
|
||||||
|
endif
|
||||||
if HasPlug('minimap.vim')
|
if HasPlug('minimap.vim')
|
||||||
nnoremap <silent> <leader>mm :MinimapToggle<CR>
|
nnoremap <silent> <leader>mm :MinimapToggle<CR>
|
||||||
let g:minimap_highlight_search = 1
|
let g:minimap_highlight_search = 1
|
||||||
let g:minimap_git_colors = 1
|
let g:minimap_git_colors = 1
|
||||||
let g:minimap_enable_highlight_colorgroup = 1
|
let g:minimap_enable_highlight_colorgroup = 1
|
||||||
|
let g:minimap_block_filetypes = ['help', 'nerdtree']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if HasPlug('vista.vim')
|
if HasPlug('vista.vim')
|
||||||
let g:special_fts += ['vista']
|
|
||||||
let g:vista_default_executive = 'vim_lsp'
|
let g:vista_default_executive = 'vim_lsp'
|
||||||
if HasPlug('coc.nvim')
|
if HasPlug('coc.nvim')
|
||||||
let g:vista_default_executive = 'coc'
|
let g:vista_default_executive = 'coc'
|
||||||
@@ -524,7 +579,12 @@ endfunction
|
|||||||
call airline#parts#define_function('cocstatus', 'AirlineCocStatus')
|
call airline#parts#define_function('cocstatus', 'AirlineCocStatus')
|
||||||
call airline#parts#define_accent('cocstatus', 'italic')
|
call airline#parts#define_accent('cocstatus', 'italic')
|
||||||
|
|
||||||
|
|
||||||
function! AirlineInit()
|
function! AirlineInit()
|
||||||
|
let _airline_section_y = ''
|
||||||
|
if HasPlug('coc.nvim')
|
||||||
|
let _airline_section_y .= airline#section#create(['cocstatus'])
|
||||||
|
endif
|
||||||
" this create function returns a format string for status line (:h
|
" this create function returns a format string for status line (:h
|
||||||
" stl). the string we append is what will happend if we pass
|
" stl). the string we append is what will happend if we pass
|
||||||
" cocstatus into the create function. By appending them we have
|
" cocstatus into the create function. By appending them we have
|
||||||
@@ -535,7 +595,7 @@ endfunction
|
|||||||
let g:airline_section_error = ''
|
let g:airline_section_error = ''
|
||||||
let g:airline_section_warning = ''
|
let g:airline_section_warning = ''
|
||||||
let g:airline_section_x = airline#section#create(['bufnum'])
|
let g:airline_section_x = airline#section#create(['bufnum'])
|
||||||
let g:airline_section_y = airline#section#create(['cocstatus'])
|
let g:airline_section_y = _airline_section_y
|
||||||
let g:airline_section_z = airline#section#create(['filetype'])
|
let g:airline_section_z = airline#section#create(['filetype'])
|
||||||
|
|
||||||
" see source for current list
|
" see source for current list
|
||||||
@@ -545,12 +605,21 @@ endfunction
|
|||||||
end
|
end
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
if !g:high_performence
|
autocmd! CursorMoved * call s:aireline_refresh(0)
|
||||||
call timer_start(100, 's:aireline_refresh', {'repeat' : -1 })
|
" if !g:high_performence
|
||||||
endif
|
" call timer_start(100, 's:aireline_refresh', {'repeat' : -1 })
|
||||||
|
" endif
|
||||||
|
|
||||||
|
function! s:airlineconfig()
|
||||||
|
let g:my_config[&background].airline_theme = g:airline_theme
|
||||||
|
endfunction
|
||||||
|
autocmd AirlineAu User AirlineAfterTheme call s:airlineconfig()
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
autocmd! User AirlineAfterInit call AirlineInit()
|
augroup AirlineAu
|
||||||
|
autocmd!
|
||||||
|
autocmd User AirlineAfterInit call AirlineInit()
|
||||||
|
augroup end
|
||||||
|
|
||||||
let g:airline#extensions#localsearch#enabled = 0
|
let g:airline#extensions#localsearch#enabled = 0
|
||||||
let g:airline_extensions = ['bufferline']
|
let g:airline_extensions = ['bufferline']
|
||||||
@@ -591,10 +660,8 @@ endfunction
|
|||||||
if HasPlug("fzf") && HasPlug("fzf.vim")
|
if HasPlug("fzf") && HasPlug("fzf.vim")
|
||||||
" [Buffers] Jump to the existing window if possible
|
" [Buffers] Jump to the existing window if possible
|
||||||
let g:fzf_buffers_jump = 1
|
let g:fzf_buffers_jump = 1
|
||||||
|
|
||||||
"let $FZF_DEFAULT_COMMAND='find . \( -name node_modules -o -name .git \) -prune -o -print'
|
"let $FZF_DEFAULT_COMMAND='find . \( -name node_modules -o -name .git \) -prune -o -print'
|
||||||
|
|
||||||
" - Preview window on the right with 50% width
|
|
||||||
" - CTRL-/ will toggle preview window.
|
" - CTRL-/ will toggle preview window.
|
||||||
if g:os == 'Windows'
|
if g:os == 'Windows'
|
||||||
let g:fzf_preview_window = []
|
let g:fzf_preview_window = []
|
||||||
@@ -602,6 +669,10 @@ endfunction
|
|||||||
let g:fzf_preview_window = ['right:50%', 'ctrl-/']
|
let g:fzf_preview_window = ['right:50%', 'ctrl-/']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let g:fzf_colors = {
|
||||||
|
\ 'gutter': ['bg', 'normal'],
|
||||||
|
\ }
|
||||||
|
|
||||||
" check if ripgrep is installed
|
" check if ripgrep is installed
|
||||||
if ! executable('rg')
|
if ! executable('rg')
|
||||||
command! -bang -nargs=* Rg
|
command! -bang -nargs=* Rg
|
||||||
@@ -609,9 +680,19 @@ endfunction
|
|||||||
\ 'grep -R --line-number --exclude-dir=".git;.svn" --color=always -- '.shellescape(<q-args>), 1,
|
\ 'grep -R --line-number --exclude-dir=".git;.svn" --color=always -- '.shellescape(<q-args>), 1,
|
||||||
\ fzf#vim#with_preview(), <bang>0)
|
\ fzf#vim#with_preview(), <bang>0)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
function! FzfColorSelect(color_name)
|
||||||
|
execute("colorscheme " . a:color_name)
|
||||||
|
call Theme_persistent(a:color_name)
|
||||||
|
if has_key(g:colo2airline, a:color_name )
|
||||||
|
call SetStatusLineTheme(g:colo2airline[a:color_name])
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
noremap <leader>fr :Rg<CR>
|
noremap <leader>fr :Rg<CR>
|
||||||
noremap <leader>ff :Files<CR>
|
noremap <leader>ff :Files<CR>
|
||||||
noremap <leader>fc :Colors<CR>
|
noremap <leader>fc :call fzf#vim#colors({
|
||||||
|
\ 'sink': function('FzfColorSelect')})<CR>
|
||||||
endif
|
endif
|
||||||
" }
|
" }
|
||||||
|
|
||||||
@@ -654,17 +735,14 @@ endfunction
|
|||||||
"""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""
|
||||||
|
|
||||||
" a list contains all available themes
|
" a list contains all available themes
|
||||||
let g:all_dark_themes = []
|
|
||||||
let g:all_light_themes = []
|
if HasPlug("tokyonight.nvim")
|
||||||
|
end
|
||||||
|
|
||||||
if HasPlug("github-nvim-theme")
|
if HasPlug("github-nvim-theme")
|
||||||
let g:all_dark_themes += ['github_dark', 'github_dark_default', 'github_dimmed', 'github_dark_colorblind']
|
|
||||||
let g:all_light_themes += ['github_light', 'github_light_default', 'github_light_colorblind']
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if HasPlug("nightfox.nvim")
|
if HasPlug("nightfox.nvim")
|
||||||
let g:all_dark_themes += ['nightfox']
|
|
||||||
let g:all_light_themes += ['dawnfox']
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if HasPlug('nvim-transparent')
|
if HasPlug('nvim-transparent')
|
||||||
@@ -684,18 +762,13 @@ endfunction
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if HasPlug('everforest')
|
if HasPlug('everforest')
|
||||||
let g:all_dark_themes += ['everforest']
|
|
||||||
let g:all_light_themes += ['everforest']
|
|
||||||
|
|
||||||
let g:everforest_better_performance = 1
|
let g:everforest_better_performance = 1
|
||||||
let g:everforest_background = 'hard'
|
let g:everforest_background = 'hard'
|
||||||
" let g:everforest_enable_italic = 1
|
" let g:everforest_enable_italic = 1
|
||||||
function! Everforest_trans_enable()
|
function! Everforest_trans_enable()
|
||||||
let g:everforest_transparent_background = 2
|
let g:everforest_transparent_background = 2
|
||||||
colorscheme everforest
|
colorscheme everforest
|
||||||
if exists(':AirlineTheme')
|
call SetStatusLineTheme('everforest')
|
||||||
execute('AirlineTheme everforest')
|
|
||||||
endif
|
|
||||||
" hack to fix caret characters appearing in the statusline when StatusLine
|
" hack to fix caret characters appearing in the statusline when StatusLine
|
||||||
" and StatusLineNC has same highlight(https://vi.stackexchange.com/questions/15873/carets-in-status-line)
|
" and StatusLineNC has same highlight(https://vi.stackexchange.com/questions/15873/carets-in-status-line)
|
||||||
hi StatusLine guifg=#d3c6aa ctermfg=223
|
hi StatusLine guifg=#d3c6aa ctermfg=223
|
||||||
@@ -703,9 +776,7 @@ endfunction
|
|||||||
function! Everforest_trans_disable()
|
function! Everforest_trans_disable()
|
||||||
let g:everforest_transparent_background = 0
|
let g:everforest_transparent_background = 0
|
||||||
colorscheme everforest
|
colorscheme everforest
|
||||||
if exists(':AirlineTheme')
|
call SetStatusLineTheme('everforest')
|
||||||
execute('AirlineTheme everforest')
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
function! CB_dark_tb_enable_everforest()
|
function! CB_dark_tb_enable_everforest()
|
||||||
call Everforest_trans_enable()
|
call Everforest_trans_enable()
|
||||||
@@ -722,184 +793,113 @@ endfunction
|
|||||||
|
|
||||||
endif
|
endif
|
||||||
if HasPlug('papercolor-theme')
|
if HasPlug('papercolor-theme')
|
||||||
let g:all_dark_themes += ['PaperColor']
|
|
||||||
let g:all_light_themes += ['PaperColor']
|
|
||||||
|
|
||||||
function! CB_dark_tb_enable_PaperColor()
|
function! CB_dark_tb_enable_PaperColor()
|
||||||
let g:PaperColor_Theme_Options = {
|
let g:PaperColor_Theme_Options = {
|
||||||
\ 'theme': {'default.dark': { 'transparent_background': 1 }}
|
\ 'theme': {'default.dark': { 'transparent_background': 1 }}}
|
||||||
\ }
|
colorscheme PaperColor
|
||||||
execute("colorscheme " . g:dark_theme)
|
|
||||||
endfunction
|
endfunction
|
||||||
function! CB_light_tb_enable_PaperColor()
|
function! CB_light_tb_enable_PaperColor()
|
||||||
let g:PaperColor_Theme_Options = {
|
let g:PaperColor_Theme_Options = {
|
||||||
\ 'theme': {'default.light': { 'transparent_background': 1 }}
|
\ 'theme': {'default.light': { 'transparent_background': 1 }}}
|
||||||
\ }
|
colorscheme PaperColor
|
||||||
execute("colorscheme " . g:light_theme)
|
|
||||||
endfunction
|
endfunction
|
||||||
function! CB_dark_tb_disable_PaperColor()
|
function! CB_dark_tb_disable_PaperColor()
|
||||||
let g:PaperColor_Theme_Options = {
|
let g:PaperColor_Theme_Options = {
|
||||||
\ 'theme': {'default.dark': { 'transparent_background': 0 }}
|
\ 'theme': {'default.dark': { 'transparent_background': 0 }}}
|
||||||
\ }
|
colorscheme PaperColor
|
||||||
execute("colorscheme " . g:dark_theme)
|
|
||||||
endfunction
|
endfunction
|
||||||
function! CB_light_tb_disable_PaperColor()
|
function! CB_light_tb_disable_PaperColor()
|
||||||
let g:PaperColor_Theme_Options = {
|
let g:PaperColor_Theme_Options = {
|
||||||
\ 'theme': {'default.light': { 'transparent_background': 0 }}
|
\ 'theme': {'default.light': { 'transparent_background': 0 }}}
|
||||||
\ }
|
colorscheme PaperColor
|
||||||
execute("colorscheme " . g:light_theme)
|
|
||||||
endfunction
|
endfunction
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""
|
||||||
"""""""""" THEME_ULTILITIES """""""""""
|
"""""""""" THEME_ULTILITIES """""""""""
|
||||||
"""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""
|
||||||
|
|
||||||
" debug function print out highlight group of cursor position
|
|
||||||
function! ShowHighLightGroup()
|
|
||||||
if !exists("*synstack")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
|
|
||||||
|
|
||||||
:echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
|
|
||||||
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
|
|
||||||
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"
|
|
||||||
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
nmap <Leader>db :call ShowHighLightGroup()<CR>
|
nmap <Leader>db :call ShowHighLightGroup()<CR>
|
||||||
|
|
||||||
" search and filter highlight group
|
function! SetDarkTheme(...)
|
||||||
" :call Sh('airline')
|
let colors_name = a:0 > 0 ? a:1 : g:my_config.dark.theme
|
||||||
function! Sh(pattern)
|
if HasColorscheme(colors_name)
|
||||||
execute("filter /" . a:pattern . "/ highlight")
|
execute("colorscheme " . colors_name)
|
||||||
endfunc
|
if &background == 'light'
|
||||||
|
set background=dark
|
||||||
" get current colorscheme name
|
endif
|
||||||
function! ColourSchemeName()
|
let g:my_config.dark.theme = colors_name
|
||||||
try
|
let g:my_config.background = 'dark'
|
||||||
return g:colors_name
|
|
||||||
catch /^Vim:E121/
|
|
||||||
return "default"
|
|
||||||
catch /.*/
|
|
||||||
return "default"
|
|
||||||
endtry
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" delete signal file if exist
|
|
||||||
function! DeleteSignalFile(name)
|
|
||||||
if filereadable(g:vim_dir . a:name)
|
|
||||||
call delete(g:vim_dir . a:name)
|
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Create signal file if not exist
|
function! SetLightTheme(...)
|
||||||
function! CreateSignalFile(name)
|
let colors_name = a:0 > 0 ? a:1 : g:my_config.light.theme
|
||||||
call system("touch " . g:vim_dir . a:name)
|
if HasColorscheme(colors_name)
|
||||||
endfunction
|
execute("colorscheme " . colors_name)
|
||||||
|
if &background == 'dark'
|
||||||
function! SignalFileExists(filename)
|
set background=light
|
||||||
if filereadable(g:vim_dir . a:filename)
|
endif
|
||||||
return v:true
|
let g:my_config.light.theme = colors_name
|
||||||
|
let g:my_config.background = 'light'
|
||||||
endif
|
endif
|
||||||
return v:false
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! SetDarkTheme()
|
|
||||||
set background=dark
|
|
||||||
" hi clear
|
|
||||||
execute("colorscheme " . g:dark_theme)
|
|
||||||
let g:dark_or_light_theme = 'dark'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! SetLightTheme()
|
|
||||||
set background=light
|
|
||||||
" hi clear
|
|
||||||
execute("colorscheme " . g:light_theme)
|
|
||||||
execute("colorscheme " . g:light_theme)
|
|
||||||
let g:dark_or_light_theme = 'light'
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Change bottom airline/lualine theme
|
" Change bottom airline/lualine theme
|
||||||
function! SetStatusLineTheme(theme)
|
function! SetStatusLineTheme(...)
|
||||||
if g:vim_type == 'nvim' && g:vim_version >= 0.5
|
if has('nvim-0.5')
|
||||||
" lualine will change theme automatically
|
" lualine will change theme automatically
|
||||||
else
|
else
|
||||||
if HasPlug('vim-airline') && HasPlug('vim-airline-themes')
|
if HasPlug('vim-airline') && HasPlug('vim-airline-themes') && exists(':AirlineTheme')
|
||||||
execute('AirlineTheme ' . a:theme)
|
let theme = a:0 > 0 ? a:1 : g:my_config[&background].airline_theme
|
||||||
|
try
|
||||||
|
execute('AirlineTheme ' . a:theme)
|
||||||
|
catch
|
||||||
|
let theme = g:default_config[&background].airline_theme
|
||||||
|
execute('AirlineTheme ' . theme)
|
||||||
|
endtry
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! EnableTransparent()
|
function! EnableTransparent()
|
||||||
let colorscheme_name = ColourSchemeName()
|
let colorscheme_name = ColourSchemeName()
|
||||||
if g:dark_or_light_theme == 'dark'
|
let bg = &background
|
||||||
let dark_cb_name = 'CB_dark_tb_enable_' . colorscheme_name
|
let cb_name = 'CB_' .bg. '_tb_enable_'.colorscheme_name
|
||||||
if exists('*' . dark_cb_name)
|
if exists('*' . cb_name)
|
||||||
execute('call ' . dark_cb_name . '()')
|
execute('call ' . cb_name . '()')
|
||||||
elseif g:dark_transparent_enable_cb != ''
|
elseif exists('g:'.bg.'_transparent_enable_cb') && g:dark_transparent_enable_cb != ''
|
||||||
execute('call ' . g:dark_transparent_enable_cb . '()')
|
let cb_name = get(g:, bg.'_transparent_enable_cb', '')
|
||||||
else
|
if cb_name != ''
|
||||||
return
|
execute('call '.cb_name.'()')
|
||||||
endif
|
endif
|
||||||
let g:transparent_dark_theme = v:true
|
|
||||||
call CreateSignalFile('.transparent_dark_theme.signal')
|
|
||||||
else
|
else
|
||||||
let light_cb_name = 'CB_light_tb_enable_' . colorscheme_name
|
return
|
||||||
if exists('*' . light_cb_name)
|
|
||||||
execute('call ' . light_cb_name . '()')
|
|
||||||
elseif g:light_transparent_enable_cb != ''
|
|
||||||
execute('call ' . g:light_transparent_enable_cb . '()')
|
|
||||||
else
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let g:transparent_light_theme = v:true
|
|
||||||
call CreateSignalFile('.transparent_light_theme.signal')
|
|
||||||
endif
|
endif
|
||||||
|
let g:my_config[&background].transparent = v:true
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! DisableTransparent()
|
function! DisableTransparent()
|
||||||
let colorscheme_name = ColourSchemeName()
|
let colorscheme_name = ColourSchemeName()
|
||||||
if g:dark_or_light_theme == 'dark'
|
let bg = &background
|
||||||
let dark_cb_name = 'CB_dark_tb_disable_' . colorscheme_name
|
let cb_name = 'CB_' . bg . '_tb_disable_'.colorscheme_name
|
||||||
if exists('*' . dark_cb_name)
|
if exists('*' . cb_name)
|
||||||
set background=dark
|
execute('call ' . cb_name . '()')
|
||||||
execute('call ' . dark_cb_name . '()')
|
elseif exists('g:'.bg.'_transparent_disable_cb')
|
||||||
elseif g:dark_transparent_disable_cb != ''
|
let cb_name = get(g:, bg.'_transparent_disable_cb', '')
|
||||||
execute('call ' . g:dark_transparent_disable_cb . '()')
|
if cb_name != ''
|
||||||
else
|
execute('call '.cb_name.'()')
|
||||||
return
|
|
||||||
endif
|
endif
|
||||||
let g:transparent_dark_theme = v:false
|
|
||||||
call DeleteSignalFile('.transparent_dark_theme.signal')
|
|
||||||
else
|
else
|
||||||
let light_cb_name = 'CB_light_tb_disable_' . colorscheme_name
|
return
|
||||||
if exists('*' . light_cb_name)
|
|
||||||
set background=light
|
|
||||||
execute('call ' . light_cb_name . '()')
|
|
||||||
elseif g:light_transparent_disable_cb != ''
|
|
||||||
execute('call ' . g:light_transparent_disable_cb . '()')
|
|
||||||
else
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let g:transparent_light_theme = v:false
|
|
||||||
call DeleteSignalFile('.transparent_light_theme.signal')
|
|
||||||
endif
|
endif
|
||||||
" if g:vim_type == 'nvim' && g:vim_version > 0.5
|
let g:my_config[&background].transparent = v:false
|
||||||
" :TransparentDisable
|
|
||||||
" endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" ToggleTransparent background
|
" ToggleTransparent background
|
||||||
function! ToggleTransparent()
|
function! ToggleTransparent()
|
||||||
if g:transparent_dark_theme && g:dark_or_light_theme == 'dark'
|
if g:my_config[&background].transparent
|
||||||
call DisableTransparent()
|
call DisableTransparent()
|
||||||
elseif g:transparent_light_theme && g:dark_or_light_theme == 'light'
|
else
|
||||||
call DisableTransparent()
|
|
||||||
elseif ! g:transparent_light_theme && g:dark_or_light_theme == 'light'
|
|
||||||
call EnableTransparent()
|
|
||||||
elseif ! g:transparent_dark_theme && g:dark_or_light_theme == 'dark'
|
|
||||||
call EnableTransparent()
|
call EnableTransparent()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@@ -907,23 +907,28 @@ endfunction
|
|||||||
" Allow to trigger background
|
" Allow to trigger background
|
||||||
function! ToggleBG()
|
function! ToggleBG()
|
||||||
" Inversion
|
" Inversion
|
||||||
if g:dark_or_light_theme == "dark"
|
if &background == "dark"
|
||||||
call SetLightTheme()
|
call SetLightTheme()
|
||||||
call SetStatusLineTheme(g:airline_light_theme)
|
|
||||||
call CreateSignalFile('.light_theme.signal')
|
|
||||||
else
|
else
|
||||||
call SetDarkTheme()
|
call SetDarkTheme()
|
||||||
call SetStatusLineTheme(g:airline_dark_theme)
|
|
||||||
call DeleteSignalFile('.light_theme.signal')
|
|
||||||
endif
|
endif
|
||||||
|
call SetStatusLineTheme(g:my_config[&background].airline_theme)
|
||||||
|
|
||||||
if (g:transparent_dark_theme && g:dark_or_light_theme == 'dark') || (g:transparent_light_theme && g:dark_or_light_theme == 'light')
|
if g:my_config[&background].transparent
|
||||||
call EnableTransparent()
|
call EnableTransparent()
|
||||||
else
|
else
|
||||||
call DisableTransparent()
|
call DisableTransparent()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" persistent config over colorscheme change
|
||||||
|
function! Theme_persistent(...)
|
||||||
|
let color_name = a:0 > 0 ? a:1 : ColourSchemeName()
|
||||||
|
|
||||||
|
let g:my_config.background = &background
|
||||||
|
let g:my_config[&background].theme = color_name
|
||||||
|
endfunction
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""
|
||||||
""""""""""""" THEME_INIT """"""""""""""
|
""""""""""""" THEME_INIT """"""""""""""
|
||||||
"""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""
|
||||||
@@ -931,84 +936,80 @@ endfunction
|
|||||||
" transparent backgroud for supported terminal emulator
|
" transparent backgroud for supported terminal emulator
|
||||||
" check if transparent_dark_theme.signl or transparent_light_theme.signl
|
" check if transparent_dark_theme.signl or transparent_light_theme.signl
|
||||||
" exist and set respect variable
|
" exist and set respect variable
|
||||||
let g:transparent_dark_theme = v:false
|
|
||||||
let g:transparent_light_theme = v:false
|
|
||||||
|
|
||||||
function! Theme_initilize()
|
function! Theme_initilize()
|
||||||
if SignalFileExists('.transparent_dark_theme.signal')
|
if has('termguicolors')
|
||||||
let g:transparent_dark_theme = v:true
|
set termguicolors
|
||||||
endif
|
|
||||||
if SignalFileExists('.transparent_light_theme.signal')
|
|
||||||
let g:transparent_light_theme = v:true
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" dark or light
|
if g:my_config.background == 'dark'
|
||||||
if filereadable(g:vim_dir . '.light_theme.signal')
|
if HasColorscheme(g:my_config.dark.theme)
|
||||||
let g:dark_or_light_theme = 'light'
|
call SetDarkTheme()
|
||||||
|
else
|
||||||
|
call SetDarkTheme(g:my_config.dark.default)
|
||||||
|
endif
|
||||||
|
call SetStatusLineTheme(g:my_config.dark.airline_theme)
|
||||||
else
|
else
|
||||||
let g:dark_or_light_theme = 'dark'
|
if HasColorscheme(g:my_config.dark.theme)
|
||||||
|
call SetLightTheme()
|
||||||
|
else
|
||||||
|
call SetLightTheme(g:my_config.light.default)
|
||||||
|
endif
|
||||||
|
call SetStatusLineTheme(g:my_config.light.airline_theme)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if g:dark_or_light_theme == 'dark'
|
if g:my_config[g:my_config.background].transparent
|
||||||
let g:airline_theme=g:airline_dark_theme
|
|
||||||
call SetDarkTheme()
|
|
||||||
else
|
|
||||||
let g:airline_theme=g:airline_light_theme
|
|
||||||
call SetLightTheme()
|
|
||||||
endif
|
|
||||||
if (g:transparent_dark_theme && g:dark_or_light_theme == 'dark')
|
|
||||||
\ || (g:transparent_light_theme && g:dark_or_light_theme == 'light')
|
|
||||||
call EnableTransparent()
|
call EnableTransparent()
|
||||||
else
|
else
|
||||||
call DisableTransparent()
|
call DisableTransparent()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
au! VimEnter * call Theme_initilize()
|
|
||||||
|
augroup ThemeAuGroup
|
||||||
|
autocmd!
|
||||||
|
autocmd VimEnter * call Theme_initilize()
|
||||||
|
augroup END
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""
|
||||||
""""""""""" THEME_OPTIONS """""""""""""
|
""""""""""" THEME_OPTIONS """""""""""""
|
||||||
"""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""
|
||||||
|
|
||||||
" Default
|
let g:default_config = {
|
||||||
let g:dark_theme = 'default'
|
\ 'background': 'dark',
|
||||||
let g:light_theme = 'default'
|
\ 'dark': {
|
||||||
|
\ 'theme': 'default',
|
||||||
|
\ 'default': 'default',
|
||||||
|
\ 'transparent': v:false,
|
||||||
|
\ 'airline_theme': 'angr',
|
||||||
|
\ },
|
||||||
|
\ 'light': {
|
||||||
|
\ 'theme': 'default',
|
||||||
|
\ 'default': 'default',
|
||||||
|
\ 'transparent': v:false,
|
||||||
|
\ 'airline_theme': 'silver',
|
||||||
|
\ },
|
||||||
|
\ }
|
||||||
|
|
||||||
" for airline
|
let g:my_config = {}
|
||||||
let g:airline_dark_theme = "angr"
|
|
||||||
let g:airline_light_theme = "silver"
|
|
||||||
|
|
||||||
" vim theme
|
let g:colo2airline = {
|
||||||
if g:vim_type == 'vim'
|
\ }
|
||||||
set t_Co=256
|
|
||||||
if has('termguicolors')
|
|
||||||
set termguicolors
|
|
||||||
endif
|
|
||||||
|
|
||||||
if HasPlug("papercolor-theme")
|
" permenent default
|
||||||
" improve coc color in this theme
|
if HasPlug("everforest")
|
||||||
let g:light_theme = 'PaperColor'
|
let g:default_config = Merge(g:default_config, {
|
||||||
endif
|
\ 'dark': {
|
||||||
|
\ 'airline_theme': 'everforest',
|
||||||
if HasPlug("everforest")
|
\ 'default': 'everforest',
|
||||||
let g:light_theme = 'everforest'
|
\ },
|
||||||
let g:dark_theme = 'everforest'
|
\ 'light': {
|
||||||
let g:airline_dark_theme = "everforest"
|
\ 'airline_theme': 'everforest',
|
||||||
let g:airline_light_theme = "everforest"
|
\ 'default': 'everforest',
|
||||||
endif
|
\ },
|
||||||
endif
|
\ })
|
||||||
|
|
||||||
if g:vim_type == 'nvim'
|
|
||||||
if HasPlug("nightfox.nvim")
|
|
||||||
let g:light_theme = 'dawnfox'
|
|
||||||
let g:dark_theme = 'nightfox'
|
|
||||||
end
|
|
||||||
|
|
||||||
if HasPlug("github-nvim-theme")
|
|
||||||
let g:dark_theme = 'github_dark'
|
|
||||||
let g:airline_dark_theme = "hybrid"
|
|
||||||
end
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let g:my_config = Merge(g:default_config, LoadConfig())
|
||||||
" }
|
" }
|
||||||
|
|
||||||
" KEY_MAPS
|
" KEY_MAPS
|
||||||
@@ -1031,7 +1032,8 @@ endfunction
|
|||||||
|
|
||||||
" leader num change tab
|
" leader num change tab
|
||||||
" only for vim or nvim without lualine
|
" only for vim or nvim without lualine
|
||||||
if g:vim_type == 'vim' || (g:vim_type == 'nvim' && g:vim_version < 0.5)
|
|
||||||
|
if (g:vim_type == 'vim' || !has('nvim-0.5')) && HasPlug('vim-bufferline')
|
||||||
for i in range(1, 9)
|
for i in range(1, 9)
|
||||||
execute "nnoremap <silent> <nowait> <leader>" . i .
|
execute "nnoremap <silent> <nowait> <leader>" . i .
|
||||||
\ " :call bufferline#jump(" . i . ")<CR>"
|
\ " :call bufferline#jump(" . i . ")<CR>"
|
||||||
@@ -1052,9 +1054,3 @@ if g:vim_type == 'nvim' && filereadable(g:mydotfiles_directory . '.vimrc.lua')
|
|||||||
execute('source ' . g:mydotfiles_directory . '/.vimrc.lua')
|
execute('source ' . g:mydotfiles_directory . '/.vimrc.lua')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" OTHER_CONFIGS
|
|
||||||
|
|
||||||
if filereadable(g:mydotfiles_directory . "/config/theme.vim")
|
|
||||||
" exec "source " . g:mydotfiles_directory . "/config/theme.vim"
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|||||||
+439
-426
@@ -6,6 +6,7 @@
|
|||||||
-- jump animation. (Performence will be effected)
|
-- jump animation. (Performence will be effected)
|
||||||
local animation_enable = vim.g.animation_enable
|
local animation_enable = vim.g.animation_enable
|
||||||
local high_performence = vim.g.high_performence
|
local high_performence = vim.g.high_performence
|
||||||
|
local debug_mode = vim.g.debug_mode
|
||||||
|
|
||||||
-- false basicly enable plugins like noice, nvim-notify etc.
|
-- false basicly enable plugins like noice, nvim-notify etc.
|
||||||
local classic_vim_ui = vim.g.classic_vim_ui
|
local classic_vim_ui = vim.g.classic_vim_ui
|
||||||
@@ -22,30 +23,29 @@ end
|
|||||||
-- use as a wrapper function to set keymap that call a function with
|
-- use as a wrapper function to set keymap that call a function with
|
||||||
-- parameters
|
-- parameters
|
||||||
local _wrap = function(func, ...)
|
local _wrap = function(func, ...)
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
return function()
|
return function()
|
||||||
func(unpack(args))
|
func(unpack(args))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- use to print object
|
-- use to print object
|
||||||
function _G.put(...)
|
function _G.put(...)
|
||||||
local objects = {}
|
local objects = {}
|
||||||
for i = 1, select('#', ...) do
|
for i = 1, select('#', ...) do
|
||||||
local v = select(i, ...)
|
local v = select(i, ...)
|
||||||
table.insert(objects, vim.inspect(v))
|
table.insert(objects, vim.inspect(v))
|
||||||
end
|
end
|
||||||
|
|
||||||
print(table.concat(objects, '\n'))
|
print(table.concat(objects, '\n'))
|
||||||
return ...
|
return ...
|
||||||
end
|
end
|
||||||
|
|
||||||
local wk = nil
|
local wk = nil
|
||||||
local function wk_register(opt)
|
local function wk_register(opt)
|
||||||
if wk == nil then
|
if wk == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
wk.register(opt)
|
wk.register(opt)
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
@@ -58,494 +58,507 @@ local vim_version_minor = vim_version['minor']
|
|||||||
|
|
||||||
local show_icon = false
|
local show_icon = false
|
||||||
if HasPlug('nvim-web-devicons') then
|
if HasPlug('nvim-web-devicons') then
|
||||||
show_icon = true
|
show_icon = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function nvim_noice_config()
|
local function nvim_noice_config()
|
||||||
if classic_vim_ui
|
if classic_vim_ui
|
||||||
or not HasPlug('noice.nvim')
|
or not HasPlug('noice.nvim')
|
||||||
or not HasPlug('nvim-notify')
|
or not HasPlug('nvim-notify')
|
||||||
or not HasPlug('nui.nvim') then
|
or not HasPlug('nui.nvim') then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
require("noice").setup({
|
require("noice").setup({
|
||||||
lsp = {
|
lsp = {
|
||||||
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
|
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
|
||||||
override = {
|
override = {
|
||||||
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
|
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
|
||||||
["vim.lsp.util.stylize_markdown"] = true,
|
["vim.lsp.util.stylize_markdown"] = true,
|
||||||
["cmp.entry.get_documentation"] = true,
|
["cmp.entry.get_documentation"] = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
-- you can enable a preset for easier configuration
|
-- you can enable a preset for easier configuration
|
||||||
presets = {
|
presets = {
|
||||||
bottom_search = true, -- use a classic bottom cmdline for search
|
bottom_search = true, -- use a classic bottom cmdline for search
|
||||||
-- command_palette = true, -- position the cmdline and popupmenu together
|
-- command_palette = true, -- position the cmdline and popupmenu together
|
||||||
long_message_to_split = true, -- long messages will be sent to a split
|
long_message_to_split = true, -- long messages will be sent to a split
|
||||||
inc_rename = false, -- enables an input dialog for inc-rename.nvim
|
inc_rename = false, -- enables an input dialog for inc-rename.nvim
|
||||||
lsp_doc_border = false, -- add a border to hover docs and signature help
|
lsp_doc_border = false, -- add a border to hover docs and signature help
|
||||||
},
|
},
|
||||||
cmdline = {
|
cmdline = {
|
||||||
enabled = true, -- enables the Noice cmdline UI
|
enabled = true, -- enables the Noice cmdline UI
|
||||||
-- view = "cmdline", -- view for rendering the cmdline. Change to `cmdline` to get a classic cmdline at the bottom
|
-- view = "cmdline", -- view for rendering the cmdline. Change to `cmdline` to get a classic cmdline at the bottom
|
||||||
opts = {}, -- global options for the cmdline. See section on views
|
opts = {}, -- global options for the cmdline. See section on views
|
||||||
format = {
|
format = {
|
||||||
-- cmdline = false,
|
-- cmdline = false,
|
||||||
search_down = false,
|
search_down = false,
|
||||||
search_up = false,
|
search_up = false,
|
||||||
-- filter = false,
|
-- filter = false,
|
||||||
-- help = false,
|
-- help = false,
|
||||||
-- input = {}, -- Used by input()
|
-- input = {}, -- Used by input()
|
||||||
-- lua = false, -- to disable a format, set to `false`
|
-- lua = false, -- to disable a format, set to `false`
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
messages = {
|
messages = {
|
||||||
-- NOTE: If you enable messages, then the cmdline is enabled automatically.
|
-- NOTE: If you enable messages, then the cmdline is enabled automatically.
|
||||||
-- This is a current Neovim limitation.
|
-- This is a current Neovim limitation.
|
||||||
enabled = true, -- enables the Noice messages UI
|
enabled = true, -- enables the Noice messages UI
|
||||||
view = "notify", -- default view for messages
|
view = "notify", -- default view for messages
|
||||||
view_error = "notify", -- view for errors
|
view_error = "notify", -- view for errors
|
||||||
view_warn = "notify", -- view for warnings
|
view_warn = "notify", -- view for warnings
|
||||||
view_history = "messages", -- view for :messages
|
view_history = "messages", -- view for :messages
|
||||||
view_search = false, -- view for search count messages. Set to `false` to disable
|
view_search = false, -- view for search count messages. Set to `false` to disable
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function nvim_scrollbar_config()
|
local function nvim_scrollbar_config()
|
||||||
if classic_vim_ui or
|
if classic_vim_ui or
|
||||||
not HasPlug('nvim-scrollbar') then
|
not HasPlug('nvim-scrollbar') then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
require("scrollbar").setup({
|
require("scrollbar").setup({
|
||||||
excluded_filetypes = {
|
excluded_filetypes = {
|
||||||
"prompt",
|
"prompt",
|
||||||
"TelescopePrompt",
|
"TelescopePrompt",
|
||||||
"noice",
|
"noice",
|
||||||
"startify",
|
"startify",
|
||||||
"vista",
|
"vista",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function toggleterm_config()
|
local function toggleterm_config()
|
||||||
if not HasPlug('toggleterm.nvim') then
|
if not HasPlug('toggleterm.nvim') then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
require("toggleterm").setup({
|
require("toggleterm").setup({
|
||||||
open_mapping = [[<c-\>]],
|
open_mapping = [[<c-\>]],
|
||||||
})
|
})
|
||||||
function _G.set_terminal_keymaps()
|
function _G.set_terminal_keymaps()
|
||||||
local opts = {buffer = 0}
|
local opts = { buffer = 0 }
|
||||||
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
|
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
|
||||||
vim.keymap.set('t', 'jk', [[<C-\><C-n>]], opts)
|
vim.keymap.set('t', 'jk', [[<C-\><C-n>]], opts)
|
||||||
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
|
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
|
||||||
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
|
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
|
||||||
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
|
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
|
||||||
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
|
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
|
||||||
vim.keymap.set('t', '<C-w>', [[<C-\><C-n><C-w>]], opts)
|
vim.keymap.set('t', '<C-w>', [[<C-\><C-n><C-w>]], opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
|
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
|
||||||
end
|
end
|
||||||
|
|
||||||
local function vim_illuminate_config()
|
local function vim_illuminate_config()
|
||||||
if not HasPlug('vim-illuminate') then
|
if not HasPlug('vim-illuminate') then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local illuminate = require('illuminate')
|
local illuminate = require('illuminate')
|
||||||
illuminate.configure({
|
illuminate.configure({
|
||||||
providers = {
|
providers = {
|
||||||
'lsp',
|
'lsp',
|
||||||
'treesitter',
|
'treesitter',
|
||||||
'regex',
|
'regex',
|
||||||
},
|
},
|
||||||
delay = 0,
|
delay = 0,
|
||||||
filetype_overrides = {},
|
filetype_overrides = {},
|
||||||
filetypes_denylist = {
|
filetypes_denylist = {
|
||||||
'dirvish',
|
'dirvish',
|
||||||
'fugitive',
|
'fugitive',
|
||||||
'NvimTree',
|
'NvimTree',
|
||||||
'help',
|
'help',
|
||||||
'vista',
|
'vista',
|
||||||
},
|
},
|
||||||
filetypes_allowlist = {},
|
filetypes_allowlist = {},
|
||||||
modes_denylist = {},
|
modes_denylist = {},
|
||||||
modes_allowlist = {},
|
modes_allowlist = {},
|
||||||
providers_regex_syntax_denylist = {},
|
providers_regex_syntax_denylist = {},
|
||||||
providers_regex_syntax_allowlist = {},
|
providers_regex_syntax_allowlist = {},
|
||||||
under_cursor = true,
|
under_cursor = true,
|
||||||
large_file_cutoff = nil,
|
large_file_cutoff = nil,
|
||||||
large_file_overrides = nil,
|
large_file_overrides = nil,
|
||||||
min_count_to_highlight = 1,
|
min_count_to_highlight = 1,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function which_key_config()
|
local function which_key_config()
|
||||||
if not HasPlug('which-key.nvim') then
|
if not HasPlug('which-key.nvim') then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
wk = require("which-key")
|
wk = require("which-key")
|
||||||
wk.setup()
|
wk.setup()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
vim.g.hhx = ''
|
||||||
local function telescope_config()
|
local function telescope_config()
|
||||||
if not HasPlug('telescope.nvim') then
|
if not HasPlug('telescope.nvim') then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if HasPlug('telescope-fzf-native.nvim') then
|
local actions = require("telescope.actions")
|
||||||
require('telescope').setup {
|
local action_state = require "telescope.actions.state"
|
||||||
pickers = {
|
if HasPlug('telescope-fzf-native.nvim') then
|
||||||
colorscheme = {
|
require('telescope').setup {
|
||||||
enable_preview = true
|
pickers = {
|
||||||
}
|
colorscheme = {
|
||||||
|
enable_preview = true,
|
||||||
|
mappings = {
|
||||||
|
i = {
|
||||||
|
["<CR>"] = function(bufnr)
|
||||||
|
local selection = action_state.get_selected_entry()
|
||||||
|
actions.select_default()
|
||||||
|
vim.fn.Theme_persistent(selection.value)
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
extensions = {
|
},
|
||||||
fzf = {
|
|
||||||
fuzzy = true, -- false will only do exact matching
|
|
||||||
override_generic_sorter = true,
|
|
||||||
override_file_sorter = true,
|
|
||||||
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
require('telescope').load_extension('fzf')
|
},
|
||||||
end
|
extensions = {
|
||||||
|
fzf = {
|
||||||
|
fuzzy = true, -- false will only do exact matching
|
||||||
|
override_generic_sorter = true,
|
||||||
|
override_file_sorter = true,
|
||||||
|
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
require('telescope').load_extension('fzf')
|
||||||
|
end
|
||||||
|
|
||||||
local builtin = require('telescope.builtin')
|
local builtin = require('telescope.builtin')
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = "Search files inside cwd" })
|
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = "Search files inside cwd" })
|
||||||
-- need to install ripgrep
|
-- need to install ripgrep
|
||||||
vim.keymap.set('n', '<leader>fr', builtin.live_grep, { desc = "Regex search inside files" })
|
vim.keymap.set('n', '<leader>fr', builtin.live_grep, { desc = "Regex search inside files" })
|
||||||
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = "Search buffers" })
|
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = "Search buffers" })
|
||||||
vim.keymap.set('n', '<leader>fc', builtin.colorscheme, { desc = "Search colorscheme" })
|
vim.keymap.set('n', '<leader>fc', builtin.colorscheme, { desc = "Search colorscheme" })
|
||||||
wk_register({ ["<leader>f"] = { name = "+Telescope" }})
|
wk_register({ ["<leader>f"] = { name = "+Telescope" } })
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("User", {
|
vim.api.nvim_create_autocmd("User", {
|
||||||
pattern = "TelescopePreviewerLoaded",
|
pattern = "TelescopePreviewerLoaded",
|
||||||
command = "setlocal wrap number" })
|
command = "setlocal wrap number"
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function github_theme_config()
|
local function github_theme_config()
|
||||||
if not HasPlug('github-nvim-theme') then
|
if not HasPlug('github-nvim-theme') then
|
||||||
return
|
return
|
||||||
|
end
|
||||||
|
-- Example config in Lua
|
||||||
|
require("github-theme").setup({
|
||||||
|
-- Overwrite the highlight groups
|
||||||
|
overrides = function(c)
|
||||||
|
return {
|
||||||
|
NormalFloat = { link = 'Pmenu' },
|
||||||
|
}
|
||||||
end
|
end
|
||||||
-- Example config in Lua
|
})
|
||||||
require("github-theme").setup({
|
|
||||||
-- Overwrite the highlight groups
|
|
||||||
overrides = function(c)
|
|
||||||
return {
|
|
||||||
NormalFloat = { link = 'Pmenu' },
|
|
||||||
}
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function animate_config()
|
local function animate_config()
|
||||||
if not animation_enable then
|
if not animation_enable then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if HasPlug('mini.animate') then
|
if HasPlug('mini.animate') then
|
||||||
|
local animate = require('mini.animate')
|
||||||
|
animate.setup({
|
||||||
|
cursor = {
|
||||||
|
-- Whether to enable this animation
|
||||||
|
enable = true,
|
||||||
|
-- Timing of animation (how steps will progress in time)
|
||||||
|
-- timing = --<function: implements linear total 250ms animation duration>,
|
||||||
|
},
|
||||||
|
scroll = {
|
||||||
|
-- Whether to enable this animation
|
||||||
|
enable = true,
|
||||||
|
-- Timing of animation (how steps will progress in time)
|
||||||
|
timing = animate.gen_timing.linear({ duration = 150, unit = 'total' }),
|
||||||
|
},
|
||||||
|
open = {
|
||||||
|
-- Whether to enable this animation
|
||||||
|
enable = false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason",
|
||||||
|
"NvimTree", "vista", "toggleterm", "noice" },
|
||||||
|
callback = function()
|
||||||
|
vim.b.minianimate_disable = true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
local animate = require('mini.animate')
|
-- if HasPlug('neoscroll.nvim') then
|
||||||
animate.setup({
|
-- require('neoscroll').setup({
|
||||||
cursor = {
|
-- -- Set any options as needed
|
||||||
-- Whether to enable this animation
|
-- mappings = {'<C-u>', '<C-d>', '<C-b>', '<C-f>',
|
||||||
enable = true,
|
-- },
|
||||||
-- Timing of animation (how steps will progress in time)
|
-- })
|
||||||
-- timing = --<function: implements linear total 250ms animation duration>,
|
|
||||||
},
|
|
||||||
scroll = {
|
|
||||||
-- Whether to enable this animation
|
|
||||||
enable = true,
|
|
||||||
-- Timing of animation (how steps will progress in time)
|
|
||||||
timing = animate.gen_timing.linear({ duration = 150, unit = 'total' }),
|
|
||||||
},
|
|
||||||
open = {
|
|
||||||
-- Whether to enable this animation
|
|
||||||
enable = false,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
|
||||||
pattern = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason",
|
|
||||||
"NvimTree", "vista", "toggleterm", "noice" },
|
|
||||||
callback = function()
|
|
||||||
vim.b.minianimate_disable = true
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- if HasPlug('neoscroll.nvim') then
|
-- local t = {}
|
||||||
-- require('neoscroll').setup({
|
-- -- Syntax: t[keys] = {function, {function arguments}}
|
||||||
-- -- Set any options as needed
|
-- t['<C-u>'] = {'scroll', {'-vim.wo.scroll', 'true', '150'}}
|
||||||
-- mappings = {'<C-u>', '<C-d>', '<C-b>', '<C-f>',
|
-- t['<C-d>'] = {'scroll', { 'vim.wo.scroll', 'true', '150'}}
|
||||||
-- },
|
-- t['<C-b>'] = {'scroll', {'-vim.api.nvim_win_get_height(0)', 'true', '200'}}
|
||||||
-- })
|
-- t['<C-f>'] = {'scroll', { 'vim.api.nvim_win_get_height(0)', 'true', '200'}}
|
||||||
|
-- -- t['zb'] = {'zb', {'250'}}
|
||||||
|
|
||||||
-- local t = {}
|
-- require('neoscroll.config').set_mappings(t)
|
||||||
-- -- Syntax: t[keys] = {function, {function arguments}}
|
-- end
|
||||||
-- t['<C-u>'] = {'scroll', {'-vim.wo.scroll', 'true', '150'}}
|
|
||||||
-- t['<C-d>'] = {'scroll', { 'vim.wo.scroll', 'true', '150'}}
|
|
||||||
-- t['<C-b>'] = {'scroll', {'-vim.api.nvim_win_get_height(0)', 'true', '200'}}
|
|
||||||
-- t['<C-f>'] = {'scroll', { 'vim.api.nvim_win_get_height(0)', 'true', '200'}}
|
|
||||||
-- -- t['zb'] = {'zb', {'250'}}
|
|
||||||
|
|
||||||
-- require('neoscroll.config').set_mappings(t)
|
|
||||||
-- end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function indentline_config()
|
local function indentline_config()
|
||||||
if not animation_enable then
|
if not animation_enable then
|
||||||
if HasPlug('indent-blankline.nvim') then
|
if HasPlug('indent-blankline.nvim') then
|
||||||
-- Example config in Lua
|
-- Example config in Lua
|
||||||
require("indent_blankline").setup {
|
require("indent_blankline").setup {
|
||||||
show_current_context = true,
|
show_current_context = true,
|
||||||
filetype_exclude = { "lspinfo", "packer", "checkhealth",
|
filetype_exclude = { "lspinfo", "packer", "checkhealth",
|
||||||
"help", "man", "", "startify", }
|
"help", "man", "", "startify", }
|
||||||
-- use_treesitter = true,
|
-- use_treesitter = true,
|
||||||
}
|
}
|
||||||
end
|
|
||||||
else
|
|
||||||
if HasPlug('mini.indentscope') then
|
|
||||||
MiniIndentscope = require('mini.indentscope')
|
|
||||||
MiniIndentscope.setup({
|
|
||||||
symbol = '│',
|
|
||||||
-- draw = {
|
|
||||||
-- animation = MiniIndentscope.gen_animation.linear({
|
|
||||||
-- easing = 'out',
|
|
||||||
-- duration = 150,
|
|
||||||
-- unit = 'total'
|
|
||||||
-- })
|
|
||||||
-- },
|
|
||||||
})
|
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
|
||||||
pattern = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason",
|
|
||||||
"NvimTree", "vista", "startify", "toggleterm" },
|
|
||||||
callback = function()
|
|
||||||
vim.b.miniindentscope_disable = true
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if HasPlug('mini.indentscope') then
|
||||||
|
MiniIndentscope = require('mini.indentscope')
|
||||||
|
MiniIndentscope.setup({
|
||||||
|
symbol = '│',
|
||||||
|
-- draw = {
|
||||||
|
-- animation = MiniIndentscope.gen_animation.linear({
|
||||||
|
-- easing = 'out',
|
||||||
|
-- duration = 150,
|
||||||
|
-- unit = 'total'
|
||||||
|
-- })
|
||||||
|
-- },
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason",
|
||||||
|
"NvimTree", "vista", "startify", "toggleterm" },
|
||||||
|
callback = function()
|
||||||
|
vim.b.miniindentscope_disable = true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function transparent_config()
|
local function transparent_config()
|
||||||
if not HasPlug('nvim-transparent') then
|
if not HasPlug('nvim-transparent') then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
require("transparent").setup({
|
require("transparent").setup({
|
||||||
enable = true, -- boolean: enable transparent
|
extra_groups = { -- table/string: additional groups that should be cleared
|
||||||
extra_groups = { -- table/string: additional groups that should be cleared
|
-- In particular, when you set it to 'all', that means all available groups
|
||||||
-- In particular, when you set it to 'all', that means all available groups
|
"NvimTreeNormal",
|
||||||
"NvimTreeNormal",
|
"VertSplit",
|
||||||
"VertSplit",
|
},
|
||||||
},
|
exclude_groups = {}, -- table: groups you don't want to clear
|
||||||
exclude = {}, -- table: groups you don't want to clear
|
})
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function lualine_config()
|
local function lualine_config()
|
||||||
if not HasPlug('lualine.nvim') then
|
if not HasPlug('lualine.nvim') then
|
||||||
return
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_set_hl(0, 'CocstatusSucceed', { fg = "#e32be0" })
|
||||||
|
vim.api.nvim_set_hl(0, 'CocstatusLoading', { fg = "#35f0e9" })
|
||||||
|
-- custom lualine plugin show coc lsp status
|
||||||
|
local function cocstatus()
|
||||||
|
local loading = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" }
|
||||||
|
local step = #loading
|
||||||
|
local ok, result = pcall(vim.fn.CocAction, 'services')
|
||||||
|
if not ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local ft = vim.bo.filetype
|
||||||
|
local state, id
|
||||||
|
for _, entry in ipairs(result) do
|
||||||
|
if entry['languageIds'][1] == ft then
|
||||||
|
state = entry['state']
|
||||||
|
id = entry['id']
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_set_hl(0, 'CocstatusSucceed', { fg = "#e32be0"})
|
local speed = 1600
|
||||||
vim.api.nvim_set_hl(0, 'CocstatusLoading', { fg = "#35f0e9"})
|
local loadidx = (vim.loop.now() % speed)
|
||||||
-- custom lualine plugin show coc lsp status
|
local msg = "lsp:" .. id
|
||||||
local function cocstatus()
|
if state == "starting" then
|
||||||
local loading = {"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
|
return msg .. " %#CocstatusLoading#" .. loading[math.floor(loadidx / (step * (speed / 100))) + 1]
|
||||||
local step = #loading
|
|
||||||
local ok, result = pcall( vim.fn.CocAction, 'services')
|
|
||||||
if not ok then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local ft = vim.bo.filetype
|
|
||||||
local state, id
|
|
||||||
for _, entry in ipairs(result) do
|
|
||||||
if entry['languageIds'][1] == ft then
|
|
||||||
state = entry['state']
|
|
||||||
id = entry['id']
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local speed = 1600
|
|
||||||
local loadidx = (vim.loop.now() % speed)
|
|
||||||
local msg = "LSP(" .. id .. ")"
|
|
||||||
if state == "starting" then
|
|
||||||
return msg .. " %#CocstatusLoading#" .. loading[math.floor(loadidx/(step * (speed/100))) + 1]
|
|
||||||
end
|
|
||||||
return msg .. " %#CocstatusSucceed#✔"
|
|
||||||
end
|
end
|
||||||
|
return msg .. " %#CocstatusSucceed#✔"
|
||||||
|
end
|
||||||
|
|
||||||
local disabled_filetypes_data = {}
|
local function debugstats()
|
||||||
if vim_version_minor < 7 then
|
local t = vim.fn.Debugstats()
|
||||||
-- globalstatus only work for nvim >= 0.7
|
return "ft:" .. t['filetype'] .. " bt:" .. t['buftype'] .. " wid:" .. t['winid']
|
||||||
disabled_filetypes_data = { -- Filetypes to disable lualine for.
|
end
|
||||||
statusline = {}, -- only ignores the ft for statusline.
|
|
||||||
winbar = {}, -- only ignores the ft for winbar.
|
|
||||||
'NvimTree',
|
|
||||||
'vista'
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
local opt = {
|
local _section_x = {}
|
||||||
options = {
|
local _section_y = { 'encoding' }
|
||||||
icons_enabled = show_icon,
|
if HasPlug('coc.nvim') then table.insert(_section_x, cocstatus) end
|
||||||
theme = 'auto', -- lualine theme
|
if debug_mode then _section_y = { debugstats } end
|
||||||
-- theme = 'ayu', -- lualine theme
|
|
||||||
-- component_separators = { left = '', right = ''},
|
|
||||||
-- section_separators = { left = '', right = ''},
|
|
||||||
component_separators = { left = '', right = ''},
|
|
||||||
section_separators = { left = '', right = ''},
|
|
||||||
|
|
||||||
always_divide_middle = false,
|
local disabled_filetypes_data = {}
|
||||||
globalstatus = true,
|
if vim_version_minor < 7 then
|
||||||
disabled_filetypes = disabled_filetypes_data,
|
-- globalstatus only work for nvim >= 0.7
|
||||||
refresh = {statusline = 200}
|
disabled_filetypes_data = {
|
||||||
},
|
-- Filetypes to disable lualine for.
|
||||||
sections = {
|
statusline = {}, -- only ignores the ft for statusline.
|
||||||
lualine_a = { 'mode' },
|
winbar = {}, -- only ignores the ft for winbar.
|
||||||
lualine_b = {},
|
'NvimTree',
|
||||||
lualine_c = {
|
'vista',
|
||||||
{
|
|
||||||
'buffers',
|
|
||||||
mode = 2,
|
|
||||||
filetype_names = {
|
|
||||||
TelescopePrompt = 'Telescope',
|
|
||||||
dashboard = 'Dashboard',
|
|
||||||
packer = 'Packer',
|
|
||||||
fzf = 'FZF',
|
|
||||||
alpha = 'Alpha',
|
|
||||||
NvimTree = '',
|
|
||||||
vista = ''
|
|
||||||
},
|
|
||||||
symbols = {
|
|
||||||
modified = ' ●', -- Text to show when the buffer is modified
|
|
||||||
alternate_file = '', -- Text to show to identify the alternate file
|
|
||||||
directory = '', -- Text to show when the buffer is a directory
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
-- lualine_x = {'encoding', 'fileformat', 'filetype'},
|
|
||||||
lualine_x = { cocstatus },
|
|
||||||
lualine_y = {'encoding'},
|
|
||||||
lualine_z = {'location' }
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
require('lualine').setup(opt)
|
local opt = {
|
||||||
|
options = {
|
||||||
|
icons_enabled = show_icon,
|
||||||
|
theme = 'auto', -- lualine theme
|
||||||
|
-- component_separators = { left = '', right = ''},
|
||||||
|
-- section_separators = { left = '', right = ''},
|
||||||
|
component_separators = { left = '', right = '' },
|
||||||
|
section_separators = { left = '', right = '' },
|
||||||
|
always_divide_middle = false,
|
||||||
|
globalstatus = true,
|
||||||
|
disabled_filetypes = disabled_filetypes_data,
|
||||||
|
refresh = { statusline = 200 }
|
||||||
|
},
|
||||||
|
sections = {
|
||||||
|
lualine_a = { 'mode' },
|
||||||
|
lualine_b = {},
|
||||||
|
lualine_c = {
|
||||||
|
{
|
||||||
|
'buffers',
|
||||||
|
mode = 2,
|
||||||
|
filetype_names = {
|
||||||
|
TelescopePrompt = 'Telescope',
|
||||||
|
dashboard = 'Dashboard',
|
||||||
|
packer = 'Packer',
|
||||||
|
fzf = 'FZF',
|
||||||
|
alpha = 'Alpha',
|
||||||
|
NvimTree = '',
|
||||||
|
vista = '',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
-- lualine_x = {'encoding', 'fileformat', 'filetype'},
|
||||||
|
lualine_x = _section_x,
|
||||||
|
lualine_y = _section_y,
|
||||||
|
lualine_z = { 'location' }
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
for i=1,9 do
|
require('lualine').setup(opt)
|
||||||
-- :nnoremap <silent> <Leader>1 :LualineBuffersJump 1<CR>
|
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>' .. i, ':LualineBuffersJump ' .. i .. '<CR>',
|
|
||||||
{ noremap = true, silent = true, nowait = true })
|
|
||||||
end
|
|
||||||
for i=10,20 do
|
|
||||||
-- :nnoremap <silent> <Leader>1 :LualineBuffersJump 1<CR>
|
|
||||||
vim.api.nvim_set_keymap('n', '<Space>' .. i, ':LualineBuffersJump ' .. i .. '<CR>',
|
|
||||||
{ noremap = true, silent = true, nowait = true })
|
|
||||||
end
|
|
||||||
|
|
||||||
|
for i = 1, 9 do
|
||||||
|
-- :nnoremap <silent> <Leader>1 :LualineBuffersJump 1<CR>
|
||||||
|
vim.api.nvim_set_keymap('n', '<Leader>' .. i, ':LualineBuffersJump ' .. i .. '<CR>',
|
||||||
|
{ noremap = true, silent = true, nowait = true })
|
||||||
|
end
|
||||||
|
for i = 10, 20 do
|
||||||
|
-- :nnoremap <silent> <Leader>1 :LualineBuffersJump 1<CR>
|
||||||
|
vim.api.nvim_set_keymap('n', '<Space>' .. i, ':LualineBuffersJump ' .. i .. '<CR>',
|
||||||
|
{ noremap = true, silent = true, nowait = true })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function nvim_treesitter_config()
|
local function nvim_treesitter_config()
|
||||||
if not HasPlug('nvim-treesitter') then
|
if not HasPlug('nvim-treesitter') then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
require('nvim-treesitter.configs').setup {
|
require('nvim-treesitter.configs').setup {
|
||||||
-- ensure_installed = { "c", "bash", "lua" },
|
ensure_installed = { "c", "bash", "lua", "python", "vim" },
|
||||||
sync_install = false,
|
sync_install = false,
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
-- ignore_install = { "javascript" },
|
highlight = {
|
||||||
highlight = {
|
enable = true,
|
||||||
enable = true,
|
additional_vim_regex_highlighting = false,
|
||||||
additional_vim_regex_highlighting = false,
|
},
|
||||||
},
|
}
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function nvim_tree_config()
|
local function nvim_tree_config()
|
||||||
if not HasPlug('nvim-tree.lua') then
|
if not HasPlug('nvim-tree.lua') then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- disable netrw at the very start of your init.lua (strongly advised)
|
-- disable netrw at the very start of your init.lua (strongly advised)
|
||||||
vim.g.loaded_netrw = 1
|
vim.g.loaded_netrw = 1
|
||||||
vim.g.loaded_netrwPlugin = 1
|
vim.g.loaded_netrwPlugin = 1
|
||||||
|
|
||||||
-- set termguicolors to enable highlight groups
|
-- set termguicolors to enable highlight groups
|
||||||
vim.opt.termguicolors = true
|
vim.opt.termguicolors = true
|
||||||
|
|
||||||
-- setup with some options
|
-- setup with some options
|
||||||
require("nvim-tree").setup({
|
require("nvim-tree").setup({
|
||||||
sort_by = "case_sensitive",
|
sort_by = "case_sensitive",
|
||||||
view = {
|
view = {
|
||||||
width = 30,
|
width = 30,
|
||||||
mappings = {
|
mappings = {
|
||||||
list = {
|
list = {
|
||||||
{ key = "C-[", action = "dir_up" },
|
{ key = "C-[", action = "dir_up" },
|
||||||
{ key = "C-]", action = "cd" },
|
{ key = "C-]", action = "cd" },
|
||||||
{ key = "<C-k>", action = "toggle_file_info" },
|
{ key = "<C-k>", action = "toggle_file_info" },
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
renderer = {
|
},
|
||||||
group_empty = true,
|
},
|
||||||
icons = {
|
renderer = {
|
||||||
show = {
|
group_empty = true,
|
||||||
file = show_icon,
|
icons = {
|
||||||
folder = show_icon,
|
show = {
|
||||||
folder_arrow = show_icon,
|
file = show_icon,
|
||||||
git = show_icon,
|
folder = show_icon,
|
||||||
modified = show_icon,
|
folder_arrow = show_icon,
|
||||||
}
|
git = show_icon,
|
||||||
}
|
modified = show_icon,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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" },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
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" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>e', ':NvimTreeFindFileToggle<CR>', { noremap = true, silent = true })
|
vim.api.nvim_set_keymap('n', '<Leader>e', ':NvimTreeFindFileToggle<CR>', { noremap = true, silent = true })
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim_version_minor >= 5 then
|
if vim_version_minor >= 5 then
|
||||||
vim_illuminate_config()
|
vim_illuminate_config()
|
||||||
transparent_config()
|
transparent_config()
|
||||||
github_theme_config()
|
github_theme_config()
|
||||||
indentline_config()
|
indentline_config()
|
||||||
which_key_config()
|
which_key_config()
|
||||||
animate_config()
|
animate_config()
|
||||||
nvim_scrollbar_config()
|
nvim_scrollbar_config()
|
||||||
|
lualine_config()
|
||||||
end
|
end
|
||||||
if vim_version_minor >= 7 then
|
if vim_version_minor >= 7 then
|
||||||
nvim_treesitter_config()
|
nvim_treesitter_config()
|
||||||
telescope_config()
|
telescope_config()
|
||||||
toggleterm_config()
|
toggleterm_config()
|
||||||
end
|
end
|
||||||
if vim_version_minor >= 8 then
|
if vim_version_minor >= 8 then
|
||||||
nvim_tree_config()
|
nvim_tree_config()
|
||||||
nvim_noice_config()
|
nvim_noice_config()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function late_loading()
|
local function late_loading()
|
||||||
lualine_config()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- late loading
|
-- late loading
|
||||||
vim.api.nvim_create_autocmd({ "VimEnter" },
|
vim.api.nvim_create_autocmd({ "VimEnter" },
|
||||||
{ pattern = { "*" }, callback = late_loading, })
|
{ pattern = { "*" }, callback = late_loading, })
|
||||||
|
|||||||
@@ -0,0 +1,169 @@
|
|||||||
|
|
||||||
|
" This file stores helper functions
|
||||||
|
|
||||||
|
function! Notify(msg)
|
||||||
|
echo msg
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" This function is used to save a variable to a file
|
||||||
|
function! SaveVariable(var, file)
|
||||||
|
let serialized = string(a:var)
|
||||||
|
call writefile([serialized], a:file)
|
||||||
|
endfun
|
||||||
|
|
||||||
|
" This function is used to retrieve a variable from a file
|
||||||
|
" only first line is count
|
||||||
|
function! ReadVariable(file)
|
||||||
|
if !filereadable(a:file)
|
||||||
|
return v:null
|
||||||
|
endif
|
||||||
|
let serialized = readfile(a:file)
|
||||||
|
if(len(serialized) == 0)
|
||||||
|
return v:null
|
||||||
|
endif
|
||||||
|
execute "let result = " . serialized[0]
|
||||||
|
return result
|
||||||
|
endfun
|
||||||
|
|
||||||
|
" Merge two dictionaries, also recursively merging nested keys.
|
||||||
|
" Use extend() if you don't need to merge nested keys.
|
||||||
|
fun! Merge(defaults, override)
|
||||||
|
let l:new = copy(a:defaults)
|
||||||
|
for [l:k, l:v] in items(a:override)
|
||||||
|
let l:new[l:k] = (type(l:v) is v:t_dict && type(get(l:new, l:k)) is v:t_dict)
|
||||||
|
\ ? Merge(l:new[l:k], l:v)
|
||||||
|
\ : l:v
|
||||||
|
endfor
|
||||||
|
return l:new
|
||||||
|
endfun
|
||||||
|
|
||||||
|
function! Sh(pattern)
|
||||||
|
execute("filter /" . a:pattern . "/ highlight")
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" get current colorscheme name
|
||||||
|
function! ColourSchemeName()
|
||||||
|
try
|
||||||
|
return g:colors_name
|
||||||
|
catch /^Vim:E121/
|
||||||
|
return "default"
|
||||||
|
catch /.*/
|
||||||
|
return "default"
|
||||||
|
endtry
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" debug function print out highlight group of cursor position
|
||||||
|
function! ShowHighLightGroup()
|
||||||
|
if !exists("*synstack")
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
|
||||||
|
|
||||||
|
:echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
|
||||||
|
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
|
||||||
|
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"
|
||||||
|
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" get highlight group information and return as dictionary
|
||||||
|
function! GetHighlight(group)
|
||||||
|
let output = execute('hi ' . a:group)
|
||||||
|
let list = split(output, '\s\+')
|
||||||
|
let dict = {}
|
||||||
|
for item in list
|
||||||
|
if match(item, '=') > 0
|
||||||
|
let splited = split(item, '=')
|
||||||
|
let dict[splited[0]] = splited[1]
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return dict
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! InTransparentMode()
|
||||||
|
let dict = GetHighlight('Normal')
|
||||||
|
let isGui = &termguicolors
|
||||||
|
if isGui
|
||||||
|
if !has_key(dict, 'guibg')
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
elseif !isGui
|
||||||
|
if !has_key(dict, 'ctermfg')
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
return 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! HasColorscheme(name)
|
||||||
|
let scheme = a:name
|
||||||
|
let colors = globpath(&runtimepath, printf('colors/%s.vim', scheme), 1, 1)
|
||||||
|
if len(colors) > 0 | return 1 | endif
|
||||||
|
let colors += globpath(&packpath, printf('pack/*/start/*/colors/%s.vim', scheme), 1, 1)
|
||||||
|
if len(colors) > 0 | return 1 | endif
|
||||||
|
let colors += globpath(&packpath, printf('pack/*/opt/*/colors/%s.vim', scheme), 1, 1)
|
||||||
|
if len(colors) > 0 | return 1 | endif
|
||||||
|
if has('nvim')
|
||||||
|
let colors = globpath(&runtimepath, printf('colors/%s.lua', scheme), 1, 1)
|
||||||
|
if len(colors) > 0 | return 1 | endif
|
||||||
|
let colors += globpath(&packpath, printf('pack/*/start/*/colors/%s.lua', scheme), 1, 1)
|
||||||
|
if len(colors) > 0 | return 1 | endif
|
||||||
|
let colors += globpath(&packpath, printf('pack/*/opt/*/colors/%s.lua', scheme), 1, 1)
|
||||||
|
if len(colors) > 0 | return 1 | endif
|
||||||
|
endif
|
||||||
|
return 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" delete signal file if exist
|
||||||
|
function! DeleteSignalFile(name)
|
||||||
|
if filereadable(g:vim_dir . a:name)
|
||||||
|
call delete(g:vim_dir . a:name)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Create signal file if not exist
|
||||||
|
function! CreateSignalFile(name)
|
||||||
|
call system("touch " . g:vim_dir . a:name)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! SignalFileExists(filename)
|
||||||
|
if filereadable(g:vim_dir . a:filename)
|
||||||
|
return v:true
|
||||||
|
endif
|
||||||
|
return v:false
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Debug related
|
||||||
|
if g:debug_mode
|
||||||
|
let g:debug_logs = []
|
||||||
|
|
||||||
|
function! Debugstats()
|
||||||
|
let d = {}
|
||||||
|
let d['filetype'] = &ft
|
||||||
|
let d['buftype'] = &buftype
|
||||||
|
let d['winid'] = win_getid()
|
||||||
|
return d
|
||||||
|
endfunction
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
" Swap values under cursor according to g:swap_dict
|
||||||
|
" {
|
||||||
|
function SwapWord()
|
||||||
|
let word = expand("<cword>")
|
||||||
|
let l1 = g:swap_dict[0]
|
||||||
|
let l2 = g:swap_dict[1]
|
||||||
|
let inx = index(l1, word)
|
||||||
|
if inx != -1
|
||||||
|
let newword = l2[inx]
|
||||||
|
else
|
||||||
|
let inx = index(l2, word)
|
||||||
|
if inx != -1
|
||||||
|
let newword = l1[inx]
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if inx != -1
|
||||||
|
execute "normal ciw" . newword . "\<Esc>"
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }
|
||||||
Reference in New Issue
Block a user