snippets/nvim-config/init.vim

407 lines
12 KiB
VimL
Raw Normal View History

2022-07-19 16:01:46 +00:00
call plug#begin('~/.local/share/nvim/site/plugged')
" airline
Plug 'https://github.com/bling/vim-airline.git'
Plug 'vim-airline/vim-airline-themes'
" git
Plug 'https://github.com/tpope/vim-fugitive.git'
" Shougos UI-Plugin
Plug 'Shougo/denite.nvim'
" Plug 'roxma/nvim-completion-manager'
" showing function-signatures/doc on completion
Plug 'Shougo/echodoc.vim'
" Tab-Completion
" Plug 'ervandew/supertab'
" vim-sourround
Plug 'https://github.com/tpope/vim-surround.git'
" theme
Plug 'https://github.com/morhetz/gruvbox.git'
Plug 'frankier/neovim-colors-solarized-truecolor-only'
" rainbow-parentethies
Plug 'luochen1990/rainbow'
" search in files/buffers for filenames - replaced by fzf
" Plug 'https://github.com/ctrlpvim/ctrlp.vim.git'
" fuzzy finder
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" show buffers in statusline
" Plug 'bling/vim-bufferline'
" git-gutter (little + - and ~ left)
Plug 'https://github.com/airblade/vim-gitgutter.git'
" apply hlint-suggestions
" Plug 'https://github.com/mpickering/hlint-refactor-vim.git'
" Tabular
Plug 'https://github.com/godlygeek/tabular.git'
" Shakespearian template-highlighting
" Plug 'https://github.com/pbrisbin/vim-syntax-shakespeare.git'
" Multiline-Comments
Plug 'tomtom/tcomment_vim'
" Auto-Formatting
Plug 'Chiel92/vim-autoformat'
" show colors (#abc) with that background-color
Plug 'ap/vim-css-color'
" multiline-stuff
Plug 'terryma/vim-multiple-cursors'
" Icons
Plug 'ryanoasis/vim-devicons'
" Markdown-Support
Plug 'plasticboy/vim-markdown'
Plug 'dhruvasagar/vim-table-mode'
Plug 'suan/vim-instant-markdown'
" Code-Folds
Plug 'tmhedberg/SimpylFold'
" better closing
Plug 'mhinz/vim-sayonara'
" Session-Management
Plug 'xolox/vim-session' | Plug 'xolox/vim-misc'
" CoC
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
" SETTINGS
" recommended by syntastic
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*
" set statusline+=%{fugitive#statusline()}
"
" let g:syntastic_always_populate_loc_list = 1
" let g:syntastic_auto_loc_list = 1
" let g:syntastic_check_on_open = 1
" let g:syntastic_check_on_wq = 0
" use autocompletion
let g:deoplete#enable_at_startup = 1
" in case of problems with stack..
" g:necoghc_use_stack = 1
" set leader to space
let mapleader= "\<SPACE>"
" autocmd InsertEnter * :set number
" autocmd InsertEnter * :set norelativenumber
" autocmd InsertLeave * :set relativenumber
" autocmd InsertLeave * :set nonumber
set relativenumber
set number
set shiftwidth=2
set tabstop=2
" show cmd - especially leader
set showcmd
" expand tabs with spaces
set expandtab
" Tell Vim which characters to show for expanded TABs,
" trailing whitespace, and end-of-lines. VERY useful!
if &listchars ==# 'eol:$'
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
endif
set list " Show problematic characters.
" Also highlight all tabs and trailing whitespace characters.
highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
match ExtraWhitespace /\s\+$\|\t/
set hlsearch " Highlight search results.
set ignorecase " Make searching case insensitive
set smartcase " ... unless the query has capital letters.
set incsearch " Incremental search.
set gdefault " Use 'g' flag by default with :s/foo/bar/.
set magic " Use 'magic' patterns (extended regular expressions).
"set inccommand=nosplit " Use live-preview of search/replace etc.
set conceallevel=2 " Allow things to be visually opressed (i.e. *foo* be italic)
set mouse=a " enable mouse
set foldenable " enable folding
set undofile " enable undo over sessions
set undodir="$HOME/.VIM_UNDO_FILES" " save in this path
set laststatus=3 " only 1 statusline, not 1 per window
highlight WinSeperator guibg=None
set hidden
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
endif
" Remember cursor position between vim sessions
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
" center buffer around cursor when opening files
autocmd BufRead * normal zz
"" KEY-BINDINGS
" use <TAB> to fold/unfold
nnoremap <TAB> za
" <Tab>: completion
function! CheckBackSpace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
inoremap <silent><expr> <Tab>
\ pumvisible() ? "\<C-N>" :
\ CheckBackSpace() ? "\<Tab>" :
\ coc#refresh()
" <S-Tab>: completion back
inoremap <silent><expr> <S-Tab> pumvisible() ? "\<C-P>" : "\<C-H>"
" <CR>: confirm completion, or insert <CR>
inoremap <expr> <CR> pumvisible() ? "\<C-Y>" : "\<CR>"
" use <C-J> to Jump to definition instead of <C-]> (default)
nnoremap <C-J> <C-]>
" c-d to delete line in insert-mode
inoremap <C-D> <esc>ddi
" exit terminal-mode
tnoremap <C-t><C-t> <C-\><C-n>
" autoformat code if possible (read docs on vim-autoformat!)
noremap <leader>f :Autoformat<CR>
noremap <leader>TM :TableModeToggle<CR>
" multi-cursor
let g:multi_cursor_next_key='<C-n>'
let g:multi_cursor_prev_key='<C-p>'
let g:multi_cursor_skip_key='<C-x>'
let g:multi_cursor_quit_key='<Esc>'
" Align blocks of text and keep them selected
vmap < <gv
vmap > >gv
nnoremap <leader>d "_d
vnoremap <leader>d "_d
" toggle comments
vnoremap <leader>/ :TComment<cr>
" Open file menu
nnoremap <Leader>o :Files<CR>
" Open buffer menu
nnoremap <Leader>b :Buffers<CR>
" Open most recently used files
nnoremap <Leader>f :GFiles<CR>
" Open Tag-Search
nnoremap <Leader>t :Tags<CR>
" Open File-Tree on left side
nmap <C-t> :NERDTreeToggle<CR>
" Expand patterns in Haskell
"nnoremap <Leader>hc :GhcModSplitFunCase<CR>
" Expand function signatures in Haskell
"nnoremap <Leader>hs :GhcModSigCodegen<CR>
" Get Type-Info under Cursor
"nnoremap <Leader>ht :GhcModType<CR>
" " Copy to clipboard
vnoremap <leader>y "+y
nnoremap <leader>Y "+yg_
nnoremap <leader>y "+y
nnoremap <leader>yy "+yy
" " Paste from clipboard
nnoremap <leader>p "+p
nnoremap <leader>P "+P
vnoremap <leader>p "+p
vnoremap <leader>P "+P
" disable syntastic for haskell
let g:syntastic_haskell_checkers=['']
" Clear stuff
nnoremap <Leader><Leader> :nohlsearch<CR>:cclose<CR>
" THEME-RELATED STUFF
syntax enable
" enable true color
set termguicolors
" enable italics, load colorscheme
let g:gruvbox_italic=1
set background=dark
colorscheme gruvbox
let g:rainbow_active = 1
let &colorcolumn="80,".join(range(120,200),",")
" spell checking for markdown
autocmd BufRead,BufNewFile *.md setlocal spell complete+=kspell textwidth=80
autocmd BufRead,BufNewFile *.markdown setlocal spell complete+=kspell textwidth=80
autocmd BufRead,BufNewFile *.md hi SpellBad guibg=#582828 gui=none
autocmd BufRead,BufNewFile *.markdown hi SpellBad guibg=#582828 gui=none
autocmd FileType markdown nnoremap <Leader>t :Toc<CR>
" set languages to english and german
set spelllang=de_de,en_us
let g:vim_markdown_toc_autofit = 1
let g:vim_markdown_emphasis_multiline = 1
let g:vim_markdown_math = 1
let g:vim_markdown_new_list_item_indent = 2
let g:vim_markdown_folding_level = 6
" disable instant-markdown-preview
let g:instant_markdown_autostart = 0
au FileType markdown setl shell=bash
let g:haskell_enable_quantification = 1 " enable highlighting of forall
let g:haskell_enable_recursivedo = 1 " enable highlighting of mdo and rec
let g:haskell_enable_arrowsyntax = 1 " enable highlighting of proc
let g:haskell_enable_pattern_synonyms = 1 " enable highlighting of pattern
let g:haskell_enable_typeroles = 1 " enable highlighting of type roles
let g:haskell_enable_static_pointers = 1 " enable highlighting of static
let g:haskell_indent_if = 3
let g:haskell_indent_case = 2
let g:haskell_indent_let = 4
let g:haskell_indent_where = 6
let g:haskell_indent_do = 3
let g:haskell_indent_in = 1
let g:haskell_indent_guard = 2
" NERDTREE
map <C-t> :NERDTreeToggle<CR>
autocmd StdinReadPre * let s:std_in=1
let NERDTreeShowHidden=1
let g:NERDTreeWinSize=45
let g:NERDTreeAutoDeleteBuffer=1
function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg)
exec 'autocmd FileType nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg
exec 'autocmd FileType nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'
endfunction
call NERDTreeHighlightFile('jade', 'green', 'none', 'green', '#141e23')
call NERDTreeHighlightFile('ini', 'yellow', 'none', 'yellow', '#141e23')
call NERDTreeHighlightFile('md', 'blue', 'none', '#3366FF', '#141e23')
call NERDTreeHighlightFile('yml', 'yellow', 'none', 'yellow', '#141e23')
call NERDTreeHighlightFile('config', 'yellow', 'none', 'yellow', '#141e23')
call NERDTreeHighlightFile('conf', 'yellow', 'none', 'yellow', '#141e23')
call NERDTreeHighlightFile('json', 'yellow', 'none', 'yellow', '#141e23')
call NERDTreeHighlightFile('html', 'yellow', 'none', 'yellow', '#141e23')
call NERDTreeHighlightFile('styl', 'cyan', 'none', 'cyan', '#141e23')
call NERDTreeHighlightFile('css', 'cyan', 'none', 'cyan', '#141e23')
call NERDTreeHighlightFile('coffee', 'Red', 'none', 'red', '#141e23')
call NERDTreeHighlightFile('js', 'Red', 'none', '#ffa500', '#141e23')
call NERDTreeHighlightFile('ts', 'Blue', 'none', '#6699cc', '#141e23')
call NERDTreeHighlightFile('hs', 'Blue', 'none', '#6699cc', '#141e23')
call NERDTreeHighlightFile('php', 'Magenta', 'none', '#ff00ff', '#141e23')
call NERDTreeHighlightFile('ds_store', 'Gray', 'none', '#686868', '#141e23')
call NERDTreeHighlightFile('gitconfig', 'Gray', 'none', '#686868', '#141e23')
call NERDTreeHighlightFile('gitignore', 'Gray', 'none', '#686868', '#141e23')
call NERDTreeHighlightFile('bashrc', 'Gray', 'none', '#686868', '#141e23')
call NERDTreeHighlightFile('bashprofile', 'Gray', 'none', '#686868', '#141e23')
" SNIPPETS
" " Emmet customization
" " Enable Emmet in all modes
" " Remapping <C-y>, just doesn't cut it.
" function! s:expand_html_tab()
" " try to determine if we're within quotes or tags.
" " if so, assume we're in an emmet fill area.
" let line = getline('.')
" if col('.') < len(line)
" let line = matchstr(line, '[">][^<"]*\%'.col('.').'c[^>"]*[<"]')
" if len(line) >= 2
" return "\<C-n>"
" endif
" endif
" " expand anything emmet thinks is expandable.
" if emmet#isExpandable()
" return "\<C-y>,"
" endif
" " return a regular tab character
" return "\<tab>"
" endfunction
" autocmd FileType html,markdown imap <buffer><expr><tab> <sid>expand_html_tab()
" let g:user_emmet_mode='a'
" let g:user_emmet_complete_tag = 1
" let g:user_emmet_install_global = 0
" autocmd FileType html,css EmmetInstall
" AIRLINE
let g:airline#extensions#tabline#ignore_bufadd_pat = 'gundo|undotree|vimfiler|tagbar|nerd_tree|startify|!'
let g:airline#extensions#tabline#enabled = 1
set hidden
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#show_tab_nr = 1
let g:airline_powerline_fonts = 1
let g:airline_theme='understated'
" let g:airline_theme='base16_solarized'
cnoreabbrev <expr> x getcmdtype() == ":" && getcmdline() == 'x' ? 'Sayonara' : 'x'
nmap <leader>tt :term<cr>
nmap <leader>, :bnext<CR>
nmap <leader>. :bprevious<CR>
let g:airline#extensions#tabline#buffer_idx_mode = 1
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
set guifont=Sauce\ Code\ Pro\ Nerd\ Font\ Complete:h13
" TABULARIZE
nmap <leader>t: :Tabularize /:: /l1c0l0<CR>
nmap <leader>t= :Tabularize /= /l1c0l0<CR>
nmap <leader>tp :Tabularize /\| /l1c0l0<CR>
nmap <leader>t, :Tabularize /, /l1c0l0<CR>
" Table mode
let g:table_mode_corner_corner="+"
let g:table_mode_header_fillchar="="
" Move between windows
nnoremap <M-Left> <C-W><C-H>
nnoremap <M-Down> <C-W><C-J>
nnoremap <M-Up> <C-W><C-K>
nnoremap <M-Right> <C-W><C-L>
" Move between tabs
nnoremap <M-Home> :bNext<CR>
nnoremap <M-End> :bnext<CR>
" Session-Options
let g:session_autoload='yes'
let g:session_autosave='yes'
" Change background quickly
nmap <F9> :let &background = ( &background == "dark" ? "light" : "dark" )<CR>
" BUGFIX UNTIL #6997 gets meged.
set guicursor=