From 4dc255bc69d0ca7842b4adacecb71f7459b463d4 Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Wed, 11 Oct 2023 20:38:57 -0700 Subject: [PATCH] Add arduino IDE config --- nvim/.config/nvim/ftplugin/arduino.vim | 11 +++ nvim/.config/nvim/plugins.vim | 95 +++++++++++++------------- 2 files changed, 59 insertions(+), 47 deletions(-) create mode 100644 nvim/.config/nvim/ftplugin/arduino.vim diff --git a/nvim/.config/nvim/ftplugin/arduino.vim b/nvim/.config/nvim/ftplugin/arduino.vim new file mode 100644 index 0000000..acc2850 --- /dev/null +++ b/nvim/.config/nvim/ftplugin/arduino.vim @@ -0,0 +1,11 @@ +" Keybindings for sketches +nnoremap aa ArduinoAttach +nnoremap av ArduinoVerify +nnoremap au ArduinoUpload +nnoremap aus ArduinoUploadAndSerial +nnoremap as ArduinoSerial +nnoremap ab ArduinoChooseBoard +nnoremap ap ArduinoChooseProgrammer + +" Status line +autocmd BufNewFile,BufRead *.ino let g:airline_section_x='%{MyStatusLine()}' diff --git a/nvim/.config/nvim/plugins.vim b/nvim/.config/nvim/plugins.vim index 225b1a5..cda283f 100644 --- a/nvim/.config/nvim/plugins.vim +++ b/nvim/.config/nvim/plugins.vim @@ -6,6 +6,7 @@ Plug 'dense-analysis/ale' "Plug 'tweekmonster/deoplete-clang2' Plug 'sbdchd/neoformat' Plug 'junegunn/fzf.vim', { 'do': { -> fzf#install() } } +Plug 'stevearc/vim-arduino' "Plug 'vim-airline/vim-airline' "Plug 'vim-airline/vim-airline-themes' @@ -27,11 +28,11 @@ let g:airline_theme='simple' " --------- Ale ---------- let g:ale_linters = { - \ 'python': ['pylint'], - \ 'vim': ['vint'], - \ 'cpp': ['clang'], - \ 'c': ['clang'] -\} + \ 'python': ['pylint'], + \ 'vim': ['vint'], + \ 'cpp': ['clang'], + \ 'c': ['clang'] + \} " ---------- Deoplete ---------- let g:deoplete#enable_at_startup = 1 @@ -48,28 +49,28 @@ set rtp+=/usr/local/opt/fzf " Navigate to a tag function! s:tags_sink(line) - let parts = split(a:line, '\t\zs') - let excmd = matchstr(parts[2:], '^.*\ze;"\t') - execute 'silent e' parts[1][:-2] - let [magic, &magic] = [&magic, 0] - execute excmd - let &magic = magic + let parts = split(a:line, '\t\zs') + let excmd = matchstr(parts[2:], '^.*\ze;"\t') + execute 'silent e' parts[1][:-2] + let [magic, &magic] = [&magic, 0] + execute excmd + let &magic = magic endfunction function! s:tags() - if empty(tagfiles()) - echohl WarningMsg - echom 'Preparing tags' - echohl None - call system('ctags -R') - endif + if empty(tagfiles()) + echohl WarningMsg + echom 'Preparing tags' + echohl None + call system('ctags -R') + endif - call fzf#run({ - \ 'source': 'cat '.join(map(tagfiles(), 'fnamemodify(v:val, ":S")')). - \ '| grep -v -a ^!', - \ 'options': '+m -d "\t" --with-nth 1,4.. -n 1 --tiebreak=index', - \ 'down': '40%', - \ 'sink': function('s:tags_sink')}) + call fzf#run({ + \ 'source': 'cat '.join(map(tagfiles(), 'fnamemodify(v:val, ":S")')). + \ '| grep -v -a ^!', + \ 'options': '+m -d "\t" --with-nth 1,4.. -n 1 --tiebreak=index', + \ 'down': '40%', + \ 'sink': function('s:tags_sink')}) endfunction command! Tags call s:tags() @@ -77,45 +78,45 @@ map :Tags " Search lines in all open buffers function! s:line_handler(l) - let keys = split(a:l, ':\t') - exec 'buf' keys[0] - exec keys[1] - normal! ^zz + let keys = split(a:l, ':\t') + exec 'buf' keys[0] + exec keys[1] + normal! ^zz endfunction function! s:buffer_lines() - let res = [] - for b in filter(range(1, bufnr('$')), 'buflisted(v:val)') - call extend(res, map(getbufline(b,0,"$"), 'b . ":\t" . (v:key + 1) . ":\t" . v:val ')) - endfor - return res + let res = [] + for b in filter(range(1, bufnr('$')), 'buflisted(v:val)') + call extend(res, map(getbufline(b,0,"$"), 'b . ":\t" . (v:key + 1) . ":\t" . v:val ')) + endfor + return res endfunction command! FZFLines call fzf#run({ -\ 'source': buffer_lines(), -\ 'sink': function('line_handler'), -\ 'options': '--extended --nth=3..', -\ 'down': '60%' -\}) + \ 'source': buffer_lines(), + \ 'sink': function('line_handler'), + \ 'options': '--extended --nth=3..', + \ 'down': '60%' + \}) " Select buffer function! s:buflist() - redir => ls - silent ls - redir END - return split(ls, '\n') + redir => ls + silent ls + redir END + return split(ls, '\n') endfunction function! s:bufopen(e) - execute 'buffer' matchstr(a:e, '^[ 0-9]*') + execute 'buffer' matchstr(a:e, '^[ 0-9]*') endfunction nnoremap :call fzf#run({ -\ 'source': reverse(buflist()), -\ 'sink': function('bufopen'), -\ 'options': '+m', -\ 'down': len(buflist()) + 2 -\ }) + \ 'source': reverse(buflist()), + \ 'sink': function('bufopen'), + \ 'options': '+m', + \ 'down': len(buflist()) + 2 + \ }) " ---------- Neoformat ---------- " Override python formatter