diff options
Diffstat (limited to 'vim.dot.link')
33 files changed, 701 insertions, 14 deletions
diff --git a/vim.dot.link/autoload/pathogen.vim b/vim.dot.link/autoload/pathogen.vim deleted file mode 120000 index a47dcdf..0000000 --- a/vim.dot.link/autoload/pathogen.vim +++ /dev/null @@ -1 +0,0 @@ -../pathogen/autoload/pathogen.vim
\ No newline at end of file diff --git a/vim.dot.link/bundle/nerdtree b/vim.dot.link/bundle/nerdtree deleted file mode 160000 -Subproject eed488b1cd1867bd25f19f90e10440c5cc7d642 diff --git a/vim.dot.link/bundle/vimperator b/vim.dot.link/bundle/vimperator deleted file mode 160000 -Subproject 249689edee67ca87520af9024d1f70dadac9bbe diff --git a/vim.dot.link/filetype.vim b/vim.dot.link/filetype.vim index 2b958bc..79e09ab 100644 --- a/vim.dot.link/filetype.vim +++ b/vim.dot.link/filetype.vim @@ -1,23 +1,76 @@ -" Vim support file to detect file types +" Vim support file to detect file types {{{ +" Check if file type config is already loaded {{{ if exists("did_load_filetypes") - finish + finish endif +" }}} -" markdown filetype file +" Filetype detection {{{ +" +" According to ":help BufRead", this augroup is also evaluated also on +" ":filetype detect". +augroup filetypedetect + autocmd! -augroup markdown - au! BufRead,BufNewFile *.mkd setfiletype mkd -augroup END + " Calendar + autocmd BufRead,BufNewFile *.rem setfiletype remind -" detect puppet filetypes + " Trac + autocmd BufRead,BufNewFile *.trac setfiletype tracwiki + autocmd BufRead,BufNewFile *.tracwiki setfiletype tracwiki -augroup filetypedetect - au! BufRead,BufNewFile *.pp setfiletype puppet + " Programming languages + autocmd BufRead,BufNewFile kvmxfile setfiletype sh + autocmd BufRead,BufNewFile Vagrantfile setfiletype ruby + autocmd BufRead,BufNewFile *.py setfiletype python + autocmd BufRead,BufNewFile *.pp setfiletype puppet + autocmd BufRead,BufNewFile *.php setfiletype php + autocmd BufRead,BufNewFile *.thtml setfiletype php + autocmd BufRead,BufNewFile *.vue setfiletype html + + " Markdown + " + " This handling is disabled by default, since it leads to some settings on + " ftplugin/markdown.vim being ignored. + " + "autocmd BufRead,BufNewFile,BufEnter *.mdwn setfiletype markdown + "autocmd BufRead,BufNewFile,BufEnter *.md setfiletype markdown augroup END +" }}} -" detect drupal modules +" Markdown workaround {{{ +" +" Since the following configuration is not working at ftplugin/markdown.vim, +" it's being used here. +" +" Also note that BufEnter event also need to be included, otherwise foldings +" won't be correctly applied in some Markdown files loaded in new windows. +augroup filetype_markdown + autocmd! + "autocmd BufRead,BufNewFile,BufEnter *.md setlocal foldexpr=NestedMarkdownFolds() + "autocmd BufRead,BufNewFile,BufEnter *.md setlocal autoindent smartindent + "autocmd BufRead,BufNewFile,BufEnter *.md setlocal formatoptions=tcroqn2 comments=n:> + autocmd BufRead,BufNewFile,BufEnter *.md setlocal tabstop=2 softtabstop=2 shiftwidth=2 expandtab +augroup END +" }}} -augroup filetypedetect - au! BufRead,BufNewFile *.module setfiletype php +" VIM filetype {{{ +augroup filetype_vim + autocmd! + autocmd FileType vim setlocal foldmethod=marker augroup END +" }}} + +" Drupal {{{ +" Handle *.module, *.install, *.profile etc +if has("autocmd") + augroup filetype_drupal + autocmd! + autocmd BufRead,BufNewFile,BufEnter *.profile setfiletype php + autocmd BufRead,BufNewFile,BufEnter *.module setfiletype php + autocmd BufRead,BufNewFile,BufEnter *.install setfiletype php + autocmd BufRead,BufNewFile,BufEnter *.test setfiletype php + augroup END +endif +" }}} diff --git a/vim.dot.link/ftplugin/mail.vim b/vim.dot.link/ftplugin/mail.vim new file mode 100644 index 0000000..c518239 --- /dev/null +++ b/vim.dot.link/ftplugin/mail.vim @@ -0,0 +1,5 @@ +" Mail +" +" Workaround for mail editing. There must be a plugin enabling autoindent in +" mail composition, which is annoying. +setlocal noautoindent diff --git a/vim.dot.link/ftplugin/markdown.vim b/vim.dot.link/ftplugin/markdown.vim new file mode 100644 index 0000000..aafef72 --- /dev/null +++ b/vim.dot.link/ftplugin/markdown.vim @@ -0,0 +1,33 @@ +" Markdown configuration +" +" This filetype script is currently disable, as it may be conflicting with +" something else. +" +" Markdown folding through NestedMarkdownFolds() are not correctly working +" with this configuration. +" +" These settings are configured directly on filetype.vim instead. + +" Basic {{{ +"setlocal autoindent smartindent +"setlocal formatoptions=tcroqn2 comments=n:> +"setlocal tabstop=2 softtabstop=2 shiftwidth=2 expandtab +" }}} + +" Markdown configuration without vim-markdown plugin {{{ +" +" Include folding setup: +" https://github.com/masukomi/vim-markdown-folding +" +" This is an alternative to the following method: +" https://codereview.stackexchange.com/questions/202620/vim-plugin-for-folding-markdown-lists +"setlocal foldexpr=NestedMarkdownFolds() +" }}} + +" Markdown configuration with vim-markdown plugin {{{ +let g:vim_markdown_new_list_item_indent = 2 +let g:vim_markdown_folding_style_pythonic = 1 +let g:vim_markdown_folding_level = 1 +let g:vim_markdown_auto_insert_bullets = 0 +let g:vim_markdown_new_list_item_indent = 0 +" }}} diff --git a/vim.dot.link/ftplugin/php.vim b/vim.dot.link/ftplugin/php.vim new file mode 100644 index 0000000..9892f83 --- /dev/null +++ b/vim.dot.link/ftplugin/php.vim @@ -0,0 +1,2 @@ +" PHP +let php_sql_query=1 diff --git a/vim.dot.link/ftplugin/python.vim b/vim.dot.link/ftplugin/python.vim new file mode 100644 index 0000000..047760c --- /dev/null +++ b/vim.dot.link/ftplugin/python.vim @@ -0,0 +1,2 @@ +" Python +setlocal autoindent smartindent tabstop=4 softtabstop=4 shiftwidth=4 expandtab diff --git a/vim.dot.link/bundle/vim-addon-mw-utils b/vim.dot.link/pack/MarcWeber/start/vim-addon-mw-utils -Subproject 6aaf4fee472db7cbec6d2c8eea69fdf3a8f8a75 +Subproject 6aaf4fee472db7cbec6d2c8eea69fdf3a8f8a75 diff --git a/vim.dot.link/bundle/vim-autoread b/vim.dot.link/pack/djoshea/start/vim-autoread -Subproject 7e83d47a71fdafc271005fc39c89863204278c7 +Subproject 7e83d47a71fdafc271005fc39c89863204278c7 diff --git a/vim.dot.link/bundle/vim-twig b/vim.dot.link/pack/evidens/opt/vim-twig -Subproject cd936524f34fc47bcb1f46a03c5614208c42383 +Subproject cd936524f34fc47bcb1f46a03c5614208c42383 diff --git a/vim.dot.link/pack/flazz/README.md b/vim.dot.link/pack/flazz/README.md new file mode 100644 index 0000000..dec2123 --- /dev/null +++ b/vim.dot.link/pack/flazz/README.md @@ -0,0 +1,10 @@ +# VIM packages from flazz + +## 2024-07-18 - xoria256 + +* We're sticking to `colorschemes` version `28a989b28457e38df620e4c7ab23e224aff70efe`, + since the next commit (`5ef0d19dc093b9f5e9874ae48792e591dc34afa7`) changes `xoria256.vim` + colorscheme in a way I don't like. + +* We may consider forking it, or sending a pull request with the old `xoria256` theme + under a new name. diff --git a/vim.dot.link/bundle/colorschemes b/vim.dot.link/pack/flazz/start/colorschemes -Subproject 28a989b28457e38df620e4c7ab23e224aff70ef +Subproject 28a989b28457e38df620e4c7ab23e224aff70ef diff --git a/vim.dot.link/bundle/tabular b/vim.dot.link/pack/godlygeek/start/tabular -Subproject 339091ac4dd1f17e225fe7d57b48aff55f99b23 +Subproject 339091ac4dd1f17e225fe7d57b48aff55f99b23 diff --git a/vim.dot.link/pack/masukomi/opt/vim-markdown-folding b/vim.dot.link/pack/masukomi/opt/vim-markdown-folding new file mode 160000 +Subproject 0592d3efcb9b287fff265aa542872d95478a753 diff --git a/vim.dot.link/pack/preservim/start/nerdtree b/vim.dot.link/pack/preservim/start/nerdtree new file mode 160000 +Subproject fbb71fcd90602e3ec77f40b864b5f9b437c496c diff --git a/vim.dot.link/pack/preservim/start/vim-markdown b/vim.dot.link/pack/preservim/start/vim-markdown new file mode 160000 +Subproject a657e697376909c41475a686eeef7fc7a4972d9 diff --git a/vim.dot.link/pack/rafkaplon/README.md b/vim.dot.link/pack/rafkaplon/README.md new file mode 100644 index 0000000..be93421 --- /dev/null +++ b/vim.dot.link/pack/rafkaplon/README.md @@ -0,0 +1,13 @@ +# VIM packages from rafkaplon + +The `opt/vim-markdown-folding` plugin is a fork of +`masukomi/vim-markdown-folding`. + +It was used in the past because it fixed the following issue: + + Fixed issue with s:SID in Vim 8.2 #43 + https://github.com/masukomi/vim-markdown-folding/pull/43 + +Since this was merged, we switched back to upstream on 2024-07-18. + +This may stay here for a while, and in the future it might be removed. diff --git a/vim.dot.link/bundle/vim-markdown-folding b/vim.dot.link/pack/rafkaplon/opt/vim-markdown-folding -Subproject 7d223be1adfa0e14c3930ac4aab9dc2594acf4c +Subproject 7d223be1adfa0e14c3930ac4aab9dc2594acf4c diff --git a/vim.dot.link/bundle/vim-session b/vim.dot.link/pack/romgrk/start/vim-session -Subproject 1133c83313b1b8d883f5e3f2016ef3040f566c3 +Subproject 1133c83313b1b8d883f5e3f2016ef3040f566c3 diff --git a/vim.dot.link/bundle/tlib_vim b/vim.dot.link/pack/tomtom/start/tlib_vim -Subproject 70c4e222464020edc2809c932b488daaf891eee +Subproject 70c4e222464020edc2809c932b488daaf891eee diff --git a/vim.dot.link/bundle/vim-airline b/vim.dot.link/pack/vim-airline/start/vim-airline -Subproject d0c67776f27eb49cccbd58008724bd6caa00ed8 +Subproject d0c67776f27eb49cccbd58008724bd6caa00ed8 diff --git a/vim.dot.link/pack/vitalk/start/vim-simple-todo b/vim.dot.link/pack/vitalk/start/vim-simple-todo new file mode 160000 +Subproject e2eead5640244cbf4e376ad91f649e2a4f536da diff --git a/vim.dot.link/bundle/vim-misc b/vim.dot.link/pack/xolox/start/vim-misc -Subproject 3e6b8fb6f03f13434543ce1f5d24f6a5d3f34f0 +Subproject 3e6b8fb6f03f13434543ce1f5d24f6a5d3f34f0 diff --git a/vim.dot.link/pathogen b/vim.dot.link/pathogen deleted file mode 160000 -Subproject e0a3efbda5ea8e5b181b2b232ef6453c05d0773 diff --git a/vim.dot.link/plugin/auto_file.vim b/vim.dot.link/plugin/auto_file.vim new file mode 100644 index 0000000..2d46efc --- /dev/null +++ b/vim.dot.link/plugin/auto_file.vim @@ -0,0 +1,28 @@ +" auto_file.vim - Automatically file reading, saving; directory change {{{ + +" Autoread {{{ +" +" http://vim.wikia.com/wiki/Have_Vim_check_automatically_if_the_file_has_changed_externally +" http://stackoverflow.com/questions/2490227/how-does-vims-autoread-work +" http://stackoverflow.com/questions/2490227/how-does-vims-autoread-work +"au FocusGained,BufEnter * :silent! ! +"au FocusLost,WinLeave * :silent! w +" }}} + +" Autosave {{{ +" See https://github.com/vim-scripts/vim-auto-save +"let g:auto_save = 1 +" }}} + +" Auto change dir {{{ +" +" Automatically set the current working directory to the current buffer file's +" directory +" +" See http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file +"set autochdir +augroup changedir + autocmd! + autocmd BufEnter * silent! lcd %:p:h +augroup END +" }}} diff --git a/vim.dot.link/plugin/key_mappings.vim b/vim.dot.link/plugin/key_mappings.vim new file mode 100644 index 0000000..5e9c315 --- /dev/null +++ b/vim.dot.link/plugin/key_mappings.vim @@ -0,0 +1,260 @@ +" key_mappings.vim - Custom Key Mappings {{{ +" +" Author: Silvio Rhatto <rhatto@riseup.net> +" +" References: +" +" * https://stackoverflow.com/questions/7501092/can-i-map-alt-key-in-vim +" * https://stackoverflow.com/questions/45244245/why-alt-and-esc-keys-behave-differently-in-emacs +" * http://vim.wikia.com/wiki/Mapping_fast_keycodes_in_terminal_Vim +" * https://github.com/vim-utils/vim-alt-mappings +" * https://github.com/drmikehenry/vim-fixkey +" +" Notes: +" +" Keys were chosen not to conflict of to be close to window manager combos +" Like Awesome has a combo (Meta-q) which could be confused with a VIM quit +" mapping (Alt-q). +" +" Other keys were chosen not to conflict with existing VIM functionality +" like Alt-t (OpenNerdTree). +" +" While we could try to map other meta keys like Menu or AltGr, this +" is currently not supported by VIM and could even cause more confusion with +" other applications. +" +" For the quit combo, an approach like listening to VimLeave would work if +" this event would be triggered by the window manager when killing VIM window, +" but this does not seem to be the case. Anyway there's interesting discussion at +" https://stackoverflow.com/questions/5142099/how-to-auto-save-vim-session-on-quit-and-auto-reload-on-start-including-split-wi +" +" Pressing Alt-<key> simultaneously is equivalent to pressing ESC and then <key>, +" so the big difference between the ESC combos and Alt combos are mainly of +" config file notation. +" +" Typing ESC keys combos have the advantage over Alt combos as they are +" difficult to be mistaken for the Meta key, but thats mainly a user and not +" config convention since they're almost the same in VIM. +" +" In the other hand, there's an disadvantage of using ESC simultaneously for +" going to normal mode and doing other stuff, with can be in ambiguous. +" +" The sollution is to decrease ESC timeout. +" + +" Decrease ESC delays {{{ +" See https://www.johnhawthorn.com/2012/09/vi-escape-delays/ +"set timeoutlen=1000 ttimeoutlen=0 +set timeoutlen=0 ttimeoutlen=0 +" }}} + +" ESC-based shortcuts {{{ +" Write, quit and close shortcuts using Esc <key> notation (works also with <Alt-key>) +nnoremap <ESC>n :tabnew<CR> +nnoremap <ESC>t :NERDTree +nnoremap <ESC>T :T +"nnoremap <ESC>q :wqa<CR> +"noremap <ESC>c :wqa<CR> +nnoremap <ESC>f :wq<CR> +nnoremap <ESC>c :tabclose<CR> +"noremap <ESC>e :tabclose<CR> +nnoremap <ESC>b :NERDTreeFromBookmark +nnoremap <ESC>B :B +nnoremap <ESC>s :OpenSession +"nnoremap <ESC>m :q!<CR> +" We're closing the buffer instead of just the window to avoid slowness due to too many opened buffers +nnoremap <ESC>m :bd<CR> +nnoremap <ESC>w :w<CR> +nnoremap <ESC>u :!up<CR> +inoremap <ESC>n <ESC>:tabnew<CR> +inoremap <ESC>t <ESC>:NERDTree +inoremap <ESC>t <ESC>:T +"inoremap <ESC>q <ESC>:wqa<CR> +"noremap <ESC>c <ESC>:wqa<CR> +inoremap <ESC>f <ESC>:wq<CR> +inoremap <ESC>c <ESC>:tabclose<CR> +"noremap <ESC>e <ESC>:tabclose<CR> +"inoremap <ESC>m <ESC>:q!<CR> +" We're closing the buffer instead of just the window to avoid slowness due to too many opened buffers +inoremap <ESC>m <ESC>:bd<CR> +inoremap <ESC>w <ESC>:w<CR> +" }}} + +" Alt-based shortcuts {{{ +" Write, quit and close shortcuts using Alt-key combo notation +"noremap n :tabnew<CR> +"noremap t :OpenNERDTree<CR> +"noremap q :wqa<CR> +"noremap c :wqa<CR> +"noremap f :wq<CR> +"noremap c :tabclose<CR> +"noremap e :tabclose<CR> +"nnoremap b :NERDTreeFromBookmark +"nnoremap B :B +"nnoremap s :OpenSession +"noremap m :q!<CR> +"noremap w :w<CR> +"noremap u :!up<CR> +"inoremap n <ESC>:tabnew<CR> +"inoremap t <ESC>:OpenNERDTree<CR> +"inoremap q <ESC>:wqa<CR> +"inoremap c <ESC>:wqa<CR> +"inoremap f <ESC>:wq<CR> +"inoremap c <ESC>:tabclose<CR> +"inoremap e <ESC>:tabclose<CR> +"inoremap m <ESC>:q!<CR> +"inoremap w <ESC>:w<CR> +" }}} + +" Crtl-based shortcuts {{{ +" Write, quit and close shortcuts using Ctrl-key combos +" We're using these due to a conflict with wyrd(1) +"nnoremap <C-n> :tabnew<CR> +"nnoremap <C-t> :OpenNERDTree<CR> +"nnoremap <C-q> :wqa<CR> +"nnoremap <C-c> :wqa<CR> +"nnoremap <C-f> :wq<CR> +"nnoremap <C-c> :tabclose<CR> +"nnoremap <C-e> :tabclose<CR> +"nnoremap <C-b> :NERDTreeFromBookmark +"nnoremap <C-B> :B +"nnoremap <C-s> :OpenSession +"nnoremap <C-m> :q!<CR> +"nnoremap <C-w> :w<CR> +"inoremap <C-n> <ESC>:tabnew<CR> +"inoremap <C-t> <ESC>:OpenNERDTree<CR> +"inoremap <C-q> <ESC>:wqa<CR> +"inoremap <C-c> <ESC>:wqa<CR> +"inoremap <C-f> <ESC>:wq<CR> +"inoremap <C-c> <ESC>:tabclose<CR> +"inoremap <C-e> <ESC>:tabclose<CR> +"inoremap <C-m> <ESC>:q!<CR> +"inoremap <C-w> <ESC>:w<CR> +" }}} + +" Write, quit and close shortcuts {{{ +noremap q :Wipeout<CR>:wqa <CR> +"noremap f :wq <CR> +"noremap t :tabclose <CR> +"noremap m :q! <CR> +"noremap w :w <CR> +noremap h :tabnew<CR> +" }}} + +" Tab navigation {{{ +" See http://vim.wikia.com/wiki/Alternative_tab_navigation +" http://comments.gmane.org/gmane.os.cygwin.xfree/16419 +nnoremap <ESC>[5^ <C-PageUp> +nnoremap <ESC>[6^ <C-PageDown> +nnoremap <C-PageDown> :tabn<CR> +nnoremap <C-PageUp> :tabp<CR> +nnoremap 1 1gt +nnoremap 2 2gt +nnoremap 3 3gt +nnoremap 4 4gt +nnoremap 5 5gt +nnoremap 6 6gt +nnoremap 7 7gt +nnoremap 8 8gt +nnoremap 9 9gt +nnoremap 0 10gt +" }}} + +" Buffer navigation: Alt-{Up,Down} {{{ +noremap Od :bprevious<CR> +noremap Oc :bnext<CR> +" }}} + +" Window navigation {{{ +"noremap <C-Left> <C-w><Left> +"noremap <C-Right> <C-w><Right> +"noremap <C-Down> <C-w><Down> +"noremap <C-Up> <C-w><Up> +"inoremap <C-Left> <ESC><C-w><Left> +"inoremap <C-Right> <ESC><C-w><Right> +"inoremap <C-Down> <ESC><C-w><Down> +"inoremap <C-Up> <ESC><C-w><Up> +"noremap <Left> <C-w><Left> +"noremap <Right> <C-w><Right> +"noremap <Down> <C-w><Down> +"noremap <Up> <C-w><Up> +"inoremap <Left> <ESC><C-w><Left> +"inoremap <Right> <ESC><C-w><Right> +"inoremap <Down> <ESC><C-w><Down> +"inoremap <Up> <ESC><C-w><Up> +nnoremap <ESC><Left> <C-w><Left> +nnoremap <ESC><Right> <C-w><Right> +nnoremap <ESC><Down> <C-w><Down> +nnoremap <ESC><Up> <C-w><Up> +inoremap <ESC><Left> <ESC><C-w><Left> +inoremap <ESC><Right> <ESC><C-w><Right> +inoremap <ESC><Down> <ESC><C-w><Down> +inoremap <ESC><Up> <ESC><C-w><Up> +" }}} + +" Recording {{{ +nnoremap Q q +" }}} + +" Copy and paste {{{ +" +" See http://superuser.com/questions/10588/how-to-make-cut-copy-paste-in-gvim-on-ubuntu-work-with-ctrlx-ctrlc-ctrlv +"imap <C-v> <C-r><C-o>+ +"vmap <C-v> c<ESC>"+p +vnoremap <C-c> "+yi +vnoremap <C-x> "+c +" }}} + +" Email {{{ +" +" Unfold and delete to your signature +" See https://hroy.eu/tips/vim/email-delete-til-signature/ +noremap ,dd zi:.;/^-- $/d<CR>O-- <UP><End><CR><CR><UP><CR><C-O>zi +" }}} + +" Task lists {{{ +" https://github.com/vitalk/vim-simple-todo/ +let g:simple_todo_map_keys = 0 +let g:simple_todo_list_symbol = '*' +nmap <Leader>i <Plug>(simple-todo-new-list-item) +nmap <Leader>I <Plug>(simple-todo-new-list-item-start-of-line) +nmap <Leader>o <Plug>(simple-todo-below) +nmap <Leader>x <Plug>(simple-todo-mark-as-done) +nmap <Leader>X <Plug>(simple-todo-mark-as-undone) +nmap <Leader>s <Plug>(simple-todo-mark-switch) +imap <Leader>i <Plug>(simple-todo-new-list-item) +imap <Leader>I <Plug>(simple-todo-new-list-item-start-of-line) +imap <Leader>o <Plug>(simple-todo-below) +imap <Leader>X <Plug>(simple-todo-mark-as-undone) +imap <Leader>x <Plug>(simple-todo-mark-as-done) +imap <Leader>s <Plug>(simple-todo-mark-switch) +vmap <Leader>I <Plug>(simple-todo-new-list-item-start-of-line) +vmap <Leader>X <Plug>(simple-todo-mark-as-undone) +vmap <Leader>x <Plug>(simple-todo-mark-as-done) +vmap <Leader>s <Plug>(simple-todo-mark-switch) + +" From lib.vim +"nnoremap <Leader>c :call ToggleCheckbox()<CR> +" }}} + +"" Leader behavior {{{ +" Cleanup the buffer {{{ +noremap <leader>c :call BufferCleansing()<CR> +" }}} + +" Insert the current date in ISO format {{{ +" +" Thanks https://vimtricks.com/p/insert-the-current-date-or-time/ +"map <leader>d :0put =strftime('%Y-%m-%d')<CR> +nnoremap <leader>d i<C-R>=strftime('%Y-%m-%d')<CR> +inoremap <leader>d <C-R>=strftime('%Y-%m-%d')<CR> +" }}} + +" Insert the current date in format useful for ChangeLog.md entries {{{ +"nnoremap <leader>e :put =strftime('## %Y-%m-%d ')<CR> +nnoremap <leader>e o<CR><C-R>=strftime('## %Y-%m-%d - ')<CR> + +" Remind shortcuts +inoremap <leader>s SATISFY [expire()] +" }}} +" }}} diff --git a/vim.dot.link/plugin/lib.vim b/vim.dot.link/plugin/lib.vim new file mode 100644 index 0000000..1c3212e --- /dev/null +++ b/vim.dot.link/plugin/lib.vim @@ -0,0 +1,45 @@ +" lib.vim - Miscelaneous functions {{{ +" +" Author: Silvio Rhatto <rhatto@riseup.net> +" + +" Checkbox handling {{{ +" +" This is commented out because vitalk/vim-simple-todo is being used instead. +" +" Thanks https://www.reddit.com/r/vim/comments/slqsao/readymade_solution_for_handling_markdown/ +"function! ToggleCheckbox() +" let line = getline('.') +" +" if line =~ '- \[ \]' +" call setline('.', substitute(line, '- \[ \]', '- \[x\]', '')) +" elseif line =~ '- \[x\]' +" call setline('.', substitute(line, '- \[x\]', '- \[ \]', '')) +" elseif line =~ '- ' +" call setline('.', substitute(line, '- ', '- \[ \] ', '')) +" endif +"endf +" }}} + +" Remove trailing spaces {{{ +" +" Thanks https://vi.stackexchange.com/a/456 +fun! TrimWhitespace() + let l:save = winsaveview() + keeppatterns %s/\s\+$//e + call winrestview(l:save) +endfun + +command! TrimWhitespace call TrimWhitespace() +" }}} + +" Cleanup the buffer {{{ +" +" Implement miscelaneous buffer cleansing procedures +function BufferCleansing() + " Trim white spaces + call TrimWhitespace() +endfunction + +command! BufferCleansing call BufferCleansing() +" }}} diff --git a/vim.dot.link/plugin/nerdtree_customizations.vim b/vim.dot.link/plugin/nerdtree_customizations.vim new file mode 100644 index 0000000..1cbb207 --- /dev/null +++ b/vim.dot.link/plugin/nerdtree_customizations.vim @@ -0,0 +1,54 @@ +" nedtree_customizations.vim - NERDTree customizations {{{ +" +" Initially adapted from +" http://stackoverflow.com/questions/1447334/how-do-you-add-nerdtree-to-your-vimrc +" +" Author: Silvio Rhatto <rhatto@riseup.net> + +" Use the minimal UI {{{ +let NERDTreeMinimalUI=1 +" }}} + +" NERDTree autogroup {{{ +augroup nerdtree + autocmd! + + " Open NERDTree when vim starts + "autocmd VimEnter * NERDTree + "autocmd VimEnter * wincmd p + + autocmd FileType nerdtree setlocal relativenumber + autocmd FileType taglist setlocal relativenumber +augroup END +" }}} + +" TabNew {{{ +function TabNew(address) + execute ":tabnew" + execute ":NERDTree " a:address +endfunction +" }}} + +" TabNewBookmark {{{ +function TabNewBookmark(bookmark) + execute ":tabnew" + execute ":NERDTreeFromBookmark " a:bookmark +endfunction +" }}} + +" OpenNERDTree {{{ +function OpenNERDTree() + execute ":NERDTree" +endfunction +" }}} + +" Shortcuts {{{ +"cnoreabbrev t NERDTree +"cnoreabbrev b NERDTreeFromBookmark +"cnoreabbrev s OpenSession +"cnoreabbrev sload OpenSession +"cnoreabbrev ssave SaveSession +command -nargs=1 -complete=dir T :call TabNew(<f-args>) +command -nargs=1 -complete=customlist,nerdtree#completeBookmarks B :call TabNewBookmark(<f-args>) +command -nargs=0 OpenNERDTree :call OpenNERDTree() +" }}} diff --git a/vim.dot.link/plugin/session_workarounds.vim b/vim.dot.link/plugin/session_workarounds.vim new file mode 100644 index 0000000..75d59cb --- /dev/null +++ b/vim.dot.link/plugin/session_workarounds.vim @@ -0,0 +1,102 @@ +" session_workarounds.vim - Session restoration workarounds {{{ +" +" Author: Silvio Rhatto <rhatto@riseup.net> +" + +" Fix NERDTree width {{{ +" +" Useful after restoring sessions between screen size changes (such +" as when you share sessions between different computers). +function FixWindowWidths() + " Make sure NERDTree is focused + execute ":NERDTreeFocus" + + " Set a fixed width + execute ":vertical resize 30" + + " Move to the left pane + wincmd l +endfunction + +" In case you want to invoke FixWindowWidths explicitly +command! -bang FixWindowWidths :call FixWindowWidths() +" }}} + +" Fix window widths on all tabs {{{ +function FixAllWindowWidths() + " Make sure to run this only once + if exists("did_fixed_window_widths") + return + endif + + " Save the last active window + let l:current_win = win_getid() + + tabdo :call FixWindowWidths() + + " Restore the active window + call win_gotoid(l:current_win) + + " An additional, last move to the left pane + wincmd l + + let did_fixed_window_widths=1 +endfunction +" }}} + +" Ensure the window has maximized height {{{ +" +" This helps restoring the window size after reopening sessions after +" switching monitors (like from laptop screen to external HDMI monitor). +" +" We just want to quickly maximize the window and then restore it to +" it's original size, to ensure all windows are refreshed. +" +" Maybe this is not a NERDTree workaround itself, but more like a +" session workaround. +" +" https://superuser.com/questions/140419/how-to-start-gvim-maximized +" https://vim.fandom.com/wiki/Maximize_or_set_initial_window_size +" https://vi.stackexchange.com/questions/8926/is-it-possible-to-obtain-the-displayable-area-width-and-height-of-current-buffe +"let lines_initial=&l:lines +function FixWindowHeights() + " Set the maximum available height + set lines=999 + + " Set the lines depending on the LINES environment variable + " or through tput. + " + " This is not always inherited by vim: + " https://github.com/vim/vim/issues/12160 + if $LINES != "" + execute ':set lines=' . $LINES + else + let available_lines = system('tput lines') + execute ':set lines=' . available_lines + " Old, and not working approach that tries to reuse the initial height + "else + " execute ':set lines=' . lines_initial + " set lines=999 + " execute ':set lines=' . winheight(0) - 3 + endif +endfunction +" }}} + +" Restore all window sizes {{{ +function RestoreWindowSizes() + call FixWindowHeights() + call FixAllWindowWidths() +endfunction +" }}} + +" Fix all window sizes {{{ +augroup workaround + autocmd! + " This tends to fire for every buffer + autocmd workaround SessionLoadPost * call RestoreWindowSizes() + + " This seems to fire only once, but even when there's no session to be + " restored. + "autocmd workaround VimEnter * call FixAllWindowWidths() +augroup END +" }}} diff --git a/vim.dot.link/plugin/ui.vim b/vim.dot.link/plugin/ui.vim new file mode 100644 index 0000000..f0985cb --- /dev/null +++ b/vim.dot.link/plugin/ui.vim @@ -0,0 +1,47 @@ +" ui.vim - UI customization {{{ +" +" Author: Silvio Rhatto <rhatto@riseup.net> + +" Status and tab lines {{{ +set laststatus=2 " Always display the statusline in all windows +set showtabline=2 " Always display the tabline, even if there is only one tab +set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline) +" }}} + +" Powerline {{{ +"python from powerline.vim import setup as powerline_setup +"python powerline_setup() +"python del powerline_setup +" }}} + +" Airline {{{ +if $WINDOWID != "" + " Use powerline symbols + let g:airline_powerline_fonts=1 + + " Enable tabline + let g:airline#extensions#tabline#enabled=1 + + " Tab numbering + let g:airline#extensions#tabline#tab_nr_type = 1 +else + let g:loaded_airline = 1 +endif +" }}} + +" Color scheme {{{ +"colorscheme github +"colorscheme solarized +"colorscheme gentooish +"colorscheme revolutions +"colorscheme two2tango +"colorscheme vj +"colorscheme wood +"colorscheme zenburn +"colorscheme inkpot +if $WINDOWID != "" + colorscheme xoria256 +else + colorscheme zenburn +endif +" }}} diff --git a/vim.dot.link/plugin/window_title.vim b/vim.dot.link/plugin/window_title.vim new file mode 100644 index 0000000..af0ce01 --- /dev/null +++ b/vim.dot.link/plugin/window_title.vim @@ -0,0 +1,30 @@ +" window_title.vim - Window title handling {{{ +" +" Author: Silvio Rhatto <rhatto@riseup.net> + +" Basic settings {{{ +set title +set titleold="terminal" +set titlestring=vim:\ %F +" }}} + +" Handling titles when vim is embedded in specific programs {{{ +augroup vimleave + autocmd! + au VimLeave *mutt/* silent call ResetTitle("mutt") + au VimLeave *remind/* silent call ResetTitle("calendar") +augroup END +" }}} + +" Reset window titles {{{ +" +" Thanks to http://stackoverflow.com/questions/1673649/vimrc-action-onclose +function! ResetTitle(title) + " disable vim's ability to set the title + exec "set title t_ts='' t_fs=''" + + " and restore it + "exec ":!echo -e '\033kbash\033\\'\<CR>" + exec ":!xtitle -q " a:title +endfunction +" }}} diff --git a/vim.dot.link/syntax/remind.vim b/vim.dot.link/syntax/remind.vim index d220f75..93fc40f 100644 --- a/vim.dot.link/syntax/remind.vim +++ b/vim.dot.link/syntax/remind.vim @@ -5,6 +5,10 @@ " Version: 0.4 " URL: http://erlug.linux.it/~da/vim/syntax/remind.vim " +" Changes: +" +" * 2027-07-18 - Adds the THROUGH keyword (rhatto@riseup.net) +" " remind is a sophisticated reminder service " you can download remind from: " http://www.roaringpenguin.com/penguin/open_source_remind.php @@ -19,7 +23,7 @@ endif syn case ignore syn keyword remindCommands REM OMIT SET FSET UNSET -syn keyword remindExpiry UNTIL FROM SCANFROM SCAN WARN SCHED +syn keyword remindExpiry UNTIL THROUGH FROM SCANFROM SCAN WARN SCHED syn keyword remindTag PRIORITY TAG syn keyword remindTimed AT DURATION syn keyword remindMove ONCE SKIP BEFORE AFTER |