From d5151c31464962392efa8f01c9101f3ee7252151 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 2 Jun 2023 08:10:19 +0300 Subject: [.vim] Moved startup scripts to .vim/ folder --- .vim/.vimrc | 8 +-- .vim/mappings.vim | 119 ++++++++++++++++++++++++++++++++++++++++ .vim/pluginsettings.vim | 58 ++++++++++++++++++++ .vim/settings.vim | 86 +++++++++++++++++++++++++++++ .vim/startup/mappings.vim | 119 ---------------------------------------- .vim/startup/pluginsettings.vim | 58 -------------------- .vim/startup/settings.vim | 86 ----------------------------- 7 files changed, 267 insertions(+), 267 deletions(-) create mode 100644 .vim/mappings.vim create mode 100644 .vim/pluginsettings.vim create mode 100644 .vim/settings.vim delete mode 100644 .vim/startup/mappings.vim delete mode 100644 .vim/startup/pluginsettings.vim delete mode 100644 .vim/startup/settings.vim (limited to '.vim') diff --git a/.vim/.vimrc b/.vim/.vimrc index b2ca834..b9181cc 100644 --- a/.vim/.vimrc +++ b/.vim/.vimrc @@ -1,5 +1,5 @@ -runtime startup/settings.vim -runtime startup/mappings.vim +runtime settings.vim +runtime mappings.vim call plug#begin('~/.vim/plugged') @@ -30,7 +30,7 @@ Plug 'digitaltoad/vim-pug', { 'for': ['jade', 'pug'] } " Pug: Filetype detec Plug 'bfrg/vim-cpp-modern', { 'for': ['c', 'cpp'] } " C/C++: Better syntax highlighting Plug 'itchyny/vim-haskell-indent', { 'for': 'haskell' } " haskell: Adds identation Plug 'vim-scripts/syntaxhaskell.vim', { 'for': 'haskell' } " haskell: Better syntax highlighting -Plug 'AndrewRadev/id3.vim' +Plug 'AndrewRadev/id3.vim' " mp3: Proper metadata editing Plug 'https://gitlab.com/Syndamia/texty-office.vim' @@ -51,5 +51,5 @@ runtime miniplugins/statusline.vim runtime miniplugins/tabline.vim runtime miniplugins/spell_check_mode.vim -runtime startup/pluginsettings.vim +runtime pluginsettings.vim diff --git a/.vim/mappings.vim b/.vim/mappings.vim new file mode 100644 index 0000000..1eb4a30 --- /dev/null +++ b/.vim/mappings.vim @@ -0,0 +1,119 @@ +" Ctrl-C, Ctrl-V, ... {{{ + " Partly taken from: https://gist.github.com/jshih/3423345 + inoremap :w + inoremap + + inoremap ggVG + inoremap + inoremap u + + nnoremap :w + nnoremap ggVG + + xnoremap c+ + xnoremap ggVG + xnoremap "+y + xnoremap "+d +" }}} + +" Move lines with Alt-J, Alt-K {{{ + execute "set =\ej" + nnoremap :m+1 + execute "set =\ek" + nnoremap :m-2 + + xnoremap :m '>+1gv=gv + xnoremap :m '<-2gv=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 + + " 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 pumvisible() ? "\" : "\u\" + " inoremap pumvisible() ? '' : '=pumvisible() ? "\Down>" : ""' + + " "Disables" arrow navigation in completion menu + inoremap pumvisible() ? '' : '' + inoremap pumvisible() ? '' : '' + + " Pressing tab goes from top to bottom + let g:SuperTabContextDefaultCompletionType = "" +" }}} + +" When line is wrapped, going up or down will also go into the wrapped part +" move in wrapped lines when no count prefix +nnoremap k (v:count == 0 ? 'gk' : 'k') +xnoremap k (v:count == 0 ? 'gk' : 'k') +nnoremap j (v:count == 0 ? 'gj' : 'j') +xnoremap j (v:count == 0 ? 'gj' : 'j') + +" Don't move cursor one character back on esc key press +" inoremap :stopinsert + +" Don't get into insert mode after adding a line with o/O +" nnoremap o o +" nnoremap O O + +" Thanks https://github.com/drzel/vim-split-line +nnoremap K :keep s/\s*\%#\s*/\r/e noh + +" Better resizing when navigating splits +nnoremap l= +nnoremap h= +nnoremap j= +nnoremap k= + +" Ctrl-Backspace deletes the previous word in insert mode. +inoremap +cnoremap +inoremap +cnoremap + +" Make session file +nnoremap :mksession! .vim-session + +" Show who edited the current line from git history +nnoremap :call gitblame#echo() + +" Open lazygit in a new tab with = +nnoremap \| :tab ter ++close lazygit + +" Tab navigtion +execute "set =\eo" +nnoremap gT +inoremap gT +tnoremap gT +execute "set =\ep" +nnoremap gt +inoremap gt +tnoremap gt + +" Arrows = bad +inoremap +inoremap +inoremap +inoremap +nnoremap +nnoremap +nnoremap +nnoremap + +" Cyrillic (Bulgarian yawerty layout) support +ca в w +ca ва wa +ca ь x +ca ьа xa + +" Make x and xa just save and quit without saving. This allows for closing all tabs and terminals. +ca x w q! +ca xa wa qa! + +" Open a terminal vim tab with tt and open a blank tab with te +ca tt tab ter +ca te tabe diff --git a/.vim/pluginsettings.vim b/.vim/pluginsettings.vim new file mode 100644 index 0000000..72757f5 --- /dev/null +++ b/.vim/pluginsettings.vim @@ -0,0 +1,58 @@ +" DelimitMate {{{ + let delimitMate_expand_cr = 1 + " Don't autocomplete diamond brackets in HTML (compatibility with closetag plugin) + autocmd FileType html let b:delimitMate_matchpairs='(:),[:],{:}' +" }}} + +" NERDTree {{{ + " Toggle NERDTree with Tab + nmap :NERDTreeToggle + + let NERDTreeCustomOpenArgs = {'file':{'where':'t'}} " Open file in new tab, doesn't work only for double-click + let NERDTreeShowHidden = 1 + let NERDTreeWinPos = "right" + let NERDTreeIgnore = ['\.swp$', '\~$'] " Ignore file, ending with .swp and ~ + + " Do not save blank screens, solves https://github.com/preservim/nerdtree/issues/745 + set sessionoptions-=blank +" }}} + +" Undotree {{{ + " Toggle undotree with F5 + nmap :UndotreeToggle + + let g:undotree_WindowLayout = 2 + let g:undotree_ShortIndicators = 1 " e.g. using 'd' instead of 'days' to save some space. + let g:undotree_SetFocusWhenToggle = 1 " if set, let undotree window get focus after being opened, otherwise focus will stay in current window. + let g:undotree_TreeNodeShape = '*' + let g:undotree_DiffCommand = "diff" +" }}} + +" Tabman {{{ + let g:tabman_toggle = '' + let g:tabman_side = 'right' +" }}} + +" SuperTab {{{ + let g:SuperTabDefaultCompletionType = "context" +" }}} + +" ALE {{{ + map :ALERename + map gd :ALEGoToDefinition + map gi :ALEHover + map ge :ALEDetail + + set omnifunc=ale#completion#OmniFunc + let g:ale_completion_enabled = 1 + + let g:ale_floating_preview = 1 " Use floating window + let g:ale_floating_window_border = ['│', '─', '╭', '╮', '╯', '╰'] " Nicer borders + + let g:ale_typescript_tsserver_use_global = 1 " Use global tsserver package +" }}} + +" texty-office {{{ + let g:texty_office_executable_directory='/home/kamen/Programming/GitLab-repos/texty-office' + " let g:texty_office_pretty_mode=1 +" }}} diff --git a/.vim/settings.vim b/.vim/settings.vim new file mode 100644 index 0000000..dd83663 --- /dev/null +++ b/.vim/settings.vim @@ -0,0 +1,86 @@ +" Color scheme {{{ + colorscheme gruvbox + let g:gruvbox_contrast_dark = 'hard' + set background=dark " Setting dark mode +" }}} + +" Cursor {{{ + set scrolloff=5 " Screen lines above and below the cursor + 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 + + 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 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 {{{ + 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 + + set foldlevel=99 " Open all folds by default + autocmd FileType vim,sh,zsh,xdefaults setlocal foldlevel=0 " Close all folds by defualt on filetypes + + set foldtext=MyFoldText() " Custom text for a fold + function MyFoldText() + let line = substitute(getline(v:foldstart), "\t", repeat(" ", shiftwidth(0)), "") " Gets the first fold line and replace tabs with spaces (as many as shiftwidth is set to) + let linecount = v:foldend - v:foldstart " Calculates amount of folded lines + return line . repeat(" ", winwidth('%') - strlen(line) - 10 - strlen(linecount)) + \ . "  " . linecount . "  " " Shows our line, then a lot of spaces, and at the very end we have line number and arrows + endfunction +" }}} + +" Splits {{{ + autocmd VimEnter,VimResized * let &winwidth=&columns/2 | let &winheight=&lines*2/3 +" }}} + +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 wildmode=list:longest,full +set history=1000 +set incsearch +set shortmess=acTOI +set undodir=~/.vim/vimundo +set undofile + +" For TOhtml +let g:html_line_ids = 1 +let g:html_dynamic_folds = 1 + +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 diff --git a/.vim/startup/mappings.vim b/.vim/startup/mappings.vim deleted file mode 100644 index 1eb4a30..0000000 --- a/.vim/startup/mappings.vim +++ /dev/null @@ -1,119 +0,0 @@ -" Ctrl-C, Ctrl-V, ... {{{ - " Partly taken from: https://gist.github.com/jshih/3423345 - inoremap :w - inoremap + - inoremap ggVG - inoremap - inoremap u - - nnoremap :w - nnoremap ggVG - - xnoremap c+ - xnoremap ggVG - xnoremap "+y - xnoremap "+d -" }}} - -" Move lines with Alt-J, Alt-K {{{ - execute "set =\ej" - nnoremap :m+1 - execute "set =\ek" - nnoremap :m-2 - - xnoremap :m '>+1gv=gv - xnoremap :m '<-2gv=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 - - " 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 pumvisible() ? "\" : "\u\" - " inoremap pumvisible() ? '' : '=pumvisible() ? "\Down>" : ""' - - " "Disables" arrow navigation in completion menu - inoremap pumvisible() ? '' : '' - inoremap pumvisible() ? '' : '' - - " Pressing tab goes from top to bottom - let g:SuperTabContextDefaultCompletionType = "" -" }}} - -" When line is wrapped, going up or down will also go into the wrapped part -" move in wrapped lines when no count prefix -nnoremap k (v:count == 0 ? 'gk' : 'k') -xnoremap k (v:count == 0 ? 'gk' : 'k') -nnoremap j (v:count == 0 ? 'gj' : 'j') -xnoremap j (v:count == 0 ? 'gj' : 'j') - -" Don't move cursor one character back on esc key press -" inoremap :stopinsert - -" Don't get into insert mode after adding a line with o/O -" nnoremap o o -" nnoremap O O - -" Thanks https://github.com/drzel/vim-split-line -nnoremap K :keep s/\s*\%#\s*/\r/e noh - -" Better resizing when navigating splits -nnoremap l= -nnoremap h= -nnoremap j= -nnoremap k= - -" Ctrl-Backspace deletes the previous word in insert mode. -inoremap -cnoremap -inoremap -cnoremap - -" Make session file -nnoremap :mksession! .vim-session - -" Show who edited the current line from git history -nnoremap :call gitblame#echo() - -" Open lazygit in a new tab with = -nnoremap \| :tab ter ++close lazygit - -" Tab navigtion -execute "set =\eo" -nnoremap gT -inoremap gT -tnoremap gT -execute "set =\ep" -nnoremap gt -inoremap gt -tnoremap gt - -" Arrows = bad -inoremap -inoremap -inoremap -inoremap -nnoremap -nnoremap -nnoremap -nnoremap - -" Cyrillic (Bulgarian yawerty layout) support -ca в w -ca ва wa -ca ь x -ca ьа xa - -" Make x and xa just save and quit without saving. This allows for closing all tabs and terminals. -ca x w q! -ca xa wa qa! - -" Open a terminal vim tab with tt and open a blank tab with te -ca tt tab ter -ca te tabe diff --git a/.vim/startup/pluginsettings.vim b/.vim/startup/pluginsettings.vim deleted file mode 100644 index 72757f5..0000000 --- a/.vim/startup/pluginsettings.vim +++ /dev/null @@ -1,58 +0,0 @@ -" DelimitMate {{{ - let delimitMate_expand_cr = 1 - " Don't autocomplete diamond brackets in HTML (compatibility with closetag plugin) - autocmd FileType html let b:delimitMate_matchpairs='(:),[:],{:}' -" }}} - -" NERDTree {{{ - " Toggle NERDTree with Tab - nmap :NERDTreeToggle - - let NERDTreeCustomOpenArgs = {'file':{'where':'t'}} " Open file in new tab, doesn't work only for double-click - let NERDTreeShowHidden = 1 - let NERDTreeWinPos = "right" - let NERDTreeIgnore = ['\.swp$', '\~$'] " Ignore file, ending with .swp and ~ - - " Do not save blank screens, solves https://github.com/preservim/nerdtree/issues/745 - set sessionoptions-=blank -" }}} - -" Undotree {{{ - " Toggle undotree with F5 - nmap :UndotreeToggle - - let g:undotree_WindowLayout = 2 - let g:undotree_ShortIndicators = 1 " e.g. using 'd' instead of 'days' to save some space. - let g:undotree_SetFocusWhenToggle = 1 " if set, let undotree window get focus after being opened, otherwise focus will stay in current window. - let g:undotree_TreeNodeShape = '*' - let g:undotree_DiffCommand = "diff" -" }}} - -" Tabman {{{ - let g:tabman_toggle = '' - let g:tabman_side = 'right' -" }}} - -" SuperTab {{{ - let g:SuperTabDefaultCompletionType = "context" -" }}} - -" ALE {{{ - map :ALERename - map gd :ALEGoToDefinition - map gi :ALEHover - map ge :ALEDetail - - set omnifunc=ale#completion#OmniFunc - let g:ale_completion_enabled = 1 - - let g:ale_floating_preview = 1 " Use floating window - let g:ale_floating_window_border = ['│', '─', '╭', '╮', '╯', '╰'] " Nicer borders - - let g:ale_typescript_tsserver_use_global = 1 " Use global tsserver package -" }}} - -" texty-office {{{ - let g:texty_office_executable_directory='/home/kamen/Programming/GitLab-repos/texty-office' - " let g:texty_office_pretty_mode=1 -" }}} diff --git a/.vim/startup/settings.vim b/.vim/startup/settings.vim deleted file mode 100644 index dd83663..0000000 --- a/.vim/startup/settings.vim +++ /dev/null @@ -1,86 +0,0 @@ -" Color scheme {{{ - colorscheme gruvbox - let g:gruvbox_contrast_dark = 'hard' - set background=dark " Setting dark mode -" }}} - -" Cursor {{{ - set scrolloff=5 " Screen lines above and below the cursor - 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 - - 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 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 {{{ - 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 - - set foldlevel=99 " Open all folds by default - autocmd FileType vim,sh,zsh,xdefaults setlocal foldlevel=0 " Close all folds by defualt on filetypes - - set foldtext=MyFoldText() " Custom text for a fold - function MyFoldText() - let line = substitute(getline(v:foldstart), "\t", repeat(" ", shiftwidth(0)), "") " Gets the first fold line and replace tabs with spaces (as many as shiftwidth is set to) - let linecount = v:foldend - v:foldstart " Calculates amount of folded lines - return line . repeat(" ", winwidth('%') - strlen(line) - 10 - strlen(linecount)) - \ . "  " . linecount . "  " " Shows our line, then a lot of spaces, and at the very end we have line number and arrows - endfunction -" }}} - -" Splits {{{ - autocmd VimEnter,VimResized * let &winwidth=&columns/2 | let &winheight=&lines*2/3 -" }}} - -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 wildmode=list:longest,full -set history=1000 -set incsearch -set shortmess=acTOI -set undodir=~/.vim/vimundo -set undofile - -" For TOhtml -let g:html_line_ids = 1 -let g:html_dynamic_folds = 1 - -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 -- cgit v1.2.3