summaryrefslogtreecommitdiff
path: root/.vim
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2023-03-10 11:03:48 +0200
committerSyndamia <kamen@syndamia.com>2023-03-10 11:03:48 +0200
commit5a70f2dc734995cfa3fff3455771a0d67a440ae3 (patch)
tree8aba3db185bf47eae87caacdb2fad7b25d074f31 /.vim
parentbe30cc55503d24f2a7d2bafab3843521b5c04540 (diff)
downloaddotfiles-5a70f2dc734995cfa3fff3455771a0d67a440ae3.tar
dotfiles-5a70f2dc734995cfa3fff3455771a0d67a440ae3.tar.gz
dotfiles-5a70f2dc734995cfa3fff3455771a0d67a440ae3.zip
[.vim] Reworked mappings and options
Diffstat (limited to '.vim')
-rw-r--r--.vim/miniplugins/statusline.vim2
-rw-r--r--.vim/startup/mappings.vim108
-rw-r--r--.vim/startup/settings.vim69
3 files changed, 97 insertions, 82 deletions
diff --git a/.vim/miniplugins/statusline.vim b/.vim/miniplugins/statusline.vim
index 12efc45..b9bdf3c 100644
--- a/.vim/miniplugins/statusline.vim
+++ b/.vim/miniplugins/statusline.vim
@@ -1,6 +1,6 @@
" Needed settings
set laststatus=2
-set timeoutlen=1000 ttimeoutlen=10
+set timeoutlen=1000 ttimeoutlen=50
set noshowmode
" Logic
diff --git a/.vim/startup/mappings.vim b/.vim/startup/mappings.vim
index 1ed6f8a..c2a9b03 100644
--- a/.vim/startup/mappings.vim
+++ b/.vim/startup/mappings.vim
@@ -1,3 +1,62 @@
+" Ctrl-C, Ctrl-V, ... {{{
+ " Partly taken from: https://gist.github.com/jshih/3423345
+ " Most use "li" instead of "i" because for some (good?) reason my cursor
+ " goes to the right after executing any of those
+ inoremap <C-S> <Esc>:w<CR>li
+ inoremap <C-V> <ESC>"+pli
+ inoremap <C-A> <ESC>ggVG
+ inoremap <C-R> <ESC><C-r>i
+ inoremap <C-U> <ESC>uli
+
+ nnoremap <C-S> <Esc>:w<CR>
+ nnoremap <C-A> ggVG
+
+ xnoremap <C-V> c<ESC>"+Pl
+ xnoremap <C-A> ggVG
+ xnoremap <C-C> "+y
+ xnoremap <C-X> "+d
+" }}}
+
+" Move lines with Alt-J, Alt-K {{{
+ execute "set <M-j>=\ej"
+ nnoremap <M-j> <ESC>:m+1<CR>
+ execute "set <M-k>=\ek"
+ nnoremap <M-k> <ESC>:m-2<CR>
+
+ xnoremap <A-j> :m '>+1<CR>gv=gv
+ xnoremap <A-k> :m '<-2<CR>gv=gv
+" }}}
+
+" Omni completion (really needs a rework) {{{
+ " Omni completion supports C, HTML, CSS, JavaScript, PHP, Python, Ruby, SQL, XML
+ set omnifunc=syntaxcomplete#Complete " Completion for all supported languages
+
+ " Do omni completion from Ctrl+Space
+ inoremap <C-@> <C-X><C-O>
+
+ " Thanks to: https://vim.fandom.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE
+ " set completeopt=longest,menuone
+ " [ The following are disabled, because they conflict with delimitMate's autobracket feature ]
+ " inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
+ " inoremap <expr> <C-n> pumvisible() ? '<C-n>' : '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
+
+ " "Disables" arrow navigation in completion menu
+ inoremap <expr> <up> pumvisible() ? '<c-y><up>' : '<up>'
+ inoremap <expr> <down> pumvisible() ? '<c-y><down>' : '<down>'
+
+ " Pressing tab goes from top to bottom
+ let g:SuperTabContextDefaultCompletionType = "<c-n>"
+" }}}
+
+" When line is wrapped, going up or down will also go into the wrapped part
+nnoremap j gj
+nnoremap k gk
+xnoremap j gj
+xnoremap k gk
+
+" Don't move cursor one character back on esc key press
+inoremap <silent> <Esc> <C-O>:stopinsert<CR>
+
" Don't get into insert mode after adding a line with o/O
nnoremap o o<Esc>
nnoremap O O<Esc>
@@ -6,36 +65,14 @@ nnoremap O O<Esc>
inoremap <C-h> <C-w>
inoremap <C-BS> <C-w>
-" Ctrl+s; Ctrl+c, Ctrl+v, Ctrl+x; Ctrl+z, Ctrl+r; Ctrl+a bindings that work on GUI applications
-" Partly taken from: https://gist.github.com/jshih/3423345
-imap <C-s> <Esc>:w<CR>i
-nmap <C-S> <Esc>:w<CR>
-"imap <C-S-z> <C-r> An impossible dream
-vmap <C-c> "+yi<Esc>
-vmap <C-v> c<ESC>"+P<Esc>
-imap <C-v> <ESC>"+Pi
-vmap <C-x> "+c<Esc>
-imap <C-z> <ESC>ui
-imap <C-r> <ESC><C-r>i
-map <C-a> ggVG
-
-" Show all buffers and be able to just type in the number of the buffer
-map <C-f> :set nomore<Bar>:ls<Bar>:set more<CR>:b<Space>
-
-" Move a line up and down with Alt+k and Alt-j
-execute "set <M-j>=\ej"
-nnoremap <M-j> <ESC>:m+1<CR>
-execute "set <M-k>=\ek"
-nnoremap <M-k> <ESC>:m-2<CR>
-vnoremap <A-j> :m '>+1<CR>gv=gv
-vnoremap <A-k> :m '<-2<CR>gv=gv
-
" Make session file
nnoremap <F1> <ESC>:mksession! .vim-session<CR>
+
" Show who edited the current line from git history
nnoremap <F8> :<C-u>call gitblame#echo()<CR>
+
" Open lazygit in a new tab with =
-nnoremap = :tab ter ++close lazygit<CR>
+nnoremap <silent> = :tab ter ++close lazygit<CR>
" Cyrillic (Bulgarian yawerty layout) support
ca в w
@@ -50,24 +87,3 @@ ca xa wa <bar> qa!
" Open a terminal vim tab with tt and open a blank tab with te
ca tt tab ter
ca te tabe
-
-" Omni completion {{{
- " Omni completion supports C, HTML, CSS, JavaScript, PHP, Python, Ruby, SQL, XML
- set omnifunc=syntaxcomplete#Complete " Completion for all supported languages
-
- " Do omni completion from Ctrl+Space
- inoremap <C-@> <C-X><C-O>
-
- " Thanks to: https://vim.fandom.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE
- " set completeopt=longest,menuone
- " [ The following are disabled, because they conflict with delimitMate's autobracket feature ]
- " inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
- " inoremap <expr> <C-n> pumvisible() ? '<C-n>' : '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
-
- " "Disables" arrow navigation in completion menu
- inoremap <expr> <up> pumvisible() ? '<c-y><up>' : '<up>'
- inoremap <expr> <down> pumvisible() ? '<c-y><down>' : '<down>'
-
- " Pressing tab goes from top to bottom
- let g:SuperTabContextDefaultCompletionType = "<c-n>"
-" }}}
diff --git a/.vim/startup/settings.vim b/.vim/startup/settings.vim
index ad215c4..d373723 100644
--- a/.vim/startup/settings.vim
+++ b/.vim/startup/settings.vim
@@ -4,52 +4,27 @@
set background=dark " Setting dark mode
" }}}
-" Character visuals {{{
- set list " Enabled customization of white space characters, so spaces, tabs, EOL, etc. (:h 'list')
+" Cursor {{{
+ set scrolloff=5 " Screen lines above and below the cursor
+ set showmatch " Cursor jumps to matching opening bracket automatically
- " Show tabs as a | with three spaces
- " DO NOT remove the trailing space in the next line!
- set listchars=tab:│\ ,extends:>,precedes:<
-
- autocmd BufReadPre,FileReadPre * call NoWrapOnLong()
- function! NoWrapOnLong()
- let maxline = system("wc -L " . bufname("%") . " | awk '{print $1}'")
- if maxline > 840
- set nowrap
- endif
- endfunction
-" }}}
-
-" Backspace and cursor {{{
- set cul " Highlight current cursor line
- autocmd InsertEnter,InsertLeave * set cul! " Don't highlight current line, when in insert mode
- set backspace=indent,eol,start " Better backspace functionality
-
- set number " Show line numbers to the left
- set scrolloff=5 " Don't keep any screen lines above or below the cursor
- set mouse=a " Mouse support
-
- set showmatch " Cursor jumps to matching opening bracket automatically
-
let &t_SI = "\e[5 q" " thin cursor on insert mode
let &t_SR = "\e[4 q" " underline on replace mode
let &t_EI = "\e[1 q" " block on normal mode
- " Don't move cursor one character back on esc key press
- inoremap <silent> <Esc> <C-O>:stopinsert<CR>
+
+ set cul " Highlight current cursor line
+ autocmd InsertEnter,InsertLeave * set cul! " Don't highlight current line, when in insert mode
" }}}
" Indentation {{{
set tabstop=4 " Show tabs as 4 wide
set shiftwidth=4 " Indent with 4 spaces
- autocmd BufRead,BufNewFile *.component.css set filetype=css
autocmd FileType css,ts setlocal ts=2 sw=2 sts=0 expandtab " Transform tabs in CSS and TS into 2 spaces
autocmd FileType lisp,scheme,haskell setlocal ts=2 sw=2 sts=0 expandtab
" }}}
" Folding {{{
- filetype plugin indent on
- syntax on " Syntax highlighting
autocmd FileType * set foldmethod=syntax " Syntax folding for all
autocmd FileType vim,text,sh,zsh,xdefaults setlocal foldmethod=marker " Overrides folding to marker for types
@@ -65,10 +40,34 @@
endfunction
" }}}
+set list " Enabled customization of white space characters, so spaces, tabs, EOL, etc. (:h 'list')
+
+" Show tabs as a | with three spaces
+" When line extends beyond the screen, use > (and <) characters
+set listchars=tab:│\ ,extends:>,precedes:<
+
+autocmd BufReadPre,FileReadPre * call NoWrapIfHasLongLine()
+function! NoWrapIfHasLongLine()
+ let longestline = system("wc -L " . bufname("%") . " | awk '{print $1}'")
+ if longestline > 840
+ set nowrap
+ endif
+endfunction
+
+set backspace=indent,eol,start " Better backspace functionality
+
+filetype plugin indent on
+syntax on " Syntax highlighting
+set number " Show line numbers to the left
+set signcolumn=number " Show signs and numbers on the same column
+set mouse=a " Mouse support
+set showcmd
+set wildmenu
+set history=1000
+
+autocmd BufRead,BufNewFile * set tw=0 " Sets textwidth to 0 for all files (set with autocmd since just doing "set tw=0" can be overridden)
+autocmd BufRead,BufNewFile *.component.css set filetype=css
+
" Language mapping for (bulgarian) cyrillic characters to english
set langmap=АA,аa,БB,бb,ВW,вw,ГG,гg,ДD,дd,ЕE,еe,ЖV,жv,ЗZ,зz,ИI,иi,ЙJ,йj,КK,кk,ЛL,лl,МM,мm,НN,нn,ОO,оo,ПP,пp,РR,рr,СS,сs,ТT,тt,УU,уu,ФF,фf,ХH,хh,ЦC,цc,Ч~,ч`,Ш{,ш[,Щ},щ],ЪY,ъy,ЬX,ьx,Ю\|,ю\\,ЯQ,яq
set spelllang=en,bg_BG " Adds Bulgarian to spelling languages
-
-autocmd BufRead,BufNewFile * set tw=0 " Sets textwidth to 0 for all files (set with autocmd since just doing "set tw=0" can be overridden)
-set signcolumn=number " Show signs and numbers on the same column
-set showcmd