1
0
mirror of https://github.com/amix/vimrc synced 2025-07-16 00:25:01 +08:00

Merge branch 'master' of github.com:amix/vimrc into amix-master

This commit is contained in:
Chris Morris
2022-07-24 21:41:11 -04:00
1967 changed files with 75340 additions and 36544 deletions

View File

@ -1,5 +1,5 @@
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer:
" Maintainer:
" Amir Salihefendic — @amix3k
"
" Awesome_version:
@ -39,6 +39,7 @@ filetype indent on
" Set to auto read when a file is changed from the outside
set autoread
au FocusGained,BufEnter * checktime
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
@ -47,9 +48,9 @@ let mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
" :W sudo saves the file
" :W sudo saves the file
" (useful for handling the permission-denied error)
command W w !sudo tee % > /dev/null
command! W execute 'w !sudo tee % > /dev/null' <bar> edit!
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@ -59,7 +60,7 @@ command W w !sudo tee % > /dev/null
set so=7
" Avoid garbled characters in Chinese language windows OS
let $LANG='en'
let $LANG='en'
set langmenu=en
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
@ -75,11 +76,11 @@ else
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
endif
"Always show current position
" Always show current position
set ruler
" Height of the command bar
set cmdheight=2
set cmdheight=1
" A buffer becomes hidden when it is abandoned
set hid
@ -91,23 +92,24 @@ set whichwrap+=<,>,h,l
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
set incsearch
" Don't redraw while executing macros (good performance config)
set lazyredraw
set lazyredraw
" For regular expressions turn magic on
set magic
" Show matching brackets when text indicator is over them
set showmatch
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
@ -122,7 +124,6 @@ if has("gui_macvim")
autocmd GUIEnter * set vb t_vb=
endif
" Add a bit extra margin to the left
set foldcolumn=1
@ -131,7 +132,7 @@ set foldcolumn=1
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
syntax enable
" Enable 256 colors palette in Gnome Terminal
if $COLORTERM == 'gnome-terminal'
@ -163,7 +164,7 @@ set ffs=unix,dos,mac
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git et.c anyway...
" Turn backup off, since most stuff is in SVN, git etc. anyway...
set nobackup
set nowb
set noswapfile
@ -205,7 +206,7 @@ vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search)
map <space> /
map <c-space> ?
map <C-space> ?
" Disable highlight when <leader><cr> is pressed
map <silent> <leader><cr> :noh<cr>
@ -229,8 +230,8 @@ map <leader>h :bprevious<cr>
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
map <leader>t<leader> :tabnext
map <leader>tm :tabmove
map <leader>t<leader> :tabnext
" Let 'tl' toggle between this and the last accessed tab
let g:lasttab = 1
@ -240,12 +241,12 @@ au TabLeave * let g:lasttab = tabpagenr()
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
map <leader>te :tabedit <C-r>=expand("%:p:h")<cr>/
" Switch CWD to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
" Specify the behavior when switching between buffers
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab,newtab
set stal=2
@ -362,7 +363,7 @@ endfunction
function! CmdLine(str)
call feedkeys(":" . a:str)
endfunction
endfunction
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"

View File

