Skip to content

Commit

Permalink
change keymap
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenyangze committed May 5, 2023
1 parent f8596cb commit fc3005c
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 146 deletions.
10 changes: 3 additions & 7 deletions layers/common/base.vim
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,10 @@ set splitright
set splitbelow

" autocmd
autocmd FileType python set tabstop=4 shiftwidth=4 expandtab ai
autocmd FileType php set tabstop=4 shiftwidth=4 expandtab ai
autocmd FileType html set tabstop=4 shiftwidth=4 expandtab ai
autocmd FileType blade set tabstop=4 shiftwidth=4 expandtab ai
autocmd FileType ruby set tabstop=2 shiftwidth=2 softtabstop=2 expandtab ai
autocmd FileType vue set tabstop=2 shiftwidth=2 softtabstop=2 expandtab ai
autocmd FileType javascript set tabstop=2 shiftwidth=2 softtabstop=2 expandtab ai
autocmd FileType python,php,html,blade set tabstop=4 shiftwidth=4 expandtab ai
autocmd FileType ruby,vue,javascript set tabstop=2 shiftwidth=2 softtabstop=2 expandtab ai
autocmd Filetype gitcommit setlocal spell textwidth=80

"autocmd FileType php setlocal noeol binary fileformat=dos
"autocmd BufRead,BufNew *.md,*.mkd,*.markdown set filetype=markdown.mkd
" vimrc文件修改之后自动加载, windows
Expand Down
7 changes: 7 additions & 0 deletions layers/common/edit-code.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Plug 'Exafunction/codeium.vim'

let g:codeium_disable_bindings = 1
imap <script><silent><nowait><expr> <C-g> codeium#Accept()
imap <C-;> <Cmd>call codeium#CycleCompletions(1)<CR>
imap <C-,> <Cmd>call codeium#CycleCompletions(-1)<CR>
imap <C-x> <Cmd>call codeium#Clear()<CR>
36 changes: 17 additions & 19 deletions layers/common/terminal-asyncrun.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ endfunction
"nnoremap <silent> <leader>ac :AsyncRun gcc -Wall -O2 "$(VIM_FILEPATH)" -o shellescape(expand("%:r")) <cr>
"nnoremap <silent> <Leader>ar :AsyncRun -raw -cwd=$(VIM_FILEDIR) shellescape(expand("%:r")) <cr>
"nnoremap <silent> <Leader>am :AsyncRun -cwd=<root> cmake . <cr>
let g:asyncrun_rootmarks = ['.svn', '.git', '.root', '_darcs', 'build.xml']
let g:asyncrun_rootmarks = ['.svn', '.git', '.root', '_darcs', 'build.xml']
"nnoremap <silent> <Leader>ab :AsyncRun -cwd=<root> make <cr>
"nnoremap <silent> <Leader>ap :AsyncRun -cwd=<root> -mode=4 make run <cr>

Expand All @@ -42,7 +42,7 @@ function! AsyncRunTest()
let save_cursor = getcurpos()

