Skip to content

Commit f511285

Browse files
committed
Do correct the mapping
1 parent 3d1452e commit f511285

7 files changed

Lines changed: 35 additions & 22 deletions

File tree

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ before_script: |
55
git clone https://github.com/tpope/vim-repeat.git
66
77
script:
8-
# Will return 1 in case of errors - 0 otherwise
9-
vim -Nu test/vimrc -c 'Vader! test/*'
8+
./test/run-tests.sh

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ this or other vim plugins
149149
* Use [vimdoc](https://github.com/google/vimdoc) to generate documentation from
150150
the `vim` docstring (instead of manually updating the .txt file). See the
151151
misc/build_doc for more on how this is done.
152-
* Use [vader](https://github.com/junegunn/vader.vim) for unittesting.
152+
* Use [vader](https://github.com/junegunn/vader.vim) for unittesting. Use
153+
`test/run-tests.sh` to run them.
153154

154155

155156
## TODO
@@ -158,14 +159,15 @@ this or other vim plugins
158159
- [ ] Method to delete all the debugging strings in current buffer
159160
- [x] Method to print name and contents of a variable
160161
- [ ] Add option for variable debugging in rest of langs
161-
- [ ] Make the counter buffer-specific
162+
- ~[ ]Make the counter buffer-specific~ Nope, we already have the filename &
163+
line for file-specific text
162164
- [ ] Escape double single quotes vimscript variable printing
163165
- [x] Append to current line if that is empty
164166
- [x] Support repeat.vim
165167
- [ ] Use an assertion module
166168
- [x] Use vader.vim for TDD
167169
- [ ] Extend vader support for rest of languages
168-
- [ ] Use travis for CI
170+
- [x] Use travis for CI
169171
- [x] Bug with changing the filename of the current file
170172
- [x] Make vim-repeat dependency optional
171173
- [x] Turn supported languages into a table - what do we support in which

doc/debugstring.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ logging statements around the various code snippets that you want to test.
2929
The form and syntax of the logging statements target the language at hand
3030
(e.g., use printf() in C/C++ but puts() in Ruby)
3131

32+
vim-debugstring should be compatible with Vim >= 7.4.313
33+
34+
3235
==============================================================================
3336
CONFIGURATION *debugstring-config*
3437

3538
To add a logging statement either use the default normal mode mapping
3639
(|g:default_dump_debug_map|) or define your own:
3740

38-
* nmap <your-key-combination> <Plug>DumpDebugString
41+
* nmap <your-key-combination> <Plug>DumpDebugStringVar
3942

4043
* nmap <a-second-key-combination> <Plug>DumpDebugStringExpr
4144

plugin/debugstring.vim

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
" To add a logging statement either use the default normal mode mapping
2626
" (@setting(default_dump_debug_map)) or define your own:
2727
"
28-
" * nmap <your-key-combination> <Plug>DumpDebugString
28+
" * nmap <your-key-combination> <Plug>DumpDebugStringVar
2929
"
3030
" * nmap <a-second-key-combination> <Plug>DumpDebugStringExpr
3131

@@ -123,13 +123,15 @@ function! s:incrDebugCounter()
123123
let g:debugStringCounter += g:debugStringCounterStep
124124
endfunc
125125

126-
if !hasmapto('<Plug>DumpDebugString')
126+
if !hasmapto('<Plug>DumpDebugStringVar')
127127
""@setting default_dump_debug_map
128128
"
129-
nmap <nowait> <unique> <Leader>ds <Plug>DumpDebugString<CR>
129+
nmap <unique> <Leader>ds <Plug>DumpDebugStringVar
130+
endif
131+
if !hasmapto('<Plug>DumpDebugStringExpr')
130132
""@setting default_dump_debug_map
131133
"
132-
nmap <nowait> <unique> <Leader>dS <Plug>DumpDebugStringExpr
134+
nmap <unique> <Leader>dS <Plug>DumpDebugStringExpr
133135
endif
134136

135137
""
@@ -168,7 +170,7 @@ function! s:debugFunctionWrapper(mode, ...)
168170
AddDebugString
169171

170172
if &runtimepath =~# 'vim-repeat'
171-
call repeat#set("\<Plug>DumpDebugString")
173+
call repeat#set("\<Plug>DumpDebugStringVar<CR>")
172174
endif
173175

174176
elseif a:mode ==# s:modes['var_debug']
@@ -187,8 +189,8 @@ function! s:debugFunctionWrapper(mode, ...)
187189

188190
" Make way for repeat.vim
189191
if &runtimepath =~# 'vim-repeat'
190-
execute 'nnoremap <silent> <Plug>DumpDebugStringSpecExpr :<C-U> :call <SID>debugFunctionWrapper(1, "' . l:expr . '")<CR>'
191-
call repeat#set("\<Plug>DumpDebugStringSpecExpr")
192+
execute 'nnoremap <silent> <Plug>DumpDebugStringSpecExpr :<C-U>call <SID>debugFunctionWrapper(1, "' . l:expr . '")<CR>'
193+
call repeat#set("\<Plug>DumpDebugStringSpecExpr<CR>")
192194
endif
193195
else
194196
echoerr 's:debugFunctionWrapper - Unknown mode: ' a:mode
@@ -215,10 +217,10 @@ endfunc
215217

216218
""
217219
" For debugging, execute a <Plug> command using execute:
218-
" :execute "normal \<Plug>DumpDebugString"
220+
" :execute "normal \<Plug>DumpDebugStringVar"
219221
"
220-
nnoremap <silent> <Plug>DumpDebugString :<C-U> :call <SID>debugFunctionWrapper(0)<CR>
221-
nnoremap <silent> <Plug>DumpDebugStringExpr :<C-U> :call <SID>debugFunctionWrapper(1)<CR>
222+
nnoremap <silent> <Plug>DumpDebugStringVar :<C-U>call <SID>debugFunctionWrapper(0)<CR>
223+
nnoremap <silent> <Plug>DumpDebugStringExpr :<C-U>call <SID>debugFunctionWrapper(1)<CR>
222224
223225
let &cpoptions = s:save_cpo
224226
unlet s:save_cpo

test/basic.vader

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,23 @@ Execute (C +std_debug +Text):
1616
:set filetype=c
1717
3
1818
AssertEqual getline('.'), 'And each in your season', "Current line contents don't match"
19+
Log join(getline(1,'$'), "\n")
1920
:normal ,ds
21+
Log join(getline(1,'$'), "\n")
2022
:normal .
23+
Log join(getline(1,'$'), "\n")
2124

2225
Then ():
2326
4
2427
AssertEqual getline('.'), 'printf("[[Vader-workbench]:4] DEBUGGING STRING ==> %d\n", 0);'
25-
6
26-
AssertEqual getline('.'), 'printf("[[Vader-workbench]:6] DEBUGGING STRING ==> %d\n", 1);'
28+
5
29+
AssertEqual getline('.'), 'printf("[[Vader-workbench]:5] DEBUGGING STRING ==> %d\n", 1);'
2730

2831
================================================================================
2932

3033
""
31-
" What happens if there isn't any text at all in the buffer?
34+
" What happens if there isn't any text in the current line? - cursor should stay
35+
" at the same line
3236
Execute (C +std_debug -Text):
3337
:set filetype=c
3438
8

test/run-tests.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
# Do not "cd" to any existing "test" dir from CDPATH!
55
unset CDPATH
66

7-
cd "$(dirname "${BASH_SOURCE[0]}")" && vim -Nu vimrc -c 'Vader! basic.vader' \
8-
> /dev/null
7+
cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")")"
8+
vim -Nu test/vimrc -c 'Vader! test/*'
9+
cd -

test/vimrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
filetype off
22
let g:mapleader = ","
33

4+
nmap <Leader>ds <Plug>DumpDebugStringVar
5+
nmap <Leader>dS <Plug>DumpDebugStringExpr
6+
47
set runtimepath+=.
58
set runtimepath+=vader.vim
69
set runtimepath+=vim-repeat
@@ -11,4 +14,3 @@ syntax enable
1114
set nomore
1215
set noswapfile
1316
set viminfo=
14-

0 commit comments

Comments
 (0)