1
0
mirror of https://github.com/gryf/.vim.git synced 2026-03-27 16:23:31 +01:00

Compare commits

...

9 Commits

Author SHA1 Message Date
585993537f Markdown files handle.
VimWiki is greedy for filetypes, as a consequence it grabs both wiki and
markdown extension and name change file filetype to "wiki". For the wiki
files it's not an issue for me, but grabbing markdown files is too much.

With this commit those two filetypes are separated by setting empty dict
for `g:vimwiki_ext2syntax`.

Other than that, added fzf-aided selector for wiki files and added ruff
as the linter for python files.
2025-07-15 11:13:17 +02:00
6092e24242 Silence warning messages from vw2html,
Make markdown files not be swallowed by vimwiki ft.
2025-04-15 16:34:02 +02:00
a55590f07c Add commands for wrapper function on vw2html 2025-02-13 09:24:42 +01:00
34d7979d62 Added diffchar plugin for detailed diff 2025-02-13 09:05:44 +01:00
7b5070ab3e Asciidoc support 2024-07-13 18:05:13 +02:00
f98486130d Make whitespace stripping not default. 2024-07-13 17:42:32 +02:00
0da4596005 Drop local vimrc files iin favor of thinca/vim-localrc plugin. 2024-07-13 17:39:06 +02:00
8497d7595a Adapt repo to support XDG configuration placemet 2024-07-13 16:43:59 +02:00
2cc95674c2 Make python3 default shebang 2023-10-04 15:39:47 +02:00
3 changed files with 129 additions and 69 deletions

View File