let l:line = getline(".")
if match(l:line, "function test") < 0
if match(l:line, "function test") < 0
normal [[
let l:line = getline(".")
endif
Expand All @@ -52,7 +52,7 @@ function! AsyncRunTest()
endfor
let l:funcName = expand("<cword>")
call setpos('.', save_cursor)
if match(l:funcName, "test") >= 0
if match(l:funcName, "test") >= 0
let g:asyncrun_command = 'AsyncRun! -mode=' . g:asyncrun_mode . ' -pos=bottom -rows=10 -cwd=<root> ./vendor/bin/phpunit tests --filter ' . l:funcName . ' ' . shellescape(expand("%:f"))
else
let g:asyncrun_command = 'AsyncRun! -mode=' . g:asyncrun_mode . ' -pos=bottom -rows=10 -cwd=<root> ./vendor/bin/phpunit tests' . ' ' . shellescape(expand("%:f"))
Expand All @@ -62,7 +62,7 @@ function! AsyncRunTest()
let save_cursor = getcurpos()

let l:line = getline(".")
if match(l:line, "func Test") < 0
if match(l:line, "func Test") < 0
normal [[
let l:line = getline(".")
endif
Expand All @@ -72,7 +72,7 @@ function! AsyncRunTest()
endfor
let l:funcName = expand("<cword>")
call setpos('.', save_cursor)
if match(l:funcName, "Test") == 0
if match(l:funcName, "Test") == 0
let g:asyncrun_command = 'AsyncRun! -mode=' . g:asyncrun_mode . ' -pos=bottom -rows=10 -cwd=<root> -raw go test -v ' . shellescape(expand("%:f")) . ' -run="' . l:funcName . '"'
else
let g:asyncrun_command = 'AsyncRun! -mode=' . g:asyncrun_mode . ' -pos=bottom -rows=10 -cwd=<root> -raw go test -v ' . shellescape(expand("%:f")) . ''
Expand All @@ -89,33 +89,31 @@ function! AsyncRunTest()
endfunction

function! AsyncRunRun()
let l:command = ''
if &filetype == 'php'
let g:asyncrun_command = 'AsyncRun! -mode=' . g:asyncrun_mode . ' -pos=bottom -rows=10 -cwd=<root> php ' . shellescape(expand("%:f")) . ''
let l:command = 'php '.shellescape(expand('%'))
elseif &filetype == 'lua'
let g:asyncrun_command = 'AsyncRun! -mode=' . g:asyncrun_mode . ' -pos=bottom -rows=10 -cwd=<root> lua ' . shellescape(expand("%:f")) . ''
let l:command = 'lua '.shellescape(expand('%'))
elseif &filetype == 'c'
let g:asyncrun_command = 'AsyncRun! -mode=' . g:asyncrun_mode . ' -pos=bottom -rows=10 gcc -Wall -O2 "$(VIM_FILEPATH)" -o ' . shellescape(expand("%:r")) . ' ;./' . shellescape(expand("%:r"))
let l:command = 'gcc -Wall -O2 "'.shellescape(expand('%:p')).'" -o "'.shellescape(expand('%:r')).'" && '.'./'.shellescape(expand('%:r'))
elseif &filetype == 'cpp'
let g:asyncrun_command = 'AsyncRun! -mode=' . g:asyncrun_mode . ' -pos=bottom -rows=10 g++ -Wall -O2 "$(VIM_FILEPATH)" -levent -o ' . shellescape(expand("%:r")) . ' ;./' . shellescape(expand("%:r"))
let l:command = 'g++ -Wall -O2 "'.shellescape(expand('%:p')).'" -o "'.shellescape(expand('%:r')).'" -levent && '.'./'.shellescape(expand('%:r'))
elseif &filetype == 'python'
"execute 'CocCommand python.execInTerminal'
"let $PYTHONNUNBUFFERED=1
let g:asyncrun_command = 'AsyncRun! -mode=' . g:asyncrun_mode . ' -pos=bottom -rows=10 -cwd=<root> -raw python %'
"let $PYTHONNUNBUFFERED=1
let l:command = 'python %'
elseif &filetype == 'go'
if len(matchstr(expand('%:t'), '_test.go')) > 0
let g:asyncrun_command = 'AsyncRun! -mode=' . g:asyncrun_mode . ' -pos=bottom -rows=10 -cwd=<root> -raw go test -v ' . shellescape(expand("%:f")) . ''
let l:command = 'go test -v '.shellescape(expand('%'))
else
let g:asyncrun_command = 'AsyncRun! -mode=' . g:asyncrun_mode . ' -pos=bottom -rows=10 -cwd=<root> -raw go run ' . shellescape(expand("%:f")) . ''
let l:command = 'go run '.shellescape(expand('%'))
endif
elseif &filetype == 'sh'
let g:asyncrun_command = 'AsyncRun! -mode=' . g:asyncrun_mode . ' -pos=bottom -rows=10 -cwd=<root> sh ' . shellescape(expand("%:f")) . ''
let l:command = 'sh '.shellescape(expand('%'))
elseif &filetype == 'java'
let g:asyncrun_command = 'AsyncRun! -mode=' . g:asyncrun_mode . ' -pos=bottom -rows=10 -cwd=<root> javac ' . shellescape(expand("%:f")) . ' ; java ' . shellescape(expand("%:t:r"))
let l:command = 'javac '.shellescape(expand('%')) .' && java '.shellescape(expand('%:t:r'))
elseif &filetype == 'rust'
let g:asyncrun_command = "RustRun"
"execute 'AsyncRun! -mode=' . g:asyncrun_mode . ' -pos=bottom -rows=10 -cwd=<root> -raw cargo run'
let l:command = "cargo run"
endif
let g:asyncrun_command = 'AsyncRun! -mode='.g:asyncrun_mode.' -pos=bottom -rows=10 -cwd=<root> '.l:command
call AsyncRunRepeat()
endfunction

Expand Down
1 change: 1 addition & 0 deletions layers/common/tool-ai.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Plug 'zhenyangze/vim-bitoai'
17 changes: 1 addition & 16 deletions layers/common/tool-functions.vim
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
"{{{common function
function! ShowNerdTree()
if (exists(":NERDTreeTabsToggle") == 0)
silent! exec "NERDTreeToggle"
else
silent! exec "NERDTreeTabsToggle"
endif
endfunction

function! ShowTagbarToggle()
if (exists(":Vista") > 0 )
silent! exec "Vista!!"
Expand Down Expand Up @@ -164,11 +156,6 @@ function! BesideFile(type)
endif
endfunction

function! TagsJumpFunction()
let s:current_word = expand("<cword>")
exec "tag " . s:current_word
endfunction

function! FzfTagsFunction()
let s:current_word = GetVisualSelection()
silent! exec "FzfTags " . s:current_word
Expand All @@ -178,9 +165,7 @@ function! FzfFilesFunction()
if len(s:current_word) == 0
let s:current_word = trim(expand('<cfile>'), './')
endif
let g:fzf_files_options = ['-m', '--query', s:current_word]
silent! exec "FzfFiles"
let g:fzf_files_options = ['-m', '--query', '']
silent! exec "Find " . s:current_word
endfunction
function! AckVisualSearch()
let s:current_word = GetVisualSelection()
Expand Down
99 changes: 0 additions & 99 deletions layers/common/tool-fzf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -202,105 +202,6 @@ command! -bang FzfChangeFiles
command! -bang FzfArtisan
\ call fzf#run(fzf#wrap('fzfartisan', {'source': 'php artisan | grep ":" | awk "{print \$1}"', 'sink': 'fzfAg'}, 0))

"command! -bang FzfGtags
"\ call fzf#run(fzf#wrap('FzfGtags', fzf#vim#with_preview({'source': 'cd ' . gen_tags#get_db_dir() . ' && global -x . --path-style="through" | sed "s/\.\///" | awk "{ print \$3\":\"\$2\"\\t:\"\$1\"\\t\"\$3 }" ', 'sink': 'CscopeFind', 'options': ["--delimiter=:", '--with-nth', '3..', '--preview-window', '+{2}-/2']}), 0))

function! CscopeFind(line)
let l:fileName = split(a:line)[0]
let l:fileLineNum = split(l:fileName, ":")[1]
let l:fileName = split(l:fileName, ":")[0]
execute 'e ' . trim(trim(l:fileName), '\')
execute ':' . trim(trim(l:fileLineNum), '\')
endfunction

function! FzfCscope(option, query)
if stridx(a:query, '<cword>') == 0
let l:symbol = trim(expand(a:query))
else
let l:symbol = trim(a:query)
endif
if strlen(l:symbol) == 0
let l:symbol = input("Input the Symbol: ")
call FzfCscope(a:option, l:symbol)
return
endif

if a:option == "tag"
let l:output = execute('silent! cstag ' . l:symbol)
else
let l:output = execute('silent! cs find ' . a:option . ' ' . l:symbol)
endif
let l:cscopeList = split(l:output, "\n")
if len(l:cscopeList) == 0
echomsg "没有找到匹配的结果"
return
endif
let l:newcscopeList = []
let l:nums = -1
let l:tempStr = ''
let l:start = 0
for item in l:cscopeList
let l:nums += 1
if l:nums <= 1
continue
endif

if stridx(item, '(empty cancels)') > -1 || stridx(item, 'Type number and') > -1
continue
endif

let item = trim(item)
let l:itemList = split(item)
let l:type = 0
if match(item, '^\d\{1,\}\s*\d\{1,\}\s*\S*[\s*<<\S*>>]*') > -1
let l:type = 1
let l:start = 1
elseif match(item, '^<<\s*\S*>>') > -1
let l:type = 3
continue
endif

if l:start < 1
echomsg "没有找到匹配的结果"
return
endif

if (l:type == 1)
if (l:tempStr != '')
call add(l:newcscopeList, l:tempStr)
let l:tempStr = ''
endif
if (stridx(l:itemList[2], getcwd()) == 0 && strlen(getcwd()) + 1 < strlen(l:itemList[2]))
let l:file = strpart(l:itemList[2], strlen(getcwd()) + 1)
else
let l:file = l:itemList[2]
endif
let l:tempStr = join([l:file . ':' . l:itemList[1] . ':' ], "\t")
elseif l:type == 3
continue
else
let l:tempStr .= "\t" . trim(item)
endif

if (l:type != 1 && l:tempStr != '')
call add(l:newcscopeList, l:tempStr)
let l:tempStr = ''
endif
endfor
if (l:tempStr != '')
call add(l:newcscopeList, l:tempStr)
let l:tempStr = ''
endif
if (g:fzf_popup_status == 1)
call fzf#run(fzf#wrap('fzfcscope', fzf#vim#with_preview({'source': l:newcscopeList, 'sink': 'CscopeFind', 'options':["--delimiter=:", '--preview-window', '+{2}-/2']}), 0))
else
call fzf#run(fzf#wrap('fzfcscope', {'source': l:newcscopeList, 'sink': 'CscopeFind', 'options':["--delimiter=:", '--preview-window', '+{2}-/2']}, 0))
endif
endfunction

"command! -nargs=1 -bang CscopeFind call CscopeFind(<q-args>)
"command! -nargs=1 -bang CscopeFindGlobal call CscopeFindGlobal(<q-args>)

function! s:fzf_neighbouring_files()
let current_file = expand("%")
let cwd = fnamemodify(current_file, ':p:h')
Expand Down
3 changes: 3 additions & 0 deletions layers/common/tool-ui.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if has("nvim")
Plug 'MunifTanjim/nui.nvim'
endif
2 changes: 1 addition & 1 deletion layers/user/init.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

autocmd TextChangedI,CompleteDone,InsertLeave * silent! exec "call popup_clear()"

let g:coc_global_extensions = ['coc-css', 'coc-snippets', 'coc-pyright', 'coc-html', 'coc-sh', 'coc-java', 'coc-tsserver', 'coc-sumneko-lua', 'coc-json', 'coc-rust-analyzer']
let g:coc_global_extensions = ['coc-css', 'coc-snippets', 'coc-pyright', 'coc-html', 'coc-sh', 'coc-java', 'coc-tsserver', 'coc-sumneko-lua', 'coc-json', 'coc-rust-analyzer', 'coc-spell-checker']

"let g:phpactorPhpBin = "/Applications/MxSrvs/bin/php/bin/php"
let g:phpactorOmniAutoClassImport = v:true
Expand Down
1 change: 0 additions & 1 deletion layers/user/keymap.vim
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ let g:which_key_map[']'] = {
\'q': ['cn', 'Next Quick'],
\'s': ['ALENext', 'Next Ale'],
\'e': [":execute 'move +'. v:count1", 'Next Edit'],
\'t': ['call TagsJumpFunction()', 'Next Tag'],
\'f': ['BesideFile("")', 'Next File in Current Dir'],
\}

Expand Down
5 changes: 2 additions & 3 deletions layers/user/quickmap.vim
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ vmap ,f :<C-u>call FzfFilesFunction()<CR>
vmap ,g :<C-U>execute("Rg " . GetRgSearchTextV2(""))<CR>
vmap ,v :<C-U>execute("CtrlSF \"" . escape(GetCtrlsfSearchText(""), '"') . "\"")<CR>
nmap ,v :<C-U>execute("CtrlSF \"" . escape(GetCtrlsfSearchText(""), '"') . "\"")<CR>
nmap ,/ :<C-u>BitoAi
vmap ,/ :BitoAi
nmap =1 :q 1<CR>
nmap =2 :q 2<CR>
Expand All @@ -66,9 +68,6 @@ nmap ]c <plug>(signify-next-hunk)
nnoremap [s :<c-u>ALEPrevious<cr>
nnoremap ]s :<c-u>ALENext<cr>
nnoremap [t :<c-u>pop<cr>
nnoremap ]t :<c-u>call TagsJumpFunction()<cr>

nnoremap [b :<c-u>bp<cr>
nnoremap ]b :<c-u>bn<cr>
Expand Down

0 comments on commit fc3005c

Please sign in to comment.