Skip to content

Instantly share code, notes, and snippets.

@anatooly
Created February 10, 2021 16:32
Show Gist options
  • Save anatooly/531c1901448258e339a4c1e93f59c8d1 to your computer and use it in GitHub Desktop.
Save anatooly/531c1901448258e339a4c1e93f59c8d1 to your computer and use it in GitHub Desktop.
2021 vimrc
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
set expandtab
set number
set nowrap
set showbreak=+++
set textwidth=100
set showmatch
set visualbell
set hlsearch
set smartcase
set ignorecase
set incsearch
set tabstop=4
set shiftwidth=4
set smarttab
set expandtab
set smartindent
set ruler
set paste
set undolevels=1000
set backspace=indent,eol,start
set clipboard=unnamed
set bomb
set encoding=utf-8
set fileencoding=utf-8
" <leader>r is \r
"map <leader>r :NERDTreeFind<cr>
" autocmd BufEnter * if &modifiable | NERDTreeFind | wincmd p | endif
"map <leader>n :NERDTreeToggle<CR>
" Map ctrl-movement keys to window switching
"map <C-k> <C-w><Up>
"map <C-j> <C-w><Down>
"map <C-l> <C-w><Right>
"map <C-h> <C-w><Left>
" Switch to alternate file
"map <C-Tab> :bnext<cr>
"map <C-S-Tab> :bprevious<cr>
" Clear prev search
map <Space> :noh<cr>
" http://vim.wikia.com/wiki/Auto_save_files_when_focus_is_lost
au FocusLost * :wa
" Enable mouse cursor position (Some problem on git into vim)
" set mouse=a
" set mousemodel=extend
" Moving lines
"nnoremap <A-j> :m .+1<CR>==
"nnoremap <A-k> :m .-2<CR>==
"inoremap <A-j> <Esc>:m .+1<CR>==gi
"inoremap <A-k> <Esc>:m .-2<CR>==gi
"vnoremap <A-j> :m '>+1<CR>gv=gv
"vnoremap <A-k> :m '<-2<CR>gv=gv
" Remove all spaces of end line
"autocmd BufWritePre * :%s/\s\+$//e
try
call plug#begin()
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" Plug 'dracula/vim'
Plug 'skywind3000/vim-quickui'
call plug#end()
catch
endtry
syntax on
"color dracula
" Mapping selecting mappings
"nmap <leader><tab> <plug>(fzf-maps-n)
"xmap <leader><tab> <plug>(fzf-maps-x)
"omap <leader><tab> <plug>(fzf-maps-o)
" Insert mode completion
"imap <c-x><c-k> <plug>(fzf-complete-word)
"imap <c-x><c-f> <plug>(fzf-complete-path)
"imap <c-x><c-j> <plug>(fzf-complete-file-ag)
"imap <c-x><c-l> <plug>(fzf-complete-line)
" Advanced customization using autoload functions
"inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'})
if executable('fzf')
" FZF {{{
" <C-p> or <C-t> to search files
nnoremap <silent> <C-t> :FZF -m<cr>
nnoremap <silent> <C-p> :FZF -m<cr>
" <M-p> for open buffers
nnoremap <silent> <M-p> :Buffers<cr>
" <M-S-p> for MRU
nnoremap <silent> <M-S-p> :History<cr>
" Use fuzzy completion relative filepaths across directory
imap <expr> <c-x><c-f> fzf#vim#complete#path('git ls-files $(git rev-parse --show-toplevel)')
" Better command history with q:
command! CmdHist call fzf#vim#command_history({'right': '40'})
nnoremap q: :CmdHist<CR>
" Better search history
command! QHist call fzf#vim#search_history({'right': '40'})
nnoremap q/ :QHist<CR>
command! -bang -nargs=* Ack call fzf#vim#ag(<q-args>, {'down': '40%', 'options': --no-color'})
" }}}
else
" CtrlP fallback
end
" Always show statusline
set laststatus=2
" Use 256 colours (Use this setting only if your terminal supports 256 colours)
set t_Co=256
"let g:netrw_altv = 1
"let g:netrw_fastbrowse = 2
"let g:netrw_keepdir = 0
"let g:netrw_liststyle = 3
"let g:netrw_retmap = 1
"let g:netrw_silent = 1
"let g:netrw_special_syntax = 1
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 25
"augroup ProjectDrawer
" autocmd!
" autocmd VimEnter * :Vexplore
"augroup END
" https://dev.to/skywind3000/vim-2021-add-a-context-menu-in-you-vim-2pcc
" define your context menu as a list of (text, command) pairs
let g:context_menu_k = [
\ ["&Help Keyword\t\\ch", 'echo expand("<cword>")' ],
\ ["&Signature\t\\cs", 'echo 101'],
\ ['-'],
\ ["Find in &File\t\\cx", 'exec "/" . expand("<cword>")' ],
\ ["Find in &Project\t\\cp", 'exec "vimgrep " . expand("<cword>") . "*"' ],
\ ["Find in &Defintion\t\\cd", 'YcmCompleter GotoDefinition' ],
\ ["Search &References\t\\cr", 'YcmCompleter GoToReferences'],
\ ['-'],
\ ["&Documentation\t\\cm", 'exec "PyDoc " . expand("<cword>")'],
\ ]
" map 'K' to display the context menu
nnoremap <silent>K :call quickui#tools#clever_context('k', g:context_menu_k, {})<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment