Last active
January 18, 2024 11:17
-
-
Save fliphess/20109923794b05b9278e1785c2fc4536 to your computer and use it in GitHub Desktop.
Vim config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Load plugin manager | |
"" | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Download vim-plug if not already installed | |
if empty(glob('~/.vim/autoload/plug.vim')) | |
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs | |
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
autocmd VimEnter * PlugInstall | source $MYVIMRC | |
endif | |
" Specify a directory for plugins | |
call plug#begin('~/.vim/plugged') | |
" Base modules | |
Plug 'tpope/vim-commentary' | |
Plug 'tpope/vim-sensible' | |
Plug 'tpope/vim-markdown' | |
Plug 'tpope/vim-fugitive' | |
Plug 'pbrisbin/vim-mkdir' | |
Plug 'dense-analysis/ale' | |
Plug 'itchyny/lightline.vim' | |
Plug 'maximbaz/lightline-ale' | |
Plug 'editorconfig/editorconfig-vim' | |
Plug 'junegunn/vim-easy-align' | |
Plug 'vitalk/vim-shebang' | |
Plug 'davidhalter/jedi-vim' | |
Plug 'hugoh/vim-alestatuslineflag' | |
" Language syntax | |
Plug 'vim-python/python-syntax' " Python | |
Plug 'vim-scripts/php.vim' " PHP | |
Plug 'aliou/bats.vim' " Bats | |
Plug 'towolf/vim-helm' " Helm | |
Plug 'ekalinin/Dockerfile.vim' " Docker | |
Plug 'andrewstuart/vim-kubernetes' " K8S | |
Plug 'hashivim/vim-terraform' " Terraform | |
Plug 'cespare/vim-toml' " Toml | |
Plug 'elzr/vim-json' " Json | |
Plug 'vim-scripts/crontab.vim' " Crontab | |
Plug 'chr4/nginx.vim' " Nginx | |
Plug 'Glench/Vim-Jinja2-Syntax' " Jinja | |
Plug 'egberts/vim-syntax-bind-named' " Bind | |
" Fuzzy finder | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'nanotee/zoxide.vim' | |
" Initialize plugin system | |
call plug#end() | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Personal vim settings | |
"" | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Display extra whitespace | |
set list listchars=tab:»·,trail:·,nbsp:· | |
" Use one space, not two, after punctuation. | |
set nojoinspaces | |
set noshowmode | |
set autowrite | |
set expandtab | |
set hidden | |
set linebreak | |
set smartcase | |
set termguicolors | |
set title | |
set background=dark | |
set backspace=2 | |
set tabstop=4 | |
set shiftwidth=4 | |
set signcolumn=no | |
set laststatus=2 | |
set nocompatible | |
set foldmethod=indent | |
set foldnestmax=10 | |
set nofoldenable | |
set foldlevel=2 | |
set wrap linebreak nolist | |
set rtp+=/usr/local/opt/fzf | |
filetype plugin on | |
filetype plugin indent on | |
syntax enable | |
if has("autocmd") | |
filetype indent on | |
endif | |
if !has('gui_running') | |
set t_Co=256 | |
endif | |
" Do not enter replace mode on insert | |
imap <INS> <NoP> | |
" close a buffer without closing the current split | |
nnoremap <leader>d :b#\|bd # | |
" Set mapleader to space | |
let mapleader = " " | |
" When editing a file, always jump to the last known cursor position. | |
" Don't do it for commit messages, when the position is invalid, or when | |
" inside an event handler (happens when dropping a file on gvim). | |
autocmd BufReadPost * | |
\ if &ft != 'gitcommit' && line("'\"") >= 1 && line("'\"") <= line("$") | | |
\ exe "normal g`\"" | | |
\ endif | |
AddShebangPattern! sh ^#!.*/bin/env\s\+toolset\> | |
AddShebangPattern! sh ^#!.*/bin/env\s\+bash\> | |
AddShebangPattern! sh ^#!.*/bin/bash> | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Autoreplace | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
iab functino function | |
iab fucntino function | |
iab pipelien pipeline | |
iab variabel variable | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Syntax and file detection | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Bash | |
au FileType sh let g:sh_fold_enabled=5 | |
au FileType sh let g:is_bash=1 | |
au FileType sh set foldmethod=indent | |
au FileType sh set foldnestmax=10 | |
au FileType sh set foldlevel=2 | |
" recognize ssh config files | |
au BufNewFile,BufRead */ssh/config,*/.ssh/config.d/*,*/.ssh/local.cfg set filetype=sshconfig | |
" recognize all Markdown files | |
autocmd BufNewFile,BufReadPost *.md set filetype=markdown | |
autocmd BufRead,BufNewFile *.md setlocal textwidth=80 | |
" Set syntax to terraform for all hcl files | |
autocmd BufRead,BufNewFile *.hcl set filetype=terraform | |
" Highliting for ansible | |
autocmd BufRead,BufNewFile */playbooks/*.yml set filetype=yaml.ansible | |
" Highliting for helm | |
autocmd BufRead,BufNewFile */charts/*.yaml,*/charts/*.tpl set filetype=helm | |
" Yaml | |
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab | |
" In makefiles DO NOT use spaces instead of tabs | |
autocmd FileType make setlocal noexpandtab | |
" For go do not expandtabs either | |
autocmd BufRead,BufNewFile *.go setlocal noexpandtab | |
" FT for dockerfiles | |
autocmd BufNewFile,BufReadPost Dockerfile.*,Dockerfile.* set filetype=dockerfile | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Plugin Settings | |
"" | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
let g:lightline = { | |
\ 'active': { | |
\ 'left': [ | |
\ [ 'mode', 'paste' ], | |
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ], | |
\ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ] | |
\ ] | |
\ }, | |
\ 'component_expand': { | |
\ 'linter_checking': 'lightline#ale#checking', | |
\ 'linter_infos': 'lightline#ale#infos', | |
\ 'linter_warnings': 'lightline#ale#warnings', | |
\ 'linter_errors': 'lightline#ale#errors', | |
\ 'linter_ok': 'lightline#ale#ok', | |
\ }, | |
\ 'component_type': { | |
\ 'linter_checking': 'right', | |
\ 'linter_infos': 'right', | |
\ 'linter_warnings': 'warning', | |
\ 'linter_errors': 'error', | |
\ 'linter_ok': 'right', | |
\ }, | |
\ 'component_function': { | |
\ 'gitbranch': 'FugitiveHead' | |
\ } | |
\ } | |
" Markdown | |
let g:markdown_fenced_languages = ['html', 'python', 'bash=sh'] | |
" folding | |
let g:SimpylFold_docstring_preview = 1 | |
"" Enable highlighting | |
let g:ale_set_highlights = 1 | |
let g:ale_open_list = 1 | |
let g:ale_keep_list_window_open = 0 | |
let g:ale_sign_column_always = 0 | |
let g:ale_set_signs = 1 | |
let g:ale_virtualtext_cursor = 'disabled' | |
let g:ale_cache_executable_check_failures = v:null | |
let g:ale_change_sign_column_color = 0 | |
let g:ale_command_wrapper = '' | |
let g:ale_completion_delay = v:null | |
let g:ale_completion_enabled = 0 | |
let g:ale_completion_max_suggestions = v:null | |
let g:ale_echo_cursor = 1 | |
let g:ale_set_loclist = 1 | |
let g:ale_set_quickfix = 1 | |
let g:ale_linters_explicit = 0 | |
let b:ale_linters = { | |
\ 'python': ['flake8', 'ruff'], | |
\ 'terraform': ['terraform', 'terraform_ls', 'terraform_lsp', 'tflint', 'tfsec'], | |
\ 'yaml': ['yamllint'], | |
\ 'bash': ['shellcheck'], | |
\ 'sh': ['shellcheck'], | |
\} | |
let g:ale_fix_on_save = 1 | |
let g:ale_fixers = { | |
\ '*': ['remove_trailing_lines', 'trim_whitespace'], | |
\ 'python': ['ruff', 'ruff_format', 'black', 'add_blank_lines_for_python_control_statements', 'remove_trailing_lines', 'trim_whitespace'], | |
\ 'terraform': ['terraform', 'remove_trailing_lines', 'trim_whitespace'], | |
\} | |
" Enable python syntax highlite | |
let g:python_highlight_all = 1 | |
" Ale settings for python | |
let g:ale_python_flake8_change_directory = 1 | |
let g:ale_python_flake8_use_global = 1 | |
" Statusline | |
set statusline+=%#warningmsg# | |
set statusline+=%{AleStatuslineFlag()} | |
set statusline+=%* | |
aug QFClose | |
au! | |
au WinEnter * if winnr('$') == 1 && &buftype == "quickfix" | q | endif | |
aug END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment