Rearranged and added descriptions what most of the stuff does.
This commit is contained in:
parent
eec591f5dd
commit
09639488d6
1 changed files with 111 additions and 60 deletions
171
dotfiles/.vimrc
171
dotfiles/.vimrc
|
|
@ -1,7 +1,10 @@
|
||||||
set encoding=utf-8
|
set encoding=utf-8
|
||||||
|
|
||||||
|
|
||||||
"vim-plug installation
|
set nocompatible " be iMproved, required
|
||||||
|
|
||||||
|
|
||||||
|
"vim-plug installation (auto installs on new machines)
|
||||||
|
|
||||||
if empty(glob('~/.vim/autoload/plug.vim'))
|
if empty(glob('~/.vim/autoload/plug.vim'))
|
||||||
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
||||||
|
|
@ -10,34 +13,80 @@ if empty(glob('~/.vim/autoload/plug.vim'))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
set nocompatible " be iMproved, required
|
|
||||||
|
|
||||||
call plug#begin('~/.vim/bundle')
|
call plug#begin('~/.vim/bundle')
|
||||||
|
|
||||||
|
" Add git changes to fron of the line
|
||||||
Plug 'airblade/vim-gitgutter'
|
Plug 'airblade/vim-gitgutter'
|
||||||
|
|
||||||
|
" Java autocomplete
|
||||||
Plug 'artur-shaik/vim-javacomplete2'
|
Plug 'artur-shaik/vim-javacomplete2'
|
||||||
|
|
||||||
|
" Generates a lift of todo comments
|
||||||
Plug 'chauncey-garrett/vim-tasklist'
|
Plug 'chauncey-garrett/vim-tasklist'
|
||||||
|
|
||||||
|
" Fuzzy file finder
|
||||||
Plug 'ctrlpvim/ctrlp.vim'
|
Plug 'ctrlpvim/ctrlp.vim'
|
||||||
|
|
||||||
|
" I need thsi for python
|
||||||
Plug 'davidhalter/jedi-vim'
|
Plug 'davidhalter/jedi-vim'
|
||||||
|
|
||||||
|
" Linter and analyse tool
|
||||||
Plug 'dense-analysis/ale'
|
Plug 'dense-analysis/ale'
|
||||||
|
|
||||||
|
" Forces <Tab> to do what I want (autocomplete etc.)
|
||||||
Plug 'ervandew/supertab'
|
Plug 'ervandew/supertab'
|
||||||
|
|
||||||
|
" Adds the closing equivalent of everything that opens: ""[]()....
|
||||||
Plug 'jiangmiao/auto-pairs'
|
Plug 'jiangmiao/auto-pairs'
|
||||||
|
|
||||||
|
" Git commit browser
|
||||||
Plug 'junegunn/gv.vim'
|
Plug 'junegunn/gv.vim'
|
||||||
|
|
||||||
|
" When pressing " or @, it shows a popup with the register content.
|
||||||
Plug 'junegunn/vim-peekaboo'
|
Plug 'junegunn/vim-peekaboo'
|
||||||
|
|
||||||
|
" The package manager itself.
|
||||||
Plug 'junegunn/vim-plug'
|
Plug 'junegunn/vim-plug'
|
||||||
|
|
||||||
|
" Add swift support
|
||||||
Plug 'keith/swift.vim'
|
Plug 'keith/swift.vim'
|
||||||
|
|
||||||
|
" Latex, I guess? Have to check if I actually need this.
|
||||||
Plug 'LaTeX-Box-Team/LaTeX-Box'
|
Plug 'LaTeX-Box-Team/LaTeX-Box'
|
||||||
|
|
||||||
|
" I use it as my snippet manager, but it is actually for HTML.
|
||||||
Plug 'mattn/emmet-vim'
|
Plug 'mattn/emmet-vim'
|
||||||
|
|
||||||
|
" Necessary to use my emmet json snippet file
|
||||||
Plug 'mattn/webapi-vim'
|
Plug 'mattn/webapi-vim'
|
||||||
|
|
||||||
|
" vue support
|
||||||
Plug 'posva/vim-vue'
|
Plug 'posva/vim-vue'
|
||||||
|
|
||||||
|
" Makes (un)commenting out stuff much easier.
|
||||||
|
Plug 'preservim/nerdcommenter'
|
||||||
|
|
||||||
|
" My light theme.
|
||||||
|
Plug 'NLKNguyen/papercolor-theme'
|
||||||
|
|
||||||
|
" File browser
|
||||||
Plug 'scrooloose/nerdtree'
|
Plug 'scrooloose/nerdtree'
|
||||||
|
|
||||||
|
" Language pack for most languages I use.
|
||||||
Plug 'sheerun/vim-polyglot'
|
Plug 'sheerun/vim-polyglot'
|
||||||
|
|
||||||
|
" Git support for vim
|
||||||
Plug 'tpope/vim-fugitive'
|
Plug 'tpope/vim-fugitive'
|
||||||
|
|
||||||
|
" Change surrounding stuff fast and reliable
|
||||||
Plug 'tpope/vim-surround'
|
Plug 'tpope/vim-surround'
|
||||||
|
|
||||||
|
" Status line for the bottom of the screen (and a themes pack)
|
||||||
Plug 'vim-airline/vim-airline'
|
Plug 'vim-airline/vim-airline'
|
||||||
Plug 'vim-airline/vim-airline-themes'
|
Plug 'vim-airline/vim-airline-themes'
|
||||||
Plug 'Yilin-Yang/vim-markbar'
|
|
||||||
|
" Shows vertical lines to make indents more visible
|
||||||
|
Plug 'Yggdroot/indentLine'
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
|
|
@ -107,8 +156,8 @@ augroup END
|
||||||
" Softtabs, 4 spaces
|
" Softtabs, 4 spaces
|
||||||
set tabstop=4
|
set tabstop=4
|
||||||
set shiftwidth=4
|
set shiftwidth=4
|
||||||
set shiftround
|
set shiftround " Tabs are rounded to multiples of shiftwidth
|
||||||
set expandtab
|
set expandtab " Tabs are spaces
|
||||||
|
|
||||||
" Display extra whitespace
|
" Display extra whitespace
|
||||||
set list listchars=tab:»·,trail:·,nbsp:·
|
set list listchars=tab:»·,trail:·,nbsp:·
|
||||||
|
|
@ -116,27 +165,23 @@ set list listchars=tab:»·,trail:·,nbsp:·
|
||||||
" Use one space, not two, after punctuation.
|
" Use one space, not two, after punctuation.
|
||||||
set nojoinspaces
|
set nojoinspaces
|
||||||
|
|
||||||
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
|
" Make it obvious where 80 characters is (Python only)
|
||||||
"if executable('ag')
|
autocmd FileType python setlocal colorcolumn=81
|
||||||
" " Use Ag over Grep
|
|
||||||
" set grepprg=ag\ --nogroup\ --nocolor
|
|
||||||
|
|
||||||
" " Use ag in fzf for listing files. Lightning fast and respects .gitignore
|
" Highlight "self." in different color in python files:
|
||||||
" let $FZF_DEFAULT_COMMAND = 'ag --literal --files-with-matches --nocolor --hidden -g ""'
|
augroup python_syntax_extra
|
||||||
|
autocmd!
|
||||||
|
autocmd! Syntax python :syn keyword Keyword self
|
||||||
|
augroup END
|
||||||
|
|
||||||
" if !exists(":Ag")
|
" Line numbers with the width of 5 digits
|
||||||
" command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
|
|
||||||
" nnoremap \ :Ag<SPACE>
|
|
||||||
" endif
|
|
||||||
"endif
|
|
||||||
|
|
||||||
" Make it obvious where 80 characters is
|
|
||||||
autocmd FileType python setlocal textwidth=80 colorcolumn=+1
|
|
||||||
|
|
||||||
" Numbers
|
|
||||||
set number
|
set number
|
||||||
set numberwidth=5
|
set numberwidth=5
|
||||||
|
|
||||||
|
" Relative line numbers, but real line number for current line
|
||||||
|
set number relativenumber
|
||||||
|
set nu rnu
|
||||||
|
|
||||||
" Autocomplete menu for command mode
|
" Autocomplete menu for command mode
|
||||||
set wildmenu
|
set wildmenu
|
||||||
set wildmode=longest:full,full
|
set wildmode=longest:full,full
|
||||||
|
|
@ -157,15 +202,6 @@ set complete+=kspell
|
||||||
"Autocompletion syntax:
|
"Autocompletion syntax:
|
||||||
set omnifunc=syntaxcomplete#Complete
|
set omnifunc=syntaxcomplete#Complete
|
||||||
|
|
||||||
" Local config
|
|
||||||
if filereadable($HOME . "/.vimrc.local")
|
|
||||||
source ~/.vimrc.local
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Relative line numbers, but real line number for current line
|
|
||||||
set number relativenumber
|
|
||||||
set nu rnu
|
|
||||||
|
|
||||||
" Keep 8 rows above and below the kk
|
" Keep 8 rows above and below the kk
|
||||||
set scrolloff=8
|
set scrolloff=8
|
||||||
|
|
||||||
|
|
@ -173,6 +209,10 @@ set scrolloff=8
|
||||||
nnoremap j gj
|
nnoremap j gj
|
||||||
nnoremap k gk
|
nnoremap k gk
|
||||||
|
|
||||||
|
" Use e and E to jump to start or end of a line.
|
||||||
|
nnoremap e ^
|
||||||
|
nnoremap E $
|
||||||
|
|
||||||
" Do not cut words when breaking lines.
|
" Do not cut words when breaking lines.
|
||||||
set linebreak
|
set linebreak
|
||||||
|
|
||||||
|
|
@ -181,6 +221,12 @@ set ignorecase
|
||||||
set smartcase
|
set smartcase
|
||||||
set hlsearch
|
set hlsearch
|
||||||
|
|
||||||
|
" Stop highlighting search results.
|
||||||
|
nnoremap <leader><space> :nohlsearch<CR>
|
||||||
|
|
||||||
|
" Search replace bind:
|
||||||
|
nnoremap S :%s//g<Left><Left>
|
||||||
|
|
||||||
" Strip trailing whitespaces on each save
|
" Strip trailing whitespaces on each save
|
||||||
fun! <SID>StripTrailingWhitespaces()
|
fun! <SID>StripTrailingWhitespaces()
|
||||||
let l = line(".")
|
let l = line(".")
|
||||||
|
|
@ -191,27 +237,17 @@ endfun
|
||||||
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
|
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
|
||||||
|
|
||||||
" Indent and unindent with tab.
|
" Indent and unindent with tab.
|
||||||
|
|
||||||
nnoremap <Tab> >>_
|
nnoremap <Tab> >>_
|
||||||
nnoremap <S-Tab> <<_
|
nnoremap <S-Tab> <<_
|
||||||
inoremap <S-Tab> <C-D>
|
inoremap <S-Tab> <C-D>
|
||||||
vnoremap <Tab> >gv
|
vnoremap <Tab> >gv
|
||||||
vnoremap <S-Tab> <gv
|
vnoremap <S-Tab> <gv
|
||||||
|
|
||||||
" Fuzzy file search by default:
|
|
||||||
set path+=**
|
|
||||||
|
|
||||||
"Python paths (installed with "pip3 install <package> --user)
|
|
||||||
"let $PATH.=':' . $HOME . '/Library/Python/3.7/'
|
|
||||||
|
|
||||||
" Remap buffer navigation:
|
" Remap buffer navigation:
|
||||||
map gn :bn<cr>
|
map gn :bn<cr>
|
||||||
map gN :bp<cr>
|
map gN :bp<cr>
|
||||||
map gp :bp<cr>
|
map gp :bp<cr>
|
||||||
|
|
||||||
" indent for curly brackets:
|
|
||||||
"inoremap {<cr> {<cr>}<c-o><s-o>
|
|
||||||
|
|
||||||
" Toggle through splits:
|
" Toggle through splits:
|
||||||
nnoremap <leader>w <C-w>w
|
nnoremap <leader>w <C-w>w
|
||||||
nnoremap <leader>W <C-w>W
|
nnoremap <leader>W <C-w>W
|
||||||
|
|
@ -221,20 +257,16 @@ let g:user_emmet_leader_key=','
|
||||||
let g:user_emmet_settings = webapi#json#decode(join(readfile(expand('~/.vim/customizations/vim-emmet-mysnippets.json')), "\n"))
|
let g:user_emmet_settings = webapi#json#decode(join(readfile(expand('~/.vim/customizations/vim-emmet-mysnippets.json')), "\n"))
|
||||||
|
|
||||||
" jedi-vim:
|
" jedi-vim:
|
||||||
|
let g:jedi#popup_on_dot = 1
|
||||||
let g:jedi#popup_on_dot = 0
|
|
||||||
|
|
||||||
|
|
||||||
" Peekaboo window width
|
" Peekaboo window width
|
||||||
let g:peekaboo_window = 'vert bo 65new'
|
let g:peekaboo_window = 'vert bo 65new'
|
||||||
|
|
||||||
|
|
||||||
" javacomplete2
|
" javacomplete2
|
||||||
autocmd FileType java setlocal omnifunc=javacomplete#Complete
|
autocmd FileType java setlocal omnifunc=javacomplete#Complete
|
||||||
|
|
||||||
|
|
||||||
" tasklist settings
|
" tasklist settings
|
||||||
let g:tlTokenList = ["FIXME", "TODO", "todo"]
|
let g:tlTokenList = ["FIXME", "TODO", "todo"] " keywords for todos
|
||||||
let g:tlWindowPosition = 1 "Open window on bottom, 0 would be top
|
let g:tlWindowPosition = 1 "Open window on bottom, 0 would be top
|
||||||
let g:tlRememberPosition = 0
|
let g:tlRememberPosition = 0
|
||||||
map <leader>t <Plug>TaskList
|
map <leader>t <Plug>TaskList
|
||||||
|
|
@ -246,28 +278,23 @@ map <C-n> :NERDTreeToggle<CR>
|
||||||
let g:airline#extensions#tabline#enabled = 1 " Show buffers as tabs
|
let g:airline#extensions#tabline#enabled = 1 " Show buffers as tabs
|
||||||
|
|
||||||
" ale settings
|
" ale settings
|
||||||
|
|
||||||
|
|
||||||
let g:ale_linters = {'python': ['flake8', 'mypy', 'pylint', 'prospector']}
|
let g:ale_linters = {'python': ['flake8', 'mypy', 'pylint', 'prospector']}
|
||||||
|
|
||||||
let g:ale_fixers = {'python': ['isort', 'black'],
|
let g:ale_fixers = {'python': ['isort', 'black'],
|
||||||
\'json': ['fixjson'],
|
\'json': ['fixjson'],
|
||||||
\'java': ['uncrustify'],
|
\'java': ['uncrustify'],
|
||||||
\'tex': ['latexindent']}
|
\'tex': ['latexindent']}
|
||||||
|
|
||||||
|
|
||||||
" Install the linter and fixer for a specific language automatically
|
" colorscheme toggle dark/light:
|
||||||
|
|
||||||
command InstallLinterFixPython python3 import pip; [pip.main(["install", singlepackage, "--user"]) for singlepackage in "flake8 pylint mypy prospector black isort".split(" ")]
|
|
||||||
|
|
||||||
|
|
||||||
" colorscheme toggle:
|
|
||||||
|
|
||||||
function! s:SwitchColorscheme()
|
function! s:SwitchColorscheme()
|
||||||
if g:colors_name == 'darcula'
|
if g:colors_name == 'darcula'
|
||||||
colorscheme default
|
set background=light
|
||||||
|
colorscheme PaperColor
|
||||||
|
AirlineTheme papercolor
|
||||||
else
|
else
|
||||||
colorscheme darcula
|
colorscheme darcula
|
||||||
|
set background=dark
|
||||||
|
AirlineTheme dark
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
map <silent> <F4> :call <SID>SwitchColorscheme()<CR>
|
map <silent> <F4> :call <SID>SwitchColorscheme()<CR>
|
||||||
|
|
@ -275,7 +302,6 @@ map <silent> <F4> :call <SID>SwitchColorscheme()<CR>
|
||||||
colorscheme darcula
|
colorscheme darcula
|
||||||
|
|
||||||
" Highlight whole todo comment, not just the keyword itself:
|
" Highlight whole todo comment, not just the keyword itself:
|
||||||
|
|
||||||
augroup myTodo
|
augroup myTodo
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd Syntax * syntax match myTodo /\v\_.<(TODO|FIXME|todo|fixme).*/hs=s+1 containedin=.*Comment
|
autocmd Syntax * syntax match myTodo /\v\_.<(TODO|FIXME|todo|fixme).*/hs=s+1 containedin=.*Comment
|
||||||
|
|
@ -296,3 +322,28 @@ augroup END
|
||||||
" Bind ctrl+u to jump list jump (opposite of ctrl+o)
|
" Bind ctrl+u to jump list jump (opposite of ctrl+o)
|
||||||
nnoremap <C-u> <C-i>
|
nnoremap <C-u> <C-i>
|
||||||
|
|
||||||
|
" Load changes to a file automatically from drive if the file has not been
|
||||||
|
" changed yet
|
||||||
|
set autoread
|
||||||
|
|
||||||
|
" Generate help tags to find the docs with :help
|
||||||
|
"if !empty((globpath(&rtp, '~/.vim/doc/**'))
|
||||||
|
" helptags ~/.vim/doc
|
||||||
|
"endif
|
||||||
|
|
||||||
|
" Use persistent history. (so undo from older sessions can be used)
|
||||||
|
if !isdirectory("$HOME/.vim/.vim-undo-dir")
|
||||||
|
silent !mkdir -p $HOME/.vim/.vim-undo-dir
|
||||||
|
endif
|
||||||
|
set undodir=$HOME/.vim/.vim-undo-dir
|
||||||
|
set undofile
|
||||||
|
|
||||||
|
" Set the character which is used as tab indent marker
|
||||||
|
let g:indentLine_char = '┊'
|
||||||
|
|
||||||
|
" Load local config if there is one
|
||||||
|
if filereadable($HOME . "/.vimrc.local")
|
||||||
|
source ~/.vimrc.local
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue