dotfiles/.vim/vimrc
2025-05-09 23:15:55 +02:00

268 lines
7.7 KiB
VimL

" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2019 Dec 17
"
" To use it, copy it to
" for Unix: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-Windows: $VIM\_vimrc
" for Haiku: ~/config/settings/vim/vimrc
" for OpenVMS: sys$login:.vimrc
" When started as "evim", evim.vim will already have done these settings, bail
" out.
if v:progname =~? "evim"
finish
endif
" Get the defaults that most users want.
source $VIMRUNTIME/defaults.vim
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file (restore to previous version)
if has('persistent_undo')
set undofile " keep an undo file (undo changes after closing)
endif
endif
if &t_Co > 2 || has("gui_running")
" Switch on highlighting the last used search pattern.
set hlsearch
endif
nnoremap <silent> <C-l> :<C-u> nohlsearch<CR><C-l>
set swapfile
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
autocmd FileType text setlocal colorcolumn=79
autocmd FileType c setlocal textwidth=90
autocmd FileType c setlocal colorcolumn=91
augroup END
" Add optional packages.
"
" The matchit plugin makes the % command work better, but it is not backwards
" compatible.
" The ! means the package won't be loaded right away but when plugins are
" loaded during initialization.
if has('syntax') && has('eval')
packadd! matchit
endif
let g:lisp_rainbow=1
filetype plugin indent on
autocmd BufNewFile,BufRead *.hsc set filetype=haskell
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
let mapleader = " "
" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'kovisoft/slimv'
Plug 'vim-scripts/paredit.vim'
Plug 'sillybun/vim-repl'
Plug 'cpcsdk/vim-z80-democoding'
" Plug 'khorser/vim-repl'
Plug 'lervag/vimtex'
Plug 'chrisdone/hindent'
Plug 'neovimhaskell/haskell-vim'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" Plug 'dense-analysis/ale'
Plug 'nvie/vim-flake8'
Plug 'joshdick/onedark.vim'
Plug 'sainnhe/everforest'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
Plug 'tpope/vim-surround'
Plug 'sjl/badwolf'
Plug 'sheerun/vim-polyglot'
Plug 'Shougo/vimproc.vim', {'do' : 'make'}
Plug 'Valloric/YouCompleteMe'
Plug 'SirVer/ultisnips'
Plug 'vimwiki/vimwiki'
Plug 'tpope/vim-rails'
let g:repl_program = {
\ 'python': ['ipython', 'python', 'ipython -i LOCAL', 'ipython -i LOCAL DEBUG'],
\ 'scheme': ['chicken-csi'],
\ 'tcl': ['wish'],
\ 'default': ['bash']
\ }
nnoremap <leader>r <cmd>REPLToggle<cr>
let g:slimv_swank_cmd = '! foot sbcl --load /usr/share/common-lisp/source/swank/start-swank.lisp &'
nnoremap <localleader>s <cmd>call g:SlimvConnectSwank<cr>
nnoremap <localleader>s <cmd>call g:SlimvConnectSwank()<cr>
let g:ycm_collect_identifiers_from_tags_files = 1 " Let YCM read tags from Ctags file
let g:ycm_use_ultisnips_completer = 1 " Default 1, just ensure
let g:ycm_seed_identifiers_with_syntax = 1 " Completion for programming language's keyword
let g:ycm_complete_in_comments = 1 " Completion in comments
let g:ycm_complete_in_strings = 1 " Completion in string
let g:UltiSnipsExpandTrigger = '<Tab>' " use jk to expand snippets
let g:UltiSnipsJumpForwardTrigger = 'jk' " use Tab to move forward through tabstops
let g:UltiSnipsJumpBackwardTrigger = 'kj' " use Shift-Tab to move backward through tabstops
let g:UltiSnipsSnippetDirectories = [$HOME.'/.vim/UltiSnips'] " using Vim
let g:UltiSnipsEditSplit = 'context'
set cursorline
nnoremap <leader>s :UltiSnipsEdit<CR>
nnoremap <leader>S :call UltiSnips#RefreshSnippets() <CR>
"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
"If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support
"(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
if (empty($TMUX))
if (has("nvim"))
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
if (has("termguicolors"))
set termguicolors
endif
endif
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" Initialize plugin system
call plug#end()
if has('patch-8.1.1880')
set completeopt=longest,menuone,popuphidden
" Highlight the completion documentation popup background/foreground the same as
" the completion menu itself, for better readability with highlighted
" documentation.
set completepopup=highlight:Pmenu,border:off
else
set completeopt=longest,menuone,preview
" Set desired preview window height for viewing documentation.
set previewheight=5
endif
syntax on
let g:onedark_terminal_italics=1
" colorscheme onedark
" colorscheme badwolf
set background=dark
colorscheme everforest
colorscheme catppuccin_frappe
" colorscheme delek
set number relativenumber
set foldmethod=indent
set foldlevel=99
"set expandtab!
set tabstop=8
set shiftwidth=8
nnoremap <leader>v :vert new ~/.vim/vimrc<CR>
nnoremap <leader>V :source ~/.vim/vimrc<CR>
function! s:goyo_enter()
if executable('tmux') && strlen($TMUX)
silent !tmux set status off
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
endif
set noshowmode
set noshowcmd
set scrolloff=999
Limelight
" ...
endfunction
function! s:goyo_leave()
if executable('tmux') && strlen($TMUX)
silent !tmux set status on
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
endif
set showmode
set showcmd
set scrolloff=5
Limelight!
" ...
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
noremap <leader>Z <Cmd>Goyo<CR>
autocmd BufNewFile,BufRead *.inc set filetype=z80
au BufNewFile, BufRead *.py
\ set tabstop=4
\ set softtabstop=4
\ set shiftwidth=4
\ set textwidth=79
\ set expandtab
\ set autoindent
\ set fileformat=unix
autocmd FileType haskell set tabstop=4
autocmd FileType haskell set softtabstop=4
autocmd FileType haskell set shiftwidth=4
autocmd FileType haskell set textwidth=120
autocmd FileType haskell set expandtab
autocmd FileType haskell set autoindent
autocmd FileType haskell set fileformat=unix
autocmd FileType python set sw=4
autocmd FileType python set ts=4
autocmd FileType python set sts=4
let s:keymaps = ['', 'serbian-latin_utf-8', 'serbian_utf-8', 'german-qwerty']
let s:keymap_ind=0
function! ToggleKeymaps()
if s:keymap_ind == len(s:keymaps) - 1
let s:keymap_ind=0
else
let s:keymap_ind+=1
endif
execute "set keymap=" . s:keymaps[s:keymap_ind]
endfunction
imap <c-l> <c-o><cmd>call ToggleKeymaps()<CR>
let projectroot = trim(execute('pwd'))
if ("/home/kappa/projects/working/galaksija-game-and-guide/igra" == projectroot)
nnoremap <leader>x <cmd>w<CR> <cmd>!make play<CR>
endif
let g:vimwiki_list = [{'path': '~/docs/vimwiki/'}]