@@ -7,14 +7,17 @@ of it.
It uses `vim-plug`_ plugin manager, so after cloning, just open vim, and it It uses `vim-plug`_ plugin manager, so after cloning, just open vim, and it
will automatically install all the plugins. will automatically install all the plugins.
Other than that, there are two additional config files which can be added to It should be cloned as is into `$HOME`` directory, i.e:
the configuration as a local configuration files just to not mess up with main
config file. Both of them should be placed under ``$HOME/.vim`` directory.
First one is ``vimrc.local``, which might contain additional/override options .. code:: console
for specific machine.
The other ``plugins.local`` and similarly there can be additional plugins cd $HOME
defined. git clone https://github.com/gryf/.vim
or in ``$XDG_COFIG_HOME`` directory, which usually is set to ``$HOME/.config``:
.. code:: console
git clone https://github.com/gryf/.vim ~/.config/vim
.. _vim-plug: https://github.com/junegunn/vim-plug .. _vim-plug: https://github.com/junegunn/vim-plug

View File

@@ -1,12 +1,10 @@
snippet #! snippet #!
#!/usr/bin/env python #!/usr/bin/env python3
snippet #!2 snippet #!2
#!/usr/bin/env python2 #!/usr/bin/env python2
# coding: utf-8 # coding: utf-8
snippet utf snippet utf
# coding: utf-8 # coding: utf-8
snippet #!3
#!/usr/bin/env python3
snippet dbg Python Debugger abbrv snippet dbg Python Debugger abbrv
__import__('pdb').set_trace() __import__('pdb').set_trace()
snippet ipdb ipdb abbrv snippet ipdb ipdb abbrv

173
vimrc
View File

@@ -1,15 +1,25 @@
"Basic setup for all files {{{ "Basic setup for all files {{{
set nocompatible "VIM over VI set nocompatible "VIM over VI
" vimplug conf {{{ " Get the config dir, as config can be either on ~/.vim or ~/.config/vim
let s:_confdir = fnamemodify($MYVIMRC, ':h')
if empty(glob('~/.vim/autoload/plug.vim')) " Set colorscheme depending on the environment vim is running
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs if $TERM == 'linux' && !has('gui_running')
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim " fallback to basic 8-color colorscheme
let s:_colorscheme = 'pablo'
else
let s:_colorscheme = 'wombat256grf'
endif
" vimplug conf {{{
if ! filereadable(s:_confdir . '/autoload/plug.vim')
silent exec "!curl -fLo " . s:_confdir . "/autoload/plug.vim --create-dirs"
\ "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif endif
call plug#begin('~/.vim/bundle') call plug#begin(s:_confdir . '/bundle')
Plug 'Valloric/MatchTagAlways', { 'for': ['html', 'xml'] } Plug 'Valloric/MatchTagAlways', { 'for': ['html', 'xml'] }
Plug 'ayuanx/vim-mark-standalone' Plug 'ayuanx/vim-mark-standalone'
@@ -54,16 +64,11 @@ Plug 'vim-scripts/mako.vim', { 'for': 'mako' }
Plug 'vim-scripts/mako.vim--Torborg', { 'for': 'mako' } Plug 'vim-scripts/mako.vim--Torborg', { 'for': 'mako' }
Plug 'vimwiki/vimwiki' Plug 'vimwiki/vimwiki'
Plug 'will133/vim-dirdiff' Plug 'will133/vim-dirdiff'
Plug 'rickhowe/diffchar.vim'
" Custom plugins: custom plugins per machine {{{ Plug 'thinca/vim-localrc'
" if filereadable($MYVIMRC . '.local')
if filereadable(fnamemodify($MYVIMRC, ':h') . '/plugins.local')
exec "source " . fnamemodify($MYVIMRC, ':h') . '/plugins.local'
endif
call plug#end() call plug#end()
" }}} " }}}
" }}}
filetype plugin indent on "turn plugins/indent on filetype plugin indent on "turn plugins/indent on
syntax on "Turn syntax highlighting on syntax on "Turn syntax highlighting on
@@ -122,7 +127,7 @@ set softtabstop=4
"spell options "spell options
set spelllang=pl,en set spelllang=pl,en
let &spellfile=expand('~/.vim/spell/pl.utf-8.add') let &spellfile=expand(s:_confdir . '/spell/pl.utf-8.add')
set splitbelow "Create new window below current one set splitbelow "Create new window below current one
set swapfile "Use swap file set swapfile "Use swap file
@@ -151,7 +156,7 @@ set noswapfile
"set undodir=~/.cache "set undodir=~/.cache
" Strip trailing whitespace option " Strip trailing whitespace option
let stripTrailingWhitespace = 1 let stripTrailingWhitespace = 0
" Ignore missing spell files " Ignore missing spell files
let loaded_spellfile_plugin = 1 let loaded_spellfile_plugin = 1
@@ -201,6 +206,12 @@ map <F3> :call <SID>CycleDiffAlgorithm()<cr>
map <F4> :call <SID>ToggleHex()<cr> map <F4> :call <SID>ToggleHex()<cr>
" }}} " }}}
"FileTypes: specific vim behaviour {{{ "FileTypes: specific vim behaviour {{{
function s:SetAsciiDoc() "{{{2
" AsciiDoc specific options
setlocal makeprg=asciidoc\ -b\ html5\ \"%\"
map <S-F5> :ShowInBrowser<CR>
endfunction
"}}}
function s:SetPythonSettings() "{{{2 function s:SetPythonSettings() "{{{2
" Python specific options " Python specific options
setlocal cinkeys-=0# setlocal cinkeys-=0#
@@ -247,18 +258,23 @@ function s:SetMarkdownSettings() "{{{2
setlocal autoindent setlocal autoindent
setlocal formatoptions=tcq "set VIms default setlocal formatoptions=tcq "set VIms default
function! <SID>ShowInBrowser()
let l:uri = expand("%:p:r") . ".html"
call system(g:browser . " " . l:uri)
echohl Statement
echo "Opened '" . l:uri ."' in " . g:browser
echohl None
endfunction
if !exists(":ShowInBrowser")
command ShowInBrowser call s:ShowInBrowser()
map <S-F5> :ShowInBrowser<CR> map <S-F5> :ShowInBrowser<CR>
endif
" https://github.com/jszakmeister/markdown2ctags
let g:tagbar_type_markdown = {
\ 'ctagstype': 'markdown',
\ 'ctagsbin' : 'markdown2ctags.py',
\ 'ctagsargs' : '-f - --sort=yes --sro=»',
\ 'kinds' : [
\ 's:sections',
\ 'i:images'
\ ],
\ 'sro' : '»',
\ 'kind2scope' : {
\ 's' : 'section',
\ },
\ 'sort': 0,
\ }
" autocmd BufWritePost *.md :silent make " autocmd BufWritePost *.md :silent make
endfunction endfunction
@@ -307,20 +323,7 @@ function s:SetRestSettings() "{{{2
setlocal formatoptions=tcq "set VIms default setlocal formatoptions=tcq "set VIms default
syn spell toplevel syn spell toplevel
function! <SID>ShowInBrowser()
let l:uri = expand("%:p:r") . ".html"
silent make
call system(g:browser . " " . l:uri)
echohl Statement
echo "Opened '" . l:uri ."' in " . g:browser
echohl None
endfunction
if !exists(":ShowInBrowser")
command ShowInBrowser call s:ShowInBrowser()
map <S-F5> :ShowInBrowser<CR> map <S-F5> :ShowInBrowser<CR>
endif
function! WordFrequency() range function! WordFrequency() range
let all = split(join(getline(a:firstline, a:lastline)), '\k\+') let all = split(join(getline(a:firstline, a:lastline)), '\k\+')
@@ -356,10 +359,19 @@ function s:SetRestSettings() "{{{2
endfunction endfunction
"}}} "}}}
function s:SetVimwikiSettings() "{{{2 function s:SetVimwikiSettings() "{{{2
let b:ale_enabled=0
setlocal spell setlocal spell
map <F5> :Vimwiki2HTML<CR> setlocal makeprg=vw2html\ -q\ \"%\"
map <S-F5> :Vimwiki2HTMLBrowse<CR> map <S-F5> :Vimwiki2HTMLBrowse<CR>
map <C-F5> :VimwikiAll2HTML<CR> map <C-F5> :PyVimwikiAll2Html<CR>
let g:tagbar_type_vimwiki = {
\ 'ctagstype' : 'vimwiki',
\ 'kinds' : [
\ 'h:header',
\ ],
\ 'sort' : 0
\ }
endfunction endfunction
"}}} "}}}
function s:SetGitcommitSettings() "{{{2 function s:SetGitcommitSettings() "{{{2
@@ -368,16 +380,14 @@ function s:SetGitcommitSettings() "{{{2
endfunction endfunction
"}}} "}}}
"remove all trailing whitespace for specified files before write autocmd BufRead,BufNewFile *.mako set filetype=mako
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces(0, 'n') autocmd BufRead,BufNewFile *.ass, *asm set filetype=kickass
autocmd BufRead *.mako set filetype=mako
autocmd BufRead *.ass, *asm set filetype=kickass
" make the current line highlighted only on current window " make the current line highlighted only on current window
autocmd WinEnter * setlocal cursorline autocmd WinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline autocmd WinLeave * setlocal nocursorline
autocmd FileType asciidoc call <SID>SetAsciiDoc()
autocmd FileType python call <SID>SetPythonSettings() autocmd FileType python call <SID>SetPythonSettings()
autocmd FileType json call <SID>SetJavaScriptSettings() autocmd FileType json call <SID>SetJavaScriptSettings()
autocmd FileType javascript call <SID>SetJavaScriptSettings() autocmd FileType javascript call <SID>SetJavaScriptSettings()
@@ -416,6 +426,7 @@ endif
"Ale {{{2 "Ale {{{2
let g:ale_sh_bashate_executable="bashate -i E006" let g:ale_sh_bashate_executable="bashate -i E006"
let g:ale_virtualtext_cursor=0 let g:ale_virtualtext_cursor=0
let g:ale_linters={'python': ['ruff']}
"}}} "}}}
"KickAssembler {{{2 "KickAssembler {{{2
let g:kickass_path = '/opt/KickAssembler/KickAss.jar' let g:kickass_path = '/opt/KickAssembler/KickAss.jar'
@@ -537,11 +548,17 @@ let g:tagbar_type_vimwiki = {
" Note: see statusline settings for status bar tag conf " Note: see statusline settings for status bar tag conf
"}}} "}}}
"VimWIKI {{{2 "VimWIKI {{{2
let g:vimwiki_list = [{'path': '~/vimwiki/', let g:vimwiki_list = [
\ {'path': '~/vimwiki/',
\ 'template_path': '~/vimwiki/', \ 'template_path': '~/vimwiki/',
\ 'path_html': '~/vimwiki_html_vw',
\ 'template_default': 'default', \ 'template_default': 'default',
\ 'template_ext': '.tpl', \ 'template_ext': '.tpl',
\ 'css_name': 'vimwiki_style.css'}] \ 'css_name': 'css/main.css'}
\ ]
let g:vimwiki_valid_html_tags = 'b,i,s,u,sub,sup,kbd,br,hr,span'
" Do not make syntax=vimwiki for markdown files, ignore md as vimwiki flavor
let g:vimwiki_ext2syntax = {}
"redefine tab key for vimwiki "redefine tab key for vimwiki
map <Leader>wn <Plug>VimwikiNextWord map <Leader>wn <Plug>VimwikiNextWord
map <Leader>wp <Plug>VimwikiPrevWord map <Leader>wp <Plug>VimwikiPrevWord
@@ -575,6 +592,19 @@ endfunction
"}}} "}}}
" FUNCTIONS: usefull functions for all of the files {{{ " FUNCTIONS: usefull functions for all of the files {{{
" open file in a browser. Usefull for documentation filetypes like reST, md or
" asciidoc
function! <SID>ShowInBrowser()
let l:uri = expand("%:p:r") . ".html"
silent make
call system(g:browser . " " . l:uri)
echohl Statement
echo "Opened '" . l:uri ."' in " . g:browser
echohl None
endfunction
command ShowInBrowser call s:ShowInBrowser()
" Simple wrapper for :make command " Simple wrapper for :make command
function <SID>Make() function <SID>Make()
echohl Statement echohl Statement
@@ -750,8 +780,46 @@ function s:CycleDiffAlgorithm()
echom 'Set diff algorithm to: ' . split(l:nextalgo, ':')[1] echom 'Set diff algorithm to: ' . split(l:nextalgo, ':')[1]
endfunction endfunction
" Convert wiki files to HTML
command -bang -nargs=? PyVimwikiAll2Html call ConvertVimwikiToHtml(<bang>0, 0)
command -bang -nargs=? PyVimwikiHtml call ConvertVimwikiToHtml(<bang>0, 1)
function ConvertVimwikiToHtml(forced, currentfile)
if &ft != 'vimwiki'
" not vimwiki file, do nothing
return
endif
let l:command = 'vw2html -q'
if a:forced == 1
let l:command = l:command . ' -f'
endif
if a:currentfile == 1
let l:command = l:command . ' ' . bufname("%")
endif
call system(l:command)
echom "Conversion to HTML done with command: " . l:command
endfunction
"write files as a root using sudo "write files as a root using sudo
command W w !sudo tee "%" > /dev/null command W w !sudo tee "%" > /dev/null
" stolen and modified from reddit, user and post doesn't exists enymore
function! InsertVimwikiLink()
" TODO: hardcoded, perhaps make some variables to handle this, or use
" g:vimwiki_list to guess the wiki location and default extension.
let l:wikilocation = '~/vimwiki'
let l:wikiext = '.wiki'
let files = systemlist("find " . l:wikilocation . " -name '*" . l:wikiext .
\ "' | sed 's#.*" . l:wikilocation[2:] .
\ "/##; s/\\" . l:wikiext . "$//'")
let choice = fzf#run(fzf#wrap(
\ {'source': files,
\ 'sink*': { lines -> execute("normal! a[[" . lines[0] . "]]") }
\}))
endfunction
nnoremap <leader>wl :call InsertVimwikiLink()<CR>
inoremap <C-x><C-w> <Esc>:call InsertVimwikiLink()<CR>
"}}} "}}}
" GUI: detect graphics mode, set colorscheme {{{ " GUI: detect graphics mode, set colorscheme {{{
if has('gui_running') if has('gui_running')
@@ -767,16 +835,7 @@ if has('gui_running')
au GUIEnter * set vb t_vb= au GUIEnter * set vb t_vb=
endif endif
silent! colorscheme wombat256grf silent! exec 'colorscheme ' . s:_colorscheme
if $TERM == 'linux' && !has('gui_running')
" fallback to basic 8-color colorscheme
colorscheme pablo
endif
"}}}
" Custom: custom config per machine {{{
if filereadable($MYVIMRC . '.local')
exec "source " . $MYVIMRC . '.local'
endif
"}}} "}}}
" vim:ts=4:sw=4:wrap:fdm=marker: " vim:ts=4:sw=4:wrap:fdm=marker: