From 0c44323e52e5d2ba5844e23a19977ccd5b720a25 Mon Sep 17 00:00:00 2001 From: Max Bucknell Date: Thu, 2 Jan 2025 13:57:30 +0000 Subject: [PATCH] Ultisnips compatibility updates --- fish/fish.xdg.symlink/conf.d/secret.fish.dist | 2 +- fish/fish.xdg.symlink/config.fish | 11 ++++ vim/vim.xdg.symlink/Ultisnips/quarto.snippets | 50 +++++++++++++++++++ .../asyncomplete/sources/ultisnips.vim | 24 +++++++++ vim/vim.xdg.symlink/colors/mpwb.vim | 1 + vim/vim.xdg.symlink/vimrc | 33 ++++++++++-- 6 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 vim/vim.xdg.symlink/autoload/asyncomplete/sources/ultisnips.vim diff --git a/fish/fish.xdg.symlink/conf.d/secret.fish.dist b/fish/fish.xdg.symlink/conf.d/secret.fish.dist index bd78772..62076da 100644 --- a/fish/fish.xdg.symlink/conf.d/secret.fish.dist +++ b/fish/fish.xdg.symlink/conf.d/secret.fish.dist @@ -1,7 +1,7 @@ set -gx GIT_AUTHOR_NAME="Max Bucknell" set -gx GIT_AUTHOR_EMAIL="me@maxbucknell.com" -set -gx NODE_VERSION="22" +set -gx NODE_VERSION "23" set -gx DOTFILES_PATH "$HOME/dotfiles" diff --git a/fish/fish.xdg.symlink/config.fish b/fish/fish.xdg.symlink/config.fish index 6700578..98b5225 100644 --- a/fish/fish.xdg.symlink/config.fish +++ b/fish/fish.xdg.symlink/config.fish @@ -27,6 +27,17 @@ set -gx GOPATH "$HOME/go" set -gx GOBIN "$GOPATH/bin" fish_add_path --global "$GOBIN" +# Python + +set -gx VIRTUAL_ENV_DISABLE_PROMPT 1 + +if ! test -f "$HOME/dotfiles/python/venv/bin/activate.fish" + python3 -m venv "$HOME/dotfiles/python/venv" +end + +source "$HOME/dotfiles/python/venv/bin/activate.fish" +set -gx PYTHONPATH "$PYTHONPATH:$HOME/dotfiles/lib/python" + # Node.js set -gx NODEPATH "$HOMEBREW_PREFIX/node@$NODE_VERSION" fish_add_path --global "$NODEPATH/bin" diff --git a/vim/vim.xdg.symlink/Ultisnips/quarto.snippets b/vim/vim.xdg.symlink/Ultisnips/quarto.snippets index ad20feb..5cd0b89 100644 --- a/vim/vim.xdg.symlink/Ultisnips/quarto.snippets +++ b/vim/vim.xdg.symlink/Ultisnips/quarto.snippets @@ -1,3 +1,33 @@ +snippet note "Note Front Matter" b +--- +title: "${1:Title}" +author: "${2:Max Bucknell}" +date: "${3:`date "+%A, %e, %B %Y"`}" +format: + html: + embed-resources: true + html-math-method: katex + mainfont: Lato + monofont: Input + theme: + light: flatly + dark: darkly + pdf: + documentclass: article + mainfont: Lato + monofont: Input + geometry: + - top=30mm + - left=20mm + - heightrounded + number-sections: true +--- + +# $1 + +$0 +endsnippet + snippet :::n "Callout: Note" b ::: {.callout-note} ${0:${VISUAL:text...}} @@ -29,6 +59,26 @@ ${0:${VISUAL:# code...}} \`\`\` endsnippet +snippet `py "Python Code Block" b +\`\`\`{python} +${1:#| output: ${2:false}} +${0:${VISUAL:# code...}} +\`\`\` +endsnippet + +snippet `ju "Julia Code Block" b +\`\`\`{julia} +${1:#| output: ${2:false}} +${0:${VISUAL:# code...}} +\`\`\` +endsnippet + snippet todo "Make a To-Do List!" b - [ ] ${0:What would you like to do..?} endsnippet + +snippet --- "Horizontal Rule" b +-------------------------------------------------------------------------------- + +$0 +endsnippet diff --git a/vim/vim.xdg.symlink/autoload/asyncomplete/sources/ultisnips.vim b/vim/vim.xdg.symlink/autoload/asyncomplete/sources/ultisnips.vim new file mode 100644 index 0000000..292caa1 --- /dev/null +++ b/vim/vim.xdg.symlink/autoload/asyncomplete/sources/ultisnips.vim @@ -0,0 +1,24 @@ +function! asyncomplete#sources#ultisnips#get_source_options(opts) + let l:defaults={ + \ 'name': 'ultisnips', + \ 'completor': function('asyncomplete#sources#ultisnips#completor'), + \ 'allowlist': ['*'] + \ } + return extend(l:defaults, a:opts) +endfunction + +function! asyncomplete#sources#ultisnips#completor(opt, ctx) + let l:snips = UltiSnips#SnippetsInCurrentScope() + + let l:matches = [] + + let l:col = a:ctx['col'] + let l:typed = a:ctx['typed'] + + let l:kwlen = len(l:typed) + + let l:matches = map(keys(l:snips),'{"word":v:val,"dup":1,"icase":1,"menu": "Snips: " . l:snips[v:val]}') + let l:startcol = l:col - l:kwlen + + call asyncomplete#complete(a:opt['name'], a:ctx, l:startcol, l:matches) +endfunction diff --git a/vim/vim.xdg.symlink/colors/mpwb.vim b/vim/vim.xdg.symlink/colors/mpwb.vim index ed5f34b..6de6e4d 100644 --- a/vim/vim.xdg.symlink/colors/mpwb.vim +++ b/vim/vim.xdg.symlink/colors/mpwb.vim @@ -129,6 +129,7 @@ hi link pandocAtxStart Title hi link pandocNoFormatted Keyword hi link pandocDelimitedCodeBlockLanguage Normal hi pandocBlockQuote cterm=italic +hi pandocHRule guibg=mpwb_tintbg hi quartoCalloutNote guibg=mpwb_callout_note hi quartoCalloutWarning guibg=mpwb_callout_warning diff --git a/vim/vim.xdg.symlink/vimrc b/vim/vim.xdg.symlink/vimrc index 55e58b5..d514ea4 100644 --- a/vim/vim.xdg.symlink/vimrc +++ b/vim/vim.xdg.symlink/vimrc @@ -14,15 +14,17 @@ plug#begin() Plug 'vimpostor/vim-lumen' Plug 'tpope/vim-commentary' +Plug 'tpope/vim-eunuch' Plug 'tpope/vim-fugitive' -Plug 'tpope/vim-surround' Plug 'tpope/vim-repeat' +Plug 'tpope/vim-surround' Plug '/opt/homebrew/opt/fzf' Plug 'junegunn/fzf.vim' Plug 'SirVer/ultisnips' Plug 'dense-analysis/ale' +Plug 'prabirshrestha/asyncomplete.vim' Plug 'vim-pandoc/vim-pandoc-syntax' Plug 'quarto-dev/quarto-vim' @@ -210,6 +212,7 @@ enddef # Git blame nnoremap a Zoom():Git blame +nnoremap z Zoom() # Make directories in a filename if they don't exist. @@ -386,7 +389,7 @@ def OpenDailyNote(offset = 0) system(shellescape(template) .. " " .. shellescape(date) .. " > " .. shellescape(filename)) endif - execute "edit " .. filename + execute "silent edit " .. filename enddef @@ -400,12 +403,14 @@ enddef augroup StartUp autocmd! + autocmd VimEnter * ++nested StartUp() + + autocmd VimResized * wincmd = augroup END # LSP and other completion -g:ale_completion_enabled = 1 g:ale_elixir_elixir_ls_release = '/opt/homebrew/opt/elixir-ls/libexec' g:ale_fix_on_save = 1 @@ -437,6 +442,26 @@ nnoremap dx :ALEGoToDefinition -split nnoremap dv :ALEGoToDefinition -vsplit nnoremap dt :ALEGoToDefinition -tab + # au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#ale#get_source_options({ + # \ 'priority': 10, " Provide your own overrides here + # \ })) + +inoremap pumvisible() ? asyncomplete#close_popup() : "\" + +augroup Completion + autocmd! + + autocmd User asyncomplete_setup { + asyncomplete#register_source( + asyncomplete#sources#ale#get_source_options({ 'priority': 10 }) + ) + + asyncomplete#register_source( + asyncomplete#sources#ultisnips#get_source_options({ 'priority': 11 }) + ) + } +augroup END + # File Running def PreviewQuarto() @@ -482,7 +507,7 @@ def SynStack() if !exists("*synstack") return endif - echo map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")') + echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') enddef nnoremap \ SynStack()