├── .github └── FUNDING.yml ├── extra └── vidir-ls.png ├── README.md └── syntax └── vidir-ls.vim /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: trapd00r 2 | -------------------------------------------------------------------------------- /extra/vidir-ls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trapd00r/vim-syntax-vidir-ls/HEAD/extra/vidir-ls.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | use LS\_COLORS in your [vidir](https://github.com/trapd00r/vidir) 2 | session inside vim. It can also be used in other places where you list 3 | filenames in your vim session, for example while editing a perl 4 | MANIFEST file. 5 | 6 | 7 | ![img](/extra/vidir-ls.png) 8 | 9 | Install to ``$VIMRUNTIME/syntax/vidir-ls.vim`` 10 | 11 | export VIDIR_EDITOR_ARGS='-c :set nolist | :set ft=vidir-ls' 12 | 13 | 14 | The colors are generated from the ``LS_COLORS`` environment variable 15 | automatically. Please see the [LS\_COLORS][1] repository for a set of good 16 | colors. 17 | 18 | [0]: https://github.com/trapd00r/vidir 19 | [1]: https://github.com/trapd00r/LS_COLORS 20 | -------------------------------------------------------------------------------- /syntax/vidir-ls.vim: -------------------------------------------------------------------------------- 1 | " What: ls colors for vidir file listings 2 | " Where: $VIMRUNTIME/syntax/vidir-ls.vim 3 | " Author: Magnus Woldrich 4 | " Update: 2012-07-01 22:07:28 5 | " URL: https://github.com/trapd00r/vim-syntax-vidir-ls 6 | " http://devel.japh.se/vim-syntax-vidir-ls/ 7 | " http://devel.japh.se/vidir 8 | " 9 | " This is supposed to be used with vidir [0]: 10 | " export VIDIR_EDITOR_ARGS='-c :set nolist | :set ft=vidir-ls' 11 | " 12 | " The colors are generated from the LS_COLORS environment variable 13 | " automatically. Please see the LS_COLORS repository [1] for a set of good 14 | " colors. 15 | " 16 | " [0]: https://github.com/trapd00r/vidir 17 | " [1]: https://github.com/trapd00r/LS_COLORS 18 | 19 | 20 | if exists('b:current_syntax') 21 | finish 22 | endif 23 | 24 | function! MakeStyle(ls_color_style) 25 | let l:style_settings = split(a:ls_color_style, ';') 26 | 27 | let l:style_string = '' 28 | 29 | while len(l:style_settings) >= 3 30 | let [l:where, l:flag, l:clr; l:style_settings] = l:style_settings 31 | 32 | if l:flag == 5 33 | if l:where == 38 34 | let l:style_string .= ' ctermfg='.l:clr 35 | \ .' guifg='.s:term2rgb[substitute(l:clr, '^0\+\ze\S', '', '')] 36 | elseif l:where == 48 37 | let l:style_string .= ' ctermbg='.l:clr 38 | \ .' guibg='.s:term2rgb[substitute(l:clr, '^0\+\ze\S', '', '')] 39 | endif 40 | endif 41 | endwhile 42 | 43 | if len(l:style_settings) == 1 44 | let l:style = l:style_settings[0] 45 | 46 | if l:style == '0' || l:style == '00' 47 | let l:style_string .= ' cterm=none' 48 | elseif l:style == '1' || l:style == '01' 49 | let l:style_string .= ' cterm=bold' 50 | elseif l:style == '4' || l:style == '04' 51 | let l:style_string .= ' cterm=underline' 52 | elseif l:style == '7' || l:style == '07' 53 | let l:style_string .= ' cterm=reverse' 54 | endif 55 | end 56 | 57 | return l:style_string 58 | endfunction 59 | 60 | function! MakeSyntax(ls_color) 61 | let [l:glob, l:colors] = split(a:ls_color, '=') 62 | 63 | if l:glob =~ '^\*\..*' 64 | let l:regex = '\v/\zs.+[.]' 65 | let l:ext = substitute(l:glob, '^\*[.]', '', '') 66 | let l:regex .= substitute(l:ext, '[.~]', '[&]', 'g') . '$' 67 | let l:ext = substitute(l:ext, '[.~]', '_', 'g') 68 | elseif l:glob == 'di' 69 | let l:ext = 'DI' 70 | let l:regex = '\v.+[/].+[/]$' 71 | else 72 | return 73 | endif 74 | 75 | execute 'silent! hi ls_' . l:ext . MakeStyle(l:colors) 76 | execute 'silent! syn match ls_' . l:ext . ' display "' . l:regex . '"' 77 | endfunction 78 | 79 | " Colors from http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html 80 | let s:term2rgb = { 81 | \ 0: "#000000", 82 | \ 1: "#800000", 83 | \ 2: "#008000", 84 | \ 3: "#808000", 85 | \ 4: "#000080", 86 | \ 5: "#800080", 87 | \ 6: "#008080", 88 | \ 7: "#c0c0c0", 89 | \ 8: "#808080", 90 | \ 9: "#ff0000", 91 | \ 10: "#00ff00", 92 | \ 11: "#ffff00", 93 | \ 12: "#0000ff", 94 | \ 13: "#ff00ff", 95 | \ 14: "#00ffff", 96 | \ 15: "#ffffff", 97 | \ 98 | \ 16: "#000000", 99 | \ 17: "#00005f", 100 | \ 18: "#000087", 101 | \ 19: "#0000af", 102 | \ 20: "#0000d7", 103 | \ 21: "#0000ff", 104 | \ 22: "#005f00", 105 | \ 23: "#005f5f", 106 | \ 24: "#005f87", 107 | \ 25: "#005faf", 108 | \ 26: "#005fd7", 109 | \ 27: "#005fff", 110 | \ 28: "#008700", 111 | \ 29: "#00875f", 112 | \ 30: "#008787", 113 | \ 31: "#0087af", 114 | \ 32: "#0087d7", 115 | \ 33: "#0087ff", 116 | \ 34: "#00af00", 117 | \ 35: "#00af5f", 118 | \ 36: "#00af87", 119 | \ 37: "#00afaf", 120 | \ 38: "#00afd7", 121 | \ 39: "#00afff", 122 | \ 40: "#00d700", 123 | \ 41: "#00d75f", 124 | \ 42: "#00d787", 125 | \ 43: "#00d7af", 126 | \ 44: "#00d7d7", 127 | \ 45: "#00d7ff", 128 | \ 46: "#00ff00", 129 | \ 47: "#00ff5f", 130 | \ 48: "#00ff87", 131 | \ 49: "#00ffaf", 132 | \ 50: "#00ffd7", 133 | \ 51: "#00ffff", 134 | \ 52: "#5f0000", 135 | \ 53: "#5f005f", 136 | \ 54: "#5f0087", 137 | \ 55: "#5f00af", 138 | \ 56: "#5f00d7", 139 | \ 57: "#5f00ff", 140 | \ 58: "#5f5f00", 141 | \ 59: "#5f5f5f", 142 | \ 60: "#5f5f87", 143 | \ 61: "#5f5faf", 144 | \ 62: "#5f5fd7", 145 | \ 63: "#5f5fff", 146 | \ 64: "#5f8700", 147 | \ 65: "#5f875f", 148 | \ 66: "#5f8787", 149 | \ 67: "#5f87af", 150 | \ 68: "#5f87d7", 151 | \ 69: "#5f87ff", 152 | \ 70: "#5faf00", 153 | \ 71: "#5faf5f", 154 | \ 72: "#5faf87", 155 | \ 73: "#5fafaf", 156 | \ 74: "#5fafd7", 157 | \ 75: "#5fafff", 158 | \ 76: "#5fd700", 159 | \ 77: "#5fd75f", 160 | \ 78: "#5fd787", 161 | \ 79: "#5fd7af", 162 | \ 80: "#5fd7d7", 163 | \ 81: "#5fd7ff", 164 | \ 82: "#5fff00", 165 | \ 83: "#5fff5f", 166 | \ 84: "#5fff87", 167 | \ 85: "#5fffaf", 168 | \ 86: "#5fffd7", 169 | \ 87: "#5fffff", 170 | \ 88: "#870000", 171 | \ 89: "#87005f", 172 | \ 90: "#870087", 173 | \ 91: "#8700af", 174 | \ 92: "#8700d7", 175 | \ 93: "#8700ff", 176 | \ 94: "#875f00", 177 | \ 95: "#875f5f", 178 | \ 96: "#875f87", 179 | \ 97: "#875faf", 180 | \ 98: "#875fd7", 181 | \ 99: "#875fff", 182 | \ 100: "#878700", 183 | \ 101: "#87875f", 184 | \ 102: "#878787", 185 | \ 103: "#8787af", 186 | \ 104: "#8787d7", 187 | \ 105: "#8787ff", 188 | \ 106: "#87af00", 189 | \ 107: "#87af5f", 190 | \ 108: "#87af87", 191 | \ 109: "#87afaf", 192 | \ 110: "#87afd7", 193 | \ 111: "#87afff", 194 | \ 112: "#87d700", 195 | \ 113: "#87d75f", 196 | \ 114: "#87d787", 197 | \ 115: "#87d7af", 198 | \ 116: "#87d7d7", 199 | \ 117: "#87d7ff", 200 | \ 118: "#87ff00", 201 | \ 119: "#87ff5f", 202 | \ 120: "#87ff87", 203 | \ 121: "#87ffaf", 204 | \ 122: "#87ffd7", 205 | \ 123: "#87ffff", 206 | \ 124: "#af0000", 207 | \ 125: "#af005f", 208 | \ 126: "#af0087", 209 | \ 127: "#af00af", 210 | \ 128: "#af00d7", 211 | \ 129: "#af00ff", 212 | \ 130: "#af5f00", 213 | \ 131: "#af5f5f", 214 | \ 132: "#af5f87", 215 | \ 133: "#af5faf", 216 | \ 134: "#af5fd7", 217 | \ 135: "#af5fff", 218 | \ 136: "#af8700", 219 | \ 137: "#af875f", 220 | \ 138: "#af8787", 221 | \ 139: "#af87af", 222 | \ 140: "#af87d7", 223 | \ 141: "#af87ff", 224 | \ 142: "#afaf00", 225 | \ 143: "#afaf5f", 226 | \ 144: "#afaf87", 227 | \ 145: "#afafaf", 228 | \ 146: "#afafd7", 229 | \ 147: "#afafff", 230 | \ 148: "#afd700", 231 | \ 149: "#afd75f", 232 | \ 150: "#afd787", 233 | \ 151: "#afd7af", 234 | \ 152: "#afd7d7", 235 | \ 153: "#afd7ff", 236 | \ 154: "#afff00", 237 | \ 155: "#afff5f", 238 | \ 156: "#afff87", 239 | \ 157: "#afffaf", 240 | \ 158: "#afffd7", 241 | \ 159: "#afffff", 242 | \ 160: "#d70000", 243 | \ 161: "#d7005f", 244 | \ 162: "#d70087", 245 | \ 163: "#d700af", 246 | \ 164: "#d700d7", 247 | \ 165: "#d700ff", 248 | \ 166: "#d75f00", 249 | \ 167: "#d75f5f", 250 | \ 168: "#d75f87", 251 | \ 169: "#d75faf", 252 | \ 170: "#d75fd7", 253 | \ 171: "#d75fff", 254 | \ 172: "#d78700", 255 | \ 173: "#d7875f", 256 | \ 174: "#d78787", 257 | \ 175: "#d787af", 258 | \ 176: "#d787d7", 259 | \ 177: "#d787ff", 260 | \ 178: "#d7af00", 261 | \ 179: "#d7af5f", 262 | \ 180: "#d7af87", 263 | \ 181: "#d7afaf", 264 | \ 182: "#d7afd7", 265 | \ 183: "#d7afff", 266 | \ 184: "#d7d700", 267 | \ 185: "#d7d75f", 268 | \ 186: "#d7d787", 269 | \ 187: "#d7d7af", 270 | \ 188: "#d7d7d7", 271 | \ 189: "#d7d7ff", 272 | \ 190: "#d7ff00", 273 | \ 191: "#d7ff5f", 274 | \ 192: "#d7ff87", 275 | \ 193: "#d7ffaf", 276 | \ 194: "#d7ffd7", 277 | \ 195: "#d7ffff", 278 | \ 196: "#ff0000", 279 | \ 197: "#ff005f", 280 | \ 198: "#ff0087", 281 | \ 199: "#ff00af", 282 | \ 200: "#ff00d7", 283 | \ 201: "#ff00ff", 284 | \ 202: "#ff5f00", 285 | \ 203: "#ff5f5f", 286 | \ 204: "#ff5f87", 287 | \ 205: "#ff5faf", 288 | \ 206: "#ff5fd7", 289 | \ 207: "#ff5fff", 290 | \ 208: "#ff8700", 291 | \ 209: "#ff875f", 292 | \ 210: "#ff8787", 293 | \ 211: "#ff87af", 294 | \ 212: "#ff87d7", 295 | \ 213: "#ff87ff", 296 | \ 214: "#ffaf00", 297 | \ 215: "#ffaf5f", 298 | \ 216: "#ffaf87", 299 | \ 217: "#ffafaf", 300 | \ 218: "#ffafd7", 301 | \ 219: "#ffafff", 302 | \ 220: "#ffd700", 303 | \ 221: "#ffd75f", 304 | \ 222: "#ffd787", 305 | \ 223: "#ffd7af", 306 | \ 224: "#ffd7d7", 307 | \ 225: "#ffd7ff", 308 | \ 226: "#ffff00", 309 | \ 227: "#ffff5f", 310 | \ 228: "#ffff87", 311 | \ 229: "#ffffaf", 312 | \ 230: "#ffffd7", 313 | \ 231: "#ffffff", 314 | \ 315 | \ 232: "#080808", 316 | \ 233: "#121212", 317 | \ 234: "#1c1c1c", 318 | \ 235: "#262626", 319 | \ 236: "#303030", 320 | \ 237: "#3a3a3a", 321 | \ 238: "#444444", 322 | \ 239: "#4e4e4e", 323 | \ 240: "#585858", 324 | \ 241: "#606060", 325 | \ 242: "#666666", 326 | \ 243: "#767676", 327 | \ 244: "#808080", 328 | \ 245: "#8a8a8a", 329 | \ 246: "#949494", 330 | \ 247: "#9e9e9e", 331 | \ 248: "#a8a8a8", 332 | \ 249: "#b2b2b2", 333 | \ 250: "#bcbcbc", 334 | \ 251: "#c6c6c6", 335 | \ 252: "#d0d0d0", 336 | \ 253: "#dadada", 337 | \ 254: "#e4e4e4", 338 | \ 255: "#eeeeee", 339 | \} 340 | 341 | let s:ls_colors = split($LS_COLORS, ':') 342 | let s:ls_colors = map(s:ls_colors, 'MakeSyntax(v:val)') 343 | 344 | let b:current_syntax = 'vidir-ls' 345 | --------------------------------------------------------------------------------