Skip to content

Commit

Permalink
Vim: Minor JS+TS ftplugin fixups. Adds a CA-specific yarn shortcut.
Browse files Browse the repository at this point in the history
  • Loading branch information
damncabbage committed Jun 15, 2021
1 parent 84f1896 commit def076a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
7 changes: 5 additions & 2 deletions .vim/ftplugin/javascript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function! AddJsDebug()
" TODO: debounce?
call add(debug_method_code, " var cl = (new Error).stack.split(\"\\n\")[2]")
call add(debug_method_code, " var index = cl.indexOf('at ')")
call add(debug_method_code, " var clClean = cl.slice(index+3, cl.length)")
call add(debug_method_code, " var clClean = cl.slice(index+3, cl.length)")
call add(debug_method_code, " console.log('[' + clClean + '] [' + name + ']:', val)")
call add(debug_method_code, " return val")
call add(debug_method_code, "}")
Expand All @@ -17,7 +17,7 @@ function! AddJsDebug()
" Save cursor position to restore at the end of the function.
let save_cursor = getcurpos()

" 1) Add the debug line to the top of the Ruby file, so it's available in
" 1) Add the debug line to the top of the JS file, so it's available in
" later code, if we haven't already added it.
call cursor(1, 1)
let debug_find_result = search('\V' . minified_debug, 'c')
Expand Down Expand Up @@ -93,3 +93,6 @@ function! AddJsDebug()
endfunction

nnoremap <leader>dd :call AddJsDebug()<CR>
" Lint Fix
nmap <leader>ll :!eslint --fix %<CR>
11 changes: 11 additions & 0 deletions .vim/ftplugin/typescript.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
" Lint Fix
nnoremap <leader>ll :!eslint --fix %<CR>
" Culture Amp 'frontend-ops'-specific D:
" (frontend-ops has package/* and example/* workspaces set up, so I want to be
" able to quickly run jest and other commands on things within those
" workspaces.)
nnoremap <leader>yy :!yarn <C-R>=expand("%:gs?\\([^/][^/]*/[^/][^/]*\\)/.*?\\1?") . ' '<CR>
nnoremap <leader>yj :!yarn <C-R>=expand("%:gs?\\([^/][^/]*/[^/][^/]*\\)/.*?\\1?") . ' jest %'<CR>
nnoremap <leader>ys :!yarn <C-R>=expand("%:gs?\\([^/][^/]*/[^/][^/]*\\)/.*?\\1?") . ' jest %'<CR><CR>
1 change: 0 additions & 1 deletion .vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ Plug 'mxw/vim-jsx', { 'for': ['javascript', 'javascript.jsx'] }
Plug 'leafgarland/typescript-vim', { 'for': 'typescript' }

Plug 'prettier/vim-prettier', {
\ 'branch': 'issue/232-adding-support-for-prettier-2.x',
\ 'do': 'yarn install',
\ 'for': ['javascript', 'javascript.jsx', 'typescript'] }
" TODO: Try:
Expand Down

0 comments on commit def076a

Please sign in to comment.