2015-06-03 21:39:41 +00:00
|
|
|
set nocompatible
|
2019-02-25 03:19:53 +00:00
|
|
|
if &shell =~# 'fish$'
|
|
|
|
set shell=sh
|
|
|
|
endif
|
|
|
|
"[Use Plug-ins and Plug-in Manager(Vundle) only on UNIX or MAC OS]"
|
|
|
|
if has("unix") || has("mac")
|
|
|
|
filetype off
|
|
|
|
"[Download and install Vundle Plug-in Manager]"
|
|
|
|
if !isdirectory(expand("$HOME/.vim/bundle"))
|
|
|
|
silent !mkdir -p $HOME/.vim/bundle
|
|
|
|
silent cd $HOME/.vim/bundle
|
|
|
|
silent !git clone https://github.com/gmarik/Vundle.vim.git
|
|
|
|
silent cd $HOME
|
|
|
|
endif
|
|
|
|
"[Run Plug-ins]"
|
|
|
|
set runtimepath+=$HOME/.vim/bundle/Vundle.vim
|
|
|
|
call vundle#begin()
|
|
|
|
Plugin 'gmarik/Vundle.vim'
|
|
|
|
map <F3> :VundleUpdate<CR>
|
|
|
|
Plugin 'dag/vim-fish'
|
|
|
|
Plugin 'w0rp/ale'
|
|
|
|
let g:ale_linters = {
|
|
|
|
\ 'cpp': ['g++'],
|
|
|
|
\ 'c': ['clang']
|
|
|
|
\ }
|
|
|
|
let g:ale_c_gcc_options='-std=c99 -pedantic'
|
|
|
|
let g:ale_sign_error = '●'
|
|
|
|
let g:ale_sign_warning = '●'
|
|
|
|
Plugin 'itchyny/lightline.vim'
|
|
|
|
let g:lightline = {
|
|
|
|
\ 'active': {
|
|
|
|
\ 'left': [['mode', 'paste'], ['filename', 'modified']],
|
|
|
|
\ 'right': [['lineinfo'],
|
|
|
|
\ ['percent'],
|
|
|
|
\ ['readonly', 'linter_warnings', 'linter_errors', 'linter_ok'],
|
|
|
|
\ ['fileformat'],
|
|
|
|
\ ['fileencoding']
|
|
|
|
\ ]
|
|
|
|
\ },
|
|
|
|
\ 'component_expand': {
|
|
|
|
\ 'linter_warnings': 'LightlineLinterWarnings',
|
|
|
|
\ 'linter_errors': 'LightlineLinterErrors',
|
|
|
|
\ 'linter_ok': 'LightlineLinterOK',
|
|
|
|
\ 'lineinfo': 'LineInfo'
|
|
|
|
\ },
|
|
|
|
\ 'component_type': {
|
|
|
|
\ 'readonly': 'error',
|
|
|
|
\ 'linter_warnings': 'warning',
|
|
|
|
\ 'linter_errors': 'error'
|
|
|
|
\ },
|
|
|
|
\}
|
|
|
|
if executable('ctags')
|
|
|
|
Plugin 'ludovicchabant/vim-gutentags'
|
|
|
|
endif
|
|
|
|
Plugin 'beyondmarc/opengl.vim'
|
|
|
|
Plugin 'tikhomirov/vim-glsl'
|
|
|
|
Plugin 'jamessan/vim-gnupg'
|
|
|
|
"[Autodetect indent style of a file]"
|
|
|
|
Plugin 'tcbbd/detectindent'
|
|
|
|
let g:detectindent_preferred_indent=4
|
|
|
|
let g:detectindent_autodetect=1
|
|
|
|
call vundle#end()
|
|
|
|
endif
|
2019-02-19 19:35:03 +00:00
|
|
|
" Allow backspacing over everything in insert mode.
|
|
|
|
set backspace=indent,eol,start
|
|
|
|
set number
|
|
|
|
set relativenumber
|
2019-02-21 05:33:55 +00:00
|
|
|
"[Hide/show the white-space and more invisible symbols]"
|
|
|
|
set list
|
|
|
|
set listchars=nbsp:¬,trail:-
|
|
|
|
"set listchars+=tab:│\ ,
|
|
|
|
set listchars+=tab:▸\ ,
|
|
|
|
set nojoinspaces
|
|
|
|
"[Indent & Tab/mode-line settings]"
|
|
|
|
set breakindent
|
|
|
|
set nopaste
|
|
|
|
set smarttab
|
|
|
|
set tabstop=4 " tabs size on screen "
|
|
|
|
set expandtab " <tab> inserts spaces "
|
|
|
|
set autoindent
|
|
|
|
set copyindent " copy existing tab/spaces mix on newline "
|
|
|
|
set smartindent " overruled by cindent "
|
|
|
|
set cinwords=except,finally,def,class,with,do,if,elif,else,for,while,try,switch
|
|
|
|
set cinoptions+=l1 " switch case label alignement, :h cinoptions-values "
|
|
|
|
set shiftwidth=4 " number of space to use on indent. Use tabstop if 0"
|
|
|
|
"set softtabstop=4
|
|
|
|
"[Matching chars]"
|
|
|
|
set showmatch
|
|
|
|
set matchpairs=\":\"
|
|
|
|
set matchpairs+=(:)
|
|
|
|
set matchpairs+={:}
|
|
|
|
set matchpairs+=[:]
|
|
|
|
"[TextWidth settings]"
|
|
|
|
set textwidth=0
|
|
|
|
"[Look for a single modeline in files]"
|
|
|
|
set modeline
|
|
|
|
set modelines=1
|
2019-02-19 19:35:03 +00:00
|
|
|
|
|
|
|
set history=200 " keep 200 lines of command line history
|
|
|
|
set ruler " show the cursor position all the time
|
|
|
|
set showcmd " display incomplete commands
|
|
|
|
set wildmenu " display completion matches in a status line
|
|
|
|
|
|
|
|
set ttimeout " time out for key codes
|
|
|
|
set ttimeoutlen=100 " wait up to 100ms after Esc for special key
|
|
|
|
|
|
|
|
"[Turn backup off and value of history]"
|
|
|
|
set nobackup
|
|
|
|
set noswapfile
|
|
|
|
set history=1000
|
|
|
|
set nowritebackup
|
|
|
|
set undolevels=5000
|
|
|
|
|
2019-02-21 05:33:55 +00:00
|
|
|
" Show @@@ in the last line if it is truncated.
|
|
|
|
set display=truncate
|
|
|
|
"[Splitting rules]"
|
|
|
|
set splitbelow
|
|
|
|
set splitright
|
|
|
|
set equalalways
|
|
|
|
|
|
|
|
" Show a few lines of context around the cursor.
|
|
|
|
set scrolloff=5
|
2019-03-06 21:40:26 +00:00
|
|
|
" Try to keep the cursor in the same column while scrolling
|
|
|
|
set nostartofline
|
2019-02-21 05:33:55 +00:00
|
|
|
|
|
|
|
set autochdir
|
|
|
|
set autoread
|
|
|
|
set autowrite
|
|
|
|
|
|
|
|
"[Shared with OS clipboard]"
|
|
|
|
set clipboard=unnamed
|
|
|
|
|
|
|
|
"[For regular expressions turn magic on, use \v to get regex parent]"
|
|
|
|
set magic
|
|
|
|
"[Search settings]"
|
|
|
|
set hlsearch
|
|
|
|
set incsearch
|
|
|
|
set smartcase
|
|
|
|
set ignorecase
|
|
|
|
set wrapscan
|
|
|
|
"[When on, the ":substitute" flag 'g' is default on]"
|
|
|
|
set nogdefault
|
|
|
|
|
|
|
|
|
|
|
|
"[Kitty doesn't support background color erase]"
|
|
|
|
let &t_ut=''
|
|
|
|
let base16colorspace=256
|
|
|
|
set background=dark
|
|
|
|
colorscheme base16-default-dark
|
|
|
|
"[Fix background transparency]"
|
|
|
|
if has("autocmd")
|
|
|
|
autocmd ColorScheme * highlight Normal ctermbg=None
|
|
|
|
autocmd ColorScheme * highlight NonText ctermbg=None
|
|
|
|
endif
|
|
|
|
|
2019-02-19 19:35:03 +00:00
|
|
|
|
2015-06-03 21:39:41 +00:00
|
|
|
"[Define the leader key]"
|
|
|
|
let mapleader=","
|
2015-09-30 22:26:57 +00:00
|
|
|
let maplocalleader=","
|
2015-06-03 21:39:41 +00:00
|
|
|
"[Reselect visual block after indent/outdent]"
|
|
|
|
vnoremap < <gv
|
|
|
|
vnoremap > >gv
|
|
|
|
"[Improve up/down movement on wrapped lines]"
|
2018-08-01 20:52:59 +00:00
|
|
|
"[If preceded by a count, jump actual lines. Also if > 5, save to jumplist]"
|
|
|
|
nnoremap <expr> j v:count ? (v:count > 5 ? "m'" . v:count : '') . 'j' : 'gj'
|
|
|
|
nnoremap <expr> k v:count ? (v:count > 5 ? "m'" . v:count : '') . 'k' : 'gk'
|
2015-06-03 21:39:41 +00:00
|
|
|
"[Easy split navigation]"
|
|
|
|
nnoremap <C-j> <C-W>j
|
|
|
|
nnoremap <C-k> <C-W>k
|
|
|
|
nnoremap <C-h> <C-W>h
|
|
|
|
nnoremap <C-l> <C-W>l
|
2015-08-08 20:44:49 +00:00
|
|
|
nnoremap <C-Up> <C-W>k
|
|
|
|
nnoremap <C-Down> <C-W>j
|
|
|
|
nnoremap <C-Left> <C-W>h
|
|
|
|
nnoremap <C-Right> <C-W>l
|
2015-06-03 21:39:41 +00:00
|
|
|
"[Locate the desired objects in the center of the screen]"
|
|
|
|
nnoremap <silent> n nzz
|
|
|
|
nnoremap <silent> N Nzz
|
|
|
|
nnoremap <silent> * *zz
|
|
|
|
nnoremap <silent> # #zz
|
|
|
|
"[New line under/bellow current line without jump to insert-mode]"
|
|
|
|
nnoremap <leader>o o<Esc>
|
|
|
|
nnoremap <leader>O O<Esc>
|
2019-02-19 19:35:03 +00:00
|
|
|
"[Clear search highlights]"
|
|
|
|
nnoremap // :nohlsearch<CR>
|
|
|
|
" Don't use Ex mode, use Q for formatting.
|
|
|
|
map Q gq
|
|
|
|
"[Reflow current paragraph]"
|
|
|
|
"[http://stevelosh.com/blog/2010/09/coming-home-to-vim/]"
|
|
|
|
nnoremap <leader>q gqip
|
2019-02-21 05:33:55 +00:00
|
|
|
" http://stackoverflow.com/questions/1005/getting-root-permissions-on-a-file-inside-of-vi
|
|
|
|
cmap w!! w !sudo tee >/dev/null %
|
|
|
|
"[To disable the arrow keys]"
|
|
|
|
for prefix in ['i', 'n', 'v']
|
|
|
|
for key in ['<Up>', '<Down>', '<Left>', '<Right>']
|
|
|
|
execute prefix . "noremap " . key . " <Nop>"
|
|
|
|
endfor
|
|
|
|
endfor
|
2019-02-19 19:35:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
" Do incremental searching when it's possible to timeout.
|
|
|
|
if has('reltime')
|
2019-02-21 05:33:55 +00:00
|
|
|
set incsearch
|
2015-06-03 21:39:41 +00:00
|
|
|
endif
|
2019-02-19 19:35:03 +00:00
|
|
|
|
|
|
|
" LaTeX ftdetect
|
|
|
|
let g:tex_flavor = "latex"
|
|
|
|
|
|
|
|
" Switch syntax highlighting on when the terminal has colors or when using the
|
|
|
|
" GUI (which always has colors).
|
|
|
|
if &t_Co > 2 || has("gui_running")
|
2019-02-21 05:33:55 +00:00
|
|
|
" Revert with ":syntax off".
|
|
|
|
syntax on
|
2019-02-19 19:35:03 +00:00
|
|
|
|
2019-02-21 05:33:55 +00:00
|
|
|
" I like highlighting strings inside C comments.
|
|
|
|
" Revert with ":unlet c_comment_strings".
|
|
|
|
let c_comment_strings=1
|
2015-06-03 21:39:41 +00:00
|
|
|
endif
|
2019-02-21 05:33:55 +00:00
|
|
|
"
|
|
|
|
"[Remove tabs and spaces at the end of lines]"
|
|
|
|
function! DeleteTrailingTWS()
|
|
|
|
if &ft =~ 'diff'
|
|
|
|
return
|
|
|
|
end
|
2019-03-06 21:40:26 +00:00
|
|
|
let l:view = winsaveview()
|
2019-02-21 05:33:55 +00:00
|
|
|
silent %s/[ \t]*$//g
|
|
|
|
silent %s/\s\+$//ge
|
2019-03-06 21:40:26 +00:00
|
|
|
call winrestview(l:view)
|
2019-02-21 05:33:55 +00:00
|
|
|
endfunction
|
|
|
|
"[Make the scripts executable]"
|
|
|
|
function! ChangeScriptMode()
|
|
|
|
if getline(1) =~ "#!"
|
|
|
|
if getline(1) =~ "bin/"
|
|
|
|
silent !chmod +x <afile>
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endfunction
|
2019-02-19 19:35:03 +00:00
|
|
|
|
|
|
|
" Only do this part when compiled with support for autocommands.
|
2017-10-19 05:09:25 +00:00
|
|
|
if has("autocmd")
|
2017-10-26 15:57:35 +00:00
|
|
|
|
2019-02-21 05:33:55 +00:00
|
|
|
" Enable file type detection.
|
|
|
|
" Use the default filetype settings, so that mail gets 'tw' set to 72,
|
|
|
|
" 'cindent' is on in C files, etc.
|
|
|
|
" Also load indent files, to automatically do language-dependent indenting.
|
|
|
|
" Revert with ":filetype off".
|
|
|
|
filetype plugin indent on
|
|
|
|
|
|
|
|
" Put these in an autocmd group, so that you can revert them with:
|
|
|
|
" ":augroup vimStartup | au! | augroup END"
|
|
|
|
augroup vimStartup
|
|
|
|
au!
|
|
|
|
|
|
|
|
" When editing a file, always jump to the last known cursor position.
|
|
|
|
" Don't do it when the position is invalid, when inside an event handler
|
|
|
|
" (happens when dropping a file on gvim) and for a commit message (it's
|
|
|
|
" likely a different one than last time).
|
|
|
|
autocmd BufReadPost *
|
|
|
|
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
|
|
|
|
\ | exe "normal! g`\""
|
|
|
|
\ | endif
|
|
|
|
|
|
|
|
augroup END
|
|
|
|
"
|
|
|
|
"[Do not clean up trailing spaces in binary mode]"
|
|
|
|
if !&binary
|
|
|
|
autocmd BufWritePre * call DeleteTrailingTWS()
|
|
|
|
endif
|
|
|
|
|
|
|
|
if has("unix") || has("mac")
|
|
|
|
autocmd BufWritePost * call ChangeScriptMode()
|
|
|
|
endif
|
2017-10-26 15:57:35 +00:00
|
|
|
|
2019-02-19 19:35:03 +00:00
|
|
|
endif " has("autocmd")
|