From a5bfe2977ed4eb2c0336c81cb2e99f9aa1c34db0 Mon Sep 17 00:00:00 2001 From: spike Date: Sun, 11 Sep 2022 14:14:24 +0200 Subject: [PATCH] Leap + local custom snippets --- TODO | 1 + custom_snippets | 1 - custom_snippets/all_mine.snippets | 37 ++++++++++++++ custom_snippets/go.snippets | 64 ++++++++++++++++++++++++ custom_snippets/lua.snippets | 4 ++ custom_snippets/markdown_btw.snippets | 72 +++++++++++++++++++++++++++ custom_snippets/markdown_zk.snippets | 3 ++ lua/core/mappings.lua | 2 +- lua/custom/plugins/configs/leap.lua | 8 +++ lua/custom/plugins/init.lua | 11 ++-- 10 files changed, 198 insertions(+), 5 deletions(-) delete mode 120000 custom_snippets create mode 100644 custom_snippets/all_mine.snippets create mode 100644 custom_snippets/go.snippets create mode 100644 custom_snippets/lua.snippets create mode 100644 custom_snippets/markdown_btw.snippets create mode 100644 custom_snippets/markdown_zk.snippets create mode 100644 lua/custom/plugins/configs/leap.lua diff --git a/TODO b/TODO index c70ec04..10ae71c 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,4 @@ +- per project lsp settings - set neovim shell to bash/sh for faster commands (fish is slow) see https://www.reddit.com/r/neovim/comments/opipij/guide_tips_and_tricks_to_reduce_startup_and/ - yank until end of line $ mapping diff --git a/custom_snippets b/custom_snippets deleted file mode 120000 index ad0f97f..0000000 --- a/custom_snippets +++ /dev/null @@ -1 +0,0 @@ -../../dotfiles/nvim/.config/nvim/mysnippets \ No newline at end of file diff --git a/custom_snippets/all_mine.snippets b/custom_snippets/all_mine.snippets new file mode 100644 index 0000000..a17a6d5 --- /dev/null +++ b/custom_snippets/all_mine.snippets @@ -0,0 +1,37 @@ +priority -55 + +global !p +from vimsnippets import foldmarker, make_box, get_comment_format +endglobal + + +################ +# ANSI Color Codes # +################ + +# The table starts with the original 16 colors (0-15). + +# The proceeding 216 colors (16-231) or formed by a 3bpc RGB value offset by +# 16, packed into a single value. + +# The final 24 colors (232-256) are grayscale +# starting from a shade slighly lighter than black, ranging up to shade slightly +# darker than white. + +# Some emulators interpret these steps as linear +# increments from (256 / 24) on all three channels, although some emulators may +# explicitly define these values. + +snippet ansi_fg "Foreground ANSI 256 Color Code" i +\033[38;5;${1:00}m +endsnippet + +snippet ansi_bg "Background ANSI 256 Color Code" i +\033[48;5;${1:00}m +endsnippet + +snippet ansi_reset "Reset ANSI 256 Color Code" i +\033[0m +endsnippet + + diff --git a/custom_snippets/go.snippets b/custom_snippets/go.snippets new file mode 100644 index 0000000..ac56be6 --- /dev/null +++ b/custom_snippets/go.snippets @@ -0,0 +1,64 @@ + +snippet errl "Error log fatal" b + if err != nil { + log.Fatal(err) + } + $0 + + + +# Log error shortcuts +snippet errlp "Error with log.Panic" b + if err != nil { + log.Panic(err) + } + $0 + + +snippet err "if err ..." + if err != nil { + $1 + } + + +snippet lerr "if err ... log.Error" + if err != nil { + log.Error($1) + } + + +snippet lerrf "if err ... log.Error" + if err != nil { + log.Errorf($1) + } + + +snippet msg "api message" + "message": "$1" + + +snippet nnil "if ? != nil" + if $1 != nil { + $2 + } + + +snippet ln "fmt.Println()" + fmt.Println($1) + + +snippet init "init func" + func init(){ + $1 + } + $0 + + + +snippet rget "redis get" + DB.Redis.Do(radix.FlatCmd(${1:target}, "GET", ${2:key})) + + +snippet rset "redis set" i + DB.Redis.Do(radix.FlatCmd(nil, "SET", ${1:key}, ${2:val})) + diff --git a/custom_snippets/lua.snippets b/custom_snippets/lua.snippets new file mode 100644 index 0000000..7cf0ba4 --- /dev/null +++ b/custom_snippets/lua.snippets @@ -0,0 +1,4 @@ +snippet fn + function() + $0 + end diff --git a/custom_snippets/markdown_btw.snippets b/custom_snippets/markdown_btw.snippets new file mode 100644 index 0000000..e37343d --- /dev/null +++ b/custom_snippets/markdown_btw.snippets @@ -0,0 +1,72 @@ +global !p + +from snippet_tools import * + +def expand_link_bottom(snip): + buf = snip.buffer + if snip.tabstop == 0: + vim.command('normal G') + buf.append('[' + snip.tabstops[2].current_text + ']: "' + snip.tabstops[1].current_text + '"') + #snip.expand_anon('$1') +endglobal + +post_jump "expand_link_bottom(snip)" +snippet lnk "Reference Link Inline" +[${1:${VISUAL:name}}][${2:id}] $0 +endsnippet + +snippet ml "Insert math" +{{< ml "${1:${VISUAL:1+1}}" >}} +$0 +endsnippet + +snippet mli "Insert math" +{{< mli "${1:${VISUAL:1+1}}" >}} +$0 +endsnippet + + + +snippet abbr "Abbreviation" +{{< abbr "${1:${VISUAL:abbr}}" "$2" >}} +endsnippet + +snippet footnote "Footnote" +{{< footnote >}} +${1:${VISUAL:footenote}} +{{< /footnote >}} +$0 +endsnippet + +snippet btc# "bitcoin issue" i +[#${1:${VISUAL:number}}](https://github.com/bitcoin/bitcoin/issues/$1) +endsnippet + +snippet btc## "bitcoin issue shortcut" +{{< ghi ${1:${VISUAL:number}} >}} +endsnippet + + + +snippet bip "Bitcoin Improvement Proposal" i +https://github.com/bitcoin/bips/blob/master/bip-${1:${VISUAL:0001}}.mediawiki +endsnippet + +snippet slip "SatoshiLabs Improvement Proposal" i +https://github.com/satoshilabs/slips/blob/master/slip-${1:${VISUAL:0001}}.md +endsnippet + +snippet lnd# "LND Issue" i +[#${1:${VISUAL:42}}](https://github.com/lightningnetwork/lnd/issues/$1) +endsnippet + +snippet cl# "c-lightning issue" i +[#${1:${VISUAL:42}}](https://github.com/ElementsProject/lightning/issues/$1) +endsnippet + +snippet hl "highlight" +{{< highlight $1 >}} + $2 +{{< /highlight >}} +$0 +endsnippet diff --git a/custom_snippets/markdown_zk.snippets b/custom_snippets/markdown_zk.snippets new file mode 100644 index 0000000..44ee3c9 --- /dev/null +++ b/custom_snippets/markdown_zk.snippets @@ -0,0 +1,3 @@ + +snippet li "zk link to note" + [${1:${VISUAL:name}}](${2:id}) $0 diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index fb0a5a6..3ca0ac0 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -132,7 +132,7 @@ M.general = { --{{{ -- luasnip edit snippets - ["se"] = { + ["sne"] = { function() require("luasnip.loaders").edit_snippet_files() end, diff --git a/lua/custom/plugins/configs/leap.lua b/lua/custom/plugins/configs/leap.lua new file mode 100644 index 0000000..53d99a5 --- /dev/null +++ b/lua/custom/plugins/configs/leap.lua @@ -0,0 +1,8 @@ +local present, leap = pcall(require, "leap") +if not present then + return +end + +leap.set_default_keymaps() +leap.opts.special_keys.next_match = "" +leap.opts.special_keys.prev_match = "" diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 72b9691..019abe7 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -149,10 +149,15 @@ return { keys = {"."}, }, - ["justinmk/vim-sneak"] = { - lock = true, - keys = {"s", "S"}, + ["ggandor/leap.nvim"] = { + config = function() + require "custom.plugins.configs.leap" + end }, + -- ["justinmk/vim-sneak"] = { + -- lock = true, + -- keys = {"s", "S"}, + -- }, ["tpope/vim-surround"] = {}, ["godlygeek/tabular"] = { cmd = "Tabularize"