├── .gitignore ├── README.md ├── doc └── markify.txt └── plugin └── markify.vim /.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VIM Markify 2 | 3 | A simple, lightweight plugin for marking lines using signs for entries in 4 | location list or quickfix lists. Location Lists are given preference over 5 | quickfix lists. 6 | 7 | ## Change Log 8 | 9 | ### Version 1.1.1 10 | * Fixed BalloonExpr (#1) 12 | 13 | ### Version 1.1 14 | * Added feature for echoing of message for line under cursor. (borrowed from 15 | Syntastic). This can be enabled / disabled using the 16 | `g:markify_echo_current_message` option. 17 | 18 | ### Version 1.0 19 | * Initial release, core functionality works. 20 | 21 | ## Getting Started 22 | ### Installation 23 | 24 | There are 2 ways to do this 25 | 26 | 1. I recommend installing pathogen.vim and then 28 | adding a git submodule for your plugin: 29 | 30 | ```sh 31 | $ cd ~/.vim 32 | $ git submodule add git@github.com:dhruvasagar/vim-markify.git bundle/markify 33 | ``` 34 | 35 | 2. Copy plugin/todo-mode.vim, doc/todo-mode.txt to respective ~/.vim/plugin 36 | and ~/.vim/doc under UNIX or vimfiles/plugin/ and vimfiles/doc under 37 | WINDOWS and restart VIM 38 | 39 | ### Usage 40 | When you have `g:markify_autocmd = 1` (default), then markify is run on 41 | `QuickFixCmdPost` event and marks the lines with signs automatically. 42 | 43 | Markify can distinguish between errors, warnings & info messages and 44 | uses different signs for each. By default it uses '>>' to display in the 45 | signcolumn, however this can be changed. 46 | 47 | If you don't wish to have markify work all the time, you can set 48 | `g:markify_autocmd = 0` in your $VIMRC. You can call `:Markify` to process 49 | the current location list or quickfix list ( location lists are given 50 | preference ) and add the signs. You can call `:MarkifyClear` to clear 51 | the signs set by Markify and you can also use `:MarkifyToggle` to toggle 52 | the same. 53 | 54 | Check `:h markify` for more details. 55 | 56 | ## Contributing 57 | 58 | ### Reporting an Issue : 59 | - Use Github 60 | Issue Tracker 61 | 62 | ### Contributing to code : 63 | - Fork it. 64 | - Commit your changes and give your commit message some love. 65 | - Push to your fork on github. 66 | - Open a Pull Request. 67 | 68 | ## Credits 69 | I would like to give a shout out to Scroolose for his awesome plugin Syntastic which gave me 71 | the inspiration and know-how to work with signs. 72 | 73 | I would also like to thank Tim Pope for sharing his configurations which 74 | inspired me to build this plugin. 75 | -------------------------------------------------------------------------------- /doc/markify.txt: -------------------------------------------------------------------------------- 1 | *markify* Mark lines in |quickfix| using signs. v1.1.1 2 | =============================================================================== 3 | Markify : Use Signs to Mark Errors / Warnings / Matches 4 | Version 1.1.1 5 | 6 | Author: Dhruva Sagar 7 | License: MIT License 8 | =============================================================================== 9 | CONTENTS *markify-contents* 10 | 11 | 1. Introduction ............|markify-intro| 12 | 2. Options .................|markify-options| 13 | 3. Mappings ................|markify-mappings| 14 | 4. Commands ................|markify-commands| 15 | 5. Contributing ............|markify-contributing| 16 | 17 | =============================================================================== 18 | INTRODUCTION *markify-intro* 19 | 20 | Markify is a simple, lightweight plugin that marks lines in buffers using 21 | signs to indicate quickfix or location list entries. This identifies and uses 22 | appropriate signs for errors, warnings or other informational messages. Works 23 | for :make, :lmake, :grep, :lgrep, :grepadd, :lgrepadd, :vimgrep, :lvimgrep, 24 | :vimgrepadd, :lvimgrepadd, :cscope, :helpgrep, :lhelpgrep 25 | 26 | =============================================================================== 27 | OPTIONS *markify-options* 28 | 29 | Overview : 30 | |markify-error-text| .............. Define text for error sign 31 | |markify-error-texthl| ............ Define texthl for error sign 32 | |markify-error-pattern| ........... Define pattern identifying an error 33 | |markify-warning-text| ............ Define text for error sign 34 | |markify-warning-texthl| .......... Define texthl for error sign 35 | |markify-warning-pattern| ......... Define pattern identifying a warning 36 | |markify-info-text| ............... Define text for error sign 37 | |markify-info-texthl| ............. Define texthl for error sign 38 | |markify-autocmd| ................. Flag for enabling autocmd 39 | |markify-map| ..................... Define mapping for |Markify| 40 | |markify-clear-map| ............... Define mapping for |MarkifyClear| 41 | |markify-toggle-map| .............. Define mapping for |MarkifyToggle| 42 | |markify-echo-current-message| .... Enable echoing of message 43 | 44 | g:markify_error_text *markify-error-text* 45 | Use this to define the text to use for error signs. > 46 | let g:markify_error_text = '>>' 47 | < 48 | 49 | g:markify_error_texthl *markify-error-texthl* 50 | Use this to define the texthl to use for error signs. > 51 | let g:markify_error_texthl = 'Error' 52 | < 53 | 54 | g:markify_error_pattern *markify-error-pattern* 55 | Use this to define a pattern that identifies text as an error text. 56 | let g:markify_error_pattern = '^ *error:' 57 | < 58 | 59 | g:markify_warning_text *markify-warning-text* 60 | Use this to define the this to define the text to use for warning 61 | signs. > 62 | let g:markify_warning_text = 'Todo' 63 | < 64 | 65 | g:markify_warning_texthl *markify-warning-texthl* 66 | Use this to define the texthl to use for error signs. > 67 | let g:markify_warning_texthl = 'Error' 68 | < 69 | 70 | g:markify_warning_pattern *markify-warning-pattern* 71 | Use this to define a pattern that identifies text as a warning text. 72 | let g:markify_warning_pattern = '^ *warning:' 73 | < 74 | 75 | g:markify_info_text *markify-info-text* 76 | Use this to define the this to define the text to use for warning 77 | signs. > 78 | let g:markify_info_text = '>>' 79 | < 80 | 81 | g:markify_info_texthl *markify-info-texthl* 82 | Use this to define the texthl to use for error signs. > 83 | let g:markify_info_texthl = 'Normal' 84 | < 85 | 86 | g:markify_autocmd *markify-autocmd* 87 | Use this to enable or disable the autocommand for markify. > 88 | let g:markify_autocmd = 1 89 | < 90 | NOTE if you set |markify-autocmd| to 0, then you will have to 91 | manually call |Markify| or |MarkifyToggle| to see the signs indicating 92 | the lists. 93 | 94 | g:markify_map *markify-map* 95 | Use this to define mapping to invoke |Markify|. > 96 | let g:markify_map = 'mm' 97 | < 98 | 99 | g:markify_clear_map *markify-clear-map* 100 | Use this to define the mapping to invoke |MarkifyClear|. > 101 | let g:markify_clear_map = 'mc' 102 | < 103 | 104 | g:markify_toggle_map *markify-toggle-map* 105 | Use this to define the mapping to invoke |MarkifyToggle|. > 106 | let g:markify_toggle_map = 'M' 107 | < 108 | 109 | g:markify_echo_current_message *markify-echo-current-message* 110 | Use this to enable / disable echoing of message for current line. > 111 | let g:markify_echo_current_message = 1 112 | < 113 | 114 | =============================================================================== 115 | MAPPINGS *markify-mappings* 116 | 117 | *markify-mm* 118 | mm Invoke |Markify|. 119 | 120 | *markify-mc* 121 | mc Invoke |MarkifyClear|. 122 | 123 | *markify-M* 124 | M Invoke |MarkifyToggle|. 125 | 126 | =============================================================================== 127 | COMMANDS *markify-commands* 128 | 129 | *:Markify* 130 | *markify-:Markify* 131 | :Markify 132 | Process the current location list or quickfix list (location lists 133 | have precedence over quickfix lists) and mark the corresponding lines 134 | in the corresponding buffers with appropriate signs for errors, 135 | warnings or info. 136 | 137 | *:MarkifyClear* 138 | *markify-:MarkifyClear* 139 | :MarkifyClear 140 | Clear the signs set by |Markify|. 141 | 142 | *:MarkifyToggle* 143 | *markify-:MarkifyToggle* 144 | :MarkifyToggle 145 | Toggle between |Markify| and |MarkifyClear| alternatively. 146 | 147 | =============================================================================== 148 | CONTRIBUTING *markify-contributing* 149 | 150 | 1. Reporting Bugs: 151 | Use Github Issue Tracker 152 | (https://github.com/dhruvasagar/vim-markify/issues) for filing bugs. 153 | 154 | 2. Contributing to Code 155 | If you want to take a stab at it, by all means, send me a pull request 156 | on Github (https://github.com/dhruvasagar/vim-markify) or get in touch 157 | with me directly via e-mail at dhruva [dot] sagar [at] gmail.com. 158 | 159 | =============================================================================== 160 | 161 | vim:tw=78 ts=8 ft=help norl 162 | -------------------------------------------------------------------------------- /plugin/markify.vim: -------------------------------------------------------------------------------- 1 | " Header Section {{{1 2 | " ============================================================================= 3 | " File: plugin/markify.vim 4 | " Description: Use sign to mark & indicate lines matched by quickfix 5 | " commands. Works for :make, :lmake, :grep, :lgrep, :grepadd, 6 | " :lgrepadd, :vimgrep, :lvimgrep, :vimgrepadd, :lvimgrepadd, 7 | " :cscope, :helpgrep, :lhelpgrep 8 | " Author: Dhruva Sagar 9 | " License: Vim License 10 | " Website: http://github.com/dhruvasagar/vim-markify 11 | " Version: 1.1.1 12 | " 13 | " Copyright Notice: 14 | " Permission is hereby granted to use and distribute this code, 15 | " with or without modifications, provided that this copyright 16 | " notice is copied with it. Like anything else that's free, 17 | " marify.vim is provided *as is* and comes with no warranty of 18 | " any kind, either expressed or implied. In no event will the 19 | " copyright holder be liable for any damamges resulting from 20 | " the use of this software. 21 | " ============================================================================= 22 | " }}}1 23 | 24 | if exists('g:markify_loaded') "{{{1 25 | finish 26 | endif 27 | let g:markify_loaded = 1 28 | " }}}1 29 | 30 | if !has('signs') "{{{1 31 | echoerr 'Compile VIM with signs to use this plugin.' 32 | finish 33 | endif 34 | " }}}1 35 | 36 | " Avoiding side effects {{{1 37 | let s:save_cpo = &cpo 38 | set cpo&vim 39 | " }}}1 40 | 41 | function! s:SetGlobalOptDefault(opt, val) "{{{1 42 | if !exists('g:' . a:opt) 43 | let g:{a:opt} = a:val 44 | endif 45 | endfunction 46 | " }}}1 47 | 48 | " Set Global Default Options {{{1 49 | call s:SetGlobalOptDefault('markify_error_text', '>>') 50 | call s:SetGlobalOptDefault('markify_error_texthl', 'Error') 51 | call s:SetGlobalOptDefault('markify_error_pattern', '^ *error:') 52 | call s:SetGlobalOptDefault('markify_warning_text', '>>') 53 | call s:SetGlobalOptDefault('markify_warning_texthl', 'Todo') 54 | call s:SetGlobalOptDefault('markify_warning_pattern', '^ *warning:') 55 | call s:SetGlobalOptDefault('markify_info_text', '>>') 56 | call s:SetGlobalOptDefault('markify_info_texthl', 'Normal') 57 | call s:SetGlobalOptDefault('markify_autocmd', 1) 58 | call s:SetGlobalOptDefault('markify_map', 'mm') 59 | call s:SetGlobalOptDefault('markify_clear_map', 'mc') 60 | call s:SetGlobalOptDefault('markify_toggle_map', 'M') 61 | call s:SetGlobalOptDefault('markify_echo_current_message', 1) 62 | " }}}1 63 | 64 | if g:markify_autocmd "{{{1 65 | augroup Markify " {{{2 66 | au! 67 | 68 | if g:markify_echo_current_message 69 | autocmd CursorMoved * call s:EchoCurrentMessage() 70 | endif 71 | 72 | autocmd QuickFixCmdPost * call s:MarkifyClear() | call s:Markify() 73 | augroup END 74 | " }}}2 75 | end 76 | " }}}1 77 | 78 | " Define Signs {{{1 79 | execute 'sign define MarkifyError text=' . g:markify_error_text . 80 | \ ' texthl=' . g:markify_error_texthl 81 | execute 'sign define MarkifyWarning text=' . g:markify_warning_text . 82 | \ ' texthl=' . g:markify_warning_texthl 83 | execute 'sign define MarkifyInfo text=' . g:markify_info_text . 84 | \ ' texthl=' . g:markify_info_texthl 85 | " }}}1 86 | 87 | function! MarkifyBalloonExpr() " {{{1 88 | for item in getqflist() 89 | if item.bufnr ==# v:beval_bufnr && item.lnum ==# v:beval_lnum 90 | return item.text 91 | endif 92 | endfor 93 | return '' 94 | endfunction 95 | " }}}1 96 | 97 | let g:markify_count = {'total': 0, 'error': 0, 'warn': 0, 'info': 0} 98 | function! s:PlaceSigns(items) " {{{1 99 | let l:markify_count = {} 100 | let l:markify_count.total = 0 101 | let l:markify_count.error = 0 102 | let l:markify_count.warn = 0 103 | let l:markify_count.info = 0 104 | 105 | for item in a:items 106 | if item.bufnr == 0 || item.lnum == 0 | continue | endif 107 | let id = item.bufnr . item.lnum 108 | if has_key(s:sign_ids, id) | continue | endif 109 | let s:sign_ids[id] = item 110 | 111 | let sign_name = '' 112 | if item.type ==? 'E' || item.text =~# g:markify_error_pattern 113 | let l:markify_count.total = l:markify_count.total + 1 114 | let l:markify_count.error = l:markify_count.error + 1 115 | let sign_name = 'MarkifyError' 116 | let sign_priority = 99 117 | elseif item.type ==? 'W' || item.text =~# g:markify_warning_pattern 118 | let l:markify_count.total = l:markify_count.total + 1 119 | let l:markify_count.warn = l:markify_count.warn + 1 120 | let sign_name = 'MarkifyWarning' 121 | let sign_priority = 98 122 | else 123 | let l:markify_count.total = l:markify_count.total + 1 124 | let l:markify_count.info = l:markify_count.info + 1 125 | let sign_name = 'MarkifyInfo' 126 | let sign_priority = 97 127 | endif 128 | 129 | execute 'sign place ' . id 130 | \ . ' priority=' . sign_priority 131 | \ . ' line=' . item.lnum 132 | \ . ' name=' . sign_name 133 | \ . ' buffer=' . item.bufnr 134 | endfor 135 | 136 | let g:markify_count.total = l:markify_count.total 137 | let g:markify_count.error = l:markify_count.error 138 | let g:markify_count.warn = l:markify_count.warn 139 | let g:markify_count.info = l:markify_count.info 140 | 141 | endfunction 142 | " }}}1 143 | 144 | " function! s:EchoMessage(message) - Taken from Syntastic {{{1 145 | function! s:EchoMessage(message) 146 | let [old_ruler, old_showcmd] = [&ruler, &showcmd] 147 | 148 | let message = substitute(a:message, "\t", repeat(' ', &tabstop), 'g') 149 | let message = strpart(message, 0, winwidth(0)-1) 150 | let message = substitute(message, "\n", '', 'g') 151 | 152 | set noruler noshowcmd 153 | redraw 154 | 155 | echo message 156 | 157 | let [&ruler, &showcmd] = [old_ruler, old_showcmd] 158 | endfunction 159 | " }}}1 160 | 161 | function! s:EchoCurrentMessage() "{{{1 162 | let id = bufnr('%') . line('.') 163 | if !has_key(s:sign_ids, id) | return | endif 164 | call s:EchoMessage(s:sign_ids[id].text) 165 | endfunction 166 | " }}}1 167 | 168 | " function! s:Markify() {{{1 169 | let [s:markified, s:sign_ids] = [0, {}] 170 | function! s:Markify() 171 | if s:markified | return | endif 172 | 173 | let [items, loclist, qflist] = [[], getloclist(0), getqflist()] 174 | if !empty(loclist) 175 | let items = loclist 176 | elseif !empty(qflist) 177 | let items = qflist 178 | endif 179 | 180 | if has('balloon_eval') 181 | let old_balloonexpr = &balloonexpr 182 | setl ballooneval balloonexpr=MarkifyBalloonExpr() 183 | endif 184 | 185 | call s:PlaceSigns(items) 186 | 187 | if has('balloon_eval') && exists(old_balloonexpr) 188 | let &balloonexpr = old_balloonexpr 189 | endif 190 | 191 | let s:markified = 1 192 | endfunction 193 | " }}}1 194 | 195 | function! s:MarkifyClear() " {{{1 196 | for sign_id in keys(s:sign_ids) 197 | exec 'sign unplace ' . sign_id 198 | call remove(s:sign_ids, sign_id) 199 | endfor 200 | let s:markified = 0 201 | endfunction 202 | " }}}1 203 | 204 | function! s:MarkifyToggle() "{{{1 205 | if s:markified | call s:MarkifyClear() | else | call s:Markify() | endif 206 | endfunction 207 | " }}}1 208 | 209 | " Commands & Mappings {{{1 210 | command! -nargs=0 Markify call s:Markify() 211 | command! -nargs=0 MarkifyClear call s:MarkifyClear() 212 | command! -nargs=0 MarkifyToggle call s:MarkifyToggle() 213 | 214 | execute "nnoremap " . g:markify_map . " :Markify" 215 | execute "nnoremap " . g:markify_clear_map . " :MarkifyClear" 216 | execute "nnoremap " . g:markify_toggle_map . " :MarkifyToggle" 217 | " }}}1 218 | 219 | " Avoid side effects {{{1 220 | let &cpo = s:save_cpo 221 | unlet s:save_cpo 222 | " }}}1 223 | 224 | " ModeLine {{{ 225 | " vim:fdl=0 fdm=marker 226 | --------------------------------------------------------------------------------