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

Compare commits

...

8 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
2 changed files with 128 additions and 66 deletions

View File

@@ -7,14 +7,17 @@ of it.
It uses `vim-plug`_ plugin manager, so after cloning, just open vim, and it
will automatically install all the plugins.
Other than that, there are two additional config files which can be added to
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.
It should be cloned as is into `$HOME`` directory, i.e:
First one is ``vimrc.local``, which might contain additional/override options
for specific machine.
.. code:: console
The other ``plugins.local`` and similarly there can be additional plugins
defined.
cd $HOME
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

177
vimrc
View File

@@ -1,15 +1,25 @@
"Basic setup for all files {{{
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'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
" Set colorscheme depending on the environment vim is running
if $TERM == 'linux' && !has('gui_running')
" 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
endif
call plug#begin('~/.vim/bundle')
call plug#begin(s:_confdir . '/bundle')
Plug 'Valloric/MatchTagAlways', { 'for': ['html', 'xml'] }
Plug 'ayuanx/vim-mark-standalone'
@@ -28,7 +38,7 @@ Plug 'gryf/pythonhelper', { 'for': 'python' }
Plug 'gryf/snipmate.vim'
Plug 'gryf/vim-latex-compiler', { 'for': 'tex' }
Plug 'gryf/wombat256grf'
Plug 'gryf/zoom.vim' " control gui font size with '+' or '-; keys.
Plug 'gryf/zoom.vim' " control gui font size with '+' or '-; keys.
Plug 'habamax/vim-rst', { 'for': 'rst' }
Plug 'honza/vim-snippets'
Plug 'kien/ctrlp.vim'
@@ -54,16 +64,11 @@ Plug 'vim-scripts/mako.vim', { 'for': 'mako' }
Plug 'vim-scripts/mako.vim--Torborg', { 'for': 'mako' }
Plug 'vimwiki/vimwiki'
Plug 'will133/vim-dirdiff'
" Custom plugins: custom plugins per machine {{{
" if filereadable($MYVIMRC . '.local')
if filereadable(fnamemodify($MYVIMRC, ':h') . '/plugins.local')
exec "source " . fnamemodify($MYVIMRC, ':h') . '/plugins.local'
endif
Plug 'rickhowe/diffchar.vim'
Plug 'thinca/vim-localrc'
call plug#end()
" }}}
" }}}
filetype plugin indent on "turn plugins/indent on
syntax on "Turn syntax highlighting on
@@ -122,7 +127,7 @@ set softtabstop=4
"spell options
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 swapfile "Use swap file
@@ -151,7 +156,7 @@ set noswapfile
"set undodir=~/.cache
" Strip trailing whitespace option
let stripTrailingWhitespace = 1
let stripTrailingWhitespace = 0
" Ignore missing spell files
let loaded_spellfile_plugin = 1
@@ -201,6 +206,12 @@ map <F3> :call <SID>CycleDiffAlgorithm()<cr>
map <F4> :call <SID>ToggleHex()<cr>
" }}}
"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
" Python specific options
setlocal cinkeys-=0#
@@ -247,18 +258,23 @@ function s:SetMarkdownSettings() "{{{2
setlocal autoindent
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
map <S-F5> :ShowInBrowser<CR>
if !exists(":ShowInBrowser")
command ShowInBrowser call s:ShowInBrowser()
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
endfunction
@@ -307,20 +323,7 @@ function s:SetRestSettings() "{{{2
setlocal formatoptions=tcq "set VIms default
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>
endif
map <S-F5> :ShowInBrowser<CR>
function! WordFrequency() range
let all = split(join(getline(a:firstline, a:lastline)), '\k\+')
@@ -356,10 +359,19 @@ function s:SetRestSettings() "{{{2
endfunction
"}}}
function s:SetVimwikiSettings() "{{{2
let b:ale_enabled=0
setlocal spell
map <F5> :Vimwiki2HTML<CR>
setlocal makeprg=vw2html\ -q\ \"%\"
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
"}}}
function s:SetGitcommitSettings() "{{{2
@@ -368,16 +380,14 @@ function s:SetGitcommitSettings() "{{{2
endfunction
"}}}
"remove all trailing whitespace for specified files before write
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces(0, 'n')
autocmd BufRead *.mako set filetype=mako
autocmd BufRead *.ass, *asm set filetype=kickass
autocmd BufRead,BufNewFile *.mako set filetype=mako
autocmd BufRead,BufNewFile *.ass, *asm set filetype=kickass
" make the current line highlighted only on current window
autocmd WinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
autocmd FileType asciidoc call <SID>SetAsciiDoc()
autocmd FileType python call <SID>SetPythonSettings()
autocmd FileType json call <SID>SetJavaScriptSettings()
autocmd FileType javascript call <SID>SetJavaScriptSettings()
@@ -416,6 +426,7 @@ endif
"Ale {{{2
let g:ale_sh_bashate_executable="bashate -i E006"
let g:ale_virtualtext_cursor=0
let g:ale_linters={'python': ['ruff']}
"}}}
"KickAssembler {{{2
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
"}}}
"VimWIKI {{{2
let g:vimwiki_list = [{'path': '~/vimwiki/',
let g:vimwiki_list = [
\ {'path': '~/vimwiki/',
\ 'template_path': '~/vimwiki/',
\ 'path_html': '~/vimwiki_html_vw',
\ 'template_default': 'default',
\ '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
map <Leader>wn <Plug>VimwikiNextWord
map <Leader>wp <Plug>VimwikiPrevWord
@@ -575,6 +592,19 @@ endfunction
"}}}
" 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
function <SID>Make()
echohl Statement
@@ -750,8 +780,46 @@ function s:CycleDiffAlgorithm()
echom 'Set diff algorithm to: ' . split(l:nextalgo, ':')[1]
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
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 {{{
if has('gui_running')
@@ -767,16 +835,7 @@ if has('gui_running')
au GUIEnter * set vb t_vb=
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: