From bd166c76b65006f2945d5072fe07e4777c085eff Mon Sep 17 00:00:00 2001 From: gxlin Date: Tue, 16 Mar 2021 19:47:31 +0800 Subject: More vim config --- .gitconfig | 2 - .tmux.conf | 16 ++++---- .vim/init.vim | 93 ++++++++++++++++++++++++++++++++++++++++++ .vim/plugins/ack.vim | 7 ---- .vim/plugins/ime.vim | 4 ++ .vim/plugins/leaderf.vim | 8 ++-- .vim/plugins/ledger.vim | 14 +++++++ .vim/plugins/markdown.vim | 4 ++ .vim/plugins/misc.vim | 6 +-- .vim/plugins/slime.vim | 15 +++++++ .vim/plugins/vimspector.vim | 68 ++++++++++++++++++++++++++++++ .vim/plugins/vimwiki.vim | 2 + .vim/plugins/youcompleteme.vim | 8 +++- .vimrc | 83 ------------------------------------- install.sh | 2 +- 15 files changed, 221 insertions(+), 111 deletions(-) delete mode 100644 .vim/plugins/ack.vim create mode 100644 .vim/plugins/ime.vim create mode 100644 .vim/plugins/ledger.vim create mode 100644 .vim/plugins/markdown.vim create mode 100644 .vim/plugins/slime.vim create mode 100644 .vim/plugins/vimspector.vim delete mode 100644 .vimrc diff --git a/.gitconfig b/.gitconfig index b99f85e..545ffb1 100644 --- a/.gitconfig +++ b/.gitconfig @@ -1,7 +1,5 @@ [user] email = iigxlin@gmail.com name = gxlin -[http] - proxy = http://127.0.0.1:7890 [init] defaultBranch = main diff --git a/.tmux.conf b/.tmux.conf index b2e3fff..1813106 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1,19 +1,19 @@ # modify the prefix -unbind ^b -set -g prefix 'M-`' +# unbind ^b +# set -g prefix 'M-`' # vim mode setw -g mode-keys vi # copy and paste like vim -bind -T copy-mode-vi 'v' send -X begin-selection -bind -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" +# bind -T copy-mode-vi 'v' send -X begin-selection +# bind -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" # swtich between pane -bind h select-pane -L -bind j select-pane -D -bind k select-pane -U -bind l select-pane -R +# bind h select-pane -L +# bind j select-pane -D +# bind k select-pane -U +# bind l select-pane -R # resize the pane # bind h resize-pane -L 10 diff --git a/.vim/init.vim b/.vim/init.vim index 2a5d6df..bd00085 100644 --- a/.vim/init.vim +++ b/.vim/init.vim @@ -1 +1,94 @@ +" General Config + +set nocompatible +set number +set backspace=indent,eol,start +syntax on +set encoding=utf-8 +set t_Co=256 +set showcmd +set autoread +set mouse=a +filetype indent on +set modeline +set textwidth=72 +set formatoptions+=mB +set formatoptions-=t +set secure + +set hidden + +set completeopt=menu,menuone + +if $COLORTERM is 'truecolor' + set termguicolors +endif + +" MacVim + +if has("gui_running") + if has("gui_macvim") + set guifont=Monaco:h15 + set noimdisable + set transparency=10 + endif +endif + +if has("macunix") +endif + +" Identation + +set autoindent +set tabstop=4 +set shiftwidth=4 +set expandtab +set softtabstop=4 + +autocmd FileType html setlocal shiftwidth=2 softtabstop=2 expandtab +autocmd FileType css setlocal shiftwidth=2 softtabstop=2 expandtab +autocmd FileType javascript setlocal shiftwidth=2 softtabstop=2 expandtab + +set wrap +"set nowrap +"set wrapmargin=4 +set scrolloff=5 +"set sidescrolloff=5 +set laststatus=2 +set ruler + +set hlsearch +set incsearch +set ignorecase +set smartcase + +" Completion + +set wildmenu +set wildmode=longest:list,full +set wildignore=*.o,*.obj,*~ +set wildignore+=*DS_Store* +set wildignore+=*.gem +set wildignore+=*.png,*.jpg,*.gif + +" change default directory +let s:vim_swapfiles_dir = expand('~/.vim/.swp/') +if !isdirectory(s:vim_swapfiles_dir) + silent! call mkdir(s:vim_swapfiles_dir, 'p') +endif +set directory=~/.vim/.swp// + +" tags +set tags=./.tags;,.tags + +" mapping +let mapleader=',' " change the key +nnoremap n :bn +nnoremap p :bp + source ~/.dotfiles/.vim/plugins/init.vim + +silent colorscheme onehalfdark + +highlight Pmenu ctermbg=grey +set exrc diff --git a/.vim/plugins/ack.vim b/.vim/plugins/ack.vim deleted file mode 100644 index dd96e47..0000000 --- a/.vim/plugins/ack.vim +++ /dev/null @@ -1,7 +0,0 @@ -Plug 'mileszs/ack.vim' - -if executable('ag') - let g:ackprg = 'ag --vimgrep' -endif -cnoreabbrev Ack Ack! -nnoremap a :Ack! diff --git a/.vim/plugins/ime.vim b/.vim/plugins/ime.vim new file mode 100644 index 0000000..de7dcf2 --- /dev/null +++ b/.vim/plugins/ime.vim @@ -0,0 +1,4 @@ +Plug 'pi314/ime.vim' +Plug 'pi314/ime-phonetic.vim' + +let g:ime_plugins = ['pinyin'] diff --git a/.vim/plugins/leaderf.vim b/.vim/plugins/leaderf.vim index 4d6d0ac..584322a 100644 --- a/.vim/plugins/leaderf.vim +++ b/.vim/plugins/leaderf.vim @@ -1,10 +1,8 @@ -Plug 'Yggdroot/LeaderF', {'do': './install.sh'} +Plug 'Yggdroot/LeaderF', {'do': ':LeaderfInstallCExtension'} " " Show icons, icons are shown by default let g:Lf_ShowDevIcons = 1 -" For GUI vim, the icon font can be specify like this, for example -let g:Lf_DevIconsFont = "DejaVuSansMono Nerd Font Mono" let g:Lf_WindowPosition = 'popup' let g:Lf_ShortcutF = "ff" @@ -12,11 +10,13 @@ noremap fb :=printf("Leaderf buffer %s", "") noremap fm :=printf("Leaderf mru %s", "") noremap ft :=printf("Leaderf bufTag %s", "") noremap fl :=printf("Leaderf line %s", "") +noremap fr :=printf("Leaderf rg %s", "") noremap :=printf("Leaderf! rg --current-buffer -e %s ", expand("")) noremap :=printf("Leaderf! rg -e %s ", expand("")) " search visually selected text literally xnoremap gf :=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual()) noremap go :Leaderf! rg --recall -let g:Lf_RootMarkers = ['.project', '.root', '.svn', '.git'] + let g:Lf_WorkingDirectoryMode = 'AF' +let g:Lf_RootMarkers = ['.project', '.root', '.svn', '.git', '.hg'] diff --git a/.vim/plugins/ledger.vim b/.vim/plugins/ledger.vim new file mode 100644 index 0000000..b3a1e25 --- /dev/null +++ b/.vim/plugins/ledger.vim @@ -0,0 +1,14 @@ +Plug 'ledger/vim-ledger', {'for': 'ledger'} + +let g:ledger_bin = 'ledger' +let g:ledger_align_at = 50 +let g:ledger_commodity_before = 0 + +au FileType ledger call s:ledger_keymap() + +function! s:ledger_keymap() abort + noremap { ?^\d + noremap } /^\d + inoremap =ledger#autocomplete_and_align() + vnoremap :LedgerAlign +endfunction diff --git a/.vim/plugins/markdown.vim b/.vim/plugins/markdown.vim new file mode 100644 index 0000000..1e12dad --- /dev/null +++ b/.vim/plugins/markdown.vim @@ -0,0 +1,4 @@ +Plug 'iamcco/markdown-preview.nvim', { + \ 'do': {-> mkdp#util#install()}, + \ 'for': ['markdown', 'vim-plug'] + \ } diff --git a/.vim/plugins/misc.vim b/.vim/plugins/misc.vim index a07c23c..5067f5a 100644 --- a/.vim/plugins/misc.vim +++ b/.vim/plugins/misc.vim @@ -9,11 +9,7 @@ let g:asyncrun_bell = 1 " the bell rings when the task is done " use f10 to open/close asyncrun quickfix window nnoremap :call asyncrun#quickfix_toggle(6) -Plug 'puremourning/vimspector' - -let g:vimspector_enable_mappings = 'HUMAN' - Plug 'mhinz/vim-signify' Plug 'tpope/vim-unimpaired' Plug 'godlygeek/tabular' -Plug 'ledger/vim-ledger', {'for': 'ledger'} +Plug 'sonph/onehalf', { 'rtp': 'vim' } diff --git a/.vim/plugins/slime.vim b/.vim/plugins/slime.vim new file mode 100644 index 0000000..0989a66 --- /dev/null +++ b/.vim/plugins/slime.vim @@ -0,0 +1,15 @@ +Plug 'jpalardy/vim-slime', { + \'on': [ + \'SlimeRegionSend', + \'SlimeParagraphSend', + \'SlimeConfig' + \] + \} + +let g:slime_no_mappings = 1 + +xmap SlimeRegionSend +nmap SlimeParagraphSend +nmap v SlimeConfig + +let g:slime_target = 'tmux' diff --git a/.vim/plugins/vimspector.vim b/.vim/plugins/vimspector.vim new file mode 100644 index 0000000..a39d4bd --- /dev/null +++ b/.vim/plugins/vimspector.vim @@ -0,0 +1,68 @@ +Plug 'puremourning/vimspector', { 'on': 'VimspectorContinue' } + +let g:vimspector_install_gadgets = ['debugpy'] + +nmap dc VimspectorContinue +nmap dq VimspectorStop +nmap db VimspectorToggleBreakpoint +nmap dn VimspectorStepOver +nmap ds VimspectorStepInto +nmap df VimspectorStepOut +nmap di VimspectorBalloonEval +xmap di VimspectorBalloonEval + +let s:mapped = {} + +function! s:set_debug_keymaps() abort + if has_key(s:mapped, string(bufnr())) + return + endif + + " nmap c VimspectorContinue + " nmap q VimspectorStop + " nmap b VimspectorToggleBreakpoint + nmap m VimspectorStepOver + " nmap s VimspectorStepInto + " nmap f VimspectorStepOut + " nmap i VimspectorBalloonEval + " xmap i VimspectorBalloonEval + + let s:mapped[string(bufnr())] = {'modifiable': &modifiable} + + setlocal nomodifiable +endfunction + +function! s:unset_debug_keymaps() abort + let original_buf = bufnr() + let hidden = &hidden + + try + set hidden + for bufnr in keys(s:mapped) + try + execute 'noautocmd buffer' bufnr + " silent! nunmap c + " silent! nunmap q + " silent! nunmap b + silent! nunmap m + " silent! nunmap s + " silent! nunmap f + " silent! nunmap i + " silent! xunmap i + + let &l:modifiable = s:mapped[bufnr]['modifiable'] + endtry + endfor + finally + execute 'noautocmd buffer' original_buf + let &hidden = hidden + endtry + + let s:mapped = {} +endfunction + +augroup CustomMappings + au! + autocmd User VimspectorJumpedToFrame call s:set_debug_keymaps() + autocmd User VimspectorDebugEnded call s:unset_debug_keymaps() +augroup end diff --git a/.vim/plugins/vimwiki.vim b/.vim/plugins/vimwiki.vim index 226e135..f2930e4 100644 --- a/.vim/plugins/vimwiki.vim +++ b/.vim/plugins/vimwiki.vim @@ -2,3 +2,5 @@ Plug 'vimwiki/vimwiki' let g:vimwiki_list = [{'path': '~/Documents/notes', \ 'syntax': 'markdown', 'ext': '.md'}] + +au FileType vimwiki setlocal textwidth=72 diff --git a/.vim/plugins/youcompleteme.vim b/.vim/plugins/youcompleteme.vim index 449e8ff..e289214 100644 --- a/.vim/plugins/youcompleteme.vim +++ b/.vim/plugins/youcompleteme.vim @@ -1,4 +1,7 @@ -Plug 'Valloric/YouCompleteMe', {'do': 'python3 ./install.py --clangd-completer'} +Plug 'Valloric/YouCompleteMe', { + \ 'do': 'python3 ./install.py --clangd-completer', + \ 'for': ['python', 'cpp'] + \ } let g:ycm_server_log_level = 'info' let g:ycm_add_preview_to_completeopt = 0 @@ -10,3 +13,6 @@ let g:ycm_filetype_whilelist = { \ "c": 1, "cpp": 1, "sh": 1, "zsh": 1, \ "python": 1, \ } +let g:ycm_filetype_blacklist = { + \ 'ledger': 1 + \ } diff --git a/.vimrc b/.vimrc deleted file mode 100644 index 092ea6b..0000000 --- a/.vimrc +++ /dev/null @@ -1,83 +0,0 @@ -" General Config - -set nocompatible -set number -set backspace=indent,eol,start -syntax on -set encoding=utf-8 -set t_Co=256 -set showcmd -set autoread -set mouse=a -filetype indent on - -set hidden - -set completeopt=menu,menuone - -" MacVim - -if has("gui_running") - if has("gui_macvim") - set guifont=Monaco:h16 - set transparency=10 - endif -endif - -if has("macunix") -endif - -" Identation - -set autoindent -set tabstop=4 -set shiftwidth=4 -set expandtab -set softtabstop=4 - -autocmd FileType html setlocal shiftwidth=2 softtabstop=2 expandtab -autocmd FileType css setlocal shiftwidth=2 softtabstop=2 expandtab -autocmd FileType javascript setlocal shiftwidth=2 softtabstop=2 expandtab - -set wrap -"set nowrap -"set wrapmargin=4 -set scrolloff=5 -"set sidescrolloff=5 -set laststatus=2 -set ruler - -set hlsearch -set incsearch -set ignorecase -set smartcase - -" Completion - -set wildmenu -set wildmode=longest:list,full -set wildignore=*.o,*.obj,*~ -set wildignore+=*DS_Store* -set wildignore+=*.gem -set wildignore+=*.png,*.jpg,*.gif - -" change default directory -let s:vim_swapfiles_dir = expand('~/.vim/.swp/') -if !isdirectory(s:vim_swapfiles_dir) - silent! call mkdir(s:vim_swapfiles_dir, 'p') -endif -set directory=~/.vim/.swp// - -" tags -set tags=./.tags;,.tags - -" mapping -let mapleader=',' " change the key -nnoremap n :bn -nnoremap p :bp -nnoremap d :bd - -if filereadable(expand('~/.dotfiles/.vim/init.vim')) - exec "source " . '~/.dotfiles/.vim/init.vim' -endif - diff --git a/install.sh b/install.sh index 7dd7ea4..e4a5761 100644 --- a/install.sh +++ b/install.sh @@ -24,13 +24,13 @@ get_dotfiles() { cd "$HOME" rm -rf .vimrc .tmux.conf .bashrc .zshrc .i3/config .emacs.d/init.el .gitconfig - ln -s ~/.dotfiles/.vimrc .vimrc ln -s ~/.dotfiles/.tmux.conf .tmux.conf ln -s ~/.dotfiles/.bashrc .bashrc ln -s ~/.dotfiles/.zshrc .zshrc ln -s ~/.dotfiles/.emacs.d/init.el .emacs.d/init.el ln -s ~/.dotfiles/.i3/config .i3/config ln -s ~/.dotfiles/.gitconfig .gitconfig + echo "source ~/.dotfiles/.vim/init.vim" > ~/.vimrc ) } -- cgit v1.2.3