diff options
| author | David Kaufmann <astra@ionic.at> | 2018-09-10 14:45:16 +0200 |
|---|---|---|
| committer | David Kaufmann <astra@ionic.at> | 2018-09-10 14:45:16 +0200 |
| commit | 709ed9b8cf11dbf28672f81d63b77729368fe4d4 (patch) | |
| tree | 99e10155f55c7ef7931c5e1723742c027d12b852 | |
| parent | 31ad097cd020519b2c8f4b82f98657f478cef1fb (diff) | |
| download | config-709ed9b8cf11dbf28672f81d63b77729368fe4d4.tar.gz | |
update vim todo plugin
| -rw-r--r-- | home/.vim/ftdetect/filetype.vim | 3 | ||||
| -rw-r--r-- | home/.vim/sample/sample.txt | 31 | ||||
| -rwxr-xr-x | home/.vim/scripts.vim | 4 | ||||
| -rw-r--r-- | home/.vim/syntax/todo.vim | 126 | ||||
| -rwxr-xr-x | home/.vim/todo/sample.todo | 23 | ||||
| -rwxr-xr-x | home/.vim/todo/sample.txt | 8 |
6 files changed, 96 insertions, 99 deletions
diff --git a/home/.vim/ftdetect/filetype.vim b/home/.vim/ftdetect/filetype.vim new file mode 100644 index 0000000..0171463 --- /dev/null +++ b/home/.vim/ftdetect/filetype.vim @@ -0,0 +1,3 @@ +augroup filetypedetect + au BufRead,BufNewFile *.todo,*_todo.txt setfiletype todo +augroup END diff --git a/home/.vim/sample/sample.txt b/home/.vim/sample/sample.txt new file mode 100644 index 0000000..48f5891 --- /dev/null +++ b/home/.vim/sample/sample.txt @@ -0,0 +1,31 @@ +#todo + +Any text file whose name ends with '.todo' or with '_todo.txt, +or whose first 100 lines contains '#todo' is a 'todo' file. + +A Header starts in column 1 with an upper-case letter and ends with a colon: + + A sub-header is any indented header line: + + + This is a high pri item, indicated by a '+' at the start. + o This is a medium priority item, indicated by 'o'. + - Low pri items start with a '-'. + + + A completed item:done + D Another way to mark an item completed is to replace the + prefix character (+/o/-) with D. + d A partially completed item has the prefix character 'd'. + + o An ignored item:ignore + x Another way to ignore an item is to use the 'x' prefix + character. + + ? An item that is in question, needs more info, etc. + + o Entries can also contain dates like so: + <2007/12/11> + <2007-12-11> + <12/31> + <8/1> + + o Comments can be embedded [this is a comment] inside an item. diff --git a/home/.vim/scripts.vim b/home/.vim/scripts.vim index 5dea2ec..db16273 100755 --- a/home/.vim/scripts.vim +++ b/home/.vim/scripts.vim @@ -1,3 +1,3 @@ -if getline(1) =~? '^#\?TODO\>' - setfiletype todo +if join(getline(1,100),' ') =~? '\<#\?TODO\>' + setfiletype todo endif diff --git a/home/.vim/syntax/todo.vim b/home/.vim/syntax/todo.vim index 1fd11bd..f244c32 100644 --- a/home/.vim/syntax/todo.vim +++ b/home/.vim/syntax/todo.vim @@ -1,86 +1,80 @@ -" Vim script to set syntax highlighting for a todo list. - -" A todo list is recognized by file names of the form *.todo, -" OR files that contain #todo as the first line of a file, -" OR files with modelines that contain ft=todo - -" Header lines - Lines starting at column 0. -" Normal priority items - Non-header lines that start with a 'o'. -" High priority items - .... with a '+'. -" Low priority items - .... with a '-'. -" Items completed - ... with a 'd' or 'D'. -" Items ignored - ... with a 'x' or 'X'. -" Dates - Digits (and / and -) enclosed by < and >. -" Comments - Stuff enclosed in '[' and ']' or any line -" that is none of the above. - -" See the file test.todo for sample entries. - -" Author: Suresh S. -" Version: 0.2 - - if exists("b:current_syntax") finish endif -syn case ignore +" Vim script to set syntax highlighting for a todo list. +" See README.txt and sample.txt for description and examples. +" Version: 0.4 +" +" Author: Suresh S. -" Dates can also be embedded. -" N/N/N or N-N-N or N/N or N-N. -syn match todoDate "<\(\(\d\{1,4\}[-/]\)\?\d\{1,2\}[-/]\d\{1,4\}\)>" contained +syn match todoDate "<\?\d\{1,4}\([-/:]\d\{1,4\}\)\{1,3\}>\?" -" Comments embedded in todo items. -syn region todoComment start="\["hs=s+1 end="\]"he=e-1 contained contains=todoDate +" Comments embedded in todo items, inside []. +syn region todoComment start="\[" end="\]" contained " Header lines to start sections. -syn match todoHeader1 "^\(\(\<[odxi\?]\s\)\@<!.\)*:$" contains=todoDate -syn match todoHeader2 "^\s\s*\(\([odxi\?]\s\)\@<!.\)*:$" contains=todoDate +syn match todoHeader1 "^\([0-9].*\s\s*\)\?[A-Z].*:$" contains=todoDate +syn match todoHeader2 "^\_\s\+\zs\([0-9].*\s\s*\)\?[A-Z].*:$" contains=todoDate + +syn case ignore " Normal priority items. -syn region todoNormalPri start="\(^\s*\)\@<=o\s" end="\(^\s*[o\-+?dxi]\s\|\n\n\+\)"he=s-1,me=s-1 contains=CONTAINED keepend +syn region todoNormalPri start="\(^\s*\)\@<=o\s" end="\(^\s*[o\-+?dxiDXI]\s\|\n\n\+\)"he=s-1,me=s-1 contains=todoDate,todoComment keepend " High priority items. -syn region todoHiPri start="\(^\s*\)\@<=+\s" end="\(^\s*[o\-+?dxi]\s\|\n\n\+\)"he=s-1,me=s-1 contains=CONTAINED keepend -" Low pri -syn region todoLowPri start="\(^\s*\)\@<=-\s" end="\(^\s*[o\-+?dxi]\s\|\n\n\+\)"he=s-1,me=s-1 contains=CONTAINED keepend +syn region todoHiPri start="\(^\s*\)\@<=+\s" end="\(^\s*[o\-+?dxiDXI]\s\|\n\n\+\)"he=s-1,me=s-1 contains=todoDate,todoComment keepend +" Low priority items. +syn region todoLowPri start="\(^\s*\)\@<=-\s" end="\(^\s*[o\-+?dxiDXI]\s\|\n\n\+\)"he=s-1,me=s-1 contains=todoDate,todoComment keepend " Unprioritized items. -syn region todoQuestion start="\(^\s*\)\@<=?\s" end="\(^\s*[o\-+?dxi]\s\|\n\n\+\)"he=s-1,me=s-1 contains=CONTAINED keepend +syn region todoNoPri start="\(^\s*\)\@<=\*\s" end="\(^\s*[o\-+?dxiDXI]\s\|\n\n\+\)"he=s-1,me=s-1 contains=todoDate,todoComment keepend +" Questions. +syn match todoQuestion "\(^\s*\)\@<=?\s" contains=todoComment +syn case match + " Items completed. -syn region todoDone start="\(^\s*\)\@<=d\s" end="\(^\s*[o\-+?dxi]\s\|\n\n\+\)"he=s-1,me=s-1 contains=CONTAINED keepend +syn region todoHalfDone start="\(^\s*\)\@<=d\s" end="\(^\s*[o\-+?dxiDXI]\s\|\n\n\+\)"he=s-1,me=s-1 contains=todoDate,todoComment keepend +syn region todoDone start="\(^\s*\)\@<=D\s" end="\(^\s*[o\-+?dxiDXI]\s\|\n\n\+\)"he=s-1,me=s-1 contains=todoDate,todoComment keepend + +syn case ignore " Items ignored/won't do. -syn region todoIgnore start="\(^\s*\)\@<=[xi]\s" end="\(^\s*[o\-+?dxi]\s\|\n\n\+\)"he=s-1,me=s-1 contains=CONTAINED keepend +syn region todoIgnore start="\(^\s*\)\@<=[xiXI]\s" end="\(^\s*[o\-+?dxiDXI]\s\|\n\n\+\)"he=s-1,me=s-1 contains=todoDate,todoComment keepend -" Fix this to handle multi-line items. -syn match todoIgnore "\(^\s*\)\@<=[o+\-?].*:ignore$" contains=CONTAINED -syn match todoDone "\(^\s*\)\@<=[o+\-?].*:done$" contains=CONTAINED +" TODO: Fix this to handle multi-line items. +syn match todoIgnore "\(^\s*\)\@<=[o+\-?].*:\(ignore\|ign\)$" contains=todoDate,todoComment +syn match todoDone "\(^\s*\)\@<=[o+\-?].*:\(done\|don\)$" contains=todoDate,todoComment +syn match todoHalfDone "\(^\s*\)\@<=[o+\-?].*:\(incomplete\|inc\)$" contains=todoDate,todoComment syn case match -"-------------------------------------------------------------------------- +"-------------------------------------------------------------------- " Colors and effects. -"-------------------------------------------------------------------------- - -hi todoHeader1 cterm=bold - -" Uncomment the following line if sub-headers should appear in bold: -" hi todoHeader2 gui=bold - -hi link todoQuestion Todo -hi todoHiPri ctermfg=Red -hi todoNormalPri ctermfg=Yellow -hi todoDone ctermfg=Green -hi todoComment cterm=Italic - -if &background == "dark" - hi todoLowPri ctermfg=LightCyan - hi todoIgnore ctermfg=Gray - hi todoDate ctermfg=LightCyan cterm=bold -else - hi todoLowPri ctermfg=Blue - hi todoIgnore ctermfg=Gray - hi todoDate ctermfg=Blue cterm=bold -endif - +"-------------------------------------------------------------------- +function! SetToDoColors() + hi todoHeader1 gui=bold,underline + hi todoHeader2 gui=undercurl + if &background == "dark" + hi def todoHiPri guifg=Red + hi def todoNormalPri guifg=Orange gui=bold + hi def todoLowPri guifg=Yellow + hi def todoDate guifg=LightCyan gui=bold + hi def todoDone guifg=Green + hi def todoHalfDone guifg=LightGreen + hi def todoComment gui=italic + hi def todoIgnore guifg=Gray80 + else + hi def todoHiPri guifg=Red gui=bold + hi def todoNormalPri guifg=DarkOrange gui=bold + hi def todoLowPri guifg=Brown gui=bold + hi def todoDate guifg=Blue gui=bold + hi def todoDone guifg=Green gui=bold + hi def todoHalfDone guifg=LightGreen gui=bold + hi def todoComment gui=italic + hi def todoIgnore guifg=Gray40 gui=bold + endif + hi link todoQuestion TODO +endfunction +augroup TodoHLGroup + autocmd! ColorScheme * call SetToDoColors() +augroup END +call SetToDoColors() let b:current_syntax = "todo" - -" vim: ts=18 diff --git a/home/.vim/todo/sample.todo b/home/.vim/todo/sample.todo deleted file mode 100755 index 5b2c38a..0000000 --- a/home/.vim/todo/sample.todo +++ /dev/null @@ -1,23 +0,0 @@ - -A Header line ends with a colon: - - A sub-header is like a header, but is indented: - -+ This is a high pri item, indicated by a '+' at the start. -o This is a medium priority item, indicated by 'o'. -- Low pri items start with a '-'. - -+ A high pri completed item is suffixed by ':done', like so:done -d Changing the prefix to 'd' does the same, if we don't care about preserving the priority info. -o An item that ends with ':ignore' is an ignored item :ignore -x Another way to say the same thing. - -? An item that is in question, needs more info, etc. - -o Entries can also contain a date like so: <2007/12/11>, -or even multiple dates: do this by <2007-12-11>, or at the latest b<12/31>. - o Or so: <8/1> - - o Comments can be embedded [this is a comment] inside an item. - [Comments can also contain a date <99/99/99>]. - diff --git a/home/.vim/todo/sample.txt b/home/.vim/todo/sample.txt deleted file mode 100755 index cbd41cf..0000000 --- a/home/.vim/todo/sample.txt +++ /dev/null @@ -1,8 +0,0 @@ -#todo - -Any file whose first line starts with #todo is a 'todo' file: - -o This is a normal todo. -D This is done -X Ignored -? Question. |
