diff options
| author | Miguel <m.i@gmx.at> | 2018-05-29 20:27:28 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-05-29 20:27:28 +0200 |
| commit | 68b54b0d1729cd036fcba1c85f85ad4af6e9e3dc (patch) | |
| tree | 3d0f4e5eb1b147ae9ba193065d9c7b09f8e72f16 /vim | |
added vim stuff
Diffstat (limited to 'vim')
| -rw-r--r-- | vim/README.md | 48 | ||||
| -rw-r--r-- | vim/colors/miguels.vim | 200 | ||||
| -rw-r--r-- | vim/colors/olgas.vim | 117 | ||||
| l--------- | vim/init.vim | 1 | ||||
| -rw-r--r-- | vim/syntax/htmljinja.vim | 27 | ||||
| -rw-r--r-- | vim/syntax/jinja.vim | 113 | ||||
| -rw-r--r-- | vim/vim-colortune/colortune.vim | 468 | ||||
| -rw-r--r-- | vim/vim-potion/autoload/potion/running.vim | 33 | ||||
| -rw-r--r-- | vim/vim-potion/doc/potion.txt | 99 | ||||
| -rw-r--r-- | vim/vim-potion/ftdetect/potion.vim | 1 | ||||
| -rw-r--r-- | vim/vim-potion/ftplugin/potion/folding.vim | 38 | ||||
| -rw-r--r-- | vim/vim-potion/ftplugin/potion/running.vim | 6 | ||||
| -rw-r--r-- | vim/vim-potion/ftplugin/potion/sections.vim | 47 | ||||
| -rw-r--r-- | vim/vim-potion/syntax/potion.vim | 37 | ||||
| -rw-r--r-- | vim/vim-potion/syntax/potionbytecode.vim | 18 | ||||
| -rw-r--r-- | vim/vimrc | 579 |
16 files changed, 1832 insertions, 0 deletions
diff --git a/vim/README.md b/vim/README.md new file mode 100644 index 0000000..e4fe8e7 --- /dev/null +++ b/vim/README.md @@ -0,0 +1,48 @@ +My Vimrc Config +=============== + +This directory hosts my personal vim config files. + +Dependancies +============ + +Requires Vundle.vim which is available from github. + +I found the foloowing on vim.org. + +* syntax/htmljinja.vim +* syntax/jinja.vim + + +Installation +============ + +* symlink this directory to ~/.vim +* symlink this directory to ~/.config/nvim +* git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim +* Launch vim and run :PluginInstall + +Vim Colortune +============= + +The vim-colortune directory holds my simple, still unpolished plugin to easily tune +the vim colors from inside vim. + +Vim Potion +========== + +The vim-potion directory holds the result of my attempt to learn vimscript along +Steve Losh's book: Learn Vimscript The Hard Way: http://learnvimscriptthehardway.stevelosh.com/ + +License +======= + +Copyright (c) 2014-2018 Michal Idziorek (unless stated otherwise) + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vim/colors/miguels.vim b/vim/colors/miguels.vim new file mode 100644 index 0000000..79b18af --- /dev/null +++ b/vim/colors/miguels.vim @@ -0,0 +1,200 @@ +" +" Miguel's Vim Colors +" +" So far this scheme is mostly optimized for the gui version of vim. +" adaption for cterm / xterm might follow one day +" +" useful vim help-screens: group-name, highlight-groups, cterm-colors +" rgb: /usr/share/vim/vim73/rgb.txt +" + +set background=dark + +hi clear + +if exists("syntax_on") + syntax reset +endif + +let g:colors_name = "miguels" + +"first objective is to set: guifg guibg gui and maybe guisp +"afterwards we will port this to xterm +"""""""""""""""""""""""""""""""""""""""""""""""""""" + +"Normal normal text, we can also use "font=Monospace 10" or similar +hi Normal guifg=White guibg=Black gui=none ctermfg=White ctermbg=Black + +""""""""""""""""""""""""""""""""""""""""""""""""""" + +"Comment /* */, //, ... +hi Comment guifg=#5a7 gui=none ctermfg=DarkGreen cterm=none + +"Constant true, false, 0.123, "hello", <iostream> ... +hi Constant guifg=#8f6 gui=bold ctermfg=Cyan cterm=none + +"Identifier mysql_escape_string, $dupa, ... +hi Identifier guifg=orange gui=bold ctermfg=Brown cterm=none + +"Statement if, for, return, ... +hi Statement guifg=#f76 gui=bold ctermfg=Red cterm=none + +"PreProc #include, ... +hi PreProc guifg=#fe5 gui=none ctermfg=Yellow cterm=none + +"Type int, float, bool, struct ... +hi Type guifg=#89f gui=bold ctermfg=Blue cterm=bold + +"Special <?php, '\n', ... +hi Special guibg=gray20 guifg=#afc gui=bold ctermbg=DarkGray ctermfg=Green cterm=bold + + +" +hi Underlined gui=underline,bold guibg=#521 guifg=white ctermbg=black ctermfg=white cterm=underline +hi Ignore guifg=grey30 ctermfg=DarkGray + +"hi Error guifg=white guibg=#a00 gui=bold cterm=bold ctermfg=white ctermbg=red +hi Error guibg=#a00 +hi Todo guifg=black guibg=#dd7 gui=bold ctermbg=yellow ctermfg=black + +"""""""""""""""""""""""""""""""""""""""""""""""" + +"ColorColumn used for the columns set with 'colorcolumn' +hi ColorColumn guibg=#200 ctermbg=DarkRed ctermfg=White + +"Conceal placeholder characters substituted for concealed text (see 'conceallevel') +hi Conceal guibg=gray20 + +"Cursor the character under the cursor +hi Cursor guifg=black guibg=#afe gui=bold + +"CursorIM like Cursor, but used when in IME mode |CursorIM| +" I do not use this by now (set to strange colors to notice them easily) +hi CursorIM gui=underline guifg=yellow guibg=red + +"CursorColumn the screen column that the cursor is in when 'cursorcolumn' is set +hi CursorColumn guibg=#052010 + +"CursorLine the screen line that the cursor is in when 'cursorline' is set +hi CursorLine guibg=#052010 + +"Directory directory names (and other special names in listings) +hi Directory guifg=green + +"DiffAdd diff mode: Added line |diff.txt| +hi DiffAdd guibg=#326 + +"DiffChange diff mode: Changed line |diff.txt| +hi DiffChange gui=reverse + +"DiffDelete diff mode: Deleted line |diff.txt| +hi DiffDelete guibg=#a43 guifg=white + +"DiffText diff mode: Changed text within a changed line |diff.txt| +hi DiffText guibg=DarkRed + +"ErrorMsg error messages on the command line +hi ErrorMsg guifg=white guibg=#a00 gui=bold + +"VertSplit the column separating vertically split windows +hi VertSplit guibg=gray20 guifg=gray60 gui=none + +"Folded line used for closed folds +hi Folded guibg=gray20 guifg=#f7f gui=bold + +"FoldColumn 'foldcolumn' +hi FoldColumn guibg=gray20 guifg=#f7f gui=bold + +"SignColumn column where |signs| are displayed +hi SignColumn guibg=gray10 + +"IncSearch 'incsearch' highlighting; also used for the text replaced with ":s///c" +hi IncSearch guifg=yellow guibg=black + +"LineNr Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set. +hi LineNr guifg=gray80 guibg=gray10 gui=none ctermbg=Black ctermfg=Gray + +"CursorLineNr Like LineNr when 'cursorline' is set for the cursor line. +hi CursorLineNr guifg=gray10 guibg=gray60 gui=bold + +"MatchParen The character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt| +hi MatchParen guifg=black guibg=white gui=bold + +"ModeMsg 'showmode' message (e.g., "-- INSERT --") +hi ModeMsg guifg=#9fa gui=bold guibg=gray10 + +"MoreMsg |more-prompt| +hi MoreMsg guifg=yellow guibg=gray10 gui=bold + +"NonText '~' and '@' at the end of the window, characters from 'showbreak' and other characters that do not really exist in the text (e.g., ">" displayed when a double-wide character doesn't fit at the end of the line). +hi NonText guibg=gray10 guifg=#f0f gui=bold + +"Pmenu Popup menu: normal item. +hi Pmenu guibg=orange guifg=black + +"PmenuSel Popup menu: selected item. +hi PmenuSel guibg=red guifg=black gui=bold + +"PmenuSbar Popup menu: scrollbar. +hi PmenuSbar guibg=red + +"PmenuThumb Popup menu: Thumb of the scrollbar. +hi PmenuThumb guibg=black + +"Question |hit-enter| prompt and yes/no questions +hi Question guifg=yellow guibg=gray10 gui=bold + +"Search Last search pattern highlighting (see 'hlsearch'). Also used for highlighting the current line in the quickfix window and similar items that need to stand out. +hi Search guibg=orange guifg=black + +"SpecialKey Meta and special keys listed with ":map", also for text used to show unprintable characters in the text, 'listchars'. Generally: text that is displayed differently from what it really is. +hi SpecialKey guibg=gray20 guifg=#f95 gui=bold + +"SpellBad Word Warsaw that is not recoggized by the spellchecker. |spell| This will be combined with the highlighting used otherwise. +hi SpellBad gui=undercurl guisp=red + +"SpellCap Word that should start with a capital. |spell| This will be combined with the highlighting used otherwise. +hi SpellCap gui=undercurl guisp=yellow + +"SpellLocal Word that is recognized by the spellchecker as one that is used in another region. |spell| This will be combined with the highlighting used otherwise. +hi SpellLocal gui=undercurl guisp=LightBlue + +"SpellRare Word that is recognized by the spellchecker as one that is hardly ever used. |spell| This will be combined with the highlighting used otherwise. +hi SpellRare gui=undercurl guisp=green + +"StatusLine status line of current window +hi StatusLine guibg=gray20 guifg=white gui=none + +"StatusLineNC status lines of not-current windows Note: if this is equal to "StatusLine" Vim will use "^^^" in the status line of the current window. +hi StatusLineNC guibg=gray10 guifg=grey50 gui=none + +"Title titles for output from ":set all", ":autocmd" etc. +hi Title guifg=red guibg=gray10 gui=bold + +"Visual Visual mode selection +hi Visual gui=none guifg=white guibg=blue ctermfg=white ctermbg=blue cterm=none term=reverse + +"VisualNOS Visual mode selection when vim is "Not Owning the Selection". Only X11 Gui's |gui-x11| and |xterm-clipboard| supports this. +" I do not use this by now (set to strange colors to notice them easily) +hi VisualNOS gui=underline guifg=yellow guibg=red + +"WarningMsg warning messages +hi WarningMsg guifg=black guibg=#fa0 gui=bold + +"WildMenu current match in 'wildmenu' completion +hi WildMenu guibg=yellow guifg=black gui=bold + +" +"(The following only applies to the terminal version) +" + +"TabLine tab pages line, not active tab page label +hi TabLine ctermbg=darkgray ctermfg=gray + +"TabLineFill tab pages line, where there are no labels +hi TabLineFill ctermbg=black cterm=none + +"TabLineSel tab pages line, active tab page label +hi TabLineSel ctermbg=gray ctermfg=white + + diff --git a/vim/colors/olgas.vim b/vim/colors/olgas.vim new file mode 100644 index 0000000..1d7131e --- /dev/null +++ b/vim/colors/olgas.vim @@ -0,0 +1,117 @@ +set background=dark +hi clear +if exists("syntax_on") +syntax reset +endif +let g:colors_name = "olgas" + +" cterm colors +hi Normal cterm=NONE ctermfg=15 ctermbg=0 +hi Comment cterm=NONE ctermfg=32 ctermbg=NONE +hi Constant cterm=NONE ctermfg=40 ctermbg=NONE +hi Identifier cterm=bold ctermfg=11 ctermbg=NONE +hi Statement cterm=bold ctermfg=196 ctermbg=NONE +hi PreProc cterm=NONE ctermfg=136 ctermbg=NONE +hi Type cterm=bold ctermfg=135 ctermbg=NONE +hi Special cterm=bold ctermfg=51 ctermbg=NONE +hi Underlined cterm=underline ctermfg=NONE ctermbg=NONE +hi Ignore cterm=NONE ctermfg=240 ctermbg=NONE +hi Error cterm=bold ctermfg=15 ctermbg=196 +hi Todo cterm=bold ctermfg=16 ctermbg=11 +hi ColorColumn cterm=NONE ctermfg=NONE ctermbg=17 +hi Conceal cterm=NONE ctermfg=248 ctermbg=NONE +hi CursorColumn cterm=NONE ctermfg=NONE ctermbg=17 +hi CursorLine cterm=underline ctermfg=NONE ctermbg=17 +hi Directory cterm=NONE ctermfg=11 ctermbg=NONE +hi DiffAdd cterm=NONE ctermfg=0 ctermbg=14 +hi DiffChange cterm=NONE ctermfg=0 ctermbg=14 +hi DiffText cterm=NONE ctermfg=0 ctermbg=14 +hi ErrorMsg cterm=bold ctermfg=15 ctermbg=196 +hi VertSplit cterm=NONE ctermfg=248 ctermbg=17 +hi Folded cterm=bold ctermfg=15 ctermbg=17 +hi FoldColumn cterm=bold ctermfg=11 ctermbg=17 +hi SignColumn cterm=bold ctermfg=14 ctermbg=17 +hi IncSearch cterm=bold ctermfg=16 ctermbg=208 +hi LineNr cterm=NONE ctermfg=239 ctermbg=NONE +hi CursorLineNr cterm=bold ctermfg=16 ctermbg=7 +hi MatchParen cterm=bold ctermfg=196 ctermbg=NONE +hi ModeMsg cterm=bold ctermfg=NONE ctermbg=4 +hi MoreMsg cterm=bold ctermfg=NONE ctermbg=4 +hi NonText cterm=bold ctermfg=4 ctermbg=NONE +hi PmenuSel cterm=NONE ctermfg=0 ctermbg=14 +hi PmenuSbar cterm=NONE ctermfg=0 ctermbg=14 +hi PmenuThumb cterm=NONE ctermfg=0 ctermbg=14 +hi Question cterm=bold ctermfg=15 ctermbg=2 +hi Search cterm=bold ctermfg=16 ctermbg=11 +hi SpecialKey cterm=bold ctermfg=11 ctermbg=17 +hi SpellBad cterm=underline ctermfg=203 ctermbg=NONE +hi SpellCap cterm=underline ctermfg=214 ctermbg=NONE +hi SpellLocal cterm=underline ctermfg=105 ctermbg=NONE +hi SpellRare cterm=underline ctermfg=112 ctermbg=NONE +hi StatusLine cterm=NONE ctermfg=NONE ctermbg=NONE +hi StatusLineNC cterm=NONE ctermfg=241 ctermbg=NONE +hi Title cterm=bold ctermfg=14 ctermbg=NONE +hi Visual cterm=bold ctermfg=NONE ctermbg=4 +hi VisualNOS cterm=bold,underline ctermfg=11 ctermbg=196 +hi WarningMsg cterm=bold ctermfg=15 ctermbg=1 +hi WildMenu cterm=bold ctermfg=15 ctermbg=17 +hi TabLine cterm=NONE ctermfg=248 ctermbg=17 +hi TabLineFill cterm=NONE ctermfg=0 ctermbg=17 +hi TabLineSel cterm=bold ctermfg=15 ctermbg=0 + +"gui colors +hi Normal gui=NONE guifg=white guibg=black guisp=NONE +hi Comment gui=NONE guifg=#7799cc guibg=NONE guisp=NONE +hi Constant gui=NONE guifg=green guibg=NONE guisp=NONE +hi Identifier gui=bold guifg=yellow guibg=NONE guisp=NONE +hi Statement gui=bold guifg=orangered guibg=NONE guisp=NONE +hi PreProc gui=NONE guifg=#ffaa44 guibg=NONE guisp=NONE +hi Type gui=bold guifg=#aa55ff guibg=NONE guisp=NONE +hi Special gui=bold guifg=cyan guibg=NONE guisp=NONE +hi Underlined gui=underline guifg=NONE guibg=NONE guisp=NONE +hi Ignore gui=NONE guifg=grey20 guibg=NONE guisp=NONE +hi Error gui=bold guifg=white guibg=red guisp=NONE +hi Todo gui=bold guifg=black guibg=gold guisp=NONE +hi ColorColumn gui=NONE guifg=NONE guibg=#000036 guisp=NONE +hi Conceal gui=NONE guifg=LightGrey guibg=gray20 guisp=NONE +hi Cursor gui=bold guifg=black guibg=white guisp=NONE +hi CursorIM gui=underline guifg=yellow guibg=red guisp=NONE +hi CursorColumn gui=NONE guifg=NONE guibg=#000036 guisp=NONE +hi CursorLine gui=underline guifg=NONE guibg=#000036 guisp=NONE +hi Directory gui=NONE guifg=yellow guibg=NONE guisp=NONE +hi DiffAdd gui=NONE guifg=black guibg=cyan guisp=NONE +hi DiffChange gui=NONE guifg=black guibg=cyan guisp=NONE +hi DiffText gui=NONE guifg=black guibg=cyan guisp=NONE +hi ErrorMsg gui=bold guifg=white guibg=red guisp=NONE +hi VertSplit gui=NONE guifg=gray20 guibg=#000036 guisp=NONE +hi Folded gui=bold guifg=white guibg=#000056 guisp=NONE +hi FoldColumn gui=bold guifg=yellow guibg=#000026 guisp=NONE +hi SignColumn gui=bold guifg=cyan guibg=#000026 guisp=NONE +hi IncSearch gui=bold guifg=black guibg=orangered guisp=NONE +hi LineNr gui=NONE guifg=gray30 guibg=#000026 guisp=NONE +hi CursorLineNr gui=bold guifg=gray10 guibg=gray60 guisp=NONE +hi MatchParen gui=bold guifg=red guibg=#000036 guisp=NONE +hi ModeMsg gui=bold guifg=white guibg=blue guisp=NONE +hi MoreMsg gui=bold guifg=white guibg=blue guisp=NONE +hi NonText gui=bold guifg=#5577ee guibg=gray5 guisp=NONE +hi PmenuSel gui=NONE guifg=black guibg=cyan guisp=NONE +hi PmenuSbar gui=NONE guifg=black guibg=cyan guisp=NONE +hi PmenuThumb gui=NONE guifg=black guibg=cyan guisp=NONE +hi Question gui=bold guifg=white guibg=darkgreen guisp=NONE +hi Search gui=bold guifg=black guibg=orange guisp=NONE +hi SpecialKey gui=bold guifg=yellow guibg=gray10 guisp=NONE +hi SpellBad gui=undercurl guifg=NONE guibg=NONE guisp=red +hi SpellCap gui=undercurl guifg=NONE guibg=NONE guisp=yellow +hi SpellLocal gui=undercurl guifg=NONE guibg=NONE guisp=LightBlue +hi SpellRare gui=undercurl guifg=NONE guibg=NONE guisp=green +hi StatusLine gui=NONE guifg=NONE guibg=#000026 guisp=NONE +hi StatusLineNC gui=NONE guifg=gray40 guibg=#000026 guisp=NONE +hi Title gui=bold guifg=MediumSpringGreen guibg=NONE guisp=NONE +hi Visual gui=bold guifg=white guibg=blue guisp=NONE +hi VisualNOS gui=underline guifg=yellow guibg=red guisp=NONE +hi WarningMsg gui=bold guifg=white guibg=orangered guisp=NONE +hi WildMenu gui=bold guifg=white guibg=#112266 guisp=NONE +hi TabLine gui=NONE guifg=black guibg=cyan guisp=NONE +hi TabLineFill gui=NONE guifg=black guibg=cyan guisp=NONE +hi TabLineSel gui=NONE guifg=black guibg=cyan guisp=NONE + diff --git a/vim/init.vim b/vim/init.vim new file mode 120000 index 0000000..c9a3c9c --- /dev/null +++ b/vim/init.vim @@ -0,0 +1 @@ +vimrc
\ No newline at end of file diff --git a/vim/syntax/htmljinja.vim b/vim/syntax/htmljinja.vim new file mode 100644 index 0000000..3f9cba4 --- /dev/null +++ b/vim/syntax/htmljinja.vim @@ -0,0 +1,27 @@ +" Vim syntax file +" Language: Jinja HTML template +" Maintainer: Armin Ronacher <armin.ronacher@active-4.com> +" Last Change: 2007 Apr 8 + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +if !exists("main_syntax") + let main_syntax = 'html' +endif + +if version < 600 + so <sfile>:p:h/jinja.vim + so <sfile>:p:h/html.vim +else + runtime! syntax/jinja.vim + runtime! syntax/html.vim + unlet b:current_syntax +endif + +let b:current_syntax = "htmljinja" diff --git a/vim/syntax/jinja.vim b/vim/syntax/jinja.vim new file mode 100644 index 0000000..7704e3a --- /dev/null +++ b/vim/syntax/jinja.vim @@ -0,0 +1,113 @@ +" Vim syntax file +" Language: Jinja template +" Maintainer: Armin Ronacher <armin.ronacher@active-4.com> +" Last Change: 2008 May 9 +" Version: 1.1 +" +" Known Bugs: +" because of odd limitations dicts and the modulo operator +" appear wrong in the template. +" +" Changes: +" +" 2008 May 9: Added support for Jinja2 changes (new keyword rules) + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +syntax case match + +" Jinja template built-in tags and parameters (without filter, macro, is and raw, they +" have special threatment) +syn keyword jinjaStatement containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained and if else in not or recursive as import + +syn keyword jinjaStatement containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained is filter skipwhite nextgroup=jinjaFilter +syn keyword jinjaStatement containedin=jinjaTagBlock contained macro skipwhite nextgroup=jinjaFunction +syn keyword jinjaStatement containedin=jinjaTagBlock contained block skipwhite nextgroup=jinjaBlockName + +" Variable Names +syn match jinjaVariable containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/ +syn keyword jinjaSpecial containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained false true none loop super caller varargs kwargs + +" Filters +syn match jinjaOperator "|" containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained nextgroup=jinjaFilter +syn match jinjaFilter contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/ +syn match jinjaFunction contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/ +syn match jinjaBlockName contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/ + +" Jinja template constants +syn region jinjaString containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained start=/"/ skip=/\\"/ end=/"/ +syn region jinjaString containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained start=/'/ skip=/\\'/ end=/'/ +syn match jinjaNumber containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[0-9]\+\(\.[0-9]\+\)\?/ + +" Operators +syn match jinjaOperator containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[+\-*\/<>=!,:]/ +syn match jinjaPunctuation containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[()\[\]]/ +syn match jinjaOperator containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /\./ nextgroup=jinjaAttribute +syn match jinjaAttribute contained /[a-zA-Z_][a-zA-Z0-9_]*/ + +" Jinja template tag and variable blocks +syn region jinjaNested matchgroup=jinjaOperator start="(" end=")" transparent display containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained +syn region jinjaNested matchgroup=jinjaOperator start="\[" end="\]" transparent display containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained +syn region jinjaNested matchgroup=jinjaOperator start="{" end="}" transparent display containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained +syn region jinjaTagBlock matchgroup=jinjaTagDelim start=/{%-\?/ end=/-\?%}/ skipwhite containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaRaw,jinjaString,jinjaNested,jinjaComment + +syn region jinjaVarBlock matchgroup=jinjaVarDelim start=/{{-\?/ end=/-\?}}/ containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaRaw,jinjaString,jinjaNested,jinjaComment + +" Jinja template 'raw' tag +syn region jinjaRaw matchgroup=jinjaRawDelim start="{%\s*raw\s*%}" end="{%\s*endraw\s*%}" containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaString,jinjaComment + +" Jinja comments +syn region jinjaComment matchgroup=jinjaCommentDelim start="{#" end="#}" containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaString + +" Block start keywords. A bit tricker. We only highlight at the start of a +" tag block and only if the name is not followed by a comma or equals sign +" which usually means that we have to deal with an assignment. +syn match jinjaStatement containedin=jinjaTagBlock contained skipwhite /\({%-\?\s*\)\@<=\<[a-zA-Z_][a-zA-Z0-9_]*\>\(\s*[,=]\)\@!/ + +" and context modifiers +syn match jinjaStatement containedin=jinjaTagBlock contained /\<with\(out\)\?\s\+context\>/ skipwhite + + +" Define the default highlighting. +" For version 5.7 and earlier: only when not done already +" For version 5.8 and later: only when an item doesn't have highlighting yet +if version >= 508 || !exists("did_jinja_syn_inits") + if version < 508 + let did_jinja_syn_inits = 1 + command -nargs=+ HiLink hi link <args> + else + command -nargs=+ HiLink hi def link <args> + endif + + HiLink jinjaPunctuation jinjaOperator + HiLink jinjaAttribute jinjaVariable + HiLink jinjaFunction jinjaFilter + + HiLink jinjaTagDelim jinjaTagBlock + HiLink jinjaVarDelim jinjaVarBlock + HiLink jinjaCommentDelim jinjaComment + HiLink jinjaRawDelim jinja + + HiLink jinjaSpecial Special + HiLink jinjaOperator Normal + HiLink jinjaRaw Normal + HiLink jinjaTagBlock PreProc + HiLink jinjaVarBlock PreProc + HiLink jinjaStatement Statement + HiLink jinjaFilter Function + HiLink jinjaBlockName Function + HiLink jinjaVariable Identifier + HiLink jinjaString Constant + HiLink jinjaNumber Constant + HiLink jinjaComment Comment + + delcommand HiLink +endif + +let b:current_syntax = "jinja" diff --git a/vim/vim-colortune/colortune.vim b/vim/vim-colortune/colortune.vim new file mode 100644 index 0000000..97f2afd --- /dev/null +++ b/vim/vim-colortune/colortune.vim @@ -0,0 +1,468 @@ +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" +" Miguel's ColorTune plugin +" +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" {{{ +" +" TODO LIST: +" {{{ +" * restrict movement and values, but how??? +" * use R/G/B r/g/b keys to increase/decrease rgb values +" * map some nice short-keys for this buffer only +" * show rgb.txt! to alllow selection of named gui-colors +" * show some dropdowns or something for other stuff +" * let user override some of the values from users vimrc!! +" * enable reset to colortheme +" * clear all groups / clear group completely or just for active mode! +" * document and publish +" * treat NONE and NOT SET AT ALL differently!! +" * add some error detection and treatment! ie. setline etc.. +" * just redraw single lines where possible +" * REORDER and CLEANUP +" * create bundle and move most of functioanlity to autoload, +" except Colortune_start or somehting +" * check if we are not reinventing the wheel at some places: +" ie: getline()? +" * check if there are already such plugins, and find out why this one is +" better ;) +" * BUG: regex limited number so start/stop omittted in complete list +" so it is also not exported via config_dump right now +" * BUG: i do not understand set background. it is always set to dark by now +" * BUG: column names are not nicely aligned +" * BUG: spaces are not supported within key-values +" +" }}} + +" Set some basic defaults and initialize +" {{{ + +" modes are: 0-term, 1-cterm, 2-gui, 3-complete +let s:default_mode=2 + +let s:colortune_buf_name='__COLORTUNE_PLUGIN__' + +let s:temp_reg='a' + +" Define the popular highlight groups +let s:colortable=[ + \ 'Normal', 'Comment', 'Constant', 'Identifier', + \ 'Statement', 'PreProc', 'Type', 'Special', 'Underlined', + \ 'Ignore', 'Error', 'Todo', 'ColorColumn', 'Conceal', 'Cursor', + \ 'CursorIM', 'CursorColumn', 'CursorLine', 'Directory', + \ 'DiffAdd', 'DiffChange', 'DiffText', 'ErrorMsg', 'VertSplit', + \ 'Folded', 'FoldColumn', 'SignColumn', 'IncSearch', 'LineNr', + \ 'CursorLineNr', 'MatchParen', 'ModeMsg', 'MoreMsg', 'NonText', + \ 'PmenuSel', 'PmenuSbar', 'PmenuThumb', 'Question', 'Search', + \ 'SpecialKey', 'SpellBad', 'SpellCap', 'SpellLocal', + \ 'SpellRare', 'StatusLine', 'StatusLineNC', 'Title', 'Visual', + \ 'VisualNOS', 'WarningMsg', 'WildMenu', 'TabLine', + \ 'TabLineFill', 'TabLineSel' ] + + +" Define modes and their relevant keys in the highlight groups +let s:modes_labels=['Black & White Terminals','Color Terminals','GUI','Complete'] +let s:modes=[ ['term','start','stop'], + \ ['cterm','ctermfg','ctermbg'], + \ ['gui','guifg','guibg','guisp'], + \ ['term','cterm','ctermfg','ctermbg','gui','guifg','guibg','guisp']] + +" init +" +let s:current_mode=s:default_mode +" }}} + +" Colortune_getline() +" {{{ +" Retruns current line of current buffer. +" +function! Colortune_getline() + return getline(line('.')) +endfunction +" }}} + +" Colortune_getcmdoutput(cmd) +" {{{ +" Redirect the output of cmd to a temporary register and return result. +" +function! Colortune_getcmdoutput(cmd) + + let reg_val=getreg(s:temp_reg) + redir @a + silent execute a:cmd + redir END + let val=getreg(s:temp_reg) + call setreg(s:temp_reg,reg_val) + return val + +endfunction +" }}} + +" Colortune_getattr(group,key) +" {{{ +" Get the value of one 'key' of a highlighting group +" returns 'NONE' if the requested key is not specified +" +function! Colortune_getattr(group,key) + + let hil=Colortune_getcmdoutput('hi '.a:group) + + " extract the value for given key (if exists) and return + if hil !~# a:key.'=.\+' + let val='NONE' + else + let val=substitute(hil.' ','^.* '.a:key.'=\(.\{-}\)\s.*$','\1','') + endif + return val + +endfunction +"}}} + +" Colortune_getmax(key) +" {{{ +" Returns maximal length of values for requested key. +" key='GROUP_NAME' returns maximal length of highlight group names. +" +function! Colortune_getmax(key) + let max=0 + for group in s:colortable + if(a:key==#'GROUP_NAME') + let length=len(group) + else + let length=len(Colortune_getattr(group,a:key)) + endif + let max = max<length ? length : max + endfor + return max +endfunction +" }}} + +" Colortune_extend(val,fill,len) +" {{{ +" Extend string 'val' with characters 'fill' to match length of 'len' +" +function! Colortune_extend(val,fill,len) + + let len=a:len-len(a:val) + let val=a:val + + while len>0 + let len-=1 + let val.=a:fill + endwhile + return val + +endfunction +" }}} + +" Colortune_togglemode() +" {{{ +" Cycles through available modes +" +function! Colortune_togglemode() + + let max=len(s:modes)-1 + let s:current_mode+=1 + if s:current_mode > max + let s:current_mode=0 + endif + call Colortune_fill() +endfunction +" }}} + +" Colortune_getregexpattern() +" {{{ +" Helper function that builds our regex-pattern for setting and clearing +" the highlight values, based on the current buffer-line +" +function! Colortune_getregexpattern() + + let str='^\(.\{-}\)\s.*' + + for column in s:modes[s:current_mode] + let str.='.*\[\(.*\)\]' + endfor + + return str + +endfunction +" }}} + +" Colortune_getregexstring() +" {{{ +" Helper function that builds our substitution string for setting +" the highlight values, based on the current buffer-line +" +function! Colortune_getregexstring() + let str='' + let idx=2 + for column in s:modes[s:current_mode] + let str.=' '.column.'=\'.idx + let idx+=1 + endfor + return str +endfunction +" }}} + +" Colortune_clearbyline() +" {{{ +" Clear highlight group in current line +" Set highlight group values by extracting them from the current line +" +function! Colortune_clearbyline() + let myline=Colortune_getline() + exec substitute(myline,Colortune_getregexpattern(),'hi clear \1','') + call Colortune_fill() +endfunction +" }}} + +" Colortune_setbyline() +" {{{ +" Set highlight group values by extracting them from the current line +" +function! Colortune_setbyline() + let myline=Colortune_getline() + exec substitute(myline,Colortune_getregexpattern(),'hi \1 '.Colortune_getregexstring(),'') + call Colortune_fill() +endfunction +" }}} + +" Colortune_fill() +" {{{ +" Create or Redraw the ColorTune Window/Buffer +" +function! Colortune_fill() + + " open a new split or switch to it (if already open) + let potbufnr=bufwinnr(s:colortune_buf_name) + if potbufnr==#-1 + execute 'vsplit '.s:colortune_buf_name + else + execute potbufnr.'wincmd w' + endif + + " set some options + setlocal filetype=colortune + setlocal buftype=nofile + setlocal nowrap + + " set mappings + nnoremap <buffer> <cr> :call Colortune_setbyline()<cr> + inoremap <buffer> <cr> <esc>:call Colortune_setbyline()<cr> + + nnoremap <buffer> X :call Colortune_clearbyline()<cr> + nnoremap <buffer> M :call Colortune_togglemode()<cr> + nnoremap <buffer> C :call Colortune_dumpconfig()<cr> + + nnoremap <buffer> Ar :call Colortune_manipulate_rgb(16,0,0)<cr> + nnoremap <buffer> Sr :call Colortune_manipulate_rgb(-16,0,0)<cr> + nnoremap <buffer> Ag :call Colortune_manipulate_rgb(0,16,0)<cr> + nnoremap <buffer> Sg :call Colortune_manipulate_rgb(0,-16,0)<cr> + nnoremap <buffer> Ab :call Colortune_manipulate_rgb(0,0,16)<cr> + nnoremap <buffer> Sb :call Colortune_manipulate_rgb(0,0,-16)<cr> + + nnoremap <buffer> ar :call Colortune_manipulate_rgb(1,0,0)<cr> + nnoremap <buffer> sr :call Colortune_manipulate_rgb(-1,0,0)<cr> + nnoremap <buffer> ag :call Colortune_manipulate_rgb(0,1,0)<cr> + nnoremap <buffer> sg :call Colortune_manipulate_rgb(0,-1,0)<cr> + nnoremap <buffer> ab :call Colortune_manipulate_rgb(0,0,1)<cr> + nnoremap <buffer> sb :call Colortune_manipulate_rgb(0,0,-1)<cr> + + + nnoremap <buffer> VG :call Colortune_showguirgb()<cr> + nnoremap <buffer> VC :call Colortune_showctermrgb()<cr> + + + " set syntax highlighting for our group keywords + for mycolor in s:colortable + execute 'syn keyword '.mycolor.' '.mycolor + endfor + + " remember current position and clean the buffer + let top_line=line('w0') + let cur_line=line('.') + let save_cursor = getpos(".") + normal! ggdG + + " display header with some infos + call append(line('$')-1,'------------------------------------------') + call append(line('$')-1,'Colortable Mode: ['.s:modes_labels[s:current_mode].']') + call append(line('$')-1,'------------------------------------------') + call append(line('$')-1,'ENTER - Set from current line -----------') + call append(line('$')-1,'X - Unset current line --------------') + call append(line('$')-1,'M - Toggle Mode ---------------------') + call append(line('$')-1,'C - Dump Config to new buffer -------') + call append(line('$')-1,'VC - View palette (cterm) -----------') + call append(line('$')-1,'VG - View palette (gui) -------------') + call append(line('$')-1,'a[rgb] - increase [rgb]] by 1 ------------') + call append(line('$')-1,'A[rgb] - increase [rgb]] by 16 -----------') + call append(line('$')-1,'s[rgb] - decrease [rgb]] by 1 ------------') + call append(line('$')-1,'S[rgb] - decrease [rgb]] by 16 -----------') + call append(line('$')-1,'------------------------------------------') + call append(line('$')-1,'-') + + " find out the maximal length for each column + let max_len=[Colortune_getmax('GROUP_NAME')] + for column in s:modes[s:current_mode] + let max_len+=[Colortune_getmax(column)] + endfor + + " display column names + let labels=Colortune_extend('GROUP_NAME'.' ',' ',5+max_len[0]) + let idx=1 + for column in s:modes[s:current_mode] + let labels.=' '.Colortune_extend(column,' ',max_len[idx]).' ' + let idx+=1 + endfor + call append(line('$')-1,labels) + call append(line('$')-1,'------------------------------------------') + + " paint the color table + for group in s:colortable + + let colorline=Colortune_extend(group.' ','-',5+max_len[0]) + + let idx=1 + for column in s:modes[s:current_mode] + let value=Colortune_getattr(group,column) + let colorline.=' ['.Colortune_extend(value,' ',max_len[idx]).'] ' + let idx+=1 + endfor + + call append(line('$')-1,colorline) + + endfor + + " delete last (empty) line and restore initial position. + normal ddgg + exec 'normal G'.top_line.'G'.cur_line.'G' + call setpos('.', save_cursor) + +endfunction +" }}} + +" Colortune_dumpconfig() +" {{{ +" +function! Colortune_dumpconfig() + + new + set ft=vim + set nowrap + + " add header stuff for our colortheme + call append(line('$')-1,[ + \ 'set background=dark', + \ 'hi clear', + \ 'if exists("syntax_on")', 'syntax reset', 'endif', + \ 'let g:colors_name = "mycolorscheme"']) + + + for group in s:colortable + let config='' + + for column in s:modes[s:current_mode] + let value=Colortune_getattr(group,column) + let config.=' '.column.'='.value + endfor + call append(line('$')-1,'hi '.group.config) + endfor + + normal gg + +endfunction +" }}} + +" Colortune_manipulate_rgb() +" {{{ +" TODO: restore register! +" TODO: check overflow/underflow +" TODO: check format +" +function! Colortune_manipulate_rgb(r,g,b) + + normal T["adt] + let val=getreg('a') + let r='0x'.substitute(val,'^#\(\x\x\)\x\x\x\x','\1','') + let g='0x'.substitute(val,'^#\x\x\(\x\x\)\x\x','\1','') + let b='0x'.substitute(val,'^#\x\x\x\x\(\x\x\)','\1','') + call setreg('a',printf("#%02x%02x%02x",r+a:r,g+a:g,b+a:b)) + normal "aP + call Colortune_setbyline() + +endfunction + + +" }}} + +" Colortune_showguirgb() +"{{{ +function! Colortune_showguirgb() + + vnew + set nowrap + nnoremap <buffer> <cr> :call Colortune_fillincolor()<cr> + + r $VIMRUNTIME/rgb.txt + let linenr=1 + let result=[] + while linenr<line('$') + + let myline=getline(linenr) + if myline =~# '^\s*\d\+\s\+\d\+\s\+\d\+\s\+\w\+\s*$' + exec substitute(myline,'^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(\d\+\)\s\+\(\w\+\)\s*$','let extr=["\4",\1,\2,\3]','') + exec 'hi color_'.extr[0].' guibg='.printf("#%02x%02x%02x",extr[1],extr[2],extr[3]) + exec 'syntax match color_'.extr[0].' "color_'.extr[0].'"' + let result+=[extr[0].' ~ color_'.extr[0]] + else + endif + + let linenr+=1 + + endwhile + + normal ggdG + call append(0,result) + + +endfunction +"}}} + +" Colortune_showctermrgb() +"{{{ +function! Colortune_showctermrgb() + + vnew + set nowrap + nnoremap <buffer> <cr> :call Colortune_fillincolor()<cr> + + let colornr=0 + let result=[] + while colornr<256 + + exec 'hi color_'.colornr.' ctermbg='.colornr + exec 'syntax match color_'.colornr.' "color_'.colornr.'"' + let result+=[colornr.' ~ color_'.colornr] + let colornr+=1 + + endwhile + + call append(0,result) + + +endfunction +"}}} + +" Colortune_fillincolor() +" {{{ +function! Colortune_fillincolor() + normal 0"ayaw + let potbufnr=bufwinnr(s:colortune_buf_name) + execute potbufnr.'wincmd w' + normal di]"aP + call Colortune_setbyline() +endfunction +" }}} + +" }}} + diff --git a/vim/vim-potion/autoload/potion/running.vim b/vim/vim-potion/autoload/potion/running.vim new file mode 100644 index 0000000..562f713 --- /dev/null +++ b/vim/vim-potion/autoload/potion/running.vim @@ -0,0 +1,33 @@ +function! potion#running#PotionCompileAndRunFile() + write + silent !clear + execute "!" . g:potion_command . " " . bufname("%") +endfunction + +function! potion#running#PotionShowBytecode() + + write + + " Get the bytecode. + let bytecode = system(g:potion_command . " -c -V " . bufname("%") . " 2>&1") + + " Check returned string for errors. + if bytecode=~#"Syntax error" + let bytecode = "SYNTAX ERROR!! Check your potion." + endif + + " Open a new split and set it up or use existing one! + let potbufnr=bufwinnr('__Potion_Bytecode__') + if potbufnr==#-1 + vsplit __Potion_Bytecode__ + else + execute potbufnr.'wincmd w' + endif + normal! ggdG + setlocal filetype=potionbytecode + setlocal buftype=nofile + + " Insert the bytecode. + call append(0, split(bytecode, '\v\n')) + +endfunction diff --git a/vim/vim-potion/doc/potion.txt b/vim/vim-potion/doc/potion.txt new file mode 100644 index 0000000..4cd9191 --- /dev/null +++ b/vim/vim-potion/doc/potion.txt @@ -0,0 +1,99 @@ +*potion.txt* basic functionality for the potion programming language +======================================================================== +INTRO *PotionIntro* + + ___ _ _ ~ + / _ \___ | |_(_) ___ _ __ ~ + / /_)/ _ \| __| |/ _ \| '_ \ ~ + / ___/ (_) | |_| | (_) | | | | ~ + \/ \___/ \__|_|\___/|_| |_| ~ + + + Functionality for the Potion programming language. + Includes syntax highlighting, code folding, and more! + + Coded by Michal Idziorek <m.i@gmx.at> + along the "Learn Vimscript the Hard Way" tutorial: + http://learnvimscriptthehardway.stevelosh.com + + +======================================================================== +CONTENTS *PotionContents* + + 1. Usage .............. |PotionUsage| + 2. Installation ....... |PotionInstall| + 3. Files .............. |PotionFiles| + 4. Credits ............ |PotionCredits| + + +======================================================================== +USAGE *PotionUsage* + +This plugin will automatically provide syntax highlighting and folding +for potion files (files ending in .pn). + +It remaps the section movement commands, to provide easy navigation +through potion files: +> + [[ ]] [] ][ +< + +The plugin offers mappings for invoking the potion compiler as well: + +Press <localleader>r for running the currently opened potion file. +Press <localleader>b for showing its compiled bytecode in a new window. + +Set your maplocalleader in your .vimrc like this: +> + let maplocalleader="\<space>" +< + +You can set the path to the potion binary in your .vimrc too: +> + let g:potion_command = "/home/miguel/int/dev/potion/bin/potion" +< + +Otherwise the following default value will be used: +> + let g:potion_command = "potion" +< + +======================================================================== +INSTALLATION *PotionInstall* + +Use Tim Pope's marvellous 'pathogen.vim' to simply put the potion plugin +into its own private directory. You can get Pathogen on GitHub: +> + https://github.com/tpope/vim-pathogen +< + +Use git to clone the plugin directly into its target directory to keep +it up to date easily. +> + ~/.vim/bundle/potion/ +< + +======================================================================== +FILES *PotionFiles* + +The potion plugin ships with the following files: + +doc/potion.txt ................ Documentation (this file) +ftdetect/potion.vim ........... Detection of potion files by .pn ending +syntax/potion.vim ............. Syntax highlighting for .pn files +syntax/potionbytecode.vim ..... Syntax highlighting for bytecode +ftplugin/potion/folding.vim ... Folding functionality +ftplugin/potion/sections.vim .. Section movement via [[,]],[],][ +ftplugin/potion/running.vim ... Mappings for running the potion compiler +autoload/potion/running.vim ... Functions for running the compiler + + +======================================================================== +CREDITS *PotionCredits* + +This is my very first Vim plugin and it emerged during the course +of reading Steve Losh' wonderful Vimscript tutorial: +> + "Learn Vimscript the Hard Way". + http://learnvimscriptthehardway.stevelosh.com +< diff --git a/vim/vim-potion/ftdetect/potion.vim b/vim/vim-potion/ftdetect/potion.vim new file mode 100644 index 0000000..a3a3170 --- /dev/null +++ b/vim/vim-potion/ftdetect/potion.vim @@ -0,0 +1 @@ +au BufNewFile,BufRead *.pn setfiletype potion diff --git a/vim/vim-potion/ftplugin/potion/folding.vim b/vim/vim-potion/ftplugin/potion/folding.vim new file mode 100644 index 0000000..d4cb32b --- /dev/null +++ b/vim/vim-potion/ftplugin/potion/folding.vim @@ -0,0 +1,38 @@ +setlocal foldmethod=expr +setlocal foldexpr=GetPotionFold(v:lnum) + +function! s:NextNonBlankLine(lnum) + let numlines = line('$') + let current = a:lnum + 1 + + while current <= numlines + if getline(current) =~? '\v\S' + return current + endif + + let current += 1 + endwhile + + return -2 +endfunction + +function! s:IndentLevel(lnum) + return indent(a:lnum) / &shiftwidth +endfunction + +function! GetPotionFold(lnum) + if getline(a:lnum) =~? '\v^\s*$' + return '-1' + endif + + let this_indent = <SID>IndentLevel(a:lnum) + let next_indent = <SID>IndentLevel(<SID>NextNonBlankLine(a:lnum)) + + if next_indent == this_indent + return this_indent + elseif next_indent < this_indent + return this_indent + elseif next_indent > this_indent + return '>' . next_indent + endif +endfunction diff --git a/vim/vim-potion/ftplugin/potion/running.vim b/vim/vim-potion/ftplugin/potion/running.vim new file mode 100644 index 0000000..d70adc0 --- /dev/null +++ b/vim/vim-potion/ftplugin/potion/running.vim @@ -0,0 +1,6 @@ +if !exists("g:potion_command") + let g:potion_command = "potion" +endif + +nnoremap <buffer> <localleader>r :call potion#running#PotionCompileAndRunFile()<cr> +nnoremap <buffer> <localleader>b :call potion#running#PotionShowBytecode()<cr> diff --git a/vim/vim-potion/ftplugin/potion/sections.vim b/vim/vim-potion/ftplugin/potion/sections.vim new file mode 100644 index 0000000..200415c --- /dev/null +++ b/vim/vim-potion/ftplugin/potion/sections.vim @@ -0,0 +1,47 @@ +function! s:NextSection(type, backwards, visual) + + if a:visual + normal! gv + endif + + if a:type == 1 + let pattern = '\v(\n\n^\S|%^)' + let flags = 'e' + elseif a:type == 2 + let pattern = '\v^\S.*\=.*:$' + let flags = '' + endif + + if a:backwards + let dir = '?' + else + let dir = '/' + endif + + execute 'silent normal! ' . dir . pattern . dir . flags . "\r" + +endfunction + +noremap <script> <buffer> <silent> ]] + \ :call <SID>NextSection(1, 0, 0)<cr> + +noremap <script> <buffer> <silent> [[ + \ :call <SID>NextSection(1, 1, 0)<cr> + +noremap <script> <buffer> <silent> ][ + \ :call <SID>NextSection(2, 0, 0)<cr> + +noremap <script> <buffer> <silent> [] + \ :call <SID>NextSection(2, 1, 0)<cr> + +vnoremap <script> <buffer> <silent> ]] + \ :<c-u>call <SID>NextSection(1, 0, 1)<cr> + +vnoremap <script> <buffer> <silent> [[ + \ :<c-u>call <SID>NextSection(1, 1, 1)<cr> + +vnoremap <script> <buffer> <silent> ][ + \ :<c-u>call <SID>NextSection(2, 0, 1)<cr> + +vnoremap <script> <buffer> <silent> [] + \ :<c-u>call <SID>NextSection(2, 1, 1)<cr> diff --git a/vim/vim-potion/syntax/potion.vim b/vim/vim-potion/syntax/potion.vim new file mode 100644 index 0000000..2ca9dbc --- /dev/null +++ b/vim/vim-potion/syntax/potion.vim @@ -0,0 +1,37 @@ +if exists("b:current_syntax") + finish +endif + +syntax keyword potionKeyword loop times to while +syntax keyword potionKeyword if elsif else +syntax keyword potionKeyword class return +syntax keyword potionFunction print join string + +syntax match potionOperator "\v\." +syntax match potionOperator "\v:" +syntax match potionOperator "\v\=" +syntax match potionOperator "\v\*" +syntax match potionOperator "\v/" +syntax match potionOperator "\v\+" +syntax match potionOperator "\v-" +syntax match potionOperator "\v\?" +syntax match potionOperator "\v\*\=" +syntax match potionOperator "\v/\=" +syntax match potionOperator "\v\+\=" +syntax match potionOperator "\v-\=" + +syntax match potionNumber "\v\d+" +syntax match potionNumber "\v0x\x+" + +syntax region potionString start=/\v"/ skip=/\v\\./ end=/\v"/ + +syntax match potionComment "\v#.*$" + +highlight link potionString String +highlight link potionOperator Operator +highlight link potionKeyword Keyword +highlight link potionFunction Function +highlight link potionComment Comment +highlight link potionNumber Number + +let b:current_syntax = "potion" diff --git a/vim/vim-potion/syntax/potionbytecode.vim b/vim/vim-potion/syntax/potionbytecode.vim new file mode 100644 index 0000000..24e2e44 --- /dev/null +++ b/vim/vim-potion/syntax/potionbytecode.vim @@ -0,0 +1,18 @@ +" minimalistic syntax highlighting for testing purposes + +if exists("b:current_syntax") + finish +endif + +syntax keyword potionKeyword code assign + + +syntax match potionNumber "\v\d+" +syntax region potionString start=/\v"/ skip=/\v\\./ end=/\v"/ + + +highlight link potionString String +highlight link potionKeyword Keyword +highlight link potionNumber Number + +let b:current_syntax = "potionbytecode" diff --git a/vim/vimrc b/vim/vimrc new file mode 100644 index 0000000..d716a0e --- /dev/null +++ b/vim/vimrc @@ -0,0 +1,579 @@ +""""""""""""""""""""""""""""""""""""" +" Miguel's .vimrc " +" Author: Michal Idziorek " +" Last Update: 2018-05-29 " +""""""""""""""""""""""""""""""""""""" + +" {{{ TODO / NOTES +" +" http://www.alexeyshmalko.com/2014/using-vim-as-c-cpp-ide/ +" set exrc +" set secure +" +" https://github.com/spf13/spf13-vim +" http://antjanus.com/blog/thoughts-and-opinions/use-vim/ +" http://stevelosh.com/blog/2010/09/coming-home-to-vim/ +" http://derekingrouville.com/2012/vim-is-my-ide/ +" http://www.alexeyshmalko.com/2014/using-vim-as-c-cpp-ide/ +" +" * check out this plugins! (and many more from vim.org) +" +" taglist.vim +" NerdTree DONE +" snipMate +" c.vim ? +" autocomplpop +" pathogen DONE +" minibufexpl DONE +" fugitive DONE +" vim-sensible DONE +" surround +" perl-support ? +" matchit +" vimspell +" conqueshell +" fuzzyfinder +" Nerd Commenter +" tSkeleton +" grep +" cppcomplete +" colortest ? +" colour sampler pack +" gundo! +" CScope / CCTree +" inline reference/ (stlrefvim?) +" emmet.io (webdev) +" +" * jump to definition / list calls +" +" * spellcheck / translate / thesaurus +" +" * change mappings to more specific mappings and use noremap! +" +" * toggle 'cursorline' via hotkey for nicer reading experience. +" +" * spellcheck +" +" * ft=c.doxygen etc. +" +" * include dependancies as git submodules (wherever possible) +" (check licenses first) +" +" * :help complete-functions +" +" * spellcheck +" +" * ctags shortcuts? +" +" * quickfix +" +" * compiler/debugger invocation +" +" * implement a plugin for fast-reading (check if one exists first ;)) +" +" * release vim-colortune plugin +" +" * dictionary +" +" * load layout automatically on start +" +" * ConqueGDB Resize +" +" * Do something about startup lag (because of YouCompleteMe) +" +" * Do something about the input problems in ConqueGDB/Term (YouCompl?) +" +" }}} + +" {{{ Vundle - Plugin Manager +" +" Vundle plugin manager (Replaces pathogen)" +" https://github.com/VundleVim/Vundle.vim +set nocompatible +filetype off + +" set the runtime path to include Vundle and initialize +set rtp+=~/.vim/bundle/Vundle.vim + +call vundle#begin() +" alternatively, pass a path where Vundle should install plugins +" call vundle#begin('~/some/path/here') + +" let Vundle manage Vundle, required +Plugin 'gmarik/Vundle.vim' + +" github plugins +" Plugin 'Valloric/YouCompleteMe' +Plugin 'fholgado/minibufexpl.vim' +Plugin 'scrooloose/nerdtree' +Plugin 'majutsushi/tagbar' +Plugin 'tpope/vim-fugitive' +Plugin 'tpope/vim-sensible' +Plugin 'vim-scripts/Conque-GDB' + +" My own plugins on github +" Plugin 'git://ex40.softwarefools.com/vim-potion.git' +" Plugin 'git://ex40.softwarefools.com/vim-colortune.git' + +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" draculatheme.com +" Plugin 'dracula/vim' +" syntax on +" color dracula +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" All of your Plugins must be added before the following line +call vundle#end() +filetype plugin indent on + +" To ignore plugin indent changes, instead use: +" filetype plugin on +" +" Brief help +" :PluginList - lists configured plugins +" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate +" :PluginSearch foo - searches for foo; append `!` to refresh local cache +" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal +" +" see :h vundle for more details or wiki for FAQ +" Put your non-Plugin stuff after this line +" }}} + +let g:ConqueGdb_Leader = '\' +let g:ConqueTerm_CloseOnEnd = 1 + +set nowrap +set invlist + +" PATH +" let $PATH='/home/miguel/opt/gcc-5.1.0/bin:'.$PATH +" let $PATH='/home/miguel/opt/gcc-5.2.0/bin:'.$PATH + +" Basic Settings +" {{{ + +" let there be mapleaders +" {{{ +" use <space> but remap to _ so it is visible for 'showcmd' +nmap <space> _ +let mapleader="\_" +let maplocalleader="\_" +" }}} + +" filetype stuff +" {{{ +filetype plugin indent on +" }}} + +" misc! +" {{{ +let g:potion_command = "/home/miguel/int/dev/potion/bin/potion" + +set nocompatible +set backspace=2 +" set ruler +set showcmd +set number +set hidden + +" set cursorcolumn +" set cursorline + +" save before making etc. +set autowrite + +" some nice candy +set laststatus=2 +set wildmenu + +" indent +set autoindent +set cindent + +" mouse support in xterm +set mouse=a + +"other +set previewheight=25 + +" http://robots.thoughtbot.com/vim-splits-move-faster-and-more-naturally +" set splitbelow +" set splitright + +nnoremap <C-J> <C-W><C-J> +nnoremap <C-K> <C-W><C-K> +nnoremap <C-L> <C-W><C-L> +nnoremap <C-H> <C-W><C-H> + +" }}} + +" set the status line +" {{{ +set statusline=%f " Path to the file +set statusline+=%= " Switch to the right side +set statusline+=%l " Current line +set statusline+=/ " Separator +set statusline+=%L " Total lines +set statusline+=, " comma +set statusline+=%c " Column +set statusline+=\ (%P) " Percentage +" }}} + +" terminal width / colorcolumn +" {{{ +" http://richarddingwall.name/2008/05/31/is-the-80-character-line-limit-still-relevant/ +" +" set tw=80 +" set tw=72 +" set tw=78 (for instance vims :help) +set tw=0 +set colorcolumn=73 +" }}} + +" wrapping +" {{{ +"set wrap +"set showbreak=>_ +" }}} + +" tabs +" {{{ +set listchars=tab:>. +set tabstop=8 +set shiftwidth=4 +set softtabstop=4 +set shiftround +" }}} + +" folding +" {{{ +set foldcolumn=5 +set foldlevelstart=0 +" }}} + +" colorscheme / syntax highlight +" {{{ +"colorscheme olgas +colorscheme desert +syntax enable +syntax sync fromstart +" }}} + +" minimize gui +" {{{ +" set guioptions= +set guioptions-=m +set guioptions-=T +set guioptions-=r +set guioptions-=L +set guifont=Monospace\ 9 +" }}} + +" searching +" {{{ +set hlsearch +set incsearch +" }}} + +" bracket matching and matchtime in ms. +" {{{ +set showmatch +set matchtime=5 +" }}} + +" }}} + +" Mappings / Custom Global Keybindings +" {{{ + +" first of all: temporary mappings, to get rid of some bad habits. +"inoremap <esc> <nop> +"inoremap <Up> <nop> +"inoremap <Down> <nop> +"inoremap <Left> <nop> +"inoremap <Right> <nop> + +" alternative to esc in insert mode! +inoremap jk <esc> + +" display help in new tab on <F1> +map <F1> :tab help<CR> + +map <F5> :silent make \| copen \| redraw!<CR> +map <F5> :silent make \| redraw!<CR> + +" retab +map <leader>rt :retab!<CR> + +" toggle tabs visibility +noremap <Leader>t :set invlist<CR> + +" nnoremap <C-]> <C-]>:tselect<CR> + +" easy editing and sourcing of vimrc +nnoremap <leader>sv :source $MYVIMRC<cr> +nnoremap <leader>ev :e $MYVIMRC<cr> + +" turn off search highlight +nnoremap <leader>h :nohlsearch<cr> + +" toggle visibility of trailing whitespaces +nnoremap <leader>w :match Error /\v +$/<cr> +nnoremap <leader>W :match<cr> + +" toggle and navigate quickfix window +nnoremap <leader>cn :cnext<cr> +nnoremap <leader>cp :cprevious<cr> +nnoremap <leader>cc :cc<cr> + +" grep operator +" nnoremap <leader>g :silent execute "grep! -R " . shellescape(expand("<cWORD>")) . " ."<cr>:copen<cr> +nnoremap <leader>g :set operatorfunc=<SID>GrepOperator<cr>g@ +vnoremap <leader>g :<c-u>call <SID>GrepOperator(visualmode())<cr> + +" buffer navigaion +nnoremap <leader>bn :MBEbn<cr> +nnoremap <leader>bp :MBEbp<cr> +nnoremap <leader>bd :MBEbd<cr> + +" activate 'very magic' for searches automatically +nnoremap / /\v +nnoremap ? ?\v + +" make +nnoremap <leader>mm :silent make!<cr> +nnoremap <leader>mc :silent make! clean<cr> +nnoremap <leader>mn :silent make! new<cr> +nnoremap <leader>mr :silent make!<cr>:call system("make run &")<cr> +nnoremap <leader>md :silent make!<cr>:call system("make debug &")<cr> +nnoremap <leader>ms :silent make! stop<cr> + +nnoremap <leader>mf :silent make! %:r<cr>:redraw! <cr> +nnoremap <leader>mx :silent make! %:r <bar> !./%:r<cr> + +" run my new 'ColorTune' plugin +" nnoremap <leader>cc :call Colortune_fill()<cr> + +" session handling +nnoremap <leader>ss :call Session_save()<cr> +nnoremap <leader>sl :call Session_load()<cr> + +" }}} + +" layout +nnoremap <leader>ln :NERDTreeToggle<cr> +nnoremap <leader>lt :TagbarToggle<cr> +nnoremap <leader>lg :ConqueGdb<cr> +nnoremap <leader>lm :MBEToggle<cr> +nnoremap <leader>lq :copen<cr> + +" File Type Specific Settings +" {{{ + +" Enforce custom syntax hl for some file extensions +" {{{ +augroup filetype_custom + autocmd! + au BufRead,BufNewFile *.twig set filetype=htmljinja + au BufRead,BufNewFile *.md set filetype=markdown +augroup END + + + +" }}} + +" Set foldmethod=marker for vim files +" {{{ +augroup filetype_vim + autocmd! + autocmd FileType vim setlocal foldmethod=marker +augroup END +" }}} + +" Custom settings for markdown files +" {{{ +augroup filetype_markdown + autocmd! +" autocmd FileType markdown setlocal spell + " autocmd FileType markdown setlocal list +augroup END +" }}} + +" Simple shortcuts for cpp files +" {{{ +augroup filetype_cpp + autocmd! + autocmd FileType cpp nnoremap <buffer> <localleader>c I//<esc> + autocmd FileType cpp :iabbrev <buffer> iff if () <cr>{<cr>}jkF + autocmd FileType cpp nnoremap <buffer> <leader>bo :r ~/_int/dev/misc/c++/template/template.cpp<cr> +augroup END + +" }}} + +" Haskell specifics +" {{{ +augroup filetype_haskell + autocmd! + autocmd FileType haskell setlocal foldmethod=marker +" autocmd Filetype haskell map <F5> :w<ENTER>:term cabal -- exec runghc %<ENTER> + autocmd Filetype haskell map <F5> :w<ENTER>:term make<ENTER> + autocmd FileType haskell setlocal expandtab +augroup END +" }}} + +" }}} + +" Session Handling (that sucks) +" {{{ +" we always want MBE, NERDTree and Tagbar +" +let g:miniBufExplBRSplit = 0 " Put new window above + +function! Session_save() + + NERDTreeClose + TagbarClose + MBECloseAll + mksession! .lastvimsession + NERDTree + Tagbar + MBEOpen + +endfunction + +function! Session_load() + + NERDTreeClose + TagbarClose + MBECloseAll +" source ~/.lastvimsession + NERDTree + Tagbar + MBEOpen + call feedkeys("\<c-w>\<c-w>") + + +endfunction + +if filereadable(".lastvimsession") +" +" augroup my_vim_leave +" autocmd! +" autocmd VimLeave * NERDTreeClose +" autocmd VimLeave * TagbarClose +" autocmd VimLeave * MBECloseAll +" autocmd VimLeave * mksession! .lastvimsession +" augroup END +" +" augroup my_vim_enter +" autocmd! +" autocmd VimEnter * source .lastvimsession +" autocmd VimEnter * NERDTree +" autocmd VimEnter * MBEOpen +" autocmd VimEnter * Tagbar +" augroup END +" +endif + +" }}} + +" Custom Functions +" {{{ + + +" GrepOperator(type) +" {{{ +function! s:GrepOperator(type) + + let saved_unnamed_register = @@ + + if a:type ==# 'v' + normal! `<v`>y + + elseif a:type ==# 'char' + normal! `[v`]y + + else + echom "not supported" + return + + endif + + silent execute "grep! -R " . shellescape(@@) . " ." + copen + + let @@ = saved_unnamed_register + +endfunction +" }}} + +" }}} + +" Experimental (Disabled) +" {{{ + +""""""""""""""""""""""""""""""""""""""""""""""""""""" +" experimental stuff added during the course of: " +" learnvimscriptthehardway.stevelosh.com " +""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" move line under the cursor up and down. +" nnoremap <leader>- ddp +" nnoremap <leader>_ kddpk + +" make word under curstor upper-case +" inoremap <leader><c-u> <esc>viwUea +" nnoremap <leader><c-u> viwUe + +" abbreviations and typo correction +" iabbrev @@ miguel@quad +" iabbrev ccopy Copyright 2014 M. Idziorek, all rights reserved. +" iabbrev teh the + +" topic handling for markdown files +" onoremap ih :<c-u>execute "normal! ?^==\\+$\r:nohlsearch\rkvg_"<cr> +" onoremap ah :<c-u>execute "normal! ?^==\\+$\r:nohlsearch\rg_vk0"<cr> +" +" single and double quoting +" nnoremap <leader>" viw<esc>a"<esc>hbi"<esc>lel +" nnoremap <leader>' viw<esc>a"<esc>hbi"<esc>lel +" vnoremap <leader>" <esc>`<i"<esc>`>la"<esc>l + +" open previous buffer in new split-window +" nnoremap <leader>p :execute "leftabove vsplit ".bufname("#")<cr> + + +" }}} + +" Vim Status Line Color +" {{{ + +function! InsertStatuslineColor(mode) + if a:mode == 'i' + hi statusline guibg=Cyan ctermfg=6 guifg=Black ctermbg=0 + elseif a:mode == 'r' + hi statusline guibg=Purple ctermfg=5 guifg=Black ctermbg=0 + else + hi statusline guibg=DarkRed ctermfg=1 guifg=Black ctermbg=0 + endif +endfunction + +" }}} +" + +if has("nvim") + " Make escape work in the Neovim terminal. + tnoremap <Esc> <C-\><C-n> + + " Make navigation into and out of Neovim terminal splits nicer. + tnoremap <C-h> <C-\><C-N><C-w>h + tnoremap <C-j> <C-\><C-N><C-w>j + tnoremap <C-k> <C-\><C-N><C-w>k + tnoremap <C-l> <C-\><C-N><C-w>l + + " I like relative numbering when in normal mode. + autocmd TermOpen * setlocal conceallevel=0 colorcolumn=0 relativenumber + + " Prefer Neovim terminal insert mode to normal mode. + autocmd BufEnter term://* startinsert +endif |
