diff --git a/nvim/.config/nvim/lua/config/zk.lua b/nvim/.config/nvim/lua/config/zk.lua new file mode 100644 index 0000000..b3b69fb --- /dev/null +++ b/nvim/.config/nvim/lua/config/zk.lua @@ -0,0 +1,52 @@ +local zk_status_ok, zk = pcall(require, "zk") +if not zk_status_ok then + return +end + +zk.setup({ + picker = "telescope", + lsp = { + -- `config` is passed to `vim.lsp.start_client(config)` + config = { + cmd = { "zk", "lsp" }, + name = "zk", + -- on_attach = ... + -- etc, see `:h vim.lsp.start_client()` + }, + + -- automatically attach buffers in a zk notebook that match the given filetypes + auto_attach = { + enabled = true, + filetypes = { "markdown" }, + }, + }, +}) + +local opts = { noremap=true, silent=false } + +-- Create a new note after asking for its title. +vim.api.nvim_set_keymap("n", "zn", "ZkNew { title = vim.fn.input('Title: ') }", opts) +vim.api.nvim_set_keymap("n", "za", "ZkNew { title = vim.fn.input('Title: '), dir = 'atoms'}", opts) +vim.api.nvim_set_keymap("n", "zm", "ZkNew { title = vim.fn.input('Title: '), dir = 'molecules'}", opts) + +-- Open notes. +vim.api.nvim_set_keymap("n", "zo", "ZkNotes { sort = { 'modified' } }", opts) +-- Open notes associated with the selected tags. +vim.api.nvim_set_keymap("n", "zt", "ZkTags", opts) + +-- Search for the notes matching a given query. +vim.api.nvim_set_keymap("n", "zf", "ZkNotes { sort = { 'modified' }, match = vim.fn.input('Search: ') }", opts) +-- Search for the notes matching the current visual selection. +vim.api.nvim_set_keymap("v", "zf", ":'<,'>ZkMatch", opts) + +-- Open notes linking to the current buffer. +vim.api.nvim_set_keymap("n", "zb", "ZkBacklinks", opts) +-- Alternative for backlinks using pure LSP and showing the source context. +--map('n', 'zb', 'lua vim.lsp.buf.references()', opts) +-- Open notes linked by the current buffer. +vim.api.nvim_set_keymap("n", "zl", "ZkLinks", opts) + +-- Preview a linked note. +vim.api.nvim_set_keymap("n", "K", "lua vim.lsp.buf.hover()", opts) +-- Open the code actions for a visual selection. +vim.api.nvim_set_keymap("v", "za", ":'<,'>lua vim.lsp.buf.code_action()", opts) diff --git a/nvim/.config/nvim/vsnips/telekasten.json b/nvim/.config/nvim/vsnips/telekasten.json new file mode 100644 index 0000000..030b6e3 --- /dev/null +++ b/nvim/.config/nvim/vsnips/telekasten.json @@ -0,0 +1,380 @@ +{ + "header 1": { + "prefix": "h1", + "body": ["# ${0}"], + "description": "Add header level 1" + }, + "header 2": { + "prefix": "h2", + "body": ["## ${0}"], + "description": "Add header level 2" + }, + "header 3": { + "prefix": "h3", + "body": ["### ${0}"], + "description": "Add header level 3" + }, + "header 4": { + "prefix": "h4", + "body": ["#### ${0}"], + "description": "Add header level 4" + }, + "header 5": { + "prefix": "h5", + "body": ["##### ${0}"], + "description": "Add header level 5" + }, + "header 6": { + "prefix": "h6", + "body": ["###### ${0}"], + "description": "Add header level 6" + }, + "Links": { + "prefix": ["l", "link"], + "body": ["[${1}](${2}) ${0}"], + "description": "Add links" + }, + "URLS": { + "prefix": ["u", "url"], + "body": ["<${1}> ${0}"], + "description": "Add urls" + }, + "Images": { + "prefix": "img", + "body": ["![${1}](${2}) ${0}"], + "description": "Add images" + }, + "Insert strikethrough": { + "prefix": "strikethrough", + "body": "~~${1}~~ ${0}", + "description": "Insert strikethrough" + }, + "Insert bold text": { + "prefix": ["bold", "b"], + "body": "**${1}** $0", + "description": "Insert bold text" + }, + "Insert italic text": { + "prefix": ["i", "italic"], + "body": "*${1}* $0", + "description": "Insert italic text" + }, + "Insert bold and italic text": { + "prefix": ["bold and italic", "bi"], + "body": "***${1}*** $0", + "description": "Insert bold and italic text" + }, + "Insert quoted text": { + "prefix": "quote", + "body": "> ${1}", + "description": "Insert quoted text" + }, + "Insert code": { + "prefix": "code", + "body": "`${1}` $0", + "description": "Insert code" + }, + "Insert code block": { + "prefix": "codeblock", + "body": ["```${1:language}", "$0", "```"], + "description": "Insert fenced code block" + }, + "Insert unordered list": { + "prefix": "unordered list", + "body": ["- ${1:first}", "- ${2:second}", "- ${3:third}", "$0"], + "description": "Insert unordered list" + }, + "Insert ordered list": { + "prefix": "ordered list", + "body": ["1. ${1:first}", "2. ${2:second}", "3. ${3:third}", "$0"], + "description": "Insert ordered list" + }, + "Insert horizontal rule": { + "prefix": "horizontal rule", + "body": "----------\n", + "description": "Insert horizontal rule" + }, + "Insert task list": { + "prefix": "task", + "body": ["- [${1| ,x|}] ${2:text}", "${0}"], + "description": "Insert task list" + }, + "Insert task list 2": { + "prefix": "task2", + "body": ["- [${1| ,x|}] ${2:text}", "- [${3| ,x|}] ${4:text}", "${0}"], + "description": "Insert task list with 2 tasks" + }, + "Insert task list 3": { + "prefix": "task3", + "body": [ + "- [${1| ,x|}] ${2:text}", + "- [${3| ,x|}] ${4:text}", + "- [${5| ,x|}] ${6:text}", + "${0}" + ], + "description": "Insert task list with 3 tasks" + }, + "Insert task list 4": { + "prefix": "task4", + "body": [ + "- [${1| ,x|}] ${2:text}", + "- [${3| ,x|}] ${4:text}", + "- [${5| ,x|}] ${6:text}", + "- [${7| ,x|}] ${8:text}", + "${0}" + ], + "description": "Insert task list with 4 tasks" + }, + "Insert task list 5": { + "prefix": "task5", + "body": [ + "- [${1| ,x|}] ${2:text}", + "- [${3| ,x|}] ${4:text}", + "- [${5| ,x|}] ${6:text}", + "- [${7| ,x|}] ${8:text}", + "- [${9| ,x|}] ${10:text}", + "${0}" + ], + "description": "Insert task list with 5 tasks" + }, + "Insert table": { + "prefix": "table", + "body": [ + "| ${1:Column1} | ${2:Column2} | ${3:Column3} |", + "|-------------- | -------------- | -------------- |", + "| ${4:Item1} | ${5:Item1} | ${6:Item1} |", + "${0}" + ], + "description": "Insert table with 2 rows and 3 columns. First row is heading." + }, + "Insert 2x1 table": { + "prefix": "2x1table", + "body": [ + "| ${1:Column1} |", + "|-------------- |", + "| ${2:Item1} |", + "${0}" + ], + "description": "Insert table with 2 rows and 1 column. First row is heading." + }, + "Insert 3x1 table": { + "prefix": "3x1table", + "body": [ + "| ${1:Column1} |", + "|-------------- |", + "| ${2:Item1} |", + "| ${3:Item2} |", + "${0}" + ], + "description": "Insert table with 3 rows and 1 column. First row is heading." + }, + "Insert 4x1 table": { + "prefix": "4x1table", + "body": [ + "| ${1:Column1} |", + "|-------------- |", + "| ${2:Item1} |", + "| ${3:Item2} |", + "| ${4:Item3} |", + "${0}" + ], + "description": "Insert table with 4 rows and 1 column. First row is heading." + }, + "Insert 5x1 table": { + "prefix": "5x1table", + "body": [ + "| ${1:Column1} |", + "|-------------- |", + "| ${2:Item1} |", + "| ${3:Item2} |", + "| ${4:Item3} |", + "| ${5:Item4} |", + "${0}" + ], + "description": "Insert table with 5 rows and 1 column. First row is heading." + }, + "Insert 2x2 table": { + "prefix": "2x2table", + "body": [ + "| ${1:Column1} | ${2:Column2} |", + "|--------------- | --------------- |", + "| ${3:Item1.1} | ${4:Item2.1} |", + "${0}" + ], + "description": "Insert table with 2 rows and 2 columns. First row is heading." + }, + "Insert 3x2 table": { + "prefix": "3x2table", + "body": [ + "| ${1:Column1} | ${2:Column2} |", + "|--------------- | --------------- |", + "| ${3:Item1.1} | ${4:Item2.1} |", + "| ${5:Item1.2} | ${6:Item2.2} |", + "${0}" + ], + "description": "Insert table with 3 rows and 2 columns. First row is heading." + }, + "Insert 4x2 table": { + "prefix": "4x2table", + "body": [ + "| ${1:Column1} | ${2:Column2} |", + "|--------------- | --------------- |", + "| ${3:Item1.1} | ${4:Item2.1} |", + "| ${5:Item1.2} | ${6:Item2.2} |", + "| ${7:Item1.3} | ${8:Item2.3} |", + "${0}" + ], + "description": "Insert table with 4 rows and 2 columns. First row is heading." + }, + "Insert 5x2 table": { + "prefix": "5x2table", + "body": [ + "| ${1:Column1} | ${2:Column2} |", + "|--------------- | --------------- |", + "| ${3:Item1.1} | ${4:Item2.1} |", + "| ${4:Item1.2} | ${5:Item2.2} |", + "| ${6:Item1.3} | ${7:Item2.3} |", + "| ${8:Item1.4} | ${9:Item2.4} |", + "${0}" + ], + "description": "Insert table with 5 rows and 2 columns. First row is heading." + }, + "Insert 2x3 table": { + "prefix": "2x3table", + "body": [ + "| ${1:Column1} | ${2:Column2} | ${3:Column3} |", + "|---------------- | --------------- | --------------- |", + "| ${4:Item1.1} | ${5:Item2.1} | ${6:Item3.1} |", + "${0}" + ], + "description": "Insert table with 2 rows and 3 columns. First row is heading." + }, + "Insert 3x3 table": { + "prefix": "3x3table", + "body": [ + "| ${1:Column1} | ${2:Column2} | ${3:Column3} |", + "|---------------- | --------------- | --------------- |", + "| ${4:Item1.1} | ${5:Item2.1} | ${6:Item3.1} |", + "| ${7:Item1.2} | ${8:Item2.2} | ${9:Item3.2} |", + "${0}" + ], + "description": "Insert table with 3 rows and 3 columns. First row is heading." + }, + "Insert 4x3 table": { + "prefix": "4x3table", + "body": [ + "| ${1:Column1} | ${2:Column2} | ${3:Column3} |", + "|---------------- | --------------- | --------------- |", + "| ${4:Item1.1} | ${5:Item2.1} | ${6:Item3.1} |", + "| ${7:Item1.2} | ${8:Item2.2} | ${9:Item3.2} |", + "| ${10:Item1.3} | ${11:Item2.3} | ${12:Item3.3} |", + "${0}" + ], + "description": "Insert table with 4 rows and 3 columns. First row is heading." + }, + "Insert 5x3 table": { + "prefix": "5x3table", + "body": [ + "| ${1:Column1} | ${2:Column2} | ${3:Column3} |", + "|---------------- | --------------- | --------------- |", + "| ${4:Item1.1} | ${5:Item2.1} | ${6:Item3.1} |", + "| ${7:Item1.2} | ${8:Item2.2} | ${9:Item3.2} |", + "| ${10:Item1.3} | ${11:Item2.3} | ${12:Item3.3} |", + "| ${13:Item1.4} | ${14:Item2.4} | ${15:Item3.4} |", + "${0}" + ], + "description": "Insert table with 5 rows and 3 columns. First row is heading." + }, + "Insert 2x4 table": { + "prefix": "2x4table", + "body": [ + "| ${1:Column1} | ${2:Column2} | ${3:Column3} | ${4:Column4} |", + "|---------------- | --------------- | --------------- | --------------- |", + "| ${5:Item1.1} | ${6:Item2.1} | ${7:Item3.1} | ${8:Item4.1} |", + "${0}" + ], + "description": "Insert table with 2 rows and 4 columns. First row is heading." + }, + "Insert 3x4 table": { + "prefix": "3x4table", + "body": [ + "| ${1:Column1} | ${2:Column2} | ${3:Column3} | ${4:Column4} |", + "|---------------- | --------------- | --------------- | --------------- |", + "| ${5:Item1.1} | ${6:Item2.1} | ${7:Item3.1} | ${8:Item4.1} |", + "| ${9:Item1.2} | ${10:Item2.2} | ${11:Item3.2} | ${12:Item4.2} |", + "${0}" + ], + "description": "Insert table with 3 rows and 4 columns. First row is heading." + }, + "Insert 4x4 table": { + "prefix": "4x4table", + "body": [ + "| ${1:Column1} | ${2:Column2} | ${3:Column3} | ${4:Column4} |", + "|---------------- | --------------- | --------------- | --------------- |", + "| ${5:Item1.1} | ${6:Item2.1} | ${7:Item3.1} | ${8:Item4.1} |", + "| ${9:Item1.2} | ${10:Item2.2} | ${11:Item3.2} | ${12:Item4.2} |", + "| ${13:Item1.3} | ${14:Item2.3} | ${15:Item3.3} | ${16:Item4.3} |", + "${0}" + ], + "description": "Insert table with 4 rows and 4 columns. First row is heading." + }, + "Insert 5x4 table": { + "prefix": "5x4table", + "body": [ + "| ${1:Column1} | ${2:Column2} | ${3:Column3} | ${4:Column4} |", + "|---------------- | --------------- | --------------- | --------------- |", + "| ${5:Item1.1} | ${6:Item2.1} | ${7:Item3.1} | ${8:Item4.1} |", + "| ${9:Item1.2} | ${10:Item2.2} | ${11:Item3.2} | ${12:Item4.2} |", + "| ${13:Item1.3} | ${14:Item2.3} | ${15:Item3.3} | ${16:Item4.3} |", + "| ${17:Item1.4} | ${18:Item2.4} | ${19:Item3.4} | ${20:Item4.4} |", + "${0}" + ], + "description": "Insert table with 5 rows and 4 columns. First row is heading." + }, + "Insert 2x5 table": { + "prefix": "2x5table", + "body": [ + "| ${1:Column1} | ${2:Column2} | ${3:Column3} | ${4:Column4} | ${5:Column5} |", + "|---------------- | --------------- | --------------- | --------------- | --------------- |", + "| ${6:Item1.1} | ${7:Item2.1} | ${8:Item3.1} | ${9:Item4.1} | ${10:Item5.1} |", + "${0}" + ], + "description": "Insert table with 2 rows and 5 columns. First row is heading." + }, + "Insert 3x5 table": { + "prefix": "3x5table", + "body": [ + "| ${1:Column1} | ${2:Column2} | ${3:Column3} | ${4:Column4} | ${5:Column5} |", + "|---------------- | --------------- | --------------- | --------------- | --------------- |", + "| ${6:Item1.1} | ${7:Item2.1} | ${8:Item3.1} | ${9:Item4.1} | ${10:Item5.1} |", + "| ${11:Item1.2} | ${12:Item2.2} | ${13:Item3.2} | ${14:Item4.2} | ${15:Item5.2} |", + "${0}" + ], + "description": "Insert table with 3 rows and 5 columns. First row is heading." + }, + "Insert 4x5 table": { + "prefix": "4x5table", + "body": [ + "| ${1:Column1} | ${2:Column2} | ${3:Column3} | ${4:Column4} | ${5:Column5} |", + "|---------------- | --------------- | --------------- | --------------- | --------------- |", + "| ${6:Item1.1} | ${7:Item2.1} | ${8:Item3.1} | ${9:Item4.1} | ${10:Item5.1} |", + "| ${11:Item1.2} | ${12:Item2.2} | ${13:Item3.2} | ${14:Item4.2} | ${15:Item5.2} |", + "| ${16:Item1.3} | ${17:Item2.3} | ${18:Item3.3} | ${19:Item4.3} | ${20:Item5.3} |", + "${0}" + ], + "description": "Insert table with 4 rows and 5 columns. First row is heading." + }, + "Insert 5x5 table": { + "prefix": "5x5table", + "body": [ + "| ${1:Column1} | ${2:Column2} | ${3:Column3} | ${4:Column4} | ${5:Column5} |", + "|---------------- | --------------- | --------------- | --------------- | --------------- |", + "| ${6:Item1.1} | ${7:Item2.1} | ${8:Item3.1} | ${9:Item4.1} | ${10:Item5.1} |", + "| ${11:Item1.2} | ${12:Item2.2} | ${13:Item3.2} | ${14:Item4.2} | ${15:Item5.2} |", + "| ${16:Item1.3} | ${17:Item2.3} | ${18:Item3.3} | ${19:Item4.3} | ${20:Item5.3} |", + "| ${21:Item1.4} | ${22:Item2.4} | ${23:Item3.4} | ${24:Item4.4} | ${25:Item5.4} |", + "${0}" + ], + "description": "Insert table with 5 rows and 5 columns. First row is heading." + } +}