Skip to content
Snippets Groups Projects
Select Git revision
  • 46374cfb44494559fc91101f40a7bf41d566d1f5
  • master default protected
2 results

.vimrc

Blame
  • .vimrc 41.28 KiB
    " Plug stuff
    set nocompatible              " be iMproved, required
    filetype off                  " required
    
    if has ("nvim")
        " Install vim-plug if we don't already have it, nvim 
        if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
            silent !curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs
                        \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
            autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
        endif
    
        call plug#begin(stdpath('data') . '/plugged')
    else
    
        " Install vim-plug if we don't already have it
        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 --sync | source $MYVIMRC
        endif
    
        call plug#begin('~/.vim/plugged')
    endif
    
    
    " Henrik's curated plugins
    " For all your commenting needs, <Leader>c<space>
    "Plug 'scrooloose/nerdcommenter'
    Plug 'preservim/nerdcommenter'
    
    if exists('g:vscode')
        " VSCode extension
    else
        " Bracketed paste, automatically enters paste mode
        Plug 'ConradIrwin/vim-bracketed-paste'
        " ordinary neovim
        " NERDTree file browser
        "Plug 'scrooloose/nerdtree'
        Plug 'preservim/nerdtree'
        " Filetype and other icons
        Plug 'Xuyuanp/nerdtree-git-plugin'
        " Icons for devices, used in nerdtree etc
        Plug 'ryanoasis/vim-devicons'
        " Syntax checker
        Plug 'scrooloose/syntastic'
        " Absolute and relative numbering
        Plug 'myusuf3/numbers.vim'
        " For tmux and vim tab jumping
        Plug 'christoomey/vim-tmux-navigator'
        " Improve tmux and vim compatibility
        Plug 'tmux-plugins/vim-tmux-focus-events'
        " spf13 color pack
        Plug 'spf13/vim-colors'
        " PaperColor theme
        Plug 'NLKNguyen/papercolor-theme'
        " vim-sol theme for diffs
        Plug 'kshenoy/vim-sol'
        " Add support for json with comments
        Plug 'kevinoid/vim-jsonc'
    endif
    
    if has('nvim')
        " Requires a Nerd Font-patched font
        " yay nerd-fonts-fira-code
        " Need to run :CHADdeps to fully install it
        "Plug 'ms-jpq/chadtree', {'branch': 'chad', 'do': 'python3 -m chadtree deps'}" ChadTree alternative
        " Coq
        " main one, might need :COQdeps to be run at install
        Plug 'ms-jpq/coq_nvim', {'branch': 'coq'}
        " 9000+ Snippets
        Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'}
        " Neovim GDB/LLDB integration
        Plug 'sakhnik/nvim-gdb', { 'do': ':!./install.sh' }
    endif
    
    " Ack, similar like grep
    Plug 'mileszs/ack.vim'
    
    " Vim-fetch, opening files with line, column
    Plug 'wsdjeg/vim-fetch'
    
    if exists('g:vscode')
        " VSCode extension
    else
        " ordinary neovim
        " use ctrl + p to preview markdown in webbrowser
        Plug 'JamshedVesuna/vim-markdown-preview'
        " Vim-markdown
        Plug 'gabrielelana/vim-markdown'
    
        " AsciiDoctor
        Plug 'habamax/vim-asciidoctor'
    
        " The ultimate undo history
        Plug 'mbbill/undotree'
        " Neat graphical indentation visibility
        Plug 'nathanaelkane/vim-indent-guides'
        " Restore and store all folds and cursor loc
        Plug 'vim-scripts/restore_view.vim'
    
        " TagList, for ultimate coding, replaced by TagBar
        "Plug 'taglist.vim'
    
        " Airline
        Plug 'vim-airline/vim-airline'
        Plug 'vim-airline/vim-airline-themes'
    
        " OCAML pluginlist
        " from https://www.cs.kent.ac.uk/people/staff/sao/articles/osx_vim_ocaml.html 
        Plug 'def-lkb/ocp-indent-vim'
    
        " VIM-Latex
        Plug 'lervag/vimtex'
        " Start compilation \ll
        " \lc for cleanup
    
        " Python autopep8
        "Plug 'tell-k/vim-autopep8'
        "Plug 'nvie/vim-flake8'
    
        " Python indentation
        "Plug 'Vimjas/vim-python-pep8-indent'
    
        "Python-mode
        "Plug 'python-mode/python-mode', { 'for': 'python', 'branch': 'develop' }
    
        " Smart quotes suppor
        Plug 'reedes/vim-textobj-quote'
        Plug 'kana/vim-textobj-user'
    endif
    
    " Candidate for inclusion into my main plugins
    Plug 'tpope/vim-sensible'
    " complementary pairs of mappings
    " Adds [n ]n for jumping between conflicts
    Plug 'tpope/vim-unimpaired'
    
    " Supporting plugins for python-mode
    Plug 'Konfekt/FastFold'
    Plug 'Konfekt/FoldText'
    
    " For maintaining folds and sessions
    Plug 'zhimsel/vim-stay'
    
    " Maintain list of FIXME, TODO etc
    Plug 'vim-scripts/TaskList.vim'
    
    " FZF
    Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
    Plug 'junegunn/fzf.vim'
    
    " Auto save files
    " Toggle with :AutoSaveToggle
    Plug '907th/vim-auto-save'
    
    " Change to a project root dir
    Plug 'airblade/vim-rooter'
    
    if exists('g:vscode')
        " VSCode extension
    else
        " ordinary neovim
        " Sublime style minimap
        " Mapping <leader>mm
        Plug 'severin-lemaignan/vim-minimap'
    
        " Tagbar
        Plug 'majutsushi/tagbar'
    
        " c.vim
        Plug 'vim-scripts/c.vim'
    
        " Themes and theming
        " ##################
    
        "  \         'color05' : ['#FFFFFF', '30'],
        " Nice bright color theme
        Plug 'vim-scripts/mayansmoke'
        " Wikipedia color theme
        Plug 'mtglsk/wikipedia.vim'
    endif
    
    let g:airline_theme='papercolor'
    
    
    " vim-auto-save
    let g:auto_save = 1  " enable AutoSave on Vim startup
    
    map <F4> :AutoSaveToggle<CR>
    map <leader>as :AutoSaveToggle<CR>
    
    if exists('g:vscode')
        " VSCode extension
    else
        " ordinary neovim
        " Testing, need to learn
        " Distraction free editing :Goyo   :Goyo!
        " Prose
        Plug 'junegunn/goyo.vim'
        " Rethinking Vim as a tool for writing prose
        Plug 'reedes/vim-pencil'
    
        " Fugitive, deep git integration
        Plug 'tpope/vim-fugitive'
    
        " Git diff and staging
        Plug 'jreybert/vimagit'
    
        " Git-gutter, shows git diffs in the gutter
        Plug 'airblade/vim-gitgutter'
    
        " vimagit, for easy visual staging
        Plug 'jreybert/vimagit'
    
        " Git blame in-line
        Plug 'tveskag/nvim-blame-line'
    
        " surround.vim: quoting/parenthesizing made simple
        Plug 'tpope/vim-surround'
    
        " Abolish, fix those typos, :Subvert
        Plug 'tpope/vim-abolish'
    
        " Vim browser :GV
        Plug 'junegunn/gv.vim'
    
        " Resize vim splits with arrow keys
        Plug 'breuckelen/vim-resize'
    
        " Plugs for handling text objects,
        " see https://owen.cymru/vim-text-objects-extend-vims-natural-language-2-2/
        Plug 'kana/vim-textobj-user'
    
        " Indentation selection with ii and ai
        Plug 'kana/vim-textobj-indent'
    
        " Simply provides ic and ac to edit comments.
        Plug 'glts/vim-textobj-comment'
    
        " Far search and replace
        "Plug 'brooth/far.vim'
        " ctrlsf.vim - Search and replace inspired by Sublime Ctrl + Shift + f
        Plug 'dyng/ctrlsf.vim'
        " Useful for replacing, multicursors
        Plug 'mg979/vim-visual-multi', {'branch': 'master'}
        " Esearch
        Plug   'eugen0329/vim-esearch'
    
        " Extended support for DOT and Graphviz
        Plug 'liuchengxu/graphviz.vim'
    
    endif
    
    " EasyMotiom jump everywhere, <Leader><Leader>movement-key
    Plug 'Lokaltog/vim-easymotion'
    
    " Vim HardTime
    Plug 'takac/vim-hardtime'
    
    if exists('g:vscode')
        " VSCode extension
    else
        " ordinary neovim
        " Grammatical checking
        Plug 'rhysd/vim-grammarous'
    
        " Tag generation for ctags
        "Plug 'ludovicchabant/vim-gutentags'
    
        " Rust-lang support
        Plug 'rust-lang/rust.vim'
    
        " Rust Racer (replaced by Coc)
        "Plug 'racer-rust/vim-racer'
    
        " Rust RLS
        "Plug 'prabirshrestha/async.vim'
        "Plug 'prabirshrestha/vim-lsp'
        "Plug 'prabirshrestha/asyncomplete.vim'
        "Plug 'prabirshrestha/asyncomplete-lsp.vim'
    
        " LSP Coc (replacing Rust RLS/racer)
        " Intellisense engine for vim8 & neovim, full language server protocol support
        " as VSCode 
        " https://github.com/fannheyward/coc-rust-analyzer
        " Requirements: yay -S npm
        Plug 'neoclide/coc.nvim', {'branch': 'release'}
    
        " For being able to run rust in playpen with :RustPlay
        Plug 'mattn/webapi-vim'
    
        " ctrlp file fuzzy
        " Plug 'ctrlpvim/ctrlp.vim.git'
        " replaced by fzf
        "Plug 'jremmen/vim-ripgrep'
    
    endif
    
    
    
    " All of your Plugins must be added before the following line
    call plug#end()
    filetype plugin indent on    " required
    " To ignore plugin indent changes, instead use:
    "filetype plugin on
    "
    " Brief help
    " :PluginList       - lists configured plugins
    " :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
    " :PluginSearch foo - searches for foo; append `!` to refresh local cache
    " :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
    "
    " Put your non-Plug stuff after this line
    
    
    "####End of Plug config ####
    " Start a remoteserver required by at least vimtex
    " Requires X-server, erros otherwise
    if $DISPLAY && empty(v:servername) && exists('*remote_startserver')
        call remote_startserver('VIM')
    endif
    
    " Change leader to '<space>'
    " Change localleader to ','
    let mapleader = "\<Space>"
    let maplocalleader = ","
    
    set t_Co=256
    set background=light
    
    " When Tmux 'focus-events' option is on, Tmux will send <Esc>[O when the
    " window loses focus and <Esc>[I when it gains focus.
    exec "set <F24>=\<Esc>[O"
    exec "set <F25>=\<Esc>[I"
    
    " You might have to force true color when using regular vim inside tmux as the
    " colorscheme can appear to be grayscale with "termguicolors" option enabled.
    if !has('gui_running') && &term =~ '^\%(screen\|tmux\)'
      let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
      let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
    endif
    
    syntax on
    set termguicolors
    
    " Modify PaperColor to have white background
    let g:PaperColor_Theme_Options = {
               \   'theme': {
                   \     'default.light': { 
                       \       'allow_bold': 1,
                       \       'allow_italic': 1,
                       \       'override' : {
                           \         'color00' : ['', '231'],
                           \         'color05' : ['', '73'],
                           \         'difftext_bg' : ['#60e1ff', ''],
                           \         'difftext_fg' : ['#0f1d20', ''],
                           \         'error_fg' : ['#af0000', ''],
                           \         'error_bg' : ['#ffd7ff', ''],
                           \       }
                           \     }
                           \   }
                           \ }
    
    "colorscheme desert256-transparent
    "colorscheme molokai
    "colorscheme wikipedia
    colorscheme PaperColor
    "if &diff
    "colorscheme sol
    "endif
    
    " Colors and themes
    "
    " Change the diff
    hi DiffAdd      ctermfg=NONE          ctermbg=LightGreen
    hi DiffChange   ctermfg=NONE          ctermbg=NONE
    hi DiffDelete   ctermfg=Blue     ctermbg=LightRed
    hi DiffText     ctermfg=Yellow        ctermbg=LightRed
    
    " Same but for Neovim
    hi DiffAdded    ctermfg=NONE          ctermbg=LightGreen
    hi DiffChanged  ctermfg=NONE          ctermbg=NONE
    hi DiffRemoved  ctermfg=Blue     ctermbg=LightRed
    hi DiffText     ctermfg=Yellow        ctermbg=LightRed
    
    au ColorScheme * hi Error     ctermfg=Black ctermbg=Red guifg=Black guibg=Red
    au ColorScheme * hi ErrorMsg  ctermfg=Black ctermbg=Red guifg=Black guibg=Red
    
    " Fix the difficult-to-read default setting for diff text highlighting.  The
    " bang (!) is required since we are overwriting the DiffText setting. The highlighting
    " for "Todo" also looks nice (yellow) if you don't like the "MatchParen" colors.
    "highlight! link DiffText MatchParen
    
    " handling setting and unsetting BAT_THEME for fzf.vim
    augroup update_bat_theme
        autocmd!
        autocmd colorscheme * call ToggleBatEnvVar()
    augroup end
    function ToggleBatEnvVar()
        if (&background == "light")
            let $BAT_THEME='GitHub'
        else
            let $BAT_THEME=''
        endif
    endfunction
    
    
    " Molokai attempt to use 256-color
    let g:rehash256 = 1
    
    " Vim would like to use regular piping, fish-shell interferes
    set shell=/bin/bash
    
    " Sensible defaults
    "
    set nowrap        " don't wrap lines
    set tabstop=4     " a tab is four spaces
    set softtabstop=4
    set backspace=indent,eol,start
    set expandtab
    " allow backspacing over everything in insert mode
    set autoindent    " always set autoindenting on
    set copyindent    " copy the previous indentation on autoindenting
    set number        " always show line numbers
    set shiftwidth=4  " number of spaces to use for autoindenting
    set shiftround    " use multiple of shiftwidth when indenting with '<' and '>'
    set showmatch     " set show matching parenthesis
    set ignorecase    " ignore case when searching
    set smartcase     " ignore case if search pattern is all lowercase,
    "    case-sensitive otherwise
    set smarttab      " insert tabs on the start of a line according to
    "    shiftwidth, not tabstop
    set hlsearch      " highlight search terms
    set incsearch     " show search matches as you type
    " Preview effects of command incrementally (e.g. :substitute). Neovim only.
    if has('nvim')
        set inccommand=nosplit
    endif
    
    
    " Get some usable undo levels
    set history=1000         " remember more commands and search history
    set undolevels=1000      " use many muchos levels of undo
    set wildignore=*.swp,*.bak,*.pyc,*.class
    set title                " change the terminal's title
    set novisualbell           " don't beep
    set noerrorbells         " don't beep
    
    " Commit and use git instead?
    set nobackup
    "set noswapfile
    
    filetype plugin indent on
    
    if has('autocmd')
        " Search for 'message =' AND search if '# Hunks' exists in file
        " set filetype to "pijul" and change colorscheme
        autocmd BufNewFile,BufRead /tmp/.tmp*
            \ if search('message =', 'nw') && search ('# Hunks', 'nw') |
                \ setlocal filetype=pijul | endif
        " Further matches on now set Filetype also possible
        " autocmd FileType pijul colorscheme desert
        autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4
        autocmd FileType json syntax match Comment +\/\/.\+$+
    endif
    
    
    "au BufNewFile,BufRead *.py set tabstop=4
                "\ softtabstop=4
                "\ shiftwidth=4
                "\ textwidth=79
                "\ expandtab
                "\ autoindent
                "\ fileformat=unix
    
    " Set unix style file-format
    set fileformat=unix
    set fileformats=unix,dos
    
    "if has('python3')
    "    silent! python3 1
    "endif
    
    " enable all Python syntax highlighting features
    let python_highlight_all = 1
    "let g:pymode_python = 'python3'
    let g:pymode_rope=0
    
    " Highlight whitespaces
    set list
    set listchars=tab:>.,trail:.,extends:#,nbsp:.
    
    " Do :set paste and revert with one easy button:
    set pastetoggle=<leader>pt
    
    " Taglist toggle
    "nnoremap <silent> <F8> :TlistToggle<CR>
    " Tagbar toggle
    nmap <F8> :TagbarToggle<CR>
    nmap <leader>tb :TagbarToggle<CR>
    
    " CTRL + \ Open definition in new tab
    " ALT + ] open the definition in a vertical split
    map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
    map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
    
    
    " Make ; and : behave equally, saving is just ;w
    nnoremap ; :
    
    " Map Ctrl + C to copy selection to clipboard, install gvim
    vnoremap <C-c> "+y
    
    " Easy window navigation
    "map <C-h> <C-w>h
    "map <C-j> <C-w>j
    "map <C-k> <C-w>k
    "map <C-l> <C-w>l
    
    " Map Ctrl + N to open NERDTree
    nmap <C-n> :NERDTreeToggle<CR>
    autocmd StdinReadPre * let s:std_in=1
    autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
    
    " Add .robot to nerdcommenter
    au BufNewFile,BufRead *.robot   setf robot
    let g:NERDCustomDelimiters = {
        \ 'robot': { 'left': '#' },
    \ }
    
    " CHADtree
    nnoremap <leader>n <cmd>CHADopen<cr>
    nnoremap <leader>l <cmd>call setqflist([])<cr>
    
    " Coq https://github.com/ms-jpq/coq_nvim
    " the [-s, --shut-up] flag will remove the greeting message
    "
    " 🐓 Coq completion settings
    
    " Change conflicting keybinds for c-h and c-k
    let g:coq_settings = {
                           \ "keymap.jump_to_mark": "<c-ö>",
                           \ "keymap.bigger_preview": "<c-ä>",
                           \}
    
    " Clear a search instead of searching random stuff
    nmap <silent> ,/ :nohlsearch<CR>
    
    " ctrlsf settings search
    let g:ctrlsf_search_mode = 'async'
    let g:ctrlsf_default_root = 'project'
    
    " Changed from <C-F> to <C-G>
    nmap     <C-G>f <Plug>CtrlSFPrompt
    vmap     <C-G>f <Plug>CtrlSFVwordPath
    vmap     <C-G>F <Plug>CtrlSFVwordExec
    nmap     <C-G>n <Plug>CtrlSFCwordPath
    nmap     <C-G>p <Plug>CtrlSFPwordPath
    nnoremap <C-G>o :CtrlSFOpen<CR>
    nnoremap <C-G>t :CtrlSFToggle<CR>
    inoremap <C-G>t <Esc>:CtrlSFToggle<CR>
    
    " Esearch settings
    
    " Use <c-g><c-g> to start the prompt, use <c-g>iw to pre-fill with the current word
    " or other text-objects. Try <plug>(esearch-exec) to start a search instantly.
    nmap <c-g><c-g> <plug>(esearch)
    map  <c-g>      <plug>(operator-esearch-prefill)
    
    let g:esearch = {}
    
    "" Use regex matching with the smart case mode by default and avoid matching text-objects.
    "let g:esearch.regex   = 1
    "let g:esearch.textobj = 0
    "let g:esearch.case    = 'smart'
    
    "" Set the initial pattern content using the highlighted '/' pattern (if
    "" v:hlsearch is true), the last searched pattern or the clipboard content.
    "let g:esearch.prefill = ['hlsearch', 'last', 'clipboard']
    
    "" Override the default files and directories to determine your project root. Set it
    "" to blank to always use the current working directory.
    let g:esearch.root_markers = ['.git', 'Makefile', 'node_modules', 'target', '.pijul']
    
    "" Prevent esearch from adding any default keymaps.
    ""let g:esearch.default_mappings = 0
    
    "" Start the search only when the enter is hit instead of updating the pattern while you're typing.
    ""let g:esearch.live_update = 0
    
    "" Open the search window in a vertical split and reuse it for all further searches.
    "let g:esearch.name = '[esearch]'
    "let g:esearch.win_new = {esearch -> esearch#buf#goto_or_open(esearch.name, 'vnew')}
    
    " Redefine the default highlights (see :help highlight and :help esearch-appearance)
    "highlight      esearchHeader     cterm=bold gui=bold ctermfg=white ctermbg=white
    "highlight link esearchStatistics esearchFilename
    "highlight link esearchFilename   Label
    "highlight      esearchMatch      ctermbg=27 ctermfg=15 guibg='#005FFF' guifg='#FFFFFF'
    
    " Esearch Git-extras
    
    " Show the popup with git-show information on CursorMoved is a git revision context is hovered.
    let g:GitShow = {ctx -> ctx().rev &&
      \ esearch#preview#shell('git show ' . split(ctx().filename, ':')[0], {
      \   'let': {'&filetype': 'git', '&number': 0},
      \   'row': screenpos(0, ctx().begin, 1).row,
      \   'col': screenpos(0, ctx().begin, col([ctx().begin, '$'])).col,
      \   'width': 47, 'height': 3,
      \ })
      \}
    " Debounce the popup updates using 70ms timeout.
    autocmd User esearch_win_config
          \  let b:git_show = esearch#async#debounce(g:GitShow, 70)
          \| autocmd CursorMoved <buffer> call b:git_show.apply(b:esearch.ctx)
    
    nnoremap <leader>fh :call esearch#init({'paths': esearch#xargs#git_log()})<cr>
    
    " Search in modified files only
    nnoremap <leader>fm :call esearch#init({'paths': '`git ls-files --modified`'})<cr>
    " Search in unmerged commits using range specification
    nnoremap <leader>fu :call esearch#init({'paths': esearch#xargs#git_log('development..HEAD')})<cr>
    " Search in stashed entries
    nnoremap <leader>fs :call esearch#init({'paths': esearch#xargs#git_stash()})<cr>
    
    " Create mappings for having astyle format your code
    nnoremap <leader>sty :%!astyle --style=allman --add-brackets --max-code-length=100
    
    " Map undotree to F5
    nnoremap <F5> :UndotreeToggle<cr>
    nnoremap <leader>ut :UndotreeToggle<cr>
    
    "When you forgot to sudo, do w!!
    cmap w!! w !sudo tee % >/dev/null
    
    "set nu
    "set norelativenumber
    set cursorline
    
    " For the preview markdown plugin vim_markdown_preview
    let vim_markdown_preview_use_xdg_open=1
    let vim_markdown_preview_hotkey='<C-m>'
    let vim_markdown_preview_github=1
    
    " For smart quotes in markdown and text
    augroup textobj_quote
        autocmd!
        autocmd FileType markdown call textobj#quote#init()
        autocmd FileType textile call textobj#quote#init()
        autocmd FileType text call textobj#quote#init({'educate': 0})
    augroup END
    
    " Keybinds for mapping between smart quotes
    map <silent> <leader>qc <Plug>ReplaceWithCurly
    map <silent> <leader>qs <Plug>ReplaceWithStraight
    
    
    " Mouse support, downside the terminal doesn't own it anymore
    set mouse=a
    
    " Don't try to spellcheck
    set nospell
    
    " But whet we spellcheck, use the following languages
    set spelllang=sv,en
    
    " Set default encoding
    set encoding=UTF-8
    
    " Make F3 retur the number of printed words in latex
    map <F3> :w !detex \| wc -w<CR>
    map <leader>wc :w !detex \| wc -w<CR>
    
    " Disables the auto-conceal which makes things into subscripts
    " parses greek-alphabet etc
    let g:tex_conceal = ""
    
    "let g:neocomplcache_disable_auto_complete = 1
    " Enable spell checking when opening .tex files
    "autocmd FileType tex setlocal spell spelllang=sv,en
    "autocmd BufRead COMMIT_EDITMSG setlocal spell spelllang=sv,en
    "autocmd BufNewFile,BufRead *.md,*.mkd,*.markdown set spell spelllang=sv,en
    
    " For quick and easy vimrc editing
    map <leader>vm :vsp $MYVIMRC<CR>
    map <leader>sv :source $MYVIMRC<CR>
    
    "Bind F1 to ESC instead of help
    map <F1> <Esc>
    imap <F1> <Esc>
    
    " Fix å support auto-pairs plugin causing the issue
    "     let g:AutoPairsShortcutToggle = '<another key>'
    "     https://github.com/jiangmiao/auto-pairs 
    "     Learnt it from using ':map!' to show all mapped keys
    let g:AutoPairsShortcutFastWrap = ''
    
    " Syntastic recommended settings
    set statusline+=%#warningmsg#
    set statusline+=%{SyntasticStatuslineFlag()}
    set statusline+=%*
    
    let g:syntastic_always_populate_loc_list = 1
    let g:syntastic_auto_loc_list = 1
    let g:syntastic_check_on_open = 1
    let g:syntastic_check_on_wq = 0
    
    "let g:syntastic_rust_checkers = ['cargo']
    " coc-rust-analyzer handling the checking now
    let g:syntastic_rust_checkers = ['']
    " The same with python, use pylint
    let g:syntastic_python_checkers = ['']
    " Use ccls instead
    let g:syntastic_c_checkers = ['']
    
    " LaTeX Checker
    let g:syntastic_tex_checkers = ['lacheck']
    
    " Mute some warnings
    let g:syntastic_quiet_messages = { 'regex': [
                \ '\mpossible unwanted space at "{"',
                \ 'double space at',
                \ ] }
    
    " Maintain folds and cursor placement vim-stay
    set viewoptions=cursor,folds,slash,unix
    
    " Vim folding commands
    " ---------------------------------
    " zf#j creates a fold from the cursor down # lines.
    " zf/ string creates a fold from the cursor to string .
    " zj moves the cursor to the next fold.
    " zk moves the cursor to the previous fold.
    " za toggle a fold at the cursor.
    " zo opens a fold at the cursor.
    " zO opens all folds at the cursor.
    " zc closes a fold under cursor. 
    " zm increases the foldlevel by one.
    " zM closes all open folds.
    " zr decreases the foldlevel by one.
    " zR decreases the foldlevel to zero -- all folds will be open.
    " zd deletes the fold at the cursor.
    " zE deletes all folds.
    " [z move to start of open fold.
    " ]z move to end of open fold.
    
    " FastFold by Enno settings
    nmap zuz <Plug>(FastFoldUpdate)
    " Do not update folds on save
    let g:fastfold_savehook = 1
    let g:fastfold_fold_command_suffixes =  ['x','X','a','A','o','O','c','C']
    let g:fastfold_fold_movement_commands = [']z', '[z', 'zj', 'zk']
    " Allow fastfold to work with smaller than 200 lines files
    let g:fastfold_minlines = 0
    
    let g:markdown_folding = 1
    let g:tex_fold_enabled = 1
    let g:vimsyn_folding = 'af'
    let g:xml_syntax_folding = 1
    let g:javaScript_fold = 1
    let g:sh_fold_enabled= 7
    let g:ruby_fold = 1
    let g:perl_fold = 1
    let g:perl_fold_blocks = 1
    let g:r_syntax_folding = 1
    let g:rust_fold = 1
    let g:php_folding = 1
    
    " Fold based on indentation, but open all folds on start
    "set foldmethod=indent
    set foldmethod=syntax
    set foldnestmax=1
    
    
    autocmd BufWritePost *.rust normal! zv
    
    " Keep all folds open when a file is opened
    augroup OpenAllFoldsOnFileOpen
        autocmd!
        autocmd BufRead * normal zR
    augroup END
    
    " Disable arrow keys, but use up and down to move line up and down
    no <down> ddp
    "no <left> <Nop>
    "no <right> <Nop>
    no <up> ddkP
    
    " Disable vim-resize auto-settings
    " retain for left and right
    let g:vim_resize_disable_auto_mappings = 1
    nnoremap <silent> <left> :CmdResizeLeft<cr>
    "nnoremap <silent> <c-down> :CmdResizeDown<cr>
    "nnoremap <silent> <c-up> :CmdResizeUp<cr>
    nnoremap <silent> <right> :CmdResizeRight<cr>
    
    
    " Always display the status line
    set laststatus=2
    
    " Python and C debugger pyclewn
    let g:pyclewn_args = "--pgm=/usr/bin/arm-none-eabi-gdb"
    
    " We're going to define single-letter keymaps, so don't try to define them
    " in the terminal window.  The debugger CLI should continue accepting text commands.
    function! NvimGdbNoTKeymaps()
      tnoremap <silent> <buffer> <esc> <c-\><c-n>
    endfunction
    
    let g:nvimgdb_config_override = {
      \ 'key_next': 'n',
      \ 'key_step': 's',
      \ 'key_finish': 'f',
      \ 'key_continue': 'c',
      \ 'key_until': 'u',
      \ 'key_breakpoint': 'b',
      \ 'set_tkeymaps': "NvimGdbNoTKeymaps",
      \ }
    
    
    " OCAML
    set rtp^="/home/henrik/.opam/system/share/ocp-indent/vim"
    
    au BufRead,BufNewFile *.ml,*.mli,*.mlw,*.why compiler ocaml
    
    " merlin
    "let g:opamshare = substitute(system('opam config var share'),'\n$','','''')
    "execute "set rtp+=" . g:opamshare . "/merlin/vim"
    
    "let g:syntastic_ocaml_checkers = ['merlin']
    
    " Include why3 syntax file
    "source ~/.vim/bundle/why3/why3.vim
    
    " Enable syntax highlightning
    syntax on
    
    " RUST related settings
    let g:rustfmt_autosave = 0
    let g:rustfmt_command = "rustup run nightly rustfmt"
    " Regular
    let g:rustfmt_options = "--config merge_derives=false,tab_spaces=4,use_field_init_shorthand=true,use_try_shorthand=true"
    " Atsamd
    "let g:rustfmt_options = "--config merge_derives=false,tab_spaces=4,use_field_init_shorthand=true,use_try_shorthand=true,wrap_comments=true"
    
    " Run rustfmt on keypress
    nmap <F9> :RustFmt<CR>
    nmap <leader>rf :RustFmt<CR>
    
    " Run RustPlay on keypress
    "nmap <F10> :RustPlay<CR>
    
    " Run cargo build on keypress
    nmap <F10> :!cargo check --features unproven,same51j-rt<CR>
    nmap <leader>rc :!cargo check --features unproven,same51j-rt<CR>
    nmap <F11> :!cargo build --release<CR>
    nmap <leader>rb :!cargo build --features unproven,same51j-rt<CR>
    nmap <leader>rbr :!cargo buildi --release<CR>
    
    " Coc LSP setup
    " Coc BEGIN
    let g:coc_node_path = '/usr/bin/node'
    " if hidden is not set, TextEdit might fail.
    set hidden
    
    " Some servers have issues with backup files, see #649
    set nobackup
    set nowritebackup
    
    " Better display for messages
    set cmdheight=2
    
    " You will have bad experience for diagnostic messages when it's default 4000.
    set updatetime=100
    
    " Autocomplete menu options
    " don't give |ins-completion-menu| messages.
    set completeopt=menuone,noselect,noinsert
    set noshowmode
    set shortmess+=c
    
    " always show signcolumns
    set signcolumn=yes
    
    " Use tab for trigger completion with characters ahead and navigate.
    " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
    inoremap <silent><expr> <TAB>
                \ pumvisible() ? "\<C-n>" :
                \ <SID>check_back_space() ? "\<TAB>" :
                \ coc#refresh()
    inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
    
    function! s:check_back_space() abort
        let col = col('.') - 1
        return !col || getline('.')[col - 1]  =~# '\s'
    endfunction
    
    " CoC
    "let g:coc_user_config = {}
    "let g:coc_user_config['coc.preferences.jumpCommand'] = 'vsp'
    
    " Use <c-space> to trigger completion.
    inoremap <silent><expr> <c-space> coc#refresh()
    
    " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
    " Coc only does snippet and additional edit on confirm.
    inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
    " Or use `complete_info` if your vim support it, like:
    " inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
    
    " Use `[g` and `]g` to navigate diagnostics
    nmap <silent> [g <Plug>(coc-diagnostic-prev)
    nmap <silent> ]g <Plug>(coc-diagnostic-next)
    
    " Remap keys for gotos
    " Going back ('' for the same file  C-o for any file)
    nmap <silent> gd <Plug>(coc-definition)
    nmap <silent> gy <Plug>(coc-type-definition)
    nmap <silent> gi <Plug>(coc-implementation)
    nmap <silent> gr <Plug>(coc-references)
    
    nmap <silent> <leader>gs :call CocAction('jumpDefinition', 'split')<CR>
    nmap <silent> <leader>gd :call CocAction('jumpDefinition', 'vsplit')<CR>
    nmap <silent> <leader>gt :call CocAction('jumpDefinition', 'tabe')<CR>
    
    nmap <silent> <leader>me <Plug>(coc-command)expandMacro
    
    " Use K to show documentation in preview window
    nnoremap <silent> K :call <SID>show_documentation()<CR>
    
    function! s:show_documentation()
        if (index(['vim','help'], &filetype) >= 0)
            execute 'h '.expand('<cword>')
        else
            call CocAction('doHover')
        endif
    endfunction
    
    " Highlight symbol under cursor on CursorHold
    autocmd CursorHold * silent call CocActionAsync('highlight')
    
    " Remap for rename current word
    nmap <leader>rn <Plug>(coc-rename)
    
    " Project wide rename word
    nnoremap <leader>pwr :CocSearch <C-R>=expand("<cword>")<CR><CR>
    nnoremap <leader>rw :CocSearch <C-R>=expand("<cword>")<CR><CR>
    
    " Remap for format selected region
    xmap <leader>F  <Plug>(coc-format-selected)
    nmap <leader>F  <Plug>(coc-format-selected)
    
    augroup mygroup
        autocmd!
        " Setup formatexpr specified filetype(s).
        autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
        " Update signature help on jump placeholder
        autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
    augroup end
    
    " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
    vmap <leader>a  <Plug>(coc-codeaction-selected)
    nmap <leader>a  <Plug>(coc-codeaction-selected)
    
    " Remap for do codeAction of current line
    nmap <leader>ac  <Plug>(coc-codeaction)
    " Fix autofix problem of current line
    nmap <leader>qf  <Plug>(coc-fix-current)
    
    " Create mappings for function text object, requires document symbols feature of languageserver.
    xmap if <Plug>(coc-funcobj-i)
    xmap af <Plug>(coc-funcobj-a)
    omap if <Plug>(coc-funcobj-i)
    omap af <Plug>(coc-funcobj-a)
    
    " Use <TAB> for select selections ranges, needs server support, like: coc-tsserver, coc-pyright
    nmap <silent> <TAB> <Plug>(coc-range-select)
    xmap <silent> <TAB> <Plug>(coc-range-select)
    
    " Use `:Format` to format current buffer
    command! -nargs=0 Format :call CocAction('format')
    
    " Use `:Fold` to fold current buffer
    command! -nargs=? Fold :call     CocAction('fold', <f-args>)
    
    " use `:OR` for organize import of current buffer
    command! -nargs=0 OR   :call     CocAction('runCommand', 'editor.action.organizeImport')
    
    " Add status line support, for integration with other plugin, checkout `:h coc-status`
    "set statusline^=%{coc#status()}
    " Should work out of the box with vim-airline
    
    " Using CocList
    " Show all diagnostics
    nnoremap <silent> <leader>e  :<C-u>CocList diagnostics<cr>
    " Manage extensions
    nnoremap <silent> <leader>ext  :<C-u>CocList extensions<cr>
    " Show commands
    nnoremap <silent> <leader>C  :<C-u>CocList commands<cr>
    " Find symbol of current document
    nnoremap <silent> <leader>o  :<C-u>CocList outline<cr>
    " Search workspace symbols
    nnoremap <silent> <leader>s  :<C-u>CocList -I symbols<cr>
    " Do default action for next item.
    nnoremap <silent> <leader>j  :<C-u>CocNext<CR>
    " Do default action for previous item.
    nnoremap <silent> <leader>k  :<C-u>CocPrev<CR>
    " Resume latest coc list
    nnoremap <silent> <leader>p  :<C-u>CocListResume<CR>
    
    
    " Rust Coc needs
    " :CocInstall coc-rust-analyzer coc-spell-checker coc-cspell-dicts coc-json coc-markdownlint coc-yaml coc-pyright coc-vimtex
    "
    " For text linting to work via coc-diagnostic, install
    " yay -S languagetool alex proselint write-good
    let g:coc_global_extensions = [
                \'coc-json',
                \'coc-rust-analyzer',
                \'coc-markdownlint',
                \'coc-yaml',
                \'coc-toml',
                \'coc-pyright',
                \'coc-diagnostic',
                \'coc-spell-checker',
                \'coc-ltex',
                \'coc-cspell-dicts',
                \'coc-vimtex']
    
    " Coc END
    nnoremap <silent> <leader>lt :!languagetool -l en-GB -d DOUBLE_PUNCTUATION,MORFOLOGIK_RULE_EN_GB,ARROWS[1],NON_STANDARD_WORD[1] %<CR>
    
    " Provide keybind for nvim-blame-line
    nnoremap <silent> <leader>b :ToggleBlameLine<CR>
    
    " Vim-Tex settings
    " Full list of keybinds
    " https://github.com/lervag/vimtex/wiki/Usage
    " Quickstart:
    " <localleader>ll  <plug>(vimtex-compile-toggle)
    " <localleader>lv Open the viewer/forward search
    "
    " <localleader>lk  <plug>(vimtex-stop)
    " <localleader>lK  <plug>(vimtex-stop-all)
    " <localleader>le  <plug>(vimtex-errors)
    " <localleader>lo  <plug>(vimtex-compile-output)
    " <localleader>lg  <plug>(vimtex-status)
    " <localleader>lG  <plug>(vimtex-status-all)
    " <localleader>lc  <plug>(vimtex-clean)
    "
    " requires xdotool
    
    let g:tex_flavor = 'latex'
    let g:vimtex_view_method = 'zathura'
    let g:vimtex_compiler_method = 'latexmk'
    let g:tex_flavor = 'latex'
    " If using markdown, you need to include
    "% \def\markdownOptionOutputDir{build}
    let g:vimtex_compiler_latexmk = {
                \ 'backend' : 'jobs',
                \ 'build_dir' : 'build',
                \ 'options' : [
                \   '-shell-escape' ,
                \   '-verbose' ,
                \   '-file-line-error',
                \   '-synctex=1' ,
                \   '-interaction=nonstopmode' ,
                \ ],
                \}
    "let g:vimtex_compiler_method = 'tectonic'
    "let g:vimtex_compiler_tectonic = {
        "    \ 'build_dir' : 'build',
        "    \}
    
    " Suggested by :checkhealth
    let g:vimtex_compiler_progname = 'nvr'
    
    " Default off, enable vimtex folding
    let g:vimtex_fold_enabled = 1
    " Need to manualy refresh folds with zx
    let g:vimtex_fold_manual = 1
    set fillchars=fold:\ 
    " No quickfix on warnings
    let g:vimtex_quickfix_open_on_warning = 0
    
    " Fzf
    map <C-f> <Esc><Esc>:Files!<CR>
    inoremap <C-f> <Esc><Esc>:Lines!<CR>
    map <C-g> <Esc><Esc>:BCommits!<CR>
    nnoremap <silent> <leader>gg :RG<CR>
    nnoremap <silent> <leader>ff :Rg<CR>
    nnoremap <Leader>fw :Rg <C-R><C-W><CR>
    " When inside the fuzzy search, use:
    "<Enter> replace current file
    "<C-t> open in a new tab
    "<C-x> new split
    "<C-v> new vertical split
    
    " Customize fzf colors to match your color scheme
    " Replaced by bat theme
    "let g:fzf_colors =
                "\ { 'fg':      ['fg', 'Normal'],
                "\ 'bg':      ['bg', 'Normal'],
                "\ 'hl':      ['fg', 'Comment'],
                "\ 'fg+':     ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
                "\ 'bg+':     ['bg', 'CursorLine', 'CursorColumn'],
                "\ 'hl+':     ['fg', 'Statement'],
                "\ 'info':    ['fg', 'PreProc'],
                "\ 'border':  ['fg', 'Ignore'],
                "\ 'prompt':  ['fg', 'Conditional'],
                "\ 'pointer': ['fg', 'Exception'],
                "\ 'marker':  ['fg', 'Keyword'],
                "\ 'spinner': ['fg', 'Label'],
                "\ 'header':  ['fg', 'Comment'] }
    
    let g:fzf_layout = {'up':'~90%', 'window': { 'width': 1, 'height': 1,'yoffset':0.5,'xoffset': 0.5, 'highlight': 'Todo', 'border': 'sharp' } }
    "let g:fzf_layout = {'up':'~90%', 'window': { 'width': 0.8, 'height': 0.8,'yoffset':0.5,'xoffset': 0.5, 'highlight': 'Todo', 'border': 'sharp' } }
    "let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6, 'relative': v:true } }
    let g:fzf_preview_window = 'right:60%'
    
    let g:fzf_buffers_jump = 1      " [Buffers] to existing split
    
    let $FZF_DEFAULT_COMMAND='rg --vimgrep --no-heading --color=never --smart-case --hidden --files-with-matches -g\!.git -g\!.pijul -g\!.ccls-cache . || git ls-tree -r --name-only HEAD || fd --type f || find .'
    
    
    "Get Files
    "command! -bang -nargs=? -complete=dir Files
                "\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
    
    "" Get text in files with Rg
    "command! -bang -nargs=* Rg
                "\ call fzf#vim#grep(
                "\   'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
                "\   fzf#vim#with_preview(), <bang>0)
    
    " Ripgrep advanced
    function! RipgrepFzf(query, fullscreen)
        let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case --hidden -g\!.git -g\!.pijul -g\!.ccls-cache %s || true'
        let initial_command = printf(command_fmt, shellescape(a:query))
        let reload_command = printf(command_fmt, '{q}')
        let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
        call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
    endfunction
    
    command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
    
    " Pijul
    function! RipgrepPijulFzf(query, fullscreen)
        let command_fmt = 'pijul log || %s || true'
        let initial_command = printf(command_fmt, shellescape(a:query))
        let reload_command = printf(command_fmt, '{q}')
        let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
        call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
    endfunction
    
    command! -nargs=* -bang PJ call RipgrepPijulFzf(<q-args>, <bang>0)
    
    " Git grep
    command! -bang -nargs=* GGrep
                \ call fzf#vim#grep(
                \   'git grep --line-number '.shellescape(<q-args>), 0,
                \   fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
    
    " Pijul grep
    command! -bang -nargs=* PGrep
                \ call fzf#vim#grep(
                \   'pijul log'.shellescape(<q-args>), 0,
                \   fzf#vim#with_preview(), <bang>0)
    
    
    " Enable Ag and Rg for fzf plugin
    "command! -bang -nargs=* Ag call fzf#vim#ag_interactive(<q-args>, fzf#vim#with_preview('right:50%:hidden', 'alt-h'))
    "command! -bang -nargs=* Rg call fzf#vim#rg_interactive(<q-args>, fzf#vim#with_preview('right:50%:hidden', 'alt-h'))
    
    "command! -bang -nargs=* Flines call fzf#vim#grep('rg --line-number --no-heading '.shellescape(<q-args>), 0, <bang>0)
    "command! -bang -nargs=* Rgfilesonly call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case ".shellescape(<q-args>), 1, {'options': '--delimiter : --nth 4..'}, <bang>0)
    
    let g:rg_command = '
      \ rg --files --column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --color "always"
      \ -g "*.{js,json,php,md,styl,jade,html,config,py,cpp,c,go,hs,rb,conf,robot,rs}"
      \ -g "!{.git,.pijul,node_modules,vendor}/*" '
    
    "command! -bang -nargs=* F call fzf#vim#grep(g:rg_command .shellescape(<q-args>), 1, <bang>0)
    
    command! -bang -nargs=* Rgrust
      \ call fzf#vim#grep(
      \   'rg -g!target -g!book -g!docs --column --line-number --no-heading --smart-case --hidden -g\!.git -g\!.pijul -g\!.ccls-cache -- '.shellescape(<q-args>), 1,
      \   fzf#vim#with_preview(), <bang>0)
    
    command! -bang -nargs=* Rgg
      \ call fzf#vim#grep(
      \   'rg --column --line-number --no-heading --color=always --hidden -g\!.git -g\!.pijul -g\!.ccls-cache '.shellescape(<q-args>), 1,
      \   <bang>0 ? fzf#vim#with_preview('up:60%')
      \           : fzf#vim#with_preview('up:50%', '?'),
      \   <bang>0)
    
    " [[B]Commits] Customize the options used by 'git log':
    ""let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
    let g:fzf_commits_log_options = '--graph --date=short --color=always --format="%C(auto)%h %ad | %s%d [%an] %C(black)%C(bold)%cr"'
    
    
    " Mapping selecting mappings
    nmap <leader><tab> <plug>(fzf-maps-n)
    xmap <leader><tab> <plug>(fzf-maps-x)
    omap <leader><tab> <plug>(fzf-maps-o)
    
    " Insert mode completion
    imap <c-x><c-k> <plug>(fzf-complete-word)
    imap <c-x><c-f> <plug>(fzf-complete-path)
    imap <c-x><c-j> <plug>(fzf-complete-file-ag)
    imap <c-x><c-l> <plug>(fzf-complete-line)
    
    " For conceal markers.
    if has('conceal')
      set conceallevel=2 concealcursor=niv
    endif
    "
    "
    " Grammarous remaps
    " 
    "This above sample, when present in your .vimrc will create five handy additional normal-mode commands namely
    "gn (next error), gp (previous error), gr (ignore the error), gf (fix automatically with suggested correction),
    "gR (ignore all errors with same rule). These are available only to the current buffer and only when
    ":GrammarousCheck is active, and will disappear as soon as :GrammarousReset is used.
    let g:grammarous#hooks = {}
    function! g:grammarous#hooks.on_check(errs) abort
        nmap <buffer>gn <Plug>(grammarous-move-to-next-error)
        nmap <buffer>gp <Plug>(grammarous-move-to-previous-error)
        nmap <buffer>gr <Plug>(grammarous-move-to-info-window)r
        nmap <buffer>gas f <Plug>(grammarous-move-to-info-window)f
        nmap <buffer>gR <Plug>(grammarous-move-to-info-window)R
    endfunction
    function! g:grammarous#hooks.on_reset(errs) abort
        nunmap <buffer>gn
        nunmap <buffer>gp
        nunmap <buffer>gr
        nunmap <buffer>gf
        nunmap <buffer>gR
    endfunction
    
    
    " For more convenient vimdiffing
    if &diff
        map <leader>1 :diffget LOCAL<CR>
        map <leader>2 :diffget BASE<CR>
        map <leader>3 :diffget REMOTE<CR>
    endif
    
    " Enable hardtime by default
    let g:hardtime_default_on = 1
    let g:hardtime_ignore_quickfix = 1
    let g:hardtime_allow_different_key = 1
    let g:hardtime_maxcount = 2
    let g:hardtime_ignore_buffer_patterns = [ "NERD.*", "Tagbar*" ]
    let g:hardtime_ignore_quickfix = 1
    let g:list_of_normal_keys = ["h", "j", "k", "l", "-", "+"]
    let g:list_of_visual_keys = ["h", "j", "k", "l", "-", "+"]
    let g:list_of_insert_keys = ["<UP>", "<DOWN>", "<LEFT>", "<RIGHT>"]
    let g:list_of_disabled_keys = []
    
    " Settings for vim-visual-multi
    let g:VM_maps = {}
    let g:VM_maps['Find Under']         = '<C-å>'           " replace C-n
    let g:VM_maps['Find Subword Under'] = '<C-å>'           " replace visual C-n
    
    " Far.vim Search and replace settings
    "let g:far#source = 'rg'
    "let g:far#default_file_mask = '%:p'
    
    " shortcut for far.vim find
    "nnoremap <silent> <Find-Shortcut>  :Farf<cr>
    "vnoremap <silent> <Find-Shortcut>  :Farf<cr>
    
    " shortcut for far.vim replace
    "nnoremap <silent> <Replace-Shortcut>  :Farr<cr>
    "vnoremap <silent> <Replace-Shortcut>  :Farr<cr>
    
    let w:ProseModeOn = 0
    
    function EnableProseMode()
        setlocal spell spelllang=sv,en
    	"Goyo 66
    	Goyo 102
    	SoftPencil
    	echo "Prose Mode On"
    endfu
    
    function DisableProseMode()
    	Goyo!
    	NoPencil
    	setlocal nospell
    	echo "Prose Mode Off"
    endfu
    
    function ToggleProseMode()
    	if w:ProseModeOn == 0
    		call EnableProseMode()
    	else
    		call DisableProseMode()
    	endif
    endfu
    
    command Prose call EnableProseMode()
    command UnProse call DisableProseMode()
    command ToggleProse call ToggleProseMode()
    map <leader>pm :ToggleProse<CR>
    
    function ScratchBufferize()
    	setlocal buftype=nofile
    	setlocal bufhidden=hide
    	setlocal noswapfile
    endfu
    
    "nnoremap <Leader>d :new \| read ! sdcv <C-R><C-W> <CR>:call ScratchBufferize() <CR>:normal gg<CR>
    "nnoremap <Leader>t :new \| read ! moby <C-R><C-W> \| tr , '\n' <CR>:call ScratchBufferize() <CR>:normal gg2dd <CR>