dotfiles/.vimrc

170 lines
4.7 KiB
VimL
Raw Normal View History

2020-08-18 11:49:44 +00:00
function! FixLastSpellingError()
normal! mm[s1z=`m
endfunction
function! MakeHeading(level)
if a:level == 1
normal! yypVr=
elseif a:level == 2
normal! yypVr~
endif
endfunction
function! Spelling(lang)
if a:lang == "en"
setlocal spell spelllang=en_us
setlocal spellfile=~/.vim/spell/en.utf-8.add
elseif a:lang == "sv"
setlocal spell spelllang=sv
setlocal spellfile=~/.vim/spell/sv.utf-8.add
elseif a:lang == "off"
setlocal nospell
endif
endfunction
2020-08-18 11:49:44 +00:00
2020-07-11 09:29:09 +00:00
nnoremap <Left> :echo "No left for you!"<CR>
vnoremap <Left> :<C-u>echo "No left for you!"<CR>
inoremap <Left> <C-o>:echo "No left for you!"<CR>
nnoremap <Right> :echo "No right for you!"<CR>
vnoremap <Right> :<C-u>echo "No right for you!"<CR>
inoremap <Right> <C-o>:echo "No right for you!"<CR>
nnoremap <Up> :echo "No left up you!"<CR>
vnoremap <Up> :<C-u>echo "No up for you!"<CR>
inoremap <Up> <C-o>:echo "No up for you!"<CR>
nnoremap <Down> :echo "No Down for you!"<CR>
vnoremap <Down> :<C-u>echo "No Down for you!"<CR>
inoremap <Down> <C-o>:echo "No Down for you!"<CR>
2020-08-18 11:12:52 +00:00
2020-05-25 15:51:47 +00:00
" Basic vim settings
set title
2020-03-30 06:56:05 +00:00
set laststatus=2
set encoding=utf-8
set autoindent
2020-07-08 15:19:37 +00:00
set nocompatible
2020-07-13 11:45:26 +00:00
set complete=.,w,b,u,t,i,kspell
2020-07-08 15:19:37 +00:00
syntax on
2020-07-13 11:45:26 +00:00
nnoremap <SPACE> <Nop>
let mapleader=" "
2020-08-18 11:49:44 +00:00
map <Leader>ss :call FixLastSpellingError()<CR>
map <Leader>u1 :call MakeHeading(1)<CR>
map <Leader>u2 :call MakeHeading(2)<CR>
map <Leader>ls :call Spelling("sv")<CR>
map <Leader>le :call Spelling("en")<CR>
map <Leader>lo :call Spelling("off")<CR>
2020-08-18 11:12:52 +00:00
2020-03-30 06:56:05 +00:00
filetype indent plugin on
" Global tab settings
2020-03-30 06:56:05 +00:00
set tabstop=4
set shiftwidth=4
set softtabstop=4
2020-03-30 06:56:05 +00:00
set expandtab
2020-07-11 09:29:34 +00:00
set relativenumber
2020-07-10 08:23:39 +00:00
" Pathogen
execute pathogen#infect()
2020-07-10 09:20:32 +00:00
" Spellcheck
2020-07-10 08:23:39 +00:00
" vimwiki
let wiki_1 = {}
let wiki_1.path = '~/Nextcloud/vimwiki'
let wiki_1.syntax = 'markdown'
let wiki_1.ext = '.md'
let wiki_2 = {}
let wiki_2.path = '~/Nextcloud/vimwiki/suse'
let wiki_2.syntax = 'markdown'
let wiki_2.ext = '.md'
let wiki_3 = {}
let wiki_3.path = '~/Nextcloud/vimwiki/private'
let wiki_3.syntax = 'markdown'
let wiki_3.ext = '.md'
let g:vimwiki_list = [wiki_1, wiki_2, wiki_3]
" Set to show invisibles (tabs & trailing spaces) & their highlight color
set list listchars=tab:»\ ,trail
2020-03-30 06:56:05 +00:00
2020-07-10 08:23:39 +00:00
" Mark characters 80+ on each line with red color
2020-05-29 05:36:04 +00:00
function! Highlight()
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.\+/
endfunction
2020-07-10 08:23:39 +00:00
" remaps
noremap <Leader>_h :call Highlight()<CR>
2020-07-30 14:45:20 +00:00
nmap <F2> i**<C-R>=strftime("%Y-%m-%d")<CR>**<Esc>
imap <F2> **<C-R>=strftime("%Y-%m-%d")<CR>**<CR>
2020-05-24 13:07:25 +00:00
2020-03-30 06:56:05 +00:00
""""""""""""""""""""
" GnuPG Extensions "
""""""""""""""""""""
" sudo zypper install vim-plugin-gnupg
let g:GPGDefaultRecipients=[
\"Jonas Forsberg <jonas@forsberg.co>",
\"Jonas Forsberg <jonas.forsberg@suse.com>"
\]
" Tell the GnuPG plugin to armor new files.
let g:GPGPreferArmor=1
" Tell the GnuPG plugin to sign new files.
let g:GPGPreferSign=1
augroup GnuPGExtra
" Set extra file options.
autocmd BufReadCmd,FileReadCmd *.\(gpg\|asc\|pgp\) call SetGPGOptions()
" Automatically close unmodified files after inactivity.
autocmd CursorHold *.\(gpg\|asc\|pgp\) quit
augroup END
function SetGPGOptions()
" Set updatetime to 1 minute.
set updatetime=60000
" Fold at markers.
set foldmethod=marker
" Automatically close all folds.
set foldclose=all
" Only open folds with insert commands.
set foldopen=insert
endfunction
2020-05-22 09:12:55 +00:00
if has("autocmd")
" To spell check all git commit messages
au BufNewFile,BufRead COMMIT_EDITMSG set spelllang=en_us spell nonumber nolist wrap linebreak
2020-06-05 10:53:40 +00:00
" To spell check all Markdown files
autocmd FileType markdown setlocal spell
autocmd BufRead,BufNewFile *.rst setlocal spell
2021-03-18 14:23:27 +00:00
autocmd BufRead,BufNewFile *.txt setlocal spell
2020-06-05 10:53:40 +00:00
" Set filetype tab settings
autocmd FileType python,doctest set ai ts=4 sw=4 sts=4 et
2020-08-21 07:50:14 +00:00
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
2020-10-13 06:07:01 +00:00
" ShellCheck settings
autocmd FileType sh set makeprg=shellcheck\ -f\ gcc\ %
autocmd FileType sh au BufWritePost * :silent make | redraw!
autocmd FileType sh au QuickFixCmdPost [^l]* nested cwindow
autocmd FileType sh au QuickFixCmdPost l* nested lwindow
endif
2020-07-10 08:23:39 +00:00
" vim-instant-markdown settings
"Uncomment to override defaults:
let g:instant_markdown_slow = 0
let g:instant_markdown_autostart = 0
let g:instant_markdown_open_to_the_world = 0
let g:instant_markdown_allow_unsafe_content = 0
let g:instant_markdown_allow_external_content = 1
"let g:instant_markdown_mathjax = 1
"let g:instant_markdown_browser = "firefox --new-window"
"let g:instant_markdown_logfile = '/tmp/instant_markdown.log'
"let g:instant_markdown_autoscroll = 0
"let g:instant_markdown_port = 8888
"let g:instant_markdown_python = 1