vim_config/vimrc

205 lines
5.7 KiB
VimL
Raw Normal View History

2021-06-11 19:35:22 +02:00
let $VIMHOME = expand('~/.vim')
let s:sep = has('win32') ? '\' : '/'
" check if in tty
let g:is_tty = system('case $(tty) in (/dev/tty[0-9]) echo 1;; (*) echo 0;; esac')
2021-06-22 22:55:50 +02:00
" set user_dir
if has('nvim')
let s:user_dir = stdpath('config')
else
let s:user_dir = has('win32') ? expand('~/vimfiles') : expand('~/.vim')
endif
2021-06-11 19:35:22 +02:00
""" Set python3 path
let g:python3_host_prog = "/usr/bin/python"
let g:python_host_prog='/usr/bin/python'
2023-06-15 18:03:47 +02:00
""" leader mapping
let mapleader = ','
2021-06-11 22:55:32 +02:00
""" source
" all other includes are in alphabetical order
source $VIMHOME/config/before/ale.vim
2023-06-15 18:04:19 +02:00
source $VIMHOME/config/before/copilot.vim
source $VIMHOME/config/before/fzf.vim
source $VIMHOME/config/before/indent.vim
source $VIMHOME/config/before/language-client.vim
source $VIMHOME/config/before/mucomplete.vim
source $VIMHOME/config/before/nerdtree.vim
source $VIMHOME/config/before/powerline.vim
source $VIMHOME/config/before/rg.vim
source $VIMHOME/config/before/theme.vim " this sets the colorscheme
source $VIMHOME/config/before/vim-go.vim
source $VIMHOME/config/before/vim-rooter.vim
packloadall
source $VIMHOME/config/after/ale.vim
2022-01-28 15:57:47 +01:00
source $VIMHOME/config/after/language-client.vim
2022-02-21 18:45:38 +01:00
source $VIMHOME/config/after/reader.vim
2021-06-11 19:35:22 +02:00
""" general
2021-06-22 22:49:57 +02:00
filetype plugin indent on
2021-06-11 19:35:22 +02:00
set nospell
" restore screen after quitting
" au VimLeave * :!clear
2021-06-15 17:07:01 +02:00
syntax on
2021-06-11 19:35:22 +02:00
silent! helptags ALL
" Enable persistent undo
2021-06-11 22:55:32 +02:00
set undodir=$VIMHOME/.undo/
2021-06-11 19:35:22 +02:00
set undofile
set undolevels=1000 "maximum number of changes that can be undone
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
" Automatically re-open files after they have changed without prompting.
" This can be a little more destructive, but a lot less annoying.
set autoread
set autoindent
set showmatch
" Put all special files in the right place
2021-06-11 22:55:32 +02:00
set backupdir=$VIMHOME/.backup/
set directory=$VIMHOME/.swp/
2021-06-11 19:35:22 +02:00
" Draw tabs and trailing spaces.
" set listchars=tab:<->
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
set listchars=tab:\ ,trail:•,extends:#,nbsp:.
"set listchars=tab:-->,trail:$,extends:#,nbsp:.
hi IndentGuidesOdd ctermbg=white
hi IndentGuidesEven ctermbg=lightgrey
set list
" Set the right margin.
set colorcolumn=89
" Automatically split words at the margin.
" set wrap
" Default to spaces instead of tabs
set expandtab
" Set tab width to 4.
set tabstop=4
set shiftwidth=4
" Setting this will make backspace delete space indents
set softtabstop=4
" Disable automatic wrapping.
set textwidth=0
" Enable highlight on search patterns matches
set hlsearch
hi Search guibg=Purple
" define line highlight color
highlight LineHighlight ctermbg=darkgray guibg=Purple
" Make :Q and :W work like :q and :w
command! W w
command! Q q
2021-06-11 22:55:32 +02:00
command! QA qa
2021-06-11 19:35:22 +02:00
command! WQ wq
command! Wq wq
2021-06-11 22:55:32 +02:00
command! Wqa wqa
command! WQA wqa
2021-06-11 19:35:22 +02:00
command! WW w ! sudo tee %:t
" Make completion smarter.
set ignorecase
set smartcase
" viminfo settings
" '100 : Remember marks for 100 previously edited files.
" <50 : ???
" s10 : ???
" h : ???
" "100 : Save 100 lines for each register
" :50 : Remember 50 lines of command history
set viminfo='100,<50,s10,h,\"100,:50
" Jump at last opened cursor position position, if valid
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
" Warn about not being able to write to .viminfo, which messes up restoring
" the cursor position when editing.
let s:info_filename = expand('~/.viminfo')
if !empty(glob(s:info_filename)) && !filewritable(s:info_filename)
echoerr 'The .viminfo file cannot be written to!'
endif
2022-09-27 18:06:26 +02:00
""" Set dockerfile syntax
autocmd BufNewFile,BufRead Dockerfile* set ft=Dockerfile
2024-06-22 23:13:41 +02:00
""" Disable SQLAutocomplete
let g:loaded_sql_completion = 0
2021-06-11 19:35:22 +02:00
""" keybindings
noremap <leader>ad :ALEGoToDefinition<CR>
nnoremap <leader>af :ALEFix<cr>
nnoremap <leader>ah :ALEHover<cr>
noremap <leader>ar :ALEFindReferences<CR>
nnoremap <leader>r :ALENextWrap<CR>
nnoremap <leader>R :ALEPreviousWrap<CR>
nnoremap <silent> <C-d> :bd<CR>
nnoremap <leader>e :NERDTree<CR>
nnoremap <leader>r :redo<CR>
nnoremap <C-h> <C-w><Left>
nnoremap <C-j> <C-w><Down>
nnoremap <C-k> <C-w><Up>
nnoremap <C-l> <C-w><Right>
nnoremap <leader>b :Gblame<CR>
nnoremap <C-p> :FZF<CR>
2021-06-22 22:50:21 +02:00
nnoremap <leader>f :Buffers<CR>
2021-06-11 19:35:22 +02:00
nnoremap <C-F> :Files<CR>
2022-09-27 18:06:26 +02:00
nnoremap <C-g> :Rg<CR>
nnoremap <leader>k :exe "Rg " . expand("<cword>")<cr>
2021-06-11 19:35:22 +02:00
nnoremap <leader>s :call Fzf_dev()<CR>
nnoremap <leader>c :Commits<CR>
2021-10-08 10:10:45 +02:00
nnoremap <leader>b :Git blame<CR>
2022-09-27 18:06:26 +02:00
nnoremap <leader>gh :exe "Git log -L:" . expand("<cword>") . ":" . expand("%")<cr>
2021-06-11 19:35:22 +02:00
nnoremap <leader><esc> :silent! nohls<CR>:call clearmatches()<CR>
nnoremap <leader><Tab> :bnext<CR>
nnoremap <leader>\ :bprev<CR>
nnoremap <Leader>m <Plug>ToggleMarkbar
nnoremap <Leader>mo <Plug>OpenMarkbar
nnoremap <Leader>mc <Plug>CloseMarkbar
nnoremap <Leader>L :call LightOrDarkness()<CR>
map <Leader>y <Plug>(operator-poweryank-osc52)
" Following three from here: https://github.com/vim/vim/issues/5157#issue-516033639
xnoremap "+y y:call system("wl-copy", @")<cr>
nnoremap "+p :let @"=substitute(system("wl-paste --no-newline"), '<C-v><C-m>', '', 'g')<cr>p
nnoremap "*p :let @"=substitute(system("wl-paste --no-newline --primary"), '<C-v><C-m>', '', 'g')<cr>p
nnoremap <Leader>u :UndotreeShow<CR>:UndotreeFocus<CR>
" highlight the current line
2022-09-27 18:05:19 +02:00
"nnoremap l :call matchadd('LineHighlight', '\%'.line('.').'l')<CR>
" Limelight and Goyo
nnoremap <Leader>l :Limelight!!<CR>
xnoremap <Leader>l :Limelight!!<CR>
nnoremap <Leader>G :Goyo<CR>
xnoremap <Leader>G :Goyo<CR>
" Move lines
2021-06-11 19:35:22 +02:00
nnoremap <silent> <C-Down> :m .+1<CR>==
nnoremap <silent> <C-Up> :m .-2<CR>==
inoremap <silent> <C-Down> <Esc>:m .+1<CR>==gi
inoremap <silent> <C-Up> <Esc>:m .-2<CR>==gi
vnoremap <silent> <C-Down> :m '>+1<CR>gv=gv
vnoremap <silent> <C-Up> :m '<-2<CR>gv=gv
" vim: set et sw=0 ts=4 sts=0: