Notes setup, in Vim, with Quarto
This commit is contained in:
parent
5a29d8348f
commit
66e0fb507d
4 changed files with 276 additions and 46 deletions
30
vim/vim.xdg.symlink/Ultisnips/quarto.snippets
Normal file
30
vim/vim.xdg.symlink/Ultisnips/quarto.snippets
Normal file
|
@ -0,0 +1,30 @@
|
|||
snippet :::n "Callout: Note" b
|
||||
::: {.callout-note}
|
||||
${0:${VISUAL:text...}}
|
||||
:::
|
||||
endsnippet
|
||||
|
||||
snippet :::t "Callout: Tip" b
|
||||
::: {.callout-tip}
|
||||
${0:${VISUAL:text...}}
|
||||
:::
|
||||
endsnippet
|
||||
|
||||
snippet :::w "Callout: Warning" b
|
||||
::: {.callout-warning}
|
||||
${0:${VISUAL:text...}}
|
||||
:::
|
||||
endsnippet
|
||||
|
||||
snippet :::i "Callout: Important" b
|
||||
::: {.callout-important}
|
||||
${0:${VISUAL:text...}}
|
||||
:::
|
||||
endsnippet
|
||||
|
||||
snippet `r "R Code Block" b
|
||||
\`\`\`{r}
|
||||
${1:#| output: ${2:false}}
|
||||
${0:${VISUAL:# code...}}
|
||||
\`\`\`
|
||||
endsnippet
|
5
vim/vim.xdg.symlink/after/syntax/quarto.vim
Normal file
5
vim/vim.xdg.symlink/after/syntax/quarto.vim
Normal file
|
@ -0,0 +1,5 @@
|
|||
syn region quartoCalloutNote start=":::\s\+{\.callout-note\s*" end=":::$" keepend
|
||||
syn region quartoCalloutWarning start=":::\s\+{\.callout-warning\s*" end=":::$" keepend
|
||||
syn region quartoCalloutImportant start=":::\s\+{\.callout-important\s*" end=":::$" keepend
|
||||
syn region quartoCalloutTip start=":::\s\+{\.callout-tip\s*" end=":::$" keepend
|
||||
syn region quartoCalloutCaution start=":::\s\+{\.callout-caution\s*" end=":::$" keepend
|
|
@ -25,64 +25,114 @@ endif
|
|||
|
||||
let g:colors_name = "mpwb"
|
||||
|
||||
hi Normal cterm=italic ctermfg=NONE ctermbg=NONE
|
||||
hi Type cterm=NONE ctermfg=NONE ctermbg=NONE
|
||||
hi Keyword cterm=NONE ctermfg=NONE ctermbg=NONE
|
||||
hi Operator cterm=NONE ctermfg=NONE ctermbg=NONE
|
||||
hi Special cterm=NONE ctermfg=NONE ctermbg=NONE
|
||||
hi Statement cterm=NONE ctermfg=NONE ctermbg=NONE
|
||||
hi Identifier cterm=NONE ctermfg=NONE ctermbg=NONE
|
||||
hi Constant cterm=NONE ctermfg=NONE ctermbg=NONE
|
||||
hi Define cterm=NONE ctermfg=NONE ctermbg=NONE
|
||||
hi Include cterm=NONE ctermfg=NONE ctermbg=NONE
|
||||
hi Macro cterm=NONE ctermfg=NONE ctermbg=NONE
|
||||
hi PreProc cterm=NONE ctermfg=NONE ctermbg=NONE
|
||||
hi Title cterm=NONE ctermfg=NONE ctermbg=NONE
|
||||
let s:is_dark=(&background == 'dark')
|
||||
|
||||
hi VimHiAttrib cterm=NONE ctermfg=NONE ctermbg=NONE
|
||||
hi VimOption cterm=NONE ctermfg=NONE ctermbg=NONE
|
||||
" \ 'mpwb_green': '#20A92E',
|
||||
call extend(v:colornames, {
|
||||
\ 'mpwb_fg': '#201C22',
|
||||
\ 'mpwb_bg': '#E7E3E9',
|
||||
\ 'mpwb_tintbg': '#FCF7FE',
|
||||
\ 'mpwb_red': '#AD1C22',
|
||||
\ 'mpwb_orange': '#AF5F27',
|
||||
\ 'mpwb_yellow': '#AD9622',
|
||||
\ 'mpwb_green': '#20A951',
|
||||
\ 'mpwb_cyan': '#20A9AE',
|
||||
\ 'mpwb_blue': '#2059AF',
|
||||
\ 'mpwb_purple': '#721CAF',
|
||||
\ 'mpwb_magenta': '#AB177B',
|
||||
\ 'mpwb_callout_note': '#CCD7E8',
|
||||
\ 'mpwb_callout_tip': '#D2E8CC',
|
||||
\ 'mpwb_callout_important': '#E8CCCC',
|
||||
\ 'mpwb_callout_warning': '#E8E3CC',
|
||||
\ 'mpwb_cursorline': '#c6c2c8'
|
||||
\ }, 'force')
|
||||
|
||||
if s:is_dark
|
||||
call extend(v:colornames, {
|
||||
\ 'mpwb_fg': '#E7E3E9',
|
||||
\ 'mpwb_bg': '#201C22',
|
||||
\ 'mpwb_tintbg': '#3B3440',
|
||||
\ 'mpwb_callout_note': '#002A68',
|
||||
\ 'mpwb_callout_tip': '#156800',
|
||||
\ 'mpwb_callout_important': '#680000',
|
||||
\ 'mpwb_callout_warning': '#685700',
|
||||
\ 'mpwb_cursorline': '#29242C',
|
||||
\ }, 'force')
|
||||
endif
|
||||
|
||||
hi Normal guifg=mpwb_fg guibg=mpwb_bg
|
||||
hi Type cterm=NONE guifg=mpwb_fg
|
||||
hi Keyword cterm=NONE guifg=mpwb_fg
|
||||
hi Operator cterm=NONE guifg=mpwb_fg
|
||||
hi Special cterm=NONE guifg=mpwb_fg
|
||||
hi Statement cterm=NONE guifg=mpwb_fg
|
||||
hi Identifier cterm=NONE guifg=mpwb_fg
|
||||
hi Constant cterm=NONE guifg=mpwb_fg
|
||||
hi Define cterm=NONE guifg=mpwb_fg
|
||||
hi Include cterm=NONE guifg=mpwb_fg
|
||||
hi Macro cterm=NONE guifg=mpwb_fg
|
||||
hi PreProc cterm=NONE guifg=mpwb_fg
|
||||
|
||||
hi VimHiAttrib cterm=NONE guifg=mpwb_fg
|
||||
hi VimOption cterm=NONE guifg=mpwb_fg
|
||||
|
||||
" Scalars are cyan
|
||||
hi String cterm=NONE ctermfg=4 ctermbg=NONE
|
||||
hi Number cterm=NONE ctermfg=4 ctermbg=NONE
|
||||
hi Boolean cterm=NONE ctermfg=4 ctermbg=NONE
|
||||
hi String cterm=NONE guifg=mpwb_cyan
|
||||
hi Number cterm=NONE guifg=mpwb_cyan
|
||||
hi Boolean cterm=NONE guifg=mpwb_cyan
|
||||
|
||||
" Comments are green
|
||||
hi Comment cterm=NONE ctermfg=2 ctermbg=NONE
|
||||
hi Todo cterm=bold ctermbg=2 ctermfg=7
|
||||
hi Comment cterm=NONE guifg=mpwb_green
|
||||
hi Todo cterm=bold guibg=mpwb_green guifg=mpwb_bg
|
||||
|
||||
" Search is bright blue
|
||||
hi Search ctermfg=8 ctermbg=14
|
||||
hi Search guifg=mpwb_fg guibg=mpwb_cyan
|
||||
hi! link MatchParen Search
|
||||
|
||||
" Chrome is magenta
|
||||
hi VertSplit ctermfg=5 ctermbg=NONE cterm=NONE
|
||||
hi StatusLine ctermfg=5 ctermbg=NONE cterm=bold
|
||||
hi StatusLineNC ctermfg=5 ctermbg=NONE cterm=NONE
|
||||
" Chrome is purple
|
||||
hi VertSplit guifg=mpwb_purple cterm=NONE
|
||||
hi StatusLine guifg=mpwb_purple cterm=bold
|
||||
hi StatusLineNC guifg=mpwb_purple cterm=NONE
|
||||
|
||||
hi Visual ctermbg=0 ctermfg=7
|
||||
hi Visual guibg=mpwb_fg guifg=mpwb_bg
|
||||
|
||||
hi LineNr cterm=NONE ctermfg=5 ctermbg=NONE
|
||||
hi CursorLine cterm=bold
|
||||
hi CursorLineNr cterm=bold ctermfg=15 ctermbg=5
|
||||
hi LineNr cterm=NONE guifg=mpwb_purple
|
||||
hi CursorLine cterm=bold guibg=mpwb_cursorline
|
||||
hi CursorLineNr cterm=bold guifg=mpwb_bg guibg=mpwb_purple
|
||||
|
||||
" LSP hints
|
||||
hi ErrorMsg cterm=NONE ctermfg=7 ctermbg=1
|
||||
hi Question cterm=NONE ctermfg=7 ctermbg=4
|
||||
hi SpellLocal cterm=NONE ctermfg=3 ctermbg=NONE
|
||||
hi SpellRare cterm=NONE ctermfg=3 ctermbg=NONE
|
||||
hi SpellCap cterm=NONE ctermfg=0 ctermbg=3
|
||||
hi SpellBad cterm=NONE ctermfg=7 ctermbg=1
|
||||
hi ErrorMsg cterm=NONE guifg=mpwb_bg guibg=mpwb_red
|
||||
hi Question cterm=NONE guifg=mpwb_bg guibg=mpwb_blue
|
||||
hi SpellLocal cterm=NONE guifg=mpwb_yellow guibg=NONE
|
||||
hi SpellRare cterm=NONE guifg=mpwb_yellow guibg=NONE
|
||||
hi SpellCap cterm=NONE guifg=mpwb_fg guibg=mpwb_yellow
|
||||
hi SpellBad cterm=NONE guifg=mpwb_bg guibg=mpwb_red
|
||||
|
||||
hi link LspDiagSignInfoText Question
|
||||
hi link LspDiagSignWarningText Question
|
||||
|
||||
hi PMenu cterm=NONE ctermfg=7 ctermbg=5
|
||||
hi PMenuSel cterm=bold ctermfg=8 ctermbg=3
|
||||
hi ALEVirtualTextError cterm=bold ctermfg=0 ctermbg=11
|
||||
hi ALEVirtualTextWarning cterm=bold ctermfg=0 ctermbg=11
|
||||
hi LspSigActiveParameter cterm=bold ctermfg=7 ctermbg=13
|
||||
hi PMenu cterm=NONE guifg=mpwb_fg guibg=mpwb_purple
|
||||
hi PMenuSel cterm=bold guifg=mpwb_bg guibg=mpwb_yellow
|
||||
hi ALEVirtualTextError cterm=bold guifg=mpwb_fg guibg=mpwb_yellow
|
||||
hi ALEVirtualTextWarning cterm=bold guifg=mpwb_fg guibg=mpwb_yellow
|
||||
hi LspSigActiveParameter cterm=bold guifg=mpwb_bg guibg=mpwb_purple
|
||||
|
||||
" Misc cleanup
|
||||
hi pandocBlockQuote cterm=NONE ctermfg=0 ctermbg=NONE
|
||||
hi pandocBlockQuote cterm=NONE guifg=mpwb_fg
|
||||
hi link elixirUnusedVariable Normal
|
||||
|
||||
" Notes in Quarto
|
||||
|
||||
hi Title cterm=bold guifg=mpwb_fg
|
||||
hi link pandocAtxHeaderMark Title
|
||||
hi link pandocAtxStart Title
|
||||
hi link pandocNoFormatted Keyword
|
||||
hi link pandocDelimitedCodeBlockLanguage Normal
|
||||
hi pandocBlockQuote cterm=italic
|
||||
|
||||
hi quartoCalloutNote guibg=mpwb_callout_note
|
||||
hi quartoCalloutWarning guibg=mpwb_callout_warning
|
||||
hi quartoCalloutImportant guibg=mpwb_callout_important
|
||||
hi quartoCalloutTip guibg=mpwb_callout_tip
|
||||
hi quartoCalloutCaution guibg=mpwb_callout_warning
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
" vim: set ft=vim
|
||||
set nocompatible
|
||||
|
||||
set termguicolors
|
||||
|
||||
set encoding=utf-8
|
||||
scriptencoding utf-8
|
||||
|
||||
|
@ -8,6 +10,8 @@ scriptencoding utf-8
|
|||
|
||||
call plug#begin()
|
||||
|
||||
Plug 'vimpostor/vim-lumen'
|
||||
|
||||
Plug 'tpope/vim-commentary'
|
||||
Plug 'tpope/vim-fugitive'
|
||||
Plug 'tpope/vim-surround'
|
||||
|
@ -26,6 +30,8 @@ Plug 'HerringtonDarkholme/yats.vim'
|
|||
|
||||
Plug 'elixir-editors/vim-elixir'
|
||||
|
||||
Plug 'bullets-vim/bullets.vim'
|
||||
|
||||
call plug#end()
|
||||
|
||||
" Language config
|
||||
|
@ -89,6 +95,7 @@ set nojoinspaces
|
|||
set expandtab
|
||||
set shiftwidth=4
|
||||
set softtabstop=4
|
||||
set textwidth=79
|
||||
set autoindent
|
||||
|
||||
" Show me when my lines are too long
|
||||
|
@ -154,9 +161,9 @@ inoremap <c-l> <esc><c-w><c-l>
|
|||
|
||||
" I'm getting back into visual mode
|
||||
" And I'm cycling the modes
|
||||
nnoremap v <c-v>
|
||||
nnoremap V v
|
||||
nnoremap <c-v> V
|
||||
nnoremap v V
|
||||
nnoremap V <c-v>
|
||||
nnoremap <c-v> v
|
||||
|
||||
" FZF
|
||||
nnoremap <leader>o :Files<cr>
|
||||
|
@ -211,8 +218,146 @@ augroup AutoMkdir
|
|||
autocmd BufNewFile * :call EnsureDirExists()
|
||||
augroup END
|
||||
|
||||
" LSP and other completion
|
||||
" Use tab for UltiSnips expansion, navigation, and
|
||||
let g:ulti_expand_or_jump_res = 0
|
||||
let g:UltiSnipsExpandOrJumpTrigger = '<tab>'
|
||||
|
||||
function! Ulti_ExpandOrJump_and_getRes()
|
||||
call UltiSnips#ExpandSnippetOrJump()
|
||||
return g:ulti_expand_or_jump_res
|
||||
endfunction
|
||||
|
||||
inoremap <tab> <c-r>=(Ulti_ExpandOrJump_and_getRes() > 0)?"":"\<tab>"<cr>
|
||||
|
||||
" Notes config
|
||||
|
||||
let g:markdown_fenced_languages = ['r', 'elixir', 'python', 'html', 'rust']
|
||||
let g:pandoc#syntax#codeblocks#embeds#langs = ['r', 'elixir', 'python', 'html', 'rust']
|
||||
|
||||
" Enable bullets.vim in Quarto files
|
||||
let g:bullets_enabled_file_types = ['markdown', 'text', 'gitcommit', 'quarto']
|
||||
" Disable the bullet changing on indents (for now)
|
||||
let g:bullets_outline_levels = ['num', 'std-']
|
||||
|
||||
def EditCodeBlock()
|
||||
var b = bufnr("%")
|
||||
var name = b .. ".codeblock"
|
||||
|
||||
# We only create one code block buffer per buffer. So if it already
|
||||
# exists, we will empty it out. If it doesn't already exist, we
|
||||
# create it.
|
||||
#
|
||||
# If it exists and has unsaved changes, we exit and warn.
|
||||
var code_buffer = bufnr(name, 1)
|
||||
if getbufvar(code_buffer, "&modified")
|
||||
echom "Unsaved changes in existing code block for this file."
|
||||
return
|
||||
endif
|
||||
|
||||
# Store current cursor position for state restoration later.
|
||||
var p = getpos(".")
|
||||
|
||||
# Set bottom mark for code block
|
||||
execute "silent normal! /^```\rmb"
|
||||
|
||||
# Set top mark for code block
|
||||
execute "silent normal! ?^```\rmt"
|
||||
|
||||
# Yank contents to source register
|
||||
execute "silent normal! j\"cy`b"
|
||||
|
||||
# Yank filetype to type register, and reset position to top
|
||||
execute "silent normal! `t3l\"fy$`t"
|
||||
|
||||
# Find offset position of cursor so the new buffer is in the
|
||||
# correct place
|
||||
var line = p[1]
|
||||
var col = p[2]
|
||||
var s = getpos("'t")
|
||||
var start_line = s[1]
|
||||
|
||||
line = line - start_line
|
||||
|
||||
# If code block buffer is visible, go there. If it is not visible,
|
||||
# then we should show it below.
|
||||
|
||||
var window = bufwinnr(code_buffer)
|
||||
if window == -1
|
||||
execute "below sbuffer " .. code_buffer
|
||||
else
|
||||
execute ":" .. window .. "windo :"
|
||||
execute "buffer " .. code_buffer
|
||||
endif
|
||||
|
||||
set buftype=acwrite
|
||||
|
||||
# Clear buffer and fill with new code
|
||||
silent :%d "
|
||||
silent :0put c
|
||||
normal! G"_dd
|
||||
|
||||
# Position cursor correctly, and mark
|
||||
setpos(".", [0, line, col, 0])
|
||||
|
||||
# Link back to the original buffer for saving
|
||||
b:original_buffer = b
|
||||
|
||||
# Set file type, if it is correctly annotated
|
||||
if @f != '`'
|
||||
execute 'set filetype=' .. @f
|
||||
endif
|
||||
|
||||
set nomodified
|
||||
enddef
|
||||
|
||||
def SaveCodeBlock()
|
||||
var b = bufnr("%")
|
||||
silent :%yank c
|
||||
normal! mc
|
||||
silent execute "buffer " .. b:original_buffer
|
||||
silent execute "normal! `tjd`b`t\"cp"
|
||||
silent execute "buffer " .. b
|
||||
set nomodified
|
||||
normal! `c
|
||||
echom "Code block updated"
|
||||
enddef
|
||||
|
||||
augroup CodeBlocks
|
||||
autocmd!
|
||||
|
||||
autocmd BufWriteCmd *.codeblock call SaveCodeBlock()
|
||||
augroup END
|
||||
|
||||
augroup Notes
|
||||
autocmd Filetype quarto setl tw=80 fo+=croqt ts=4 sts=4 sw=4 comments=n:>
|
||||
|
||||
" Surround mappings for Quarto callouts
|
||||
autocmd FileType quarto let b:surround_110 = "::: {.callout-note}\n\r\n:::"
|
||||
autocmd FileType quarto let b:surround_116 = "::: {.callout-tip}\n\r\n:::"
|
||||
autocmd FileType quarto let b:surround_119 = "::: {.callout-warning}\n\r\n:::"
|
||||
autocmd FileType quarto let b:surround_105 = "::: {.callout-important}\n\r\n:::"
|
||||
|
||||
autocmd FileType quarto imap <tab> <c-r>=(Ulti_ExpandOrJump_and_getRes() > 0)?"":"\<c-t>"<cr>
|
||||
autocmd FileType quarto imap <s-tab> <c-d>
|
||||
|
||||
autocmd FileType quarto onoremap cb :<c-u>execute "normal! /^```\rk$ms?^```\rj:noh\rv`s"<cr>
|
||||
autocmd FileType quarto nnoremap <leader>ec :call EditCodeBlock()<cr>
|
||||
autocmd FileType quarto inoremap <c-e> <esc>:call EditCodeBlock()<cr>
|
||||
augroup END
|
||||
|
||||
def StartUp()
|
||||
if @% == ""
|
||||
edit ~/tmp/testing.qmd
|
||||
endif
|
||||
enddef
|
||||
|
||||
augroup StartUp
|
||||
autocmd!
|
||||
autocmd VimEnter * ++nested call StartUp()
|
||||
augroup END
|
||||
|
||||
|
||||
" LSP and other completion
|
||||
let g:ale_completion_enabled = 1
|
||||
let g:ale_elixir_elixir_ls_release = '/opt/homebrew/opt/elixir-ls/libexec'
|
||||
let g:ale_fix_on_save = 1
|
||||
|
@ -279,7 +424,7 @@ augroup TextFormatting
|
|||
|
||||
autocmd FileType make,go setl noet sw=8 sts=8 ts=8
|
||||
|
||||
autocmd FileType r,quarto,rmd,elixir setl et sw=2 sts=2 ts=2
|
||||
autocmd FileType r,elixir setl et sw=2 sts=2 ts=2
|
||||
augroup END
|
||||
|
||||
" Show syntax highlighting groups for word under cursor
|
||||
|
|
Loading…
Add table
Reference in a new issue