diff --git a/.gitignore b/.gitignore index ef3c6c4..cfb5e0e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .vim/ autoload/ node_modules/ +tags diff --git a/.vimrc b/.vimrc index 76d035e..f83df56 100644 --- a/.vimrc +++ b/.vimrc @@ -12,6 +12,9 @@ let g:vim_version = str2float(g:vim_version) let g:dotfile_path = '~/.dotfiles/' + set runtimepath^=~/.vim runtimepath+=~/.vim/after + let &packpath=&runtimepath + " The default leader is '\', but many people prefer ',' as it's in a standard let mapleader = ',' let maplocalleader = '_' @@ -35,7 +38,7 @@ " Always switch to the current file directory set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter') - set viewoptions=folds,options,cursor,unix,slash " Better Unix / Windows compatibility + " set viewoptions=folds,options,cursor,unix,slash " Better Unix / Windows compatibility set virtualedit=onemore " Allow for cursor beyond last character set history=1000 " Store a ton of history (default is 20) set hidden " Allow buffer switching without saving @@ -165,20 +168,16 @@ " Yank from the cursor to the end of the line, to be consistent with C and D. nnoremap Y y$ - set foldmethod=syntax - autocmd FileType python set foldmethod=indent + if has('nvim') + set foldmethod=expr + set foldexpr=nvim_treesitter#foldexpr() + else + set foldmethod=syntax + autocmd FileType python set foldmethod=indent + endif + + " so when a buffer open it wouldn't be fold by default set nofoldenable - " Code folding options - nmap f0 :set foldlevel=0 - nmap f1 :set foldlevel=1 - nmap f2 :set foldlevel=2 - nmap f3 :set foldlevel=3 - nmap f4 :set foldlevel=4 - nmap f5 :set foldlevel=5 - nmap f6 :set foldlevel=6 - nmap f7 :set foldlevel=7 - nmap f8 :set foldlevel=8 - nmap f9 :set foldlevel=9 " Find merge conflict markers map fc /\v^[<\|=>]{7}( .*\|$) diff --git a/.vimrc.bundles b/.vimrc.bundles index 9a7770c..da8a0f1 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -38,7 +38,6 @@ Plug 'scrooloose/nerdtree' - Plug 'godlygeek/tabular' " for markdown{ Plug 'preservim/vim-markdown' "} @@ -79,6 +78,9 @@ " put text in neibouring tmux pane into auto complete Plug 'wellle/tmux-complete.vim' + Plug 'ludovicchabant/vim-gutentags' + Plug 'lambdalisue/readablefold.vim' + " only work with nvim > 0.5 " For other versions, just loading the plugin may " cause error @@ -132,6 +134,11 @@ if g:vim_type == 'nvim' endif " } + " ludovicchabant/vim-gutentags { + set statusline+=%{gutentags#statusline()} + let g:gutentags_cache_dir=g:vim_dir . '/.vimtags/' + "} + " easymotion/vim-easymotion { " f{char} to move to {char} @@ -179,23 +186,10 @@ endif if isdirectory(expand(plugin_dir . "/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 endif " } - " godlygeek/tabular { - if isdirectory(expand(plugin_dir . "/tabular")) - nmap t= :Tabularize /= - vmap t= :Tabularize /= - - nmap t\| :Tab /\| - vmap t\| :Tab /\| - - nmap t: :Tab /:\zs - vmap t: :Tab /:\zs - endif - - " } - " NerdTree { if isdirectory(expand(plugin_dir . "/nerdtree")) let g:NERDShutUp=1 @@ -381,7 +375,7 @@ endif "if !has('nvim') || g:vim_version < 0.5 if v:true highlight SignColumn ctermbg=none - highlight CursorLineNr 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 @@ -391,7 +385,7 @@ endif highlight CocInfoSign ctermbg=none highlight CocHintSign ctermbg=none if g:theme_color == 'dark' - highlight! link TempColor Pmenu + highlight! link TempColor Visual highlight! link CocFloating TempColor highlight! link CocErrorFloat TempColor highlight! link CocWarningFloat TempColor diff --git a/install.py b/install.py new file mode 100644 index 0000000..689f810 --- /dev/null +++ b/install.py @@ -0,0 +1,87 @@ +""" cross platform installation script +""" +import subprocess +import os +import urllib.request + +from os.path import expanduser, join +from shutil import which + +home = expanduser("~") +app_name = 'dotfiles' +APP_PATH = join(home, '.' + app_name) +REPO_URL = 'https://github.com/Donaldttt/' + app_name +REPO_BRANCH = 'dev' +VIM_RTPATH = join(home, '.vim') + +def exist(app): + return which(app) is not None + +def program_must_exist(app): + if not exist(app): + fatal_error(app, "must be installed to continue") + +def fatal_error(msg): + print('Error:', msg) + exit() + +def msg(msg): + print(msg) + +def execute(cmd, cwd=None): + out = subprocess.check_output( + cmd, + stderr=subprocess.STDOUT, + shell=True, + cwd=None + ) + print(out) + +def sync_repo(repo_path, repo_url, repo_branch, repo_name): + if not os.path.exists(repo_path): + msg('Trying to clone ' + repo_name) + cmd = "git clone -b {} {} {}".format(repo_branch, repo_url, repo_path) + execute(cmd) + else: + msg('Trying to update ' + repo_name) + cmd = "git pull origin {}".format(repo_branch) + execute(cmd, cwd=APP_PATH) + +def setup_vimplug(): + + vimplug_path = VIM_RTPATH + "\\autoload\\plug.vim" + if not os.path.isdir(os.path.dirname(vimplug_path)): + os.makedirs(os.path.dirname(vimplug_path)) + urllib.request.urlretrieve("https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim", vimplug_path) + print("Please execute :PlugInstall in vim") + +def setup_nvim(): + if exist('nvim'): + nvim_dir = home + '\\AppData\\Local\\nvim\\' + nvim_config = nvim_dir + 'init.vim' + if not os.path.isdir(nvim_dir): + os.mkdir(nvim_dir) + msg('Setting up neovim config') + with open(nvim_config, 'w') as f: + f.write('''set runtimepath^=~/.vim runtimepath+=~/.vim/after + let &packpath=&runtimepath + source ~/.vimrc''') + +def setup_vim(): + if not exist('vim') and not exist('nvim'): + fatal_error('Error: vim or nvim has to be installed.') + program_must_exist('git') + sync_repo(APP_PATH, REPO_URL, REPO_BRANCH, app_name) + path = join(home, '.vimrc') + if os.path.exists(path): + os.remove(path) + os.symlink(join(APP_PATH, '.vimrc'), join(home, '.vimrc')) + path = join(home, '.vimrc.bundles') + if os.path.exists(path): + os.remove(path) + os.symlink(join(APP_PATH, '.vimrc.bundles'), join(home, '.vimrc.bundles')) + setup_nvim() + setup_vimplug() + msg("Done!") + +setup_vim() diff --git a/windows.tips b/windows.tips index dedd8bb..159c827 100644 --- a/windows.tips +++ b/windows.tips @@ -1,6 +1,10 @@ # Windows Tips +## Install vim + +Probably need to install bulid tool through scoop(like gcc) + Config powershell as emac style put this line into powershell's config file(which is in $profile)