summaryrefslogtreecommitdiff
path: root/.vim/autocommands.vim
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2024-01-28 16:05:38 +0200
committerSyndamia <kamen@syndamia.com>2024-01-28 16:07:18 +0200
commitf3ea7c8003c7a65de29c2f4e0e1bf0d592dd0ad8 (patch)
treebd5953791d769f96f6cb660e74a73b9043db16e5 /.vim/autocommands.vim
parent999bb0cb0e771505ea13cba702474bd27b9d9930 (diff)
downloaddotfiles-f3ea7c8003c7a65de29c2f4e0e1bf0d592dd0ad8.tar
dotfiles-f3ea7c8003c7a65de29c2f4e0e1bf0d592dd0ad8.tar.gz
dotfiles-f3ea7c8003c7a65de29c2f4e0e1bf0d592dd0ad8.zip
[.vimrc] Reworked entire vimrc
Diffstat (limited to '.vim/autocommands.vim')
-rw-r--r--.vim/autocommands.vim45
1 files changed, 45 insertions, 0 deletions
diff --git a/.vim/autocommands.vim b/.vim/autocommands.vim
new file mode 100644
index 0000000..9100420
--- /dev/null
+++ b/.vim/autocommands.vim
@@ -0,0 +1,45 @@
+"""
+""" Settings
+"""
+
+autocmd FileType * set foldmethod=syntax
+
+autocmd BufRead,BufNewFile * set foldtext=MyFoldText()
+function! MyFoldText()
+ " Gets the first fold line and replace tabs with spaces (as many as shiftwidth is set to)
+ let line = substitute(getline(v:foldstart), "\t", repeat(" ", shiftwidth(0)), "")
+
+ " Calculates amount of folded lines
+ let linecount = v:foldend - v:foldstart
+
+ " Shows our line, then a lot of spaces, and at the very end we have line number and arrows
+ return line . repeat(" ", winwidth('%') - strlen(line) - 10 - strlen(linecount))
+ \ . "  " . linecount . "  "
+endfunction
+
+" autocmd BufEnter * call ResizeOnEnter()
+function! ResizeOnEnter()
+ vert res &columns/2
+ hor res &lines*2/3
+
+ for bufN in range(1, bufnr('$'))
+ if bufname(bufN) =~ "NERD_tree"
+ call setbufvar(bufN, "&winwidth", 31)
+ endif
+ endfor
+endfunction
+
+"""
+""" Config file formatting
+"""
+
+autocmd FileType vim,sh,zsh,xdefaults setlocal foldlevel=0
+
+"""
+""" Programming language formatting
+"""
+
+autocmd FileType css,ts setlocal ts=2 sw=2 sts=0 expandtab " Transform tabs in CSS and TS into 2 spaces
+
+autocmd FileType lisp,scheme,haskell setlocal ts=2 sw=2 sts=0 expandtab
+autocmd BufRead,BufNewFile *.component.css set filetype=css