diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index 8266e52b6..a490d77b0 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -45,8 +45,18 @@ end -- Notes -- if f.is_available("zk-nvim") then maps.n["n"] = M.sections.n - maps.n["ni"] = { require("zk.commands").get("ZkIndex"), desc = "Index Notes" } - maps.n["nn"] = { require("zk.commands").get("ZkIndex"), desc = "Index Notes" } + maps.n["nn"] = { + function() require("zk").new({ notebook_path = vim.g.wikidir, title = vim.fn.input('Title: ') }) end, + desc = "New Note" + } + maps.n["no"] = { + function() require("zk").edit({ notebook_path = vim.g.wikidir }) end, + desc = "Open Note" + } + maps.n["ni"] = { + function() require("zk").index({ notebook_path = vim.g.wikidir }) end, + desc = "Index Notes" + } end -- Window Navigation -- @@ -180,7 +190,11 @@ if f.is_available("telescope.nvim") then maps.n["fr"] = { function() require("telescope.builtin").registers() end, desc = "Find registers" } maps.n["fw"] = { function() require("telescope.builtin").live_grep() end, desc = "Find words" } -- maps.n["fb"] = { function() require("telescope.builtin").buffers() end, desc = "Find buffers" } - maps.n["ft"] = { function() require("telescope").extensions["todo-comments"].todo() end, desc = "Find buffers" } + maps.n["ft"] = { + function() require("telescope").extensions["todo-comments"].todo() end, + desc = + "Find buffers" + } maps.n["fW"] = { function() require("telescope.builtin").live_grep({ diff --git a/.config/nvim/lua/config/lsp.lua b/.config/nvim/lua/config/lsp.lua index e39e1b00a..399504369 100644 --- a/.config/nvim/lua/config/lsp.lua +++ b/.config/nvim/lua/config/lsp.lua @@ -16,7 +16,7 @@ conf.handlers["bashls"] = { } } -conf.required = { "lua_ls" } +conf.required = { "lua_ls", "zk" } conf.ignore = { "rust_analyzer" } -- This will be setup by rustacean.nvim return conf diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua index a632a3c9c..8b733597a 100644 --- a/.config/nvim/lua/config/options.lua +++ b/.config/nvim/lua/config/options.lua @@ -2,6 +2,7 @@ local g = vim.g local o = vim.opt local d = vim.diagnostic.config +g.wikidir = os.getenv("XDG_DOCUMENTS_DIR") .. "/wiki" g.mapleader = " " g.maplocalleader = " " g.vim_json_conceal = 0 diff --git a/.config/nvim/lua/funcs.lua b/.config/nvim/lua/funcs.lua index cf845e20b..11009ee9f 100644 --- a/.config/nvim/lua/funcs.lua +++ b/.config/nvim/lua/funcs.lua @@ -212,46 +212,46 @@ end function M.lsp_on_attach(client, bufnr) local lsp_mappings = M.empty_map_table() - lsp_mappings.n["ld"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" } + lsp_mappings.n["ld"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" } lsp_mappings.n["[d"] = { function() vim.diagnostic.goto_prev() end, desc = "Previous diagnostic" } lsp_mappings.n["]d"] = { function() vim.diagnostic.goto_next() end, desc = "Next diagnostic" } lsp_mappings.n["gl"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" } if M.is_available("telescope.nvim") then - lsp_mappings.n["lD"] = { + lsp_mappings.n["lD"] = { function() require("telescope.builtin").diagnostics() end, desc = "Search diagnostics", } end if M.is_available("mason-lspconfig.nvim") then - lsp_mappings.n["li"] = { "LspInfo", desc = "LSP information" } + lsp_mappings.n["li"] = { "LspInfo", desc = "LSP information" } end if M.is_available("none-ls.nvim") then - lsp_mappings.n["lI"] = { "NullLsInfo", desc = "Null-ls information" } + lsp_mappings.n["lI"] = { "NullLsInfo", desc = "Null-ls information" } end if client.supports_method("textDocument/codeAction") then - lsp_mappings.n["la"] = { + lsp_mappings.n["la"] = { function() vim.lsp.buf.code_action() end, desc = "Code action", } - lsp_mappings.v["la"] = lsp_mappings.n["la"] + lsp_mappings.v["la"] = lsp_mappings.n["la"] end if client.supports_method("textDocument/codeLens") then vim.lsp.codelens.refresh() - lsp_mappings.n["ll"] = { + lsp_mappings.n["ll"] = { function() vim.lsp.codelens.refresh() end, desc = "Refresh CodeLens", } - lsp_mappings.n["lL"] = { + lsp_mappings.n["lL"] = { function() vim.lsp.codelens.run() end, desc = "Run CodeLens", } lsp_mappings.n["u"] = { desc = icons.Gear .. " Utility" } - lsp_mappings.n["uL"] = { + lsp_mappings.n["uL"] = { function() vim.lsp.codelens.clear() end, desc = "Toggle CodeLens" } @@ -293,14 +293,14 @@ function M.lsp_on_attach(client, bufnr) end if client.supports_method "workspace/symbol" then - lsp_mappings.n["lG"] = { + lsp_mappings.n["lG"] = { function() vim.lsp.buf.workspace_symbol() end, desc = "List symbols" } end if client.supports_method "textDocument/rename" then - lsp_mappings.n["lr"] = { + lsp_mappings.n["lr"] = { function() vim.lsp.buf.rename() end, desc = "Rename symbol", } @@ -310,7 +310,7 @@ function M.lsp_on_attach(client, bufnr) if client.supports_method "textDocument/semanticTokens/full" and vim.lsp.semantic_tokens then vim.b[bufnr].semantic_tokens_enabled = true lsp_mappings.n["u"] = { desc = icons.Gear .. " Utility" } - lsp_mappings.n["uY"] = { + lsp_mappings.n["uY"] = { function() vim.b[bufnr].semantic_tokens_enabled = not vim.b[bufnr].semantic_tokens_enabled for _, active_client in ipairs(vim.lsp.get_active_clients { bufnr = bufnr }) do @@ -325,7 +325,7 @@ function M.lsp_on_attach(client, bufnr) end if client.supports_method("textDocument/formatting") then - lsp_mappings.n["lf"] = { + lsp_mappings.n["lf"] = { function() vim.lsp.buf.format({ filter = function(c) @@ -343,7 +343,7 @@ function M.lsp_on_attach(client, bufnr) end, desc = "Format buffer", } - lsp_mappings.v["lf"] = lsp_mappings.n["lf"] + lsp_mappings.v["lf"] = lsp_mappings.n["lf"] end if client.supports_method("textDocument/documentHighlight") then @@ -383,7 +383,7 @@ function M.lsp_on_attach(client, bufnr) if vim.lsp.inlay_hint then if vim.b.inlay_hints_enabled then vim.lsp.inlay_hint.enable(bufnr, true) end lsp_mappings.n["u"] = { desc = icons.Gear .. " Utility" } - lsp_mappings.n["uH"] = { + lsp_mappings.n["uH"] = { function() vim.b[bufnr].inlay_hints_enabled = not vim.b[bufnr].inlay_hints_enabled if vim.lsp.inlay_hint then @@ -396,7 +396,7 @@ function M.lsp_on_attach(client, bufnr) end if client.supports_method "textDocument/signatureHelp" then - lsp_mappings.n["lh"] = { + lsp_mappings.n["lh"] = { function() vim.lsp.buf.signature_help() end, desc = "Signature help", } @@ -412,14 +412,14 @@ function M.lsp_on_attach(client, bufnr) if lsp_mappings.n.gr then lsp_mappings.n.gr[1] = function() require("telescope.builtin").lsp_references() end end - if lsp_mappings.n["lR"] then - lsp_mappings.n["lR"][1] = function() require("telescope.builtin").lsp_references() end + if lsp_mappings.n["lR"] then + lsp_mappings.n["lR"][1] = function() require("telescope.builtin").lsp_references() end end if lsp_mappings.n.gy then lsp_mappings.n.gy[1] = function() require("telescope.builtin").lsp_type_definitions() end end - if lsp_mappings.n["lG"] then - lsp_mappings.n["lG"][1] = function() + if lsp_mappings.n["lG"] then + lsp_mappings.n["lG"][1] = function() vim.ui.input({ prompt = "Symbol Query: (leave empty for word under cursor)" }, function(query) if query then -- word under cursor if given query is empty @@ -435,14 +435,14 @@ function M.lsp_on_attach(client, bufnr) end if not vim.tbl_isempty(lsp_mappings.v) then - if lsp_mappings.v["l"] then lsp_mappings.v["l"] = { desc = icons.Code .. " LSP" } end - if lsp_mappings.v["u"] then lsp_mappings.v["u"] = { desc = icons.Code .. " LSP" } end + if lsp_mappings.v["l"] then lsp_mappings.v["l"] = { desc = icons.Code .. " LSP" } end + if lsp_mappings.v["u"] then lsp_mappings.v["u"] = { desc = icons.Code .. " LSP" } end end M.set_maps(lsp_mappings, { buffer = bufnr }) end -function M.has_value (table, value) +function M.has_value(table, value) for _, v in ipairs(table) do if v == value then return true diff --git a/.config/nvim/lua/plugins/misc/init.lua b/.config/nvim/lua/plugins/misc/init.lua index df5e429d6..c1e3e1474 100644 --- a/.config/nvim/lua/plugins/misc/init.lua +++ b/.config/nvim/lua/plugins/misc/init.lua @@ -25,5 +25,4 @@ return { require('plugins.misc.ufo'), require('plugins.misc.vimtex'), require('plugins.misc.which-key'), - require('plugins.misc.wiki'), } diff --git a/.config/nvim/lua/plugins/misc/wiki.lua b/.config/nvim/lua/plugins/misc/wiki.lua deleted file mode 100644 index c69e42eb2..000000000 --- a/.config/nvim/lua/plugins/misc/wiki.lua +++ /dev/null @@ -1,16 +0,0 @@ -local M = { "lervag/wiki.vim" } - -M.cmd = { - "WikiIndex", - "WikiJournal", - "WikiPages", - "WikiTags", - "WikiToc", - "WikiTocGenerate", -} - -M.init = function() - vim.g.wiki_root = "~/Documents/wiki" -end - -return M