From 05a28c5093e1c6119b3bd9bc803b3892faabc2b9 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Mon, 25 Jan 2021 01:04:26 +0800 Subject: [PATCH] [bugfix] ctrlp not working on windows --- cli/vim/init.vim | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/cli/vim/init.vim b/cli/vim/init.vim index 63a0112..669f43f 100644 --- a/cli/vim/init.vim +++ b/cli/vim/init.vim @@ -230,6 +230,24 @@ nnoremap gmh :diffget //2 nnoremap gml :diffget //3 nnoremap gsc :exec "!git switch -c " . input("Enter new branch name:") +" ==== functions ====== +fu! SilentOK(cmd) + let l:ouput = system(substitute(a:cmd, "%", expand("%"), "g")) + if v:shell_error != 0 + echo ouput + endif +endfu + +fu! SystemOr(cmd, default) + let l:ouput = system(substitute(a:cmd, "%", expand("%"), "g")) + if v:shell_error != 0 + return a:default + endif + return trim(output) +endfu + + + " ==== ctrlp configuration ==== "let g:ctrlp_user_command = ['.git', 'git ls-files -co --exclude-standard'] @@ -238,7 +256,7 @@ nnoremap gsc :exec "!git switch -c " . input("Enter new branch name:") :call fzf#vim#files(trim(system("git rev-parse --show-toplevel \|\| pwd"))) +nnoremap :call fzf#vim#files(SystemOr("git rev-parse --show-toplevel", ".")) nnoremap gco :call fzf#run({'source': 'git branch \| cut -c 3-; git tag -l', 'sink': '!git checkout'}) nnoremap gm :call fzf#run({'source': 'git branch \| cut -c 3-', 'sink': '!git merge'}) nnoremap b :Buffers @@ -274,12 +292,6 @@ fu! NERDCommenter_after() endfu " ==== groff ==== -fu! SilentOK(cmd) - let l:ouput = system(substitute(a:cmd, "%", expand("%"), "g")) - if v:shell_error != 0 - echo ouput - endif -endfu fu! ToggleGroffMomAutoCompilation() let g:GroffMomAutoCompilation = !get(g:, "GroffMomAutoCompilation", 0)