From 7f76f05215abd41d38eb9c05bdb25fb9c5fc0586 Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Fri, 14 Oct 2022 15:25:26 -0400 Subject: [PATCH 1/9] . --- .vimrc.bundles | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vimrc.bundles b/.vimrc.bundles index 77359c8..fd2faf3 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -368,7 +368,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 From 93f5a7985dad2dfc4289ff02686a5138a0fe1a3c Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Tue, 25 Oct 2022 22:30:53 -0400 Subject: [PATCH 2/9] add plugins --- .gitignore | 1 + .vimrc.bundles | 22 +++++++--------------- 2 files changed, 8 insertions(+), 15 deletions(-) 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.bundles b/.vimrc.bundles index 70a8fa0..08e7723 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,8 @@ " put text in neibouring tmux pane into auto complete Plug 'wellle/tmux-complete.vim' + Plug 'ludovicchabant/vim-gutentags' + " only work with nvim > 0.5 " For other versions, just loading the plugin may " cause error @@ -132,6 +133,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} @@ -182,20 +188,6 @@ endif 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 From 1e7127f6923211888450bb1407ee344b2c30e26f Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Wed, 26 Oct 2022 00:11:48 -0400 Subject: [PATCH 3/9] add rtp --- .vimrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.vimrc b/.vimrc index 76d035e..2027b0c 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 = '_' From 88251af71efc9e8f6d3b39c4e1f2800f4d335a3f Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Wed, 26 Oct 2022 00:17:23 -0400 Subject: [PATCH 4/9] add python install script --- install.py | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 install.py diff --git a/install.py b/install.py new file mode 100644 index 0000000..e1c5476 --- /dev/null +++ b/install.py @@ -0,0 +1,77 @@ +""" cross platform installation script +""" +import subprocess +import os +import urllib + +from os.path import expanduser, join +from shutil import which + +home = expanduser("~") +app_name = 'dotfile' +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(): + urllib.URLopener().retrieve("https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim", VIM_RTPATH + "\\autoload\\plug.vim") + 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) + os.symlink(join(APP_PATH, '.vimrc'), join(home, '.vimrc')) + os.symlink(join(APP_PATH, '.vimrc.bundles'), join(home, '.vimrc.bundles')) + setup_nvim() + setup_vimplug() + msg("Done!") + +setup_vim() From b5c16da8700bcc48b617fe0459c1c0402a9a9598 Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Wed, 26 Oct 2022 00:51:14 -0400 Subject: [PATCH 5/9] . --- install.py | 16 +++++++++++++--- windows.tips | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/install.py b/install.py index e1c5476..689f810 100644 --- a/install.py +++ b/install.py @@ -2,13 +2,13 @@ """ import subprocess import os -import urllib +import urllib.request from os.path import expanduser, join from shutil import which home = expanduser("~") -app_name = 'dotfile' +app_name = 'dotfiles' APP_PATH = join(home, '.' + app_name) REPO_URL = 'https://github.com/Donaldttt/' + app_name REPO_BRANCH = 'dev' @@ -48,7 +48,11 @@ def sync_repo(repo_path, repo_url, repo_branch, repo_name): execute(cmd, cwd=APP_PATH) def setup_vimplug(): - urllib.URLopener().retrieve("https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim", VIM_RTPATH + "\\autoload\\plug.vim") + + 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(): @@ -68,7 +72,13 @@ def setup_vim(): 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() 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) From 2ff24995207b9ec5829148bb836cb4fa7cb8ee91 Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Thu, 17 Nov 2022 15:45:39 -1000 Subject: [PATCH 6/9] delete useless code --- .vimrc | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/.vimrc b/.vimrc index 2027b0c..91e9912 100644 --- a/.vimrc +++ b/.vimrc @@ -38,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 @@ -170,18 +170,7 @@ set foldmethod=syntax autocmd FileType python set foldmethod=indent - 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 + "set nofoldenable " Find merge conflict markers map fc /\v^[<\|=>]{7}( .*\|$) From a1ea629d3c087152ac5252cbfbc4099b3d89bbc4 Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Fri, 18 Nov 2022 21:59:33 -0500 Subject: [PATCH 7/9] change nvim fold method --- .vimrc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.vimrc b/.vimrc index 91e9912..b028f0b 100644 --- a/.vimrc +++ b/.vimrc @@ -168,8 +168,13 @@ " 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 "set nofoldenable " Find merge conflict markers From 81eb3b357da4d5e26002f6e2bdd93cde9b639b5b Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Fri, 18 Nov 2022 22:07:51 -0500 Subject: [PATCH 8/9] no auto fold at start --- .vimrc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.vimrc b/.vimrc index b028f0b..f83df56 100644 --- a/.vimrc +++ b/.vimrc @@ -175,7 +175,9 @@ set foldmethod=syntax autocmd FileType python set foldmethod=indent endif - "set nofoldenable + + " so when a buffer open it wouldn't be fold by default + set nofoldenable " Find merge conflict markers map fc /\v^[<\|=>]{7}( .*\|$) From ed169612b7b8835ca1acde21569137be0c2e81d7 Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Fri, 18 Nov 2022 22:26:11 -0500 Subject: [PATCH 9/9] prettier fold plugin --- .vimrc.bundles | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.vimrc.bundles b/.vimrc.bundles index 08e7723..da19fe2 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -79,6 +79,7 @@ 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 @@ -185,6 +186,7 @@ endif if isdirectory(expand(plugin_dir . "/vim-rooter")) let g:rooter_patterns = ['.vscode', '.git', '*.sln'] let g:rooter_change_directory_for_non_project_files = 'current' + let g:rooter_silent_chdir = 1 endif " } @@ -373,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