init
This commit is contained in:
+166
@@ -0,0 +1,166 @@
|
|||||||
|
" Set internal encoding of vim, not needed on neovim, since coc.nvim using some
|
||||||
|
" unicode characters in the file autoload/float.vim
|
||||||
|
" set encoding=utf-8
|
||||||
|
|
||||||
|
" TextEdit might fail if hidden is not set.
|
||||||
|
set hidden
|
||||||
|
|
||||||
|
" Some servers have issues with backup files, see #649.
|
||||||
|
set nobackup
|
||||||
|
set nowritebackup
|
||||||
|
|
||||||
|
" Give more space for displaying messages.
|
||||||
|
set cmdheight=2
|
||||||
|
|
||||||
|
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
|
||||||
|
" delays and poor user experience.
|
||||||
|
set updatetime=4000
|
||||||
|
|
||||||
|
" Don't pass messages to |ins-completion-menu|.
|
||||||
|
set shortmess+=c
|
||||||
|
|
||||||
|
" Always show the signcolumn, otherwise it would shift the text each time
|
||||||
|
" diagnostics appear/become resolved.
|
||||||
|
if has("nvim-0.5.0") || has("patch-8.1.1564")
|
||||||
|
" Recently vim can merge signcolumn and number column into one
|
||||||
|
set signcolumn=number
|
||||||
|
else
|
||||||
|
set signcolumn=yes
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Use tab for trigger completion with characters ahead and navigate.
|
||||||
|
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
|
||||||
|
" other plugin before putting this into your config.
|
||||||
|
inoremap <silent><expr> <TAB>
|
||||||
|
\ pumvisible() ? "\<C-n>" :
|
||||||
|
\ <SID>check_back_space() ? "\<TAB>" :
|
||||||
|
\ coc#refresh()
|
||||||
|
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||||||
|
|
||||||
|
function! s:check_back_space() abort
|
||||||
|
let col = col('.') - 1
|
||||||
|
return !col || getline('.')[col - 1] =~# '\s'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Use <c-space> to trigger completion.
|
||||||
|
if has('nvim')
|
||||||
|
inoremap <silent><expr> <c-space> coc#refresh()
|
||||||
|
else
|
||||||
|
inoremap <silent><expr> <c-@> coc#refresh()
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Make <CR> auto-select the first completion item and notify coc.nvim to
|
||||||
|
" format on enter, <cr> could be remapped by other vim plugin
|
||||||
|
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
|
||||||
|
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
||||||
|
|
||||||
|
" Use `[g` and `]g` to navigate diagnostics
|
||||||
|
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
|
||||||
|
nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
||||||
|
nmap <silent> ]g <Plug>(coc-diagnostic-next)
|
||||||
|
|
||||||
|
" GoTo code navigation.
|
||||||
|
nmap <silent> gd <Plug>(coc-definition)
|
||||||
|
nmap <silent> gy <Plug>(coc-type-definition)
|
||||||
|
nmap <silent> gi <Plug>(coc-implementation)
|
||||||
|
nmap <silent> gr <Plug>(coc-references)
|
||||||
|
|
||||||
|
" Use K to show documentation in preview window.
|
||||||
|
nnoremap <silent> K :call <SID>show_documentation()<CR>
|
||||||
|
|
||||||
|
function! s:show_documentation()
|
||||||
|
if CocAction('hasProvider', 'hover')
|
||||||
|
call CocActionAsync('doHover')
|
||||||
|
else
|
||||||
|
call feedkeys('K', 'in')
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Highlight the symbol and its references when holding the cursor.
|
||||||
|
autocmd CursorHold * silent call CocActionAsync('highlight')
|
||||||
|
|
||||||
|
" Symbol renaming.
|
||||||
|
nmap <leader>rn <Plug>(coc-rename)
|
||||||
|
|
||||||
|
" Formatting selected code.
|
||||||
|
xmap <leader>f <Plug>(coc-format-selected)
|
||||||
|
nmap <leader>f <Plug>(coc-format-selected)
|
||||||
|
|
||||||
|
augroup mygroup
|
||||||
|
autocmd!
|
||||||
|
" Setup formatexpr specified filetype(s).
|
||||||
|
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
|
||||||
|
" Update signature help on jump placeholder.
|
||||||
|
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
|
||||||
|
augroup end
|
||||||
|
|
||||||
|
" Applying codeAction to the selected region.
|
||||||
|
" Example: `<leader>aap` for current paragraph
|
||||||
|
xmap <leader>a <Plug>(coc-codeaction-selected)
|
||||||
|
nmap <leader>a <Plug>(coc-codeaction-selected)
|
||||||
|
|
||||||
|
" Remap keys for applying codeAction to the current buffer.
|
||||||
|
nmap <leader>ac <Plug>(coc-codeaction)
|
||||||
|
" Apply AutoFix to problem on the current line.
|
||||||
|
nmap <leader>qf <Plug>(coc-fix-current)
|
||||||
|
|
||||||
|
" Run the Code Lens action on the current line.
|
||||||
|
nmap <leader>cl <Plug>(coc-codelens-action)
|
||||||
|
|
||||||
|
" Map function and class text objects
|
||||||
|
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
|
||||||
|
xmap if <Plug>(coc-funcobj-i)
|
||||||
|
omap if <Plug>(coc-funcobj-i)
|
||||||
|
xmap af <Plug>(coc-funcobj-a)
|
||||||
|
omap af <Plug>(coc-funcobj-a)
|
||||||
|
xmap ic <Plug>(coc-classobj-i)
|
||||||
|
omap ic <Plug>(coc-classobj-i)
|
||||||
|
xmap ac <Plug>(coc-classobj-a)
|
||||||
|
omap ac <Plug>(coc-classobj-a)
|
||||||
|
|
||||||
|
" Remap <C-f> and <C-b> for scroll float windows/popups.
|
||||||
|
if has('nvim-0.4.0') || has('patch-8.2.0750')
|
||||||
|
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
|
||||||
|
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
|
||||||
|
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
|
||||||
|
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
|
||||||
|
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
|
||||||
|
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Use CTRL-S for selections ranges.
|
||||||
|
" Requires 'textDocument/selectionRange' support of language server.
|
||||||
|
nmap <silent> <C-s> <Plug>(coc-range-select)
|
||||||
|
xmap <silent> <C-s> <Plug>(coc-range-select)
|
||||||
|
|
||||||
|
" Add `:Format` command to format current buffer.
|
||||||
|
command! -nargs=0 Format :call CocActionAsync('format')
|
||||||
|
|
||||||
|
" Add `:Fold` command to fold current buffer.
|
||||||
|
command! -nargs=? Fold :call CocAction('fold', <f-args>)
|
||||||
|
|
||||||
|
" Add `:OR` command for organize imports of the current buffer.
|
||||||
|
command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport')
|
||||||
|
|
||||||
|
" Add (Neo)Vim's native statusline support.
|
||||||
|
" NOTE: Please see `:h coc-status` for integrations with external plugins that
|
||||||
|
" provide custom statusline: lightline.vim, vim-airline.
|
||||||
|
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
|
||||||
|
|
||||||
|
" Mappings for CoCList
|
||||||
|
" Show all diagnostics.
|
||||||
|
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
|
||||||
|
" Manage extensions.
|
||||||
|
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
|
||||||
|
" Show commands.
|
||||||
|
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
|
||||||
|
" Find symbol of current document.
|
||||||
|
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
|
||||||
|
" Search workspace symbols.
|
||||||
|
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
|
||||||
|
" Do default action for next item.
|
||||||
|
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
|
||||||
|
" Do default action for previous item.
|
||||||
|
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
|
||||||
|
" Resume latest coc list.
|
||||||
|
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
.DS_Store
|
||||||
|
*.pyc
|
||||||
|
*._*
|
||||||
|
.vim/
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
set-option -sg escape-time 10
|
||||||
|
set-option -g default-terminal "screen-256color"
|
||||||
|
|
||||||
|
set-option -sa terminal-overrides ',xterm-256color:RGB'
|
||||||
|
setw -g mode-keys vi
|
||||||
|
bind-key -T copy-mode-vi 'v' send -X begin-selection
|
||||||
|
bind -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
|
||||||
|
|
||||||
|
# vim-like pane resizing
|
||||||
|
bind -r C-k resize-pane -U
|
||||||
|
bind -r C-j resize-pane -D
|
||||||
|
bind -r C-h resize-pane -L
|
||||||
|
bind -r C-l resize-pane -R
|
||||||
|
|
||||||
|
# vim-like pane switching
|
||||||
|
bind -n C-k select-pane -U
|
||||||
|
bind -n C-j select-pane -D
|
||||||
|
bind -n C-h select-pane -L
|
||||||
|
bind -n C-l select-pane -R
|
||||||
|
|
||||||
|
# and now unbind keys
|
||||||
|
unbind Up
|
||||||
|
unbind Down
|
||||||
|
unbind Left
|
||||||
|
unbind Right
|
||||||
|
|
||||||
|
unbind C-Up
|
||||||
|
unbind C-Down
|
||||||
|
unbind C-Left
|
||||||
|
unbind C-Right
|
||||||
@@ -0,0 +1,492 @@
|
|||||||
|
" Modeline and Notes {
|
||||||
|
" vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} nofoldenable foldmethod=marker spell:
|
||||||
|
"
|
||||||
|
" This is Nachuan's personal vim config fork from
|
||||||
|
" spf13/spf13-vim (http://spf13.com)
|
||||||
|
|
||||||
|
" Environment {
|
||||||
|
|
||||||
|
" The default leader is '\', but many people prefer ',' as it's in a standard
|
||||||
|
let mapleader = ','
|
||||||
|
let maplocalleader = '_'
|
||||||
|
|
||||||
|
" }
|
||||||
|
|
||||||
|
" Use bundles config {
|
||||||
|
if filereadable(expand("~/.vimrc.bundles"))
|
||||||
|
source ~/.vimrc.bundles
|
||||||
|
endif
|
||||||
|
" }
|
||||||
|
|
||||||
|
" General {
|
||||||
|
|
||||||
|
set background=dark " Assume a dark background
|
||||||
|
|
||||||
|
" Allow to trigger background
|
||||||
|
function! ToggleBG()
|
||||||
|
let s:tbg = &background
|
||||||
|
" Inversion
|
||||||
|
if s:tbg == "dark"
|
||||||
|
set background=light
|
||||||
|
else
|
||||||
|
set background=dark
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
noremap <leader>bg :call ToggleBG()<CR>
|
||||||
|
noremap <leader>h :noh<CR> " turn off highlight
|
||||||
|
|
||||||
|
filetype plugin indent on " Automatically detect file types.
|
||||||
|
syntax on " Syntax highlighting
|
||||||
|
syntax enable " Syntax highlighting
|
||||||
|
set mouse=a " Automatically enable mouse usage
|
||||||
|
set mousehide " Hide the mouse cursor while typing
|
||||||
|
scriptencoding utf-8
|
||||||
|
|
||||||
|
|
||||||
|
" Most prefer to automatically switch to the current file directory when
|
||||||
|
" a new buffer is opened; to prevent this behavior, add the following to
|
||||||
|
" your .vimrc.before.local file:
|
||||||
|
" let g:spf13_no_autochdir = 1
|
||||||
|
if !exists('g:spf13_no_autochdir')
|
||||||
|
autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9\]*://" | lcd %:p:h | endif
|
||||||
|
" Always switch to the current file directory
|
||||||
|
endif
|
||||||
|
|
||||||
|
set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
|
||||||
|
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 spell " Spell checking on
|
||||||
|
set hidden " Allow buffer switching without saving
|
||||||
|
set iskeyword-=. " '.' is an end of word designator
|
||||||
|
set iskeyword-=# " '#' is an end of word designator
|
||||||
|
set iskeyword-=- " '-' is an end of word designator
|
||||||
|
"set iskeyword-=_ " '_' is an end of word designator
|
||||||
|
|
||||||
|
" Instead of reverting the cursor to the last position in the buffer, we
|
||||||
|
" set it to the first line when editing a git commit message
|
||||||
|
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
|
||||||
|
|
||||||
|
" http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
|
||||||
|
" Restore cursor to file position in previous editing session
|
||||||
|
" To disable this, add the following to your .vimrc file:
|
||||||
|
" let g:spf13_no_restore_cursor = 1
|
||||||
|
if !exists('g:spf13_no_restore_cursor')
|
||||||
|
function! ResCur()
|
||||||
|
if line("'\"") <= line("$")
|
||||||
|
silent! normal! g`"
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
augroup resCur
|
||||||
|
autocmd!
|
||||||
|
autocmd BufWinEnter * call ResCur()
|
||||||
|
augroup END
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Setting up the directories {
|
||||||
|
set backup " Backups are nice ...
|
||||||
|
if has('persistent_undo')
|
||||||
|
set undofile " So is persistent undo ...
|
||||||
|
set undolevels=1000 " Maximum number of changes that can be undone
|
||||||
|
set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
|
||||||
|
endif
|
||||||
|
" }
|
||||||
|
|
||||||
|
" }
|
||||||
|
|
||||||
|
" Vim UI {
|
||||||
|
|
||||||
|
if filereadable(expand("~/.vim/bundle/vim-colors-solarized/colors/solarized.vim"))
|
||||||
|
let g:solarized_termcolors=256
|
||||||
|
let g:solarized_termtrans=1
|
||||||
|
let g:solarized_contrast="normal"
|
||||||
|
let g:solarized_visibility="normal"
|
||||||
|
call togglebg#map("<F5>")
|
||||||
|
colorscheme solarized
|
||||||
|
endif
|
||||||
|
|
||||||
|
set tabpagemax=15 " Only show 15 tabs
|
||||||
|
set showmode " Display the current mode
|
||||||
|
set cursorline " Highlight current line
|
||||||
|
|
||||||
|
highlight clear SignColumn " SignColumn should match background
|
||||||
|
highlight clear LineNr " Current line number row will have same background color in relative mode
|
||||||
|
"highlight clear CursorLineNr " Remove highlight color from current line number
|
||||||
|
|
||||||
|
if has('cmdline_info')
|
||||||
|
set ruler " Show the ruler
|
||||||
|
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids
|
||||||
|
set showcmd " Show partial commands in status line and
|
||||||
|
endif
|
||||||
|
|
||||||
|
if has('statusline')
|
||||||
|
set laststatus=2
|
||||||
|
" Broken down into easily includeable segments
|
||||||
|
set statusline=%<%f\ " Filename
|
||||||
|
set statusline+=%w%h%m%r " Options
|
||||||
|
set statusline+=\ [%{&ff}/%Y] " Filetype
|
||||||
|
set statusline+=\ [%{getcwd()}] " Current dir
|
||||||
|
set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info
|
||||||
|
endif
|
||||||
|
|
||||||
|
set backspace=indent,eol,start " Backspace for dummies
|
||||||
|
|
||||||
|
set number " Line numbers on
|
||||||
|
set showmatch " Show matching brackets/parenthesis
|
||||||
|
set incsearch " Find as you type search
|
||||||
|
set hlsearch " Highlight search terms
|
||||||
|
set winminheight=0 " Windows can be 0 line high
|
||||||
|
set ignorecase " Case insensitive search
|
||||||
|
set smartcase " Case sensitive when uc present
|
||||||
|
set wildmenu " Show list instead of just completing
|
||||||
|
set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all.
|
||||||
|
set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
|
||||||
|
set scrolljump=1 " Lines to scroll when cursor leaves screen
|
||||||
|
set scrolloff=5 " Minimum lines to keep above and below cursor
|
||||||
|
set sidescrolloff=5 " Minimum lines to keep at the left or right of the cursor
|
||||||
|
|
||||||
|
" }
|
||||||
|
|
||||||
|
" Formatting {
|
||||||
|
|
||||||
|
"set nowrap " Do not wrap long lines
|
||||||
|
set autoindent " Indent at the same level of the previous line
|
||||||
|
set shiftwidth=4 " Use indents of 4 spaces
|
||||||
|
set expandtab " Tabs are spaces, not tabs
|
||||||
|
set tabstop=4 " An indentation every four columns
|
||||||
|
set softtabstop=4 " Let backspace delete indent
|
||||||
|
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
|
||||||
|
set splitright " Puts new vsplit windows to the right of the current
|
||||||
|
set splitbelow " Puts new split windows to the bottom of the current
|
||||||
|
set nolist " let vim not showing '$' or other sign
|
||||||
|
|
||||||
|
set matchpairs+=<:> " Match, to be used with %
|
||||||
|
set comments=sl:/*,mb:*,elx:*/ " auto format comment blocks
|
||||||
|
" Remove trailing whitespaces and ^M chars
|
||||||
|
" To disable the stripping of whitespace, add the following to your
|
||||||
|
" .vimrc.before.local file:
|
||||||
|
" let g:spf13_keep_trailing_whitespace = 1
|
||||||
|
"autocmd FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl,sql autocmd BufWritePre <buffer> if !exists('g:spf13_keep_trailing_whitespace') | call StripTrailingWhitespace() | endif
|
||||||
|
"autocmd FileType go autocmd BufWritePre <buffer> Fmt
|
||||||
|
autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
|
||||||
|
autocmd FileType haskell,puppet,ruby,yml setlocal expandtab shiftwidth=2 softtabstop=2
|
||||||
|
" preceding line best in a plugin but here for now.
|
||||||
|
|
||||||
|
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
|
||||||
|
|
||||||
|
" Workaround vim-commentary for Haskell
|
||||||
|
autocmd FileType haskell setlocal commentstring=--\ %s
|
||||||
|
" Workaround broken colour highlighting in Haskell
|
||||||
|
autocmd FileType haskell,rust setlocal nospell
|
||||||
|
|
||||||
|
" }
|
||||||
|
|
||||||
|
" Key (re)Mappings {
|
||||||
|
|
||||||
|
|
||||||
|
" Wrapped lines goes down/up to next row, rather than next line in file.
|
||||||
|
noremap j gj
|
||||||
|
noremap k gk
|
||||||
|
|
||||||
|
|
||||||
|
" Stupid shift key fixes
|
||||||
|
if !exists('g:spf13_no_keyfixes')
|
||||||
|
if has("user_commands")
|
||||||
|
command! -bang -nargs=* -complete=file E e<bang> <args>
|
||||||
|
command! -bang -nargs=* -complete=file W w<bang> <args>
|
||||||
|
command! -bang -nargs=* -complete=file Wq wq<bang> <args>
|
||||||
|
command! -bang -nargs=* -complete=file WQ wq<bang> <args>
|
||||||
|
command! -bang Wa wa<bang>
|
||||||
|
command! -bang WA wa<bang>
|
||||||
|
command! -bang Q q<bang>
|
||||||
|
command! -bang QA qa<bang>
|
||||||
|
command! -bang Qa qa<bang>
|
||||||
|
endif
|
||||||
|
|
||||||
|
cmap Tabe tabe
|
||||||
|
endif
|
||||||
|
|
||||||
|
" 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
|
||||||
|
set nofoldenable
|
||||||
|
" Code folding options
|
||||||
|
nmap <leader>f0 :set foldlevel=0<CR>
|
||||||
|
nmap <leader>f1 :set foldlevel=1<CR>
|
||||||
|
nmap <leader>f2 :set foldlevel=2<CR>
|
||||||
|
nmap <leader>f3 :set foldlevel=3<CR>
|
||||||
|
nmap <leader>f4 :set foldlevel=4<CR>
|
||||||
|
nmap <leader>f5 :set foldlevel=5<CR>
|
||||||
|
nmap <leader>f6 :set foldlevel=6<CR>
|
||||||
|
nmap <leader>f7 :set foldlevel=7<CR>
|
||||||
|
nmap <leader>f8 :set foldlevel=8<CR>
|
||||||
|
nmap <leader>f9 :set foldlevel=9<CR>
|
||||||
|
|
||||||
|
" Most prefer to toggle search highlighting rather than clear the current
|
||||||
|
" search results. To clear search highlighting rather than toggle it on
|
||||||
|
" and off, add the following to your .vimrc.before.local file:
|
||||||
|
" let g:spf13_clear_search_highlight = 1
|
||||||
|
if exists('g:spf13_clear_search_highlight')
|
||||||
|
nmap <silent> <leader>/ :nohlsearch<CR>
|
||||||
|
else
|
||||||
|
nmap <silent> <leader>/ :set invhlsearch<CR>
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
" Find merge conflict markers
|
||||||
|
map <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
|
||||||
|
|
||||||
|
" Visual shifting (does not exit Visual mode)
|
||||||
|
vnoremap < <gv
|
||||||
|
vnoremap > >gv
|
||||||
|
|
||||||
|
" Allow using the repeat operator with a visual selection (!)
|
||||||
|
" http://stackoverflow.com/a/8064607/127816
|
||||||
|
vnoremap . :normal .<CR>
|
||||||
|
|
||||||
|
" For when you forget to sudo.. Really Write the file.
|
||||||
|
cmap w!! w !sudo tee % >/dev/null
|
||||||
|
|
||||||
|
" Adjust viewports to the same size
|
||||||
|
map <Leader>= <C-w>=
|
||||||
|
|
||||||
|
" Map <Leader>ff to display all lines with keyword under cursor
|
||||||
|
" and ask which one to jump to
|
||||||
|
nmap <Leader>ff [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
|
||||||
|
|
||||||
|
" Easier horizontal scrolling
|
||||||
|
map zl zL
|
||||||
|
map zh zH
|
||||||
|
|
||||||
|
" Easier formatting
|
||||||
|
nnoremap <silent> <leader>q gwip
|
||||||
|
|
||||||
|
" Plugins {
|
||||||
|
|
||||||
|
" Misc {
|
||||||
|
if isdirectory(expand("~/.vim/bundle/nerdtree"))
|
||||||
|
let g:NERDShutUp=1
|
||||||
|
endif
|
||||||
|
if isdirectory(expand("~/.vim/bundle/matchit.zip"))
|
||||||
|
let b:match_ignorecase = 1
|
||||||
|
endif
|
||||||
|
" }
|
||||||
|
|
||||||
|
" AutoCloseTag {
|
||||||
|
" Make it so AutoCloseTag works for xml and xhtml files as well
|
||||||
|
au FileType xhtml,xml ru ftplugin/html/autoclosetag.vim
|
||||||
|
nmap <Leader>ac <Plug>ToggleAutoCloseMappings
|
||||||
|
" }
|
||||||
|
|
||||||
|
" NerdTree {
|
||||||
|
if isdirectory(expand("~/.vim/bundle/nerdtree"))
|
||||||
|
nnoremap <C-e> :NERDTreeToggle<CR>
|
||||||
|
" map <leader>e :NERDTreeFind<CR>
|
||||||
|
nmap <leader>nt :NERDTreeFind<CR>
|
||||||
|
|
||||||
|
let NERDTreeShowBookmarks=1
|
||||||
|
let NERDTreeIgnore=['\.py[cd]$', '\~$', '\.swo$', '\.swp$', '^\.git$', '^\.hg$', '^\.svn$', '\.bzr$']
|
||||||
|
let NERDTreeChDirMode=0
|
||||||
|
let NERDTreeQuitOnOpen=1
|
||||||
|
let NERDTreeMouseMode=2
|
||||||
|
let NERDTreeShowHidden=1
|
||||||
|
let NERDTreeKeepTreeInNewTab=1
|
||||||
|
endif
|
||||||
|
" }
|
||||||
|
" JSON {
|
||||||
|
nmap <leader>jt <Esc>:%!python -m json.tool<CR><Esc>:set filetype=json<CR>
|
||||||
|
let g:vim_json_syntax_conceal = 0
|
||||||
|
" }
|
||||||
|
|
||||||
|
" indent_guides {
|
||||||
|
if isdirectory(expand("~/.vim/bundle/vim-indent-guides/"))
|
||||||
|
let g:indent_guides_start_level = 2
|
||||||
|
let g:indent_guides_guide_size = 1
|
||||||
|
let g:indent_guides_enable_on_vim_startup = 0
|
||||||
|
map <leader>f :IndentGuidesToggle<CR>
|
||||||
|
|
||||||
|
endif
|
||||||
|
" }
|
||||||
|
" vim-airline {
|
||||||
|
" Set configuration options for the statusline plugin vim-airline.
|
||||||
|
" Use the powerline theme and optionally enable powerline symbols.
|
||||||
|
" To use the symbols , , , , , , and .in the statusline
|
||||||
|
" segments add the following to your .vimrc.before.local file:
|
||||||
|
" let g:airline_powerline_fonts=1
|
||||||
|
" If the previous symbols do not render for you then install a
|
||||||
|
" powerline enabled font.
|
||||||
|
|
||||||
|
" See `:echo g:airline_theme_map` for some more choices
|
||||||
|
" Default in terminal vim is 'dark'
|
||||||
|
let g:airline_section_z = ''
|
||||||
|
let g:airline_section_y = ''
|
||||||
|
|
||||||
|
if isdirectory(expand("~/.vim/bundle/vim-airline-themes/"))
|
||||||
|
if !exists('g:airline_theme')
|
||||||
|
let g:airline_theme = 'solarized'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" }
|
||||||
|
|
||||||
|
" }
|
||||||
|
|
||||||
|
" Functions {
|
||||||
|
|
||||||
|
" Initialize directories {
|
||||||
|
function! InitializeDirectories()
|
||||||
|
let parent = $HOME
|
||||||
|
let prefix = 'vim'
|
||||||
|
let dir_list = {
|
||||||
|
\ 'backup': 'backupdir',
|
||||||
|
\ 'views': 'viewdir',
|
||||||
|
\ 'swap': 'directory' }
|
||||||
|
|
||||||
|
if has('persistent_undo')
|
||||||
|
let dir_list['undo'] = 'undodir'
|
||||||
|
endif
|
||||||
|
|
||||||
|
" To specify a different directory in which to place the vimbackup,
|
||||||
|
" vimviews, vimundo, and vimswap files/directories, add the following to
|
||||||
|
" your .vimrc.before.local file:
|
||||||
|
" let g:spf13_consolidated_directory = <full path to desired directory>
|
||||||
|
" eg: let g:spf13_consolidated_directory = $HOME . '/.vim/'
|
||||||
|
let g:spf13_consolidated_directory = $HOME . '/.vim/.'
|
||||||
|
if exists('g:spf13_consolidated_directory')
|
||||||
|
let common_dir = g:spf13_consolidated_directory . prefix
|
||||||
|
else
|
||||||
|
let common_dir = parent . '/.' . prefix
|
||||||
|
endif
|
||||||
|
|
||||||
|
for [dirname, settingname] in items(dir_list)
|
||||||
|
let directory = common_dir . dirname . '/'
|
||||||
|
if exists("*mkdir")
|
||||||
|
if !isdirectory(directory)
|
||||||
|
call mkdir(directory)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if !isdirectory(directory)
|
||||||
|
echo "Warning: Unable to create backup directory: " . directory
|
||||||
|
echo "Try: mkdir -p " . directory
|
||||||
|
else
|
||||||
|
let directory = substitute(directory, " ", "\\\\ ", "g")
|
||||||
|
exec "set " . settingname . "=" . directory
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
call InitializeDirectories()
|
||||||
|
" }
|
||||||
|
|
||||||
|
" Initialize NERDTree as needed {
|
||||||
|
function! NERDTreeInitAsNeeded()
|
||||||
|
redir => bufoutput
|
||||||
|
buffers!
|
||||||
|
redir END
|
||||||
|
let idx = stridx(bufoutput, "NERD_tree")
|
||||||
|
if idx > -1
|
||||||
|
NERDTreeMirror
|
||||||
|
NERDTreeFind
|
||||||
|
wincmd l
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
" }
|
||||||
|
|
||||||
|
" Strip whitespace {
|
||||||
|
function! StripTrailingWhitespace()
|
||||||
|
" Preparation: save last search, and cursor position.
|
||||||
|
let _s=@/
|
||||||
|
let l = line(".")
|
||||||
|
let c = col(".")
|
||||||
|
" do the business:
|
||||||
|
%s/\s\+$//e
|
||||||
|
" clean up: restore previous search history, and cursor position
|
||||||
|
let @/=_s
|
||||||
|
call cursor(l, c)
|
||||||
|
endfunction
|
||||||
|
" }
|
||||||
|
|
||||||
|
" Shell command {
|
||||||
|
function! s:RunShellCommand(cmdline)
|
||||||
|
botright new
|
||||||
|
|
||||||
|
setlocal buftype=nofile
|
||||||
|
setlocal bufhidden=delete
|
||||||
|
setlocal nobuflisted
|
||||||
|
setlocal noswapfile
|
||||||
|
setlocal nowrap
|
||||||
|
setlocal filetype=shell
|
||||||
|
setlocal syntax=shell
|
||||||
|
|
||||||
|
call setline(1, a:cmdline)
|
||||||
|
call setline(2, substitute(a:cmdline, '.', '=', 'g'))
|
||||||
|
execute 'silent $read !' . escape(a:cmdline, '%#')
|
||||||
|
setlocal nomodifiable
|
||||||
|
1
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
command! -complete=file -nargs=+ Shell call s:RunShellCommand(<q-args>)
|
||||||
|
" e.g. Grep current file for <search_term>: Shell grep -Hn <search_term> %
|
||||||
|
" }
|
||||||
|
|
||||||
|
" Fix file type error for typescript
|
||||||
|
autocmd BufNewFile,BufRead *.ts set filetype=typescript
|
||||||
|
|
||||||
|
" leader s change occurence
|
||||||
|
:nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
|
||||||
|
" leader num change tab
|
||||||
|
nnoremap <Leader>1 :b1<CR>
|
||||||
|
nnoremap <Leader>2 :b2<CR>
|
||||||
|
nnoremap <Leader>3 :b3<CR>
|
||||||
|
nnoremap <Leader>4 :b4<CR>
|
||||||
|
nnoremap <Leader>5 :b5<CR>
|
||||||
|
nnoremap <Leader>6 :b6<CR>
|
||||||
|
nnoremap <Leader>7 :b7<CR>
|
||||||
|
nnoremap <Leader>8 :b8<CR>
|
||||||
|
nnoremap <Leader>9 :b9<CR>
|
||||||
|
"let c = 0
|
||||||
|
"while c <= 100
|
||||||
|
" execute 'nnoremap <Leader>'.c ':b'.c.'<CR>'
|
||||||
|
" let c += 1
|
||||||
|
"endwhile
|
||||||
|
|
||||||
|
|
||||||
|
" These are to cancel the default behavior of d, D, c, C
|
||||||
|
" to put the text they delete in the default register.
|
||||||
|
" Note that this means e.g. "ad won't copy the text into
|
||||||
|
" register a anymore. You have to explicitly yank it.
|
||||||
|
"
|
||||||
|
" TIPS: you can type :registers to view value in each registers
|
||||||
|
vnoremap p "0p
|
||||||
|
|
||||||
|
|
||||||
|
" TIPS: :hi can be used to check current highlight options
|
||||||
|
" Coc has wired floating color, this is an attempt to fix it
|
||||||
|
highlight CocFloating ctermbg=green
|
||||||
|
highlight FgCocErrorFloatBgCocFloating cterm=bold ctermfg=124 guifg=DarkRed ctermbg=green
|
||||||
|
|
||||||
|
" c highlight fix
|
||||||
|
highlight cComment ctermfg=12 guifg=#458588
|
||||||
|
|
||||||
|
" copy to system
|
||||||
|
set clipboard=unnamed
|
||||||
|
|
||||||
|
" space-d jump to definition if coc is installed
|
||||||
|
"nnoremap <silent><nowait> <space>d :call CocAction('jumpDefinition', v: false)<CR>
|
||||||
|
"nnoremap <silent><nowait> <space>r :call CocAction('jumpReferences', v: false)<CR>
|
||||||
|
if filereadable(expand("~/.vim-config/.exp-coc-config"))
|
||||||
|
source ~/.vim-config/.exp-coc-config
|
||||||
|
endif
|
||||||
|
|
||||||
|
" fix paste mess up when using tmux
|
||||||
|
if &term =~ "screen"
|
||||||
|
let &t_BE = "\e[?2004h"
|
||||||
|
let &t_BD = "\e[?2004l"
|
||||||
|
exec "set t_PS=\e[200~"
|
||||||
|
exec "set t_PE=\e[201~"
|
||||||
|
endif
|
||||||
|
|
||||||
+136
@@ -0,0 +1,136 @@
|
|||||||
|
" Modeline and Notes {
|
||||||
|
" vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} foldlevel=0 foldmethod=marker spell:
|
||||||
|
"
|
||||||
|
" This file imports the various plugins of spf13.
|
||||||
|
" }
|
||||||
|
|
||||||
|
" Environment {
|
||||||
|
|
||||||
|
" Basics {
|
||||||
|
set nocompatible " Must be first line
|
||||||
|
set background=dark " Assume a dark background
|
||||||
|
" }
|
||||||
|
|
||||||
|
" Setup Bundle Support {
|
||||||
|
" The next three lines ensure that the ~/.vim/bundle/ system works
|
||||||
|
filetype off
|
||||||
|
set rtp+=~/.vim/bundle/vundle
|
||||||
|
call vundle#rc()
|
||||||
|
" }
|
||||||
|
|
||||||
|
" Add an UnBundle command {
|
||||||
|
function! UnBundle(arg, ...)
|
||||||
|
let bundle = vundle#config#init_bundle(a:arg, a:000)
|
||||||
|
call filter(g:vundle#bundles, 'v:val["name_spec"] != "' . a:arg . '"')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
com! -nargs=+ UnBundle
|
||||||
|
\ call UnBundle(<args>)
|
||||||
|
" }
|
||||||
|
|
||||||
|
" }
|
||||||
|
|
||||||
|
" Bundles {
|
||||||
|
|
||||||
|
" Deps {
|
||||||
|
Bundle 'gmarik/vundle'
|
||||||
|
Bundle 'MarcWeber/vim-addon-mw-utils'
|
||||||
|
Bundle 'tomtom/tlib_vim'
|
||||||
|
if executable('ag')
|
||||||
|
Bundle 'mileszs/ack.vim'
|
||||||
|
let g:ackprg = 'ag --nogroup --nocolor --column --smart-case'
|
||||||
|
elseif executable('ack-grep')
|
||||||
|
let g:ackprg="ack-grep -H --nocolor --nogroup --column"
|
||||||
|
Bundle 'mileszs/ack.vim'
|
||||||
|
elseif executable('ack')
|
||||||
|
Bundle 'mileszs/ack.vim'
|
||||||
|
endif
|
||||||
|
" }
|
||||||
|
|
||||||
|
" In your .vimrc.before.local file
|
||||||
|
" list only the plugin groups you will use
|
||||||
|
if !exists('g:spf13_bundle_groups')
|
||||||
|
let g:spf13_bundle_groups=['my_bundle', 'general']
|
||||||
|
endif
|
||||||
|
|
||||||
|
" To override all the included bundles, add the following to your
|
||||||
|
" .vimrc.bundles.local file:
|
||||||
|
" let g:override_spf13_bundles = 1
|
||||||
|
if !exists("g:override_spf13_bundles")
|
||||||
|
|
||||||
|
|
||||||
|
" my bundles {
|
||||||
|
if count(g:spf13_bundle_groups, 'my_bundle')
|
||||||
|
" {
|
||||||
|
"Bundle 'codota/tabnine-vim'
|
||||||
|
Bundle 'neoclide/coc.nvim'
|
||||||
|
Bundle 'rust-lang/rust.vim'
|
||||||
|
" add desired extensions to the following global variable
|
||||||
|
" coc-tsserver: javascript
|
||||||
|
" coc-pyright: python
|
||||||
|
" coc-clangd: c/c++, may need to install clangd seperatly
|
||||||
|
let g:coc_global_extensions = ['coc-pyright', 'coc-rls']
|
||||||
|
" syntax highlighting(and more) for typescript
|
||||||
|
" {
|
||||||
|
Bundle 'leafgarland/typescript-vim'
|
||||||
|
" }
|
||||||
|
" {
|
||||||
|
Bundle 'alvan/vim-closetag'
|
||||||
|
let g:closetag_filenames = '*.html,*.xhtml,*.phtml, *.js'
|
||||||
|
" }
|
||||||
|
endif
|
||||||
|
" }]
|
||||||
|
" General {
|
||||||
|
if count(g:spf13_bundle_groups, 'general')
|
||||||
|
Bundle 'altercation/vim-colors-solarized'
|
||||||
|
"Bundle 'lifepillar/vim-solarized8'
|
||||||
|
"Bundle 'spf13/vim-colors'
|
||||||
|
Bundle 'scrooloose/nerdtree'
|
||||||
|
|
||||||
|
" for markdown{
|
||||||
|
Bundle 'godlygeek/tabular'
|
||||||
|
Bundle 'preservim/vim-markdown'
|
||||||
|
"}
|
||||||
|
" for window resize{
|
||||||
|
Bundle 'simeji/winresizer'
|
||||||
|
let g:winresizer_start_key = '<C-r>'
|
||||||
|
let g:winresizer_vert_resize = 2
|
||||||
|
let g:winresizer_horiz_resize = 2
|
||||||
|
" }
|
||||||
|
|
||||||
|
Bundle 'tpope/vim-surround'
|
||||||
|
Bundle 'rhysd/conflict-marker.vim'
|
||||||
|
" {
|
||||||
|
Bundle 'jiangmiao/auto-pairs'
|
||||||
|
"let g:AutoPairsFlyMode = 1
|
||||||
|
|
||||||
|
" }
|
||||||
|
" {
|
||||||
|
Bundle 'mg979/vim-visual-multi'
|
||||||
|
" }
|
||||||
|
Bundle 'matchit.zip'
|
||||||
|
Bundle 'vim-airline/vim-airline'
|
||||||
|
Bundle 'vim-airline/vim-airline-themes'
|
||||||
|
|
||||||
|
" For nvim-bufferline
|
||||||
|
" {
|
||||||
|
"Bundle 'kyazdani42/nvim-web-devicons'
|
||||||
|
"Bundle 'akinsho/nvim-bufferline.lua'
|
||||||
|
" }
|
||||||
|
Bundle 'bling/vim-bufferline'
|
||||||
|
Bundle 'easymotion/vim-easymotion'
|
||||||
|
Bundle 'nathanaelkane/vim-indent-guides'
|
||||||
|
if !exists('g:spf13_no_views')
|
||||||
|
Bundle 'vim-scripts/restore_view.vim'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
" }
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Custome script {
|
||||||
|
|
||||||
|
if filereadable(expand("~/.vim-config/buffer_arrange.vim"))
|
||||||
|
source ~/.vim-config/buffer_arrange.vim
|
||||||
|
endif
|
||||||
|
|
||||||
|
" }
|
||||||
Reference in New Issue
Block a user