execute pathogen#infect()

syntax on
filetype plugin indent on

" Theming
if $TERM != 'linux' && version >= 800
	colorscheme gruvbox
	set termguicolors
	set background=dark
endif

set autoread " Automatically read when a file is changed outside of Vim
set clipboard=unnamedplus " Use XA_PRIMARY clipboard by default
set encoding=utf-8
set hidden " Allow buffer switching without saving
set incsearch " Search while you type
set laststatus=2 " Always show statusbar
set list
set listchars=tab:>·,trail:·
set modeline
set modelines=5
set number
set t_Co=256
set viminfo='20,<1000,s1000 " Increase buffer size
set updatetime=100
" Folding
set foldmethod=syntax
"nnoremap <space> za
set nofoldenable " Fuck autofolding

" ALE
let g:ale_completion_enabled = 1
set completeopt=menu,menuone,noselect
let g:ale_linters = {
	\	'python':	['pylsp', 'ruff'],
	\}
let g:ale_fixers = {
	\	'*':		['remove_trailing_lines', 'trim_whitespace'],
	\	'python':	['ruff_format'],
	\}
let g:ale_fix_on_save = 1

" Tab completion on ALE
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<BS>"

" Lightline
set noshowmode
let g:lightline = {
	\	'active': {
	\		'left':		[
	\				[ 'mode', 'paste' ],
	\				[ 'readonly', 'filename', 'modified' ],
	\				[ 'charvaluehex' ]
	\				],
	\		'right':	[
	\				[ 'lineinfo' ],
	\				[ 'percent' ],
	\				[ 'fileformat', 'fileencoding', 'filetype' ]
	\				]
	\	},
	\	'component': {
	\		'charvaluehex': 'char: 0x%B'
	\	},
	\}
let g:lightline.colorscheme = 'gruvbox'
hi Normal guibg=NONE ctermbg=NONE

" Jenkinsfile
au BufNewFile,BufRead Jenkinsfile setf groovy
" Json
au BufNewFile,BufRead *.json
	\ set tabstop=2 |
	\ set softtabstop=2 |
	\ set shiftwidth=2 |
	\ set autoindent |
	\ set smartindent
" Python
au BufNewFile,BufRead *.py " Set up nice PEP8 indentation
	\ set tabstop=4 |
	\ set softtabstop=4 |
	\ set shiftwidth=4 |
	\ set textwidth=79 |
	\ set expandtab |
	\ set autoindent |
	\ set fileformat=unix
" HTML
au BufNewFile,BufRead *.html,*.php
	\ set tabstop=2 |
	\ set softtabstop=2 |
	\ set shiftwidth=2 |
	\ set autoindent |
	\ set smartindent
" Treat PHP like HTML
au BufNewFile,BufRead *.php
	\ set filetype=html
au FileType yaml
	\ set tabstop=2 |
	\ set softtabstop=2 |
	\ set shiftwidth=2
