mirror of
https://github.com/Smaug123/nix-dotfiles
synced 2025-10-08 16:08:39 +00:00
243 lines
6.0 KiB
VimL
243 lines
6.0 KiB
VimL
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" Maintainer:
|
|
" Amir Salihefendic — @amix3k
|
|
"
|
|
" Awesome_version:
|
|
" Get this config, nice color schemes and lots of plugins!
|
|
"
|
|
" Install the awesome version from:
|
|
"
|
|
" https://github.com/amix/vimrc
|
|
"
|
|
" Sections:
|
|
" -> General
|
|
" -> VIM user interface
|
|
" -> Colors and Fonts
|
|
" -> Files and backups
|
|
" -> Text, tab and indent related
|
|
" -> Visual mode related
|
|
" -> Moving around, tabs and buffers
|
|
" -> Status line
|
|
" -> Editing mappings
|
|
" -> vimgrep searching and cope displaying
|
|
" -> Spell checking
|
|
" -> Misc
|
|
" -> Helper functions
|
|
"
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" => General
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" Enable filetype plugins
|
|
filetype plugin on
|
|
filetype indent on
|
|
|
|
" With a map leader it's possible to do extra key combinations
|
|
" like <leader>w saves the current file
|
|
let mapleader = "`"
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" => VIM user interface
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" Set 7 lines to the cursor - when moving vertically using j/k
|
|
set so=7
|
|
|
|
" Avoid garbled characters in Chinese language windows OS
|
|
let $LANG='en'
|
|
set langmenu=en
|
|
" source $VIMRUNTIME/delmenu.vim
|
|
" source $VIMRUNTIME/menu.vim
|
|
|
|
" Turn on the Wild menu
|
|
set wildmenu
|
|
|
|
" Ignore compiled files
|
|
set wildignore=*.o,*~,*.pyc
|
|
if has("win16") || has("win32")
|
|
set wildignore+=.git\*,.hg\*,.svn\*
|
|
else
|
|
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
|
|
endif
|
|
|
|
" Height of the command bar
|
|
set cmdheight=2
|
|
|
|
" A buffer becomes hidden when it is abandoned
|
|
set hid
|
|
|
|
" Ignore case when searching
|
|
set ignorecase
|
|
|
|
" When searching try to be smart about cases
|
|
set smartcase
|
|
|
|
" Makes search act like search in modern browsers
|
|
set incsearch
|
|
|
|
" For regular expressions turn magic on
|
|
set magic
|
|
|
|
" No annoying sound on errors
|
|
set tm=500
|
|
|
|
" Properly disable sound on errors on MacVim
|
|
if has("gui_macvim")
|
|
autocmd GUIEnter * set vb t_vb=
|
|
endif
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" => Colors and Fonts
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" Enable syntax highlighting
|
|
syntax enable
|
|
|
|
" Enable 256 colors palette in Gnome Terminal
|
|
if $COLORTERM == 'gnome-terminal'
|
|
set t_Co=256
|
|
endif
|
|
|
|
" Set extra options when running in GUI mode
|
|
if has("gui_running")
|
|
set guioptions-=T
|
|
set guioptions-=e
|
|
set t_Co=256
|
|
set guitablabel=%M\ %t
|
|
endif
|
|
|
|
" Set utf8 as standard encoding and en_US as the standard language
|
|
set encoding=utf8
|
|
|
|
" Use Unix as the standard file type
|
|
set ffs=unix
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" => Files, backups and undo
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
set nowb
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" => Text, tab and indent related
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" Linebreak on 500 characters
|
|
set lbr
|
|
set tw=500
|
|
|
|
set ai "Auto indent
|
|
set si "Smart indent
|
|
set wrap "Wrap lines
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" => Moving around, tabs, windows and buffers
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" Specify the behavior when switching between buffers
|
|
try
|
|
set switchbuf=useopen,usetab,newtab
|
|
set stal=2
|
|
catch
|
|
endtry
|
|
|
|
" Return to last edit position when opening files (You want this!)
|
|
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
|
|
|
|
|
""""""""""""""""""""""""""""""
|
|
" => Status line
|
|
""""""""""""""""""""""""""""""
|
|
" Always show the status line
|
|
set laststatus=2
|
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" => Editing mappings
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" Delete trailing white space on save, useful for some filetypes ;)
|
|
fun! CleanExtraSpaces()
|
|
let save_cursor = getpos(".")
|
|
let old_query = getreg('/')
|
|
silent! %s/\s\+$//e
|
|
call setpos('.', save_cursor)
|
|
call setreg('/', old_query)
|
|
endfun
|
|
|
|
if has("autocmd")
|
|
autocmd BufWritePre *.fs,*.fsi,*.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
|
|
endif
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" => Spell checking
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" Pressing ,ss will toggle and untoggle spell checking
|
|
map <leader>ss :setlocal spell!<cr>
|
|
|
|
" Shortcuts using <leader>
|
|
map <leader>sn ]s
|
|
map <leader>sp [s
|
|
map <leader>sa zg
|
|
map <leader>s? z=
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" => Helper functions
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" Returns true if paste mode is enabled
|
|
function! HasPaste()
|
|
if &paste
|
|
return 'PASTE MODE '
|
|
endif
|
|
return ''
|
|
endfunction
|
|
|
|
" Don't close window, when deleting a buffer
|
|
command! Bclose call <SID>BufcloseCloseIt()
|
|
function! <SID>BufcloseCloseIt()
|
|
let l:currentBufNum = bufnr("%")
|
|
let l:alternateBufNum = bufnr("#")
|
|
|
|
if buflisted(l:alternateBufNum)
|
|
buffer #
|
|
else
|
|
bnext
|
|
endif
|
|
|
|
if bufnr("%") == l:currentBufNum
|
|
new
|
|
endif
|
|
|
|
if buflisted(l:currentBufNum)
|
|
execute("bdelete! ".l:currentBufNum)
|
|
endif
|
|
endfunction
|
|
|
|
function! CmdLine(str)
|
|
call feedkeys(":" . a:str)
|
|
endfunction
|
|
|
|
function! VisualSelection(direction, extra_filter) range
|
|
let l:saved_reg = @"
|
|
execute "normal! vgvy"
|
|
|
|
let l:pattern = escape(@", "\\/.*'$^~[]")
|
|
let l:pattern = substitute(l:pattern, "\n$", "", "")
|
|
|
|
if a:direction == 'gv'
|
|
call CmdLine("Ack '" . l:pattern . "' " )
|
|
elseif a:direction == 'replace'
|
|
call CmdLine("%s" . '/'. l:pattern . '/')
|
|
endif
|
|
|
|
let @/ = l:pattern
|
|
let @" = l:saved_reg
|
|
endfunction
|
|
|
|
set statusline+=%#warningmsg#
|
|
set statusline+=%{SyntasticStatuslineFlag()}
|
|
set statusline+=%*
|
|
" Format the status line
|
|
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c
|