about summary refs log tree commit diff stats
path: root/vimrc.vim
blob: 0200e01c54e61f623ff7885d9d9dd865620cec56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
" Highlighting literate directives in C++ sources.
function! HighlightTangledFile()
  " Tangled comments only make sense in the sources and are stripped out of
  " the generated .cc file. They're highlighted same as regular comments.
  syntax match tangledComment /\/\/:.*/ | highlight link tangledComment Comment
  syntax match tangledSalientComment /\/\/::.*/ | highlight link tangledSalientComment SalientComment
  set comments-=://
  set comments-=n://
  set comments+=n://:,n://

  " Inside tangle scenarios.
  syntax region tangleDirective start=+:(+ skip=+".*"+ end=+)+
  highlight link tangleDirective Delimiter
  syntax match traceContains /^+.*/
  highlight traceContains ctermfg=22
  syntax match traceAbsent /^-.*/
  highlight traceAbsent ctermfg=darkred
  syntax match tangleScenarioSetup /^\s*% .*/ | highlight link tangleScenarioSetup SpecialChar
  highlight Special ctermfg=160

  syntax match subxString %"[^"]*"% | highlight link subxString Constant
  " match globals but not registers like 'EAX'
  syntax match subxGlobal %\<[A-Z][a-z0-9_-]*\>% | highlight link subxGlobal SpecialChar
endfunction
augroup LocalVimrc
  autocmd BufRead,BufNewFile *.cc call HighlightTangledFile()
  autocmd BufRead,BufNewFile *.subx set ft=subx
augroup END

" Scenarios considered:
"   opening or starting vim with a new or existing file without an extension (should interpret as C++)
"   opening or starting vim with a new or existing file with a .mu extension
"   starting vim or opening a buffer without a file name (ok to do nothing)
"   opening a second file in a new or existing window (shouldn't mess up existing highlighting)
"   reloading an existing file (shouldn't mess up existing highlighting)

command! -nargs=1 E call EditSubx("edit", <f-args>)
if exists("&splitvertical")
  command! -nargs=1 S call EditSubx("vert split", <f-args>)
  command! -nargs=1 H call EditSubx("hor split", <f-args>)
else
  command! -nargs=1 S call EditSubx("vert split", <f-args>)
  command! -nargs=1 H call EditSubx("split", <f-args>)
endif

function! EditSubx(cmd, arg)
  exec "silent! " . a:cmd . " " . SubxPath(a:arg)
endfunction

function! SubxPath(arg)
  if a:arg =~ "^ex"
    return "examples/" . a:arg . ".subx"
  else
    return "apps/" . a:arg . ".subx"
  endif
endfunction

" we often want to crib lines of machine code from other files
function! GrepSubX(regex)
  " https://github.com/mtth/scratch.vim
  Scratch!
  silent exec "r !grep -h '".a:regex."' *.subx */*.subx"
endfunction
command! -nargs=1 G call GrepSubX(<q-args>)

if exists("&splitvertical")
  command! -nargs=0 P hor split opcodes
else
  command! -nargs=0 P split opcodes
endif

" useful for inspecting just the control flow in a trace
" see https://github.com/akkartik/mu/blob/master/Readme.md#a-few-hints-for-debugging
command! -nargs=0 L exec "%!grep label |grep -v clear-stream:loop"

