dotfiles/nvim/init.vim

134 lines
3.3 KiB
VimL
Executable file

" vim:set ts=2 sw=2 et:
"
" This configuration depends on the following plugins:
" nerdtree: https://github.com/scrooloose/nerdtree
" vim-polygot: https://github.com/sheerun/vim-polyglot
" coc: https://github.com/neoclide/coc.nvim
" indent, load plugin and detect filetype depending on filetype
filetype indent plugin on
set autoindent
" fix different locale settings when ssh'ing
set encoding=utf-8
" replace vertical split pipe character with space
set fillchars="vert:\ |,fold:\ "
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
set splitright
set splitbelow
set termguicolors
let current_time = strftime("%H")
" colorscheme based on time
if current_time > 11 && current_time < 17
colorscheme xcodelight
else
set background=dark
colorscheme space_vim_theme
endif
" syntax on
syntax on
" switch buffers without writing to file
set hidden
" file specific formatting
autocmd Filetype python,bash,sh,java,php,json setlocal tabstop=4 softtabstop=4 shiftwidth=4 expandtab autoindent fileformat=unix
autocmd Filetype css,scss,html,htmldjango,javascript,yaml setlocal tabstop=2 softtabstop=2 shiftwidth=2 expandtab autoindent
" open folds by default
autocmd Syntax * normal zR
" fold indents
set foldmethod=indent
" Don't open folds when jumping over one with (, {, [[ or [{
set foldopen-=block
" search down into subfolders
" provides tab-completion for all file-related tasks
set path+=**
" display all matching files when we tab complete
set wildmenu
" use normal backspace behavior
set backspace=2
" allow arrow keys to be used
set nocompatible
" Color trailing spaces with red color
highlight ExtraWhitespace ctermbg=green guibg=green
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" line numbers
set number
" changes to current directory when creating new files
set autochdir
" higlhight search
set hls
" search as characters are entered
set incsearch
" line for linewrapping
set colorcolumn=80
" wrap text instead of being on one line
set lbr
" default Colors for CursorLine
set cursorline
highlight CursorLine cterm=NONE
" activate statusbar
set laststatus=2
set statusline=\ %F\ %m%r%w\ %=\ %{hostname()}\ \ \ %{strlen(&ft)?&ft:'none'}\ %{(&bomb?\",BOM\":\"\")}\ %{&ff}\ \ %l/%L\ \ %c\ %P
" use <tab> for trigger completion and navigate to the next complete item
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
" tab completion
inoremap <silent><expr> <Tab>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<Tab>" :
\ coc#refresh()
" open nerdtree browser
map <silent> <C-E> :NERDTreeToggle <CR>
" default coc extensions
" see https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions#install-extensions
" installed if not detected to ~/.config/coc/extensions
let g:coc_global_extensions = [
\'coc-pyright',
\'coc-html',
\'coc-htmldjango',
\'coc-css',
\'coc-tsserver',
\'coc-git',
\'coc-json',
\'coc-yaml'
\]
if filereadable(expand('~/.config/nvim/override.vim'))
source ~/.config/nvim/override.vim
endif