@ -14,9 +14,9 @@ if has("mac") || has("macunix")
elseif has("win16") || has("win32")
set gfn=IBM\ Plex\ Mono:h14,Source\ Code\ Pro:h12,Bitstream\ Vera\ Sans\ Mono:h11
elseif has("gui_gtk2")
set gfn=IBM\ Plex\ Mono:h14,:Hack\ 14,Source\ Code\ Pro\ 12,Bitstream\ Vera\ Sans\ Mono\ 11
set gfn=IBM\ Plex\ Mono\ 14,:Hack\ 14,Source\ Code\ Pro\ 12,Bitstream\ Vera\ Sans\ Mono\ 11
elseif has("linux")
set gfn=IBM\ Plex\ Mono:h14,:Hack\ 14,Source\ Code\ Pro\ 12,Bitstream\ Vera\ Sans\ Mono\ 11
set gfn=IBM\ Plex\ Mono\ 14,:Hack\ 14,Source\ Code\ Pro\ 12,Bitstream\ Vera\ Sans\ Mono\ 11
elseif has("unix")
set gfn=Monospace\ 11
endif
@ -85,7 +85,7 @@ vnoremap $2 <esc>`>a]<esc>`<i[<esc>
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
vnoremap $q <esc>`>a'<esc>`<i'<esc>
vnoremap $e <esc>`>a"<esc>`<i"<esc>
vnoremap $e <esc>`>a`<esc>`<i`<esc>
" Map auto complete of (, ", ', [
inoremap $1 ()<esc>i
@ -99,7 +99,7 @@ inoremap $e ""<esc>i
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General abbreviations
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
iab xdate <C-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@ -139,6 +139,8 @@ map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
map <leader>n :cn<cr>
map <leader>p :cp<cr>
" Make sure that enter is never overriden in the quickfix window
autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@ -167,3 +169,59 @@ endfunc
func! CurrentFileDir(cmd)
return a:cmd . " " . expand("%:p:h") . "/"
endfunc
"=================================================================================
"
" Following file contains the commands on how to run the currently open code.
" The default mapping is set to F5 like most code editors.
" Change it as you feel comfortable with, keeping in mind that it does not
" clash with any other keymapping.
"
" NOTE: Compilers for different systems may differ. For example, in the case
" of C and C++, we have assumed it to be gcc and g++ respectively, but it may
" not be the same. It is suggested to check first if the compilers are installed
" before running the code, or maybe even switch to a different compiler.
"
" NOTE: Adding support for more programming languages
"
" Just add another elseif block before the 'endif' statement in the same
" way it is done in each case. Take care to add tabbed spaces after each
" elseif block (similar to python). For example:
"
" elseif &filetype == '<your_file_extension>'
" exec '!<your_compiler> %'
"
" NOTE: The '%' sign indicates the name of the currently open file with extension.
" The time command displays the time taken for execution. Remove the
" time command if you dont want the system to display the time
"
"=================================================================================
map <F5> :call CompileRun()<CR>
imap <F5> <Esc>:call CompileRun()<CR>
vmap <F5> <Esc>:call CompileRun()<CR>
func! CompileRun()
exec "w"
if &filetype == 'c'
exec "!gcc % -o %<"
exec "!time ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &filetype == 'java'
exec "!javac %"
exec "!time java %"
elseif &filetype == 'sh'
exec "!time bash %"
elseif &filetype == 'python'
exec "!time python3 %"
elseif &filetype == 'html'
exec "!google-chrome % &"
elseif &filetype == 'go'
exec "!go build %<"
exec "!time go run %"
elseif &filetype == 'matlab'
exec "!time octave %"
endif
endfunc

View File

@ -17,9 +17,6 @@ au FileType python map <buffer> <leader>1 /class
au FileType python map <buffer> <leader>2 /def
au FileType python map <buffer> <leader>C ?class
au FileType python map <buffer> <leader>D ?def
au FileType python set cindent
au FileType python set cinkeys-=0#
au FileType python set indentkeys-=0#
""""""""""""""""""""""""""""""
@ -29,11 +26,11 @@ au FileType python set indentkeys-=0#
au FileType javascript setl fen
au FileType javascript setl nocindent
au FileType javascript imap <c-t> $log();<esc>hi
au FileType javascript imap <c-a> alert();<esc>hi
au FileType javascript,typescript imap <C-t> console.log();<esc>hi
au FileType javascript,typescript imap <C-a> alert();<esc>hi
au FileType javascript inoremap <buffer> $r return
au FileType javascript inoremap <buffer> $f // --- PH<esc>FP2xi
au FileType javascript,typescript inoremap <buffer> $r return
au FileType javascript,typescript inoremap <buffer> $f // --- PH<esc>FP2xi
function! JavaScriptFold()
setl foldmethod=syntax
@ -75,3 +72,9 @@ endif
" => Twig section
""""""""""""""""""""""""""""""
autocmd BufRead *.twig set syntax=html filetype=html
""""""""""""""""""""""""""""""
" => Markdown
""""""""""""""""""""""""""""""
let vim_markdown_folding_disabled = 1

View File

@ -1,6 +1,6 @@
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Important:
" This requries that you install https://github.com/amix/vimrc !
" This requires that you install https://github.com/amix/vimrc !
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@ -14,6 +14,19 @@ call pathogen#infect(s:vim_runtime.'/sources_non_forked/{}')
call pathogen#infect(s:vim_runtime.'/my_plugins/{}')
call pathogen#helptags()
<<<<<<< HEAD
=======
""""""""""""""""""""""""""""""
" => bufExplorer plugin
""""""""""""""""""""""""""""""
let g:bufExplorerDefaultHelp=0
let g:bufExplorerShowRelativePath=1
let g:bufExplorerFindActive=1
let g:bufExplorerSortBy='name'
map <leader>o :BufExplorer<cr>
>>>>>>> 5108ca4ec066ed9b93bab2c7f5b0d37d244ac0a9
""""""""""""""""""""""""""""""
" => MRU plugin
@ -27,17 +40,32 @@ map <leader>f :MRU<CR>
""""""""""""""""""""""""""""""
let g:yankstack_yank_keys = ['y', 'd']
nmap <c-p> <Plug>yankstack_substitute_older_paste
nmap <c-n> <Plug>yankstack_substitute_newer_paste
nmap <C-p> <Plug>yankstack_substitute_older_paste
nmap <C-n> <Plug>yankstack_substitute_newer_paste
""""""""""""""""""""""""""""""
" => FZF
""""""""""""""""""""""""""""""
<<<<<<< HEAD
nnoremap <C-f> :Files<Cr>
nmap <Leader>o :Buffers<CR>
nnoremap <Leader>g :Ag<CR>
set rtp+=/usr/local/opt/fzf
=======
let g:ctrlp_working_path_mode = 0
" Quickly find and open a file in the current working directory
let g:ctrlp_map = '<C-f>'
map <leader>j :CtrlP<cr>
" Quickly find and open a buffer
map <leader>b :CtrlPBuffer<cr>
let g:ctrlp_max_height = 20
let g:ctrlp_custom_ignore = 'node_modules\|^\.DS_Store\|^\.git\|^\.coffee'
>>>>>>> 5108ca4ec066ed9b93bab2c7f5b0d37d244ac0a9
""""""""""""""""""""""""""""""
" => ZenCoding
@ -49,8 +77,9 @@ let g:user_zen_mode='a'
""""""""""""""""""""""""""""""
" => snipMate (beside <TAB> support <CTRL-j>)
""""""""""""""""""""""""""""""
ino <c-j> <c-r>=snipMate#TriggerSnippet()<cr>
snor <c-j> <esc>i<right><c-r>=snipMate#TriggerSnippet()<cr>
ino <C-j> <C-r>=snipMate#TriggerSnippet()<cr>
snor <C-j> <esc>i<right><C-r>=snipMate#TriggerSnippet()<cr>
let g:snipMate = { 'snippet_version' : 1 }
""""""""""""""""""""""""""""""
@ -99,10 +128,6 @@ au FileType mako vmap Si S"i${ _(<esc>2f"a) }<esc>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => lightline
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:lightline = {
\ 'colorscheme': 'wombat',
\ }
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
@ -113,12 +138,12 @@ let g:lightline = {
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"🔒":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}',
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ 'fugitive': '%{exists("*FugitiveHead")?FugitiveHead():""}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ 'fugitive': '(exists("*FugitiveHead") && ""!=FugitiveHead())'
\ },
\ 'separator': { 'left': ' ', 'right': ' ' },
\ 'subseparator': { 'left': ' ', 'right': ' ' }
@ -134,16 +159,10 @@ nnoremap <silent> <leader>z :Goyo<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vim-go
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:go_fmt_command = "goimports"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Syntastic (syntax checker)
" => Ale (syntax checker and linter)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ale_linters = {
\ 'javascript': ['jshint'],
\ 'javascript': ['eslint'],
\ 'python': ['flake8'],
\ 'go': ['go', 'golint', 'errcheck']
\}
@ -163,3 +182,17 @@ let g:ale_lint_on_enter = 0
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:gitgutter_enabled=0
nnoremap <silent> <leader>d :GitGutterToggle<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => EditorConfig (project-specific EditorConfig rule)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Fugitive
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Copy the link to the line of a Git repository to the clipboard
nnoremap <leader>v :.GBrowse!<CR>
xnoremap <leader>v :'<'>GBrowse!<CR>