mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-13 22:53:07 +00:00
chore(config): vim: split config, tweaks
Signed-off-by: Ismo Vuorinen <ismo@ivuorinen.net>
This commit is contained in:
64
config/vim/after/autocmd.vim
Normal file
64
config/vim/after/autocmd.vim
Normal file
@@ -0,0 +1,64 @@
|
||||
"" The PC is fast enough, do syntax highlight
|
||||
"" syncing from start 6nless 200 lines
|
||||
augroup vimrc-sync-fromstart
|
||||
autocmd!
|
||||
autocmd BufEnter * :syntax sync maxlines=600
|
||||
augroup END
|
||||
|
||||
"" txt
|
||||
augroup vimrc-wrapping
|
||||
autocmd!
|
||||
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
|
||||
augroup END
|
||||
|
||||
"" make/cmake
|
||||
augroup vimrc-make-cmake
|
||||
autocmd!
|
||||
autocmd FileType make setlocal noexpandtab
|
||||
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
|
||||
augroup END
|
||||
|
||||
set autoread
|
||||
|
||||
""" Create/get autocommand group
|
||||
function! s:CreateAugroup(name) abort
|
||||
execute 'augroup' a:name
|
||||
autocmd!
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
" Highlight on yank
|
||||
" See `:help vim.highlight.on_yank()`
|
||||
call s:CreateAugroup('YankHighlight')
|
||||
autocmd YankHighlight TextYankPost * silent! lua vim.highlight.on_yank()
|
||||
|
||||
" Set the numberwidth to the maximum line number.
|
||||
" Fixes the issue where the line numbers jump
|
||||
" around when moving between lines with relative line numbers enabled.
|
||||
call s:CreateAugroup('AdjustNumberWidth')
|
||||
autocmd AdjustNumberWidth BufEnter,BufWinEnter,TabEnter *
|
||||
\ let max_line_count = line('$') |
|
||||
\ if max_line_count > 99 |
|
||||
\ let &numberwidth = strlen(string(max_line_count)) + 1
|
||||
\ endif
|
||||
|
||||
" Windows to close with "q"
|
||||
call s:CreateAugroup('close_with_q')
|
||||
autocmd close_with_q FileType checkhealth,dbout,gitsigns.blame,grug-far,help,
|
||||
\ lspinfo,man,neotest-output,neotest-output-panel,neotest-summary,notify,
|
||||
\ qf,spectre_panel,startuptime,tsplayground
|
||||
\ setlocal buflisted=false |
|
||||
\ nnoremap <silent> <buffer> q :close<CR>
|
||||
|
||||
" Make it easier to close man-files when opened inline
|
||||
call s:CreateAugroup('man_unlisted')
|
||||
autocmd man_unlisted FileType man setlocal buflisted=false
|
||||
|
||||
" Wrap and check for spell in text filetypes
|
||||
call s:CreateAugroup('wrap_spell')
|
||||
autocmd wrap_spell FileType text,plaintex,typst,gitcommit,markdown,asciidoc,rst,tex
|
||||
\ setlocal wrap spell
|
||||
|
||||
" Fix conceallevel for json files
|
||||
call s:CreateAugroup('json_conceal')
|
||||
autocmd json_conceal FileType json,jsonc,json5 setlocal conceallevel=0
|
||||
26
config/vim/after/colors.vim
Normal file
26
config/vim/after/colors.vim
Normal file
@@ -0,0 +1,26 @@
|
||||
function! ChangeColorScheme(channel, msg)
|
||||
let time = trim(a:msg)
|
||||
if time ==# "Dark"
|
||||
set background="dark"
|
||||
else
|
||||
set background="light"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! CheckStatus(timer)
|
||||
if executable("defaults")
|
||||
let job = job_start(
|
||||
\ ["defaults", "read", "-g", "AppleInterfaceStyle"],
|
||||
\ {"out_cb": "ChangeColorScheme"}
|
||||
\ )
|
||||
else
|
||||
set background="dark"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! AutoDarkModeSetup()
|
||||
let timer = timer_start(3000, 'CheckStatus', {'repeat': -1})
|
||||
call CheckStatus(timer) " Initial call to setup the theme
|
||||
endfunction
|
||||
|
||||
call AutoDarkModeSetup()
|
||||
113
config/vim/after/mappings.vim
Normal file
113
config/vim/after/mappings.vim
Normal file
@@ -0,0 +1,113 @@
|
||||
"*****************************************************************************
|
||||
"" Abbreviations
|
||||
"*****************************************************************************
|
||||
"" no one is really happy until you have this shortcuts
|
||||
cnoreabbrev W! w! " force write
|
||||
cnoreabbrev Q! q! " force quit
|
||||
cnoreabbrev Qall! qall! " force quit all
|
||||
cnoreabbrev Wq wq " write and quit
|
||||
cnoreabbrev Wa wa " write all
|
||||
cnoreabbrev wQ wq " write and quit
|
||||
cnoreabbrev WQ wq " write and quit
|
||||
cnoreabbrev W w " write
|
||||
cnoreabbrev Q q " quit
|
||||
cnoreabbrev Qall qall " quit all
|
||||
|
||||
"*****************************************************************************
|
||||
"" Mappings
|
||||
"*****************************************************************************
|
||||
|
||||
noremap <C-S> :w<CR> " save buffer
|
||||
|
||||
" Split
|
||||
noremap <Leader>h :<C-u>split<CR> " horizontal split
|
||||
noremap <Leader>v :<C-u>vsplit<CR> " vertical split
|
||||
|
||||
" Git
|
||||
noremap <Leader>ga :Gwrite<CR>
|
||||
noremap <Leader>gc :Git commit --verbose<CR>
|
||||
noremap <Leader>gsh :Git push<CR>
|
||||
noremap <Leader>gll :Git pull<CR>
|
||||
noremap <Leader>gs :Git<CR>
|
||||
noremap <Leader>gb :Git blame<CR>
|
||||
noremap <Leader>gd :Gvdiffsplit<CR>
|
||||
noremap <Leader>gr :GRemove<CR>
|
||||
|
||||
" session management
|
||||
nnoremap <leader>so :OpenSession<Space>
|
||||
nnoremap <leader>ss :SaveSession<Space>
|
||||
nnoremap <leader>sd :DeleteSession<CR>
|
||||
nnoremap <leader>sc :CloseSession<CR>
|
||||
|
||||
" Tabs
|
||||
nnoremap <Tab> gt " next tab
|
||||
nnoremap <S-Tab> gT " previous tab
|
||||
nnoremap <silent> <S-t> :tabnew<CR> " new tab
|
||||
|
||||
nnoremap <leader>. :lcd %:p:h<CR> " set working directory to the current file
|
||||
|
||||
" Opens an edit command with the path of the currently
|
||||
" edited file filled in
|
||||
noremap <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
|
||||
|
||||
" Opens a tab edit command with the path of the currently
|
||||
" edited file filled
|
||||
noremap <Leader>r :tabe <C-R>=expand("%:p:h") . "/" <CR>
|
||||
|
||||
" fzf.vim
|
||||
let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'vendor/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null"
|
||||
|
||||
cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
|
||||
nnoremap <silent> <leader>b :Buffers<CR>
|
||||
nnoremap <silent> <leader>e :FZF -m<CR>
|
||||
" Recovery commands from history through FZF
|
||||
nmap <leader>y :History:<CR>
|
||||
|
||||
" Tagbar
|
||||
nmap <silent> <F4> :TagbarToggle<CR> " open tagbar
|
||||
let g:tagbar_autofocus = 1
|
||||
|
||||
" Disable visualbell
|
||||
set noerrorbells visualbell t_vb=
|
||||
if has('autocmd')
|
||||
autocmd GUIEnter * set visualbell t_vb=
|
||||
endif
|
||||
|
||||
"" Copy/Paste/Cut
|
||||
if has('unnamedplus')
|
||||
set clipboard=unnamed,unnamedplus
|
||||
endif
|
||||
|
||||
noremap YY "+y<CR> " copy line
|
||||
noremap <leader>p "+gP<CR> " paste
|
||||
noremap XX "+x<CR> " cut
|
||||
|
||||
if has('macunix')
|
||||
" pbcopy for OSX copy/paste
|
||||
vmap <C-x> :!pbcopy<CR> " copy
|
||||
vmap <C-c> :w !pbcopy<CR><CR> " cut
|
||||
vmap <C-v> :!pbpaste<CR> " paste
|
||||
endif
|
||||
|
||||
"" Buffer nav
|
||||
noremap <leader>z :bp<CR> " previous buffer
|
||||
noremap <leader>x :bn<CR> " next buffer
|
||||
noremap <leader>bq :bp<CR> " previous buffer
|
||||
noremap <leader>bw :bn<CR> " next buffer
|
||||
noremap <leader>bd :bd<CR> " close buffer
|
||||
|
||||
|
||||
"" Switching windows
|
||||
noremap <C-j> <C-w>j " move to window below
|
||||
noremap <C-k> <C-w>k " move to window above
|
||||
noremap <C-l> <C-w>l " move to window right
|
||||
noremap <C-h> <C-w>h " move to window left
|
||||
|
||||
vmap < <gv " move visual block left, keep selection
|
||||
vmap > >gv " move visual block right, keep selection
|
||||
vnoremap J :m '>+1<CR>gv=gv " move visual block down, keep selection
|
||||
vnoremap K :m '<-2<CR>gv=gv " move visual block up, keep selection
|
||||
|
||||
nnoremap <Leader>o :.GBrowse<CR> " open current line on GitHub
|
||||
nnoremap <silent> <leader>sh :terminal<CR> " open a new terminal
|
||||
nnoremap <silent> <esc><esc> :noh<cr> " clean search
|
||||
84
config/vim/after/settings.vim
Normal file
84
config/vim/after/settings.vim
Normal file
@@ -0,0 +1,84 @@
|
||||
let mapleader=' ' " Map leader to <space>
|
||||
filetype off " disable filetype detection (but re-enable later, see below)
|
||||
|
||||
" find matching tags in html/xml documents using matchit
|
||||
filetype plugin on
|
||||
packadd! matchit
|
||||
" disable super buggy netrw
|
||||
let g:loaded_netrw=1
|
||||
let g:netrw_loaded_netrwPlugin=1
|
||||
" show JSDoc highlight colors
|
||||
let g:javascript_plugin_jsdoc=1
|
||||
|
||||
set backspace=indent,eol,start " Backspace behavior
|
||||
set cindent " Use 'C' style program indenting
|
||||
set cursorline " Highlight current line
|
||||
set encoding=utf-8 " UTF-8
|
||||
set expandtab " Use spaces instead of tabs
|
||||
set fileformats=unix,dos,mac " File formats
|
||||
set foldmethod=indent " Fold based on indent
|
||||
set foldlevel=99 " Open all folds
|
||||
set guioptions=egmrti " GUI options
|
||||
set hidden " Enable hidden buffers
|
||||
set ignorecase " Always case-insensitive
|
||||
set incsearch " Searches for strings incrementally
|
||||
set laststatus=2 " Always show statusline (even with only single window)
|
||||
set linespace=3 " Set line spacing
|
||||
set list " Show invisible characters
|
||||
set listchars=tab:⌴\ ,trail:◼,nbsp:•,extends:…,precedes:… " Invisible characters
|
||||
set modeline " Enable modelines
|
||||
set modelines=3 " Number of lines to check for modelines
|
||||
set mouse=a " Enable mouse support
|
||||
set mousemodel=popup " Enable mouse support
|
||||
set nobackup " Disable backup files
|
||||
set nocompatible " disable compatibility mode with vi
|
||||
set nowritebackup " Disable backup files
|
||||
set number " Show line numbers
|
||||
set relativenumber " Show relative line numbers
|
||||
set ruler " Show row and column ruler information
|
||||
set scrolloff=8 " Minimum number of lines to keep above and below the cursor
|
||||
set shiftwidth=4 " Number of auto-indent spaces
|
||||
set shortmess+=A " Don't show autocommand messages
|
||||
set shortmess+=F " Avoid showing the "file-info" message
|
||||
set shortmess+=I " Don't show intro message
|
||||
set shortmess+=O " Avoid showing the "file-read" message
|
||||
set shortmess+=O " Don't show overlength messages
|
||||
set shortmess+=T " Don't show title messages
|
||||
set shortmess+=W " Don't show "written" messages
|
||||
set shortmess+=a " Avoid showing the "ATTENTION" message
|
||||
set shortmess+=c " Avoid showing the "ins-completion-menu" message
|
||||
set shortmess+=c " Don't pass messages to |ins-completion-menu|
|
||||
set shortmess+=o " Avoid showing the "overlength" message
|
||||
set shortmess+=t " Avoid showing the "trailing whitespace" message
|
||||
set showcmd " Show command in status line
|
||||
set showmatch " Highlight matching brace
|
||||
set signcolumn=yes " Show sign column
|
||||
set smartcase " Enable smart-case search
|
||||
set smartindent " Enable smart-indent
|
||||
set smarttab " Enable smart-tabs
|
||||
set softtabstop=4 " Number of spaces per Tab
|
||||
set spelllang=fi,en " Set the spell language
|
||||
set spellsuggest=double " Suggest the first word when spell checking
|
||||
set t_Co=256 " 256 colors
|
||||
set termguicolors " Enable 24-bit RGB color in the terminal
|
||||
set timeoutlen=500 " By default timeoutlen=1000 (ms)
|
||||
set ttimeoutlen=0 " By default ttimeoutlen=-1 (ms)
|
||||
set undolevels=1000 " Number of undo levels
|
||||
set visualbell " Use visual bell (no beeping)
|
||||
set wildmenu " Enable wildmenu
|
||||
set wildmode=longest,list:longest " Command-line completion mode
|
||||
set wrap " Wrap lines
|
||||
set wrapscan " Searches wrap around the end of the file
|
||||
|
||||
" Ignore these files in wildmenu
|
||||
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__,vendor
|
||||
|
||||
colorscheme iceberg " Set the color scheme
|
||||
filetype plugin indent on " enable filetype detection, plugins and indenting
|
||||
|
||||
" Set the shell
|
||||
if exists('$SHELL')
|
||||
set shell=$SHELL
|
||||
else
|
||||
set shell=/bin/sh
|
||||
endif
|
||||
34
config/vim/after/ui.vim
Normal file
34
config/vim/after/ui.vim
Normal file
@@ -0,0 +1,34 @@
|
||||
" GUI settings
|
||||
if has("gui_running")
|
||||
if has("gui_mac") || has("gui_macvim")
|
||||
set macligatures
|
||||
set guifont=JetBrains\ Mono:h14
|
||||
set transparency=7
|
||||
endif
|
||||
else
|
||||
let g:CSApprox_loaded = 1
|
||||
|
||||
" IndentLine
|
||||
let g:indentLine_enabled = 1
|
||||
let g:indentLine_concealcursor = ''
|
||||
let g:indentLine_char = '┆'
|
||||
let g:indentLine_faster = 1
|
||||
|
||||
if $COLORTERM == 'gnome-terminal'
|
||||
set term=gnome-256color
|
||||
else
|
||||
if $TERM == 'xterm'
|
||||
set term=xterm-256color
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
" if terminal supports 256 colors, disable t_ut
|
||||
if &term =~ '256color'
|
||||
set t_ut=
|
||||
endif
|
||||
|
||||
" set the title of the terminal to the file name
|
||||
set title
|
||||
set titleold="Terminal"
|
||||
set titlestring=%F
|
||||
Reference in New Issue
Block a user