diff --git a/.tmux.conf b/.tmux.conf index 4f80231..4666e19 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1,22 +1,23 @@ set-option -sg escape-time 10 set-option -g default-terminal "screen-256color" +set-option -g history-limit 6000 set-option -sa terminal-overrides ',xterm-256color:RGB' setw -g mode-keys vi bind-key -T copy-mode-vi 'v' send -X begin-selection -bind -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard' +bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard' # vim-like pane resizing -bind -r C-k resize-pane -U -bind -r C-j resize-pane -D -bind -r C-h resize-pane -L -bind -r C-l resize-pane -R +bind-key -r C-k resize-pane -U +bind-key -r C-j resize-pane -D +bind-key -r C-h resize-pane -L +bind-key -r C-l resize-pane -R # vim-like pane switching -bind -n C-k select-pane -U -bind -n C-j select-pane -D -bind -n C-h select-pane -L -bind -n C-l select-pane -R +bind-key -n C-k select-pane -U +bind-key -n C-j select-pane -D +bind-key -n C-h select-pane -L +bind-key -n C-l select-pane -R # and now unbind keys unbind Up diff --git a/.vimrc b/.vimrc index bbd453d..cc28b17 100644 --- a/.vimrc +++ b/.vimrc @@ -2,6 +2,12 @@ " Environment { " get current neovim version let g:vim_version = -1 + + " dotfile location + let g:mydotfiles_directory = expand('~/.dotfiles/') + let after_directory = g:mydotfiles_directory . 'config/vi-plugs/coc-theme/after/' + + " detect vim type(vim or nvim) if has('nvim') let g:vim_type = 'nvim' let g:vim_version = matchstr(execute('version'), 'NVIM v\zs[^\n]*') @@ -9,10 +15,19 @@ let g:vim_type = 'vim' let g:vim_version = matchstr(execute('version'), 'Vi IMproved \zs[^\n]*') endif + + " detect operating system (Windows/Linux/Darwin) + if has("win64") || has("win32") || has("win16") + let g:os = "Windows" + else + let g:os = substitute(system('uname'), '\n', '', '') + endif + let g:vim_version = str2float(g:vim_version) let g:dotfile_path = '~/.dotfiles/' set runtimepath^=~/.vim runtimepath+=~/.vim/after + execute('set runtimepath^=' . after_directory) let &packpath=&runtimepath " The default leader is '\', but many people prefer ',' as it's in a standard @@ -80,7 +95,7 @@ " " set tabpagemax=15 " Only show 15 tabs " set showmode " Display the current mode - set cursorline " Highlight current line + " set cursorline " Highlight current line " get rid of current line highlight, instead just highlight the number column augroup CLClear @@ -118,15 +133,17 @@ " } - + " Formatting { "set nowrap " Do not wrap long lines set autoindent " Indent at the same level of the previous line - set shiftwidth=4 " Use indents of 4 spaces set expandtab " Tabs are spaces, not tabs + set shiftwidth=4 " Use indents of 4 spaces set tabstop=4 " An indentation every four columns set softtabstop=4 " Let backspace delete indent + autocmd FileType javascript,typescript set tabstop=2 shiftwidth=2 softtabstop=2 + autocmd FileType c,cpp,python,java set tabstop=4 shiftwidth=4 softtabstop=4 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 splitbelow " Puts new split windows to the bottom of the current diff --git a/.vimrc.bundles b/.vimrc.bundles index acb11f9..6cb3fd9 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -18,30 +18,26 @@ " Plugin_Install " { " Plugin environment - let config_dir = '~/.dotfiles/' - let plugin_dir = '~/.vim/plugged/' - let g:vim_dir = '~/.vim/' + let g:mydotfiles_directory = expand('~/.dotfiles/') + let s:plugin_dir = expand('~/.vim/plugged/') + let g:vim_dir = expand('~/.vim/') - call plug#begin(plugin_dir) - - " make sure to install nodejs to use coc.nvim - if executable('node') - Plug 'neoclide/coc.nvim', {'branch': 'release'} - endif - - Plug 'rust-lang/rust.vim' + call plug#begin(s:plugin_dir) + "Plug 'NoahTheDuke/vim-just' + " Plug 'mbbill/undotree' " { - Plug 'alvan/vim-closetag' - let g:closetag_filenames = '*.html,*.xhtml,*.phtml, *.js' + " Plug 'alvan/vim-closetag' + " let g:closetag_filenames = '*.html,*.xhtml,*.phtml, *.js' " } - " for markdown{ - Plug 'preservim/vim-markdown' + " Plug 'preservim/vim-markdown' "} + Plug 'dstein64/vim-startuptime' Plug 'simeji/winresizer' + Plug 'rust-lang/rust.vim' Plug 'tpope/vim-surround' Plug 'rhysd/conflict-marker.vim' @@ -51,6 +47,7 @@ "Plug 'easymotion/vim-easymotion' Plug 'vim-scripts/restore_view.vim' + Plug 'mhinz/vim-startify' if executable('fzf') " fzf#install() makes sure that you have the latest binary, comment out because I don't want it to install binary for me @@ -61,25 +58,32 @@ Plug 'NLKNguyen/papercolor-theme' Plug 'airblade/vim-rooter' - Plug 'mbbill/undotree' - Plug 'tpope/vim-commentary' + + " Comment stuff out + Plug 'tpope/vim-commentary' " put text in neibouring tmux pane into auto complete Plug 'wellle/tmux-complete.vim' - Plug 'NoahTheDuke/vim-just' - Plug 'ludovicchabant/vim-gutentags', { 'for': ['c', 'cpp', 'vim'] } + Plug 'ludovicchabant/vim-gutentags', { 'for': ['c', 'cpp'] } Plug 'lambdalisue/readablefold.vim' " only work with vim if g:vim_type == 'vim' + set encoding=UTF-8 Plug 'scrooloose/nerdtree' + Plug 'tiagofumo/vim-nerdtree-syntax-highlight' " Plug 'tribela/vim-transparent' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' " The bottom buffer display Plug 'Donaldttt/vim-bufferline' - " Plug 'itchyny/lightline.vim' + Plug 'ryanoasis/vim-devicons' + Plug 'Yggdroot/indentLine' + endif + + if executable('node') + Plug 'neoclide/coc.nvim', {'branch': 'release'} endif " only work with nvim > 0.5 @@ -91,7 +95,7 @@ Plug 'lukas-reineke/indent-blankline.nvim' " nvim theme Plug 'EdenEast/nightfox.nvim' - Plug 'projekt0n/github-nvim-theme' + Plug 'projekt0n/github-nvim-theme', { 'tag': 'v0.0.7' } Plug 'nvim-lualine/lualine.nvim' @@ -102,6 +106,7 @@ " comment out this plugin if the machine doesn't have required " font install Plug 'nvim-tree/nvim-web-devicons' + Plug 'ziontee113/color-picker.nvim' endif if g:vim_version >= 0.8 Plug 'nvim-tree/nvim-tree.lua' @@ -114,48 +119,84 @@ call plug#end() " } +function! HasPlug(plug_name, ...) + let plug_dir_name = get(a:, 1, a:plug_name) " optional argument for the name of plug's folder + if has_key(g:plugs, a:plug_name) && isdirectory(s:plugin_dir . "/" . plug_dir_name) + return v:true + endif + return v:false +endfunction + " Plugin_Preferences " { -" -" nvim > 0.5 or above plugin { - -if g:vim_type == 'nvim' - if g:vim_version >= 0.5 - " xiyaowong/nvim-transparent { - - " } - - " lukas-reineke/indent-blankline.nvim { - let g:indent_blankline_use_treesitter = v:true - let g:indent_blankline_show_current_context = v:true - "let g:indent_blankline_show_current_context_start = v:true - " } - + " Yggdroot/indentLine { + if HasPlug('indentLine') + let g:indentLine_fileTypeExclude = ['startify'] endif - - if g:vim_version >= 0.7 - " nvim-treesitter/nvim-treesitter { - " } + + " mhinz/vim-startify { + if HasPlug("vim-startify") + if g:vim_type == 'nvim' + let buffer_str_len = (&columns - 60) / 2 + let buf_str = repeat(' ', buffer_str_len) + let g:startify_custom_header = [ + \ buf_str . ' __ __ ________ ______ __ __ ______ __ __ ', + \ buf_str . '| \ | \| \ / \ | \ | \| \| \ / \', + \ buf_str . '| $$\ | $$| $$$$$$$$| $$$$$$\| $$ | $$ \$$$$$$| $$\ / $$', + \ buf_str . '| $$$\| $$| $$__ | $$ | $$| $$ | $$ | $$ | $$$\ / $$$', + \ buf_str . '| $$$$\ $$| $$ \ | $$ | $$ \$$\ / $$ | $$ | $$$$\ $$$$', + \ buf_str . '| $$\$$ $$| $$$$$ | $$ | $$ \$$\ $$ | $$ | $$\$$ $$ $$', + \ buf_str . '| $$ \$$$$| $$_____ | $$__/ $$ \$$ $$ _| $$_ | $$ \$$$| $$', + \ buf_str . '| $$ \$$$| $$ \ \$$ $$ \$$$ | $$ \| $$ \$ | $$', + \ buf_str . ' \$$ \$$ \$$$$$$$$ \$$$$$$ \$ \$$$$$$ \$$ \$$', + \] + else + let buffer_str_len = (&columns - 30) / 2 + let buf_str = repeat(' ', buffer_str_len) + let g:startify_custom_header = [ + \ buf_str . ' __ __ ______ __ __ ', + \ buf_str . '| \ | \| \| \ / \', + \ buf_str . '| $$ | $$ \$$$$$$| $$\ / $$', + \ buf_str . '| $$ | $$ | $$ | $$$\ / $$$', + \ buf_str . ' \$$\ / $$ | $$ | $$$$\ $$$$', + \ buf_str . ' \$$\ $$ | $$ | $$\$$ $$ $$', + \ buf_str . ' \$$ $$ _| $$_ | $$ \$$$| $$', + \ buf_str . ' \$$$ | $$ \| $$ \$ | $$', + \ buf_str . ' \$ \$$$$$$ \$$ \$$', + \] + endif + + let g:startify_lists = [ + \ { 'header': [' RECENT'], 'type': 'files' }, + \ { 'header': [' SESSIONS'], 'type': 'sessions' }, + \ ] endif -endif -" } + " } + " + " ryanoasis/vim-devicons { + if HasPlug("vim-devicons") + let g:webdevicons_enable_airline_statusline = 0 + endif + " } + " " simeji/winresizer { - if isdirectory(expand(plugin_dir . "/winresizer")) + if HasPlug("winresizer") let g:winresizer_vert_resize = 2 let g:winresizer_horiz_resize = 2 nnoremap r :WinResizerStartResize endif + " } " ludovicchabant/vim-gutentags { - if isdirectory(expand(plugin_dir . "/vim-gutentags")) + if HasPlug("vim-gutentags") if exists("*gutentags#statusline()") set statusline+=%{gutentags#statusline()} endif let g:gutentags_cache_dir=g:vim_dir . '/.vimtags/' let g:gutentags_project_root=['.git', '.hg', '.svn', '.bzr', '_darcs', '_FOSSIL_', '.fslckout', 'src'] endif - "} + " } " easymotion/vim-easymotion { @@ -177,7 +218,7 @@ endif " } " antoinemadec/coc-fzf { - if isdirectory(expand(plugin_dir . "/coc-fzf")) + if HasPlug("coc-fzf") nnoremap :CocFzfList nnoremap o :CocFzfList outline endif @@ -203,7 +244,7 @@ endif " } " airblade/vim-rooter { - if isdirectory(expand(plugin_dir . "/vim-rooter")) + if HasPlug("vim-rooter") let g:rooter_patterns = ['.vscode', '.git', '*.sln', 'src'] let g:rooter_change_directory_for_non_project_files = 'current' let g:rooter_silent_chdir = 1 @@ -211,17 +252,18 @@ endif " } " NerdTree { - if (g:vim_type == 'vim' || g:vim_version < 0.8) && isdirectory(expand(plugin_dir . "/nerdtree")) + if (g:vim_type == 'vim' || g:vim_version < 0.8) && HasPlug('nerdtree') let g:NERDShutUp=1 " work around for nerdtree bug: https://github.com/preservim/nerdtree/issues/1321 - let g:NERDTreeMinimalMenu=1 + let g:NERDTreeMinimalMenu = v:true + let g:NERDTreeMinimalUI = v:true "nnoremap :NERDTreeToggle - " nnoremap e :NERDTreeToggle function! NERDTreeFindToggle() let my_filetype = &filetype - if my_filetype == 'nerdtree' || my_filetype == '' + let specical_fts = ['nerdtree', 'startify'] + if my_filetype == '' || index(specical_fts, my_filetype) >= 0 :NERDTreeToggle else :NERDTreeFind @@ -243,7 +285,7 @@ endif " } " nvim-tree.lua { - if g:vim_type == 'nvim' && isdirectory(expand(plugin_dir . "/nvim-tree.lua")) + if g:vim_type == 'nvim' && HasPlug("nvim-tree.lua") " Hide vim bottom statusline " autocmd FileType NvimTree setlocal noshowmode noruler laststatus=0 noshowcmd @@ -252,47 +294,29 @@ endif endif " } - "if has('nvim') && str2float(g:nvim_version) >= 0.5 && isdirectory(expand(plugin_dir . "/lualine.nvim")) + "if has('nvim') && str2float(g:nvim_version) >= 0.5 && HasPlug("lualine.nvim") " nvim-lualine/lualine.nvim { " } "else " - " itchyny/lightline.vim { - if g:vim_type == 'vim' && isdirectory(expand(plugin_dir . "/lightline.vim")) - set laststatus=2 - let g:lightline = { - \ 'colorscheme': 'wombat', - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], - \ [ 'buffers' ] ] - \ }, - \ 'component_function': { - \ 'buffers': 'bufferline#get_echo_string' - \ }, - \ } - endif - " } - " " vim-airline { - if g:vim_type == 'vim' && isdirectory(expand(plugin_dir . "/vim-airline")) + if g:vim_type == 'vim' && HasPlug("vim-airline") " Set configuration options for the statusline plugin vim-airline. " Use the powerline theme and optionally enable powerline symbols. " This must using my fork version of bufferline " - let g:bufferline_max_length = &columns - 25 + let g:bufferline_max_length = &columns - 22 function! BufferNumber() return len(g:index_to_buffer) endfunction call airline#parts#define_function('bufnum', 'BufferNumber') - let g:airline_section_b = '' - let g:airline_section_x = '' - "let g:airline_section_gutter = '' - let g:airline_section_y = airline#section#create(['bufnum']) + let g:airline_extensions = ['bufferline'] + let g:airline_section_x = airline#section#create(['bufnum']) + let g:airline_section_y = '' let g:airline_section_z = airline#section#create(['filetype']) - let g:airline_section_warning = '' - let g:airline_section_error = '' + let g:airline_skip_empty_sections = 1 "let g:airline_exclude_filetypes = ['nerdtree'] " see source for current list let g:airline#extensions#nerdtree_statusline = 0 "let g:airline#extensions#bufferline#overwrite_variables = 0 @@ -316,7 +340,7 @@ endif \ 'V' : 'V', \ '' : 'V', \ } - if isdirectory(expand(plugin_dir . "/vim-airline-themes/")) + if HasPlug("vim-airline-themes/") "let g:airline_theme = 'solarized' endif endif @@ -331,7 +355,11 @@ endif " - Preview window on the right with 50% width " - CTRL-/ will toggle preview window. - let g:fzf_preview_window = ['right:50%', 'ctrl-/'] + if g:os == 'Windows' + let g:fzf_preview_window = [] + else + let g:fzf_preview_window = ['right:50%', 'ctrl-/'] + end " check if ripgrep is installed @@ -346,19 +374,12 @@ endif " } " neoclide/coc.nvim { - if isdirectory(expand(plugin_dir . "/coc.nvim/")) && executable('node') + if HasPlug("coc.nvim") && executable('node') " add desired extensions to the following global variable - " coc-tsserver: javascript - " coc-pyright: python " coc-clangd: c/c++, may need to install clangd seperatly - let g:coc_global_extensions = ['coc-pyright', 'coc-rls', 'coc-clangd', 'coc-tsserver', 'coc-html', 'coc-cmake', 'coc-json', 'coc-sh', 'coc-java'] - let g:coc_user_config = { - \ 'suggest.noselect': v:true, - \ 'suggest.enablePreselect': v:false } - - if filereadable(expand(config_dir . "/.exp-coc-config")) - exec "source " . config_dir . "/.exp-coc-config" + if filereadable(g:mydotfiles_directory . "/coc-nvim-config.vim") + exec "source " . g:mydotfiles_directory . "/coc-nvim-config.vim" endif " warning that coc work best for vim >= 8.3 let g:coc_disable_startup_warning = 1 @@ -387,7 +408,7 @@ endif endfunc " dark or light - if filereadable(expand(g:vim_dir . '.light_theme.signal')) + if filereadable(g:vim_dir . '.light_theme.signal') let g:dark_or_white_theme = 'light' else let g:dark_or_white_theme = 'dark' @@ -407,10 +428,10 @@ endif " exist and set respect variable let g:transparent_dark_theme = v:false let g:transparent_light_theme = v:false - if filereadable(expand(g:vim_dir . '.transparent_dark_theme.signal')) + if filereadable(g:vim_dir . '.transparent_dark_theme.signal') let g:transparent_dark_theme = v:true endif - if filereadable(expand(g:vim_dir . '.transparent_light_theme.signal')) + if filereadable(g:vim_dir . '.transparent_light_theme.signal') let g:transparent_light_theme = v:true endif @@ -441,26 +462,29 @@ endif " Fix colorscheme not working correctly under transparent background " There is no plugin for this for nvim < 0.5 or vim without lua support function! TransparentBackgroundFix() - "if !has('nvim') || g:vim_version < 0.5 - if v:true - "if v:false + if !has('nvim') || g:vim_version < 0.5 + " if v:true + " if v:true + highlight CursorLineNr ctermbg=none highlight SignColumn ctermbg=none - "highlight CursorLineNr ctermbg=none - highlight CocWarningHighlight ctermbg=none - highlight CocErrorSign ctermbg=none ctermfg=9 cterm=bold - highlight CocErrorHighlight ctermbg=none ctermfg=9 cterm=underline,bold - highlight CocInfoHighlight ctermbg=none - highlight CocHintHighlight ctermbg=none - highlight CocWarningSign ctermbg=none - highlight CocInfoSign ctermbg=none - highlight CocHintSign ctermbg=none - if g:dark_or_white_theme == 'dark' - highlight! link TempColor Visual - highlight! link CocFloating TempColor - highlight! link CocErrorFloat TempColor - highlight! link CocWarningFloat TempColor - highlight! link CocInfoFloat TempColor - highlight! link CocHintFloat TempColor + if v:false + "highlight CursorLineNr ctermbg=none + highlight CocWarningHighlight ctermbg=none + highlight CocErrorSign ctermbg=none ctermfg=9 cterm=bold + highlight CocErrorHighlight ctermbg=none ctermfg=9 cterm=underline,bold + highlight CocInfoHighlight ctermbg=none + highlight CocHintHighlight ctermbg=none + highlight CocWarningSign ctermbg=none + highlight CocInfoSign ctermbg=none + highlight CocHintSign ctermbg=none + if g:dark_or_white_theme == 'dark' + highlight! link TempColor Visual + highlight! link CocFloating TempColor + highlight! link CocErrorFloat TempColor + highlight! link CocWarningFloat TempColor + highlight! link CocInfoFloat TempColor + highlight! link CocHintFloat TempColor + endif endif endif endfunction @@ -489,6 +513,7 @@ endif execute("colorscheme " . g:light_theme) endif endif + call TransparentBackgroundFix() endfunction function! DisableTransparent() @@ -519,8 +544,8 @@ endif " delete signal file if exist function! DeleteSignalFile(name) - if filereadable(expand(g:vim_dir . a:name)) - call delete(expand(g:vim_dir . a:name)) + if filereadable(g:vim_dir . a:name) + call delete(g:vim_dir . a:name) endif endfunction @@ -550,12 +575,11 @@ endif call CreateSignalFile('.transparent_light_theme.signal') endif endif - call TransparentBackgroundFix() endfunction " vim theme - if !has('nvim') && isdirectory(expand(plugin_dir . "/papercolor-theme")) + if !has('nvim') && HasPlug("papercolor-theme") && HasPlug('papercolor-theme') set t_Co=256 " improve coc color in this theme let g:light_theme = 'PaperColor' @@ -566,13 +590,15 @@ endif " nvim only theme if has('nvim') - if g:vim_version >= 0.8 && isdirectory(expand(plugin_dir . "/nightfox.nvim")) + if g:vim_version >= 0.8 && HasPlug("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")) + if g:vim_version >= 0.5 && HasPlug("/github-nvim-theme") let g:dark_theme = 'github_dark' + " let g:dark_theme = 'github_dark_default' + " let g:dark_theme = 'github_dimmed' let g:airline_dark_theme = "hybrid" end endif @@ -588,12 +614,13 @@ endif " Since in .vimrc we cannot call plugin function as they " are not loaded (:help startup) - if g:transparent_dark_theme && g:dark_or_white_theme == 'dark' || g:transparent_light_theme && g:dark_or_white_theme == '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 call EnableTransparent() endif + call TransparentBackgroundFix() else if g:vim_type == 'nvim' && g:vim_version > 0.5 let g:transparent_enabled = v:false @@ -602,7 +629,6 @@ endif endif endif - call TransparentBackgroundFix() " Allow to trigger background function! ToggleBG() " Inversion @@ -622,7 +648,6 @@ endif else call DisableTransparent() endif - call TransparentBackgroundFix() endfunction " } @@ -657,32 +682,43 @@ endif " nnoremap 7 :b7 " nnoremap 8 :b8 " nnoremap 9 :b9 - nnoremap 1 :call bufferline#jump(1) - nnoremap 2 :call bufferline#jump(2) - nnoremap 3 :call bufferline#jump(3) - nnoremap 4 :call bufferline#jump(4) - nnoremap 5 :call bufferline#jump(5) - nnoremap 6 :call bufferline#jump(6) - nnoremap 7 :call bufferline#jump(7) - nnoremap 8 :call bufferline#jump(8) - nnoremap 9 :call bufferline#jump(9) - nnoremap 10 :call bufferline#jump(10) - nnoremap 11 :call bufferline#jump(11) - nnoremap 12 :call bufferline#jump(12) - nnoremap 13 :call bufferline#jump(13) + nnoremap 1 :call bufferline#jump(1) + nnoremap 2 :call bufferline#jump(2) + nnoremap 3 :call bufferline#jump(3) + nnoremap 4 :call bufferline#jump(4) + nnoremap 5 :call bufferline#jump(5) + nnoremap 6 :call bufferline#jump(6) + nnoremap 7 :call bufferline#jump(7) + nnoremap 8 :call bufferline#jump(8) + nnoremap 9 :call bufferline#jump(9) + nnoremap 10 :call bufferline#jump(10) + nnoremap 11 :call bufferline#jump(11) + nnoremap 12 :call bufferline#jump(12) + nnoremap 13 :call bufferline#jump(13) end " split window comform with other window management shortcuts nnoremap % :vsplit nnoremap " :split + + " session related KeyBinding. These KeyBinding uses function from startify + nnoremap s :SSave + nnoremap l :SLoad + nnoremap d :SDelete! + nnoremap c :SClose + " } " " Lua configuration - if g:vim_type == 'nvim' && filereadable(expand(g:dotfile_path . '.vimrc.lua')) - execute('source ' . g:dotfile_path . '/.vimrc.lua') + if g:vim_type == 'nvim' && filereadable(g:mydotfiles_directory . '.vimrc.lua') + execute('source ' . g:mydotfiles_directory . '/.vimrc.lua') endif " " Useful_Info{ " show mapping info " :verbose map ,cf " } + +if filereadable(g:mydotfiles_directory . "/config/theme.vim") + exec "source " . g:mydotfiles_directory . "/config/theme.vim" +endif diff --git a/.vimrc.lua b/.vimrc.lua index e55b5be..12f356a 100644 --- a/.vimrc.lua +++ b/.vimrc.lua @@ -1,41 +1,58 @@ -vim_version = vim.version() -vim_version_minor = vim_version['minor'] +local vim_version = vim.version() +local vim_version_minor = vim_version['minor'] -- debug -- print(vim.inspect(version)) - -if vim_version_minor >= 5 then - - require("transparent").setup({ - enable = true, -- boolean: enable transparent - extra_groups = { -- table/string: additional groups that should be cleared - -- In particular, when you set it to 'all', that means all available groups - - "NvimTreeNormal", - "VertSplit", - }, - exclude = {}, -- table: groups you don't want to clear +-- +local function github_theme_config() + -- Example config in Lua + require("github-theme").setup({ + -- Overwrite the highlight groups + overrides = function(c) + return { + NormalFloat = { link = 'Pmenu' }, + } + end }) - end -if vim_version_minor >= 7 then - - require('nvim-treesitter.configs').setup { - -- ensure_installed = { "c", "bash", "lua" }, - sync_install = false, - auto_install = true, - -- ignore_install = { "javascript" }, - highlight = { - enable = true, - additional_vim_regex_highlighting = false, +local function color_picker_nvim_config() + -- config for ziontee113/color-picker.nvim + require("color-picker").setup({ + ["keymap"] = { -- mapping example: + ["U"] = "ColorPickerSlider5Decrease", + ["O"] = "ColorPickerSlider5Increase", }, + }) + local opts = { noremap = true, silent = true } + + vim.keymap.set("n", "cp", "PickColor", opts) + -- vim.keymap.set("i", "c", "PickColorInsert", opts) +end + +local function indent_blankline_config() + -- Example config in Lua + require("indent_blankline").setup { + show_current_context = true, + filetype_exclude = { "lspinfo", "packer", "checkhealth", "help", "man", "", "startify",} + -- use_treesitter = true, } end -if vim_version_minor >= 5 then +local function transparent_config() + require("transparent").setup({ + enable = true, -- boolean: enable transparent + extra_groups = { -- table/string: additional groups that should be cleared + -- In particular, when you set it to 'all', that means all available groups + "NvimTreeNormal", + "VertSplit", + }, + exclude = {}, -- table: groups you don't want to clear + }) +end +local function lualine_config() for i=1,9 do vim.api.nvim_set_keymap('n', ''..i, ':LualineBuffersJump '..i..'', { noremap = true, silent = true, nowait = true }) -- :nnoremap 1 :LualineBuffersJump 1 @@ -54,7 +71,6 @@ if vim_version_minor >= 5 then 'NvimTree' } end - require('lualine').setup { options = { theme = 'auto', -- lualine theme @@ -68,7 +84,7 @@ if vim_version_minor >= 5 then sections = { lualine_a = {'mode'}, lualine_b = {}, - lualine_c = { + lualine_c = { { 'buffers', mode = 2, @@ -96,13 +112,22 @@ if vim_version_minor >= 5 then lualine_z = {'encoding', 'location'} }, } - end -if vim_version_minor >= 8 then - -- nvim-tree configuration - -- +local function nvim_treesitter_config() + require('nvim-treesitter.configs').setup { + -- ensure_installed = { "c", "bash", "lua" }, + sync_install = false, + auto_install = true, + -- ignore_install = { "javascript" }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + } +end +local function nvim_tree_config() -- disable netrw at the very start of your init.lua (strongly advised) vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 @@ -144,8 +169,20 @@ if vim_version_minor >= 8 then }) vim.api.nvim_set_keymap('n', 'e', ':NvimTreeFindFileToggle', { noremap = true, silent = true }) - - -- - -- nvim-tree configuration end - -- end + +if vim_version_minor >= 5 then + transparent_config() + lualine_config() + github_theme_config() + indent_blankline_config() +end +if vim_version_minor >= 7 then + nvim_treesitter_config() + color_picker_nvim_config() + -- lsp_zero_config() +end +if vim_version_minor >= 8 then + nvim_tree_config() +end + diff --git a/.exp-coc-config b/coc-nvim-config.vim similarity index 52% rename from .exp-coc-config rename to coc-nvim-config.vim index 7424ac4..5609da5 100644 --- a/.exp-coc-config +++ b/coc-nvim-config.vim @@ -1,27 +1,9 @@ -" Set internal encoding of vim, not needed on neovim, since coc.nvim using some -" unicode characters in the file autoload/float.vim -" set encoding=utf-8 -" TextEdit might fail if hidden is not set. -set hidden +" let g:coc_global_extensions = ['coc-pyright', 'coc-rls', 'coc-clangd', 'coc-tsserver', 'coc-html', 'coc-cmake', 'coc-json', 'coc-sh', 'coc-java'] +let g:coc_global_extensions = ['coc-pyright', 'coc-tsserver'] -" Some servers have issues with backup files, see #649. -set nobackup -set nowritebackup - -" Give more space for displaying messages. -"set cmdheight=2 - -" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable -" delays and poor user experience. -set updatetime=2000 - -" Don't pass messages to |ins-completion-menu|. -set shortmess+=c - -" Always show the signcolumn, otherwise it would shift the text each time -" diagnostics appear/become resolved. -"set signcolumn=yes +let g:coc_data_home = g:vim_dir . '/coc' +let g:coc_config_home = g:vim_dir . '/coc' " Use to trigger completion. if has('nvim') @@ -30,16 +12,13 @@ else inoremap coc#refresh() endif +set updatetime=300 + " Make auto-select the first completion item and notify coc.nvim to " format on enter, could be remapped by other vim plugin inoremap pumvisible() ? coc#_select_confirm() \: "\u\\=coc#on_enter()\" -" Use `[g` and `]g` to navigate diagnostics -" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. -nmap [g (coc-diagnostic-prev) -nmap ]g (coc-diagnostic-next) - " GoTo code navigation. nmap gd (coc-definition) nmap gy (coc-type-definition) @@ -57,8 +36,6 @@ function! s:show_documentation() endif endfunction -" Highlight the symbol and its references when holding the cursor. -autocmd CursorHold * silent call CocActionAsync('highlight') " Symbol renaming. nmap rn (coc-rename) @@ -75,30 +52,9 @@ augroup mygroup autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') augroup end -" Applying codeAction to the selected region. -" Example: `aap` for current paragraph -xmap a (coc-codeaction-selected) -nmap a (coc-codeaction-selected) - -" Remap keys for applying codeAction to the current buffer. -nmap ac (coc-codeaction) " Apply AutoFix to problem on the current line. nmap qf (coc-fix-current) -" Run the Code Lens action on the current line. -nmap cl (coc-codelens-action) - -" Map function and class text objects -" NOTE: Requires 'textDocument.documentSymbol' support from the language server. -xmap if (coc-funcobj-i) -omap if (coc-funcobj-i) -xmap af (coc-funcobj-a) -omap af (coc-funcobj-a) -xmap ic (coc-classobj-i) -omap ic (coc-classobj-i) -xmap ac (coc-classobj-a) -omap ac (coc-classobj-a) - " Remap and for scroll float windows/popups. if has('nvim-0.4.0') || has('patch-8.2.0750') nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" @@ -109,25 +65,6 @@ if has('nvim-0.4.0') || has('patch-8.2.0750') vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" endif -" Use CTRL-S for selections ranges. -" Requires 'textDocument/selectionRange' support of language server. -nmap (coc-range-select) -xmap (coc-range-select) - -" Add `:Format` command to format current buffer. -command! -nargs=0 Format :call CocActionAsync('format') - -" Add `:Fold` command to fold current buffer. -command! -nargs=? Fold :call CocAction('fold', ) - -" Add `:OR` command for organize imports of the current buffer. -command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') - -" Add (Neo)Vim's native statusline support. -" NOTE: Please see `:h coc-status` for integrations with external plugins that -" provide custom statusline: lightline.vim, vim-airline. -set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} - " Mappings for CoCList " Show all diagnostics. nnoremap a :CocList diagnostics @@ -145,3 +82,13 @@ nnoremap j :CocNext nnoremap k :CocPrev " Resume latest coc list. nnoremap p :CocListResume + +"COC LSP SETTING +let g:coc_user_config = { +\ 'suggest.noselect': v:true, +\ 'suggest.enablePreselect': v:false, } + +call coc#config("java.jdt.ls.vmargs", '-javaagent:' . g:mydotfiles_directory . '/config/coc/java/lombok-1.18.26.jar') +call coc#config("java.jdt.ls.lombokSupport.enabled", v:false) +call coc#config("java.inlayHints.parameterNames.enabled", v:false) +call coc#config("inlayHint.enable", v:false) diff --git a/config/coc/java/lombok-1.18.26.jar b/config/coc/java/lombok-1.18.26.jar new file mode 100644 index 0000000..d7d7d69 Binary files /dev/null and b/config/coc/java/lombok-1.18.26.jar differ diff --git a/config/coc/setting.json b/config/coc/setting.json deleted file mode 100644 index 49a5b69..0000000 --- a/config/coc/setting.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "suggest.noselect": true, - "suggest.enablePreselect": false -} diff --git a/config/colortrans.py b/config/colortrans.py new file mode 100755 index 0000000..513d503 --- /dev/null +++ b/config/colortrans.py @@ -0,0 +1,376 @@ +#! /usr/bin/env python + +""" Convert values between RGB hex codes and xterm-256 color codes. + +Nice long listing of all 256 colors and their codes. Useful for +developing console color themes, or even script output schemes. + +Resources: +* http://en.wikipedia.org/wiki/8-bit_color +* http://en.wikipedia.org/wiki/ANSI_escape_code +* /usr/share/X11/rgb.txt + +I'm not sure where this script was inspired from. I think I must have +written it from scratch, though it's been several years now. +""" + +__author__ = 'Micah Elliott http://MicahElliott.com' +__version__ = '0.1' +__copyright__ = 'Copyright (C) 2011 Micah Elliott. All rights reserved.' +__license__ = 'WTFPL http://sam.zoy.org/wtfpl/' + +#--------------------------------------------------------------------- + +import sys, re + +CLUT = [ # color look-up table +# 8-bit, RGB hex + + # Primary 3-bit (8 colors). Unique representation! + ('00', '000000'), + ('01', '800000'), + ('02', '008000'), + ('03', '808000'), + ('04', '000080'), + ('05', '800080'), + ('06', '008080'), + ('07', 'c0c0c0'), + + # Equivalent "bright" versions of original 8 colors. + ('08', '808080'), + ('09', 'ff0000'), + ('10', '00ff00'), + ('11', 'ffff00'), + ('12', '0000ff'), + ('13', 'ff00ff'), + ('14', '00ffff'), + ('15', 'ffffff'), + + # Strictly ascending. + ('16', '000000'), + ('17', '00005f'), + ('18', '000087'), + ('19', '0000af'), + ('20', '0000d7'), + ('21', '0000ff'), + ('22', '005f00'), + ('23', '005f5f'), + ('24', '005f87'), + ('25', '005faf'), + ('26', '005fd7'), + ('27', '005fff'), + ('28', '008700'), + ('29', '00875f'), + ('30', '008787'), + ('31', '0087af'), + ('32', '0087d7'), + ('33', '0087ff'), + ('34', '00af00'), + ('35', '00af5f'), + ('36', '00af87'), + ('37', '00afaf'), + ('38', '00afd7'), + ('39', '00afff'), + ('40', '00d700'), + ('41', '00d75f'), + ('42', '00d787'), + ('43', '00d7af'), + ('44', '00d7d7'), + ('45', '00d7ff'), + ('46', '00ff00'), + ('47', '00ff5f'), + ('48', '00ff87'), + ('49', '00ffaf'), + ('50', '00ffd7'), + ('51', '00ffff'), + ('52', '5f0000'), + ('53', '5f005f'), + ('54', '5f0087'), + ('55', '5f00af'), + ('56', '5f00d7'), + ('57', '5f00ff'), + ('58', '5f5f00'), + ('59', '5f5f5f'), + ('60', '5f5f87'), + ('61', '5f5faf'), + ('62', '5f5fd7'), + ('63', '5f5fff'), + ('64', '5f8700'), + ('65', '5f875f'), + ('66', '5f8787'), + ('67', '5f87af'), + ('68', '5f87d7'), + ('69', '5f87ff'), + ('70', '5faf00'), + ('71', '5faf5f'), + ('72', '5faf87'), + ('73', '5fafaf'), + ('74', '5fafd7'), + ('75', '5fafff'), + ('76', '5fd700'), + ('77', '5fd75f'), + ('78', '5fd787'), + ('79', '5fd7af'), + ('80', '5fd7d7'), + ('81', '5fd7ff'), + ('82', '5fff00'), + ('83', '5fff5f'), + ('84', '5fff87'), + ('85', '5fffaf'), + ('86', '5fffd7'), + ('87', '5fffff'), + ('88', '870000'), + ('89', '87005f'), + ('90', '870087'), + ('91', '8700af'), + ('92', '8700d7'), + ('93', '8700ff'), + ('94', '875f00'), + ('95', '875f5f'), + ('96', '875f87'), + ('97', '875faf'), + ('98', '875fd7'), + ('99', '875fff'), + ('100', '878700'), + ('101', '87875f'), + ('102', '878787'), + ('103', '8787af'), + ('104', '8787d7'), + ('105', '8787ff'), + ('106', '87af00'), + ('107', '87af5f'), + ('108', '87af87'), + ('109', '87afaf'), + ('110', '87afd7'), + ('111', '87afff'), + ('112', '87d700'), + ('113', '87d75f'), + ('114', '87d787'), + ('115', '87d7af'), + ('116', '87d7d7'), + ('117', '87d7ff'), + ('118', '87ff00'), + ('119', '87ff5f'), + ('120', '87ff87'), + ('121', '87ffaf'), + ('122', '87ffd7'), + ('123', '87ffff'), + ('124', 'af0000'), + ('125', 'af005f'), + ('126', 'af0087'), + ('127', 'af00af'), + ('128', 'af00d7'), + ('129', 'af00ff'), + ('130', 'af5f00'), + ('131', 'af5f5f'), + ('132', 'af5f87'), + ('133', 'af5faf'), + ('134', 'af5fd7'), + ('135', 'af5fff'), + ('136', 'af8700'), + ('137', 'af875f'), + ('138', 'af8787'), + ('139', 'af87af'), + ('140', 'af87d7'), + ('141', 'af87ff'), + ('142', 'afaf00'), + ('143', 'afaf5f'), + ('144', 'afaf87'), + ('145', 'afafaf'), + ('146', 'afafd7'), + ('147', 'afafff'), + ('148', 'afd700'), + ('149', 'afd75f'), + ('150', 'afd787'), + ('151', 'afd7af'), + ('152', 'afd7d7'), + ('153', 'afd7ff'), + ('154', 'afff00'), + ('155', 'afff5f'), + ('156', 'afff87'), + ('157', 'afffaf'), + ('158', 'afffd7'), + ('159', 'afffff'), + ('160', 'd70000'), + ('161', 'd7005f'), + ('162', 'd70087'), + ('163', 'd700af'), + ('164', 'd700d7'), + ('165', 'd700ff'), + ('166', 'd75f00'), + ('167', 'd75f5f'), + ('168', 'd75f87'), + ('169', 'd75faf'), + ('170', 'd75fd7'), + ('171', 'd75fff'), + ('172', 'd78700'), + ('173', 'd7875f'), + ('174', 'd78787'), + ('175', 'd787af'), + ('176', 'd787d7'), + ('177', 'd787ff'), + ('178', 'd7af00'), + ('179', 'd7af5f'), + ('180', 'd7af87'), + ('181', 'd7afaf'), + ('182', 'd7afd7'), + ('183', 'd7afff'), + ('184', 'd7d700'), + ('185', 'd7d75f'), + ('186', 'd7d787'), + ('187', 'd7d7af'), + ('188', 'd7d7d7'), + ('189', 'd7d7ff'), + ('190', 'd7ff00'), + ('191', 'd7ff5f'), + ('192', 'd7ff87'), + ('193', 'd7ffaf'), + ('194', 'd7ffd7'), + ('195', 'd7ffff'), + ('196', 'ff0000'), + ('197', 'ff005f'), + ('198', 'ff0087'), + ('199', 'ff00af'), + ('200', 'ff00d7'), + ('201', 'ff00ff'), + ('202', 'ff5f00'), + ('203', 'ff5f5f'), + ('204', 'ff5f87'), + ('205', 'ff5faf'), + ('206', 'ff5fd7'), + ('207', 'ff5fff'), + ('208', 'ff8700'), + ('209', 'ff875f'), + ('210', 'ff8787'), + ('211', 'ff87af'), + ('212', 'ff87d7'), + ('213', 'ff87ff'), + ('214', 'ffaf00'), + ('215', 'ffaf5f'), + ('216', 'ffaf87'), + ('217', 'ffafaf'), + ('218', 'ffafd7'), + ('219', 'ffafff'), + ('220', 'ffd700'), + ('221', 'ffd75f'), + ('222', 'ffd787'), + ('223', 'ffd7af'), + ('224', 'ffd7d7'), + ('225', 'ffd7ff'), + ('226', 'ffff00'), + ('227', 'ffff5f'), + ('228', 'ffff87'), + ('229', 'ffffaf'), + ('230', 'ffffd7'), + ('231', 'ffffff'), + + # Gray-scale range. + ('232', '080808'), + ('233', '121212'), + ('234', '1c1c1c'), + ('235', '262626'), + ('236', '303030'), + ('237', '3a3a3a'), + ('238', '444444'), + ('239', '4e4e4e'), + ('240', '585858'), + ('241', '626262'), + ('242', '6c6c6c'), + ('243', '767676'), + ('244', '808080'), + ('245', '8a8a8a'), + ('246', '949494'), + ('247', '9e9e9e'), + ('248', 'a8a8a8'), + ('249', 'b2b2b2'), + ('250', 'bcbcbc'), + ('251', 'c6c6c6'), + ('252', 'd0d0d0'), + ('253', 'dadada'), + ('254', 'e4e4e4'), + ('255', 'eeeeee'), +] + +def _str2hex(hexstr): + return int(hexstr, 16) + +def _strip_hash(rgb): + # Strip leading `#` if exists. + if rgb.startswith('#'): + rgb = rgb.lstrip('#') + return rgb + +def _create_dicts(): + short2rgb_dict = dict(CLUT) + rgb2short_dict = {} + for k, v in short2rgb_dict.items(): + rgb2short_dict[v] = k + return rgb2short_dict, short2rgb_dict + +def short2rgb(short): + return SHORT2RGB_DICT[short] + +def print_all(): + """ Print all 256 xterm color codes. + """ + for short, rgb in CLUT: + sys.stdout.write('\033[48;5;%sm%s:%s' % (short, short, rgb)) + sys.stdout.write("\033[0m ") + sys.stdout.write('\033[38;5;%sm%s:%s' % (short, short, rgb)) + sys.stdout.write("\033[0m\n") + print("Printed all codes.") + print("You can translate a hex or 0-255 code by providing an argument.") + +def rgb2short(rgb): + """ Find the closest xterm-256 approximation to the given RGB value. + @param rgb: Hex code representing an RGB value, eg, 'abcdef' + @returns: String between 0 and 255, compatible with xterm. + >>> rgb2short('123456') + ('23', '005f5f') + >>> rgb2short('ffffff') + ('231', 'ffffff') + >>> rgb2short('0DADD6') # vimeo logo + ('38', '00afd7') + """ + rgb = _strip_hash(rgb) + incs = (0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff) + # Break 6-char RGB code into 3 integer vals. + parts = [ int(h, 16) for h in re.split(r'(..)(..)(..)', rgb)[1:4] ] + res = [] + for part in parts: + i = 0 + while i < len(incs)-1: + s, b = incs[i], incs[i+1] # smaller, bigger + if s <= part <= b: + s1 = abs(s - part) + b1 = abs(b - part) + if s1 < b1: closest = s + else: closest = b + res.append(closest) + break + i += 1 + #print '***', res + res = ''.join([ ('%02.x' % i) for i in res ]) + equiv = RGB2SHORT_DICT[ res ] + #print '***', res, equiv + return equiv, res + +RGB2SHORT_DICT, SHORT2RGB_DICT = _create_dicts() + +#--------------------------------------------------------------------- + +if __name__ == '__main__': + import doctest + doctest.testmod() + if len(sys.argv) == 1: + print_all() + raise SystemExit + arg = sys.argv[1] + if len(arg) < 4 and int(arg) < 256: + rgb = short2rgb(arg) + sys.stdout.write('xterm color \033[38;5;%sm%s\033[0m -> RGB exact \033[38;5;%sm%s\033[0m' % (arg, arg, arg, rgb)) + sys.stdout.write("\033[0m\n") + else: + short, rgb = rgb2short(arg) + sys.stdout.write('RGB %s -> xterm color approx \033[38;5;%sm%s (%s)' % (arg, short, short, rgb)) + sys.stdout.write("\033[0m\n") diff --git a/config/theme.vim b/config/theme.vim new file mode 100644 index 0000000..cba118d --- /dev/null +++ b/config/theme.vim @@ -0,0 +1,66 @@ + +function! GetHi(group, term) + " Store output of group to variable + let output = execute('hi ' . a:group) + " Find the term we're looking for + return matchstr(output, a:term.'=\zs\S*') +endfunction + +function! StrIsNr(input) + if a:input =~# '^\d\+$' + return v:true + endif + return v:false +endfunction + +" Pick an appropriate 256 color base on old color +function! SuitableColor(oldColor) + return a:oldColor - 40 +endfunction + +function! ThemeFix() + let newValue = -1 + let hiGroups = ['CocErrorFloat', 'CocFloating', 'NormalFloat'] + if has('nvim') + for group in hiGroups + if hlexists(group) + let oldColor = GetHi(group, 'ctermbg') + if StrIsNr(oldColor) + let newValue = SuitableColor(str2nr(oldColor)) + " execute('hi ' . group . ' ctermbg=' . newValue) + execute('autocmd! ColorScheme * hi ' . group . ' ctermbg=' . newValue) + endif + endif + endfor + end +endfunction + +function! GetRidOfBg() + let hiGroups = ['CocErrorSign', 'CocWarningSign', 'CocHintSign'] + for group in hiGroups + if hlexists(group) + execute('hi ' . group . ' ctermbg=none') + endif + endfor +endfunction + +function! CocThemeFix() + hi CocErrorHighlight cterm=underline ctermfg=124 ctermbg=none " Keyword at the error position highlight + hi CocErrorSign ctermbg=none ctermfg=124 " Error Sign at the sign column highlight + + hi CocWarningSign ctermbg=none ctermfg=214 " Warning Sign at the sign column highlight + hi CocHintSign ctermbg=none ctermfg=214 " Hint Sign at the sign column highlight + hi CocUnusedHighlight cterm=underline ctermfg=214 ctermbg=none " Unused variable/function etc. highlight + hi CocWarningHighlight cterm=underline ctermfg=214 ctermbg=none " Warning variable/function etc. highlight + + hi CocInfoHighlight ctermfg=207 ctermbg=none " Info variable/function etc. highlight + hi CocInfoSign ctermbg=none ctermfg=207 " Info Sign at the sign column highlight + + hi Todo ctermbg=none ctermfg=214 " Info Sign at the sign column highlight + + hi Error cterm=underline ctermfg=124 ctermbg=none + hi javaError cterm=underline ctermfg=124 ctermbg=none +endfunction + +call CocThemeFix() +au! ColorScheme * call CocThemeFix() diff --git a/install.py b/install.py index 689f810..88911d7 100644 --- a/install.py +++ b/install.py @@ -19,7 +19,7 @@ def exist(app): def program_must_exist(app): if not exist(app): - fatal_error(app, "must be installed to continue") + fatal_error("must be installed to continue") def fatal_error(msg): print('Error:', msg) diff --git a/install.sh b/install.sh index f9f8baa..e8125b4 100755 --- a/install.sh +++ b/install.sh @@ -43,6 +43,9 @@ program_exists() { # return 0 if exists # 1 not contain string # 2 file not exist +# when using this function: +# file path should not be quoted but like this: +# file_contains 'abc' file_path file_contains(){ if [ -f "$2" ]; then a=`grep "$1" $2`