" run test around cursor
if empty($TMUX)
  " hack: need to move cursor outside function at start (`{`), but inside function at end (`<C-o>`)
  " this solution is unfortunate, but seems forced:
  "   can't put initial cursor movement inside function because we rely on <C-r><C-w> to grab word at cursor
  "   can't put final cursor movement out of function because that disables the wait for <CR> prompt; function must be final operation of map
  "   can't avoid the function because that disables the wait for <CR> prompt
  noremap <Leader>t {:keeppatterns /^[^ #]<CR>:call RunTestMoveCursor("<C-r><C-w>")<CR>
  function RunTestMoveCursor(arg)
    exec "!./run_one_test ".expand("%")." '".a:arg."'"
    exec "normal \<C-o>"
  endfunction
else
  " we have tmux; we don't need to show any output in the Vim pane so life is simpler
  " assume the left-most window is for the shell
  noremap <Leader>t {:keeppatterns /^[^ #]<CR>:silent! call RunTestInFirstPane("<C-r><C-w>")<CR><C-o>
  function RunTestInFirstPane(arg)
    call RunInFirstPane("./run_one_test ".expand("%")." ".a:arg)
  endfunction
  function RunInFirstPane(arg)
    exec "!tmux select-pane -t :0.0"
    exec "!tmux send-keys '".a:arg."' C-m"
    exec "!tmux last-pane"
    " for some reason my screen gets messed up, so force a redraw
    exec "!tmux send-keys 'C-l'"
  endfunction
endif

set switchbuf=useopen
if exists("&splitvertical")
  command! -nargs=0 T badd last_run | sbuffer last_run
else
  command! -nargs=0 T badd last_run | vert sbuffer last_run
endif
} /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
[colours]
bkgnd=blue
titlebar=white
titlebar.text=black
titlebar.brackets=black
titlebar.unencrypted=black
titlebar.encrypted=black
titlebar.untrusted=black
titlebar.trusted=black
titlebar.online=black
titlebar.offline=black
titlebar.away=black
titlebar.xa=black
titlebar.dnd=black
titlebar.chat=black
statusbar=white
statusbar.text=black
statusbar.brackets=black
statusbar.active=black
statusbar.new=black
main.text=bold_white
main.text.me=bold_white
main.text.them=bold_white
main.splash=bold_green
main.help.header=bold_white
main.time=bold_green
input.text=bold_white
subscribed=bold_green
unsubscribed=bold_red
otr.started.trusted=bold_green
otr.started.untrusted=bold_yellow
otr.ended=bold_red
otr.trusted=bold_green
otr.untrusted=bold_yellow
online=bold_green
away=bold_cyan
chat=bold_white
dnd=bold_red
xa=bold_cyan
offline=bold_blue
incoming=bold_yellow
mention=bold_green
trigger=bold_green
typing=bold_yellow
gone=bold_red
error=bold_red
roominfo=bold_yellow
roommention=bold_green
roommention.term=bold_green
roomtrigger=bold_green
roomtrigger.term=bold_green
me=bold_cyan
them=bold_magenta
roster.header=bold_magenta
roster.chat=white
roster.online=green
roster.away=cyan
roster.xa=cyan
roster.dnd=red
roster.offline=bold_blue
roster.chat.active=white
roster.online.active=green
roster.away.active=cyan
roster.xa.active=cyan
roster.dnd.active=red
roster.offline.active=bold_blue
roster.chat.unread=bold_white
roster.online.unread=bold_green
roster.away.unread=bold_cyan
roster.xa.unread=bold_cyan
roster.dnd.unread=bold_red
roster.offline.unread=bold_blue
roster.room=bold_red
roster.room.unread=bold_magenta
roster.room.mention=bold_magenta
roster.room.trigger=bold_magenta
occupants.header=bold_magenta
receipt.sent=bold_blue

[ui]
beep=false
flash=false
splash=true
wrap=true
time.console=%H:%M:%S
time.chat=%d/%m/%y %H:%M:%S
time.muc=%d/%m/%y %H:%M:%S
time.mucconfig=off
time.private=%d/%m/%y %H:%M:%S
time.xmlconsole=%H:%M:%S
time.statusbar=%H:%M:%S
time.lastactivity=%d/%m/%y %H:%M:%S
privileges=true
presence=true
intype=true
enc.warn=true
resource.title=true
resource.message=true
statuses.console=all
statuses.chat=all
statuses.muc=none
roster=true
roster.offline=true
roster.empty=false
roster.by=group
roster.order=presence
roster.unread=before
roster.count=true
roster.priority=false
roster.size=25
roster.wrap=true
roster.header.char=@
roster.contact.indent=1
roster.resource=true
roster.resource.char=/
roster.resource.indent=1
roster.resource.join=true
roster.presence=true
roster.presence.indent=-1
roster.status=true
roster.contacts=true
roster.rooms=true
roster.rooms.order=name
roster.rooms.unread=before
roster.rooms.pos=last
occupants=true
occupants.size=15
occupants.jid=false
wins.autotidy=true
otr.char=@
pgp.char=%
tls.show=true
console.muc=first
titlebar.position=1
mainwin.position=2
statusbar.position=3
inputwin.position=4