diff --git a/config/nvim/ftplugin/haskell.vim b/config/nvim/ftplugin/haskell.vim new file mode 100644 index 0000000..02d9248 --- /dev/null +++ b/config/nvim/ftplugin/haskell.vim @@ -0,0 +1,4 @@ + +" Interactive +nnoremap i :terminal cabal exec -- ghci -Wall '%' + diff --git a/config/nvim/ftplugin/markdown.vim b/config/nvim/ftplugin/markdown.vim new file mode 100644 index 0000000..c8b0925 --- /dev/null +++ b/config/nvim/ftplugin/markdown.vim @@ -0,0 +1,14 @@ + +" Making and showing html +nnoremap c :terminal markdown '%:p' > '%:p:r.html' +nnoremap i :!rifle '%:p:r.html' + +setlocal textwidth=0 +setlocal wrapmargin=0 +setlocal colorcolumn=0 +setlocal wrap +setlocal linebreak +setlocal nolist + +nmap j gj +nmap k gk diff --git a/config/nvim/ftplugin/python.vim b/config/nvim/ftplugin/python.vim new file mode 100644 index 0000000..7ab2d64 --- /dev/null +++ b/config/nvim/ftplugin/python.vim @@ -0,0 +1,40 @@ + +" Interactive +nnoremap i :terminal python -i '%' + +" Lint +function Pylint() + silent !pylint --reports=n --output-format=parseable '%' > /tmp/errors.err 2> /dev/null + cfile + silent !rm /tmp/errors.err + redraw! + copen +endfunction + +nnoremap x :call Pylint() + +" Folding +function PythonFold(lnum) + if getline(a:lnum-1) =~ '^\s*def\s' || getline(a:lnum-1) =~ '^\s*class\s' + return indent(a:lnum-1) / 4 + 1 + endif + if getline(a:lnum) =~ '^\s*def\s' || getline(a:lnum) =~ '^\s*class\s' + return indent(a:lnum) / 4 + endif + if getline(a:lnum+1) =~ '^\s*def\s' || getline(a:lnum+1) =~ '^\s*class\s' + return indent(a:lnum + 1) / 4 + endif + if getline(a:lnum+1) =~ '^\S.*$' + return '0' + endif + return '=' +endfunction + +function PythonFoldText() + return repeat(' ', indent(v:foldstart - 1) + 4) . '+' +endfunction + +setlocal foldmethod=expr +setlocal foldexpr=PythonFold(v:lnum) +setlocal foldtext=PythonFoldText() + diff --git a/config/nvim/ftplugin/ruby.vim b/config/nvim/ftplugin/ruby.vim new file mode 100644 index 0000000..7abf672 --- /dev/null +++ b/config/nvim/ftplugin/ruby.vim @@ -0,0 +1,33 @@ + +" Interactive +nnoremap i :!irb -Ilib -r ./% + +" Indent +setlocal tabstop=2 +setlocal shiftwidth=2 + +" Folding +function RubyFold(lnum) + if getline(a:lnum) =~ '^\s*def\s' || getline(a:lnum) =~ '^\s*class\s' || getline(a:lnum) =~ '^\s*module\s' + return indent(a:lnum) / 2 + 1 + endif + if getline(a:lnum) =~ '^\s*end' + return indent(a:lnum) / 2 + 1 + endif + if getline(a:lnum - 1) =~ '^\s*end' + return indent(a:lnum - 1) / 2 + endif + return '=' +endfunction + +function RubyFoldText() + return getline(v:foldstart) . ' +' +endfunction + +setlocal foldmethod=expr +setlocal foldexpr=RubyFold(v:lnum) +setlocal foldtext=RubyFoldText() + +" Use rake as makeprogram +setlocal makeprg=rake + diff --git a/config/nvim/ftplugin/sh.vim b/config/nvim/ftplugin/sh.vim new file mode 100644 index 0000000..3333769 --- /dev/null +++ b/config/nvim/ftplugin/sh.vim @@ -0,0 +1,4 @@ + +" Interactive +nnoremap i :terminal bash --init-file './%' + diff --git a/config/nvim/ftplugin/tex.vim b/config/nvim/ftplugin/tex.vim new file mode 100644 index 0000000..4fbce46 --- /dev/null +++ b/config/nvim/ftplugin/tex.vim @@ -0,0 +1,13 @@ + +" Make a pdf +nnoremap c :terminal pdflatex -shell-escape '%' +nnoremap i :!rifle '%:p:r.pdf' + +" Indent +setlocal tabstop=2 +setlocal shiftwidth=2 +setlocal softtabstop=2 + +" Folding +setlocal foldmethod=marker +